Python handles globals badly.
antoon.pardon at rece.vub.ac.be
Mon Sep 14 09:13:45 CEST 2015
Op 11-09-15 om 13:59 schreef Marko Rauhamaa:
> Antoon Pardon <antoon.pardon at rece.vub.ac.be>:
>> I just don't get why people want to introduce special cases in python.
>> Why allow such a construct only in while and if? Why not just allow
>> it generally as an assignment expression?
>> Why not allow:
>> while (f(x) as fx) > 5:
>> if check(nextvalue() as new):
> Hey, I know, I know!... Let's allow:
> while (fx = f(x)) > 5:
> if check(new = nextvalue()):
> Seriously, though, I share your distaste of special cases, Antoon. Only
> I don't like too much syntax (just look at Perl).
This proposal would have as an effect less syntax. The 'as ...' syntax
already exists, but as special cases. Making 'as ...' a general assignment
operator would eliminated the special cases and collect them all in the
expression syntax. So less syntax.
> There's nothing wrong
> while True:
> fx = f(x)
> if fx <= 5:
There was also nothing wrong with:
if b > c:
a = 5
a = 2
> new = nextvalue()
> if check(new):
Except that it would need an extra indentation level if
it was an elif.
More information about the Python-list