Python Tips

From EggeWiki
Revision as of 07:12, 17 September 2008 by Egge (talk | contribs) (New page: Python takes some getting used to. The clean syntax is great, but it has some things which a Java or Ruby programmer might not guess. == How to tell if an object is None == This won't...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Python takes some getting used to. The clean syntax is great, but it has some things which a Java or Ruby programmer might not guess.

How to tell if an object is None

This won't parse: <geshi lang="python"> user = users.get_current_user() if !user:

   gologin()

</geshi>

This parses but doesn't work: <geshi lang="python"> user = users.get_current_user() if not user:

   gologin()

</geshi>

This works! <geshi lang="python"> user = users.get_current_user() if user is None:

   gologin()

</geshi>