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)

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'argument': 0.05; 'assign': 0.07; 'subject:instance': 0.09; 'variable,': 0.09; 'cc:addr :python-list': 0.11; '__lt__': 0.16; 'argument.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'ought': 0.16; 'set,': 0.16; 'subject: \n ': 0.16; 'subject:class': 0.16; 'subject:variable': 0.16; 'wrote:': 0.18; 'wed,': 0.18; '(the': 0.22; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'function': 0.29; 'message- id:@mail.gmail.com': 0.30; '13,': 0.31; 'class': 0.32; 'becomes': 0.33; 'subject:from': 0.34; 'subject: (': 0.35; 'something': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'method': 0.36; 'pm,': 0.38; 'first': 0.61; 'significance': 0.84; 'on?': 0.91; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:cc:content-type; bh=OYBfUF2Na5Du4pznLbcULxiBjk7IRIZa6G2OnYqmWNk=; b=nq/PiFzgpapAEV68aVIzkHW8bYET1vxX1k6STSMCNjPo3GfFEGDVS9Jbyuv/xRhK0F Z0KVrqGquSegzF6d6sbVnXh/C8Nny7GcPAWC40C7JYTU3qfsAeY0Ah2yVeEOD60DcMqR f6E4wJd6q9GYxBZ6t84aA8RyWQ3xGvdwF5cg4L3FWfd6pdNmJwMLBkWiP5XcT1Rzc/EF KAO4SSjRdJqgDf2+O/GfIILHzXhBe6OyWYBWWRIN6fpJlSCZe/c4QhoyEWtM4EDOcUJT eJOwnWlqTYwpar9DeRjPKKgyIjK8tKpj7V8ZTsgCasxf/pv1R6G1Xpi7a8EvyMPO/SFg vf9Q==
MIME-Version 1.0
X-Received by 10.42.216.148 with SMTP id hi20mr4782051icb.12.1407923498116; Wed, 13 Aug 2014 02:51:38 -0700 (PDT)
Date Wed, 13 Aug 2014 19:51:38 +1000
Subject Arbitrary dunder attributes (was Re: odd difference calling function from class or instance variable)
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12915.1407923500.18130.python-list@python.org> (permalink)
Lines 15
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1407923500 news.xs4all.nl 2977 [2001:888:2000:d::a6]:59131
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:76181

Show key headers only | 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