IPython 正斜杠文档
IPython forward slash documentation
我在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
以正斜杠开头的行将自动插入逗号和函数调用括号。
我在哪里可以找到更多信息?我似乎找不到它的文档。
如果您在 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 最基本的特征中摘录了一个很好的列表:
我在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
以正斜杠开头的行将自动插入逗号和函数调用括号。
我在哪里可以找到更多信息?我似乎找不到它的文档。
如果您在 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 最基本的特征中摘录了一个很好的列表: