Show More
@@ -186,15 +186,15 b' python-profiler package from non-free.""")' | |||||
186 | def extract_input_lines(self, range_str, raw=False): |
|
186 | def extract_input_lines(self, range_str, raw=False): | |
187 | """Return as a string a set of input history slices. |
|
187 | """Return as a string a set of input history slices. | |
188 |
|
188 | |||
189 |
|
|
189 | Parameters | |
190 |
|
190 | ---------- | ||
191 | - range_str: the set of slices is given as a string, like |
|
191 | range_str : string | |
192 | "~5/6-~4/2 4:8 9", since this function is for use by magic functions |
|
192 | The set of slices is given as a string, like "~5/6-~4/2 4:8 9", | |
193 | which get their arguments as strings. The number before the / is the |
|
193 | since this function is for use by magic functions which get their | |
194 | session number: ~n goes n back from the current session. |
|
194 | arguments as strings. The number before the / is the session | |
195 |
|
195 | number: ~n goes n back from the current session. | ||
196 | Optional inputs: |
|
|||
197 |
|
196 | |||
|
197 | Optional Parameters: | |||
198 | - raw(False): by default, the processed input is used. If this is |
|
198 | - raw(False): by default, the processed input is used. If this is | |
199 | true, the raw input history is used instead. |
|
199 | true, the raw input history is used instead. | |
200 |
|
200 | |||
@@ -456,27 +456,33 b' Currently the magic system has the following functions:\\n"""' | |||||
456 |
|
456 | |||
457 | In this mode, you get: |
|
457 | In this mode, you get: | |
458 |
|
458 | |||
459 | In [1]: callable |
|
459 | .. sourcecode:: ipython | |
460 | Out[1]: <built-in function callable> |
|
460 | ||
|
461 | In [1]: callable | |||
|
462 | Out[1]: <built-in function callable> | |||
461 |
|
463 | |||
462 | In [2]: callable 'hello' |
|
464 | In [2]: callable 'hello' | |
463 | ------> callable('hello') |
|
465 | ------> callable('hello') | |
464 | Out[2]: False |
|
466 | Out[2]: False | |
465 |
|
467 | |||
466 | 2 -> Active always. Even if no arguments are present, the callable |
|
468 | 2 -> Active always. Even if no arguments are present, the callable | |
467 | object is called: |
|
469 | object is called: | |
468 |
|
470 | |||
469 | In [2]: float |
|
471 | .. sourcecode:: ipython | |
470 | ------> float() |
|
472 | ||
471 |
|
|
473 | In [2]: float | |
|
474 | ------> float() | |||
|
475 | Out[2]: 0.0 | |||
472 |
|
476 | |||
473 | Note that even with autocall off, you can still use '/' at the start of |
|
477 | Note that even with autocall off, you can still use '/' at the start of | |
474 | a line to treat the first argument on the command line as a function |
|
478 | a line to treat the first argument on the command line as a function | |
475 | and add parentheses to it: |
|
479 | and add parentheses to it: | |
476 |
|
480 | |||
477 | In [8]: /str 43 |
|
481 | .. sourcecode:: ipython | |
478 | ------> str(43) |
|
482 | ||
479 |
|
|
483 | In [8]: /str 43 | |
|
484 | ------> str(43) | |||
|
485 | Out[8]: '43' | |||
480 |
|
486 | |||
481 | # all-random (note for auto-testing) |
|
487 | # all-random (note for auto-testing) | |
482 | """ |
|
488 | """ | |
@@ -575,7 +581,7 b' Currently the magic system has the following functions:\\n"""' | |||||
575 |
|
581 | |||
576 | Examples |
|
582 | Examples | |
577 | -------- |
|
583 | -------- | |
578 | :: |
|
584 | .. sourcecode:: ipython | |
579 |
|
585 | |||
580 | In [3]: %pdef urllib.urlopen |
|
586 | In [3]: %pdef urllib.urlopen | |
581 | urllib.urlopen(url, data=None, proxies=None) |
|
587 | urllib.urlopen(url, data=None, proxies=None) | |
@@ -737,7 +743,9 b' Currently the magic system has the following functions:\\n"""' | |||||
737 | Examples |
|
743 | Examples | |
738 | -------- |
|
744 | -------- | |
739 |
|
745 | |||
740 |
Define two variables and list them with who_ls: |
|
746 | Define two variables and list them with who_ls: | |
|
747 | ||||
|
748 | .. sourcecode:: ipython | |||
741 |
|
749 | |||
742 | In [1]: alpha = 123 |
|
750 | In [1]: alpha = 123 | |
743 |
|
751 | |||
@@ -772,7 +780,7 b' Currently the magic system has the following functions:\\n"""' | |||||
772 | """Print all interactive variables, with some minimal formatting. |
|
780 | """Print all interactive variables, with some minimal formatting. | |
773 |
|
781 | |||
774 | If any arguments are given, only variables whose type matches one of |
|
782 | If any arguments are given, only variables whose type matches one of | |
775 | these are printed. For example: |
|
783 | these are printed. For example:: | |
776 |
|
784 | |||
777 | %who function str |
|
785 | %who function str | |
778 |
|
786 | |||
@@ -780,12 +788,14 b' Currently the magic system has the following functions:\\n"""' | |||||
780 | variables. To find the proper type names, simply use type(var) at a |
|
788 | variables. To find the proper type names, simply use type(var) at a | |
781 | command line to see how python prints type names. For example: |
|
789 | command line to see how python prints type names. For example: | |
782 |
|
790 | |||
|
791 | .. sourcecode:: ipython | |||
|
792 | ||||
783 | In [1]: type('hello')\\ |
|
793 | In [1]: type('hello')\\ | |
784 | Out[1]: <type 'str'> |
|
794 | Out[1]: <type 'str'> | |
785 |
|
795 | |||
786 | indicates that the type name for strings is 'str'. |
|
796 | indicates that the type name for strings is 'str'. | |
787 |
|
797 | |||
788 | %who always excludes executed names loaded through your configuration |
|
798 | ``%who`` always excludes executed names loaded through your configuration | |
789 | file and things which are internal to IPython. |
|
799 | file and things which are internal to IPython. | |
790 |
|
800 | |||
791 | This is deliberate, as typically you may load many modules and the |
|
801 | This is deliberate, as typically you may load many modules and the | |
@@ -794,7 +804,9 b' Currently the magic system has the following functions:\\n"""' | |||||
794 | Examples |
|
804 | Examples | |
795 | -------- |
|
805 | -------- | |
796 |
|
806 | |||
797 |
Define two variables and list them with who: |
|
807 | Define two variables and list them with who: | |
|
808 | ||||
|
809 | .. sourcecode:: ipython | |||
798 |
|
810 | |||
799 | In [1]: alpha = 123 |
|
811 | In [1]: alpha = 123 | |
800 |
|
812 | |||
@@ -847,7 +859,9 b' Currently the magic system has the following functions:\\n"""' | |||||
847 | Examples |
|
859 | Examples | |
848 | -------- |
|
860 | -------- | |
849 |
|
861 | |||
850 |
Define two variables and list them with whos: |
|
862 | Define two variables and list them with whos: | |
|
863 | ||||
|
864 | .. sourcecode:: ipython | |||
851 |
|
865 | |||
852 | In [1]: alpha = 123 |
|
866 | In [1]: alpha = 123 | |
853 |
|
867 | |||
@@ -984,29 +998,32 b' Currently the magic system has the following functions:\\n"""' | |||||
984 |
|
998 | |||
985 | See Also |
|
999 | See Also | |
986 | -------- |
|
1000 | -------- | |
987 | magic_reset_selective |
|
1001 | magic_reset_selective : invoked as ``%reset_selective`` | |
988 |
|
1002 | |||
989 | Examples |
|
1003 | Examples | |
990 | -------- |
|
1004 | -------- | |
991 | In [6]: a = 1 |
|
|||
992 |
|
1005 | |||
993 | In [7]: a |
|
1006 | .. sourcecode:: ipython | |
994 | Out[7]: 1 |
|
1007 | ||
|
1008 | In [6]: a = 1 | |||
|
1009 | ||||
|
1010 | In [7]: a | |||
|
1011 | Out[7]: 1 | |||
995 |
|
1012 | |||
996 | In [8]: 'a' in _ip.user_ns |
|
1013 | In [8]: 'a' in _ip.user_ns | |
997 | Out[8]: True |
|
1014 | Out[8]: True | |
998 |
|
1015 | |||
999 | In [9]: %reset -f |
|
1016 | In [9]: %reset -f | |
1000 |
|
1017 | |||
1001 | In [1]: 'a' in _ip.user_ns |
|
1018 | In [1]: 'a' in _ip.user_ns | |
1002 | Out[1]: False |
|
1019 | Out[1]: False | |
1003 |
|
1020 | |||
1004 | In [2]: %reset -f in |
|
1021 | In [2]: %reset -f in | |
1005 | Flushing input history |
|
1022 | Flushing input history | |
1006 |
|
1023 | |||
1007 |
In [3]: %reset -f dhist in |
|
1024 | In [3]: %reset -f dhist in | |
1008 | Flushing directory history |
|
1025 | Flushing directory history | |
1009 | Flushing input history |
|
1026 | Flushing input history | |
1010 |
|
1027 | |||
1011 | Notes |
|
1028 | Notes | |
1012 | ----- |
|
1029 | ----- | |
@@ -1095,44 +1112,48 b' Currently the magic system has the following functions:\\n"""' | |||||
1095 |
|
1112 | |||
1096 | See Also |
|
1113 | See Also | |
1097 | -------- |
|
1114 | -------- | |
1098 | magic_reset |
|
1115 | magic_reset : invoked as ``%reset`` | |
1099 |
|
1116 | |||
1100 | Examples |
|
1117 | Examples | |
1101 | -------- |
|
1118 | -------- | |
1102 |
|
1119 | |||
1103 | We first fully reset the namespace so your output looks identical to |
|
1120 | We first fully reset the namespace so your output looks identical to | |
1104 | this example for pedagogical reasons; in practice you do not need a |
|
1121 | this example for pedagogical reasons; in practice you do not need a | |
1105 |
full reset |
|
1122 | full reset: | |
1106 |
|
1123 | |||
1107 | In [1]: %reset -f |
|
1124 | .. sourcecode:: ipython | |
|
1125 | ||||
|
1126 | In [1]: %reset -f | |||
1108 |
|
1127 | |||
1109 | Now, with a clean namespace we can make a few variables and use |
|
1128 | Now, with a clean namespace we can make a few variables and use | |
1110 | %reset_selective to only delete names that match our regexp: |
|
1129 | ``%reset_selective`` to only delete names that match our regexp: | |
|
1130 | ||||
|
1131 | .. sourcecode:: ipython | |||
1111 |
|
1132 | |||
1112 | In [2]: a=1; b=2; c=3; b1m=4; b2m=5; b3m=6; b4m=7; b2s=8 |
|
1133 | In [2]: a=1; b=2; c=3; b1m=4; b2m=5; b3m=6; b4m=7; b2s=8 | |
1113 |
|
1134 | |||
1114 | In [3]: who_ls |
|
1135 | In [3]: who_ls | |
1115 | Out[3]: ['a', 'b', 'b1m', 'b2m', 'b2s', 'b3m', 'b4m', 'c'] |
|
1136 | Out[3]: ['a', 'b', 'b1m', 'b2m', 'b2s', 'b3m', 'b4m', 'c'] | |
1116 |
|
1137 | |||
1117 | In [4]: %reset_selective -f b[2-3]m |
|
1138 | In [4]: %reset_selective -f b[2-3]m | |
1118 |
|
1139 | |||
1119 | In [5]: who_ls |
|
1140 | In [5]: who_ls | |
1120 | Out[5]: ['a', 'b', 'b1m', 'b2s', 'b4m', 'c'] |
|
1141 | Out[5]: ['a', 'b', 'b1m', 'b2s', 'b4m', 'c'] | |
1121 |
|
1142 | |||
1122 | In [6]: %reset_selective -f d |
|
1143 | In [6]: %reset_selective -f d | |
1123 |
|
1144 | |||
1124 | In [7]: who_ls |
|
1145 | In [7]: who_ls | |
1125 | Out[7]: ['a', 'b', 'b1m', 'b2s', 'b4m', 'c'] |
|
1146 | Out[7]: ['a', 'b', 'b1m', 'b2s', 'b4m', 'c'] | |
1126 |
|
1147 | |||
1127 | In [8]: %reset_selective -f c |
|
1148 | In [8]: %reset_selective -f c | |
1128 |
|
1149 | |||
1129 | In [9]: who_ls |
|
1150 | In [9]: who_ls | |
1130 | Out[9]: ['a', 'b', 'b1m', 'b2s', 'b4m'] |
|
1151 | Out[9]: ['a', 'b', 'b1m', 'b2s', 'b4m'] | |
1131 |
|
1152 | |||
1132 | In [10]: %reset_selective -f b |
|
1153 | In [10]: %reset_selective -f b | |
1133 |
|
1154 | |||
1134 | In [11]: who_ls |
|
1155 | In [11]: who_ls | |
1135 | Out[11]: ['a'] |
|
1156 | Out[11]: ['a'] | |
1136 |
|
1157 | |||
1137 | Notes |
|
1158 | Notes | |
1138 | ----- |
|
1159 | ----- | |
@@ -1456,7 +1477,9 b' Currently the magic system has the following functions:\\n"""' | |||||
1456 | '%run -p [prof_opts] filename.py [args to program]' where prof_opts |
|
1477 | '%run -p [prof_opts] filename.py [args to program]' where prof_opts | |
1457 | contains profiler specific options as described here. |
|
1478 | contains profiler specific options as described here. | |
1458 |
|
1479 | |||
1459 |
You can read the complete documentation for the profile module with: |
|
1480 | You can read the complete documentation for the profile module with: | |
|
1481 | ||||
|
1482 | .. sourcecode:: ipython | |||
1460 |
|
1483 | |||
1461 | In [1]: import profile; profile.help() |
|
1484 | In [1]: import profile; profile.help() | |
1462 | """ |
|
1485 | """ | |
@@ -1608,6 +1631,8 b' Currently the magic system has the following functions:\\n"""' | |||||
1608 |
|
1631 | |||
1609 | For example (testing the script uniq_stable.py): |
|
1632 | For example (testing the script uniq_stable.py): | |
1610 |
|
1633 | |||
|
1634 | .. sourcecode:: ipython | |||
|
1635 | ||||
1611 | In [1]: run -t uniq_stable |
|
1636 | In [1]: run -t uniq_stable | |
1612 |
|
1637 | |||
1613 | IPython CPU timings (estimated):\\ |
|
1638 | IPython CPU timings (estimated):\\ | |
@@ -1907,6 +1932,8 b' Currently the magic system has the following functions:\\n"""' | |||||
1907 |
|
1932 | |||
1908 | Examples: |
|
1933 | Examples: | |
1909 |
|
1934 | |||
|
1935 | .. sourcecode:: ipython | |||
|
1936 | ||||
1910 | In [1]: %timeit pass |
|
1937 | In [1]: %timeit pass | |
1911 | 10000000 loops, best of 3: 53.3 ns per loop |
|
1938 | 10000000 loops, best of 3: 53.3 ns per loop | |
1912 |
|
1939 | |||
@@ -2027,7 +2054,9 b' Currently the magic system has the following functions:\\n"""' | |||||
2027 | 2.3, the timeit module offers more control and sophistication, so this |
|
2054 | 2.3, the timeit module offers more control and sophistication, so this | |
2028 | could be rewritten to use it (patches welcome). |
|
2055 | could be rewritten to use it (patches welcome). | |
2029 |
|
2056 | |||
2030 |
|
|
2057 | Examples | |
|
2058 | -------- | |||
|
2059 | .. sourcecode:: ipython | |||
2031 |
|
2060 | |||
2032 | In [1]: time 2**128 |
|
2061 | In [1]: time 2**128 | |
2033 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s |
|
2062 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s | |
@@ -2135,7 +2164,7 b' Currently the magic system has the following functions:\\n"""' | |||||
2135 | Note: as a 'hidden' feature, you can also use traditional python slice |
|
2164 | Note: as a 'hidden' feature, you can also use traditional python slice | |
2136 | notation, where N:M means numbers N through M-1. |
|
2165 | notation, where N:M means numbers N through M-1. | |
2137 |
|
2166 | |||
2138 | For example, if your history contains (%hist prints it): |
|
2167 | For example, if your history contains (%hist prints it):: | |
2139 |
|
2168 | |||
2140 | 44: x=1 |
|
2169 | 44: x=1 | |
2141 | 45: y=3 |
|
2170 | 45: y=3 | |
@@ -2147,6 +2176,8 b' Currently the magic system has the following functions:\\n"""' | |||||
2147 | you can create a macro with lines 44 through 47 (included) and line 49 |
|
2176 | you can create a macro with lines 44 through 47 (included) and line 49 | |
2148 | called my_macro with: |
|
2177 | called my_macro with: | |
2149 |
|
2178 | |||
|
2179 | .. sourcecode:: ipython | |||
|
2180 | ||||
2150 | In [55]: %macro my_macro 44-47 49 |
|
2181 | In [55]: %macro my_macro 44-47 49 | |
2151 |
|
2182 | |||
2152 | Now, typing `my_macro` (without quotes) will re-execute all this code |
|
2183 | Now, typing `my_macro` (without quotes) will re-execute all this code | |
@@ -2160,9 +2191,9 b' Currently the magic system has the following functions:\\n"""' | |||||
2160 | but IPython's display system checks for macros and executes them as |
|
2191 | but IPython's display system checks for macros and executes them as | |
2161 | code instead of printing them when you type their name. |
|
2192 | code instead of printing them when you type their name. | |
2162 |
|
2193 | |||
2163 | You can view a macro's contents by explicitly printing it with: |
|
2194 | You can view a macro's contents by explicitly printing it with:: | |
2164 |
|
2195 | |||
2165 |
|
|
2196 | print macro_name | |
2166 |
|
2197 | |||
2167 | """ |
|
2198 | """ | |
2168 | opts,args = self.parse_options(parameter_s,'r',mode='list') |
|
2199 | opts,args = self.parse_options(parameter_s,'r',mode='list') | |
@@ -2502,47 +2533,61 b' Currently the magic system has the following functions:\\n"""' | |||||
2502 | This is an example of creating a simple function inside the editor and |
|
2533 | This is an example of creating a simple function inside the editor and | |
2503 | then modifying it. First, start up the editor: |
|
2534 | then modifying it. First, start up the editor: | |
2504 |
|
2535 | |||
2505 | In [1]: ed |
|
2536 | .. sourcecode :: ipython | |
2506 | Editing... done. Executing edited code... |
|
2537 | ||
2507 | Out[1]: 'def foo():n print "foo() was defined in an editing session"n' |
|
2538 | In [1]: ed | |
|
2539 | Editing... done. Executing edited code... | |||
|
2540 | Out[1]: 'def foo():n print "foo() was defined in an editing session"n' | |||
2508 |
|
2541 | |||
2509 | We can then call the function foo(): |
|
2542 | We can then call the function foo(): | |
2510 |
|
2543 | |||
2511 | In [2]: foo() |
|
2544 | .. sourcecode :: ipython | |
2512 | foo() was defined in an editing session |
|
2545 | ||
|
2546 | In [2]: foo() | |||
|
2547 | foo() was defined in an editing session | |||
2513 |
|
2548 | |||
2514 | Now we edit foo. IPython automatically loads the editor with the |
|
2549 | Now we edit foo. IPython automatically loads the editor with the | |
2515 | (temporary) file where foo() was previously defined: |
|
2550 | (temporary) file where foo() was previously defined: | |
2516 |
|
2551 | |||
2517 | In [3]: ed foo |
|
2552 | .. sourcecode :: ipython | |
2518 | Editing... done. Executing edited code... |
|
2553 | ||
|
2554 | In [3]: ed foo | |||
|
2555 | Editing... done. Executing edited code... | |||
2519 |
|
2556 | |||
2520 | And if we call foo() again we get the modified version: |
|
2557 | And if we call foo() again we get the modified version: | |
2521 |
|
2558 | |||
2522 | In [4]: foo() |
|
2559 | .. sourcecode :: ipython | |
2523 | foo() has now been changed! |
|
2560 | ||
|
2561 | In [4]: foo() | |||
|
2562 | foo() has now been changed! | |||
2524 |
|
2563 | |||
2525 | Here is an example of how to edit a code snippet successive |
|
2564 | Here is an example of how to edit a code snippet successive | |
2526 | times. First we call the editor: |
|
2565 | times. First we call the editor: | |
2527 |
|
2566 | |||
2528 | In [5]: ed |
|
2567 | .. sourcecode :: ipython | |
2529 | Editing... done. Executing edited code... |
|
2568 | ||
2530 | hello |
|
2569 | In [5]: ed | |
2531 | Out[5]: "print 'hello'n" |
|
2570 | Editing... done. Executing edited code... | |
|
2571 | hello | |||
|
2572 | Out[5]: "print 'hello'n" | |||
2532 |
|
2573 | |||
2533 | Now we call it again with the previous output (stored in _): |
|
2574 | Now we call it again with the previous output (stored in _): | |
2534 |
|
2575 | |||
2535 | In [6]: ed _ |
|
2576 | .. sourcecode :: ipython | |
2536 | Editing... done. Executing edited code... |
|
2577 | ||
2537 | hello world |
|
2578 | In [6]: ed _ | |
2538 | Out[6]: "print 'hello world'n" |
|
2579 | Editing... done. Executing edited code... | |
|
2580 | hello world | |||
|
2581 | Out[6]: "print 'hello world'n" | |||
2539 |
|
2582 | |||
2540 | Now we call it with the output #8 (stored in _8, also as Out[8]): |
|
2583 | Now we call it with the output #8 (stored in _8, also as Out[8]): | |
2541 |
|
2584 | |||
2542 | In [7]: ed _8 |
|
2585 | .. sourcecode :: ipython | |
2543 | Editing... done. Executing edited code... |
|
2586 | ||
2544 | hello again |
|
2587 | In [7]: ed _8 | |
2545 | Out[7]: "print 'hello again'n" |
|
2588 | Editing... done. Executing edited code... | |
|
2589 | hello again | |||
|
2590 | Out[7]: "print 'hello again'n" | |||
2546 |
|
2591 | |||
2547 |
|
2592 | |||
2548 | Changing the default editor hook: |
|
2593 | Changing the default editor hook: | |
@@ -2715,6 +2760,8 b' Defaulting color scheme to \'NoColor\'"""' | |||||
2715 | You can use the %l specifier in an alias definition to represent the |
|
2760 | You can use the %l specifier in an alias definition to represent the | |
2716 | whole line when the alias is called. For example: |
|
2761 | whole line when the alias is called. For example: | |
2717 |
|
2762 | |||
|
2763 | .. sourcecode:: ipython | |||
|
2764 | ||||
2718 | In [2]: alias bracket echo "Input in brackets: <%l>" |
|
2765 | In [2]: alias bracket echo "Input in brackets: <%l>" | |
2719 | In [3]: bracket hello world |
|
2766 | In [3]: bracket hello world | |
2720 | Input in brackets: <hello world> |
|
2767 | Input in brackets: <hello world> | |
@@ -2722,6 +2769,8 b' Defaulting color scheme to \'NoColor\'"""' | |||||
2722 | You can also define aliases with parameters using %s specifiers (one |
|
2769 | You can also define aliases with parameters using %s specifiers (one | |
2723 | per parameter): |
|
2770 | per parameter): | |
2724 |
|
2771 | |||
|
2772 | .. sourcecode:: ipython | |||
|
2773 | ||||
2725 | In [1]: alias parts echo first %s second %s |
|
2774 | In [1]: alias parts echo first %s second %s | |
2726 | In [2]: %parts A B |
|
2775 | In [2]: %parts A B | |
2727 | first A second B |
|
2776 | first A second B | |
@@ -2737,14 +2786,17 b' Defaulting color scheme to \'NoColor\'"""' | |||||
2737 | the semantic rules, see PEP-215: |
|
2786 | the semantic rules, see PEP-215: | |
2738 | http://www.python.org/peps/pep-0215.html. This is the library used by |
|
2787 | http://www.python.org/peps/pep-0215.html. This is the library used by | |
2739 | IPython for variable expansion. If you want to access a true shell |
|
2788 | IPython for variable expansion. If you want to access a true shell | |
2740 |
variable, an extra $ is necessary to prevent its expansion by |
|
2789 | variable, an extra $ is necessary to prevent its expansion by | |
|
2790 | IPython: | |||
|
2791 | ||||
|
2792 | .. sourcecode:: ipython | |||
2741 |
|
2793 | |||
2742 | In [6]: alias show echo |
|
2794 | In [6]: alias show echo | |
2743 | In [7]: PATH='A Python string' |
|
2795 | In [7]: PATH='A Python string' | |
2744 | In [8]: show $PATH |
|
2796 | In [8]: show $PATH | |
2745 | A Python string |
|
2797 | A Python string | |
2746 | In [9]: show $$PATH |
|
2798 | In [9]: show $$PATH | |
2747 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... |
|
2799 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... | |
2748 |
|
2800 | |||
2749 | You can use the alias facility to acess all of $PATH. See the %rehash |
|
2801 | You can use the alias facility to acess all of $PATH. See the %rehash | |
2750 | and %rehashx functions, which automatically create aliases for the |
|
2802 | and %rehashx functions, which automatically create aliases for the | |
@@ -2866,7 +2918,7 b' Defaulting color scheme to \'NoColor\'"""' | |||||
2866 |
|
2918 | |||
2867 | Examples |
|
2919 | Examples | |
2868 | -------- |
|
2920 | -------- | |
2869 | :: |
|
2921 | .. sourcecode:: ipython | |
2870 |
|
2922 | |||
2871 | In [9]: pwd |
|
2923 | In [9]: pwd | |
2872 | Out[9]: '/home/tsuser/sprint/ipython' |
|
2924 | Out[9]: '/home/tsuser/sprint/ipython' | |
@@ -2908,7 +2960,7 b' Defaulting color scheme to \'NoColor\'"""' | |||||
2908 |
|
2960 | |||
2909 | Examples |
|
2961 | Examples | |
2910 | -------- |
|
2962 | -------- | |
2911 | :: |
|
2963 | .. sourcecode:: ipython | |
2912 |
|
2964 | |||
2913 | In [10]: cd parent/child |
|
2965 | In [10]: cd parent/child | |
2914 | /home/tsuser/parent/child |
|
2966 | /home/tsuser/parent/child | |
@@ -3124,7 +3176,7 b' Defaulting color scheme to \'NoColor\'"""' | |||||
3124 |
|
3176 | |||
3125 | For example: |
|
3177 | For example: | |
3126 |
|
3178 | |||
3127 | # all-random |
|
3179 | .. sourcecode:: ipython | |
3128 |
|
3180 | |||
3129 | # Capture into variable a |
|
3181 | # Capture into variable a | |
3130 | In [1]: sc a=ls *py |
|
3182 | In [1]: sc a=ls *py | |
@@ -3158,6 +3210,8 b' Defaulting color scheme to \'NoColor\'"""' | |||||
3158 | the sense that you can equally invoke the .s attribute on them to |
|
3210 | the sense that you can equally invoke the .s attribute on them to | |
3159 | automatically get a whitespace-separated string from their contents: |
|
3211 | automatically get a whitespace-separated string from their contents: | |
3160 |
|
3212 | |||
|
3213 | .. sourcecode:: ipython | |||
|
3214 | ||||
3161 | In [7]: sc -l b=ls *py |
|
3215 | In [7]: sc -l b=ls *py | |
3162 |
|
3216 | |||
3163 | In [8]: b |
|
3217 | In [8]: b | |
@@ -3167,7 +3221,7 b' Defaulting color scheme to \'NoColor\'"""' | |||||
3167 | Out[9]: 'setup.py win32_manual_post_install.py' |
|
3221 | Out[9]: 'setup.py win32_manual_post_install.py' | |
3168 |
|
3222 | |||
3169 | In summary, both the lists and strings used for output capture have |
|
3223 | In summary, both the lists and strings used for output capture have | |
3170 | the following special attributes: |
|
3224 | the following special attributes:: | |
3171 |
|
3225 | |||
3172 | .l (or .list) : value as list. |
|
3226 | .l (or .list) : value as list. | |
3173 | .n (or .nlstr): value as newline-separated string. |
|
3227 | .n (or .nlstr): value as newline-separated string. | |
@@ -3494,7 +3548,9 b' Defaulting color scheme to \'NoColor\'"""' | |||||
3494 | pylab and mlab, as well as all names from numpy and pylab. |
|
3548 | pylab and mlab, as well as all names from numpy and pylab. | |
3495 |
|
3549 | |||
3496 | If you are using the inline matplotlib backend for embedded figures, |
|
3550 | If you are using the inline matplotlib backend for embedded figures, | |
3497 |
you can adjust its behavior via the %config magic: |
|
3551 | you can adjust its behavior via the %config magic: | |
|
3552 | ||||
|
3553 | .. sourcecode:: ipython | |||
3498 |
|
3554 | |||
3499 | # enable SVG figures, necessary for SVG+XHTML export in the qtconsole |
|
3555 | # enable SVG figures, necessary for SVG+XHTML export in the qtconsole | |
3500 | In [1]: %config InlineBackend.figure_format = 'svg' |
|
3556 | In [1]: %config InlineBackend.figure_format = 'svg' | |
@@ -3514,7 +3570,9 b' Defaulting color scheme to \'NoColor\'"""' | |||||
3514 |
|
3570 | |||
3515 | Examples |
|
3571 | Examples | |
3516 | -------- |
|
3572 | -------- | |
3517 |
In this case, where the MPL default is TkAgg: |
|
3573 | In this case, where the MPL default is TkAgg: | |
|
3574 | ||||
|
3575 | .. sourcecode:: ipython | |||
3518 |
|
3576 | |||
3519 | In [2]: %pylab |
|
3577 | In [2]: %pylab | |
3520 |
|
3578 | |||
@@ -3522,7 +3580,9 b' Defaulting color scheme to \'NoColor\'"""' | |||||
3522 | Backend in use: TkAgg |
|
3580 | Backend in use: TkAgg | |
3523 | For more information, type 'help(pylab)'. |
|
3581 | For more information, type 'help(pylab)'. | |
3524 |
|
3582 | |||
3525 |
But you can explicitly request a different backend: |
|
3583 | But you can explicitly request a different backend: | |
|
3584 | ||||
|
3585 | .. sourcecode:: ipython | |||
3526 |
|
3586 | |||
3527 | In [3]: %pylab qt |
|
3587 | In [3]: %pylab qt | |
3528 |
|
3588 | |||
@@ -3561,7 +3621,7 b' Defaulting color scheme to \'NoColor\'"""' | |||||
3561 |
|
3621 | |||
3562 | Examples |
|
3622 | Examples | |
3563 | -------- |
|
3623 | -------- | |
3564 | :: |
|
3624 | .. sourcecode:: ipython | |
3565 |
|
3625 | |||
3566 | In [1]: from math import pi |
|
3626 | In [1]: from math import pi | |
3567 |
|
3627 | |||
@@ -3679,7 +3739,9 b' Defaulting color scheme to \'NoColor\'"""' | |||||
3679 | Examples |
|
3739 | Examples | |
3680 | -------- |
|
3740 | -------- | |
3681 |
|
3741 | |||
3682 |
To see what classes are available for config, pass no arguments: |
|
3742 | To see what classes are available for config, pass no arguments: | |
|
3743 | ||||
|
3744 | .. sourcecode:: ipython | |||
3683 |
|
3745 | |||
3684 | In [1]: %config |
|
3746 | In [1]: %config | |
3685 | Available objects for config: |
|
3747 | Available objects for config: | |
@@ -3691,7 +3753,9 b' Defaulting color scheme to \'NoColor\'"""' | |||||
3691 | PromptManager |
|
3753 | PromptManager | |
3692 | DisplayFormatter |
|
3754 | DisplayFormatter | |
3693 |
|
3755 | |||
3694 |
To view what is configurable on a given class, just pass the class name: |
|
3756 | To view what is configurable on a given class, just pass the class name: | |
|
3757 | ||||
|
3758 | .. sourcecode:: ipython | |||
3695 |
|
3759 | |||
3696 | In [2]: %config IPCompleter |
|
3760 | In [2]: %config IPCompleter | |
3697 | IPCompleter options |
|
3761 | IPCompleter options | |
@@ -3715,11 +3779,15 b' Defaulting color scheme to \'NoColor\'"""' | |||||
3715 | This will enable completion on elements of lists, results of function calls, |
|
3779 | This will enable completion on elements of lists, results of function calls, | |
3716 | etc., but can be unsafe because the code is actually evaluated on TAB. |
|
3780 | etc., but can be unsafe because the code is actually evaluated on TAB. | |
3717 |
|
3781 | |||
3718 |
but the real use is in setting values: |
|
3782 | but the real use is in setting values: | |
|
3783 | ||||
|
3784 | .. sourcecode:: ipython | |||
3719 |
|
3785 | |||
3720 | In [3]: %config IPCompleter.greedy = True |
|
3786 | In [3]: %config IPCompleter.greedy = True | |
3721 |
|
3787 | |||
3722 |
and these values are read from the user_ns if they are variables: |
|
3788 | and these values are read from the user_ns if they are variables: | |
|
3789 | ||||
|
3790 | .. sourcecode:: ipython | |||
3723 |
|
3791 | |||
3724 | In [4]: feeling_greedy=False |
|
3792 | In [4]: feeling_greedy=False | |
3725 |
|
3793 |
General Comments 0
You need to be logged in to leave comments.
Login now