inspect.getmembers() vs __dict__.items() vs dir()

Viewed 8025

Can anybody explain to me with adequate examples whats the difference b/w

>>> import inspect
>>> inspect.getmembers(1)

and

>>> type(1).__dict__.items()

and

>>> dir(1)  

except that they show an decreasing no.s of attributes & methods in that order. 1 is integer (but it can be of any type.)


EDIT

>>>obj.__class__.__name__  #gives the class name of object  
>>>dir(obj)                #gives attributes & methods  
>>>dir()                   #gives current scope/namespace
>>>obj.__dict__            #gives attributes
1 Answers
Related