I have a GP.py file that I am then running a MyBot.py file from.
In the MyBot.py file, I have the line
from GP import *
I have a suspicion it is importing the whole file instead of just the class methods and class descriptions I want. In the GP.py file, There is code in addition to the defintions
You cannot import class methods separately, you have to import the classes. You can do this by enumerating the classes you want to import:
from GP import class1, class2, class3
Note that this will still load the entire module. This always happens if you import anything from the module. If you have code in that module that you do not want to be executed when the module is imported, you can protect it like this:
if __name__ == "__main__":
# put code here
Code inside the block will only be executed if the module is run directly, not if it is imported.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With