comparison python/example/ternary.py @ 541:776d83eb0fd9

python/example/ternary.py
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 27 Sep 2013 13:02:36 -0700
parents
children
comparison
equal deleted inserted replaced
540:8c9cd7472d28 541:776d83eb0fd9
1 #!/usr/bin/env python
2
3 """
4 illustrates python ternary is smart about branching
5 """
6
7 class Foo(object):
8 def __init__(self):
9 print 'hi'
10 bar = 1
11 print Foo() if bar is None else bar