Page 120 - Beginning Programming with Pyth - John Paul Mueller
P. 120
example, instead of displaying graphic output in a separate window, you can chose to display it within the cell, as if by magic (because the cells appear to hold only text). Or you can use magic to check the performance of your application, without all the usual added code that such performance checks require.
A magic function begins with either a % or %% sign. Those with a % sign work within the environment and those with a %% sign work at the cell level. For example, if you want to obtain a list of magic functions, type %lsmagic and then press Enter in IPython (or run the command in Notebook) to see them, as shown in Figure 5-7. (Note that IPython uses the same input, In, and output, Out, prompts that Notebook uses.)
FIGURE 5-7: The %lsmagic function displays a list of magic functions for you.
Not every magic function works with IPython. For example, the %autosave function has no purpose in IPython because IPython doesn't automatically save anything.
Table 5-1 lists a few of the most common magic functions and their purpose. To obtain a full listing, type %quickref and press Enter in Notebook (or the IPython console) or check out the full listing at https://damontallen.github.io/IPython-quick-ref-sheets/.
TABLE 5-1 Common Notebook and IPython Magic Functions