Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76181

Arbitrary dunder attributes (was Re: odd difference calling function from class or instance variable)

Date 2014-08-13 19:51 +1000
Subject Arbitrary dunder attributes (was Re: odd difference calling function from class or instance variable)
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.12915.1407923500.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Wed, Aug 13, 2014 at 7:06 PM, GregS <not@my.real.address.com> wrote:
> When I assign the reference as a class variable, the reference has __self__
> set, too, so I get an extra argument passed to the function.  If I assign
> the reference as an instance variable, then __self__ is unset so no extra
> argument.

Spin-off from Greg's thread.

The bound method object stores a reference to the original object (the
thing that becomes the first argument to the target function) in
__self__ (and the function in __func__). ISTM this ought to be _self
(and _func), as it's intended to be private; is it really something
that has language-level significance on par with __lt__ and so on?

ChrisA

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Arbitrary dunder attributes (was Re: odd difference calling function from class or instance variable) Chris Angelico <rosuav@gmail.com> - 2014-08-13 19:51 +1000
  Re: Arbitrary dunder attributes (was Re: odd difference calling function from class or instance variable) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-13 23:12 +1000
    Re: Arbitrary dunder attributes (was Re: odd difference calling function from class or instance variable) Chris Angelico <rosuav@gmail.com> - 2014-08-14 00:09 +1000

csiph-web