Regular expression and exception
bearophileHUGS at lycos.com
bearophileHUGS at lycos.com
Sat Nov 15 09:45:32 EST 2008
Mr.SpOOn:
> try:
> m = re.match('[1-9]$', my_string)
> except:
> print 'something...'
> ...
> try:
> m.group()
> except:
> print 'error...'
Generally don't write a nude except, use qualified exceptions, that is
put there one of more exceptions that you want to catch (be careful
with the syntax with more than one exception, see the docs).
Bye,
bearophile
More information about the Python-list
mailing list