CodeNebula
All paths

Python in Practice

Master the standard library and tackle concurrency — asyncio, threading, and multiprocessing.

0 / 25 completed0%
1

`os` and `sys` — System Interface

`os` provides a portable interface to operating system services: file/directory ...

Python
2

`pathlib` — Object-Oriented File Paths

`pathlib.Path` (Python 3.4+) replaces string-based path manipulation with an obj...

Python
3

`json` — JSON Encoding and Decoding

`json.dumps()` serializes Python objects to JSON strings; `json.loads()` parses ...

Python
4

`re` — Regular Expressions

The `re` module provides Perl-compatible regular expressions. Key functions: `re...

Python
5

`datetime` — Dates, Times, and Timezones

The `datetime` module provides `date`, `time`, `datetime`, `timedelta`, and `tim...

Python
6

`collections` — High-Performance Containers

The `collections` module provides specialized container types. `Counter` counts ...

Python
7

`itertools` — Iterator Building Blocks

`itertools` provides memory-efficient combinatoric and functional iterators. Inf...

Python
8

`functools` — Higher-Order Functions

`functools` provides tools for higher-order functions. `lru_cache` (and `cache`)...

Python
9

`contextlib` — Context Manager Utilities

`contextlib` provides utilities for creating and composing context managers. `@c...

Python
10

`logging` — Structured Logging

The `logging` module provides a configurable, hierarchical logging system. Logge...

Python
11

`unittest` — Testing Framework

`unittest` is Python's built-in xUnit-style testing framework. Test cases extend...

Python
12

`subprocess` — Running External Commands

`subprocess.run()` (Python 3.5+) is the recommended way to run shell commands. `...

Python
13

`argparse` — Command-Line Argument Parsing

`argparse` builds fully-featured CLI parsers from Python code. It auto-generates...

Python
14

`typing` — Advanced Type Annotations

The `typing` module provides building blocks for complex type annotations. `Type...

Python
15

The Global Interpreter Lock (GIL)

The GIL is a mutex in CPython that allows only one thread to execute Python byte...

Python
16

`threading` — OS-Level Threads

`threading.Thread` runs a callable in an OS thread. Threads share the process's ...

Python
17

`multiprocessing` — True Parallelism

`multiprocessing.Process` launches a separate Python interpreter process — no GI...

Python
18

`concurrent.futures` — High-Level Executor Interface

`concurrent.futures` provides `ThreadPoolExecutor` (threads, good for I/O) and `...

Python
19

`asyncio` — Cooperative Concurrency

`asyncio` runs many coroutines on a single thread using cooperative multitasking...

Python
20

Coroutines and `async`/`await`

A coroutine is a function defined with `async def` that returns a coroutine obje...

Python
21

`asyncio.Queue` — Async Producer-Consumer

`asyncio.Queue` is a thread-safe, async-friendly queue for producer-consumer pat...

Python
22

Locks, Events, and Semaphores

`threading.Lock` is a mutual exclusion lock — only one thread can hold it at a t...

Python
23

Shared State and Thread Safety

Sharing mutable state between threads without synchronization causes race condit...

Python
24

Performance Patterns — Choosing the Right Concurrency Model

Python offers three concurrency models: `threading` (I/O-bound, shared memory, G...

Python
25

`asyncio.TaskGroup` and `ExceptionGroup` (Python 3.11+)

`asyncio.TaskGroup` (PEP 654) is the structured concurrency primitive for asynci...

Python