Embedding Python in a shell script

Timo Lindemann tlindemann at arcor.de
Fri Jun 17 13:47:50 EDT 2011


On Fri, 17 Jun 2011 00:57:25 +0000, 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__":
	hello();

EOPYTHON



More information about the Python-list mailing list