Python handles globals badly.

Marko Rauhamaa marko at pacujo.net
Fri Sep 11 07:59:20 EDT 2015


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). There's nothing wrong
in:

   while True:
       fx = f(x)
       if fx <= 5:
           break
       process(fx)

   new = nextvalue()
   if check(new):
       treat(new)


Marko



More information about the Python-list mailing list