🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

advanced python question

Started by
1 comment, last by denethor 20 years, 5 months ago
When calling a C function from a Python script, is there any way to determine the name of the calling script. For example: static PyObject* function(PyObject *self, PyObject *args) { ... //need to determine name of python script here ... }
Advertisement
I honestly can''t think of any way, as the flow of information is from module -> executable in Python AFAIK. Would you consider writing a wrapper Python module/function that passes __name__ to the C function as its first (or last, or any other specific position number) argument?
there could never be any built in way of detecting the name of a calling script from the C code ... because how would C even know it was called by python in the first place, let alone what called it ...

In C, the only was for a function to know ANYTHING about the outside world at run time is thorugh calling functions which tell it, looking up global variables, or function parameters ...

obviously there are many many ways you can gather this information yourself, and make it accessable to your C function ...

This topic is closed to new replies.

Advertisement