Re: Embedding Python in a shell script

2011-06-17 Thread Jason Friedman
Thank you, everyone, for your suggestions. I'll try them all and decide which I like best. -- http://mail.python.org/mailman/listinfo/python-list

Re: Embedding Python in a shell script

2011-06-17 Thread Timo Lindemann
On Fri, 17 Jun 2011 22:15:57 +0200, Hans Mulder said: > On 17/06/11 19:47:50, Timo Lindemann wrote: >> On Fri, 17 Jun 2011 00:57:25 +, Jason Friedman said: >> >> >> >>> but for various reasons I want a single script. Any alternatives? >> >> you can use a here document like this: > That does n

Re: Embedding Python in a shell script

2011-06-17 Thread Hans Mulder
On 17/06/11 19:47:50, Timo Lindemann wrote: On Fri, 17 Jun 2011 00:57:25 +, Jason Friedman said: but for various reasons I want a single script. Any alternatives? you can use a here document like this: #! /bin/bash /usr/bin/python2<< EOPYTHON def hello(): print("Hello, Worl

Re: Embedding Python in a shell script

2011-06-17 Thread Timo Lindemann
On Fri, 17 Jun 2011 00:57:25 +, Jason Friedman said: > > but for various reasons I want a single script. Any alternatives? you can use a here document like this: #! /bin/bash /usr/bin/python2 << EOPYTHON def hello(): print("Hello, World"); if __name__ == "__main__": hel

Re: Embedding Python in a shell script

2011-06-17 Thread mg
rusi wrote: > On Jun 17, 6:05 am, Chris Angelico wrote: > >> > Python call becomes.  I'd prefer something like: >> >> #!/bin/bash >> for i in 1 2 3 4; do >>   python -c "if True: > # comfortably indented python code > > Thanks. Nice! You can use bash here document feature, <<-, that strips hea

Re: Embedding Python in a shell script

2011-06-16 Thread rusi
On Jun 17, 6:05 am, Chris Angelico wrote: > > Python call becomes.  I'd prefer something like: > > #!/bin/bash > for i in 1 2 3 4; do >   python -c "if True: # comfortably indented python code Thanks. Nice! -- http://mail.python.org/mailman/listinfo/python-list

Re: Embedding Python in a shell script

2011-06-16 Thread Chris Angelico
On Fri, Jun 17, 2011 at 10:57 AM, Jason Friedman wrote: > The code behaves as I expect and want, but the de-denting of the > Python call is unattractive, especially unattractive the longer the > Python call becomes.  I'd prefer something like: > #!/bin/bash for i in 1 2 3 4; do python -c "if Tr