我偶然在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
以正斜杠开头的行将自动插入逗号和函数调用parens。
我在哪里可以找到更多信息?我似乎无法找到它的文档。
答案 0 :(得分:4)
如果您在ipython中输入?
,您将获得内置文档:
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)
包含其他功能的相关docs页面。
从here的大多数基本功能中都有一个很好的列表: