def to_float(s, default=<NUM_LIT:0.0>, allow_nan=False):
try:<EOL><INDENT>f = float(s)<EOL><DEDENT>except (TypeError, ValueError):<EOL><INDENT>return default<EOL><DEDENT>if not allow_nan:<EOL><INDENT>if f != f or f in _infs:<EOL><INDENT>return default<EOL><DEDENT><DEDENT>return f<EOL>
Return input converted into a float. If failed, then return ``default``.

Note that, by default, ``allow_nan=False``, so ``to_float`` will not return
``nan``, ``inf``, or ``-inf``.

Examples::

    >>> to_float('1.5')
    1.5
    >>> to_float(1)
    1.0
    >>> to_float('')
    0.0
    >>> to_float('nan')
    0.0
    >>> to_float('inf')
    0.0
    >>> to_float('-inf', allow_nan=True)
    -inf
    >>> to_float(None)
    0.0
    >>> to_float(0, default='Empty')
    0.0
    >>> to_float(None, default='Empty')
    'Empty'