popkey() method for dictionaries?

John Hunter jdhunter at ace.bsd.uchicago.edu
Mon Nov 18 10:22:35 EST 2002


>>>>> "Fernando" == Fernando Pérez <fperez528 at yahoo.com> writes:

    Fernando> Sure. First, on principle: the exception option is still
    Fernando> there, if no default is provided. What giving a default
    Fernando> buys you is not having to trap the exception
    Fernando> yourself. If you want a missing key to generate an
    Fernando> exception, simply don't give a default and that's
    Fernando> it. 

But then you break the symmetry with get, which provides None as a
default if no default is provided.  Aren't you now back in danger of
violating the principle of least surprise?

John Hunter





More information about the Python-list mailing list