I am experimenting with the EasyGoPiGo3/easygopigo3 libraries using Thonny and the Python “command line”
On the documentation web-site,
If I execute “import easygopygo3” as the documentation suggests, it succeeds. (i.e. It returns the “>>>” prompt.)
Then if I try to instantiate the EasyGoPiGo3 class by executing “Charlie = EasyGoPiGo3()”, it throws an error that “EasyGoPiGo3” doesn’t exist/is undefined, or something similar.
In contrast, if I execute “from easygopigo3 import EasyGoPiGo3” then try to instantiate the class, it succeeds.
Confusion reigns supreme.
My understanding of the “import” statement was that if I didn’t import something explicitly from a library, it imported everything.
- “import easygopigo3” = “from easygopigo3 import *” (Which includes EasyGoPiGo3 - along with whatever else is there.)
- Whereas “from easygopigo3 import EasyGoPiGo3” imports ONLY the EasyGoPiGo3 part of the library, excluding everything else.
Obviously my understanding is not correct since trying to access the module/method “EasyGoPiGo3” when importing using the first statement results in ignominious failure, shame, humiliation, and a decided lack of cooperation from the robot.
- Why does the documentation recommend the first style of import if it doesn’t work?
- Why doesn’t it work?
- If it should work, what am I doing wrong?