At 04:35 PM 3/14/05 +0100, Thomas Heller wrote:
Another possibility (ugly, maybe) would be to create sourcecode with the
function signature that you need, and compile it. inspect.getargspec() and
inspect.formatargspec can do most of the work.

I've done exactly that, for generic functions in PyProtocols. It's *very* ugly, and not something I'd wish on anyone needing to write a decorator. IMO, inspect.getargspec() shouldn't need to be so complicated; it should just return an object's __signature__ in future Pythons.


Also, the 'object' type should have a __signature__ descriptor that returns the __signature__ of __call__, if present. And types should have a __signature__ that returns the __init__ or __new__ signature of the type. Finally, C methods should have a way to define a __signature__ as well.

At that point, any callable object has an introspectable __signature__, which would avoid the need for every introspection framework or documentation tool having to rewrite the same old type dispatching code to check if it's an instancemethod, an instance with a __call__, a type, etc. etc. in order to find the real function and how to modify what getargspec() returns.

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to