[Python-Dev] Add a -z interpreter flag to execute a zip file

"Martin v. Löwis" martin at v.loewis.de
Fri Jul 13 09:15:50 CEST 2007


>> What happens if multiple entries contain __main__.py entries?  I don't like
>> this one so much.  I don't know what Java does if you specify -jar more than
>> once; that might suggest something.
> 
> You can't with:
> java version "1.5.0_11"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
> Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_11-b03, mixed mode)
> 
> -help says:
>      or  java [-options] -jar jarfile [args...]
>            (to execute a jar file)
> 
> args are passed to the jarfile being run.

Sure. However, you *can* specify multiple jar files on the command
line, in the class path.

java -cp xerces.jar -jar xalan2.jar

This runs xalan2.jar, but adds xerces.jar to the class path. It
has all the advantages of a command line option compared to
setting CLASSPATH: it won't be inherited to subprocesses, and
you can use it on Windows, too, whereas you cannot set environment
variables in the command line on Windows.

So while -z strictly gives the equivalent -jar, it's actually
-cp that is used much more often in Java (I think), and that
doesn't have an equivalent in Python still. My typical usage
of java goes like this

java -cp <endless list of jar files> the.main.class

The equivalent Python line would be

python -p <path> -m main_module

Regards,
Martin


More information about the Python-Dev mailing list