a simple question for writtting module

lud lud at sogetek.fr
Wed Sep 5 10:04:26 EDT 2001


i must do it,
but don't be afraid, i writting this
module for vxWorks and for a personnal use !
so i think that you probably never use it !!

Thanks a lot for your quick answer !!!

Ludo


"Alex Martelli" <aleax at aleax.it> a écrit dans le message news:
9n59fk01upf at enews1.newsguy.com...
> "lud" <lud at sogetek.fr> wrote in message
> news:Hhpl7.530$mg1.11523 at tengri.easynet.fr...
> > Hi !!
> >
> > my problem :
> >
> > first i write in python :
> >         import mymodule
> >         data="is a test"
> >         mymodule.show()
> >
> > ###################
> > now in c :
> > static PyObject *
> > mymodule_show(PyObject * self, PyObject *args)
> > {
> > /*bla bla bla ....*/
> > }
> > so i want get the value of data without transmit her in the call of the
> > function show
> >
> > any idea ?
>
> Yes, several.
>
> The first and main one: don't do it -- it's silly.  It's
> counter-productive.  It's unPythonic.  It's the style of
> programming that gives programming a bad name.
>
> The second one: if you MUST do it at any cost, look into
> sys._getframe, the frame-objects type it returns, and
> how from a frame-object you can get at your caller's
> local and global variables -- this will let you do this
> silliness pretty easily in Python, and the extra mile to
> do it from C is really only 800 meters, as it's so easy
> for C code to do the equivalent of "import sys", call
> the _getframe function of module sys, and so on.
>
> At least, when you're done, you'll have learned a lot
> about some of Python's internals and the use of them
> from C extension code -- also, this will give you the
> time to reflect on whether you really truly want to
> do this at all, and hopefully reconsider:-).
>
>
> Alex
>
>
>





More information about the Python-list mailing list