what's this instance?

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Tue Jan 22 03:08:19 EST 2008


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



More information about the Python-list mailing list