[Python-Dev] iterator API in Py3.0

Fredrik Lundh fredrik at pythonware.com
Sat Mar 4 07:27:41 CET 2006


Raymond Hettinger wrote:

> When teaching your classes, do you sense an aversion to using double
> underscore methods in regular code?  I sense an implied message that
> these methods are not intended to be called directly (i.e. the discomfort
> of typing x.__setitem__(k,v) serves as a cue to write x[k]=v instead;
> likewise, x.__int__() pushes towards int(x) instead).

the "if called magically, it should be __xxx__" rule is pretty worthless on
its own; you also need to answer the questions "called by whom ?" and
"never called by application code ?"

(from the sound of it, one could suspect that some posters here would
like all template methods in all standard library components to use the
__xxx__ form).

</F>





More information about the Python-Dev mailing list