On Sat, 16 Dec 2006 17:36:00 +0530, Amit Khemka wrote:

> If I gather correctly, i guess in case of errors/exceptions in a class
> function, you want to get the error string. One thing that comes
> straight to my mind is, in such a case use a return statement in
> functions with two arguments.
> 
> for example:
> def foo(self, value):
>     try:
>         a.x = value
>         return True, ''
>     except ValueError:  return False, 'Float conversion error: %s' %(value)
> 
> and when ever u call the function, check the first return value, It is
> false then alert/print the error message.

Oh lordy, that is _so_ 1980s programming practice!!!

I'm not saying that it is never a good idea, but avoiding that sort of
thing is one of the reasons exceptions were created!


-- 
Steven.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to