Good question. Python has a lot of introspection features but some of them are a bit haphazard and others are perhaps less-than-optimally documented.That's what this page is: "a list of needed introspection features". The initial question had to do with a function which reports a method's signature. Fred L. Drake, Jr., pointed out a number of features beyond those Guido mentions above, including:(The key ones, of course, are so simple that you don't even think about them -- __dict__, __class__, __bases__, __name__, __file__, as well as locals(), globals(), vars(), dir(), type(), isinstance(), issubclass(), not to mention sys.modules.)
I've rarely felt the need to extract signatures from functions, but I can see that such a need exists in others.
Perhaps we can create a list of needed introspection features?
You could try:
try:
version = func.func_globals['__version__']
except KeyError:
version = None
The value of __version__ should be set if the author will make sure
the module will not be released without updating the number. One way
to do this under CVS or RCS would be:
__version__ = "$Revision$"
Other revision control systems may support similar constructs.