All tags
Coding
Narrow down
Python25
- Tip
import asyncioPython's asyncio.timeout puts a time limit on a block of awaitsWrap awaits in asyncio.timeout and get a TimeoutError when the time is up.2 Dec 2026 - Tip
from enum import StrEnum, autoPython's StrEnum makes enum members behave like plain stringsStrEnum members are real strings, and auto() gives each one its lowercase name.2 Dec 2026 - Tip
except* ValueError as eg:Python's except* handles each error type inside an ExceptionGroupUse except* to catch some exceptions from a group and leave the others for later.2 Dec 2026 - Tip
import pytestPytest.approx compares floats without the rounding surpriseWrap the expected number in pytest.approx so tiny float errors do not fail the test.2 Dec 2026 - Tip
from functools import cached_propertyPython's functools.cached_property computes a value once per objectA cached_property runs its method on first access and then keeps the result on the object.2 Dec 2026 - Tip
from itertools import accumulatePython's itertools.accumulate gives a running total of a listaccumulate yields the running sum, or a running max or product if you pass a function.2 Dec 2026 - Tip
from dataclasses import dataclass, replacePython's dataclasses.replace copies an object with one field changedreplace() makes a new dataclass instance with the fields you name changed.2 Dec 2026 - Tip
match cmd.split():Python's match statement picks apart lists and values by their shapematch and case unpack sequences by shape, with guards and alternatives, from Python 3.10.2 Dec 2026 - Tip
from unittest.mock import patchPython's unittest.mock.patch fakes a network call in a testReplace a slow or flaky dependency with a fake during a test.30 Nov 2026 - Tip
def greet(name):Python pytest's capsys lets a test check what your code printedAssert on stdout and stderr output of a function inside a pytest test.30 Nov 2026 - Tip
python3 -m pytest -k "login and not bad" -vpython -m pytest -k picks tests by name with and, or and notRun only the tests whose names match a keyword expression.30 Nov 2026 - Tip
for n, line in enumerate(f, start=1):Python's enumerate(start=1) numbers lines the way humans countNumber items from 1 in a loop without adding one everywhere.30 Nov 2026 - Tip
from itertools import groupbyPython's itertools.groupby only groups neighbours, so sort firstAvoid duplicate groups from itertools.groupby by sorting on the same key first.30 Nov 2026 - Tip
from datetime import datetime, timezonePython's datetime.fromisoformat parses timestamps without a format stringTurn ISO 8601 timestamps from logs and APIs into datetime objects without strptime.30 Nov 2026 - Tip
import mathPython's math.isclose compares floats that look equal but aren'tCompare floating point numbers safely instead of trusting the double equals sign.30 Nov 2026 - Tip
from collections import defaultdictPython's defaultdict(list) groups items without the setdefault danceGroup items into lists by a key without checking whether the key exists yet.30 Nov 2026 - Tip
python3 mypkg/cli.py # ModuleNotFoundError: No module named 'mypkg'python -m package.module runs a file so its package imports workRun a script inside your package without ModuleNotFoundError on its own imports.30 Nov 2026 - Tip
def save_report(folder, text):Python pytest's tmp_path gives every test its own empty folderTest code that writes files without touching real folders or cleaning up yourself.30 Nov 2026 - Tip
import pytestPython pytest.mark.parametrize runs one test against a table of casesTest a function with many inputs without copying the test function.30 Nov 2026 - Tip
from decimal import Decimal, ROUND_HALF_UPPython's decimal.Decimal keeps money sums exactAdd up prices and amounts without floating point rounding errors.30 Nov 2026 - Tip
import pytestPython pytest.raises(match=) checks the error message, not just the typeMake sure code fails with the right exception and the right reason.30 Nov 2026 - Tip
from operator import itemgetterPython's operator.itemgetter sorts a list of dicts on two keysSort rows on one or more fields without writing a lambda.30 Nov 2026 - Tip
for name, email in zip(names, emails, strict=True):Zip(strict=True) makes Python complain when two lists differ in lengthRaises an error when the lists you zip together don't have the same length.27 Nov 2026 - Tip
from dataclasses import dataclass, fieldPython dataclass fields need default_factory for lists and dictsGives each dataclass instance its own fresh list or dict instead of a shared default.24 Nov 2026 - Tip
from dataclasses import dataclassPython dataclass(slots=True, frozen=True) blocks typos and mutationMakes a dataclass immutable, hashable and typo-proof with two decorator arguments.24 Nov 2026
AI6
- Tip
Why does @src/auth/session.ts refresh the token twice?Type @ in Claude Code to point at a file instead of describing itAutocompletes file paths in your prompt so Claude looks at exactly the file you mean.30 Nov 2026 - Tip
echo '{"decision": "block", "reason": "The tests fail. Run npm test and fix them before you stop."}'A Stop hook keeps Claude Code working until your tests passBlocks Claude from ending its turn while the test suite fails, with a guard against loops.30 Nov 2026 - Tip
Before you finish, verify your answer against these cases:End a Claude prompt with what to verify before it finishesAsks Claude to check its answer against criteria you name, which catches mistakes in code and math.30 Nov 2026 - Tip
"model": "opus".claude/settings.local.json overrides the team file just for youOverrides a shared Claude Code project setting for you only, without touching git.23 Sep 2026 - Tip
---A skill can run shell commands before Claude reads itRuns a shell command before a skill loads, so Claude gets fresh data in its prompt.11 Sep 2026 - Tip
.envA .worktreeinclude file carries your .env into each Claude worktreeCopies your gitignored local files, like .env, into every new Claude Code worktree.12 Jun 2026
Git4
- Tip
"fatal error" repo:github-linguist/linguistPath: in GitHub code search limits results to the files you meanCut thousands of code results down to one folder or file type.1 Dec 2026 - Tip
is:open involves:@meInvolves:@me turns GitHub issue search into a list of what you touchedFind that issue you once commented on without remembering the repository.1 Dec 2026 - Tip
/security-review/security-review in Claude Code checks your branch for security holesReviews the diff between your branch and the main branch for injection, auth and data leaks.30 Nov 2026 - Tip
git commit --fixup a1b2c3dgit commit --fixup plus --autosquash keeps your history clean without any editing10 Nov 2026
Other tips1
Network1
Posts2
Nothing matches.