On this page
typing.Container
Prev: typing.Concatenate | Up: typing | Next: typing.ContextManager
Rel: typing.AbstractSet, typing.Annotated, typing.Any, typing.assert_never
Ref: docs.python.org — typing.Container
Tags: #public #python3 #stdlib #typing
Import
import typing
from typing import Container
Signature & Overview
typing.Container(*args, **kwargs)
Deprecated alias to collections.abc.Container.
Usage
from typing import Container
def has_admin(roles: Container[str]) -> bool:
return "admin" in roles
assert has_admin({"admin", "editor"})
Gotchas
- Prefer
collections.abc.Container[T]in Python 3.9+: Represents any type supportingx in c.
REPL Inspect
from typing import Container
help(Container)
Linked from
Related notes
- tuts/python3/stdlib_module/typing/Concatenate Linked here; links to this page; shared tags: #stdlib, #typing
- tuts/python3/stdlib_module/typing/ContextManager 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