Mercurial > hg > config
annotate python/example/classes.py @ 626:89a72399286b
adding file demonstrating classes
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Mon, 17 Feb 2014 17:33:23 -0800 |
parents | |
children | 870af8d51552 |
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 |
89a72399286b
adding file demonstrating classes
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
10 tests = ["issubclass(A, A)"] |
89a72399286b
adding file demonstrating classes
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
11 |
89a72399286b
adding file demonstrating classes
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
12 if __name__ == '__main__': |
89a72399286b
adding file demonstrating classes
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
13 for test in tests: |
89a72399286b
adding file demonstrating classes
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
14 print ("? {}".format(test)) |
89a72399286b
adding file demonstrating classes
Jeff Hammel <k0scist@gmail.com>
parents:
diff
changeset
|
15 print (eval(test)) |