##// END OF EJS Templates
More informative failure when passing bytes to a Unicode traitlet
More informative failure when passing bytes to a Unicode traitlet

File last commit:

r13439:c6bbf964
r13734:6c5e8f35
Show More
usage.py
570 lines | 22.6 KiB | text/x-python | PythonLexer
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 # -*- coding: utf-8 -*-
Fernando Perez
Unify command-line usage information in one place....
r2427 """Usage information for the main IPython applications.
"""
#-----------------------------------------------------------------------------
Matthias BUSSONNIER
update copyright to 2011/20xx-2011...
r5390 # Copyright (C) 2008-2011 The IPython Development Team
Fernando Perez
Unify command-line usage information in one place....
r2427 # Copyright (C) 2001-2007 Fernando Perez. <fperez@colorado.edu>
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 #
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
Fernando Perez
Unify command-line usage information in one place....
r2427 #-----------------------------------------------------------------------------
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
Brian Granger
Massive, crazy refactoring of everything....
r2202 import sys
from IPython.core import release
Fernando Perez
Unify command-line usage information in one place....
r2427 cl_usage = """\
Fernando Perez
Fix padding of matplotlib figures, after much whining from Stefan :)
r4254 =========
IPython
=========
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
Fernando Perez
Fix padding of matplotlib figures, after much whining from Stefan :)
r4254 Tools for Interactive Computing in Python
=========================================
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
Fernando Perez
Unify command-line usage information in one place....
r2427 A Python shell with automatic history (input and output), dynamic object
introspection, easier configuration, command completion, access to the
system shell and more. IPython can also be embedded in running programs.
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
Fernando Perez
Fix padding of matplotlib figures, after much whining from Stefan :)
r4254
Usage
MinRK
mention `--` in usage
r10056 ipython [subcommand] [options] [-c cmd | -m mod | file] [--] [arg] ...
MinRK
fix ipython usage text...
r10026
If invoked with no options, it executes the file and exits, passing the
remaining arguments to the script, just as if you had specified the same
MinRK
mention `--` in usage
r10056 command with python. You may need to specify `--` before args to be passed
to the script, to prevent IPython from attempting to parse them. If you
specify the option `-i` before the filename, it will enter an interactive
IPython session after running the script, rather than exiting. Files ending
in .py will be treated as normal Python, but files ending in .ipy can
contain special IPython syntax (magic commands, shell expansions, etc.).
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
MinRK
update usage.py for 0.11...
r4186 Almost all configuration in IPython is available via the command-line. Do
`ipython --help-all` to see all available options. For persistent
Bernardo B. Marques
remove all trailling spaces
r4872 configuration, look into your `ipython_config.py` configuration file for
MinRK
update usage.py for 0.11...
r4186 details.
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
Bradley M. Froehle
IPYTHON_DIR -> IPYTHONDIR in comments and documentation
r6696 This file is typically installed in the `IPYTHONDIR` directory, and there
MinRK
update usage.py for 0.11...
r4186 is a separate configuration directory for each profile. The default profile
Paul Ivanov
a couple of more stray XDG / .config references
r13439 directory will be located in $IPYTHONDIR/profile_default. IPYTHONDIR
defaults to to `$HOME/.ipython`. For Windows users, $HOME resolves to
C:\\Documents and Settings\\YourUserName in most instances.
Bernardo B. Marques
remove all trailling spaces
r4872
Fernando Perez
Fix padding of matplotlib figures, after much whining from Stefan :)
r4254 To initialize a profile with the default configuration file, do::
Bernardo B. Marques
remove all trailling spaces
r4872
MinRK
update usage.py for 0.11...
r4186 $> ipython profile create
Bernardo B. Marques
remove all trailling spaces
r4872
Bradley M. Froehle
IPYTHON_DIR -> IPYTHONDIR in comments and documentation
r6696 and start editing `IPYTHONDIR/profile_default/ipython_config.py`
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
Fernando Perez
Fix padding of matplotlib figures, after much whining from Stefan :)
r4254 In IPython's documentation, we will refer to this directory as
Bradley M. Froehle
IPYTHON_DIR -> IPYTHONDIR in comments and documentation
r6696 `IPYTHONDIR`, you can change its default location by creating an
Fernando Perez
Fix padding of matplotlib figures, after much whining from Stefan :)
r4254 environment variable with this name and setting it to the desired path.
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
Fernando Perez
Unify command-line usage information in one place....
r2427 For more information, see the manual available in HTML and PDF in your
Thomas Kluyver
Update various references to IPython's homepage.
r4086 installation, or online at http://ipython.org/documentation.html.
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 """
interactive_usage = """
IPython -- An enhanced Interactive Python
=========================================
IPython offers a combination of convenient shell features, special commands
and a history mechanism for both input (command history) and output (results
caching, similar to Mathematica). It is intended to be a fully compatible
replacement for the standard Python interpreter, while offering vastly
improved functionality and flexibility.
MinRK
update usage.py for 0.11...
r4186 At your system command line, type 'ipython -h' to see the command line
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 options available. This document only describes interactive features.
MAIN FEATURES
Carlos Cordoba
Make interactive_usage a bit more rst friendly...
r7680 -------------
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
* 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
type 'help' (no quotes) to access it.
* Magic commands: type %magic for information on the magic subsystem.
Erik Tollerud
purged ipythonrc from documentation and docstrings where no longer relevant
r4467 * System command aliases, via the %alias command or the configuration file(s).
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
* Dynamic object information:
Typing ?word or word? prints detailed information about an object. If
certain strings in the object are too long (docstrings, code, etc.) they get
snipped in the center for brevity.
Typing ??word or word?? gives access to the full information without
snipping long strings. Long strings are sent to the screen through the less
pager if longer than the screen, printed otherwise.
The ?/?? system gives access to the full source code for any object (if
available), shows function prototypes and other useful information.
If you just want to see an object's docstring, type '%pdoc object' (without
quotes, and without % if you have automagic on).
Both %pdoc and ?/?? give you access to documentation even on things which are
not explicitely defined. Try for example typing {}.get? or after import os,
type os.path.abspath??. The magic functions %pdef, %source and %file operate
similarly.
* Completion in the local namespace, by typing TAB at the prompt.
At any time, hitting tab will complete any available python commands or
variable names, and show you a list of the possible completions if there's
no unambiguous one. It will also complete filenames in the current directory.
This feature requires the readline and rlcomplete modules, so it won't work
if your Python lacks readline support (such as under Windows).
* 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
Carlos Cordoba
Make interactive_usage a bit more rst friendly...
r7680 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.
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
- Hit Ctrl-r: opens a search prompt. Begin typing and the system searches
Carlos Cordoba
Make interactive_usage a bit more rst friendly...
r7680 your history for lines that match what you've typed so far, completing as
much as it can.
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
MinRK
update usage.py for 0.11...
r4186 - %hist: search history by index (this does *not* require readline).
* Persistent command history across sessions.
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0
* Logging of input with the ability to save and restore a working session.
Bernardo B. Marques
remove all trailling spaces
r4872
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 * System escape with !. Typing !ls will run 'ls' in the current directory.
* The reload command does a 'deep' reload of a module: changes made to the
module since you imported will actually be available without having to exit.
* Verbose and colored exception traceback printouts. See the magic xmode and
xcolor functions for details (just type %magic).
* Input caching system:
IPython offers numbered prompts (In/Out) with input and output caching. All
input is saved and can be retrieved as variables (besides the usual arrow
key recall).
The following GLOBAL variables always exist (so don't overwrite them!):
_i: stores previous input.
_ii: next previous.
_iii: next-next previous.
_ih : a list of all input _ih[n] is the input from line n.
Additionally, global variables named _i<n> are dynamically created (<n>
being the prompt counter), such that _i<n> == _ih[<n>]
For example, what you typed at prompt 14 is available as _i14 and _ih[14].
You can create macros which contain multiple input lines from this history,
for later re-execution, with the %macro function.
The history function %hist allows you to see any part of your input history
by printing a range of the _i variables. Note that inputs which contain
magic functions (%) appear in the history with a prepended comment. This is
because they aren't really valid Python code, so you can't exec them.
* Output caching system:
For output that is returned from actions, a system similar to the input
cache exists but using _ instead of _i. Only actions that produce a result
(NOT assignments, for example) are cached. If you are familiar with
Mathematica, IPython's _ variables behave exactly like Mathematica's %
variables.
The following GLOBAL variables always exist (so don't overwrite them!):
_ (one underscore): previous output.
__ (two underscores): next previous.
___ (three underscores): next-next previous.
Global variables named _<n> are dynamically created (<n> being the prompt
counter), such that the result of output <n> is always available as _<n>.
Finally, a global dictionary named _oh exists with entries for all lines
which generated output.
* Directory history:
Your history of visited directories is kept in the global list _dh, and the
magic %cd command can be used to go to any entry in that list.
* Auto-parentheses and auto-quotes (adapted from Nathan Gray's LazyPython)
Carlos Cordoba
Make interactive_usage a bit more rst friendly...
r7680 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
fperez
Reorganized the directory for ipython/ to have its own dir, which is a bit...
r0 """
vivainio
%quickref
r154
Brian Granger
Massive, crazy refactoring of everything....
r2202 interactive_usage_min = """\
An enhanced console for Python.
Some of its features are:
- Readline support if the readline library is present.
- Tab completion in the local namespace.
- Logging of input, see command-line options.
- System shell escape via ! , eg !ls.
- Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
- Keeps track of locally defined variables via %who, %whos.
- Show object information with a ? eg ?x or x? (use ?? for more info).
"""
vivainio
%quickref
r154 quick_reference = r"""
IPython -- An enhanced Interactive Python - Quick Reference Card
================================================================
fperez
- Fixes for doctest support. Need more testing, esp. to be sure they don't...
r834 obj?, obj?? : Get help, or more help for object (also works as
?obj, ??obj).
?foo.*abc* : List names in 'foo' containing 'abc' in them.
%magic : Information about IPython's 'magic' % functions.
vivainio
%quickref
r154
Fernando Perez
Update interactive usage message (used by %quickref and others).
r7006 Magic functions are prefixed by % or %%, and typically take their arguments
without parentheses, quotes or even commas for convenience. Line magics take a
single % and cell magics are prefixed with two %%.
Bernardo B. Marques
remove all trailling spaces
r4872
vivainio
Change banner, %quickref
r824 Example magic function calls:
vivainio
%quickref
r154 %alias d ls -F : 'd' is now an alias for 'ls -F'
alias d ls -F : Works if 'alias' not a python name
alist = %alias : Get list of aliases to 'alist'
vivainio
Change banner, %quickref
r824 cd /usr/share : Obvious. cd -<tab> to choose from visited dirs.
%cd?? : See help AND source for magic %cd
Fernando Perez
Update interactive usage message (used by %quickref and others).
r7006 %timeit x=10 : time the 'x=10' statement with high precision.
%%timeit x=2**100
x**100 : time 'x*100' with a setup of 'x=2**100'; setup code is not
counted. This is an example of a cell magic.
vivainio
%quickref
r154
System commands:
Bernardo B. Marques
remove all trailling spaces
r4872
vivainio
%quickref
r154 !cp a.txt b/ : System command escape, calls os.system()
vivainio
corrected some quickref glitches
r203 cp a.txt b/ : after %rehashx, most system commands work without !
vivainio
%quickref
r154 cp ${f}.txt $bar : Variable expansion in magics and system commands
vivainio
corrected some quickref glitches
r203 files = !ls /usr : Capture sytem command output
vivainio
%quickref
r154 files.s, files.l, files.n: "a b c", ['a','b','c'], 'a\nb\nc'
History:
_i, _ii, _iii : Previous, next previous, next next previous input
vivainio
merge all from 0.7.3 branch to trunk
r503 _i4, _ih[2:5] : Input history line 4, lines 2-4
exec _i81 : Execute input history line #81 again
Bernardo B. Marques
remove all trailling spaces
r4872 %rep 81 : Edit input history line #81
vivainio
%quickref
r154 _, __, ___ : previous, next previous, next next previous output
_dh : Directory history
_oh : Output history
vivainio
Change banner, %quickref
r824 %hist : Command history. '%hist -g foo' search history for 'foo'
vivainio
%quickref
r154
Autocall:
Fernando Perez
Update docs about autocall and remove manual copy of cmd-line flags....
r5627 f 1,2 : f(1,2) # Off by default, enable with %autocall magic.
vivainio
corrected some quickref glitches
r203 /f 1,2 : f(1,2) (forced autoparen)
vivainio
%quickref
r154 ,f 1 2 : f("1","2")
;f 1 2 : f("1 2")
vivainio
Change banner, %quickref
r824 Remember: TAB completion works in many contexts, not just file names
or python names.
The following magic functions are currently available:
vivainio
%quickref
r154 """
Brian Granger
Massive, crazy refactoring of everything....
r2202
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008 gui_reference = """\
===============================
Fernando Perez
Fixes to guiref after more careful proofreading.
r3015 The graphical IPython console
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008 ===============================
Fernando Perez
Fixes to guiref after more careful proofreading.
r3015 This console is designed to emulate the look, feel and workflow of a terminal
environment, while adding a number of enhancements that are simply not possible
in a real terminal, such as inline syntax highlighting, true multiline editing,
inline graphics and much more.
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008
This quick reference document contains the basic information you'll need to
know to make the most efficient use of it. For the various command line
MinRK
update usage.py for 0.11...
r4186 options available at startup, type ``ipython qtconsole --help`` at the command line.
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008
Multiline editing
=================
The graphical console is capable of true multiline editing, but it also tries
to behave intuitively like a terminal when possible. If you are used to
W. Trevor King
Fix pyhton -> python typos (everywhere found by grep).
r6143 IPython's old terminal behavior, you should find the transition painless, and
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008 once you learn a few basic keybindings it will be a much more efficient
environment.
For single expressions or indented blocks, the console behaves almost like the
epatters
Pressing Enter now always executes when the input buffer has one line.
r3021 terminal IPython: single expressions are immediately evaluated, and indented
blocks are evaluated once a single blank line is entered::
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008
In [1]: print "Hello IPython!" # Enter was pressed at the end of the line
Hello IPython!
Bernardo B. Marques
remove all trailling spaces
r4872
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008 In [2]: for i in range(10):
...: print i,
Bernardo B. Marques
remove all trailling spaces
r4872 ...:
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008 0 1 2 3 4 5 6 7 8 9
If you want to enter more than one expression in a single input block
(something not possible in the terminal), you can use ``Control-Enter`` at the
end of your first line instead of ``Enter``. At that point the console goes
into 'cell mode' and even if your inputs are not indented, it will continue
accepting arbitrarily many lines until either you enter an extra blank line or
you hit ``Shift-Enter`` (the key binding that forces execution). When a
multiline cell is entered, IPython analyzes it and executes its code producing
an ``Out[n]`` prompt only for the last expression in it, while the rest of the
Fernando Perez
Fixes to guiref after more careful proofreading.
r3015 cell is executed as if it was a script. An example should clarify this::
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008
In [3]: x=1 # Hit C-Enter here
...: y=2 # from now on, regular Enter is sufficient
...: z=3
...: x**2 # This does *not* produce an Out[] value
...: x+y+z # Only the last expression does
Bernardo B. Marques
remove all trailling spaces
r4872 ...:
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008 Out[3]: 6
The behavior where an extra blank line forces execution is only active if you
are actually typing at the keyboard each line, and is meant to make it mimic
the IPython terminal behavior. If you paste a long chunk of input (for example
a long script copied form an editor or web browser), it can contain arbitrarily
Fernando Perez
Fixes to guiref after more careful proofreading.
r3015 many intermediate blank lines and they won't cause any problems. As always,
you can then make it execute by appending a blank line *at the end* or hitting
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008 ``Shift-Enter`` anywhere within the cell.
With the up arrow key, you can retrieve previous blocks of input that contain
Fernando Perez
Fixes to guiref after more careful proofreading.
r3015 multiple lines. You can move inside of a multiline cell like you would in any
text editor. When you want it executed, the simplest thing to do is to hit the
force execution key, ``Shift-Enter`` (though you can also navigate to the end
and append a blank line by using ``Enter`` twice).
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008
If you've edited a multiline cell and accidentally navigate out of it with the
up or down arrow keys, IPython will clear the cell and replace it with the
contents of the one above or below that you navigated to. If this was an
accident and you want to retrieve the cell you were editing, use the Undo
keybinding, ``Control-z``.
Key bindings
============
Fernando Perez
Fixes to guiref after more careful proofreading.
r3015 The IPython console supports most of the basic Emacs line-oriented keybindings,
in addition to some of its own.
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008
The keybinding prefixes mean:
Fernando Perez
Fixes to guiref after more careful proofreading.
r3015 - ``C``: Control
- ``S``: Shift
- ``M``: Meta (typically the Alt key)
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008
The keybindings themselves are:
Fernando Perez
Fixes to guiref after more careful proofreading.
r3015 - ``Enter``: insert new line (may cause execution, see above).
epatters
Update %guiref with a note about Ctrl-R style history searching.
r4482 - ``C-Enter``: *force* new line, *never* causes execution.
Fernando Perez
Fixes to guiref after more careful proofreading.
r3015 - ``S-Enter``: *force* execution regardless of where cursor is, no newline added.
epatters
Update %guiref with a note about Ctrl-R style history searching.
r4482 - ``Up``: step backwards through the history.
- ``Down``: step forwards through the history.
- ``S-Up``: search backwards through the history (like ``C-r`` in bash).
- ``S-Down``: search forwards through the history.
Fernando Perez
Fixes to guiref after more careful proofreading.
r3015 - ``C-c``: copy highlighted text to clipboard (prompts are automatically stripped).
- ``C-S-c``: copy highlighted text to clipboard (prompts are not stripped).
- ``C-v``: paste text from clipboard.
- ``C-z``: undo (retrieves lost text if you move out of a cell with the arrows).
- ``C-S-z``: redo.
- ``C-o``: move to 'other' area, between pager and terminal.
- ``C-l``: clear terminal.
- ``C-a``: go to beginning of line.
- ``C-e``: go to end of line.
Paul Ivanov
make Ctrl-D in qtconsole act same as in terminal
r5964 - ``C-u``: kill from cursor to the begining of the line.
Fernando Perez
Fixes to guiref after more careful proofreading.
r3015 - ``C-k``: kill from cursor to the end of the line.
- ``C-y``: yank (paste)
- ``C-p``: previous line (like up arrow)
- ``C-n``: next line (like down arrow)
- ``C-f``: forward (like right arrow)
- ``C-b``: back (like left arrow)
Paul Ivanov
make Ctrl-D in qtconsole act same as in terminal
r5964 - ``C-d``: delete next character, or exits if input is empty
Fernando Perez
Fixes to guiref after more careful proofreading.
r3015 - ``M-<``: move to the beginning of the input region.
- ``M->``: move to the end of the input region.
- ``M-d``: delete next word.
- ``M-Backspace``: delete previous word.
- ``C-.``: force a kernel restart (a confirmation dialog appears).
Fernando Perez
Add Ctrl-+/- to increase/decrease font size....
r3081 - ``C-+``: increase font size.
- ``C--``: decrease font size.
Matthias BUSSONNIER
add fullscreen support for QtConsole throught shortcut...
r4817 - ``C-M-Space``: toggle full screen. (Command-Control-Space on Mac OS X)
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008
The IPython pager
=================
IPython will show long blocks of text from many sources using a builtin pager.
You can control where this pager appears with the ``--paging`` command-line
flag:
epatters
Update guiref with correct paging options....
r3799 - ``inside`` [default]: the pager is overlaid on top of the main terminal. You
must quit the pager to get back to the terminal (similar to how a pager such
as ``less`` or ``more`` works).
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008
epatters
Update guiref with correct paging options....
r3799 - ``vsplit``: the console is made double-tall, and the pager appears on the
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008 bottom area when needed. You can view its contents while using the terminal.
epatters
Update guiref with correct paging options....
r3799 - ``hsplit``: the console is made double-wide, and the pager appears on the
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008 right area when needed. You can view its contents while using the terminal.
epatters
Update guiref with correct paging options....
r3799 - ``none``: the console never pages output.
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008 If you use the vertical or horizontal paging modes, you can navigate between
terminal and pager as follows:
- Tab key: goes from pager to terminal (but not the other way around).
- Control-o: goes from one to another always.
- Mouse: click on either.
Fernando Perez
Fixes to guiref after more careful proofreading.
r3015 In all cases, the ``q`` or ``Escape`` keys quit the pager (when used with the
focus on the pager area).
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008
Running subprocesses
====================
The graphical IPython console uses the ``pexpect`` module to run subprocesses
when you type ``!command``. This has a number of advantages (true asynchronous
output from subprocesses as well as very robust termination of rogue
Fernando Perez
Fixes to guiref after more careful proofreading.
r3015 subprocesses with ``Control-C``), as well as some limitations. The main
limitation is that you can *not* interact back with the subprocess, so anything
that invokes a pager or expects you to type input into it will block and hang
(you can kill it with ``Control-C``).
We have provided as magics ``%less`` to page files (aliased to ``%more``),
``%clear`` to clear the terminal, and ``%man`` on Linux/OSX. These cover the
most common commands you'd want to call in your subshell and that would cause
problems if invoked via ``!cmd``, but you need to be aware of this limitation.
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008
Brian Granger
Final work on display system....
r3288 Display
=======
The IPython console can now display objects in a variety of formats, including
HTML, PNG and SVG. This is accomplished using the display functions in
``IPython.core.display``::
In [4]: from IPython.core.display import display, display_html
In [5]: from IPython.core.display import display_png, display_svg
Python objects can simply be passed to these functions and the appropriate
representations will be displayed in the console as long as the objects know
how to compute those representations. The easiest way of teaching objects how
to format themselves in various representations is to define special methods
Brian Granger
Renaming the special methods of the formatters....
r3878 such as: ``_repr_html_``, ``_repr_svg_`` and ``_repr_png_``. IPython's display formatters
Brian Granger
Final work on display system....
r3288 can also be given custom formatter functions for various types::
In [6]: ip = get_ipython()
In [7]: html_formatter = ip.display_formatter.formatters['text/html']
In [8]: html_formatter.for_type(Foo, foo_to_html)
For further details, see ``IPython.core.formatters``.
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008
Inline matplotlib graphics
==========================
The IPython console is capable of displaying matplotlib figures inline, in SVG
Matthias BUSSONNIER
pylab-> matplotlib
r11782 or PNG format. If started with the ``matplotlib=inline``, then all figures are
rendered inline automatically (PNG by default). If started with ``--matplotlib``
or ``matplotlib=<your backend>``, then a GUI backend will be used, but IPython's
MinRK
update usage.py for 0.11...
r4186 ``display()`` and ``getfigs()`` functions can be used to view plots inline::
Brian Granger
Final work on display system....
r3288
In [9]: display(*getfigs()) # display all figures inline
In[10]: display(*getfigs(1,2)) # display figures 1 and 2 inline
"""
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008
Brian Granger
Massive, crazy refactoring of everything....
r2202 quick_guide = """\
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008 object? -> Details about 'object', use 'object??' for extra details.
"""
gui_note = """\
%guiref -> A brief reference about the graphical user interface.
"""
Brian Granger
Massive, crazy refactoring of everything....
r2202
Brian Granger
More work on getting rid of ipmaker.
r2203 default_banner_parts = [
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008 'Python %s\n' % (sys.version.split('\n')[0],),
'Type "copyright", "credits" or "license" for more information.\n\n',
MinRK
remove codename from banner
r11886 'IPython {version} -- An enhanced Interactive Python.\n'.format(
Matthias BUSSONNIER
add unformal Name for 1.0
r11781 version=release.version,
),
Brian Granger
Massive, crazy refactoring of everything....
r2202 quick_guide
]
Brian Granger
More work on getting rid of ipmaker.
r2203
Fernando Perez
Add %guiref to give a quick reference to the GUI console.
r3008 default_gui_banner_parts = default_banner_parts + [gui_note]
default_banner = ''.join(default_banner_parts)
default_gui_banner = ''.join(default_gui_banner_parts)
MinRK
move %guiref out of KernelMagics, into usage
r7078
# page GUI Reference, for use as a magic:
def page_guiref(arg_s=None):
"""Show a basic reference about the GUI Console."""
from IPython.core import page
page.page(gui_reference, auto_html=True)