Strange _ behavior
pavlenko-volodymyr opened this issue · 4 comments
pavlenko-volodymyr commented
Hi!
I ran your example and got this:
In [1]: from fn.iters import map
In [2]: from fn import _
In [3]: list(map(_ * 2, range(5)))
Out[3]: [0, 2, 4, 6, 8]
In [4]: list(map(_ * 2, range(5)))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-448bfa47eeda> in <module>()
----> 1 list(map(_ * 2, range(5)))
TypeError: 'list' object is not callable
python 2.7.3 windows 7 x64
kachayev commented
The problem is that _
means "latest output" in python interactive shells (both python and ipython). I.e.
>>> 1 + 1
2
>>> _
2
So, in your case you get in In [4] _ = [0, 2, 4, 6, 8]
(list from Out[3]). Usually I advice to make import like
from fn import _ as __
when working in shells. In any case, I'll add this block to documentation and than close this ticket.
pavlenko-volodymyr commented
Thanks
But __ in ipython is empty string. So, it can be some misunderstanding with this.