python - Libraries act differently depending on if they are installed or not -
I have a Python Library which I have written which is working on me I have a set of variables Changes the way It is all right to test, but when I use the Library: script: if Place the library in the same directory as a script and output it to: But if you install the library and try again Use of Library from Display Package The script output is: Can someone tell what is happening? I am a little confused and I am very interested in events and reasons. Is the programmatic configuration completely wrong? Edit It shows that the problem is the init .py file. It's basically like importing a library which only imports another library when you import an installed module, then the folder script: Output: Function run () appears in lib.py for Do you describe how Python works with incompatible (Read, if you wish , "I do not believe you did well and got the exact same result"). If you can python lib.py install variable does not affect the library. I probably broke it down for the easiest example:
## lib.py config = "original" def run (): print config
import lib libconfig = "new" lib.run () print lib.config
New new
original new
lib and init .py file Looks at init .py is only one liner
liberalization import * . This is only the appearance of the actual library, but if you use a global variable it causes a strange problem. A simulated example of what's actually going on:
script ## init.py lib import * from
< Code> import init init.config = 'new' init.run () print init.config
original new
config , but
print init.config looks for init.py. Thanks for the help everyone. The way to fix the fix module is to change (no init .py). After all, I hope to remove all the global variables, but for the time everything is correct.
lib from different places or in different ways, however, you can finish it with two copies, either copies of two modules or current Getting a "basic" / "new" behavior from directory-
lib and one of the other
lib if you are Seems possible reason.
Comments
Post a Comment