On this page
typing.Counter
Prev: typing.Coroutine | Up: typing | Next: typing.dataclass_transform
Rel: typing.AbstractSet, typing.Annotated, typing.Any, typing.assert_never
Ref: docs.python.org — typing.Counter
Tags: #public #python3 #stdlib #typing
Import
import typing
from typing import Counter
Signature & Overview
typing.Counter(*args, **kwargs)
Deprecated alias to collections.Counter.
Usage
from collections import Counter as _Counter
from typing import Counter
counts: Counter[str] = _Counter(["a", "a", "b"])
assert counts["a"] == 2
Gotchas
- Deprecated alias in Python 3.9+: Use
collections.Counter[str]directly.
REPL Inspect
from typing import Counter
help(Counter)
Linked from
Related notes
- tuts/python3/stdlib_module/typing/Coroutine Linked here; links to this page; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/dataclass_transform 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