Error message <exceptions.TypeError unpack non-sequence>

ahsan Imam ahsan.imam at newtimes.com
Thu Feb 5 23:59:36 CET 2004


Hello All,

I am trying to move an application from python 1.5.2 to 2.3. The code
works fine in 1.5.2 but gives the exception (exceptions.TypeError
unpack non-sequence) in python 2.3. I did not write this code so I am
not sure what is happening here.

Here is the code snippet:

for (item, agent) in self.lItems:
      lItems.append(interpolate(self._ITEM_FMT, id=str(item)))

Note:
self.lItems contains two elements.

Questions:
1) What is the for statement doing?
2) Is this called tuple unpacking or list unpacking? 
3) Is there newer syntax?
4) Why does he use the "for" loop like that?

Any help is appreciated.

Thanks
Ahsan



More information about the Python-list mailing list