[Python-Dev] PEP 362 Second Revision (original) (raw)
Terry Reedy tjreedy at udel.edu
Thu Jun 7 23:39:54 CEST 2012
- Previous message: [Python-Dev] PEP 362 Second Revision
- Next message: [Python-Dev] PEP 362 Second Revision
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] PEP 362 Second Revision
- Next message: [Python-Dev] PEP 362 Second Revision
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]