Re: [Python-Dev] PEP 455: TransformDict

2013年9月13日 14:46:47 -0700

On 2013年9月13日 23:18:39 +0300
Serhiy Storchaka <[email protected]> wrote:
> 13.09.13 23:02, Antoine Pitrou написав(ла):
> > On 2013年9月13日 16:54:01 -0300
> > "Joao S. O. Bueno" <[email protected]> wrote:
> >> I see the PEP does not contemplate a way to retrieve the original key
> >> - like we've talked about somewhere along the thread.
> >
> > Indeed. If that's important I can add it. I was hoping to keep very
> > close to the MutableMapping API, to make the PEP as few
> > controversial as possible.
> 
> 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'
Regards
Antoine.
_______________________________________________
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