Any way to not create .pyc files?

Terry Hancock hancock at anansispaceworks.com
Thu Jun 9 23:58:17 EDT 2005


On Thursday 09 June 2005 03:48 pm, Lonnie Princehouse wrote:
> At one point last week, users started reporting that they were
> encountering problems running our Python application (the one that uses
> the package on the network drive).  The admins noticed that lots of
> .pyc files had been inadvertantly created when someone with write
> access had run the application.  The admins deleted all of the .pyc
> files, and users were once again able to run the application.
> I suspect this hadn't come up before because very few people have write
> access, and those who do are not usually users.  I don't know the
> nature of the problems encountered.

Well, if most users are using an older version of Python, but the user
with write access was using a new version, I can see this happening.

The user with write access would run the script, causing the pyc files
to be generated for that interpreter.  Then a normal user, running an
older Python tries to load the modules.  Since a .pyc file exists, it gets
used instead, but *oops* it's for a later version of the interpreter and
stuff breaks.

A better solution than getting rid of the pyc files would be to put good
ones there --- use the version of python that users are expected to be
using and generate them.  If you delete the pyc files, you create an
unnecessary drag on performance and the hazard remains to mess you
up again.  If the pyc files are generated, though, I *think* they will be
used and work for both the expected python and (fingers crossed) the
later version.

If the later version doesn't work, your "unusual" person with write
access ought to be smart enough to use the right version, right?  It's
the usual user you should be designing for.

I hope I'm not totally off-base here --- I've had relatively little
experience with mixed versions and pyc files, so my assumptions
may be a little off, but hopefully someone will correct me if that's so.

Cheers,
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com




More information about the Python-list mailing list