Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #71840 > unrolled thread

Re: Loading modules from files through C++

Started byStefan Behnel <stefan_ml@behnel.de>
First post2014-05-21 08:33 +0200
Last post2014-05-21 08:33 +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.


Contents

  Re: Loading modules from files through C++ Stefan Behnel <stefan_ml@behnel.de> - 2014-05-21 08:33 +0200

#71840 — Re: Loading modules from files through C++

FromStefan Behnel <stefan_ml@behnel.de>
Date2014-05-21 08:33 +0200
SubjectRe: Loading modules from files through C++
Message-ID<mailman.10179.1400654047.18130.python-list@python.org>
Roland Plüss, 20.05.2014 19:17:
> PyObject * const loadedModule = Py_InitModule3( fullname, NULL, "Loaded
> module" );
> PyObject * const moduleDict = PyModule_GetDict( loadedModule ); //
> borrowed reference
> PyDict_SetItemString( moduleDict, "__builtins__", PyEval_GetBuiltins() );
> PyRun_StringFlags( fileContent, Py_file_input, moduleDict, moduleDict,
> NULL );
> 
> Hopefully this works also in Py3 should I switch some time later. But I
> guess it should seeing how simple the import now became.

The general principle should still work, just the module creation has changed.

Stefan

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web