A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-May/100245.html below:

[Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a method

[Python-Dev] Reasons behind misleading TypeError message when passing the wrong number of arguments to a methodMichael Urman murman at gmail.com
Fri May 21 14:25:33 CEST 2010
On Thu, May 20, 2010 at 22:54, Steven D'Aprano <steve at pearwood.info> wrote:
> This is misleading, since C().method is a bound method which takes one
> argument, x, not two. I find myself wishing that Python distinguished
> between ArgumentError and other TypeErrors, so that the method wrapper
> of bound methods could simply catch ArgumentError and subtract 1 from
> each argument count.

But how exactly could it distinguish between various levels of call nesting?

    class C:
        def a(self, i): return self.b(i)
        def b(self, j): return self.c(j)
        def c(self, k): return self.a()

What should C.a(), C().a(), and C().a(1) each yield? Does it change if
c(self, k) calls C.a(self)?

-- 
Michael Urman
More information about the Python-Dev mailing list

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