porting python script from linux to windows

BW Glitch bwglitch at hotpop.com
Fri Dec 12 15:50:09 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?
> 
> 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? What about 
> creating fs objects? file works the same on both? os.walk works the same?

Instead of using full paths, try using the os.path.join method. It makes 
it easier to port from/to any OS.

-- 
Glitch

-----BEGIN TF FAN CODE BLOCK-----
G+++ G1 G2+ BW++++ MW++ BM+ Rid+ Arm-- FR+ FW-
#3 D+ ADA N++ W OQP MUSH- BC- CN++ OM P75
-----END TF FAN CODE BLOCK-----

"So you failed."
"Absolutely!"
"Completely."
         -- Optimus Primal, Rattrap, and Airazor, "Before the Storm"





More information about the Python-list mailing list