A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-June/025118.html below:

Performance vs. Clarity vs. Convention

[Python-Dev] OT: Performance vs. Clarity vs. ConventionGreg Ewing greg@cosc.canterbury.ac.nz
Fri, 07 Jun 2002 12:53:52 +1200 (NZST)
Guido van Rossum <guido@python.org>:

> > >     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!

In this particular case, the program blows up anyway if this
method is ever called, so you might as well return a meaningful
exception!

Python 2.2 (#14, May 28 2002, 14:11:27) 
[GCC 2.95.2 19991024 (release)] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> class C:
...  def __str__(self):
...   pass
... 
>>> c = C()
>>> str(c)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: __str__ returned non-string (type NoneType)
>>> 

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg@cosc.canterbury.ac.nz	   +--------------------------------------+




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4