Marc 'BlackJack' Rintsch
1/22/2008 8:08:00 AM
On Tue, 22 Jan 2008 15:36:49 +0800, J. Peng wrote:
> def safe_float(object):
> try:
> retval = float(object)
> except (ValueError, TypeError), oops:
> retval = str(oops)
> return retval
>
> x=safe_float([1,2,3,4])
> print x
>
>
> The code above works well.But what's the instance of "oops"? where is it
> coming from? I'm totally confused on it.thanks.
`oops` is bound to the `ValueError` or `TypError` object if `float()`
raises such an exception.
Ciao,
Marc 'BlackJack' Rintsch