Re: [Python-Dev] PEP 455: TransformDict

2013年9月13日 18:06:34 -0700

On 2013年9月13日 15:32:55 -0700
Ethan Furman <[email protected]> wrote:
> On 09/13/2013 02:45 PM, Antoine Pitrou wrote:
> > Serhiy Storchaka wrote:
> >>
> >> I think that's important. As OrderectDict has additional methods besides
> >> the MutableMapping API, so TransformDict should provide useful
> >> specialized methods.
> >
> > Ok, I have a better (IMO) proposal:
> >
> > >>> d = TransformDict(str.casefold, {'Foo': 1})
> > >>> d.getitem('foo')
> > ('Foo', 1)
> > >>> d.getitem('bar')
> > Traceback (most recent call last):
> > File "<stdin>", line 1, in <module>
> > KeyError: 'bar'
> 
> -1
> 
> When I want the canonical key, I'm not going to care about the value; and if 
> I do, it's easy enough to get.
But if you don't care about the value, the key is enough to get ;-)
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to