Favorite non-python language trick?

Devan L devlai at gmail.com
Sun Jun 26 14:38:17 EDT 2005


< "return a if a.value == true"
< "database.query(q) unless database.connect == error
(etc)

if a.value == True:
    return a

if not database.connect == error:
    database.query(q)

Trading two words for one word doesn't necessarily make the code
better.

< unless false then print 1 # this prints 1 forever
while not False:
    print 1

"unless" seems to become "while not", as opposed to "if not". Should be
more consistent.




More information about the Python-list mailing list