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/2002-September/028963.html below:

[Python-Dev] Keyword for first argument of methods?

[Python-Dev] Keyword for first argument of methods?Andrew Koenig ark@research.att.com
27 Sep 2002 11:26:42 -0400
Dave> When implementing keyword argument support for Boost.Python, I noticed the
Dave> following. I'm sure it's not worth a lot of effort to change this behavior,
Dave> but I thought someone might like to know:

Dave> class X:
Dave> ...     def foo(self, y): print y
Dave> ...
Dave> X.foo(y = 1, self = X())
Dave> Traceback (most recent call last):
Dave>   File "<stdin>", line 1, in ?
Dave> TypeError: unbound method foo() must be called with X instance as first
Dave> argument (got nothing instead)

Perhaps more interesting:

        >>> X.foo(X(), 1)
        1
        >>> X.foo(self = X(), y = 1)
        TypeError: unbound method foo() must be called with X instance as first argument (got nothing instead)

-- 
Andrew Koenig, ark@research.att.com, http://www.research.att.com/info/ark



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