Zip Question

Stephen Hansen apt.shansen at gmail.com
Fri Oct 9 20:10:50 CEST 2009


On Fri, Oct 9, 2009 at 11:04 AM, Victor Subervi <victorsubervi at gmail.com>wrote:

> So, because the results in sstp were duplicates ( ['prescriptions',
> 'prescriptions'] ) it only returned one result in the dict(zip()) statement.
> Weird. Bug or feature? ;)
> Thanks,
> V


Feature.

zip() returned two results, but dictionaries are mappings of keys to values.
If you duplicate a key, you don't get multiple values for that key -- you
replace the value.  If you want something dictionary like which has multiple
values, try something like:

http://code.activestate.com/recipes/52219/

Or even this dict subclass:

http://code.activestate.com/recipes/440502/

HTH,

--S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091009/80977938/attachment.html>


More information about the Python-list mailing list