##// END OF EJS Templates
further fixes to magic docstrings...
Paul Ivanov -
Show More
@@ -454,9 +454,7 b' Currently the magic system has the following functions:\\n"""'
454 454
455 455 1 -> active, but do not apply if there are no arguments on the line.
456 456
457 In this mode, you get:
458
459 .. sourcecode:: ipython
457 In this mode, you get::
460 458
461 459 In [1]: callable
462 460 Out[1]: <built-in function callable>
@@ -466,9 +464,7 b' Currently the magic system has the following functions:\\n"""'
466 464 Out[2]: False
467 465
468 466 2 -> Active always. Even if no arguments are present, the callable
469 object is called:
470
471 .. sourcecode:: ipython
467 object is called::
472 468
473 469 In [2]: float
474 470 ------> float()
@@ -476,9 +472,7 b' Currently the magic system has the following functions:\\n"""'
476 472
477 473 Note that even with autocall off, you can still use '/' at the start of
478 474 a line to treat the first argument on the command line as a function
479 and add parentheses to it:
480
481 .. sourcecode:: ipython
475 and add parentheses to it::
482 476
483 477 In [8]: /str 43
484 478 ------> str(43)
@@ -581,7 +575,7 b' Currently the magic system has the following functions:\\n"""'
581 575
582 576 Examples
583 577 --------
584 .. sourcecode:: ipython
578 ::
585 579
586 580 In [3]: %pdef urllib.urlopen
587 581 urllib.urlopen(url, data=None, proxies=None)
@@ -682,7 +676,9 b' Currently the magic system has the following functions:\\n"""'
682 676 search with -s or exclude them with -e (these options can be given
683 677 more than once).
684 678
685 Examples:
679 Examples
680 --------
681 ::
686 682
687 683 %psearch a* -> objects beginning with an a
688 684 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
@@ -691,11 +687,11 b' Currently the magic system has the following functions:\\n"""'
691 687 %psearch r*.e* -> objects that start with e in modules starting in r
692 688 %psearch r*.* string -> all strings in modules beginning with r
693 689
694 Case sensitive search:
690 Case sensitive search::
695 691
696 692 %psearch -c a* list all object beginning with lower case a
697 693
698 Show objects beginning with a single _:
694 Show objects beginning with a single _::
699 695
700 696 %psearch -a _* list objects beginning with a single underscore"""
701 697 try:
@@ -743,9 +739,7 b' Currently the magic system has the following functions:\\n"""'
743 739 Examples
744 740 --------
745 741
746 Define two variables and list them with who_ls:
747
748 .. sourcecode:: ipython
742 Define two variables and list them with who_ls::
749 743
750 744 In [1]: alpha = 123
751 745
@@ -788,7 +782,7 b' Currently the magic system has the following functions:\\n"""'
788 782 variables. To find the proper type names, simply use type(var) at a
789 783 command line to see how python prints type names. For example:
790 784
791 .. sourcecode:: ipython
785 ::
792 786
793 787 In [1]: type('hello')\\
794 788 Out[1]: <type 'str'>
@@ -804,9 +798,7 b' Currently the magic system has the following functions:\\n"""'
804 798 Examples
805 799 --------
806 800
807 Define two variables and list them with who:
808
809 .. sourcecode:: ipython
801 Define two variables and list them with who::
810 802
811 803 In [1]: alpha = 123
812 804
@@ -859,9 +851,7 b' Currently the magic system has the following functions:\\n"""'
859 851 Examples
860 852 --------
861 853
862 Define two variables and list them with whos:
863
864 .. sourcecode:: ipython
854 Define two variables and list them with whos::
865 855
866 856 In [1]: alpha = 123
867 857
@@ -1002,8 +992,7 b' Currently the magic system has the following functions:\\n"""'
1002 992
1003 993 Examples
1004 994 --------
1005
1006 .. sourcecode:: ipython
995 ::
1007 996
1008 997 In [6]: a = 1
1009 998
@@ -1119,16 +1108,12 b' Currently the magic system has the following functions:\\n"""'
1119 1108
1120 1109 We first fully reset the namespace so your output looks identical to
1121 1110 this example for pedagogical reasons; in practice you do not need a
1122 full reset:
1123
1124 .. sourcecode:: ipython
1111 full reset::
1125 1112
1126 1113 In [1]: %reset -f
1127 1114
1128 1115 Now, with a clean namespace we can make a few variables and use
1129 ``%reset_selective`` to only delete names that match our regexp:
1130
1131 .. sourcecode:: ipython
1116 ``%reset_selective`` to only delete names that match our regexp::
1132 1117
1133 1118 In [2]: a=1; b=2; c=3; b1m=4; b2m=5; b3m=6; b4m=7; b2s=8
1134 1119
@@ -1234,14 +1219,14 b' Currently the magic system has the following functions:\\n"""'
1234 1219 Python code.
1235 1220
1236 1221 Since this marker is always the same, filtering only the output from
1237 a log is very easy, using for example a simple awk call:
1222 a log is very easy, using for example a simple awk call::
1238 1223
1239 1224 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
1240 1225
1241 1226 -r: log 'raw' input. Normally, IPython's logs contain the processed
1242 1227 input, so that user lines are logged in their final form, converted
1243 1228 into valid Python. For example, %Exit is logged as
1244 '_ip.magic("Exit"). If the -r flag is given, all input is logged
1229 _ip.magic("Exit"). If the -r flag is given, all input is logged
1245 1230 exactly as typed, with no transformations applied.
1246 1231
1247 1232 -t: put timestamps before each input line logged (these are put in
@@ -1477,9 +1462,7 b' Currently the magic system has the following functions:\\n"""'
1477 1462 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1478 1463 contains profiler specific options as described here.
1479 1464
1480 You can read the complete documentation for the profile module with:
1481
1482 .. sourcecode:: ipython
1465 You can read the complete documentation for the profile module with::
1483 1466
1484 1467 In [1]: import profile; profile.help()
1485 1468 """
@@ -1629,9 +1612,7 b' Currently the magic system has the following functions:\\n"""'
1629 1612 must be an integer indicating how many times you want the script to
1630 1613 run. The final timing report will include total and per run results.
1631 1614
1632 For example (testing the script uniq_stable.py):
1633
1634 .. sourcecode:: ipython
1615 For example (testing the script uniq_stable.py)::
1635 1616
1636 1617 In [1]: run -t uniq_stable
1637 1618
@@ -1655,7 +1636,7 b' Currently the magic system has the following functions:\\n"""'
1655 1636
1656 1637 with a breakpoint set on line 1 of your file. You can change the line
1657 1638 number for this automatic breakpoint to be <N> by using the -bN option
1658 (where N must be an integer). For example:
1639 (where N must be an integer). For example::
1659 1640
1660 1641 %run -d -b40 myscript
1661 1642
@@ -1692,7 +1673,7 b' Currently the magic system has the following functions:\\n"""'
1692 1673 the -m option for the python interpreter. Use this option last if you
1693 1674 want to combine with other %run options. Unlike the python interpreter
1694 1675 only source modules are allowed no .pyc or .pyo files.
1695 For example:
1676 For example::
1696 1677
1697 1678 %run -m example
1698 1679
@@ -1930,9 +1911,9 b' Currently the magic system has the following functions:\\n"""'
1930 1911 Default: 3
1931 1912
1932 1913
1933 Examples:
1934
1935 .. sourcecode:: ipython
1914 Examples
1915 --------
1916 ::
1936 1917
1937 1918 In [1]: %timeit pass
1938 1919 10000000 loops, best of 3: 53.3 ns per loop
@@ -2056,7 +2037,7 b' Currently the magic system has the following functions:\\n"""'
2056 2037
2057 2038 Examples
2058 2039 --------
2059 .. sourcecode:: ipython
2040 ::
2060 2041
2061 2042 In [1]: time 2**128
2062 2043 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
@@ -2174,9 +2155,7 b' Currently the magic system has the following functions:\\n"""'
2174 2155 49: print 'x',x,'y',y
2175 2156
2176 2157 you can create a macro with lines 44 through 47 (included) and line 49
2177 called my_macro with:
2178
2179 .. sourcecode:: ipython
2158 called my_macro with::
2180 2159
2181 2160 In [55]: %macro my_macro 44-47 49
2182 2161
@@ -2531,63 +2510,50 b' Currently the magic system has the following functions:\\n"""'
2531 2510 Note that %edit is also available through the alias %ed.
2532 2511
2533 2512 This is an example of creating a simple function inside the editor and
2534 then modifying it. First, start up the editor:
2535
2536 .. sourcecode :: ipython
2513 then modifying it. First, start up the editor::
2537 2514
2538 2515 In [1]: ed
2539 2516 Editing... done. Executing edited code...
2540 Out[1]: 'def foo():n print "foo() was defined in an editing session"n'
2541
2542 We can then call the function foo():
2517 Out[1]: 'def foo():\\n print "foo() was defined in an editing
2518 session"\\n'
2543 2519
2544 .. sourcecode :: ipython
2520 We can then call the function foo()::
2545 2521
2546 2522 In [2]: foo()
2547 2523 foo() was defined in an editing session
2548 2524
2549 2525 Now we edit foo. IPython automatically loads the editor with the
2550 (temporary) file where foo() was previously defined:
2551
2552 .. sourcecode :: ipython
2526 (temporary) file where foo() was previously defined::
2553 2527
2554 2528 In [3]: ed foo
2555 2529 Editing... done. Executing edited code...
2556 2530
2557 And if we call foo() again we get the modified version:
2558
2559 .. sourcecode :: ipython
2531 And if we call foo() again we get the modified version::
2560 2532
2561 2533 In [4]: foo()
2562 2534 foo() has now been changed!
2563 2535
2564 2536 Here is an example of how to edit a code snippet successive
2565 times. First we call the editor:
2566
2567 .. sourcecode :: ipython
2537 times. First we call the editor::
2568 2538
2569 2539 In [5]: ed
2570 2540 Editing... done. Executing edited code...
2571 2541 hello
2572 Out[5]: "print 'hello'n"
2542 Out[5]: "print 'hello'\\n"
2573 2543
2574 Now we call it again with the previous output (stored in _):
2575
2576 .. sourcecode :: ipython
2544 Now we call it again with the previous output (stored in _)::
2577 2545
2578 2546 In [6]: ed _
2579 2547 Editing... done. Executing edited code...
2580 2548 hello world
2581 Out[6]: "print 'hello world'n"
2582
2583 Now we call it with the output #8 (stored in _8, also as Out[8]):
2549 Out[6]: "print 'hello world'\\n"
2584 2550
2585 .. sourcecode :: ipython
2551 Now we call it with the output #8 (stored in _8, also as Out[8])::
2586 2552
2587 2553 In [7]: ed _8
2588 2554 Editing... done. Executing edited code...
2589 2555 hello again
2590 Out[7]: "print 'hello again'n"
2556 Out[7]: "print 'hello again'\\n"
2591 2557
2592 2558
2593 2559 Changing the default editor hook:
@@ -2758,18 +2724,14 b' Defaulting color scheme to \'NoColor\'"""'
2758 2724 alias can not be executed until 'del foo' removes the Python variable.
2759 2725
2760 2726 You can use the %l specifier in an alias definition to represent the
2761 whole line when the alias is called. For example:
2762
2763 .. sourcecode:: ipython
2727 whole line when the alias is called. For example::
2764 2728
2765 2729 In [2]: alias bracket echo "Input in brackets: <%l>"
2766 2730 In [3]: bracket hello world
2767 2731 Input in brackets: <hello world>
2768 2732
2769 2733 You can also define aliases with parameters using %s specifiers (one
2770 per parameter):
2771
2772 .. sourcecode:: ipython
2734 per parameter)::
2773 2735
2774 2736 In [1]: alias parts echo first %s second %s
2775 2737 In [2]: %parts A B
@@ -2787,9 +2749,7 b' Defaulting color scheme to \'NoColor\'"""'
2787 2749 http://www.python.org/peps/pep-0215.html. This is the library used by
2788 2750 IPython for variable expansion. If you want to access a true shell
2789 2751 variable, an extra $ is necessary to prevent its expansion by
2790 IPython:
2791
2792 .. sourcecode:: ipython
2752 IPython::
2793 2753
2794 2754 In [6]: alias show echo
2795 2755 In [7]: PATH='A Python string'
@@ -2918,7 +2878,7 b' Defaulting color scheme to \'NoColor\'"""'
2918 2878
2919 2879 Examples
2920 2880 --------
2921 .. sourcecode:: ipython
2881 ::
2922 2882
2923 2883 In [9]: pwd
2924 2884 Out[9]: '/home/tsuser/sprint/ipython'
@@ -2960,7 +2920,7 b' Defaulting color scheme to \'NoColor\'"""'
2960 2920
2961 2921 Examples
2962 2922 --------
2963 .. sourcecode:: ipython
2923 ::
2964 2924
2965 2925 In [10]: cd parent/child
2966 2926 /home/tsuser/parent/child
@@ -3174,9 +3134,7 b' Defaulting color scheme to \'NoColor\'"""'
3174 3134 space-separated string. These are convenient, respectively, either
3175 3135 for sequential processing or to be passed to a shell command.
3176 3136
3177 For example:
3178
3179 .. sourcecode:: ipython
3137 For example::
3180 3138
3181 3139 # Capture into variable a
3182 3140 In [1]: sc a=ls *py
@@ -3208,9 +3166,7 b' Defaulting color scheme to \'NoColor\'"""'
3208 3166
3209 3167 Similarly, the lists returned by the -l option are also special, in
3210 3168 the sense that you can equally invoke the .s attribute on them to
3211 automatically get a whitespace-separated string from their contents:
3212
3213 .. sourcecode:: ipython
3169 automatically get a whitespace-separated string from their contents::
3214 3170
3215 3171 In [7]: sc -l b=ls *py
3216 3172
@@ -3264,11 +3220,16 b' Defaulting color scheme to \'NoColor\'"""'
3264 3220 Notes:
3265 3221
3266 3222 1) If an input line begins with '!!', then %sx is automatically
3267 invoked. That is, while:
3223 invoked. That is, while::
3224
3268 3225 !ls
3269 causes ipython to simply issue system('ls'), typing
3226
3227 causes ipython to simply issue system('ls'), typing::
3228
3270 3229 !!ls
3271 is a shorthand equivalent to:
3230
3231 is a shorthand equivalent to::
3232
3272 3233 %sx ls
3273 3234
3274 3235 2) %sx differs from %sc in that %sx automatically splits into a list,
@@ -3278,6 +3239,7 b' Defaulting color scheme to \'NoColor\'"""'
3278 3239 typing.
3279 3240
3280 3241 3) Just like %sc -l, this is a list with special attributes:
3242 ::
3281 3243
3282 3244 .l (or .list) : value as list.
3283 3245 .n (or .nlstr): value as newline-separated string.
@@ -3299,8 +3261,10 b' Defaulting color scheme to \'NoColor\'"""'
3299 3261 %bookmark -d <name> - remove bookmark
3300 3262 %bookmark -r - remove all bookmarks
3301 3263
3302 You can later on access a bookmarked folder with:
3264 You can later on access a bookmarked folder with::
3265
3303 3266 %cd -b <name>
3267
3304 3268 or simply '%cd <name>' if there is no directory called <name> AND
3305 3269 there is such a bookmark defined.
3306 3270
@@ -3548,9 +3512,7 b' Defaulting color scheme to \'NoColor\'"""'
3548 3512 pylab and mlab, as well as all names from numpy and pylab.
3549 3513
3550 3514 If you are using the inline matplotlib backend for embedded figures,
3551 you can adjust its behavior via the %config magic:
3552
3553 .. sourcecode:: ipython
3515 you can adjust its behavior via the %config magic::
3554 3516
3555 3517 # enable SVG figures, necessary for SVG+XHTML export in the qtconsole
3556 3518 In [1]: %config InlineBackend.figure_format = 'svg'
@@ -3570,9 +3532,7 b' Defaulting color scheme to \'NoColor\'"""'
3570 3532
3571 3533 Examples
3572 3534 --------
3573 In this case, where the MPL default is TkAgg:
3574
3575 .. sourcecode:: ipython
3535 In this case, where the MPL default is TkAgg::
3576 3536
3577 3537 In [2]: %pylab
3578 3538
@@ -3580,9 +3540,7 b' Defaulting color scheme to \'NoColor\'"""'
3580 3540 Backend in use: TkAgg
3581 3541 For more information, type 'help(pylab)'.
3582 3542
3583 But you can explicitly request a different backend:
3584
3585 .. sourcecode:: ipython
3543 But you can explicitly request a different backend::
3586 3544
3587 3545 In [3]: %pylab qt
3588 3546
@@ -3621,7 +3579,7 b' Defaulting color scheme to \'NoColor\'"""'
3621 3579
3622 3580 Examples
3623 3581 --------
3624 .. sourcecode:: ipython
3582 ::
3625 3583
3626 3584 In [1]: from math import pi
3627 3585
@@ -3739,9 +3697,7 b' Defaulting color scheme to \'NoColor\'"""'
3739 3697 Examples
3740 3698 --------
3741 3699
3742 To see what classes are available for config, pass no arguments:
3743
3744 .. sourcecode:: ipython
3700 To see what classes are available for config, pass no arguments::
3745 3701
3746 3702 In [1]: %config
3747 3703 Available objects for config:
@@ -3753,9 +3709,8 b' Defaulting color scheme to \'NoColor\'"""'
3753 3709 PromptManager
3754 3710 DisplayFormatter
3755 3711
3756 To view what is configurable on a given class, just pass the class name:
3757
3758 .. sourcecode:: ipython
3712 To view what is configurable on a given class, just pass the class
3713 name::
3759 3714
3760 3715 In [2]: %config IPCompleter
3761 3716 IPCompleter options
@@ -3779,15 +3734,11 b' Defaulting color scheme to \'NoColor\'"""'
3779 3734 This will enable completion on elements of lists, results of function calls,
3780 3735 etc., but can be unsafe because the code is actually evaluated on TAB.
3781 3736
3782 but the real use is in setting values:
3783
3784 .. sourcecode:: ipython
3737 but the real use is in setting values::
3785 3738
3786 3739 In [3]: %config IPCompleter.greedy = True
3787 3740
3788 and these values are read from the user_ns if they are variables:
3789
3790 .. sourcecode:: ipython
3741 and these values are read from the user_ns if they are variables::
3791 3742
3792 3743 In [4]: feeling_greedy=False
3793 3744
General Comments 0
You need to be logged in to leave comments. Login now