Windows - Drag & drop on Python script?

Tim Peters tim_one at email.msn.com
Thu Jun 24 22:32:31 EDT 1999


[Greg Ewing]
> ...
> Another question - what is the recommended way of
> getting the effect of a unix #!? I came up with:
>
> python -x %0 %1
> exit
> <python code here>
>
> which only works by the serendipitous fact that
> there is an 'exit' defined in the python builtins.
> Without the exit, after the python finishes, the
> shell goes on to try and interpret it as msdos
> commands!
>
> Is there a more elegant way to do this?

Dale Nagata has a cute one-liner for this; see

    http://www.deja.com/getdoc.xp?AN=465164252

The bug he reported there (tracebacks are off by a line when using -x)
didn't get fixed in time for 1.5.2, alas; it is fixed in the development
version.  Note too that parts of Dale's method require that you're running
NT and have "cmd extensions" enabled (which is the default, so don't worry
about it if it doesn't make sense).

> Another other question - what is the "Batch File"
> box in the Properties dialog of a .bat file for?
> If you put the name of another .bat file there,
> it gets executed before the main file. But what
> is its purpose? Just curious.

It's more useful for certain kinds of .exe's, where it can be convenient to
run a .bat file to fiddle system properties before the .exe gets run.
Usually see it only in programs with deep Windows backward-compatibility
problems.

but-still-useful-to-e.g.-delete-copies-of-perl.exe-from-your-disk-ly y'rs
    - tim






More information about the Python-list mailing list