Writing portably for 1.5.1 using 1.5.2

François Pinard pinard at iro.umontreal.ca
Sat Sep 25 08:16:47 EDT 1999


Hello, people.

I'm using 1.5.2 on my development machines, but have to execute the scripts
on machines still having 1.5.1, from time to time.  I notice that on 1.5.1,
I have to write:

if __name__ == '__main__':
    apply(main, tuple(sys.argv[1:]))

instead of:

if __name__ == '__main__':
    apply(main, sys.argv[1:])

There are some newer functions and modules, but it did not hurt me much
so far.  Is there, by any chance, some guide about writing Python portably
between versions?


P.S. - I got a few unexpected bugs on a given system using 1.5.2, which
problems did not show on other 1.5.2 systems.  Strange!  For example,

   exec 'recipes.append(%s())' % class_name

was always failing to resolve the name to a class.  I'll postpone exploring
this problem.  In the meantime, for this machine only, I reorganised all
the code so to not need `exec', and I feel better for stylistic reasons :-).

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard





More information about the Python-list mailing list