converting from shell script to python
Hal Wine
hal_wine at yahoo.com
Tue Apr 1 12:32:13 EST 2003
William Park wrote:
> Shao Zhang <shao at cia.com.au> wrote:
>
>>I need to convert a very simple shell script to python in order get it
>>run on both windows and unix. However I cannot quite work out a simple
NB: ^^^^^^^
Which means that the class path needs to look like a normal file
path on each platform. Which, afaik, _does_ mean using
os.path.join and os.pathsep
As 'elegant' as I can get is
import os
ROOTDIR = r'c:\lib'
JARS = ( ('a', 'a.jar'),
('b', 'b.jar'),
('c', 'c.jar'))
CLASSPATH = os.pathsep.join(
map(lambda x: os.path.join( ROOTDIR, *x ), JARS) )
os.system( 'java -classpath %s foo' % (CLASSPATH) )
>
>>Will perl be a better
>>choice for things like this?
Not IMO -- it's harder to find the equivalent of os.pathsep...
More information about the Python-list
mailing list