fork download
  1. import inspect
  2.  
  3. class Foo(object):
  4. def __init__(self):
  5. self.x = 1
  6. self.y = 2
  7.  
  8. def method(self):
  9. pass
  10.  
  11. foo = Foo()
  12.  
  13. members = ((name, type(value).__name__) for name, value in inspect.getmembers(foo))
  14.  
  15. for member in members:
  16. print(member)
Success #stdin #stdout 0.03s 30944KB
stdin
Standard input is empty
stdout
('__class__', 'type')
('__delattr__', 'method-wrapper')
('__dict__', 'dict')
('__dir__', 'builtin_function_or_method')
('__doc__', 'NoneType')
('__eq__', 'method-wrapper')
('__format__', 'builtin_function_or_method')
('__ge__', 'method-wrapper')
('__getattribute__', 'method-wrapper')
('__gt__', 'method-wrapper')
('__hash__', 'method-wrapper')
('__init__', 'method')
('__le__', 'method-wrapper')
('__lt__', 'method-wrapper')
('__module__', 'str')
('__ne__', 'method-wrapper')
('__new__', 'builtin_function_or_method')
('__reduce__', 'builtin_function_or_method')
('__reduce_ex__', 'builtin_function_or_method')
('__repr__', 'method-wrapper')
('__setattr__', 'method-wrapper')
('__sizeof__', 'builtin_function_or_method')
('__str__', 'method-wrapper')
('__subclasshook__', 'builtin_function_or_method')
('__weakref__', 'NoneType')
('method', 'method')
('x', 'int')
('y', 'int')