Live data from Hacker News

What's Coming in Python 3.8

lwn.net

121–130 of 558 posts

Re: What's Coming in Python 3.8

#121
post #86

I long for a language which has a basic featureset, and then "freezes", and no longer adds any more language features. You may continue working on the standard library, optimizing, etc. Just no new language features. In my opinion, someone should be able to learn all of a language in a few days, including every corner case and oddity, and then understand any code. If new language features get added over time, eventua…

Isn't that what C is?

Certainly Common Lisp.

Re: What's Coming in Python 3.8

#122
post #5

Walrus operator looks like a great addition, not too much syntax sugar for a common pattern. Why were folks arguing about it?

I don't know how you read it - 'if x is assigned the value y'? Most other things in Python can just be read out loud.

'If x, which is y' maybe?

Re: What's Coming in Python 3.8

#123

I long for a language which has a basic featureset, and then "freezes", and no longer adds any more language features. You may continue working on the standard library, optimizing, etc. Just no new language features. In my opinion, someone should be able to learn all of a language in a few days, including every corner case and oddity, and then understand any code. If new language features get added over time, eventua…

Python 2.7 is not far from that language.

Re: What's Coming in Python 3.8

#124

I long for a language which has a basic featureset, and then "freezes", and no longer adds any more language features. You may continue working on the standard library, optimizing, etc. Just no new language features. In my opinion, someone should be able to learn all of a language in a few days, including every corner case and oddity, and then understand any code. If new language features get added over time, eventua…

remember the gang of four book? such books happen when the language is incapable of expressing ideas concisely. complexity gets pushed to libraries which you have to understand anyway. i'd rather have syntax for the visitor pattern or whatever else is there.

Re: What's Coming in Python 3.8

#125

Earlier quoted context omitted.

Oh come on, it doesn't.

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…

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

#126
post #62

Earlier quoted context omitted.

I see what you're saying, but I kinda like the gets ":=" operator.

But now there are two ways to do assignment. That's not very pythonic, is it?

You think that's bad? Check out:

    a = 17
    print("a=", a)
    print("a=" + str(a))
    print("a=%s" % a)
    print("a={}".format(a))
    print(f"a={a}") 
    # python 3.8 =>
    print(f"{a=}")
So many ways to do it...

But, if it sounds like I agree with you, I actually don't. I feel that the Zen of Python has taken on an almost religious level of veneration in people's minds, and leads to all sorts of unproductive debates. One person can latch onto "there should be one obvious way to do it" and another onto "practicality beats purity" and another onto "readability counts." Who's right? All can be. Or none. All could be applied to this particular case.

The Zen of Python is just a set of rough heuristics, and no heuristic or principle in the field of software development applies 100% of the time, IMHO. <= except for this one ;)

Re: What's Coming in Python 3.8

#127
post #5

Walrus operator looks like a great addition, not too much syntax sugar for a common pattern. Why were folks arguing about it?

I don't know how you read it - 'if x is assigned the value y'? Most other things in Python can just be read out loud.

Personally, I think they should have went with `if y as x:` syntax, as I think that makes it clearer what it does

Re: What's Coming in Python 3.8

#128
post #91

Earlier quoted context omitted.

You could read "if x := y()" as "if x gets a truthy value from y()." For what it's worth, "x = y()" is one of the harder things for new programmers to translate to English in the first place -- it reads most naturally as "x equals y," but leads to better intuitions as "x gets the value of y". I think that's what makes this clunky to verbalize, rather than the "if truthy" bit.

So := is 'gets a truthy value from'? That seems to work. > For what it's worth, "x = y()" is one of the harder things for new programmers to translate to English in the first place Right... so why have we added more complexity to something known to be very complicated?

How about "assigns to and returns"?

Re: What's Coming in Python 3.8

#129

Earlier quoted context omitted.

Disagree. In my experience (albeit, not very long, been writing Python since 2007 or so), assigning to a value and checking for truthiness is a very common pattern.

Very common pattern, confusing nonetheless. It does two different things at once where traditionally Python is explicit and only does one thing at once.

This is probably the one argument against it that I agree with: I don't actually like it when I see it in other languages!

Re: What's Coming in Python 3.8

#130
post #91

Earlier quoted context omitted.

You could read "if x := y()" as "if x gets a truthy value from y()." For what it's worth, "x = y()" is one of the harder things for new programmers to translate to English in the first place -- it reads most naturally as "x equals y," but leads to better intuitions as "x gets the value of y". I think that's what makes this clunky to verbalize, rather than the "if truthy" bit.

So := is 'gets a truthy value from'? That seems to work. > For what it's worth, "x = y()" is one of the harder things for new programmers to translate to English in the first place Right... so why have we added more complexity to something known to be very complicated?

we added new syntax for a code pattern that has inherent complexity which can't be reduced.
Post reply on HN