Extended functions in embedded code

Ervin Hegedüs airween at gmail.com
Wed Oct 14 02:11:44 EDT 2015


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_AddFunction was introduced in Python 3.5. Most of stable
> >Linux distribution has Python 3.4
> > 
> >> instead of the current module initialization. You import the name
> >> 'builtins', stuff some extra stuff into it, and then go on your merry
> >> way. It should be reasonably easy.
> >
> >Is there any other solution to add functions to builtins?
> >
> 
> You can stuff things into the __dict__ of __builtin__ if you like.
> It's highly frowned upon.
> But see discussion attatched to:
> http://code.activestate.com/recipes/577888-see-what-the-builtins-are/

As I understand this, it shows the Python's builtins (or
__builtins__) capabilities.

As Chris wrote, the soultion would be, that I'm loading the
__builtins__ module in C (through API), and add/extend its
__dict__ with my funtions.

The link above doesn't help me in this :).

Thanks,

a.



More information about the Python-list mailing list