/top/
/new/
/best/
/ask/
/show/
/job/
^
slacker news
login
about
←back to thread
PEP 572: Python assignment expressions has been accepted
(groups.google.com)
317 points
est
| 1 comments |
03 Jul 18 08:30 UTC
|
HN request time: 0.001s
|
source
Show context
oooooof
◴[
03 Jul 18 09:00 UTC
]
No.
17448560
[source]
▶
>>17448439 (OP)
#
What is it? The link points to a discussion more deep than I’m willing to read.
replies(10):
>>17448567
#
>>17448570
#
>>17448571
#
>>17448572
#
>>17448575
#
>>17448579
#
>>17448584
#
>>17448591
#
>>17448617
#
>>17448638
#
hultner
◴[
03 Jul 18 09:05 UTC
]
No.
17448584
[source]
▶
>>17448560
#
You're allowed to do assignments inside of expressions
E.g.
if(x:=f() is not None): print(x)
You can read more about it here:
https://www.python.org/dev/peps/pep-0572/
replies(1):
>>17448672
#
majewsky
◴[
03 Jul 18 09:22 UTC
]
No.
17448672
[source]
▶
>>17448584
#
I'm immediately skeptical after seeing this example because I'm not sure if the first line parses as:
if (x := f()) is not None:
or as:
if x := (f() is not None):
replies(2):
>>17448788
#
>>17449070
#
1.
icebraining
◴[
03 Jul 18 09:42 UTC
]
No.
17448788
[source]
▶
>>17448672
#
:= overrules everything except a comma, so it's the latter. Still, I agree it's potentially confusing.
ID:
GO
↑