Guest User

Untitled

a guest
Oct 23rd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. class Point:
  2. def __init__(self, x, y):
  3. self.__x=x
  4. self.__y=y
  5.  
  6. dir(Point)
  7.  
  8. In [1]: class Point:
  9. ...: def __init__(self, x, y):
  10. ...: self.__x=x
  11. ...: self.__y=y
  12. ...:
  13.  
  14. In [2]: vars(Point)
  15. Out[2]:
  16. mappingproxy({'__dict__': <attribute '__dict__' of 'Point' objects>,
  17. '__doc__': None,
  18. '__init__': <function __main__.Point.__init__>,
  19. '__module__': '__main__',
  20. '__weakref__': <attribute '__weakref__' of 'Point' objects>})
  21.  
  22. In [3]: for k, v in vars(Point).items():
  23. ...: if callable(v):
  24. ...: print(k)
  25. ...:
  26. __init__
  27.  
  28. def list_methods(t):
  29. for item in t.__dict__:
  30. if isinstance(item, types.FunctiobType):
  31. print(item)
Add Comment
Please, Sign In to add comment