# Python Scala Collections

> Guide for mapping Python collection types and operations to Scala equivalents.

- Skill: `cxcscmu/python-scala-collections` (Agent Skill)
- Install (CLI): `npx get-skill add cxcscmu/python-scala-collections`
- Raw SKILL.md: https://api.skillmd.com/api/skills/cxcscmu/python-scala-collections/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: cxcscmu (https://skillmd.com/u/cxcscmu)
- Updated: 2026-11-24
- Page: https://skillmd.com/skills/cxcscmu/python-scala-collections

---


# Python to Scala Collections

## Type Mappings
| Python | Scala |
|--------|-------|
| `list[T]` | `List[T]` or `mutable.ListBuffer[T]` |
| `dict[K, V]` | `Map[K, V]` or `mutable.Map[K, V]` |
| `tuple[T, ...]` | `(T, ...)` or `Vector[T]` |
| `set[T]` | `Set[T]` |
| `Sequence[T]` | `Seq[T]` |
| `Iterable[T]` | `Iterable[T]` |
| `Iterator[T]` | `Iterator[T]` |

## Mutable Collections
```scala
import scala.collection.mutable

// Python: list with append -> mutable.ListBuffer
val buf = mutable.ListBuffer.empty[Token]
buf += token

// Python: dict -> mutable.Map
val reg = mutable.Map.empty[String, TokenContainer[T]]
reg(key) = container
```

## Collection Operations
```scala
// Python: [f(x) for x in xs] -> xs.map(f)
// Python: [x for x in xs if p(x)] -> xs.filter(p)
// Python: enumerate(xs) -> xs.zipWithIndex
```

