Re: splitting my python code into multiple .py files like in bgt

2019-08-27 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector


  


Re: splitting my python code into multiple .py files like in bgt

I should point out that the example in post six for multiple imports with a from statement does not need to use indention. I believe Python will accept something like this as wellfrom includes import (test,test1,test2,test3)That's ugly, though.I would also avoid typing from x import * as it could, and most likely will, cause a lot of issues down the road, especially if you have a reference to the importing module from the importer, i.e:#test.py
from test1 import *
#test1.py
from test import *
#and so onThose bugs are going to be the most difficult to track down, as Python will not complain about that code. Most likely you'll end up overwriting something with your import by mistake and the compiler will complain about that fact.

URL: https://forum.audiogames.net/post/457953/#p457953




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: splitting my python code into multiple .py files like in bgt

2019-08-27 Thread AudioGames . net Forum — Developers room : amerikranian via Audiogames-reflector


  


Re: splitting my python code into multiple .py files like in bgt

I should point out that the example in post six for multiple imports with a from statement does not need to use indention. I believe Python will accept something like this as wellfrom includes import test,test1,test2,test3That's ugly, though.I would also avoid typing from x import * as it could, and most likely will, cause a lot of issues down the road, especially if you have a reference to the importing module from the importer, i.e:#test.py
from test1 import *
#test1.py
from test import *
#and so onThose bugs are going to be the most difficult to track down, as Python will not complain about that code. Most likely you'll end up overwriting something with your import by mistake and the compiler will complain about that fact.

URL: https://forum.audiogames.net/post/457953/#p457953




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: splitting my python code into multiple .py files like in bgt

2019-08-27 Thread AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector


  


Re: splitting my python code into multiple .py files like in bgt

Na, you're messing keywords up a bit here. A single file is a module, a folder however is a package and needs to contain a __init__.py file (it may be empty) so you can import modules from it.You also need to import a module to access its functions, or import the modules in the __init__.py file of the package.So you have multiple options. Either you go with the following, what i'd still recommend:from includes import test
from includes import module
from includes import my_test_module
# you can combine multiple imports as follows
from includes import (
  test,
  module,
  my_test_module)

# now you can access all the functions
test.my_test()
module.initialize()
my_test_module.do_something()Or you can do the following:includes/__init__.py:
from . import test
from . import module
from . import my_test_module

main.py:
import includes

includes.test.my_test()
# ... etc

# you can also do
from includes import *

test.my_test()
# ... etcAs you can see, there are always multiple ways to go, the only requirement is that you're doing it the correct way.Best Regards.Hijacker

URL: https://forum.audiogames.net/post/457885/#p457885




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: splitting my python code into multiple .py files like in bgt

2019-08-26 Thread AudioGames . net Forum — Developers room : simter via Audiogames-reflector


  


Re: splitting my python code into multiple .py files like in bgt

I just tried it. I just created a directory called includes and put some files in there. Then i did import includes. But what ever funktion i tried to execute, it failed. Atribute error. Modul includes has no atribute called test(). But it has.

URL: https://forum.audiogames.net/post/457813/#p457813




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: splitting my python code into multiple .py files like in bgt

2019-08-26 Thread AudioGames . net Forum — Developers room : ashleygrobler04 via Audiogames-reflector


  


Re: splitting my python code into multiple .py files like in bgt

let's say you have a module called test.And in the test module you have a few functions.What would you do? here is an example:import testt=test.test()t.show_message("the import was successfull...")Don't care to much about the function of the module, this was just to show how the module imports works.

URL: https://forum.audiogames.net/post/457795/#p457795




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: splitting my python code into multiple .py files like in bgt

2019-08-26 Thread AudioGames . net Forum — Developers room : Hijacker via Audiogames-reflector


  


Re: splitting my python code into multiple .py files like in bgt

You'll have to "write a module", even though you don't have to do anything to make it an actual module. Then just import it like in bgt. You could also dofrom my_module import *to import all stuff from that specific module, which will end in a bloated namespace which works similar to how BGT handles things, but i wouldn't recommend that, it can possibly slow your code down and doesn't look nice, because you don't know where certain things come from / are located and thus you'll have to fix them if they're broken.Best Regards.Hijacker

URL: https://forum.audiogames.net/post/457759/#p457759




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector


Re: splitting my python code into multiple .py files like in bgt

2019-08-26 Thread AudioGames . net Forum — Developers room : redfox via Audiogames-reflector


  


Re: splitting my python code into multiple .py files like in bgt

Can't you just import them like librarys? I don't python much so sorry if this is dumb.

URL: https://forum.audiogames.net/post/457752/#p457752




-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector