annotate python/example/classes.py @ 627:870af8d51552

STUB: python/example/classes.py
author Jeff Hammel <k0scist@gmail.com>
date Tue, 18 Feb 2014 20:09:42 -0800
parents 89a72399286b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
626
89a72399286b adding file demonstrating classes
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
89a72399286b adding file demonstrating classes
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2
89a72399286b adding file demonstrating classes
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3 """
89a72399286b adding file demonstrating classes
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4 illustrate how classes work
89a72399286b adding file demonstrating classes
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 """
89a72399286b adding file demonstrating classes
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6
89a72399286b adding file demonstrating classes
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
7 class A:
89a72399286b adding file demonstrating classes
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8 pass
89a72399286b adding file demonstrating classes
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9
627
870af8d51552 STUB: python/example/classes.py
Jeff Hammel <k0scist@gmail.com>
parents: 626
diff changeset
10 tests = ["issubclass(A(), A)",
870af8d51552 STUB: python/example/classes.py
Jeff Hammel <k0scist@gmail.com>
parents: 626
diff changeset
11 "issubclass(A, A)"]
626
89a72399286b adding file demonstrating classes
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12
89a72399286b adding file demonstrating classes
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13 if __name__ == '__main__':
89a72399286b adding file demonstrating classes
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
14 for test in tests:
89a72399286b adding file demonstrating classes
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
15 print ("? {}".format(test))
627
870af8d51552 STUB: python/example/classes.py
Jeff Hammel <k0scist@gmail.com>
parents: 626
diff changeset
16 try:
870af8d51552 STUB: python/example/classes.py
Jeff Hammel <k0scist@gmail.com>
parents: 626
diff changeset
17 print (eval(test))
870af8d51552 STUB: python/example/classes.py
Jeff Hammel <k0scist@gmail.com>
parents: 626
diff changeset
18 except Exception as e:
870af8d51552 STUB: python/example/classes.py
Jeff Hammel <k0scist@gmail.com>
parents: 626
diff changeset
19 print ('{}'.format(repr(e)))