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


Groups > comp.lang.python > #29404 > unrolled thread

Re: 'indent'ing Python in windows bat

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2012-09-17 21:01 -0600
Last post2012-09-19 09:53 +0200
Articles 3 — 3 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: 'indent'ing Python in windows bat Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-17 21:01 -0600
    Re: 'indent'ing Python in windows bat Roy Smith <roy@panix.com> - 2012-09-17 23:17 -0400
    Re: 'indent'ing Python in windows bat Hans Mulder <hansmu@xs4all.nl> - 2012-09-19 09:53 +0200

#29404 — Re: 'indent'ing Python in windows bat

FromIan Kelly <ian.g.kelly@gmail.com>
Date2012-09-17 21:01 -0600
SubjectRe: 'indent'ing Python in windows bat
Message-ID<mailman.854.1347937306.27098.python-list@python.org>
On Mon, Sep 17, 2012 at 7:08 PM, David Smith <davids@invtools.com> wrote:
> 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)

How about:

if sR == 'Cope':
    sys.exit(1)
elif sR == 'Perform':
    sys.exit(2)
else:
    sys.exit(3)

I don't really understand why you're trying to keep it all on one line.

[toc] | [next] | [standalone]


#29405

FromRoy Smith <roy@panix.com>
Date2012-09-17 23:17 -0400
Message-ID<roy-042AE8.23175417092012@news.panix.com>
In reply to#29404
In article <mailman.854.1347937306.27098.python-list@python.org>,
 Ian Kelly <ian.g.kelly@gmail.com> wrote:

> On Mon, Sep 17, 2012 at 7:08 PM, David Smith <davids@invtools.com> wrote:
> > 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)
> 
> How about:
> 
> if sR == 'Cope':
>     sys.exit(1)
> elif sR == 'Perform':
>     sys.exit(2)
> else:
>     sys.exit(3)
> 
> I don't really understand why you're trying to keep it all on one line.

sys.exit({'Cope':1, 'Perform':2}.get(sR, 3))

[toc] | [prev] | [next] | [standalone]


#29469

FromHans Mulder <hansmu@xs4all.nl>
Date2012-09-19 09:53 +0200
Message-ID<50597a08$0$6961$e4fe514c@news2.news.xs4all.nl>
In reply to#29404
On 18/09/12 05:01:14, Ian Kelly wrote:
> On Mon, Sep 17, 2012 at 7:08 PM, David Smith <davids@invtools.com> wrote:
>> 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)
> 
> How about:
> 
> if sR == 'Cope':
>     sys.exit(1)
> elif sR == 'Perform':
>     sys.exit(2)
> else:
>     sys.exit(3)
> 
> I don't really understand why you're trying to keep it all on one line.

He's using Windows.

If he were on Unix, there'd be no problem:

python -c 'import sys
if sR == "Cope":
    sys.exit(1)
elif sR == "Perform":
    sys.exit(2)
else:
    sys.exit(3) '

Unfortunately, the Windows shell doesn't do multi-line strings,
so he has to cram it all on one line.


-- HansM

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web