[Tutor] special attributes naming confusion

Alan Gauld alan.gauld at btinternet.com
Thu Jun 7 01:47:23 CEST 2012

On 06/06/12 21:32, Dave wrote:
> I'm not sure where this comment belongs, but I want to share my
> perspective on the documentation of these special method names. In the
> following section there is an inconsistency which could be confusing to
> someone just learning Python (e.g., me).

In general someone "just learning python" doesn't need to know about 
special names, they just use the operations they define.
The only exception being __init__() in class definitions.

These methods are really only of interest to someone who wants to define 
their own abstract data type and make it look like a built in type(*). 
In the vast majority of beginner scenarios that is not
needed or can be faked without use of them.

Even where it is needed the special names can be discovered on
a "need to know" basis. By the time that need arises the programmer
is hopefully so familiar with Python implementation style(use of 
dictionaries for namespaces etc) that the special name trick will be no 
great surprise and in fact come as an "aha!" moment of understanding.

So mostly I'd say just ignore them for now, you almost certainly don;t 
need them. And if you do you probably aren't "just learning" any more!


(*) Someone from a Lisp, Smalltalk or C++ background might stumble on 
them earlier because these languages support operator overloading and so 
the beginner may wonder about how to do it in Python. Most other 
languages don't use the concept so it won't even occur to ask!

Alan G
Author of the Learn to Program web site

More information about the Tutor mailing list