SHARE
TWEET

Untitled

a guest Jan 23rd, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from collections import *
  2. ABCS = (
  3.     Container,
  4.     Hashable,
  5.     Iterable,
  6.     Iterator,
  7.     Sized,
  8.     Callable,
  9.     Sequence,
  10.     MutableSequence,
  11.     Set,
  12.     MutableSet,
  13.     Mapping,
  14.     MutableMapping,
  15.     MappingView,
  16.     ItemsView,
  17.     KeysView,
  18.     ValuesView
  19. )
  20.  
  21. python_primitives = (
  22.     basestring,
  23.     bool,
  24.     bytearray,
  25.     dict,
  26.     file,
  27.     float,
  28.     int,
  29.     list,
  30.     frozenset,
  31.     object,
  32.     set,
  33.     slice,
  34.     str,
  35.     tuple,
  36.     type,
  37.     unicode,
  38. )
  39.  
  40. def get_abcs_for_class(cls):
  41.    abcs_found = []
  42.    for abc in ABCS:
  43.        if issubclass(cls, abc):
  44.            abcs_found.append(abc)
  45.    return abcs_found
  46.  
  47. if __name__ == "__main__":
  48.    for t in python_primitives:
  49.       abcs = get_abcs_for_class(t)
  50.       print "{}: {}".format(t, abcs)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top