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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4