KeyError without [] harmful?
A. Lloyd Flanagan
alloydflanagan at attbi.com
Tue May 13 13:18:52 EDT 2003
jjl at pobox.com (John J. Lee) wrote in message news:<87n0hryf8y.fsf at pobox.com>...
> Sometimes I have methods that work rather like dictionary access, but
> whose class for one reason or another can't sensibly be given a real
> mapping interface (with __getitem__ etc).
>
<missing stuff>
>
> Strictly, I suppose it should raise ValueError if a dict lookup in
> there fails, but part of me wants to just leave it at that and let the
> KeyErrors propagate. Is that a wicked thought?
Doesn't bother me. As long as the object "looks like" a dictionary I
think KeyError is appropriate.
More information about the Python-list
mailing list