"Lonnie Princehouse" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> In short:
>
> Is there any way to run Python WITHOUT trying to create .pyc files (or
> .pyo) or to have Python not attempt to import the .pyc files it finds?
>
> Reason:
>
> We have a site-specific package installed on a network drive[1].  When
> anyone with write access imports this package, the network drive gets
> spammed with .pyc files.
>
> If these .pyc files exist, they appear to cause problems when other
> users' Python interpreters use them instead of the .py files.  (I know,
> they *should* work, but they don't).  This may have something to do
> with the fact that all of these users (on Windows) have the network
> drive mapped to arbitrary drive letters.  I don't know.
>
> PEP 304 would have helped, but it appears to be deceased.  What I
> really want is a command line option
>
> I'm going to have to cobble together a work-around, like having
> imported modules delete their own .pyc files immediately after import,
> but it would be really nice to have a /good/ way of not using .pyc...
>
> (footnotes)
>
> [1] Because it's an administrative nightmare to distribute code updates
> to dozens of non-technical users
>

Are you using ActivePython?  ActivePython's installation updates the PATHEXT 
environment variable on Windows with the .pyc and .py extensions (.pyc 
first).  This environment variable is used to try extensions when you run a 
program from the command line without an extension.

Example:

  [1] C:\ex>set pathext
  PATHEXT=.com;.exe;.bat;.cmd;.pyc;.py

  [2] C:\ex>echo print "old" > script.py

  [3] C:\ex>python -c "import script"
  old

  [4] C:\ex>script
  old

  [5] C:\ex>echo print "new" > script.py

  [6] C:\ex>script
  old

  [7] C:\ex>python -c "import script"
  new

  [8] C:\ex>script
  new

Even though script.py contains new (line 5), script in line 6 runs the .pyc 
generated by line 3.

To fix this problem, put .py and .pyw extenstions ahead of .pyc and .pyo in 
PATHEXT.

Hope this helps,
Mark 


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to