Re: Extended functions in embedded code

2015-10-15 Thread Ervin Hegedüs
Hi, I've read many docs and examples, then I made a usable test version. If anybody interested about this (and for the mailing list archives), then it could be found here: https://code.activestate.com/recipes/579110-add-function-to-__builtin__-module-through-c-api/ Hope this helps, and many than

Re: Extended functions in embedded code

2015-10-13 Thread Ervin Hegedüs
On Wed, Oct 14, 2015 at 12:02:36AM +0200, Laura Creighton wrote: > In a message of Tue, 13 Oct 2015 22:28:54 +0200, Ervin Hegedüs writes: > >Hi Chris, > > > >what I misses: currently I'm using Python 2.7. > > > >On Wed, Oct 14, 2015 at 02:48:57AM +1100, Chris Angelico wrote: [...] > > > >PyModule_

Re: Extended functions in embedded code

2015-10-13 Thread Chris Angelico
On Wed, Oct 14, 2015 at 7:28 AM, Ervin Hegedüs wrote: > Hi Chris, > > what I misses: currently I'm using Python 2.7. Oh, sorry. In that case, you'll be importing "__builtin__" rather than "builtins", but the same technique works. > On Wed, Oct 14, 2015 at 02:48:57AM +1100, Chris Angelico wrote:

Re: Extended functions in embedded code

2015-10-13 Thread Laura Creighton
In a message of Tue, 13 Oct 2015 22:28:54 +0200, Ervin Hegedüs writes: >Hi Chris, > >what I misses: currently I'm using Python 2.7. > >On Wed, Oct 14, 2015 at 02:48:57AM +1100, Chris Angelico wrote: >> On Wed, Oct 14, 2015 at 2:29 AM, Ervin Hegedüs wrote: >> >> >> >> Sounds to me like the easiest

Re: Extended functions in embedded code

2015-10-13 Thread Emile van Sebille
On 10/13/2015 1:32 PM, Ervin Hegedüs wrote: Hi, On Tue, Oct 13, 2015 at 08:55:42AM -0700, Emile van Sebille wrote: On 10/13/2015 8:29 AM, Ervin Hegedüs wrote: Hi Chris, On Wed, Oct 14, 2015 at 02:05:43AM +1100, Chris Angelico wrote: Sounds to me like the easiest way would be to inject into

Re: Extended functions in embedded code

2015-10-13 Thread Ervin Hegedüs
Hi, On Tue, Oct 13, 2015 at 08:55:42AM -0700, Emile van Sebille wrote: > On 10/13/2015 8:29 AM, Ervin Hegedüs wrote: > >Hi Chris, > > > >On Wed, Oct 14, 2015 at 02:05:43AM +1100, Chris Angelico wrote: > > >>Sounds to me like the easiest way would be to inject into the > >>builtins. You should be

Re: Extended functions in embedded code

2015-10-13 Thread Ervin Hegedüs
Hi Chris, what I misses: currently I'm using Python 2.7. On Wed, Oct 14, 2015 at 02:48:57AM +1100, Chris Angelico wrote: > On Wed, Oct 14, 2015 at 2:29 AM, Ervin Hegedüs wrote: > >> > >> Sounds to me like the easiest way would be to inject into the > >> builtins. You should be able to import the

Re: Extended functions in embedded code

2015-10-13 Thread Emile van Sebille
On 10/13/2015 8:29 AM, Ervin Hegedüs wrote: Hi Chris, On Wed, Oct 14, 2015 at 02:05:43AM +1100, Chris Angelico wrote: Sounds to me like the easiest way would be to inject into the builtins. You should be able to import the builtins module from your C code, and then stuff some extra attributes

Re: Extended functions in embedded code

2015-10-13 Thread Chris Angelico
On Wed, Oct 14, 2015 at 2:29 AM, Ervin Hegedüs wrote: >> >> Sounds to me like the easiest way would be to inject into the >> builtins. You should be able to import the builtins module from your C >> code, and then stuff some extra attributes into it; they'll be >> automatically available to the sc

Re: Extended functions in embedded code

2015-10-13 Thread Ervin Hegedüs
Hi Chris, On Wed, Oct 14, 2015 at 02:05:43AM +1100, Chris Angelico wrote: > On Wed, Oct 14, 2015 at 1:59 AM, Ervin Hegedüs wrote: > > no, I have filesystem. I help to contribute a software, which had > > written in C. The configuration schema is very simple, there are > > several keywords, but no

Re: Extended functions in embedded code

2015-10-13 Thread Chris Angelico
On Wed, Oct 14, 2015 at 1:59 AM, Ervin Hegedüs wrote: > no, I have filesystem. I help to contribute a software, which had > written in C. The configuration schema is very simple, there are > several keywords, but not all required function could be > configure with them. Python would be a good choi

Re: Extended functions in embedded code

2015-10-13 Thread Ervin Hegedüs
Hi, On Tue, Oct 13, 2015 at 02:51:21PM +0200, Laura Creighton wrote: > Are you looking for this:? > https://docs.python.org/3.5/library/runpy.html I think I'm not - I'm afraid, the runpy modul wasn't developed for me, for this reason. > or maybe this:? > https://docs.python.org/3.5/library/impo

Re: Extended functions in embedded code

2015-10-13 Thread Laura Creighton
Are you looking for this:? https://docs.python.org/3.5/library/runpy.html or maybe this:? https://docs.python.org/3.5/library/importlib.html#importlib.import_module Or is your real problem 'I don't have a filesystem'? Laura -- https://mail.python.org/mailman/listinfo/python-list

Extended functions in embedded code

2015-10-13 Thread Ervin Hegedüs
Hello there, I'm interesting for the embeding of Python code - the examples and docs are very helpfully. The main code, which embeds the Python interpreter, had written in C. There are several functions, what I have to use in embedded (Python) code, so I must to write them as Python extension. Th