Reputation: 61
Is it possible to do the following in Python?
Pseudo-code:
<code to extract contents from a password-protected .zip file (includes module)>
<path to module>
import module
reload(module)
<delete extracted contents, including the imported module>
<program code (within it, use reload(module) to use the module)>
The purpose of this is to basically make the module "invisible" to the user. I know that if the user really wants to get it, he can, but this is just more of a deterrent. I also know that this may not be desirable at all, but is it possible?
Thanks.
Upvotes: 1
Views: 133
Reputation: 279385
It might work, if by "contents includes module" you mean a .py
file, and if the first import module
can create a module.pyc
file (which normally it can, but for example a read-only filesystem would stop it). If you don't delete that .pyc
file, then reload(module)
can load from it.
If there's another module.py
found later in the include path, then deleting the files from one place would result in reload
loading it from another.
If you delete all files relating to module
everywhere in the path then it can't be reloaded, because what reload means is, "go load this from the include path".
Upvotes: 3