2

I was working on a project in which I had to write

%matplotlib inline 

at the beginning to solve a problem.

But I'm wondering what does this "%" stands for: is it an operator ? Has it a name so I could do some researches about it ?

Drico
  • 1,284
  • 15
  • 33

1 Answers1

4

You are not looking at standard Python code.

You are almost certainly using an IPython interactive session, and it uses % as a prefix to recognize special commands, called magic functions. Type %quickref to get a quick reference. From that reference:

%magic : Information about IPython's 'magic' % functions.

Magic functions are prefixed by % or %%, and typically take their arguments without parentheses, quotes or even commas for convenience. Line magics take a single % and cell magics are prefixed with two %%.

If you then type in %magic you'll find the reference documentation for available magic functions, including:

%matplotlib:

 %matplotlib [gui]

Set up matplotlib to work interactively.

This function lets you activate matplotlib interactive support at any point during an IPython session. It does not import anything into the interactive namespace.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343