By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,300 Members | 1,789 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,300 IT Pros & Developers. It's quick & easy.

import with "python -O"

P: n/a
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@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@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
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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@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@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
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.