On 10 September 2013 13:24, Paul Moore <p.f.mo...@gmail.com> wrote: > On 10 September 2013 13:00, Nick Coghlan <ncogh...@gmail.com> wrote: >> Is this just syntactic sugar for recursive lookup of a transformed version >> in __missing__? Or a way of supplying a custom "key" function to a >> dictionary? > > Not quite, because the dict should preserve the originally entered key. > >>>> td['FOO'] = 42 >>>> td['bar'] = 1 >>>> td['foo'] > 42 >>>> td['BAR'] > 1 >>>> list(td.keys()) > ['FOO', 'bar'] > > This actually prompts the question, what should the following produce: > >>>> td['FOO'] = 42 >>>> td['foo'] = 32 >>>> list(td.keys()) > > ['FOO'] or ['foo']? Both answers are justifiable. Both are possibly > even useful depending on context...
I'm using the case where the transform is str.lower here - sorry I wasn't explicit. Paul _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com