On 19 June 2012 00:53, Jason Friedman <ja...@powerpull.net> wrote: > Which leads me to another question ... how can I debug these things? > > $ echo 'hello' | python3 -m pdb ~/my-input.py > > /home/jason/my-input.py(2)<module>() > -> import sys > (Pdb) *** NameError: name 'hello' is not defined > -- > http://mail.python.org/mailman/listinfo/python-list >
It's difficult to debug problems that are related to reading from stdin. I don't know of any good way, so I just end up doing things like adding print statements and checking the output rather than using a debugger. Tools like hd can help with checking the input/output files that you're using. If there were a debugger it would probably need to be one with a GUI - the only one I know is spyder but I don't think that will allow you to pipe anything on stdin. One thing I wanted to say is that if your script is intended to work on Windows you'll need to use msvcrt.setmode() to disable newline translation on stdin (I haven't tested with Python 3.x, but it's definitely necessary with Python 2.x). See Frazil's post here: http://stackoverflow.com/questions/2850893/reading-binary-data-from-stdin
-- http://mail.python.org/mailman/listinfo/python-list