Advanced Dictionary

Stephen Hansen me+list/python at ixokai.io
Wed Jun 16 12:49:28 EDT 2010


On 6/16/10 9:34 AM, Steven D'Aprano wrote:
> On Wed, 16 Jun 2010 09:17:47 -0700, Stephen Hansen wrote:
> 
>> Leading-and-trailing double underscores are explicitly reserved for
>> Python to define as Special. 
> 
> 
> That part is correct. But of course Python doesn't prevent you from 
> ignoring this rule (more of a guideline really).

Agreed. Its a namespace reserved for Python itself to define. But
"reserved" in the more traditional Python sense of it saying, "Please
keep your hands off", and not, "SyntaxError: Illegal creation of new
special method".

>> They also imply a slightly different
>> calling semantic: normal leading-and-trailing double underscore methods
>> bypass instance lookup.
> 
> This is semi-correct. Operator overloading and other special method 
> lookup bypasses instance lookup and calls type(instance).__method__ but 
> that has nothing to do with the double-underscore methods themselves. 
> They operate normally if you call them by hand:

Well, yes; I was simplifying slightly because people don't really call
them by hand in the normal course of events (and eventually you'll pass
the object into some internal where it most certainly doesn't get called
that way).

But true, that's more accurate. :)

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20100616/29d92384/attachment.sig>


More information about the Python-list mailing list