On this page
typing.SupportsFloat
Prev: typing.SupportsComplex | Up: typing | Next: typing.SupportsIndex
Rel: typing.AbstractSet, typing.Annotated, typing.Any, typing.assert_never
Ref: docs.python.org — typing.SupportsFloat
Tags: #public #python3 #stdlib #typing
Import
import typing
from typing import SupportsFloat
Signature & Overview
typing.SupportsFloat(*args, **kwargs)
A protocol with one abstract method float.
Usage
from decimal import Decimal
from typing import SupportsFloat
assert isinstance(Decimal("1.5"), SupportsFloat)
Gotchas
- Matches anything convertible via
float(x)that defines__float__()(note:strdoes not implement__float__).
REPL Inspect
from typing import SupportsFloat
help(SupportsFloat)
Linked from
Related notes
- tuts/python3/stdlib_module/typing/SupportsComplex Linked here; links to this page; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/SupportsIndex Linked here; links to this page; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/typing/AbstractSet Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/Annotated Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/Any Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/assert_never Linked here; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/assert_type shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/AsyncContextManager shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/AsyncGenerator shared tags: #stdlib, #typing