News for hackers. Stuff that matters.
Re:What's Coming in Python 3.8 by sametmax on Wednesday July 17, 2019 @05:29PM (#20464245)
My metric for this is to put some of my freshest student in front of a code and see how they deal with it. How easily can they understand it ? How easily can they write it ? Debug it ?

They are most of the time a fantastic indicator of the cognitive load a feature will add in prod. Because of course a feature doesn't exist in a vacuum, it's always in a more complex context. So what's easy to understand for a student will be alright for a pro in the complexity of real life engineering. And I found the opposite to hold quite often as well.

I haven't tried the walrus on them yet, but I'm pretty sure of the result.

Re:What's Coming in Python 3.8 by llukas on Wednesday July 17, 2019 @06:05PM (#20464523)
> my freshest student in front of a code and see how they deal with it.

That is fine if you want to optimize language for "fresh students". That is not representative how brain process stuff after getting even some experience.

Re:What's Coming in Python 3.8 by mbreese on Wednesday July 17, 2019 @08:43PM (#20465558)
It's not about experience vs inexperience... it's about code readability and being unsurprising.

    m = re.match(...)
    if m:
        ... do something ...
is verbose, but quite readable. Given that it's the way things have been done since forever, it's also unsurprising.

    if m := re.match(...):
        ... do something ...
Without knowing what the walrus operator is, it is not entirely clear what is going on here. := is only syntactic sugar, which is not what Python has ever been about.
Re:What's Coming in Python 3.8 by clinta on Thursday July 18, 2019 @12:04AM (#20466591)
Python already has " as " operator that I think is very readable.

  with open('file') as f:
      ... do something ...
I don't know why that didn't come out on top in the debate.

  if re.match(...) as m:
      ... do something ...
Re:What's Coming in Python 3.8 by owaislone on Wednesday July 17, 2019 @09:19PM (#20465751)
If feel Go solves this in a much more readable way.

    if m := re.match(...); m {
        ... do something ...
    }

Still not as readable as splitting it over multiple lines but quite a lot better than Python's syntax IMO especially once you learn how the if statement works in Go.
Re:What's Coming in Python 3.8 by mkl on Wednesday July 17, 2019 @09:58PM (#20466002)
How is that more readable? It's identical except for ":" -> ";", and some extra symbols added. Needing to repeat "m" seems seems redundant, and particularly bad for readability as it moves the actual condition far away from the "if".
Re:What's Coming in Python 3.8 by owaislone on Friday July 19, 2019 @01:43PM (#20480828)
It is better IMO because it doesn't merge two things into one. It simply translates to `if <assignment>; <condition> { <body> }` as a generic rule. Variable used in condition may or may not be the same one in assignment. Bundling assignment and condition is what people don't like about this feature.
Re:What's Coming in Python 3.8 by sametmax on Thursday July 18, 2019 @03:02AM (#20467450)
It's not, it's correlation between fresh student, and what happens in the field.
Re:What's Coming in Python 3.8 by nerdponx on Wednesday July 17, 2019 @06:02PM (#20464498)
I for one predict that the new operator will appear very sparingly, in while loops and code golf competitions.

There are already so many complicated semantics about mutability, iteration, bytes/strings, scoping, et al. And yet somehow a tiny piece of syntax that finally lets us stop writing "while true/break" is the big pain point?

Re:What's Coming in Python 3.8 by PeterisP on Wednesday July 17, 2019 @08:01PM (#20465333)
I'd expect the new operator to become the idiomatic way to write certain quite common things, for example regexp group matching and objects returned by dictionary .get() - currently you always need a dummy variable to check if it's not None before you use it.
Re:What's Coming in Python 3.8 by upofadown on Wednesday July 17, 2019 @06:27PM (#20464673)
Excess complexity almost always comes in small increments...
Re:What's Coming in Python 3.8 by nerdponx on Wednesday July 17, 2019 @07:57PM (#20465306)
Fair. Fortunately with all the blowback over the walrus operator I don't think we will be seeing any new operators for a long time.