[Tutor] iterating through large dictionary

Sean Perry shaleh at speakeasy.net
Tue Mar 22 23:04:10 CET 2005


>>D:\Python24>ad-attr.py
>>Traceback (most recent call last):
>>  File "D:\Python24\ad-attr.py", line 32, in ?
>>    for k, v in ad_dict(user):
>>ValueError: too many values to unpack
> 
> 
> Try this instead ... I think it should help:
> 
> <code>
> 
> for k,v in ad_dict(user).items():
> 
> </code>

in 2.3 and newer, the preferred function is 'iteritems()' instead of 
'items()'. Faster, less mem use, etc.


More information about the Tutor mailing list