python: cross-platform?

Fernando Pérez fperez528 at yahoo.com
Wed May 8 05:09:29 EDT 2002


Eric Texier wrote:

> Is there a guide line for writing cross-platform code in python. I am
> dealing with only one os for now but I would like to be sure that I am
> using only cross platform code.
> Thanks in advance

As always, the devil is in the details. But in broad strokes, never call 
os.system(), os.popen*() [unless you know what you are calling exists 
everywhere], and do all file handling via shutil or os.path and friends (in 
particular, use os.path.join liberally).

Also don't import modules with obvious os dependencies like win32. 

For gui stuff, Tkinter isn't the best around but its extremely portable, Qt 
(via pyqt) is from what I hear very portable and wxpython a bit less (though 
they seem to be making progress).

cheers,

f.



More information about the Python-list mailing list