[Python-ideas] Add dict.getkey() and set.get()

Raymond Hettinger raymond.hettinger at gmail.com
Sat Sep 14 23:03:09 CEST 2013


On Sep 14, 2013, at 1:10 PM, Serhiy Storchaka <storchaka at gmail.com> wrote:

> I have no good use cases.

That should be the end of the story ;-)

Also, we need to have a strong preference to keep the core APIs small.
Python is becoming harder and harder to teach -- it no longer
"fits in your head".

If you look at mapping and set APIs in other languages, you will
see than this particular feature creep has usually been 
deemed unnecessary.

The most important thing we can do for Python is to teach how
to use the core objects to solve problems rather than trying to
add a method for every single idea that has ever occurred to us.

Dictionaries and lists are very flexible tools.  We need to teach
people to use them to solve simple problems:

   canonical = {}

   def intern(obj):
          'Return a canonical member of an equivalent class'
          if obj in canonical:
              return canonical[obj]
          canonical[obj] = obj
          return obj


Raymond
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130914/fc3de074/attachment.html>


More information about the Python-ideas mailing list