News for hackers. Stuff that matters.
Re:What Is the Switch-Case Equivalent in Python? by neolog on Saturday April 03, 2021 @05:00PM (#26684689)
The walrus operator was definitely a mistake. But type annotations, pattern matching, attrs/dataclasses, and f-strings are significant improvements.
Re:What Is the Switch-Case Equivalent in Python? by jsmeaton on Saturday April 03, 2021 @05:25PM (#26684879)
See though, this is the issue. What you see as a useful or mistaken feature is likely a different set to another user, just as we’ve seen above.

I think it’s a mistake to defer to the zen of python without considering the PEPs themselves which do discuss trade offs. (I’ll note that you didn’t make that claim but GP did).

Re:What Is the Switch-Case Equivalent in Python? by neolog on Saturday April 03, 2021 @05:31PM (#26684920)
Tbh I think a consensus of expert Pythonistas would agree with me. Walrus only got through because of the "dictatorship".
Re:What Is the Switch-Case Equivalent in Python? by jsmeaton on Saturday April 03, 2021 @05:47PM (#26685043)
Perhaps :)

That’s not a hill I’m willing to die on but I agree with the positives from your list.

And the small handful of times I’ve used walrus have been nice, but not game changing.

Re:What Is the Switch-Case Equivalent in Python? by musingsole on Saturday April 03, 2021 @05:53PM (#26685073)
Language features of this type should be nice and not game changing. It's how spoken word languages evolve. If every change was game-changing, it'd only be a few mutations until a dialect became a language in its own right. In reality, you get countless dialects frequently with features that eventually die off and new languages rarely and only in the aggregate.
Re:What Is the Switch-Case Equivalent in Python? by GeorgeTirebiter on Saturday April 03, 2021 @06:10PM (#26685185)
Seems to me the 'sweet spot' for a language is a careful balance of continuing to evolve - slowly, carefully - and to not become so large as to 'not fit into one head'. Python3.9 is not yet at the 'too big for one head'; but 3.xx could be. Perhaps old-style features need to be removed, and only available via some sort of "from __past__ import old-feature-set"
Re:What Is the Switch-Case Equivalent in Python? by musingsole on Saturday April 03, 2021 @06:30PM (#26685321)
It's hard for me to separate a language from what it is used to accomplish, and from that perspective, Python has been far too large to fit in one head for a good long time. Perhaps that is why I don't find any compulsion for language purity.
Re:What Is the Switch-Case Equivalent in Python? by neolog on Sunday April 04, 2021 @02:17AM (#26687319)
> too large to fit in one head

is it? I don't think the core language is that big. The libraries are big of course.

Re:What Is the Switch-Case Equivalent in Python? by pansa2 on Sunday April 04, 2021 @03:31AM (#26687580)
An example of core language complexity: if asked, could you explain what all of these do?

https://twitter.com/raymondh/status/1280988785841278976

Re:What Is the Switch-Case Equivalent in Python? by neolog on Sunday April 04, 2021 @05:44AM (#26688092)
The only one I didn't know was text_signature.
Re:What Is the Switch-Case Equivalent in Python? by neolog on Sunday April 04, 2021 @02:35PM (#26691751)
I'm very curious why is this downvoted?
Re:What Is the Switch-Case Equivalent in Python? by neolog on Saturday April 03, 2021 @06:23PM (#26685277)
They could just deprecate without removing.
Re:What Is the Switch-Case Equivalent in Python? by coldtea on Sunday April 04, 2021 @04:16AM (#26687766)
>Walrus only got through because of the "dictatorship".

Well, then again I wouldn't consider anybody a more expert Pythonista than Guido.

Re:What Is the Switch-Case Equivalent in Python? by neolog on Sunday April 04, 2021 @05:55AM (#26688133)
I can think of some.
Re:What Is the Switch-Case Equivalent in Python? by coldtea on Sunday April 04, 2021 @07:49AM (#26688700)
Such as?
Re:What Is the Switch-Case Equivalent in Python? by neolog on Sunday April 04, 2021 @02:44PM (#26691803)
I don't want to get into that kind of argument, but if you've been in python for a while you can probably think of people.
Re:What Is the Switch-Case Equivalent in Python? by coldtea on Sunday April 04, 2021 @04:16AM (#26687760)
>The walrus operator was definitely a mistake.

Was it tho? It's one of my favorite improvements, and has no actual downside.

Re:What Is the Switch-Case Equivalent in Python? by bobbylarrybobby on Sunday April 04, 2021 @12:59AM (#26687005)
Can you explain why you don’t like the walrus operator? I personally love it.
Re:What Is the Switch-Case Equivalent in Python? by neolog on Sunday April 04, 2021 @02:13AM (#26687307)
- Languages should only make special syntax for very common or very important needs. Neither applies here.

- It violates the longstanding Python rule that assignments don't escape the enclosing scope.

Re:What Is the Switch-Case Equivalent in Python? by smetj on Sunday April 04, 2021 @03:03AM (#26687483)
> It violates the longstanding Python rule that assignments don't escape the enclosing scope.

But doesn't that violate the longstanding Python rule that A Foolish Consistency is the Hobgoblin of Little Minds ?

Re:What Is the Switch-Case Equivalent in Python? by beforeolives on Sunday April 04, 2021 @04:02AM (#26687690)
The trick is tell when striving for consistensy is foolish and when it isn't. Otherwise you would always be able to fall back on this quote to justify creating unuseable code/frameworks/projects/languages.
Re:What Is the Switch-Case Equivalent in Python? by neolog on Sunday April 04, 2021 @03:24AM (#26687553)
No. Assignment leaking into enclosing scope is a bad idea.
Re:What Is the Switch-Case Equivalent in Python? by bobbylarrybobby on Sunday April 04, 2021 @02:15PM (#26691612)
Don’t assignments already escape scope?

if True: x = 1 print(x)

Re:What Is the Switch-Case Equivalent in Python? by neolog on Sunday April 04, 2021 @02:34PM (#26691748)
`if` blocks don't make a scope. Comprehensions do.
Re:What Is the Switch-Case Equivalent in Python? by mixmastamyk on Sunday April 04, 2021 @03:39AM (#26687608)
The "as NAME" phrasing already existed. No need to invent a third confusing colon syntax to assign variables.