[Python-Dev] OT: Performance vs. Clarity vs. Convention

Aahz aahz@pythoncraft.com
Thu, 6 Jun 2002 09:13:25 -0400


On Thu, Jun 06, 2002, Guido van Rossum wrote:
>
>>> class Element:
>>> 
>>>     def __str__(self):
>>>         pass
>> 
>> Dunno about other people's opinions, but I have a strong distaste for
>> creating methods whose body contains pass.  I always use "raise
>> NotImplementedError".
> 
> But that has different semantics!

Yes, exactly.  My point was that one rarely wants the semantics of
"pass" for method definitions, and that goes double or triple for the
special methods such as __str__.  Consider what happens to an
application that calls str() on this object and gets back a None instead
of a string.  Blech -- errors should never pass silently.
-- 
Aahz (aahz@pythoncraft.com)           <*>         http://www.pythoncraft.com/

"I had lots of reasonable theories about children myself, until I
had some."  --Michael Rios