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


Groups > comp.lang.python > #7787

Re: Embedding Python in a shell script

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.012
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; '"if': 0.04; 'subject:Python': 0.06; 'python': 0.08; 'am,': 0.14; 'received:209.85.214.174': 0.14; 'received:mail- iw0-f174.google.com': 0.14; 'wrote:': 0.14; 'cares': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'indent': 0.16; 'places.': 0.16; 'header:In-Reply-To:1': 0.21; 'jason': 0.22; 'tells': 0.22; 'fri,': 0.23; 'code': 0.24; 'expect': 0.25; 'message-id:@mail.gmail.com': 0.28; 'received:209.85.214': 0.28; 'behaves': 0.30; 'print': 0.31; 'done': 0.32; 'to:addr:python-list': 0.33; "i've": 0.33; 'nobody': 0.34; '17,': 0.35; 'like:': 0.35; 'received:google.com': 0.37; 'something': 0.37; 'received:209.85': 0.37; 'hack': 0.37; 'miles': 0.37; 'another': 0.37; 'two': 0.37; 'but': 0.38; 'subject:: ': 0.38; 'received:209': 0.39; 'to:addr:python.org': 0.39; 'your': 0.60; 'want,': 0.74; '#!/bin/bash': 0.84; '10:57': 0.84; 'spaces.': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=NENBM4CCW0vq5bx7mxlkY0tLgDvyyYdcYbJX+AL2PEc=; b=EvQidxbxPzWe4oxebRTIhfVxAWKtIZ0CB5n5LDPkiQGNn8ctBPHnKNCEpQXFhGgq2R mUmixQE4xuV3kz5bmXkREHH4dI6GtfAMNc41RC5kVGlWO3rq5JExMjtRYWNUD85jWm+V KAZ238J9YH0ONZZtraBRcAD3q0T8mMSODur9Y=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=EcQYlagmgaPRJnnJe5PqZg/BScKs1dFe0dDSYp9AEJE7m+f++f9E30vcj3oa0Dxgt7 D0KJHA9lBGUGd40hs0DstLhLV6EZqISqVisyDwayb0R8HNh1MrL3Lqf5ukYzsHX/eDKq LJfRW3xC8GqO8CVxdF+WCIjYsakHpMS/2fboA=
MIME-Version 1.0
In-Reply-To <BANLkTimB7ygPz6YhxSzJWuAf_yGaW-Hdww@mail.gmail.com>
References <BANLkTimB7ygPz6YhxSzJWuAf_yGaW-Hdww@mail.gmail.com>
Date Fri, 17 Jun 2011 11:05:46 +1000
Subject Re: Embedding Python in a shell script
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.54.1308272749.1164.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 82.94.164.166
X-Trace 1308272749 news.xs4all.nl 49179 [::ffff:82.94.164.166]:59772
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:7787

Show key headers only | 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