Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76190 > unrolled thread
| Started by | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| First post | 2014-08-13 08:11 -0400 |
| Last post | 2014-08-13 08:11 -0400 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Arbitrary dunder attributes (was Re: odd difference calling function from class or instance variable) Ned Batchelder <ned@nedbatchelder.com> - 2014-08-13 08:11 -0400
| From | Ned Batchelder <ned@nedbatchelder.com> |
|---|---|
| Date | 2014-08-13 08:11 -0400 |
| Subject | Re: Arbitrary dunder attributes (was Re: odd difference calling function from class or instance variable) |
| Message-ID | <mailman.12920.1407931879.18130.python-list@python.org> |
On 8/13/14 5:51 AM, Chris Angelico wrote: > 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 > As I see it, dunder names are those whose meaning is defined by the Python language (and/or implementation?), and whose use is typically behind-the-scenes. So "len" is defined by the language, but is meant to be front-and-center, so it has a nice name. __init__, __lt__, and __self__, have meanings and uses defined by Python itself, and so are reasonable as dunder names. This is a crude namespacing: Python can use any name it likes so long as its a dunder name, and I can use any name I like, so long as it isn't. Yes, the definition is fuzzy.... :) -- Ned Batchelder, http://nedbatchelder.com
Back to top | Article view | comp.lang.python
csiph-web