Re: Any way to not create .pyc files?



Lonnie Princehouse wrote:
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?

You could roll your package into a zip archive and then import that. For instance, keep your main.py out of the archive and put everything else in. Then, at the top of main.py:


import sys
sys.path.insert("network_path/package.zip")

import package
# do normal stuff with package here.

As long as you zipped up the package will all .pyc and .pyo files removed, Python will have no choice but to compile the files every time they are imported - unless I'm grossly mistaken Python won't put the pyc files into the zip archive, or modify any that were there already.

As far as the maintenance headache of distributing updated copies to individual workstations, IMO this just requires a little forethought and then it isn't a headache at all. Instead of the users starting the application directly, they could start a starter application that checks with the server to determine if local files need to be updated, and if so grab them and then start the main app. This actually removes headaches in the Windows world, where you can't drop-in updates to programs that are currently running.

What I've done in the past adds on to the starter application idea, and has the main application check to see if there are updates to the starter application, and if so pull those changes down upon exit of the main application. I just saved the file locations locally in an INI file.

--
Paul McNett
http://paulmcnett.com

.