Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #71964 > unrolled thread
| Started by | Roland Plüss <roland@rptd.ch> |
|---|---|
| First post | 2014-05-24 16:48 +0200 |
| Last post | 2014-05-24 16:48 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Loading modules from files through C++ Roland Plüss <roland@rptd.ch> - 2014-05-24 16:48 +0200
| From | Roland Plüss <roland@rptd.ch> |
|---|---|
| Date | 2014-05-24 16:48 +0200 |
| Subject | Re: Loading modules from files through C++ |
| Message-ID | <mailman.10263.1400942910.18130.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
> # CODE #
> PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, NULL, NULL, 0, NULL,
> NULL, NULL, NULL, NULL };
>
> moduledef.m_name = "MyModule";
> moduledef.m_doc = "MyModule";
> pModule = PyModule_Create( &moduledef );
> PyState_AddModule( pModule, &moduledef );
>
> PyRun_SimpleString( "print( globals() )\n" );
> PyRun_SimpleString( "import MyModule\nprint( globals() )\n" );
> # CODE #
>
> yields this:
>
> {'__name__': '__main__', '__builtins__': <module 'builtins' (built-in)>,
> '__doc__': None, '__loader__': <class
> '_frozen_importlib.BuiltinImporter'>, '__package__': None}
> Traceback (most recent call last):
> File "<string>", line 1, in <module>
> ImportError: No module named 'MyModule'
>
Anybody got an idea? Somebody has a working example where he create a
valid module from C++? It's just a namespace not even yet script sources
applied.
--
Yours sincerely
Plüss Roland
Leader and Head Programmer
- Game: Epsylon ( http://www.indiedb.com/games/epsylon )
- Game Engine: Drag[en]gine ( http://www.indiedb.com/engines/dragengine
, http://dragengine.rptd.ch/wiki )
- Normal Map Generator: DENormGen ( http://epsylon.rptd.ch/denormgen.php )
- As well as various Blender export scripts und game tools
Back to top | Article view | comp.lang.python
csiph-web