a simple question for writtting module
Alex Martelli
aleax at aleax.it
Wed Sep 5 09:31:27 EDT 2001
More information about the Python-list mailing list
Wed Sep 5 09:31:27 EDT 2001
- Previous message (by thread): a simple question for writtting module
- Next message (by thread): a simple question for writtting module
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"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
- Previous message (by thread): a simple question for writtting module
- Next message (by thread): a simple question for writtting module
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list