Live data from Hacker News

Python 3.8.0a1 is now available for testing

pythoninsider.blogspot.com

31–40 of 59 posts

Re: Python 3.8.0a1 is now available for testing

#31
post #2

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.

You have causality backwards. The vitriolic backlash to this change is part of why Guido stepped back from Python...

Re: Python 3.8.0a1 is now available for testing

#32
post #14

Earlier 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?

Intuition is defined as being based on what one feels to be true even without conscious reasoning.

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

#33
post #2

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…

if a := 1 or b := 0: return a + b Good luck debugging why this doesn’t work.

This statement returns a syntax error. But I get what you mean. For

  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

#34
post #2

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…

if a := 1 or b := 0: return a + b Good luck debugging why this doesn’t work.

I believe or has higher precedence than := in this case thus the syntax error. Wrapping := in parentheses, like the other commenter suggested, resolves the issue.

Re: Python 3.8.0a1 is now available for testing

#35
post #2

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…

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 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

#36
post #4

Earlier 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...

> 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

#37

Earlier 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...

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

#38
post #37

Earlier 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.)

Thanks, reworded.

Re: Python 3.8.0a1 is now available for testing

#39

Earlier 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…

I am arguing for short circuiting and against assignment expressions returning. You save one line per assignment while also making everything more confusing. Next thing you know we will be debating why a++ is a thing and how it that now returns so you can use it in if statements.

Re: Python 3.8.0a1 is now available for testing

#40
Are assignment expressions the only linguistic change?

For 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).

Post reply on HN