import with "python -O"

Sylvain Thenault sylvain.thenault at nospam.logilab.fr
Thu Dec 30 16:56:17 CET 2004


Hi there !

I'm usually relying on the fact that pyc file are autogenerated when
necessary (ie usually when the py file has been modified since the pyc
creation). However, it doesn't seems to work correctly when the -O option
is given to the interpreter :

syt at musca:test$ python
Python 2.3.4 (#2, Sep 24 2004, 08:39:09)
[GCC 3.3.4 (Debian 1:3.3.4-12)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
.>>> from logilab import pylint
.>>> pylint.__file__
'/home/syt/cvs_work/logilab/pylint/__init__.pyc'
.>>>
syt at musca:test$ python -O
Python 2.3.4 (#2, Sep 24 2004, 08:39:09)
[GCC 3.3.4 (Debian 1:3.3.4-12)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
.>>> from logilab import pylint
.>>> pylint.__file__
'/usr/lib/python2.3/site-packages/logilab/pylint/__init__.pyo'

The PYTHONPATH has not changed but the interpreter seems to take the first
pyo it finds, even if there is a more recent .py file before in the python
path. Should this behaviour be considered as normal ?

-- 
Sylvain Thénault                               LOGILAB, Paris (France).

http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org





More information about the Python-list mailing list