When I was playing with Python in an interactive environment such as IPython, it was a generator type instead of a list type, so
In [2]: foo()
Out[2]: <generator object foo at 0x7f1f35a3dee8>
I think that there is an irritating experience. I think it became especially noticeable after Python3.
In such a case, well, I should modify it to list (foo ())
.
Ctrl + A (or Home),'l','i','s','t','(', Ctrl + E (or End),')'
And I have to press the 8 key. Tedious. I'm irritated.
I suddenly came up with it.
class Apply:
def __init__(self, f):
self.f = f
def __lt__(self, x):
return self.f(x)
L = Apply(list)
Once written,
In [2]: foo()
Out[2]: <generator object foo at 0x7f1f35a3dee8>
Even if it's irritating
In [8]: foo() >L
Out[8]: [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
You can easily make a list just by doing.
If you create 50-apply.py
in the $ HOME / .ipython / profile_default / startup
directory, you can calm down and list it with > L
after that.