What's the type of time in jupyter notebook? Variable or function?
Below is my tests using python code.
What's the type of time in jupyter notebook? Variable or function?
Below is my tests using python code.
time (or more properly, %time), is an IPython magic - a command that is otherwise not available directly in Python. As I noted, they are typically prefixed with % or %% - % is for line magics, %% is for cell magics. If the automagic option is on, line magics can also be executed without the % character.
The () is not part of the IPython magic syntax. When you wrote time(), you were timing the expression (), which evaluates to an empty tuple.
IPython magic return values, if any, can be assigned to variables, but only when invoked with the % prefix:
a = %time
However, %time does not have a typical return value, so in the above example, a will be None.