Re: __pycache__, one more good reason to stck with Python 2?



On Jan 19, 7:03 pm, Antoine Pitrou <solip...@xxxxxxxxxx> wrote:
On Wed, 19 Jan 2011 08:30:12 -0800 (PST)

jmfauth <wxjmfa...@xxxxxxxxx> wrote:
Yes, I can launch a pyc, when I have a single file.
But what happens, if one of your cached .pyc file import
a module with a name as defined in the parent directory?
The machinery is broken. The parent dir is not in the
sys.path.

Well, you don't have to launch a pyc file anyway. Put all your code in
some (pyc) modules on the standard Python path, and use a clear-text
script with some trivial code to invoke a function from the compiled
modules.

That's not the point. I'm toying. And the "behaviour" from now
is deeply different from what it was.

Otherwise you can customize sys.path a little from your script,
using __file__ and os.path.dirname. Nothing complicated AFAICT.

That's not as simple. You have too prepare the py file in such a way,
that it recognizes the path of its ancestor py file. The "home dir"
is no more the same.


(by the way, the fact that pyc files are version-specific should
discourage any use outside of version-specific directories,
e.g. /usr/lib/pythonX.Y/site-packages)

Here we are. I'm just wondering if all this stuff is not just
here in order to satisfy the missmatched Python installation on
*x platforms compared to Windows whre each Python version
lives cleanely in its isolated space. (Please no os war).

jmf



compared to
.



Relevant Pages

  • Re: __pycache__, one more good reason to stck with Python 2?
    ... a module with a name as defined in the parent directory? ... you don't have to launch a pyc file anyway. ... script with some trivial code to invoke a function from the compiled ... Otherwise you can customize sys.path a little from your script, ...
    (comp.lang.python)
  • Re: PEP 3147 - new .pyc format
    ... version number should the .pyc file show? ... I don't know enough about Python yet to comment on your question, but, ... But now consider the human reader. ... Why do you care *which* ...
    (comp.lang.python)
  • Re: Run pyc file without specifying python path ?
    ... Run pyc file without specifying python path? ...  a python script text executable ... the user just types   "wrapper.py" on his command line. ...
    (comp.lang.python)
  • RE: Run pyc file without specifying python path ?
    ... On second thoughts, I may have a problem implementing the wrapper solution, because my actual test_pyc.pyc, needs to parse its command line. ... Run pyc file without specifying python path? ...
    (comp.lang.python)
  • RE: Run pyc file without specifying python path ?
    ... Run pyc file without specifying python path? ... Barak, Ron wrote: ...
    (comp.lang.python)