So I was generating Python wrappers for some GObjects in C with h2def.py/codegen.py/scanvirtuals.py and I wanted to access a class variable in my classes (if you don’t know the difference between class and instance variables in Python, read the programmer’s note on this page). However, I couldn’t find an easy way of doing this until I found this function:
pyg_register_class_init(GType, PyGClassInitFunc)
It can add a function to be called when the class for that GType is initialized. That solved my problem because I only had to register a class init function for my base class. This function verifies if my python class has a specific variable and just uses it if it has or raises an exception if it doesn’t. Simple and to the point but if someone has a better way of doing this, just post a comment, please. :-)