13 Dec
2004
13 Dec
'04
5:13 p.m.
On Dec 13, 2004, at 17:15, Florent Guillaume wrote:
Can we have instead:
def getUserById(self, id, default=_marker): """Return the user corresponding to the given id.
Raises a KeyError if the user does not exist and no default is provided. """ user = self.getUser(id) if user is not None: return user if default is not _marker: return default raise KeyError(id)
What is the advantage of throwing a KeyError over simply returning None? I don't see the reason for "getUser" and "getUserById" behaving in different ways here. They should both behave similar. jens