agentsclimarketplace

Python scala syntax mapping

Skill cxcscmu/SkillLearnBench/skills/b1-one-shot-gemini-3-flash-preview/python-scala-translation/python-scala-syntax-mapping

Basic syntax and type mapping from Python to Scala, including primitive types and common control structures.From its SKILL.md

Install
npx -y skills add cxcscmu/SkillLearnBench --skill python-scala-syntax-mapping

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

1.7 KB, 536 tokens by cl100k_base, as published. Nobody here has run it

Python to Scala Syntax Mapping

This skill provides a quick reference for translating basic Python syntax to Scala 2.13.

Type Mapping

PythonScalaNotes
intInt or LongUse Long for large integers.
floatDoubleScala's Double is equivalent to Python's float.
strString
bytesArray[Byte]
boolBoolean
Nonenull or NoneUse Option[T] (Some/None) for idiomatic Scala.
list[T]List[T] or Seq[T]List is immutable, ArrayBuffer is mutable.
dict[K, V]Map[K, V]Map is immutable, mutable.Map is mutable.
tuple[T, ...](T, ...)Scala uses parentheses for tuples.
AnyAny
Union[A, B]Either[A, B] or TraitUse traits for better structure.

Variables and Constants

  • Python: x = 1 (mutable/immutable by convention)
  • Scala: val x = 1 (immutable), var x = 1 (mutable)

String Formatting

  • Python: f"Value: {val:.2f}"
  • Scala: s"Value: $val", f"Value: $val%.2f"

Control Flow

If-Else

  • Python:
    if x > 0:
        return "pos"
    else:
        return "neg"
    
  • Scala:
    if (x > 0) "pos" else "neg" // Expressions are preferred
    

For Loops

  • Python: for i in range(10):
  • Scala: for (i <- 0 until 10) { ... }

List Comprehension

  • Python: [x * 2 for x in items if x > 0]
  • Scala: items.filter(_ > 0).map(_ * 2) or for (x <- items if x > 0) yield x * 2

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.