Remove duplicates but keep order
Deduplicate a list while preserving the first occurrence order, for hashable values or by key.
Scripts, data handling and standard-library recipes.
Loading snippets…
21 snippets
Deduplicate a list while preserving the first occurrence order, for hashable values or by key.
Validate and normalize fields in __post_init__ so invalid objects can never be created.
Load configuration from the environment with defaults, type conversion and clear errors for missing values.
Write to a temporary file and rename it into place so readers never see a half-written file.
A small CLI with a positional argument, flags, a main function and proper exit codes.
Validate a signed webhook body with hmac.compare_digest and a timestamp tolerance.
Re-run a flaky function a limited number of times with growing delays, only for chosen exception types.
Tokenize text and list the most common words using collections.Counter.
Yield fixed-size lists from a list, generator or file without loading everything into memory.