1

In a python script(module) any global function call will be executed each time I import/reload module. I call these module-level initialization function.

ex.

def init():
    print "Hello, this is module initialization function"
    print "init() has been called"

init()

Every time I import this module/reload it will print these lines.

Currently I have a Python/C API module, that I want to add module-level initialization function.

Is this possible to do using this approach ?


Another possible solution that I know, I may add another normal function, then call it via PyRun_String or other functions of the C-API.

Azat Ibrakov
  • 9,998
  • 9
  • 38
  • 50
Shady Atef
  • 2,121
  • 1
  • 22
  • 40

0 Answers0