<div class="gmail_quote">On Sat, Dec 5, 2009 at 12:01 PM, Carsten Haese <span dir="ltr"><<a href="mailto:carsten.haese@gmail.com">carsten.haese@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">Victor Subervi wrote:<br>
>>>> d = {'cat': {'one':'two'}}<br>
>>>> for a, b in d:<br>
> ...<br>
>   File "<stdin>", line 2<br>
><br>
>     ^<br>
> IndentationError: expected an indented block<br>
>>>> d = {'cat': {}}<br>
>>>> for a, b in d:<br>
> ...<br>
>   File "<stdin>", line 2<br>
><br>
>     ^<br>
> IndentationError: expected an indented block<br>
>>>><br>
><br>
> So apparently, if either the nested dict is populated or not doesn't<br>
> seem to throw any errors in the interpreter.<br>
<br>
</div>What do you mean by "doesn't seem to throw any errors in the<br>
interpreter?" Can't you see the IndentationErrors above?!?<br>
IndentationErrors *are* errors!<br>
<br>
A for-loop needs to have at least one statement inside the suite after<br>
the colon. You're not putting any statements after the colon, and that's<br>
why Python is throwing the same error in either case.<br>
<br>
Because you're not entering syntactically correct code, the interpreter<br>
session never even gets around to iterating over the dictionary, so your<br>
session dies before it gets a chance to reproduce the error you're<br>
looking for. If you put a dummy "pass" statement into the loop, you'll<br>
reproduce the ValueError you're trying to troubleshoot:<br>
<div class="im"><br>
>>> d = {'cat': {'one':'two'}}<br>
>>> for a, b in d:<br>
</div>...     pass<br>
...<br>
Traceback (most recent call last):<br>
  File "<stdin>", line 1, in <module><br>
<div class="im">ValueError: too many values to unpack<br>
<br>
</div>As far as what's causing this error, I already explained that two weeks<br>
ago: <a href="http://groups.google.com/group/comp.lang.python/msg/b9e02a9a9b550ad3" target="_blank">http://groups.google.com/group/comp.lang.python/msg/b9e02a9a9b550ad3</a><br>
<br>
The fact that you're still struggling with this error is deeply<br>
disturbing to me.<br></blockquote><div><br>Relax, Carsten. Of course I knew about those indentation errors, etc. I was testing to see if it would even take the line I entered. I wasn't interested in supplying anything beyond that.<br>
<br>The others who answered this post hit the issue squarely. This "pseudo-code" was actually supplied to me by one of you python "gurus" who has all my respect, so I didn't review it as closely as I should have. My apologies.<br>
Thanks,<br>V<br></div></div>