Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion 'indent'ing Python in windows bat
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Albert Hopkins  
View profile  
 More options Sep 19 2012, 1:51 pm
Newsgroups: comp.lang.python
From: Albert Hopkins <mar...@letterboxes.org>
Date: Wed, 19 Sep 2012 13:51:44 -0400
Local: Wed, Sep 19 2012 1:51 pm
Subject: Re: 'indent'ing Python in windows bat

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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.