Re: [Python-Dev] Add a "transformdict" to collections

2013年9月11日 09:35:54 -0700

2013年9月11日 Ethan Furman <[email protected]>:
> He isn't keeping the key unchanged (notice no white space in MAPPING), he's
> merely providing a function that will automatically strip the whitespace
> from key lookups.
transformdict keeps the key unchanged, see the first message:
 >>> d = transformdict(str.lower)
 >>> d['Foo'] = 5
 >>> d['foo']
 5
 >>> d['FOO']
 5
 >>> list(d)
 ['Foo']
'Foo' is stored as 'Foo', not as 'foo'. So for stripped keys:
d=transformdict(str.strip); d[' abc ']; print(list(d))
should print "[' abc ']", not "['abc']".
Is it the expected result?
Victor
_______________________________________________
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