Python handles globals badly.
Antoon Pardon
antoon.pardon at rece.vub.ac.be
Mon Sep 14 03:13:45 EDT 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:
>> proces(fx)
>>
>> or
>>
>> if check(nextvalue() as new):
>> treat(new)
> Hey, I know, I know!... Let's allow:
>
> while (fx = f(x)) > 5:
> process(fx)
>
> if check(new = nextvalue()):
> treat(new)
>
> 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
> in:
>
> while True:
> fx = f(x)
> if fx <= 5:
> break
> process(fx)
There was also nothing wrong with:
if b > c:
a = 5
else:
a = 2
> new = nextvalue()
> if check(new):
> treat(new)
Except that it would need an extra indentation level if
it was an elif.
--
Antoon Pardon
More information about the Python-list
mailing list