import with "python -O"

Sylvain Thenault sylvain.thenault at nospam.logilab.fr
Thu Dec 30 11:20:49 EST 2004


On Thu, 30 Dec 2004 16:56:17 +0100, Sylvain Thenault wrote:

> 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 ?

ok, my fault... The problem was that the logilab subdirectory didn't have
anymore the __init__.py file, but only the __init__.pyc file. Adding it
fix the problem.
Thank you four your attention.

-- 
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