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


Groups > comp.lang.python > #7787

Re: Embedding Python in a shell script

References <BANLkTimB7ygPz6YhxSzJWuAf_yGaW-Hdww@mail.gmail.com>
Date 2011-06-17 11:05 +1000
Subject Re: Embedding Python in a shell script
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.54.1308272749.1164.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Jun 17, 2011 at 10:57 AM, Jason Friedman <jason@powerpull.net> 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 True:
      for j in range($i):
          print j
  "
done

Untested, but it's a hack I've used in a few places. The if tells
Python to expect an indent, and nobody cares if your first indent is
two miles and the one after that is only another two spaces.

ChrisA

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


Thread

Re: Embedding Python in a shell script Chris Angelico <rosuav@gmail.com> - 2011-06-17 11:05 +1000
  Re: Embedding Python in a shell script rusi <rustompmody@gmail.com> - 2011-06-16 19:25 -0700
    Re: Embedding Python in a shell script mg <marco.giusti@gmail.com> - 2011-06-17 08:58 +0000

csiph-web