does this exception mean something else?

Chris Rebert clp2 at rebertia.com
Thu May 6 20:50:22 EDT 2010


On Thu, May 6, 2010 at 5:33 PM, Alex Hall <mehgcap at gmail.com> wrote:
> Hi all,
> I have a file, pasted below for what good it will do, which makes a
> couple conditional calls to a function called writeDefaults. However,
> when I manually trigger a condition that causes the function to be
> called, Python gives me a name error and says that my writeDefaults
> does not exist. I am sure that it does, as I copied the text from the
> call and pasted it into the text search of my editor, and it found the
> line that defines the function, so the text in the call is obviously
> correct.

You're calling the function before you've defined it; that doesn't
work in Python. `def`s are executable statements, not declarations
like in statically-typed languages.
Move the "def writeDefaults():" and its body so it comes before the
"#first, load the ini file setting" code.

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list