Computer >> Computer tutorials >  >> Programming >> Python

What does built-in class attribute __module__ do in Python?


This built-in class attribute when called prints the name of the module the function/object was defined in, or None if unavailable.

Example

The following code shows how __module__ works

class A(object): pass
class B(A): pass
b = B()
print B.__module__

Output

This gives the output

__main__