strange dict issue
Ferdinand Sousa
ferdinandsousa at gmail.com
Mon Jan 12 08:26:40 EST 2009
James
First off, the computer is always right :-)
> {'value': 'Route66', 'key': 'NAME'}
>
>
>
> Yet when the second line of my code throws an error saying the key 'NAME'
> doesn't exist.
>
If you look carefully the key NAME indeed does not exist. The dictionary
contains 2 key-value pairs.
This should clear things out:
*key * *value
*'value' 'Route66'
'key' 'NAME'
Get it? NAME is a value, not a key. You have used the string 'key' itself as
a dictionary key. My advice would be to not use such conflicting names.
Regards,
Ferdi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090112/6ca2e062/attachment-0001.html>
More information about the Python-list
mailing list