[Python-Dev] PEP 455: TransformDict

Antoine Pitrou solipsis at pitrou.net
Sat Sep 14 12:30:46 CEST 2013

On Sat, 14 Sep 2013 14:33:56 +0900
Larry Hastings <larry at hastings.org> wrote:
> On 09/14/2013 03:40 AM, Antoine Pitrou wrote:
> > Hello,
> >
> > Following the python-dev discussion, I've written a PEP to recap the
> > proposal and the various arguments. It's inlined below, and it will
> > probably appear soon at http://www.python.org/dev/peps/pep-0455/, too.
> Whenever I read a discussion about the dict, I always wonder whether the 
> same thing applies to a set.  Have you considered the utility of a 
> TransformSet?  Or is it YAGNI?

Well, a TransformSet is like a normal dict, you just need to call the
transformation function yourself when inserting the keys.

  d = TransformSet(str.lower)

is the same conceptually as:

  d = {}
  d['Foo'.lower()] = 'Foo'
  d['foo']  # gets the original key



More information about the Python-Dev mailing list