With respect to every class some attributes are added
automatically and we call those attributes as a default attributes. The default
attributes which are added to each and every class are –
1. __dict__
2. __doc__
3. __name__
4. __module__
5. __bases__
Example –
class demo:
""" This is a testing """
a=100
def __init__(self):
self.b=200
print demo.a
print demo.__name__
print demo.__dict__
print demo.__doc__
print demo.__bases__
print demo.__module__
""" This is a testing """
a=100
def __init__(self):
self.b=200
print demo.a
print demo.__name__
print demo.__dict__
print demo.__doc__
print demo.__bases__
print demo.__module__
Output –
100
demo
{'a':
100, '__module__': '__main__', '__doc__': ' This is a testing ', '__init__':
<function __init__ at 0x02779970>}
This is a testing
()
__main__
No comments:
Post a Comment