However, the line <<levelDict[nm] = expand(...)>> indicates that the
keys in levelDict are only "nm"s, which are presumably single objects,
not pairs. Also, the "dt" that you're trying to unpack from levelDict's
keys is not used anywhere in your function.
So, this would indicate that changing the offending line to <<for nm in
levelDict>> should fix this particular error.
HTH,
--
Carsten Haese
http://informixdb.sourceforge.net
It's not a statement. It's a function. The function is defined in your
code. Or rather, it's defined in the code that you copied from Dennis
Lee Bieber, apparently. Look at the function definition. It'll tell you
what the function does.
> Could
> someone please explain what this code does?
Maybe you should ask the person that wrote the code.
I already explained what's causing this error. Read my first response on
this thread.
(http://mail.python.org/pipermail/python-list/2009-November/1227008.html)
> I apparently thought "for ... in dictionary" would return (key,
> value) pairs, but it appears that it only returns the key itself -- and
> a single key can't be unpacked.
>
> Misleading error... too many /targets/ to unpack...
My guess is that the keys are strings, which means it's
unpacking them into characters, in which case a key of
length 3 or more will produce that message.
--
Greg
> I apparently thought "for ... in dictionary" would return (key,
> value) pairs, but it appears that it only returns the key itself -- and
> a single key can't be unpacked.
>
> Misleading error... too many /targets/ to unpack...
No, the error is fine.
>>> for x, y in {1:'a'}:
... pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unpack non-sequence
>>>
>>> for x, y in {'a':1}:
... pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: need more than 1 value to unpack
>>>
>>> for x, y in {'parrot':1}:
... pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: too many values to unpack
Strings are iterable, and so unpack into individual characters.
--
Steven