unicodedata name for \u000a

"Martin v. Löwis" martin at v.loewis.de
Sun Aug 22 17:15:20 CEST 2004


Tor Iver Wilhelmsen wrote:
> Then why not return None or the empty string instead of raising an
> exception?

Why does a dictionary lookup raise a KeyError instead of returning
None or an empty exception? It's easy enough to add a function that
does what you want:

  def name(c):
    try:
      return unicodedata.name
    except ValueError:
      return None

Python reports failures through exceptions, not through special
return values. It might have been an option initially to return
None. Now, it cannot be changed for backwards compatibility.

Regards,
Martin



More information about the Python-list mailing list