Short answer : basically the answer is no.
But can you not find the functionality you are looking for with docstrings?
testmodule.py
""" my module test does x and y """ class myclass(object): ...
test.py
import testmodule print testmodule.__doc__
Long answer:
You can define your own __repr__ at the module level (just specify def __repr__(... ), but then you will need:
import mymodule print mymodule.__repr__()
to get the functionality you need.
Take a look at the following python shell session:
>>> import sys # we import the module >>> sys.__repr__() # works as usual "<module 'sys' (built-in)>" >>> sys.__dict__['__repr__'] # but it not in the modules __dict__ ? Traceback (most recent call last): File "<stdin>", line 1, in <module> KeyError: '__repr__' >>> sys.__class__.__dict__['__repr__'] # __repr__ is provided on the module type as a slot wrapper <slot wrapper '__repr__' of 'module' objects> >>> sys.__class__.__dict__['__repr__'](sys) # which we should feed an instance of the module type "<module 'sys' (built-in)>"
Therefore, I believe that the problem lies in these slot cover objects , which (from what can be read by reference) have the result of going around the usual "python" way of searching for item attributes.
For these class methods, CPython returns C pointers to the corresponding methods on these objects (which are then wrapped in slot cover objects that can be invoked by python).
source share