AMSA

Python 101

Authors

Ferran Aran Domingo

Oriol Agost Batalla

Pablo Fraile Alonso

Introduction

This page is intended for people that don’t know a lot of python or want to know a little bit more about the tools we’ll be using on Prac-2.

Python 101

If you’re just getting started with Python, a great introduction is 🔗 Harvard’s CS50 lecture

Typed Python

You’ll often hear that Python is not a typed language. That’s true in the sense that it’s dynamically typed, but the Python community has recognized the value of type hints. That’s why we now have the typing module.

With typing, you can:

  • Make your code more self-documenting.

  • Get IDE/editor assistance (e.g., autocomplete, type checking).

  • Catch bugs earlier.

In our library and Prac-2, we use typing. We recommend you to use it too!

🔗 Learn more about Python typing here

Project Management Tool

Instead of managing dependencies the old way with pip: (pip install ...), we’ll be using uv.

Why uv?:

  • It’s faster and more modern than pip.

  • Handles virtual environments automatically.

  • Created and maintained by the same team behind Ruff (our linter).

If you want to learn more, check out: 🔗 Why uv is the future of Python tooling

Linter

Python follows community standards defined in PEPs (Python Enhancement Proposals). PEP 8, for example, specifies how code should be styled (indentation, line length, naming conventions, etc.).

Of course, no one wants to memorize every detail about the standard, so we use linters. The term comes from an old C tool called Lint (1970s), which checked code for bugs and style issues.

As a summary, is a tool that formats the code according to the python standard. For this course, we’ll use Ruff as a linter because:

  • It’s extremely fast.

  • Maintained by the astral (the same ones that developed uv).

  • Enforces PEP standards automatically.