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

PythonServer Side ProgrammingProgramming

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__
raja
Published on 12-Jan-2018 14:23:10
Advertisements