Let Python and AI do the boring work for you
Automate files, reports, websites, and everyday tasks
Renaming a hundred files, pulling numbers from a website, sending the weekly report: if you do it more than twice, a short Python script can do it for you. Real Python teaches you to write scripts and command-line tools you can trust, one practical task at a time.
from collections import Counter from pathlib import Path import shutil downloads = Path.home() / "Downloads" moved = Counter() for path in downloads.iterdir(): if path.is_file() and path.suffix: folder = downloads / path.suffix[1:].lower() folder.mkdir(exist_ok=True) shutil.move(path, folder / path.name) moved[folder.name] += 1 print(f"Moved {moved.total()} files:", dict(moved))
$ python tidy.py Moved 23 files: {'pdf': 9, 'jpg': 7, 'csv': 4, 'zip': 3} $ ls ~/Downloads csv/ jpg/ pdf/ zip/
- 50tutorials & video courses
- 30+interactive quizzes
- 45+coding exercises
- 5guided learning paths
Automate the tasks that eat your week
Python’s standard library and a handful of well-loved packages cover almost everything you’d want to automate. Real Python shows you how to use them with small, practical examples you can adapt right away.
Files and folders
Find, rename, move, back up, and compress files across whole directory trees without clicking through a file manager.
Command-line tools
Turn a one-off script into a reusable tool with options and help text, and run other programs from Python.
Documents and data
Read and write CSV, JSON, Excel, and PDF files, and send the finished report by email.
The web
Download files, call APIs, scrape pages, and drive a real browser to fill in forms and click through sites for you.
From your first script to tools you can rely on
Not sure where to start? Work through these learning paths in order. Each one mixes tutorials, video courses, quizzes, and exercises, and tracks your progress as you go.
-
1
Files and File Streams
Read and write files, navigate the file system with pathlib, and work with encodings, ZIP archives, and PDFs.
-
2
Important Standard Library Modules
Dates and times, JSON and CSV, regular expressions, subprocess, and argparse: the batteries-included toolkit behind most automation scripts.
-
3
Exceptions, Logging, and Debugging
Make scripts that run unattended fail gracefully, leave a useful log behind, and are easy to fix when something goes wrong.
-
4
Python Web Scraping
Make HTTP requests, parse HTML with Beautiful Soup, scale up with Scrapy, and automate a real browser with Selenium.
-
DevOps With Python
Run scripts anywhere, package and share them, and automate testing and deployment with CI/CD, Docker, and AWS.
New to Python itself? Start with Python Basics first, then come back here.
Find files by extension
This is a real exercise from the Practical Recipes for Working With Files in Python video course, and the first step toward a script like the one above. Write your function in the editor and click Run Tests.
Running tests, hints, and solutions are included with a Real Python membership. Not a member yet? You can still read the task and write your solution before you join.
Read it, watch it, test it, practice it
Every automation topic comes in the formats that help it stick. Mix them however you like.
Tutorials
In-depth, example-driven guides to pathlib, subprocess, argparse, web scraping, and more.
Start with pathlib →Video courses
Follow along as an instructor builds real scripts, one bite-sized lesson at a time.
Watch the file recipes course →Quizzes
Check what you’ve learned in a few minutes and see exactly which concepts to review.
Test your standard library skills →Coding exercises
Write real file-handling, logging, and scraping code in your browser and get instant test feedback.
How exercises work →Script not doing what you expected? Ask right where you are
Automation code tends to fail quietly: a path that’s relative to the wrong folder, a glob that matches nothing, a PermissionError halfway through a batch of files.
Mentor AI sees the tutorial, lesson, or exercise you’re on and your code, and nudges you toward the fix one hint at a time, so you understand what your script is actually doing.
Meet Mentor AI →['data_01.txt', 'data_02.txt'], but my list is full of long PosixPath(...) things. What’s wrong?You’re close! .iterdir() gives you Path objects for the full location of each file, and you’re adding those to your list as they are.
A Path can tell you just the last part of itself. Which attribute do you think that is?
path.name! Now I get the filenames.Exactly. One test still fails on order. .iterdir() doesn’t promise any particular order, so how could you make sure the list comes back alphabetical?
Learn the tools that get the job done
Most of what you need ships with Python. The rest is a pip install away.
New and updated for 2026
The Real Python team keeps publishing and refreshing automation content, so what you learn matches the tools and Python versions you’ll use every day.
Explore the standard library path →- CourseSending Emails Using Python
- CourseStructuring Your Python Script
- TutorialPython sleep(): How to Add Time Delays to Your Code
- CourseDownloading Files From URLs With Python
- CourseWorking With APIs in Python: Reading Public Data
- TutorialHow to Run Your Python Scripts and Code
- TutorialThe Terminal: First Steps and Useful Commands for Python Developers
Questions and answers
Do I need to know Python before I start?
You should be comfortable with Python basics like variables, lists, loops, and functions. If you’re not there yet, the Python Basics learning path gets you ready, and many first automation scripts use nothing more than what it covers.
What’s the difference between a script and a program?
Mostly size and intent. A script is usually a single file that does one job, like tidying a folder. As you add options, error handling, and logging, it grows into a tool others can use. This roadmap covers both steps. To get comfortable running your code, start with How to Run Your Python Scripts and Code.
Should I use argparse, Click, or Typer for command-line tools?
Start with argparse. It ships with Python, so your script runs anywhere without extra installs. When your tool grows several subcommands, Click and Typer save you a lot of boilerplate.
Is web scraping allowed?
It depends on the site. Always check its terms of service and robots.txt, prefer an official API when one exists, and keep your request rate polite. The Python Web Scraping path covers these ground rules before you write your first scraper.
What’s included in a membership?
Every Real Python membership includes all video courses, quizzes, coding exercises, and learning paths for automation and every other topic, along with Mentor AI as it rolls out.
Stop doing it by hand
Get your free learning plan and follow the full scripting and automation roadmap, with courses, quizzes, coding exercises, and a mentor at your side.