/ lib / IPython / core / usage.pyc
usage.pyc
  1  o

  2  .��c�4�@sZdZddlZddlmZdZdZdZdZdej�	d	�dd
  3  dj
  4  ejd�gZd
�e�Z
dS)z5Usage information for the main IPython applications.
  5  �N)�releasea}=========
  6   IPython
  7  =========
  8  
  9  Tools for Interactive Computing in Python
 10  =========================================
 11  
 12      A Python shell with automatic history (input and output), dynamic object
 13      introspection, easier configuration, command completion, access to the
 14      system shell and more.  IPython can also be embedded in running programs.
 15  
 16  
 17  Usage
 18  
 19      ipython [subcommand] [options] [-c cmd | -m mod | file] [--] [arg] ...
 20  
 21      If invoked with no options, it executes the file and exits, passing the
 22      remaining arguments to the script, just as if you had specified the same
 23      command with python. You may need to specify `--` before args to be passed
 24      to the script, to prevent IPython from attempting to parse them. If you
 25      specify the option `-i` before the filename, it will enter an interactive
 26      IPython session after running the script, rather than exiting. Files ending
 27      in .py will be treated as normal Python, but files ending in .ipy can
 28      contain special IPython syntax (magic commands, shell expansions, etc.).
 29  
 30      Almost all configuration in IPython is available via the command-line. Do
 31      `ipython --help-all` to see all available options.  For persistent
 32      configuration, look into your `ipython_config.py` configuration file for
 33      details.
 34  
 35      This file is typically installed in the `IPYTHONDIR` directory, and there
 36      is a separate configuration directory for each profile. The default profile
 37      directory will be located in $IPYTHONDIR/profile_default. IPYTHONDIR
 38      defaults to to `$HOME/.ipython`.  For Windows users, $HOME resolves to
 39      C:\Users\YourUserName in most instances.
 40  
 41      To initialize a profile with the default configuration file, do::
 42  
 43        $> ipython profile create
 44  
 45      and start editing `IPYTHONDIR/profile_default/ipython_config.py`
 46  
 47      In IPython's documentation, we will refer to this directory as
 48      `IPYTHONDIR`, you can change its default location by creating an
 49      environment variable with this name and setting it to the desired path.
 50  
 51      For more information, see the manual available in HTML and PDF in your
 52      installation, or online at https://ipython.org/documentation.html.
 53  a�
 54  IPython -- An enhanced Interactive Python
 55  =========================================
 56  
 57  IPython offers a fully compatible replacement for the standard Python
 58  interpreter, with convenient shell features, special commands, command
 59  history mechanism and output results caching.
 60  
 61  At your system command line, type 'ipython -h' to see the command line
 62  options available. This document only describes interactive features.
 63  
 64  GETTING HELP
 65  ------------
 66  
 67  Within IPython you have various way to access help:
 68  
 69    ?         -> Introduction and overview of IPython's features (this screen).
 70    object?   -> Details about 'object'.
 71    object??  -> More detailed, verbose information about 'object'.
 72    %quickref -> Quick reference of all IPython specific syntax and magics.
 73    help      -> Access Python's own help system.
 74  
 75  If you are in terminal IPython you can quit this screen by pressing `q`.
 76  
 77  
 78  MAIN FEATURES
 79  -------------
 80  
 81  * Access to the standard Python help with object docstrings and the Python
 82    manuals. Simply type 'help' (no quotes) to invoke it.
 83  
 84  * Magic commands: type %magic for information on the magic subsystem.
 85  
 86  * System command aliases, via the %alias command or the configuration file(s).
 87  
 88  * Dynamic object information:
 89  
 90    Typing ?word or word? prints detailed information about an object. Certain
 91    long strings (code, etc.) get snipped in the center for brevity.
 92  
 93    Typing ??word or word?? gives access to the full information without
 94    snipping long strings. Strings that are longer than the screen are printed
 95    through the less pager.
 96  
 97    The ?/?? system gives access to the full source code for any object (if
 98    available), shows function prototypes and other useful information.
 99  
100    If you just want to see an object's docstring, type '%pdoc object' (without
101    quotes, and without % if you have automagic on).
102  
103  * Tab completion in the local namespace:
104  
105    At any time, hitting tab will complete any available python commands or
106    variable names, and show you a list of the possible completions if there's
107    no unambiguous one. It will also complete filenames in the current directory.
108  
109  * Search previous command history in multiple ways:
110  
111    - Start typing, and then use arrow keys up/down or (Ctrl-p/Ctrl-n) to search
112      through the history items that match what you've typed so far.
113  
114    - Hit Ctrl-r: opens a search prompt. Begin typing and the system searches
115      your history for lines that match what you've typed so far, completing as
116      much as it can.
117  
118    - %hist: search history by index.
119  
120  * Persistent command history across sessions.
121  
122  * Logging of input with the ability to save and restore a working session.
123  
124  * System shell with !. Typing !ls will run 'ls' in the current directory.
125  
126  * The reload command does a 'deep' reload of a module: changes made to the
127    module since you imported will actually be available without having to exit.
128  
129  * Verbose and colored exception traceback printouts. See the magic xmode and
130    xcolor functions for details (just type %magic).
131  
132  * Input caching system:
133  
134    IPython offers numbered prompts (In/Out) with input and output caching. All
135    input is saved and can be retrieved as variables (besides the usual arrow
136    key recall).
137  
138    The following GLOBAL variables always exist (so don't overwrite them!):
139    _i: stores previous input.
140    _ii: next previous.
141    _iii: next-next previous.
142    _ih : a list of all input _ih[n] is the input from line n.
143  
144    Additionally, global variables named _i<n> are dynamically created (<n>
145    being the prompt counter), such that _i<n> == _ih[<n>]
146  
147    For example, what you typed at prompt 14 is available as _i14 and _ih[14].
148  
149    You can create macros which contain multiple input lines from this history,
150    for later re-execution, with the %macro function.
151  
152    The history function %hist allows you to see any part of your input history
153    by printing a range of the _i variables. Note that inputs which contain
154    magic functions (%) appear in the history with a prepended comment. This is
155    because they aren't really valid Python code, so you can't exec them.
156  
157  * Output caching system:
158  
159    For output that is returned from actions, a system similar to the input
160    cache exists but using _ instead of _i. Only actions that produce a result
161    (NOT assignments, for example) are cached. If you are familiar with
162    Mathematica, IPython's _ variables behave exactly like Mathematica's %
163    variables.
164  
165    The following GLOBAL variables always exist (so don't overwrite them!):
166    _ (one underscore): previous output.
167    __ (two underscores): next previous.
168    ___ (three underscores): next-next previous.
169  
170    Global variables named _<n> are dynamically created (<n> being the prompt
171    counter), such that the result of output <n> is always available as _<n>.
172  
173    Finally, a global dictionary named _oh exists with entries for all lines
174    which generated output.
175  
176  * Directory history:
177  
178    Your history of visited directories is kept in the global list _dh, and the
179    magic %cd command can be used to go to any entry in that list.
180  
181  * Auto-parentheses and auto-quotes (adapted from Nathan Gray's LazyPython)
182  
183    1. Auto-parentheses
184          
185       Callable objects (i.e. functions, methods, etc) can be invoked like
186       this (notice the commas between the arguments)::
187         
188           In [1]: callable_ob arg1, arg2, arg3
189         
190       and the input will be translated to this::
191         
192           callable_ob(arg1, arg2, arg3)
193         
194       This feature is off by default (in rare cases it can produce
195       undesirable side-effects), but you can activate it at the command-line
196       by starting IPython with `--autocall 1`, set it permanently in your
197       configuration file, or turn on at runtime with `%autocall 1`.
198  
199       You can force auto-parentheses by using '/' as the first character
200       of a line.  For example::
201         
202            In [1]: /globals             # becomes 'globals()'
203         
204       Note that the '/' MUST be the first character on the line!  This
205       won't work::
206         
207            In [2]: print /globals    # syntax error
208  
209       In most cases the automatic algorithm should work, so you should
210       rarely need to explicitly invoke /. One notable exception is if you
211       are trying to call a function with a list of tuples as arguments (the
212       parenthesis will confuse IPython)::
213         
214            In [1]: zip (1,2,3),(4,5,6)  # won't work
215         
216       but this will work::
217         
218            In [2]: /zip (1,2,3),(4,5,6)
219            ------> zip ((1,2,3),(4,5,6))
220            Out[2]= [(1, 4), (2, 5), (3, 6)]
221  
222       IPython tells you that it has altered your command line by
223       displaying the new command line preceded by -->.  e.g.::
224         
225            In [18]: callable list
226            -------> callable (list)
227  
228    2. Auto-Quoting
229      
230       You can force auto-quoting of a function's arguments by using ',' as
231       the first character of a line.  For example::
232         
233            In [1]: ,my_function /home/me   # becomes my_function("/home/me")
234  
235       If you use ';' instead, the whole argument is quoted as a single
236       string (while ',' splits on whitespace)::
237         
238            In [2]: ,my_function a b c   # becomes my_function("a","b","c")
239            In [3]: ;my_function a b c   # becomes my_function("a b c")
240  
241       Note that the ',' MUST be the first character on the line!  This
242       won't work::
243         
244            In [4]: x = ,my_function /home/me    # syntax error
245  azAn enhanced console for Python.
246  Some of its features are:
247  - Tab completion in the local namespace.
248  - Logging of input, see command-line options.
249  - System shell escape via ! , eg !ls.
250  - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
251  - Keeps track of locally defined variables via %who, %whos.
252  - Show object information with a ? eg ?x or x? (use ?? for more info).
253  ay
254  
255  IPython -- An enhanced Interactive Python - Quick Reference Card
256  ================================================================
257  
258  obj?, obj??      : Get help, or more help for object (also works as
259                     ?obj, ??obj).
260  ?foo.*abc*       : List names in 'foo' containing 'abc' in them.
261  %magic           : Information about IPython's 'magic' % functions.
262  
263  Magic functions are prefixed by % or %%, and typically take their arguments
264  without parentheses, quotes or even commas for convenience.  Line magics take a
265  single % and cell magics are prefixed with two %%.
266  
267  Example magic function calls:
268  
269  %alias d ls -F   : 'd' is now an alias for 'ls -F'
270  alias d ls -F    : Works if 'alias' not a python name
271  alist = %alias   : Get list of aliases to 'alist'
272  cd /usr/share    : Obvious. cd -<tab> to choose from visited dirs.
273  %cd??            : See help AND source for magic %cd
274  %timeit x=10     : time the 'x=10' statement with high precision.
275  %%timeit x=2**100
276  x**100           : time 'x**100' with a setup of 'x=2**100'; setup code is not
277                     counted.  This is an example of a cell magic.
278  
279  System commands:
280  
281  !cp a.txt b/     : System command escape, calls os.system()
282  cp a.txt b/      : after %rehashx, most system commands work without !
283  cp ${f}.txt $bar : Variable expansion in magics and system commands
284  files = !ls /usr : Capture system command output
285  files.s, files.l, files.n: "a b c", ['a','b','c'], 'a\nb\nc'
286  
287  History:
288  
289  _i, _ii, _iii    : Previous, next previous, next next previous input
290  _i4, _ih[2:5]    : Input history line 4, lines 2-4
291  exec(_i81)       : Execute input history line #81 again
292  %rep 81          : Edit input history line #81
293  _, __, ___       : previous, next previous, next next previous output
294  _dh              : Directory history
295  _oh              : Output history
296  %hist            : Command history of current session.
297  %hist -g foo     : Search command history of (almost) all sessions for 'foo'.
298  %hist -g         : Command history of (almost) all sessions.
299  %hist 1/2-8      : Command history containing lines 2-8 of session 1.
300  %hist 1/ ~2/     : Command history of session 1 and 2 sessions before current.
301  %hist ~8/1-~6/5  : Command history from line 1 of 8 sessions ago to
302                     line 5 of 6 sessions ago.
303  %edit 0/         : Open editor to execute code with history of current session.
304  
305  Autocall:
306  
307  f 1,2            : f(1,2)  # Off by default, enable with %autocall magic.
308  /f 1,2           : f(1,2) (forced autoparen)
309  ,f 1 2           : f("1","2")
310  ;f 1 2           : f("1 2")
311  
312  Remember: TAB completion works in many contexts, not just file names
313  or python names.
314  
315  The following magic functions are currently available:
316  
317  z
318  Python %s
319  �
320  z>Type 'copyright', 'credits' or 'license' for more information
321  zHIPython {version} -- An enhanced Interactive Python. Type '?' for help.
322  )�version�)�__doc__�sys�IPython.corer�cl_usage�interactive_usage�interactive_usage_min�quick_referencer�split�format�default_banner_parts�join�default_banner�rr��C:\Users\Jacks.GUTTSPC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\IPython\core\usage.py�<module>s
323  3CA�