python-fp
Guide to functional-style Python — pure functions, immutability, HOFs, functools/itertools, typed functional patterns.
Skill by wachawo
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/wachawo-python-fp
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: writing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/python-fp
What's inside
- Skill name
python-fp- Description
- Guide to functional-style Python — pure functions, immutability, HOFs, functools/itertools, typed functional patterns. Use when writing new code in a functional style, refactoring classes into functions, mentioning "functional approach", "pure functions", "immutability", or asking to remove side effects.
- License
- MIT
- Instructions
- 339 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Functional Python
## When to use
- Writing serializers, helpers, formatters, validators, mappers, converters — anything stateless
- Refactoring a class with a single method + `__init__` into a plain function
- A data transformation pipeline (load → filter → map → aggregate)
- Making code easier to test (a pure function = `assert f(x) == y`, no mocks)
When **not** to use: ORM models, framework extensions (Flask/Marshmallow), long-lived objects with invariants.
## 1. Pure functions
A pure function:
1. **Deterministic** — the same inputs produce the same output.
2. **No side effects** — does not write to globals, files, or the database, and does not mutate its arguments.
```python
# Bad: mutates argument + reads global
TAX = 0.2
def add_total(items):
for it in items:
it["total"] = it["price"] * (1 + TAX)
return items
# Good: pure, tax is a parameter
def with_total(item: dict, tax: float) -> dict:
return {**item, "total": item["price"] * (1 + tax)}
results = [with_total(it, 0.2) for it in items]
```
Rule: if a function returns `None` and does something, that's a side effect. Isolate such functions at the system boundary (handlers, repositories), and keep the core pure.
## 2. Immutability
Immutable types in Python: `int`, `str`, `bytes`, `tuple`, `frozenset`, `NamedTuple`.
For records in FP style, use **`NamedTuple`** (it's a tuple under the hood, with no `__dict__` and no class behavior):
```python
from typing import NamedTuple
class User(NamedTuple):
id: int
name: str
email: str
u = User(1, "Alice", "a@x.com")
u2 = u._replace(email="alice@x.com") # new object, u is untouched
```
If the data has no behavior at all, use a plain `dict` returned from a factory function:
```python
def make_user(id: int, name: str, email: str) -> dict:
return {"id": id, "name": name, "email": email}
def with_email(user: dict, email: str) -> dict:
return {**user, "email": email}
```
Read-only view of a dictionary or module constants — via `types.MappingProxyType`:
```python
from types import MappingProxyType
CONFIG = MappingProxyType({"host": "localhost", "port": 5432})
CONFIG["host"] = "x" # TypeError: 'mappingproxy' does not support item assignment
```
`@dataclass(frozen=True)` is a pragmatic compromise when you need methods, validation in `__post_init__`, or framework integration. In strictly functional code, prefer `NamedTuple` or a dict factory.
For collections, return new ones rather than mutating:
```python
# Bad
def add_tag(tags: list[str], tag: str) -> list[str]:
tags.append(tag)
return tags
# Good
def add_tag(tags: tuple[str, ...], tag: str) -> tuple[str, ...]:
return (*tags, tag)
```
## 3. Higher-order functions
A first-class function: can be passed, returned, and captured in closures.
```python
from functools import partial, reduce
from operator import add, attrgetter, itemgetter
# partial: fix part of the arguments
to_usd = partial(format, fmt="${:.2f}")
# reduce: fold
total = reduce(add, prices, 0)
# operator: atomic operations without lambdas
users.sort(key=attrgetter("created_at"))
rows.sort(key=itemgetter("id"))
```
**Rule**: use `lambda` only for a single short expression inside `key=` / `map` / `filter`. If the body is longer than one line, use a regular `def`.
## 4. Closures and currying
A **closure** is an inner function that captures variables from an outer scope. Useful for configuration and accumulators:
```python
def make_multiplier(factor: int):
def multiply(x: int) -> int:
return x * factor
return multiply
double = make_multiplier(2)
triple = make_multiplier(3)From wachawo/claude-skills, MIT.
More from wachawo/claude-skills
- 0.479score
playwright
wachawo
Use when the task requires automating a real browser from the terminal (navigation, form filling, snapshots, screenshots, data extraction, debugging user…
SkillCFreshness: CClaude Code +9 - 0.479score
diagnose
wachawo
Disciplined loop for diagnosing complex bugs and performance regressions.
SkillCFreshness: CClaude Code +9 - 0.479score
mcp-builder
wachawo
Guidance for building high-quality MCP (Model Context Protocol) servers that let LLMs interact with external services through well-designed tools.
SkillCFreshness: CClaude Code +9 - 0.479score
drilldown-analyzer
wachawo
Systematic investigation of metric changes and anomalies.
SkillCFreshness: CClaude Code +9 - 0.476score
data-analyzer
wachawo
Systematic exploratory data analysis.
SkillCFreshness: CClaude Code +9 - 0.474score
qa
wachawo
Interactive QA session in which the user freely reports bugs or issues, and the agent files the corresponding GitHub issues.
SkillCFreshness: CClaude Code +9 - 0.474score
design-api
wachawo
Generate several radically different interface design options for a module via parallel sub-agents.
SkillCFreshness: CClaude Code +9 - 0.474score
grill-docs
wachawo
A "grilling" session that stress-tests your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) as…
SkillCFreshness: CClaude Code +9 - 0.474score
improve-arch
wachawo
Find opportunities to deepen modules in the codebase, drawing on the domain language from CONTEXT.md and decisions recorded in docs/adr/.
SkillCFreshness: CClaude Code +9 - 0.474score
python-code
wachawo
Improves Python library code quality through ruff linting, mypy type checking, Pythonic idioms, and refactoring.
SkillCFreshness: CClaude Code +9 - 0.474score
python-pep8
wachawo
Detailed PEP 8 guide for Python code — layout, imports, names, whitespace, comments, programming recommendations (None comparisons, exceptions, return…
SkillCFreshness: CClaude Code +9 - 0.474score
claude-api
wachawo
Build, debug, and optimize Claude API / Anthropic SDK applications.
SkillCFreshness: CClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- May 5, 2026 (5 months ago)
- Last release
- May 5, 2026 (5 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/wachawo/claude-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from wachawo
- 0.479score
mcp-builder
wachawo
Guidance for building high-quality MCP (Model Context Protocol) servers that let LLMs interact with external services through well-designed tools.
SkillCFreshness: CClaude Code +9 - 0.479score
playwright
wachawo
Use when the task requires automating a real browser from the terminal (navigation, form filling, snapshots, screenshots, data extraction, debugging user…
SkillCFreshness: CClaude Code +9 - 0.479score
diagnose
wachawo
Disciplined loop for diagnosing complex bugs and performance regressions.
SkillCFreshness: CClaude Code +9 - 0.479score
drilldown-analyzer
wachawo
Systematic investigation of metric changes and anomalies.
SkillCFreshness: CClaude Code +9 - 0.476score
data-analyzer
wachawo
Systematic exploratory data analysis.
SkillCFreshness: CClaude Code +9 - 0.474score
grill-docs
wachawo
A "grilling" session that stress-tests your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) as…
SkillCFreshness: CClaude Code +9
Cite this page
python-fp skill. Agent Mart. https://agentmart.dev/skills/wachawo-python-fp (last updated 2026-10-24)