<br><br><div><span class="gmail_quote">On 3/3/06, <b class="gmail_sendername">Raymond Hettinger</b> &lt;<a href="mailto:raymond.hettinger@verizon.net">raymond.hettinger@verizon.net</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
[Aahz]<br>&gt; * As a writer/teacher, I want to be able to say, &quot;All Python special<br>&gt; methods have leading and trailing double-underscore.&quot;&nbsp;&nbsp;Period, end of<br>&gt; story.<br><br>When teaching your classes, do you sense an aversion to using double underscore
<br>methods in regular code?&nbsp;&nbsp;I sense an implied message that these methods are not<br>intended to be called directly (i.e. the discomfort of typing x.__setitem__(k,v)<br>serves as a cue to write x[k]=v instead; likewise, x.__int__() pushes towards
<br>int(x) instead).<br><br>If so, then that is a good reason to leave it.next() as-is.&nbsp;&nbsp;Unlike __setitem__<br>or __int__, the next() method is intended to be called directly in normal code.<br>Of course, for-loops are the most common case and it makes no difference there;
<br>however, in the rest of the cases where the iterator is accessed directly, the<br>current naming is clean, readable, and doesn't provide an aversive cue.<br><br>The double underscore convention is appropriate where the method is always
<br>invoked magically in normal code and not called directly.&nbsp;&nbsp;The next() method is<br>differenct because it is a mixed case, sometimes called magically and sometimes<br>called directly.&nbsp;&nbsp;In the latter case, the name is highly visible and therefore
<br>should not have double underscores.<br><br>I suspect that those who feel differently are ones who usually avoid calling<br>next() directly.&nbsp;&nbsp;That's okay, but we shouldn't muck-up the naming for the rest<br>of us who often do have a need to use next().
<br><br>This is doubly important because we're now expanding the protocol to include<br>send() and throw().&nbsp;&nbsp;Adding underscores around them too will only make those<br>methods look harder to use than they actually are.&nbsp;&nbsp;Don't underestimate the
<br>psychological revulsion to calling code filled with piles of double underscores.</blockquote><div><br>
<br>
I think this is a really good point. next() is supposed to get used, by
coders, in regular code - so it shouldn't be __next__. I can understand
the desire for both forms, although that seems it would clutter things
up unnecessarily - particularly if the two do the same thing. <br>
</div><br>
Anna<br>
</div><br>