On Wednesday 06 November 2002 08:32 pm, Tim Peters wrote: > Unfortunately, Python is inconsistent about this. On the one hand, > > >>> x = [] > >>> push = x.append > >>> push() > > Traceback (most recent call last): > File "<stdin>", line 1, in ? > TypeError: append() takes exactly one argument (0 given) > > > On the other, > > >>> class X(list): > > ... def append(self, item): > ... pass > ... > > >>> push = X().append > >>> push() > > Traceback (most recent call last): > File "<stdin>", line 1, in ? > TypeError: append() takes exactly 2 arguments (1 given) > > > I care about matching the error msgs because error msgs are a prime > trigger for looking up help. OTOH, when the error msgs are inconsistent, > you can't win. I'd count self, myself, as you can only suck the > signature out of Python-defined callables, and those seem consistent > about reporting the "real" number of arguments required. Except the net (args required minus args given) is the same in both cases. Which would argue for not including self in the results of getargspec(). Plus, you'll get an error if you try to explicitly pass the first argument. So while technically self *is* part of the argspec, I think in practice most applications will end up wanting to eliminate it because Python takes care of it implicitly. If that turns out to be 90% of the use cases, we save everyone a lot of trouble by taking the practical approach and not including self in the results returned by getargspec(). -- Patrick K. O'Brien Orbtech http://www.orbtech.com/web/pobrien ----------------------------------------------- "Your source for Python programming expertise." -----------------------------------------------
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