Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import *
- ABCS = (
- Container,
- Hashable,
- Iterable,
- Iterator,
- Sized,
- Callable,
- Sequence,
- MutableSequence,
- Set,
- MutableSet,
- Mapping,
- MutableMapping,
- MappingView,
- ItemsView,
- KeysView,
- ValuesView
- )
- python_primitives = (
- basestring,
- bool,
- bytearray,
- dict,
- file,
- float,
- int,
- list,
- frozenset,
- object,
- set,
- slice,
- str,
- tuple,
- type,
- unicode,
- )
- def get_abcs_for_class(cls):
- abcs_found = []
- for abc in ABCS:
- if issubclass(cls, abc):
- abcs_found.append(abc)
- return abcs_found
- if __name__ == "__main__":
- for t in python_primitives:
- abcs = get_abcs_for_class(t)
- print "{}: {}".format(t, abcs)
Add Comment
Please, Sign In to add comment