Hitohira | Hitorijime My Hero | Hokuto no Ken

, asked
Views : 2

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

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


1 Answer
Rajendra Dharmkar

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

The following code shows how __module__ works

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

This gives the output

__main__

Advertisements
Related Questions