Using SDK/C++ Enumerated Types in Python

Eusebius

Warlord
Joined
Feb 11, 2006
Messages
242
Location
Hopewell, NJ, USA
Okay, maybe everyone else knew this, but I just figured out how to use enumerated types in Python.

For example, functions like getStateReligionCommerce want a commerce type. Often one just puts in the corresponding integer; but you don't need to. It turns out that all the enumerated types are exported to Python, so you just create an object of that type.

Example follows...
def getTotalStateReligionCommerce(self):
ct = CommerceTypes()
return (self.getStateReligionCommerce(ct.COMMERCE_GOLD) + self.getStateReligionCommerce(ct.COMMERCE_RESEARCH) + self.getStateReligionCommerce(ct.COMMERCE_CULTURE))

Cheers,
Eusebius

PS. How is that for the world's shortest tutorial? ;)
 
Back
Top Bottom