How to define a new function in pdb
pdb, python, python-2.7
Solution
You can define your function in a one line statement using `;` instead of indentation, like this:
(Pdb) def foo(): print 'Hello world'; print 'I see you'
(Pdb) foo()
Hello world
I see you
Problem
Why can't I define new functions when I run `pdb`? For example take myscript.py: ``` #!/gpfs0/export/opt/anaconda-2.3.0/bin/python print "Hello World" print "I see you" ``` If I run `python -m pdb myscript.py` and try to interactively define a new function: ``` def foo(): ``` I get the error: ``` *** SyntaxError: unexpected EOF while parsing (<stdin>, line 1) ``` Why is this?