porting python script from linux to windows

Hans Nowak hans at zephyrfalcon.org
Fri Dec 12 22:08:59 EST 2003


hokieghal99 wrote:
> What are the specific steps that one should take to make a python script 
> that works on a Linux x86 machine also work on a Windows x86 machine?

Run it, and see what happens. ;-)  Seriously, in theory there is no reason why 
it shouldn't work right out of the box, unless you have platform-specific code. 
  So I'd say, just run it and see if you encounter any problems.

> I am using os, re and string in the script. How do paths differ between 
> the two OSes? I am use to a unix-like path /blah/blah/blah. Would I need 
> to change this to x:\blah\blah\blah where x = drive letter? 

Maybe.  Paths with slashes can be used on Windows as well.

> What about 
> creating fs objects? file works the same on both? os.walk works the same?

Files should work the same, except that on Windows opening files in 'binary 
mode' is different from 'text mode'.  os.walk should work just fine.

HTH,

-- 
Hans (hans at zephyrfalcon.org)
http://zephyrfalcon.org/







More information about the Python-list mailing list