On 3/5/07, Ka-Ping Yee <[EMAIL PROTECTED]> wrote: > On Tue, 6 Mar 2007, Neil Schemenauer wrote: > > We don't suggest that file-like objects > > should implement __read__() instead of read(), for example. > > There is a convention and it is applied quite consistently: > > Double-underscores are for methods implicitly invoked > by a language construct. > > In fact, your example was specifically anticipated and addressed in > the PEP draft I posted here. file.read() is not invoked by a language > construct. When file.read() gets called, it is because the calling > code has an explicit call to read() in it, not because the standard > semantics of some piece of Python syntax require it to be invoked.
I agree that file.read() is a different beast than iter.next(). However, file.write() is a counterexample to your argument here. It gets called by Python syntax, and yet doesn't (and shouldn't) have double underscores. >>> print >> object(), "foo" Traceback (most recent call last): ... AttributeError: 'object' object has no attribute 'write' Greg F _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com