Can't get sys.stdin.readlines() to work
Grant Edwards
invalid at invalid.invalid
Sun Jan 31 13:50:56 EST 2010
On 2010-01-31, Steve Holden <steve at holdenweb.com> wrote:
> tinnews at isbd.co.uk wrote:
>> I'm trying to read some data from standard input, what I'm actually
>> trying to do is process some date pasted in using the mouse cut and
>> paste on a Linux box (xubuntu 9.10) in a terminal window.
>>
>> First attempts failed so I'm now trying the trivial:-
>>
>> import sys
>> data = sys.stdin.readlines()
>> print "Counted", len(data), "lines."
>>
>>
>> When I run this and try to paste something into the terminal window I
>> get the following errors:-
>>
>> /home/chris/bin/m2r.py: line 2: syntax error near unexpected token `('
>> /home/chris/bin/m2r.py: line 2: `data = sys.stdin.readlines()'
>>
>>
>> It does exactly the same if I try:-
>>
>> cat | m2r.py
>>
>> and then paste something into the window.
>>
>>
>> So - what on earth am I doing wrong?
>>
>>
> Trying to run Python scripts with /bin/sh, probably.
Yup. I can't count the number of times I've run ImageMagick's
"import" program unintentionally...
--
Grant Edwards grante Yow! The SAME WAVE keeps
at coming in and COLLAPSING
visi.com like a rayon MUU-MUU ...
More information about the Python-list
mailing list