Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 68 additions & 51 deletions IPython/core/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
options available. This document only describes interactive features.

MAIN FEATURES
-------------

* Access to the standard Python help. As of Python 2.1, a help system is
available with access to object docstrings and the Python manuals. Simply
Expand Down Expand Up @@ -116,13 +117,13 @@
* Search previous command history in two ways (also requires readline):

- Start typing, and then use Ctrl-p (previous,up) and Ctrl-n (next,down) to
search through only the history items that match what you've typed so
far. If you use Ctrl-p/Ctrl-n at a blank prompt, they just behave like
normal arrow keys.
search through only the history items that match what you've typed so
far. If you use Ctrl-p/Ctrl-n at a blank prompt, they just behave like
normal arrow keys.

- Hit Ctrl-r: opens a search prompt. Begin typing and the system searches
your history for lines that match what you've typed so far, completing as
much as it can.
your history for lines that match what you've typed so far, completing as
much as it can.

- %hist: search history by index (this does *not* require readline).

Expand Down Expand Up @@ -189,52 +190,68 @@

* Auto-parentheses and auto-quotes (adapted from Nathan Gray's LazyPython)

1. Auto-parentheses
Callable objects (i.e. functions, methods, etc) can be invoked like
this (notice the commas between the arguments):
In [1]: callable_ob arg1, arg2, arg3
and the input will be translated to this:
------> callable_ob(arg1, arg2, arg3)
This feature is off by default (in rare cases it can produce
undesirable side-effects), but you can activate it at the command-line
by starting IPython with `--autocall 1`, set it permanently in your
configuration file, or turn on at runtime with `%autocall 1`.

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)

2. Auto-Quoting
You can force auto-quoting of a function's arguments by using ',' as
the first character of a line. For example:
In [1]: ,my_function /home/me # becomes my_function("/home/me")

If you use ';' instead, the whole argument is quoted as a single
string (while ',' splits on whitespace):
In [2]: ,my_function a b c # becomes my_function("a","b","c")
In [3]: ;my_function a b c # becomes my_function("a b c")

Note that the ',' MUST be the first character on the line! This
won't work:
In [4]: x = ,my_function /home/me # syntax error
1. Auto-parentheses

Callable objects (i.e. functions, methods, etc) can be invoked like
this (notice the commas between the arguments)::

In [1]: callable_ob arg1, arg2, arg3

and the input will be translated to this::

callable_ob(arg1, arg2, arg3)

This feature is off by default (in rare cases it can produce
undesirable side-effects), but you can activate it at the command-line
by starting IPython with `--autocall 1`, set it permanently in your
configuration file, or turn on at runtime with `%autocall 1`.

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)

2. Auto-Quoting

You can force auto-quoting of a function's arguments by using ',' as
the first character of a line. For example::

In [1]: ,my_function /home/me # becomes my_function("/home/me")

If you use ';' instead, the whole argument is quoted as a single
string (while ',' splits on whitespace)::

In [2]: ,my_function a b c # becomes my_function("a","b","c")
In [3]: ;my_function a b c # becomes my_function("a b c")

Note that the ',' MUST be the first character on the line! This
won't work::

In [4]: x = ,my_function /home/me # syntax error
"""

interactive_usage_min = """\
Expand Down