[Python-ideas] Add dict.getkey() and set.get()
raymond.hettinger at gmail.com
Sun Sep 15 02:32:48 CEST 2013
On Sep 14, 2013, at 8:09 AM, Serhiy Storchaka <storchaka at gmail.com> wrote:
> I propose to add two methods:
> dict.getkey(key) returns original key stored in the dict which is equal to specified key. E.g.
For what is worth:
* this idea was proposed and rejected at least once before
* the one obvious way to do it is an interning dictionary
that maps values back to themselves
* the use cases for this are somewhat uncommon
(i.e. most people don't need it most of the time)
* if you think you really need this functionality,
it is possible to write a function that works with all
containers as they are already implemented
(i.e. you could you it today):
* all the participants on this list would be well served to teach
some python classes to get an appreciation of the negative
consequences of further expanding the APIs of the core containers.
Bigger is not better. Learnability matters.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas