Any way to not create .pyc files?

Steve Holden steve at holdenweb.com
Thu Jun 9 14:07:07 EDT 2005


Lonnie Princehouse wrote:
> 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.
> 
Well, at least they have the right to create them. Wouldn't it be 
easier, though, to just create all the .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.

The .pyc file is normally created in the same directory as the .py file. 
You may be seeing problems because one user doesn't have permissions to 
access a file created by another. In that case you may be able to set 
the inherited permissions for Creator Owner to allow reading by all users.

You might also expect problems if one user was using python 2.2 and 
another was using 2.4, since each version requires its own format for 
the .pyc file, and they might conflict. Ulitmately it sounds like a 
permissions problem.

> 
> PEP 304 would have helped, but it appears to be deceased.  What I
> really want is a command line option
> 
Not sure it's deceased (a dead parrot?) - it's on the standards track, 
it hasn't been rejected, and Skip has actually provided a patch to 
implement the solution.

> 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...
> 
It would be *much* more sensible to find the underlying cause of the 
problems and actually fix them :-)

> (footnotes)
> 
> [1] Because it's an administrative nightmare to distribute code updates
> to dozens of non-technical users
> 
I hear that.

regards
  Steve
-- 
Steve Holden        +1 703 861 4237  +1 800 494 3119
Holden Web LLC             http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/




More information about the Python-list mailing list