On 10/27/10 08:27, Martin Gregorie wrote:
(2) made me take care of 2 files instead of 1 from now on.

Not necessarily:

$ cat heredoc.sh
#!/usr/bin/env bash
python<<  'EOF'
print "hello world"
def foo():
     print "foo()"
foo()
EOF
$

Or even better:

$ cat hello
#!/usr/bin/python
print "hello world"
def foo():
     print "foo()"
foo()

$ chmod u+x hello
$ hello
hello world
foo()
$

which saves an unnecessary shell invocation.

Note that the OP was including this inside a pre-existing shell-script that was working for their purposes. Lie's suggestion allows Python to be embedded in the existing shell-script; to use your solution, the OP would have to rewrite their entire existing script in Python (not necessarily a bad thing in my book, for maintainability purposes, but does not appear to be at the top of their list of things to do)

-tkc


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to