annotate python/example/ternary.py @ 754:f011ec45b8e8

add example load type interface
author Jeff Hammel <k0scist@gmail.com>
date Fri, 03 Jul 2015 21:07:03 -0700
parents 776d83eb0fd9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
541
776d83eb0fd9 python/example/ternary.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 #!/usr/bin/env python
776d83eb0fd9 python/example/ternary.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2
776d83eb0fd9 python/example/ternary.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 """
776d83eb0fd9 python/example/ternary.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 illustrates python ternary is smart about branching
776d83eb0fd9 python/example/ternary.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 """
776d83eb0fd9 python/example/ternary.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6
776d83eb0fd9 python/example/ternary.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7 class Foo(object):
776d83eb0fd9 python/example/ternary.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 def __init__(self):
776d83eb0fd9 python/example/ternary.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9 print 'hi'
776d83eb0fd9 python/example/ternary.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 bar = 1
776d83eb0fd9 python/example/ternary.py
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 print Foo() if bar is None else bar