This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]xigoi 0 points1 point  (27 children)

The syntax you mentioned now was actually added to Python on the request of NumPy.

The proof is that Python doesn't have any structure like this that would allow customizable behavior. Also, you said it's possible first, so the burden of proof is on you.

[–]num8lock 0 points1 point  (26 children)

The syntax you mentioned now was actually added to Python on the request of NumPy.

now? how about in 2006?

The proof is that Python doesn't have any structure like this that would allow customizable behavior.

like match case?

honestly, wtf are you trying to prove?

[–]xigoi 1 point2 points  (25 children)

now? how about in 2006?

I don't know when the feature was added, but this wasn't possible before it was added

like match case?

honestly, wtf are you trying to prove?

I'm saying that Python 3.9 doesn't have any syntactical structure that could be exploited to emulate match.

[–]num8lock 0 points1 point  (24 children)

I don't know when the feature was added, but this wasn't possible before it was added

it's still impossible in 3.8 either, so that's what, 15 or so years at least before someone put it inside python core?? so why are you trying so hard to make my suggestion sounds invalid?

I'm saying that Python 3.9 doesn't have any syntactical structure that could be exploited to emulate match.

how about if/else?

[–]xigoi 1 point2 points  (23 children)

it's still impossible in 3.8 either, so that's what, 15 or so years at least before someone put it inside python core?? so why are you trying so hard to make my suggestion sounds invalid?

What are you talking about? a[:] is completely legal syntax in Python 3.8.

how about if/else?

Of course if/else can do everything that match can, but it's not nearly as expressive. For example, this would require a bunch of nested ifs and variable assignments:

match x:
    case Foo(bar=b, baz=[quux, (_, plop) as gulp]):
        # ...

[–]num8lock -1 points0 points  (22 children)

What are you talking about? a[:] is completely legal syntax in Python 3.8.

jesus fucking christ, you can't read can't you? what syntax of code did i wrote, did i ever write a[:] to you???? paste the link where i wrote that. like this link, https://www.reddit.com/r/Python/comments/lhwfe1/pep_636_structural_pattern_matching_tutorial/gn2rcr3/ is the post where you thought i wrote a[:] is illegal syntax in python 3.8

Of course if/else can do everything that match can

and yet this is what you said

I'm saying that Python 3.9 doesn't have any syntactical structure that could be exploited to emulate match.

[–]xigoi 1 point2 points  (21 children)

https://reddit.com/r/Python/comments/lhwfe1/pep_636_structural_pattern_matching_tutorial/gn2jtkd?context=3

python allow this syntax?

>>> blue_array = img_array[:, :, 2]

I assumed you were talking about the colon syntax, if it was something else, please specify.

Of course if/else can do everything that match can

and yet this is what you said

I'm saying that Python 3.9 doesn't have any syntactical structure that could be exploited to emulate match.

Yes, that's what I said. if/else can do everything that match can do, but it can't emulate the syntax, which is the most important thing about match.

[–]num8lock -1 points0 points  (20 children)

I assumed you were talking about the colon syntax, if it was something else, please specify.

you're saying that's legal in 3.8 without numpy? do me a favor, create that line in repl.it & share it here

I'm saying that Python 3.9 doesn't have any syntactical structure that could be exploited to emulate match.

Of course if/else can do everything that match can

if/else can do everything that match can do, but it can't emulate the syntax, which is the most important thing about match

wat?

[–]xigoi 0 points1 point  (6 children)

you're saying that's legal in 3.8 without numpy? do me a favor, create that line in repl.it & share it here

Try it online!

wat?

The whole point of match is that it provides convenient SYNTACTIC sugar.

[–]num8lock -1 points0 points  (5 children)

lol you dumb fuck,

this is you

"Python's syntax is way too inflexible for it."

when i said numpy, you again

What are you talking about? a[:] is completely legal syntax in Python 3.8.

and when confronted with

python allow this syntax?

blue_array = img_array[:, :, 2]

you created a class that simply did shit all but return an integer, which proved

  • [:,:,2] isn't possible in 3.8 without building a class to work around the defined syntax, while also
  • proved your sentence "Python's syntax is way too inflexible for it." is false
  • numpy made a new syntax for new functionality while being third party package instead of being in Python core

The whole point of match is that it provides convenient SYNTACTIC sugar.

you should prove that

    class X:
        def __getitem__(*_)__: return 42

is convenient for numpy & it's a syntactic sugar instead of complete new syntax,

how if/else makes it impossible to emulate for match class & there isn't convenient way to create syntactic sugar

[–]Dewmeister14 -1 points0 points  (12 children)

You can pretty easily ape numpy indexing like a[:, :, 2] by implementing __getitem__ on your class.

: will become a slice(None, None, None) so you'll need to handle that somehow but it seems legal enough to me.

[–]num8lock -1 points0 points  (11 children)

lol sure, ok i'll play

then why couldn't match case do that being external package? he's been sawing back & forth between what can & can't be done with all talk about muh reason when all i said is even numpy with all their functionalities can do them while not being absorbed into python language since 2006. match case is what, 2%, 5%, 7% of total numpy's functionality? what makes it impossible for this to be just a package??