Civilization IV/Tips and Tricks

Getting Python to Generate Documentation
If you're looking for a quick and easy way to get documentation about the Python modules in Civilization IV then here's what you can do:

import pydoc pydoc.writedoc(&lt;module name&gt;) So if you want to show all Dll-exported classes do: import pydoc pydoc.writedoc(sys.modules['CvPythonExtensions'])
 * Open up a .py file.
 * Add these lines to the __init__ function:
 * Run Civ4.

This (should) write out an .html file in the Civilization 4 root directory all the information that pydoc can find about the module. While this depends heavily on the programmers leaving lots of descriptive __doc__ strings, you can at least get the function and parameter names out of it.

Making Changes Quickly
Since Python is an interpreted language, you should be able to modify a python file, and then see the results in Civ4 immediately. I've found that this is true in at least one case, but false in certain other cases.

For example, if you modify the Civilopedia pages, and then access this page from Civ4 main menu (when you load up the game), then any changes to the Civilopedia wont be seen until you either restart the game, or actually start a game.

However, if you are in a game, and you alt-tab back to the desktop, make changes to the Python files, then alt-tab back to Civ4, the Python files are reloaded and you see the changes immediately, and more importantly, Civ4 tells you at this point whether there's a problem loading any files.

As always, your mileage may vary, but in most cases development in Python should be fairly quick. No more restarting the whole game to see changes...