# Magic Command

*noun*

say it: **“MAJ-ik kuh-MAND”** **/ˈmædʒɪk kəˈmænd/**

A line in a notebook that starts with %, giving an instruction to the notebook's kernel instead of running as Python.

## What is a **magic command** in a notebook?

A **magic command** is a line in a notebook cell that starts with `%`. It's an instruction to the notebook's kernel,
not Python, so it works only in a notebook: the same line in a `.py` file is a syntax error.

```python
%load_ext autoreload
%autoreload 2
```

## In a sentence

- “%autoreload 2 is a **magic command**, so it fails in a .py file.”
- “The first cell held a **magic command** that turns on autoreload.”

Level: Journeyman · [More Python terms at this level](https://www.ask-codey.com/glossary?category=python&level=3)

Updated: November 19, 2026

Source: https://www.ask-codey.com/glossary/magic-command
