Global functions?

Thalassicus

Bytes and Nibblers
Joined
Nov 9, 2005
Messages
11,057
Location
Texas
How do I import and use global functions from a seperate file in python with Civ IV? I imported the external file at the top of both CvCustomEventManager and the file I'm working in. I tried then calling the functions, which returns a function-undefined error.
 
Thalassicus said:
How do I import and use global functions from a seperate file in python with Civ IV? I wish to use the functions in Stone-D's toolkit, and imported that file at the top of both CvCustomEventManager and the file I'm working in. I tried then calling the functions, which returns a function-undefined error.

Say you have this:

import MyPackage

All that does is imports the MyPackage namespace into your file, not all the functions and variables in the namespace. In order to call a something in MyPackage, you would need to do this in the code that you have the import statement in...


MyPackage.MyFunc(...)

-not-

MyFunc(...)

If you want to just do "MyFunc", you would do the following...

from MyPackage import MyFunc

This imports MyFunc into the namespace of the current file as well.
 
Back
Top Bottom