ingame python script importer

Hi I need a script that will import an external script into bge and run it, this way I can have python modding for my games.
If there is any way some one could help I would be very grateful.
If you need more info I will add it.

Just place the .py module into the python search path.

Indeed you need something that calls that module. This is standard Python … you can look at the Python documentation.

Btw. this is no good idea, when you do not even know how that works.

Just place the .py module into the python search path.

Indeed you need something that calls that module. This is standard Python … you can look at the Python documentation.

Btw. this is no good idea, when you do not even know how that works.

Just place the .py module into the python search path.

Indeed you need something that calls that module. This is standard Python … you can look at the Python documentation.

Btw. this is no good idea, when you do not even know how that works.

Just place the .py module into the python search path.

Indeed you need something that calls that module. This is standard Python … you can look at the Python documentation.

Btw. this is no good idea, when you do not even know how that works.

Just place the .py module into the python search path.

Indeed you need something that calls that module. This is standard Python … you can look at the Python documentation.

Btw. this is no good idea, when you do not even know how that works.

Just place the .py module into the python search path.

Indeed you need something that calls that module. This is standard Python … you can look at the Python documentation.

Btw. this is no good idea, when you do not even know how that works.

Well as monster said x6 times, just place the .py file into the python search path, the most common path by the way is the folder in wich your .blend file is. This is just how python works and it’s not related to BGE, so it is an excellent idea if you want to work extensively with Python (like on BGECore). Only problem is that when using for modds the external scripts will be able to use most python objects of the game, wich usually isn’t a problem, but if you want to restrict that you can do that too.

You should use google more for questions not specific to BGE like this one by the way.

P.S. In python you can even import all scripts in a folder, so crating a mod would be just as easy as creating a file.

You can use the imp module to load python modules from a script dynamically, or to reload existing ones. But as has been said before, this is bad practice.

What you may actually be wanting to know is the following:
In BGE, a script can only be inside the blend, but a module can be external. Therefore, use the python logic brick in module mode. Then you can use modules from the python search path, which, by default includes the blend directory and the directory of any linked in blends. You can also add to the python search path with the sys module.

Sry, the server didn’t accepted my post (at least it returned 500 Messages). Luckily I can remove 5 of them :D.

… no I do not have that problem anymore … seams to be temporary.

For the record, imp is now deprecated (use importlib / importlib.import_module), but you can also use “import(“mod”)” to programmatically import a module at runtime.