Notably new is the assignment expressions [1]. This was quite controversial and the battle around it caused Guido to step down as BDFL [2]. I personally think it's quite a nifty feature. I often end up writing something along the lines of: result = do_something() if result: do_more(result) Now that can be expressed as: if result := do_something(): do_more(result) It definitely has the potential to be abused and reduc…
I am already disappointed in post-Guido Python. Although the walrus operator makes enough sense to me, it doesn’t solve anything that I consider a problem so I can’t reason that it was worth going against so much pushback.
Python 3.8.0a1 is now available for testing
31–40 of 59 posts
Re: Python 3.8.0a1 is now available for testing
#32Earlier quoted context omitted.
I agree with you. It's very exciting to remove these sorts of redundant lines, but I cannot train my brain to intuitively view that line as it will be interpreted. There is one case where the benefit, IMHO, far outweighs the negatives, and that can be seen in slides 30-31 of Dustin Ingram's slideshow[1]. PEP 572... the day Python jumped the walrus. 1. https://speakerdeck.com/di_codes/pep-572-the-walrus-operator...
Yes, you can. How do you think your brain learned the original way?
Something that is unnatural, such as an operator mixed with an expression is anything but natural, in the context of Python.
I can force myself to recognize the pattern; yes.
Also, the example I linked to in the slide show does feel somewhat intuitive (usage in a while loop).
Re: Python 3.8.0a1 is now available for testing
#33Notably new is the assignment expressions [1]. This was quite controversial and the battle around it caused Guido to step down as BDFL [2]. I personally think it's quite a nifty feature. I often end up writing something along the lines of: result = do_something() if result: do_more(result) Now that can be expressed as: if result := do_something(): do_more(result) It definitely has the potential to be abused and reduc…
if a := 1 or b := 0: return a + b Good luck debugging why this doesn’t work.
if (a := 1) or (b := 1):
print(locals())
since a is truthy, it gets bound and is in scope, whereas b is not, which makes sense to me.Re: Python 3.8.0a1 is now available for testing
#34Notably new is the assignment expressions [1]. This was quite controversial and the battle around it caused Guido to step down as BDFL [2]. I personally think it's quite a nifty feature. I often end up writing something along the lines of: result = do_something() if result: do_more(result) Now that can be expressed as: if result := do_something(): do_more(result) It definitely has the potential to be abused and reduc…
if a := 1 or b := 0: return a + b Good luck debugging why this doesn’t work.
Re: Python 3.8.0a1 is now available for testing
#35Notably new is the assignment expressions [1]. This was quite controversial and the battle around it caused Guido to step down as BDFL [2]. I personally think it's quite a nifty feature. I often end up writing something along the lines of: result = do_something() if result: do_more(result) Now that can be expressed as: if result := do_something(): do_more(result) It definitely has the potential to be abused and reduc…
if a := 1 or b := 0: return a + b Good luck debugging why this doesn’t work.
So are you arguing that the language should not have short-circuit or-statements?
That just seems like you are sacrificing tons of usability only to slightly improve on the expectations of those who are just starting python, like the first 1-2weeks of trying to learn it.
Re: Python 3.8.0a1 is now available for testing
#36Earlier quoted context omitted.
It is definitely useful, but it severely reduces readability in my opinion. Your example is also a great example for this. The first version in way more readable than the second version with the walrus operator.
I agree with you. It's very exciting to remove these sorts of redundant lines, but I cannot train my brain to intuitively view that line as it will be interpreted. There is one case where the benefit, IMHO, far outweighs the negatives, and that can be seen in slides 30-31 of Dustin Ingram's slideshow[1]. PEP 572... the day Python jumped the walrus. 1. https://speakerdeck.com/di_codes/pep-572-the-walrus-operator...
Direct link: https://speakerd.s3.amazonaws.com/presentations/025e2c4bf551... (s/preview_// for a larger version)
Re: Python 3.8.0a1 is now available for testing
#37Earlier quoted context omitted.
I am already disappointed in post-Guido Python. Although the walrus operator makes enough sense to me, it doesn’t solve anything that I consider a problem so I can’t reason that it was worth going against so much pushback.
You have causality backwards. The vitriolic backlash to this change is part of why Guido stepped back from Python...
(In fact he's just been elected to the five-member council that has taken over that role.)
Re: Python 3.8.0a1 is now available for testing
#38Earlier quoted context omitted.
You have causality backwards. The vitriolic backlash to this change is part of why Guido stepped back from Python...
Note Guido hasn't left Python. He just didn't want to be the sole final-decision-maker any more. (In fact he's just been elected to the five-member council that has taken over that role.)
Re: Python 3.8.0a1 is now available for testing
#39Earlier quoted context omitted.
if a := 1 or b := 0: return a + b Good luck debugging why this doesn’t work.
To understand that you need to understand “if”, “or” and assignment expressions. You think this is hard to understand, and that’s fair, but the hard point here isn’t the assignment expression, it’s the short circuiting or-statement. You’d have the same issues with debugging “if f() or g():...” So are you arguing that the language should not have short-circuit or-statements? That just seems like you are sacrificing to…
Re: Python 3.8.0a1 is now available for testing
#40For years,I've been holding my breath in Python for sum types, totality checking, and an enforced, complete type system -- one where you can say "this should be a list of lists of integers" and it won't let you put any other kind of thing there.
(Yes, there are external typing solutions like PyPy, but last I checked they did not offer complete type systems (you could specify that something is a list, but not that it's a list of ints), nor did they permit totality checking (so if type X is a sum type with two constructors X1 and X2, and f is a function that takes an X as input, and you forgot to define what happens if f is given an X2, it would not know to complain that you hadn't covered all possibilities).