On 6/7/2012 4:54 PM, Yury Selivanov wrote:
I think we'll add a 'format' method to the Signature, that will work
like 'inspect.formatargspec'. 'Signature.__str__' will use it with
default parameters/formatters.
Great. If I don't like the default, I could customize.
I'm not sure how __repr__ should look like. Maybe default repr
(object.__repr__) is good enough.
__repr__ = __str__ is common.
Idle tooltips use an re to strip 'self[, ]' from the
inspect.formatargspec result*. I have revised the code to only do that
when appropriate (for bound instance methods and callable instances),
which is to say, when the user has already entered the object that will
become the self parameter). If signature does the same, I might delete
the code and use the signature object instead.
*The same could be done for class methods, but I am not sure that 'cls'
is standard enough to bother. Of course, any function using anything
other than 'self' will also not see the deletion. Come to think of it,
now that I am doing the search-and-replace conditionally rather than
always, I can and should re-write the re to remove the first name rather
than 'self' specifically. It will be good to have all such signature
manipulations done correctly in one place.
---
Terry Jan Reedy
_______________________________________________
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