Zip Question

Victor Subervi victorsubervi at gmail.com
Fri Oct 9 20:04:39 CEST 2009


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

On Fri, Oct 9, 2009 at 12:37 PM, Stephen Hansen <apt.shansen at gmail.com>wrote:

>
>
> Changing the line:
>>  subtypes = dict(zip(sstp, sst))
>> to:
>> subtypes = dict(zip(sst, sstp))
>> as I believe Stephen misread it to be causes the zip operation to return:
>> [('doctors', 'prescriptions'), ('patient', 'prescriptions')]
>> and thus the dict will contain:
>> {'patient': 'prescriptions', 'doctors': 'prescriptions'}
>>
>>
> Whoops! You're absolutely right. I totally flipped the options to zip in my
> head when eyeing it. I suppose I'm suffering from late-onset dyslexia. Ahem.
>
> Yeah, I think the arguments to zip() were probably just flipped in Victor's
> code. Unless he wants a result different then what I assume is expected. I
> assume he's expecting {"doctors": "prescriptions", "patient":
> "prescriptions"}. If instead its something more like {"prescriptions":
> ["doctors", "patient"]} then zip() isn't how to accomplish it.
>
> --S
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091009/c1017c71/attachment.html>


More information about the Python-list mailing list