top of page

Python for People Who Already Code

  • Contributor
  • Feb 27
  • 5 min read

You write code in another language — JavaScript, C#, Java, whatever — and you need to pick up Python. Maybe you're joining a project that uses it. Maybe you want to build something with Django or FastAPI. Maybe every ML tutorial assumes you know it and you're tired of translating in your head.

This isn't "Python for beginners." You already understand variables, functions, loops, and data structures. This is a guided tour of what makes Python different from what you already know, where the ecosystem lives, and how to be productive in days instead of weeks.

What's Different About Python

Whitespace Is Syntax

The most immediately obvious difference. Python uses indentation to define code blocks — no braces, no end keywords.

def process_order(order):
    if order.total > 100:
        discount = order.total * 0.1
        order.total -= discount
    return order

The indentation isn't style. It's structure. Mix tabs and spaces and Python will error. Use 4 spaces (the universal convention) and configure your editor to convert tabs to spaces.

If this feels wrong after years of braces, give it a week. The visual clarity grows on you.

Dynamic Typing with Type Hints

Python is dynamically typed — variables don't have declared types. But modern Python (3.5+) supports type hints that look like static typing without enforcing it at runtime.

# No types — works fine
def greet(name):
    return f"Hello, {name}"

# Type hints — same runtime behavior, but tooling can check
def greet(name: str) -> str:
    return f"Hello, {name}"

Type hints are checked by tools like mypy, not by Python itself. Use them. They catch bugs, improve documentation, and make your IDE smarter. Coming from a typed language, they'll feel familiar.

Everything Is an Object

Functions are objects. Classes are objects. Modules are objects. You can pass functions as arguments, return them from other functions, and assign them to variables. If you know JavaScript, this is familiar. If you come from Java or C#, it's more flexible than you're used to.

def apply(func, value):
    return func(value)

result = apply(len, "hello")  # 5

List Comprehensions

Python's most distinctive idiom. A concise way to create lists from other iterables.

# Other languages: loop and append
squares = []
for x in range(10):
    squares.append(x ** 2)

# Python: list comprehension
squares = [x ** 2 for x in range(10)]

# With filter
even_squares = [x ** 2 for x in range(10) if x % 2 == 0]

These replace the map/filter pattern you know from other languages. They're readable once you internalize the pattern, and they're everywhere in Python code.

The Standard Library Is Enormous

Python ships with batteries included. HTTP requests (urllib), JSON parsing (json), CSV handling (csv), file system operations (pathlib), regular expressions (re), date/time (datetime), testing (unittest, pytest externally), and much more — all in the standard library.

Before installing a package, check if the standard library already handles it. It often does.

The Ecosystem Map

Web Frameworks

Django: Full-featured, opinionated, includes ORM, admin panel, authentication, and templates. The "Rails of Python." Use for full-stack web applications where you want convention over configuration.

FastAPI: Modern, fast, designed for APIs. Type hints drive automatic validation, serialization, and documentation. Use for APIs, microservices, and ML model serving.

Flask: Minimal, flexible, plug what you need. Use when you want control over every component choice.

Recommendation for someone learning: FastAPI if you're building APIs. Django if you're building a full web application. Flask is fine but increasingly less compelling as FastAPI matures.

Data and ML

pandas: Data manipulation and analysis. If you've used R's dataframes or SQL on tabular data, pandas is the Python equivalent.

NumPy: Numerical computing. Arrays, linear algebra, random number generation. The foundation under almost every scientific Python library.

scikit-learn: Machine learning. Classification, regression, clustering, preprocessing. The standard toolkit for traditional ML.

PyTorch / TensorFlow: Deep learning frameworks. PyTorch has won the research and developer experience battle.

Package Management

pip: Python's package installer. pip install requests installs a package from PyPI (the Python Package Index).

Virtual environments: Isolate project dependencies. Without them, every project shares the same global packages and version conflicts are inevitable.

# Create a virtual environment
python -m venv .venv

# Activate it (Unix/Mac)
source .venv/bin/activate

# Activate it (Windows)
.venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

Poetry or uv: Modern dependency management tools that handle virtual environments, dependency resolution, and lock files. If you're starting a new project, use one of these instead of raw pip. uv is the newest and fastest.

Testing

pytest: The standard testing framework. Simpler and more powerful than unittest. Fixtures, parameterization, and a massive plugin ecosystem.

def test_greet():
    assert greet("World") == "Hello, World"

def test_greet_empty():
    assert greet("") == "Hello, "

Just functions that start with test_ and use assert. No test classes required unless you want them.

Common Gotchas for Newcomers

Mutable Default Arguments

# BUG: the list is shared across all calls
def append_to(element, target=[]):
    target.append(element)
    return target

# FIX: use None as default
def append_to(element, target=None):
    if target is None:
        target = []
    target.append(element)
    return target

Default arguments are evaluated once when the function is defined, not on each call. Mutable defaults (lists, dicts) persist between calls. This surprises everyone exactly once.

Indentation Errors Are Syntax Errors

If your code has inconsistent indentation — even a single line — Python won't run it. Configure your editor for 4-space indentation and never mix tabs and spaces.

is vs ==

== checks equality (same value). is checks identity (same object in memory). Use == for comparisons. Use is only for None checks: if x is None.

Global Interpreter Lock (GIL)

Python's GIL means only one thread executes Python code at a time. CPU-bound multithreading doesn't speed things up. Use multiprocessing for CPU parallelism, or asyncio for I/O-bound concurrency.

This is Python's most significant limitation for performance-critical work. For most web applications and scripting, it doesn't matter. For heavy computation, it matters a lot.

Getting Productive Fast

  1. Set up your environment. Install Python 3.11+, install uv or poetry, create a virtual environment.

  2. Pick a project. Build something small in the domain you care about — a web API with FastAPI, a data analysis script with pandas, a CLI tool.

  3. Use type hints from day one. They'll feel natural coming from a typed language and they'll save you from the debugging overhead of dynamic typing.

  4. Read real Python code. Find well-maintained open source projects (FastAPI itself, httpx, rich) and read their source. Python's readability makes this uniquely productive.

  5. Use pytest immediately. It's the easiest test framework you'll ever use. Write tests alongside your code from the start.

Key Takeaway

Python's differences from other languages are: whitespace as syntax, dynamic typing with optional type hints, a massive standard library, and list comprehensions as a core idiom. The ecosystem covers web (Django, FastAPI), data (pandas, NumPy), and ML (scikit-learn, PyTorch). Use virtual environments for every project. Watch for mutable default arguments and the GIL. Pick a project and build — Python's readability means you'll be productive faster than in most languages.

bottom of page