Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Python

Knowledge base — Python

Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.

Entries: 583

Python

`deque.pop()` — remove the rightmost item

`deque.pop()` removes and returns the rightmost item of a double-ended queue. Use it to discard dominated candidates when computing a sliding-window maximum.

Advanced · Python 3.12
Python

Remove the leftmost item with deque.popleft()

`popleft()` removes and returns the first item in a deque. In a sliding window, it lets you discard indices that fall before the window’s left boundary.

Advanced · Python 3.12
Python

ExitStack.close(): explicit LIFO cleanup

Register context managers at runtime, then call `stack.close()` to release their resources in reverse registration order before the enclosing `with` block ends.

Advanced · Python 3.12
Python

Attach a UTC offset with datetime.replace()

Attach a known fixed UTC offset without changing the calendar date or clock reading, then format the result as either a custom string or an ISO 8601 string.

Intermediate · Python 3.12
Python

Dictionary unpacking: `{**a, **b}`

Merge defaults and overrides into a new dictionary. When both inputs contain the same key, the value from the right wins.

Intermediate · Python 3.12
Python

The `...` literal in an abstract method body

In Python 3.12, `...` denotes the `Ellipsis` object. A bare `...` can signal an omitted implementation, but `@abstractmethod`, not `...`, marks the method as abstract.

Advanced · Python 3.12
Python

Forward-reference annotation

In Python 3.12, a quoted type annotation can refer to a name that becomes available only after the function is defined.

Basic · Python 3.12
Python

Forward references in type annotations

In Python 3.12, quote a type name that is not yet available when a method is defined, then resolve the reference later if you need the class object.

Advanced · Python 3.12
Python

Function docstrings, `__doc__`, and `__name__`

Read a function's documentation without calling it, and preserve its name and docstring across decoration so audit logs and reports describe the intended function.

Advanced · Python 3.12
Python

`io.StringIO.read`: reading text from memory

Read from the current position in a `StringIO` text stream, and distinguish that operation from retrieving the entire buffer with `getvalue()`.

Intermediate · Python 3.12