[Zope] Script (Python) function definitions

Michael Casaday meeper@innerverse.com
Wed, 11 Jul 2001 20:27:47 -0700


Defining functions within Script (Python) methods doesn't seem to work very
well.  This code...


 def funcA():
  print "<p>Hello, from funcA()!</p>"

 def funcB():
  print "<p>Hello, from funcB()!  I also have a message from funcA()...</p>"
  funcA()

 funcB()
 return printed


...produces the following error...


 Error Type: Name
 ErrorError Value: funcA


Apparently, funcB doesn't know where to look for the definition of funcA.
If I were to call funcA from the body of the script instead of from a
function, the script would execute with no problem.

Would anyone be so kind as to share their insight into this matter?  Should
I not be writing def's into my Python scripts but instead relying solely on
other Python scripts for reusable code?  I apologize in advance if any of
this is covered in the docs.

_________________
meeper