Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7840

Re: Embedding Python in a shell script

From Timo Lindemann <tlindemann@arcor.de>
Subject Re: Embedding Python in a shell script
Newsgroups comp.lang.python
References <mailman.50.1308272248.1164.python-list@python.org>
Message-ID <cpydncH6HOHbDmbQnZ2dnUVZ8uadnZ2d@powerusenet.com> (permalink)
Date 2011-06-17 12:47 -0500

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Embedding Python in a shell script Jason Friedman <jason@powerpull.net> - 2011-06-17 00:57 +0000
  Re: Embedding Python in a shell script Timo Lindemann <tlindemann@arcor.de> - 2011-06-17 12:47 -0500
    Re: Embedding Python in a shell script Hans Mulder <hansmu@xs4all.nl> - 2011-06-17 22:15 +0200
      Re: Embedding Python in a shell script Timo Lindemann <tlindemann@arcor.de> - 2011-06-17 15:43 -0500

csiph-web