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


Groups > comp.lang.python > #71840

Re: Loading modules from files through C++

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'null,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:files': 0.09; 'subject:modules': 0.09; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'fullname,': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'module': 0.19; 'stefan': 0.19; 'work,': 0.20; 'import': 0.22; 'header:User-Agent:1': 0.23; 'switch': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'changed.': 0.31; 'guess': 0.33; 'subject:from': 0.34; 'but': 0.35; 'should': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'how': 0.40; 'simple': 0.61; 'const': 0.84; 'received:87.139': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Stefan Behnel <stefan_ml@behnel.de>
Subject Re: Loading modules from files through C++
Date Wed, 21 May 2014 08:33:53 +0200
References <5376ACE7.8030706@rptd.ch> <ll7iu1$oge$1@ger.gmane.org> <53775D68.2010009@rptd.ch> <ll7o30$pc3$1@ger.gmane.org> <537768FB.7060303@rptd.ch> <ll7q3m$idv$1@ger.gmane.org> <53778005.8030105@rptd.ch> <ll80dl$bov$1@ger.gmane.org> <53778E22.3040701@rptd.ch> <ll84s5$5bd$1@ger.gmane.org> <53790CCF.1070905@rptd.ch> <CAPTjJmrOeSsmoxqk8iCL2tKEX9Qa1yHBLzfbfvNr_7Ap+AP6pg@mail.gmail.com> <537B8E31.7000607@rptd.ch>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host p578baff2.dip0.t-ipconnect.de
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0
In-Reply-To <537B8E31.7000607@rptd.ch>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.10179.1400654047.18130.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1400654047 news.xs4all.nl 2924 [2001:888:2000:d::a6]:54171
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:71840

Show key headers only | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web