Why do I get an empty tuple if I type / in iPython?

Open iPython and enter the following:

/ 

Click and ask a question about the results:

 () 

You cannot assign it, I assume it has something to do with shell functionality.

Edit:

You can assign it using

  p = Out[xx] 

But not directly:

  p = / 

will give:

 SyntaxError 

This is really an empty tuple.

+5
source share
1 answer

This is a convenience function for called objects / names. This is not an empty tuple, but brackets. From iPython help system ( ? ):

  • Auto Negotiation and Autocopy (adapted from Nathan Gray LazyPython)

    • Auto Brackets

      Called objects (i.e. functions, methods, etc.) can be called like this (note the commas between the arguments) ::

      In [1]: callable_ob arg1, arg2, arg3

      and the input will be translated to this:

      callable_ob (arg1, arg2, arg3)

      This feature is disabled by default (in rare cases it may have unwanted side effects), but you can activate it on the command line by running IPython using --autocall 1 , install it permanently in your configuration file, or enable it at runtime using %autocall 1 .

      You can force the parentheses to be copied using "/" as the first character of the line. For instance:

      In [1]: / globals # becomes 'globals ()'

+7
source

Source: https://habr.com/ru/post/1213454/


All Articles