Python scala libraries
Mapping standard and common libraries from Python to Scala, including datetime, decimal, and JSON.From its SKILL.md
npx -y skills add cxcscmu/SkillLearnBench --skill python-scala-librariesAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
1.2 KB, 279 tokens by cl100k_base, as published. Nobody here has run it
Python to Scala Libraries and Specialized Types
This skill covers the translation of library-specific functionality.
Datetime
- Python:
datetime.datetime,datetime.date. - Scala:
java.time.LocalDateTime,java.time.LocalDate. - Formatting:
java.time.format.DateTimeFormatter.
| Python | Scala |
|---|---|
dt.strftime("%Y-%m-%d") | dt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) |
datetime.now() | LocalDateTime.now() |
Decimal
- Python:
decimal.Decimal. - Scala:
BigDecimal. - Formatting:
f"$decimal%.2f".
JSON (Circe)
- Python:
json.dumps(obj),json.loads(str). - Scala (Circe):
obj.asJson.noSpaces,parse(str). - Recursive JSON: Use
io.circe.Jsonfor a safe representation.
Error Handling
- Python:
try...except,raise RuntimeError. - Scala:
Try[T](Success/Failure),Either[L, R]. - Runtime Error:
throw new RuntimeException("...").
import scala.util.Try
val result = Try(operation()) // Success(v) or Failure(e)
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.