import with "python -O"

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sylvain Thenault

    #1

    import with "python -O"

    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


  • Sylvain Thenault

    #2
    Re: import with "python -O"

    On Thu, 30 Dec 2004 16:56:17 +0100, Sylvain Thenault wrote:
    [color=blue]
    > 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 ?[/color]

    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


    Comment

    Working...