Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tlug] variable assignments inside expressions in python



Hector Akamine writes:

 > Trying to do the same in python
 > while ( (myvar = get_time( ) ) < DEADLINE):
 > 
 >  throws an error. Is there a "python way" to do this?

No.  This is definitely unpythonic.

The pythonic way to do this (if it really needs doing) is to define
get_time as an iterator, and then use the "for myvar in
get_post_deadline():" syntax, possibly as a list comprehension.  I
haven't defined an interator in a while though, so I can't help with
that tonight.




Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links