Python Gotcha's?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Apr 16 01:34:46 EDT 2012


On Sun, 15 Apr 2012 13:01:54 -0700, Bryan wrote:

> Steven wrote:
>> Yes, but I have reasons for disagreeing, which you trimmed out of your
>> response. If you have reasons for thinking that a separate file
>> extension for Python 3 is a good idea, you are keeping it to yourself.
> 
> On Windows the file extension determines what executable opens the file.
> Running both Python 2 and Python 3 on Windows is painful where it
> doesn't need to be.

And how is that different from any other two versions of Python?

Unless both versions include the same libraries (either standard modules 
or third party), and your code is written to use only the lowest common 
denominator functionality, you will have problems regardless of which 
versions they are.

It is true that simple Python code using no external libraries has a 
better chance of working without modification across multiple 2.x 
versions than across the 2-3 transition, but that's not an absolute. 
Going from 2.5 to 2.6 can cause breakage; on the other hand with care you 
can support 2.6-3.2. With some extra effort, you can support 2.5 or even 
older too.

(Sufficiently trivial, or careful, code can probably support any version 
of Python from 1.4 to 3.2 inclusive. But it wouldn't be pleasant.)

The situation is worse on Windows, as Windows doesn't support hash-bang 
syntax. But that is being looked at now:

http://www.python.org/dev/peps/pep-0397/

which should make supporting multiple Python versions much more pleasant 
Real Soon Now.



-- 
Steven



More information about the Python-list mailing list