[Zope] windows python differences

Tino Wildenhain tino at wildenhain.de
Fri May 19 03:01:09 EDT 2006


garry saddington wrote:
> This code on linux works without a problem
> 
> ispell = os.popen("echo " + word +
> | /opt/scholarpack/ancillary/ispell/bin/ispell -a")
> ispell.readline
> sentence = ispell.readline()


What if the word is like `rm -rf /`  for example?
Doing something like that above is completely
creazy :( There are actually 3 different popen()
variants - 2 of them give you stdin too so you better
use this to write the "word" to ispells stdin.
Don't use echo or something like this!
...
> 
> however on windows it throws a string index out of range at the
> sentence[0] constructs.
> 
> the popen command on windows is:
> ispell=os.popen("echo" +word+ "\scholarpack\ancillary\ispell\bin\ispell
> -a")
> 
> Anyone know what the difference is on the two platforms?

As Andreas already said (and you can easily see by
comparing the strings, can you? ;)
Python has os.path.join() to construct paths
for the actual platform.
(And since this is a 3rd party tool anyway, you
might want to make it configurable - of course not
via ZMI)

Regards
Tino


More information about the Zope mailing list