annotate python/example/subclass.py @ 787:d265e49b965e

shortcut
author Jeff Hammel <k0scist@gmail.com>
date Sun, 25 Sep 2016 16:29:22 -0700
parents ae7e75a8cdb0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
598
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 import string
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2 from pprint import pprint
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4 class Foo:
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 pass
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
7 class Bar(Foo):
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8 pass
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10 fleem = 1
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12 mystuff = {i:j for i, j in globals().items()}
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13 types = {i:type(j) for i, j in globals().items()}
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
14
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
15 mynewstuff = {i:j for i, j in mystuff.items()
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
16 if (type(j) == type(Foo)) and issubclass(j, Foo)}
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
17
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
18 pprint(mynewstuff)