I accidentally discovered this feature in IPython:
In [126]: def blah(): return 5
In [127]: /blah
Out[127]: 5
In [128]: /range 5 2 4
Out[128]: range(5, 2, 4)
In [133]: /int '100' base=16
Out[133]: 256
A line starting with a forward slash will have commas and function call parens automatically inserted.
Where do I find out more? I can't seem to find the docs for it.
If you type ?
in ipython you will get the builtin documentation:
You can force auto-parentheses by using '/' as the first character
of a line. For example::
In [1]: /globals # becomes 'globals()'
Note that the '/' MUST be the first character on the line! This
won't work::
In [2]: print /globals # syntax error
In most cases the automatic algorithm should work, so you should
rarely need to explicitly invoke /. One notable exception is if you
are trying to call a function with a list of tuples as arguments (the
parenthesis will confuse IPython)::
In [1]: zip (1,2,3),(4,5,6) # won't work
but this will work::
In [2]: /zip (1,2,3),(4,5,6)
------> zip ((1,2,3),(4,5,6))
Out[2]= [(1, 4), (2, 5), (3, 6)]
IPython tells you that it has altered your command line by
displaying the new command line preceded by -->. e.g.::
In [18]: callable list
-------> callable (list)
The relevant docs page which includes other features.
There is a nice list taken from here of most basic features:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.