[Zope] Class definition problem in a Python Script - Disregard

complaw@hal-pc.org complaw@hal-pc.org
Thu, 6 Dec 2001 22:09:39 GMT


I used a 

try:
except:

block at the calling end.  Something I should have done in the first place. 
Less fuss.

I don't know why I think of a solution only _after_ I have mailed this
list-group.

Sorry for the bother...

Ron


> 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
> 
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>