Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. # foo.py
  2. class Foo:
  3. pass
  4.  
  5. # test.py
  6. import inspect
  7. import foo
  8.  
  9. for name, obj in inspect.getmembers(foo):
  10. if inspect.isclass(obj):
  11. print obj
  12.  
  13. # foo.py
  14. import inspect
  15.  
  16. class Foo:
  17. pass
  18.  
  19. def print_classes():
  20. for name, obj in inspect.getmembers(???): # what do I do here?
  21. if inspect.isclass(obj):
  22. print obj
  23.  
  24. # test.py
  25. import foo
  26.  
  27. foo.print_classes()
  28.  
  29. import sys
  30. current_module = sys.modules[__name__]
  31.  
  32. import sys
  33. def print_classes():
  34. for name, obj in inspect.getmembers(sys.modules[__name__]):
  35. if inspect.isclass(obj):
  36. print obj
  37.  
  38. clsmembers = inspect.getmembers(sys.modules[__name__], inspect.isclass)
  39.  
  40. g = globals().copy()
  41. for name, obj in g.iteritems():
  42.  
  43. import pyclbr
  44. print(pyclbr.readmodule(__name__).keys())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement