- Updated Monday, June 1st 2015 @ 20:47:28
[SOLVED] Fail importing scripts bug. See post #3
I am keeping Python 2.X compliant.
My bot is compiling and testing OK, but not responding in battle as the logic lies in an imported script that obviously never gets instantiated. I try to keep my classes orderly and separated. I keep getting this ERROR DUMP :
/bin/python: can't open file 'src/class_bot_waic2.py
src/bot.py': [Errno 2] No such file or directory
In the bot.py I have commented: # __main__
I have tried both forms of import
- import class_bot_waic2
- from class_bot_waic2 import Bot
and with both forms of namespacing:
- MyBot = Bot()
- MyBot = class_bot_waic2.Bot()
I have even tried with, and without the old import trap by having a __init__.py present in dir.
Surely I am missing something ... but what ?
How do I use class from imported scripts ?
- Updated Thursday, May 28th 2015 @ 18:56:14
An obvious solution is (for now) to keep code in one single script file ... but this really turns the propeller on my hat the wrong way.
- Updated Monday, June 1st 2015 @ 20:51:30
[SOLVED] the compiler on warlights server looks for a COMMENT "__main__" as their solution to know which of the uploaded python scripts IS the main script. BUT
If you like me use a lot of traps and rems all over your development code - especially in scripts you import as modules, then you surely will have a hard to find bug -> IE all the commenteds line of your extensively well documented code ... and guess what - somewher in this forest of proper comments is the seguence of charchters _ _ main _ _ !!!
WHO EVER LOOKS FOR BUGS IN COMMENT LINES... Huh ?
Conclusion : you can use any/all the importing conventions of python. Just make sure that NONE of the comments in ALL the other files has the word __main__ behild it.
X-d:-( < - not happy proppeler head