Re: Read STDIN as bytes rather than a string

2012-06-19 Thread Oscar Benjamin
On 19 June 2012 00:53, Jason Friedman 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)() > -> import sys > (Pdb) *** NameError: name 'hello' is not defined > -- > http://mail.python.org/m

Re: Read STDIN as bytes rather than a string

2012-06-18 Thread Jason Friedman
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)() -> import sys (Pdb) *** NameError: name 'hello' is not defined -- http://mail.python.org/mailman/listinfo/python-list

Re: Read STDIN as bytes rather than a string

2012-06-18 Thread Jason Friedman
> sys.stdin wraps a buffered reader which itself wraps a raw file reader. > sys.stdin > <_io.TextIOWrapper name='' mode='r' encoding='UTF-8'> sys.stdin.buffer > <_io.BufferedReader name=''> sys.stdin.buffer.raw > <_io.FileIO name='' mode='rb'> > > You should read from sys.stdin.buffe

Re: Read STDIN as bytes rather than a string

2012-06-18 Thread Christian Heimes
Am 19.06.2012 01:13, schrieb Jason Friedman: > I tried this: sys.stdin wraps a buffered reader which itself wraps a raw file reader. >>> sys.stdin <_io.TextIOWrapper name='' mode='r' encoding='UTF-8'> >>> sys.stdin.buffer <_io.BufferedReader name=''> >>> sys.stdin.buffer.raw <_io.FileIO name='' m

Re: Read STDIN as bytes rather than a string

2012-06-18 Thread Benjamin Kaplan
On Mon, Jun 18, 2012 at 4:13 PM, Jason Friedman wrote: > I tried this: > > Python 3.2.2 (default, Feb 24 2012, 20:07:04) > [GCC 4.6.1] on linux2 > Type "help", "copyright", "credits" or "license" for more information. import sys import io fh = io.open(sys.stdin) > Traceback (most re