Tim Chase <[EMAIL PROTECTED]> wrote:
>def CFloat(value):
> try:
> value = float(value)
> except (ValueError, TypeError):
> value = 0
> return value
>>> type(CFloat(None))
I think you want value = 0.0 . And you might also want to consider
what errors
Tim Chase wrote:
> Is there some set of preexisting functions that do this sort
> of "sensible" conversions without griping about crazy values
> passed to them?
No, because this isn't Perl.
Seriously, it's a core principle of the Python language not to presume
what a user considers to be "sensibl
"Tim Chase" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Are there existing "quiet" conversion functions? Kin of
> int() and float()?
>
> My aim would be to call a function that would guarntee that
> the result was of the defined typ
Tim Chase wrote:
> Are there existing "quiet" conversion functions? Kin of
> int() and float()?
Not in the standard library. Nor will there be. It goes against the development
philosophy of the core Python development team.
> My aim would be to call a function that would g
Are there existing "quiet" conversion functions? Kin of
int() and float()?
My aim would be to call a function that would guarntee that
the result was of the defined type, choosing sensible
defaults if needed. Example problems include:
int("3.14")
int(None)
int(__bu