Favorite non-python language trick?

Thomas Guettler guettli at thomas-guettler.de
Fri Jun 24 06:49:08 EDT 2005


Am Fri, 24 Jun 2005 00:55:38 -0600 schrieb Joseph Garvin:

> As someone who learned C first, when I came to Python everytime I read 
> about a new feature it was like, "Whoa! I can do that?!" Slicing, dir(), 
> getattr/setattr, the % operator, all of this was very different from C.
> 
> I'm curious -- what is everyone's favorite trick from a non-python 
> language? And -- why isn't it in Python?
> 
> Here's my current candidate:
[cut]
> This syntax lets you do a nifty trick, where you can add or subtract a
> third dash to change whether or not code runs:

I do it this way:

if 0: # Just for testing
    print value
    .....

You only need to change "if 0" to "if 1" and the code gets executed.

 Thomas

-- 
Thomas Güttler, http://www.thomas-guettler.de/





More information about the Python-list mailing list