Why doesn't IPython return anything from an if statement?

I am writing instructions in IPython that should return something, but they do not. For example, this statement if:

In [1]: 1
Out[1]: 1

In [2]: if True: 1

In [3]: 

And the same thing happens with operators for:

In [3]: for i in [1]: i

In [4]: 

Meanwhile, in the regular Python interpreter, it works as expected:

>>> if True: 1
... 
1
>>> for i in [1]: i
... 
1

I tested this on IPython 1.2.1 ( Update : and 6.1.0) on Ubuntu 14.04 and 4.1.2 on PythonAnywhere with Python 2 and 3.

Is this behavior intentional? If so, what is its purpose?

+4
source share

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


All Articles