'What does the % in load_ext mean in python

There is a lot of discussion of %load_ext magic in Python (e.g. here https://ipython.readthedocs.io/en/stable/config/extensions/index.html)

One thing that has always confused me though: what is the % doing / what does it mean?

Why isn't the relevant code just called by load_ext



Solution 1:[1]

From the IPython docs, Built-in magic commands:

Note To Jupyter users: Magics are specific to and provided by the IPython kernel. Whether Magics are available on a kernel is a decision that is made by the kernel developer on a per-kernel basis. To work properly, Magics must use a syntax element which is not valid in the underlying language. For example, the IPython kernel uses the % syntax element for Magics as % is not a valid unary operator in Python. However, % might have meaning in other languages.

(By the way, %load_ext is covered in brief on the same page.)


Related questions:

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1