annotate python/example/ternary.py @ 842:03f9657514e9

while we might not want Octave *that* much, we will never want OCAML
author Jeff Hammel <k0scist@gmail.com>
date Sun, 09 Jul 2017 15:01:16 -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