Re: Are ActivePython scripts compatible with Linux?



Thanks alot Larry for your comprehensive answer.

"Larry Bates" <larry.bates@xxxxxxxxxxx> wrote in message
news:SYCdnZBPbu0GTeDZnZ2dneKdnZydnZ2d@xxxxxxxxxxxxxx
Short answer: yes

Things to watch out for:

1) Versions on both Windows/Linux need to be compatible. If Linux
has same or later version, you are normally OK. If Linux version
is older, you will have to use only Python Libraries and functions
that are in the oldest version.

2) Don't use OS-specific constructs. Things like backslashes
in filenames, etc. Use os.path.join, os.path.basename, etc. to work
with paths. Linux has OS-specific code that handles all the
cross-OS problems for you if you use these methods. Don't hard
code drive letters in your code, Linux/Mac don't have drive letters.

3) Obviously you can't use Python Windows extensions, which won't
port. You can't move something that is written as COM object or
as a Windows service (sorry those were probably too obvious ;-).

4) If you use GUI, use something that is cross-platform (like
wxWindows, TK, etc.). You can't use Windows-specific GUI calls.

5) You can be affected by word length issues if you move from
32-bit Windows to 64-bit Linux. Normally this is only only
a problem if you use struct module to pack/unpack buffers or if
you do bit shift operations (e.g. <<, >>).

6) Don't depend on Windows line endings in files. Linux/Mac
use different ones than Windows.

7) Some Linux machine have different endian storage of bytes.
If you do bit shifting or struct pack/unpack you will need to
take that into account.

8) If you have OS-specific "things" in your code, put them in
a function or class that can easily be rewritten for the
specific OS you are porting to. Don't spread them out all
through your code. It is much easier to rewrite a couple of
functions/classes that are OS-specific than it is to try to
find problems all over your program.

Hope info helps at least a little.

-Larry


A.M wrote:
Hi,



I am planning to develop python applications on windows and run them on
Linux. Are ActivePython scripts compatible with Linux? Is there any
guideline that explains the compatibility issues between python in
different
platforms?



What would be the best approach for what I am trying to do?



Any help would be appreciated,

Alan




.



Relevant Pages

  • Re: OT: Mozilla/Firefox (was:Re: Windoze ends year with a major cert ...)
    ... How many Linux users are there worldwide? ... Windows as a desktop OS (though it's coming closer and closer to ... underlying OSs and compatibility at the application level. ... applications like browsers. ...
    (comp.os.vms)
  • Re: Crossover / Wine cannot install Office
    ... fill-in-the-form database apps on Linux. ... if that is the business you have chosen. ... I'll use Access under Windows. ... Office compatibility are an order of magnitude more exacting than most ...
    (comp.os.linux.misc)
  • Re: PcLinux
    ... first instance, we use Java. ... Can't comment on Python because I've never used it. ... Postgresql running on linux works nicely. ... Returning to comments WRT the aesthetics of OS X vs Windows - it's a ...
    (rec.crafts.metalworking)
  • Re: Future of IT in Lebanon
    ... working knowledge of Indian programmers DNA, nor of their intuitive Java ... > So Longhorn is not an experiment and Linux is an experiment? ... another chapter in the Windows story, and the Microsoft marketing machine is ... > application opens, Check the about, it says Microsoft Visual Basic 6.3. ...
    (soc.culture.lebanon)
  • Re: Pyhton Interpreter Startup time
    ... versions of Python for comparisons (the first time a new version is ... Similar startups on a PIII-333 running a Gentoo 2.4.x Linux install ... posix/posixpath with nt/ntpath under Windows) and then an additional ...
    (comp.lang.python)