View Full Version : Python question. I think


pholtz
May 06, 2006, 10:12 PM
I am looking at how events are handled in the normal code and some of the mods. I am new to python and trying to understand the syntax.

Looking at the following file

CvEventInterface

The line:

normalEventManager = CvEventManager.CvEventManager()

I assume is instancing the Event Manager, but when I look in the CvEventManager class definition, I see lots of variables (attributes) and methods but none named CvEventmanager.

I'll go out on a limb here and guess that this is a python standard and that when a class in instanced with

classobj = className.className()

that the __init__ function is called?

This wasn't discussed in the tutorial I did, I'll head off to the python website and see if I can find the answer. But any help here would be appreciated.

Denniz
May 07, 2006, 07:03 AM
I am looking at how events are handled in the normal code and some of the mods. I am new to python and trying to understand the syntax.

Looking at the following file

CvEventInterface

The line:

normalEventManager = CvEventManager.CvEventManager()

I assume is instancing the Event Manager, but when I look in the CvEventManager class definition, I see lots of variables (attributes) and methods but none named CvEventmanager.

I'll go out on a limb here and guess that this is a python standard and that when a class in instanced with

classobj = className.className()

that the __init__ function is called?

This wasn't discussed in the tutorial I did, I'll head off to the python website and see if I can find the answer. But any help here would be appreciated.
classobj = moduleName.className()

Yes, __init__ is called.

The Great Apple
May 07, 2006, 09:38 AM
http://forums.civfanatics.com/showpost.php?p=2495872&postcount=187 sorta covers it.

pholtz
May 07, 2006, 02:30 PM
Ah, thank you both. Learned 2 things for the price of one. I was a bit confused with CvEventManager.CvEventManager, thinking the first one was the class name. If the first one is the module name it makes sense. And also nice to know that __init__ is called.