[Python-Dev] PEP 362 Second Revision (original) (raw)
Yury Selivanov yselivanov.ml at gmail.com
Thu Jun 7 23:53:57 CEST 2012
- Previous message: [Python-Dev] [Python-checkins] peps: Update 422 based on python-dev feedback
- Next message: [Python-Dev] PyPy 1.9 - Yard Wolf
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2012-06-07, at 5:39 PM, Terry Reedy wrote:
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.
Can you tell me how do you use those customizations (i.e. formatvarargs, formatarg and other arguments of formatargspec)?
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.
Well, signature won't strip parameters based on their names, but rather based on the callable type. If it's a method, than no matter how its first parameter is named - it will be omitted. Same applies for classmethods.
- Yury
- Previous message: [Python-Dev] [Python-checkins] peps: Update 422 based on python-dev feedback
- Next message: [Python-Dev] PyPy 1.9 - Yard Wolf
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]