Batch commands on Windows

Dave Brueck dave at pythonapocrypha.com
Sat Jan 24 00:19:56 EST 2004


Moosebumps wrote:
[snip]
> # this actually does the same thing as Python, I was mistaken.  I was
> mislead by the IDLE behavior.
[snip]

> The general idea is that it would be nice if there weren't any differences
> between the batch file and python.  From a practical standpoint, it would
> encourage a lot of people to switch from nasty batch files to Python scripts
> if you could just surround the entire thing with os.batch(' ') or some
> similar sort of mechanical textual substitution.  Then you could clean it up
> gradually.

Ah, now I understand what you meant. In practical terms, there isn't much of a
difference between executing Python commands in batch mode or interactively
from the *Python* command prompt (the interactive interpreter), and I think
that's what this all boils down to. A DOS window is an interactive command
prompt for the MS-DOS batch language; Python is a different language and has
its own command prompt, so it wouldn't really make sense for commands in one
language to be valid in the other. It's easy to miss this point though since
its common to access the Python "command prompt" by first launching the DOS
command prompt, but they really are two different languages with two different
purposes.

> > > What's the deal with that?  I thought Python started out as a scripting
> > > language.  And that seems like the most basic thing that a scripting
> > > language should do.
> >
> > Dunno, although MS-DOS shell scripting is certainly a small subset of
> scripting
> > in general. Maybe with a concrete example somebody will be able to give
> you a
> > hand.
>
> It is a small subset, but an important subset.  Shell scripting started
> probably when people got sick of typing the same commands into the prompt.
> For a language to really support shell scripting, it should provide a way of
> automating the process of typing in the commands.  As in, there should be no
> difference whether you're actually typing, or you're running the script.

Right, and there is little difference between batch and interactive modes of
Python, and little difference between batch and interactive modes of MS-DOS,
but what you're wishing for is for batch mode of language A to be the same as
interactive mode of language B. Unless one language is a subset of the other,
that just doesn't make sense (and I'm very pleased that Python is not a
superset of DOS batch files! :) )

> If there is a way and I don't know about it, I would be happy to hear about
> it.  But I do think it is a pretty big hole.

I don't - Python is a general purpose programming language that happens to be
pretty good for so-called "shell scripting" too, but the language is useful in
so many other domains that it wouldn't make sense to tailor it too heavily to
this particular type of problem. Further, if it were to be tailored to make
shell scripting even easier, I really doubt that basing it on the MS-DOS batch
language would be a good idea - even something as quirky as bash would be far
better.

-Dave





More information about the Python-list mailing list