catching exceptions
Scott David Daniels
scott.daniels at acm.org
Tue Dec 19 00:16:45 EST 2006
jm.suresh at no.spam.gmail.com wrote:
>
> class Test(object):
> ...
> def _setx(self,strvalue):
> try:
> self._x = float(strvalue)
> except ValueError:
> print 'Warning : could not set x attribute to %s' % strvalue
> ...
I think what you are looking for is:
class Test(object):
...
def _setx(self, strvalue):
try:
self._x = float(strvalue)
except ValueError:
print 'Warning : could not set x attribute to %s' % (
strvalue)
raise # re-raise the exception that got us here.
...
--Scott David Daniels
scott.daniels at acm.org
More information about the Python-list
mailing list