"SyntaxError: unexpected EOF while parsing" while iterating a dictionary in PDB

Solution 1:

You can't enter multi-line statements in pdb. You can use the commands command if the code block is to be executed on a break point, though; help commands for more information.

You can also sometimes collapse a multi-line statement into a single line. For example:

for d in dir(request): print d

In your particular case, though, it seems that either print dir(request) or pp dir(request) would suffice.

Solution 2:

At the pdb prompt, do the following:

(Pdb) a = [1, 2, 3, 4]
(Pdb) for i in a:
*** SyntaxError: unexpected EOF while parsing (<stdin>, line 1)
(Pdb) import code
(Pdb) code.interact(local=locals())
>>> for i in a:
...     print i
... 
1
2
3
4