yakupme yakupme - 1 year ago 148
Python Question

TypeError: 'long' object is not iterable

I have just created a dictionary in python.

stb_info = self.stb_type()
print type(stb_info) #The output gives me dict

When I want to run my tread function for each group

for group_no, shelves in stb_info:
self.thread_function(group_no, shelves)

I am getting the following error:

TypeError: 'long' object is not iterable

So, how I can solve this bug?

Answer Source

Try stb_info.items(). Just iterating over a dict iterates over its keys, so it's trying to unpack a key (a long) into two parts, which isn't possible.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download