[Zope] Class definition problem in a Python Script

complaw@hal-pc.org complaw@hal-pc.org
Thu, 6 Dec 2001 20:48:41 GMT


I'm using a method to look up an object within a folder and returning that
object.  In some cases, however, the object isn't found.

In all cases, I want to return an object as I do some checking to ensure that
the object was indeed found.  Unfortunately, my mechanism for doing so is giving
me a "SyntaxError, Names starting with "_" are not allowed (__doc__)."

Here is the code...

def get_object_by_element_number(objList, given_element_number):

  class MyErrorClass:
    "Dummy class so something is returned (with an error indicator)"
    element_number = -1

  found = 0
  for obj in objList:
    if given_element_number = obj.element_number:
      found = 1
      return obj

  if found == 0:
    error_obj = MyErrorClass
    return error_obj


-------

Does anyone know what the problem is?  At first, I thought it was a docstring
problem, but I pulled the example out of the Python Tutorial (from python.org).

Any hints?

Thanks in advance,

Ron