modernize-scientific-stack

Migrate legacy Python 2 scientific scripts to Python 3 with pathlib and pandas.

134|21|Updated Nov 12, 2025
One-click install
npx skills add https://github.com/letta-ai/skills --skill modernize-scientific-stack
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: modernize-scientific-stack
Source: https://github.com/letta-ai/skills/tree/main/ai/benchmarks/letta/terminal-bench-2/trajectory-only/modernize-scientific-stack
Command: npx skills add https://github.com/letta-ai/skills --skill modernize-scientific-stack

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides converting legacy Python 2 scientific computing scripts to Python 3, addressing deprecated libraries and syntax, and aligning with modern scientific stacks.

Core Features & Use Cases

  • Code modernization: Update Python 2 syntax (print, unicode, division) to Python 3.
  • Library migration: Replace legacy libraries like ConfigParser, cPickle, urllib2, and StringIO with modern equivalents (configparser, pickle, urllib.request, io.StringIO) and adopt pathlib.
  • Validation & Testing: Ensure results are preserved after modernization using tests and sample data.

Quick Start

Run a small pilot: identify Python 2 scripts in your repo, apply the recommended modernization steps, then run existing tests to verify identical results.

Frequently Asked Questions about modernize-scientific-stack

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate Python 2 scientific code to Python 3?

Migrate Python 2 scientific code to Python 3 by updating syntax (print statements, division), replacing deprecated libraries (ConfigParser → configparser, urllib2 → urllib.request), adopting pathlib for file paths, and adding type hints. Verify results match the original using existing tests and sample data.

What libraries should I use when modernizing Python 2 data processing scripts?

Use pandas and numpy for data processing, pathlib for file path handling, and io.StringIO instead of StringIO. Replace csv with pandas for tabular data, pickle for cPickle, and configparser for ConfigParser to align with Python 3 scientific stacks.

How do I ensure my Python 2 to Python 3 migration preserves results?

Create a verification workflow by running existing tests against migrated code with sample data to confirm identical output. Enforce UTF-8 encoding for all file I/O, use context managers for resource handling, and maintain a requirements.txt documenting dependencies before deployment.

Can I use pathlib instead of os.path for all file operations?

Yes. Pathlib modernizes file handling in Python 3 by replacing os.path for all path manipulations. It provides object-oriented path operations, better cross-platform compatibility, and cleaner syntax than legacy string-based approaches.

What Python 2 patterns need updating for Python 3 scientific computing?

Update print statements to functions, fix integer division (/→//), remove unicode literals, replace StringIO and cPickle imports, and migrate ConfigParser usage. Add type hints and use context managers (with statements) for file handling.

Do I need to rewrite tests when converting Python 2 scientific code to Python 3?

No. Keep existing tests and run them against your migrated code to verify identical results. Tests validate that modernization preserves functionality without requiring rewrites if your original test suite covers the core logic.