Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 6.6 — Modern Project Tooling with uv
Python · Example 1 of 2

Reading a pyproject.toml before and after uv add

uv is a command-line program and cannot run in the browser, but the file it edits is plain TOML, and Python 3.11+ can read it with tomllib. The first text has the shape uv init writes (the details vary a little by uv version); the second is what uv add httpx pydantic changes. The version numbers in both are examples: uv writes whatever is newest when you run the command.

uv is one fast tool that replaces pip, venv, pyenv and pipx: it creates projects, installs the right Python, adds dependencies, writes an exact uv.lock, and runs your code in the project's environment.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write the uv commands, one per line, to create a project called chatbot, move into its folder, add the package httpx, and run main.py.

02

In pyproject.toml, which section holds the packages needed at run time? Write a small [project] example with the name chatbot that needs httpx version 0.28 or newer.

03

Which files should be committed to git in a uv project, and which should not?

Explain it without notes

01

What problems does uv solve, and which older tools does it replace?

02

What is the difference between pyproject.toml and uv.lock?

03

What does uv run do that plain python does not?

04

How do you make a teammate's environment match yours exactly?

Reading a pyproject.toml before and after uv add
Sign in to run this example in your browser.

Expected output

after uv init
  name: weather-bot | python: >=3.13
  dependencies: []
after uv add httpx pydantic
  name: weather-bot | python: >=3.13
  dependencies: ['httpx>=0.28', 'pydantic>=2.12']