Raymond writes:
> The double underscore convention is appropriate where the method is always
> invoked magically in normal code and not called directly.  The next() method
is
> differenct because it is a mixed case, sometimes called magically and
sometimes
> called directly.  In the latter case, the name is highly visible and therefore
> should not have double underscores.

I think it's clear that if a method is invoked magically, it ought to have
underscores; if it is invoked directly then it ought not to. next() is
invoked both ways, so the question is which of the following invariants
we would rather maintain:

  * Any method that gets invoked 'magically' (by syntax) will have
    underscores.

  * Any method with underscores should be invoked directly only if
    you are practicing deep magic.

What I would *really* like is to keep both invariants... but the only way
to do that is to have a __next__() method paired with a next() builtin.
(The pattern we use for things like len().) This is great for everyone
except for (1) backward compatibility, (2) performance (but does the
indirection really need to hurt, and how much?), and (3) proliferation
of builtins (adding one more for next() won't hurt, but if we make a
practice of it we'll eventually have too many).

All told, I prefer using the underscores. I think that the first
invariant is important. But it's a judgement call, and a close one, so
I'll be happy with either decision.

-- Michael Chermside

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to