using python on the command line with 'here-documents' and pipes

calmar calmar at calmar.ws
Sun Nov 14 13:26:04 EST 2004


On 2004-11-14, Roy Smith <roy at panix.com> wrote:

hi,

> $ python -c 'import sys
>> for line in sys.stdin:
>>     print line[:10]
>> 
>> ' << EOF
>> line one of many
>> line two of many
>> line three of many
>> EOF
> line one o
> line two o
> line three

Yeah, that works nicely.

Actually, I didn't find the solution to just press enter (after a -c
'..) and write the idented code I want.

> executable.  Then you've got a stand-alone program that you can edit and 
> maintain apart from the shell script that surrounds it.  In the long 
> run, this is likely to be simpler to test and to maintain.

Yeah, true.


Thanks a lot to all!

-- 
  calmar
          (o_  It rocks: LINUX + Command-Line-Interface
          //\
          V_/_                     http://www.calmar.ws



More information about the Python-list mailing list