On this page
  1. typing.Counter
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

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

REPL Inspect

from typing import Counter
help(Counter)

Linked from

Related notes