Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'else:': 0.03; 'elif': 0.04; 'subject:Python': 0.05; 'bash': 0.07; 'python': 0.09; '"if': 0.09; 'eof': 0.09; 'received:internal': 0.09; 'sys.exit(2)': 0.09; 'portion': 0.13; '"import': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:66.111.4.27': 0.16; 'received:mail.srv.osa': 0.16; 'received:messagingengine.com': 0.16; 'received:nyi.mail.srv.osa': 0.16; 'received:osa': 0.16; 'received:out3-smtp.messagingengine.com': 0.16; 'received:srv.osa': 0.16; 'subject:windows': 0.16; 'sys.exit(1)': 0.16; 'true:': 0.16; 'wrote:': 0.17; 'script.': 0.17; '(in': 0.18; 'windows': 0.19; 'module': 0.19; 'import': 0.21; 'posted': 0.22; 'header:In-Reply-To:1': 0.25; 'ago': 0.27; 'question': 0.27; 'converting': 0.27; 'lines': 0.28; "i'm": 0.29; 'code': 0.31; 'print': 0.32; 'like:': 0.33; 'received:10.0': 0.33; 'to:addr :python-list': 0.33; 'list': 0.35; 'jason': 0.35; 'similar': 0.35; 'something': 0.35; 'but': 0.36; 'wanted': 0.36; 'method': 0.36; 'bad': 0.37; '(for': 0.37; 'files': 0.38; 'some': 0.38; 'received:10': 0.38; 'to:addr:python.org': 0.39; 'little': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'think': 0.40; 'most': 0.61; 'between': 0.63; 'within': 0.64; 'world:': 0.91 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=letterboxes.org; h=message-id:subject:from:to:date:in-reply-to:references :content-type:mime-version:content-transfer-encoding; s=mesmtp; bh=ifqX/xER3BvCDlRX9Tgo5bDsxks=; b=nHEC9Nz5+mquiAlQiFSFVVvCHd+Y a4aWSY+OUjGyldpOmbAX4c3voTAUlVQ5ilFJsX08ykHpzeLeG9lYPe5E7KkQ5ajp uMpM4tPMOro9bS/pAiE+kcgafgpvyjTEKm8pOA6UzHJ7g0XLOy0wh7muLPF2UkMW bCbT0SYanPcrdeo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:subject:from:to:date :in-reply-to:references:content-type:mime-version :content-transfer-encoding; s=smtpout; bh=ifqX/xER3BvCDlRX9Tgo5b Dsxks=; b=klt/ZOxYeyC1xxyIFuU1USBPcosKF5ALl3vM2ERriU6ug2BCGGP8PZ SAu/2elZ+yJtRPUopVQFoR+H/WZbAMqMcUkVRH4qlOyX+SGzvXlLoZ7GGmJAPyve tTxrFbzYkcxOWNOUulAwgf27gvdBvTNAO/JvNXxx8OuWHvOwiHmdc= X-Sasl-enc: BpqWBLsBDuZe/g9i4+THFFojiJQh+NFcvXfjggGMTKUX 1348077104 Subject: Re: 'indent'ing Python in windows bat From: Albert Hopkins To: python-list@python.org Date: Wed, 19 Sep 2012 13:51:44 -0400 In-Reply-To: References: <5057C990.8080809@invtools.com> Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAAXNSR0IArs4c6QAAADBQTFRF1///CwsLGxsbJycnNzc3RUVFU1NTYmJicXFxf39/jIyMm5ubq6urubm5yMjI3t7eukg4JQAAAAF0Uk5TAEDm2GYAAAIoSURBVDhPpZC9btRQEEbPGIJQhOIZB4SEhGJ7W/42lihoKCJ6agoeglfgDXiQPAGEio5sKGgTLxRIFNk7DigV7FD4J4SW23jud+75ZA38x9ncnb3wf0PgjZnZdvo35rVZZWa3RiLDd+PGMNz5oABkw/2e9ne+HTgwGRt3nejHzc8Gk/EURfvx/IgLcK3YNZWB7C8vwFqtqcxEAPYD4CoAr5xUiBaJlfOrvTA+IRLqLhisWx/B9RItzckjHCJNxtqKGhRBgEiTAWCIBqGXDNBODEdBIWIEgquCiosD6GQsTYzAVVUAH0FCFDPP3ce8Byenx0hhFRBoX5cBFPXJUVILUog6rTOs5Mv5DnGyOAaXHMvb0fiU3z8QbNZAjmg5VXVbP/N0uHhyWJrAl8RYhebzVcq+K4CJ2WgomSbWsSsguRY6GtncD0N0EYImEcrRkPUxXcrKflNYN4LUmqKndQVOV5qOIDp5Vhb518oEqqxgBFuyOhSKlRF4NptPhp22Ee0ylnioNfVkPPLSix1SG9BJrRN4aFcevfNIKw8f8h5k8vtsnlUauSBiF2DD6/ePd5LPAOvzHpw97F6+dbHOk1T1X4DnXN2rlF+OWKXAuN3Cj3HHNW5u/13FzeQtEkv/YU0vDCATjZSn8KqZXwLdA3Kny+q6GZoGwPPFmZ5oNWt29TK4/XSVpK6bPRny4a+Qx1+FrNkrdATji/XHhdTbw55gMrC0TaFTEfwB/cbNxoZIacsAAAAASUVORK5CYII= Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.4.4 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 44 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1348077113 news.xs4all.nl 6934 [2001:888:2000:d::a6]:34571 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29511 On Tue, 2012-09-18 at 22:12 -0600, Jason Friedman wrote: > > I'm converting windows bat files little by little to Python 3 as I find time > > and learn Python. > > The most efficient method for some lines is to call Python like: > > python -c "import sys; sys.exit(3)" > > > > How do I "indent" if I have something like: > > if (sR=='Cope'): sys.exit(1) elif (sR=='Perform') sys.exit(2) else > > sys.exit(3) > > Some months ago I posted what I think is a similar question in the > Unix world: I wanted to call a small portion of Python from within a > Bash script. > > Someone on this list answered (for Bash): > > #!/bin/bash > command1 > command2 > python -c "if True: > import module > if condition: > do_this > else: > do_that > " > command4 > # end code A better way (in *nix) would be, e.g.: #!/bin/sh read -p 'Enter a number ' count python << EOF print 'Odd numbers between 0 and ${count}' for i in range(${count}): if i % 2: print i EOF Horribly bad example, but you get the idea.