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 | |||
@@ -454,29 +454,29 b' Currently the magic system has the following functions:\\n"""' | |||||
454 |
|
454 | |||
455 | 1 -> active, but do not apply if there are no arguments on the line. |
|
455 | 1 -> active, but do not apply if there are no arguments on the line. | |
456 |
|
456 | |||
457 | In this mode, you get: |
|
457 | In this mode, you get:: | |
458 |
|
458 | |||
459 | In [1]: callable |
|
459 | In [1]: callable | |
460 | Out[1]: <built-in function callable> |
|
460 | Out[1]: <built-in function callable> | |
461 |
|
461 | |||
462 | In [2]: callable 'hello' |
|
462 | In [2]: callable 'hello' | |
463 | ------> callable('hello') |
|
463 | ------> callable('hello') | |
464 | Out[2]: False |
|
464 | Out[2]: False | |
465 |
|
465 | |||
466 | 2 -> Active always. Even if no arguments are present, the callable |
|
466 | 2 -> Active always. Even if no arguments are present, the callable | |
467 | object is called: |
|
467 | object is called:: | |
468 |
|
468 | |||
469 | In [2]: float |
|
469 | In [2]: float | |
470 | ------> float() |
|
470 | ------> float() | |
471 | Out[2]: 0.0 |
|
471 | Out[2]: 0.0 | |
472 |
|
472 | |||
473 | Note that even with autocall off, you can still use '/' at the start of |
|
473 | 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 |
|
474 | a line to treat the first argument on the command line as a function | |
475 | and add parentheses to it: |
|
475 | and add parentheses to it:: | |
476 |
|
476 | |||
477 | In [8]: /str 43 |
|
477 | In [8]: /str 43 | |
478 | ------> str(43) |
|
478 | ------> str(43) | |
479 | Out[8]: '43' |
|
479 | Out[8]: '43' | |
480 |
|
480 | |||
481 | # all-random (note for auto-testing) |
|
481 | # all-random (note for auto-testing) | |
482 | """ |
|
482 | """ | |
@@ -676,22 +676,24 b' Currently the magic system has the following functions:\\n"""' | |||||
676 | search with -s or exclude them with -e (these options can be given |
|
676 | search with -s or exclude them with -e (these options can be given | |
677 | more than once). |
|
677 | more than once). | |
678 |
|
678 | |||
679 |
Examples |
|
679 | Examples | |
|
680 | -------- | |||
|
681 | :: | |||
680 |
|
682 | |||
681 | %psearch a* -> objects beginning with an a |
|
683 | %psearch a* -> objects beginning with an a | |
682 | %psearch -e builtin a* -> objects NOT in the builtin space starting in a |
|
684 | %psearch -e builtin a* -> objects NOT in the builtin space starting in a | |
683 | %psearch a* function -> all functions beginning with an a |
|
685 | %psearch a* function -> all functions beginning with an a | |
684 | %psearch re.e* -> objects beginning with an e in module re |
|
686 | %psearch re.e* -> objects beginning with an e in module re | |
685 | %psearch r*.e* -> objects that start with e in modules starting in r |
|
687 | %psearch r*.e* -> objects that start with e in modules starting in r | |
686 | %psearch r*.* string -> all strings in modules beginning with r |
|
688 | %psearch r*.* string -> all strings in modules beginning with r | |
687 |
|
689 | |||
688 | Case sensitive search: |
|
690 | Case sensitive search:: | |
689 |
|
691 | |||
690 | %psearch -c a* list all object beginning with lower case a |
|
692 | %psearch -c a* list all object beginning with lower case a | |
691 |
|
693 | |||
692 | Show objects beginning with a single _: |
|
694 | Show objects beginning with a single _:: | |
693 |
|
695 | |||
694 | %psearch -a _* list objects beginning with a single underscore""" |
|
696 | %psearch -a _* list objects beginning with a single underscore""" | |
695 | try: |
|
697 | try: | |
696 | parameter_s.encode('ascii') |
|
698 | parameter_s.encode('ascii') | |
697 | except UnicodeEncodeError: |
|
699 | except UnicodeEncodeError: | |
@@ -772,7 +774,7 b' Currently the magic system has the following functions:\\n"""' | |||||
772 | """Print all interactive variables, with some minimal formatting. |
|
774 | """Print all interactive variables, with some minimal formatting. | |
773 |
|
775 | |||
774 | If any arguments are given, only variables whose type matches one of |
|
776 | If any arguments are given, only variables whose type matches one of | |
775 | these are printed. For example: |
|
777 | these are printed. For example:: | |
776 |
|
778 | |||
777 | %who function str |
|
779 | %who function str | |
778 |
|
780 | |||
@@ -780,12 +782,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 |
|
782 | 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: |
|
783 | command line to see how python prints type names. For example: | |
782 |
|
784 | |||
|
785 | :: | |||
|
786 | ||||
783 | In [1]: type('hello')\\ |
|
787 | In [1]: type('hello')\\ | |
784 | Out[1]: <type 'str'> |
|
788 | Out[1]: <type 'str'> | |
785 |
|
789 | |||
786 | indicates that the type name for strings is 'str'. |
|
790 | indicates that the type name for strings is 'str'. | |
787 |
|
791 | |||
788 | %who always excludes executed names loaded through your configuration |
|
792 | ``%who`` always excludes executed names loaded through your configuration | |
789 | file and things which are internal to IPython. |
|
793 | file and things which are internal to IPython. | |
790 |
|
794 | |||
791 | This is deliberate, as typically you may load many modules and the |
|
795 | This is deliberate, as typically you may load many modules and the | |
@@ -984,29 +988,31 b' Currently the magic system has the following functions:\\n"""' | |||||
984 |
|
988 | |||
985 | See Also |
|
989 | See Also | |
986 | -------- |
|
990 | -------- | |
987 | magic_reset_selective |
|
991 | magic_reset_selective : invoked as ``%reset_selective`` | |
988 |
|
992 | |||
989 | Examples |
|
993 | Examples | |
990 | -------- |
|
994 | -------- | |
991 | In [6]: a = 1 |
|
995 | :: | |
|
996 | ||||
|
997 | In [6]: a = 1 | |||
992 |
|
998 | |||
993 | In [7]: a |
|
999 | In [7]: a | |
994 | Out[7]: 1 |
|
1000 | Out[7]: 1 | |
995 |
|
1001 | |||
996 | In [8]: 'a' in _ip.user_ns |
|
1002 | In [8]: 'a' in _ip.user_ns | |
997 | Out[8]: True |
|
1003 | Out[8]: True | |
998 |
|
1004 | |||
999 | In [9]: %reset -f |
|
1005 | In [9]: %reset -f | |
1000 |
|
1006 | |||
1001 | In [1]: 'a' in _ip.user_ns |
|
1007 | In [1]: 'a' in _ip.user_ns | |
1002 | Out[1]: False |
|
1008 | Out[1]: False | |
1003 |
|
1009 | |||
1004 | In [2]: %reset -f in |
|
1010 | In [2]: %reset -f in | |
1005 | Flushing input history |
|
1011 | Flushing input history | |
1006 |
|
1012 | |||
1007 |
In [3]: %reset -f dhist in |
|
1013 | In [3]: %reset -f dhist in | |
1008 | Flushing directory history |
|
1014 | Flushing directory history | |
1009 | Flushing input history |
|
1015 | Flushing input history | |
1010 |
|
1016 | |||
1011 | Notes |
|
1017 | Notes | |
1012 | ----- |
|
1018 | ----- | |
@@ -1095,44 +1101,44 b' Currently the magic system has the following functions:\\n"""' | |||||
1095 |
|
1101 | |||
1096 | See Also |
|
1102 | See Also | |
1097 | -------- |
|
1103 | -------- | |
1098 | magic_reset |
|
1104 | magic_reset : invoked as ``%reset`` | |
1099 |
|
1105 | |||
1100 | Examples |
|
1106 | Examples | |
1101 | -------- |
|
1107 | -------- | |
1102 |
|
1108 | |||
1103 | We first fully reset the namespace so your output looks identical to |
|
1109 | 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 |
|
1110 | this example for pedagogical reasons; in practice you do not need a | |
1105 |
full reset |
|
1111 | full reset:: | |
1106 |
|
1112 | |||
1107 | In [1]: %reset -f |
|
1113 | In [1]: %reset -f | |
1108 |
|
1114 | |||
1109 | Now, with a clean namespace we can make a few variables and use |
|
1115 | Now, with a clean namespace we can make a few variables and use | |
1110 | %reset_selective to only delete names that match our regexp: |
|
1116 | ``%reset_selective`` to only delete names that match our regexp:: | |
1111 |
|
1117 | |||
1112 | In [2]: a=1; b=2; c=3; b1m=4; b2m=5; b3m=6; b4m=7; b2s=8 |
|
1118 | In [2]: a=1; b=2; c=3; b1m=4; b2m=5; b3m=6; b4m=7; b2s=8 | |
1113 |
|
1119 | |||
1114 | In [3]: who_ls |
|
1120 | In [3]: who_ls | |
1115 | Out[3]: ['a', 'b', 'b1m', 'b2m', 'b2s', 'b3m', 'b4m', 'c'] |
|
1121 | Out[3]: ['a', 'b', 'b1m', 'b2m', 'b2s', 'b3m', 'b4m', 'c'] | |
1116 |
|
1122 | |||
1117 | In [4]: %reset_selective -f b[2-3]m |
|
1123 | In [4]: %reset_selective -f b[2-3]m | |
1118 |
|
1124 | |||
1119 | In [5]: who_ls |
|
1125 | In [5]: who_ls | |
1120 | Out[5]: ['a', 'b', 'b1m', 'b2s', 'b4m', 'c'] |
|
1126 | Out[5]: ['a', 'b', 'b1m', 'b2s', 'b4m', 'c'] | |
1121 |
|
1127 | |||
1122 | In [6]: %reset_selective -f d |
|
1128 | In [6]: %reset_selective -f d | |
1123 |
|
1129 | |||
1124 | In [7]: who_ls |
|
1130 | In [7]: who_ls | |
1125 | Out[7]: ['a', 'b', 'b1m', 'b2s', 'b4m', 'c'] |
|
1131 | Out[7]: ['a', 'b', 'b1m', 'b2s', 'b4m', 'c'] | |
1126 |
|
1132 | |||
1127 | In [8]: %reset_selective -f c |
|
1133 | In [8]: %reset_selective -f c | |
1128 |
|
1134 | |||
1129 | In [9]: who_ls |
|
1135 | In [9]: who_ls | |
1130 | Out[9]: ['a', 'b', 'b1m', 'b2s', 'b4m'] |
|
1136 | Out[9]: ['a', 'b', 'b1m', 'b2s', 'b4m'] | |
1131 |
|
1137 | |||
1132 | In [10]: %reset_selective -f b |
|
1138 | In [10]: %reset_selective -f b | |
1133 |
|
1139 | |||
1134 | In [11]: who_ls |
|
1140 | In [11]: who_ls | |
1135 | Out[11]: ['a'] |
|
1141 | Out[11]: ['a'] | |
1136 |
|
1142 | |||
1137 | Notes |
|
1143 | Notes | |
1138 | ----- |
|
1144 | ----- | |
@@ -1213,14 +1219,14 b' Currently the magic system has the following functions:\\n"""' | |||||
1213 | Python code. |
|
1219 | Python code. | |
1214 |
|
1220 | |||
1215 | Since this marker is always the same, filtering only the output from |
|
1221 | Since this marker is always the same, filtering only the output from | |
1216 | 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:: | |
1217 |
|
1223 | |||
1218 | awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py |
|
1224 | awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py | |
1219 |
|
1225 | |||
1220 | -r: log 'raw' input. Normally, IPython's logs contain the processed |
|
1226 | -r: log 'raw' input. Normally, IPython's logs contain the processed | |
1221 | input, so that user lines are logged in their final form, converted |
|
1227 | input, so that user lines are logged in their final form, converted | |
1222 | into valid Python. For example, %Exit is logged as |
|
1228 | into valid Python. For example, %Exit is logged as | |
1223 |
|
|
1229 | _ip.magic("Exit"). If the -r flag is given, all input is logged | |
1224 | exactly as typed, with no transformations applied. |
|
1230 | exactly as typed, with no transformations applied. | |
1225 |
|
1231 | |||
1226 | -t: put timestamps before each input line logged (these are put in |
|
1232 | -t: put timestamps before each input line logged (these are put in | |
@@ -1606,7 +1612,7 b' Currently the magic system has the following functions:\\n"""' | |||||
1606 | must be an integer indicating how many times you want the script to |
|
1612 | must be an integer indicating how many times you want the script to | |
1607 | run. The final timing report will include total and per run results. |
|
1613 | run. The final timing report will include total and per run results. | |
1608 |
|
1614 | |||
1609 | For example (testing the script uniq_stable.py): |
|
1615 | For example (testing the script uniq_stable.py):: | |
1610 |
|
1616 | |||
1611 | In [1]: run -t uniq_stable |
|
1617 | In [1]: run -t uniq_stable | |
1612 |
|
1618 | |||
@@ -1630,7 +1636,7 b' Currently the magic system has the following functions:\\n"""' | |||||
1630 |
|
1636 | |||
1631 | with a breakpoint set on line 1 of your file. You can change the line |
|
1637 | with a breakpoint set on line 1 of your file. You can change the line | |
1632 | number for this automatic breakpoint to be <N> by using the -bN option |
|
1638 | number for this automatic breakpoint to be <N> by using the -bN option | |
1633 | (where N must be an integer). For example: |
|
1639 | (where N must be an integer). For example:: | |
1634 |
|
1640 | |||
1635 | %run -d -b40 myscript |
|
1641 | %run -d -b40 myscript | |
1636 |
|
1642 | |||
@@ -1667,7 +1673,7 b' Currently the magic system has the following functions:\\n"""' | |||||
1667 | the -m option for the python interpreter. Use this option last if you |
|
1673 | the -m option for the python interpreter. Use this option last if you | |
1668 | want to combine with other %run options. Unlike the python interpreter |
|
1674 | want to combine with other %run options. Unlike the python interpreter | |
1669 | only source modules are allowed no .pyc or .pyo files. |
|
1675 | only source modules are allowed no .pyc or .pyo files. | |
1670 | For example: |
|
1676 | For example:: | |
1671 |
|
1677 | |||
1672 | %run -m example |
|
1678 | %run -m example | |
1673 |
|
1679 | |||
@@ -1905,7 +1911,9 b' Currently the magic system has the following functions:\\n"""' | |||||
1905 | Default: 3 |
|
1911 | Default: 3 | |
1906 |
|
1912 | |||
1907 |
|
1913 | |||
1908 |
Examples |
|
1914 | Examples | |
|
1915 | -------- | |||
|
1916 | :: | |||
1909 |
|
1917 | |||
1910 | In [1]: %timeit pass |
|
1918 | In [1]: %timeit pass | |
1911 | 10000000 loops, best of 3: 53.3 ns per loop |
|
1919 | 10000000 loops, best of 3: 53.3 ns per loop | |
@@ -2027,7 +2035,9 b' Currently the magic system has the following functions:\\n"""' | |||||
2027 | 2.3, the timeit module offers more control and sophistication, so this |
|
2035 | 2.3, the timeit module offers more control and sophistication, so this | |
2028 | could be rewritten to use it (patches welcome). |
|
2036 | could be rewritten to use it (patches welcome). | |
2029 |
|
2037 | |||
2030 |
|
|
2038 | Examples | |
|
2039 | -------- | |||
|
2040 | :: | |||
2031 |
|
2041 | |||
2032 | In [1]: time 2**128 |
|
2042 | In [1]: time 2**128 | |
2033 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s |
|
2043 | CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s | |
@@ -2135,7 +2145,7 b' Currently the magic system has the following functions:\\n"""' | |||||
2135 | Note: as a 'hidden' feature, you can also use traditional python slice |
|
2145 | Note: as a 'hidden' feature, you can also use traditional python slice | |
2136 | notation, where N:M means numbers N through M-1. |
|
2146 | notation, where N:M means numbers N through M-1. | |
2137 |
|
2147 | |||
2138 | For example, if your history contains (%hist prints it): |
|
2148 | For example, if your history contains (%hist prints it):: | |
2139 |
|
2149 | |||
2140 | 44: x=1 |
|
2150 | 44: x=1 | |
2141 | 45: y=3 |
|
2151 | 45: y=3 | |
@@ -2145,7 +2155,7 b' Currently the magic system has the following functions:\\n"""' | |||||
2145 | 49: print 'x',x,'y',y |
|
2155 | 49: print 'x',x,'y',y | |
2146 |
|
2156 | |||
2147 | you can create a macro with lines 44 through 47 (included) and line 49 |
|
2157 | you can create a macro with lines 44 through 47 (included) and line 49 | |
2148 | called my_macro with: |
|
2158 | called my_macro with:: | |
2149 |
|
2159 | |||
2150 | In [55]: %macro my_macro 44-47 49 |
|
2160 | In [55]: %macro my_macro 44-47 49 | |
2151 |
|
2161 | |||
@@ -2160,9 +2170,9 b' Currently the magic system has the following functions:\\n"""' | |||||
2160 | but IPython's display system checks for macros and executes them as |
|
2170 | but IPython's display system checks for macros and executes them as | |
2161 | code instead of printing them when you type their name. |
|
2171 | code instead of printing them when you type their name. | |
2162 |
|
2172 | |||
2163 | You can view a macro's contents by explicitly printing it with: |
|
2173 | You can view a macro's contents by explicitly printing it with:: | |
2164 |
|
2174 | |||
2165 |
|
|
2175 | print macro_name | |
2166 |
|
2176 | |||
2167 | """ |
|
2177 | """ | |
2168 | opts,args = self.parse_options(parameter_s,'r',mode='list') |
|
2178 | opts,args = self.parse_options(parameter_s,'r',mode='list') | |
@@ -2500,49 +2510,50 b' Currently the magic system has the following functions:\\n"""' | |||||
2500 | Note that %edit is also available through the alias %ed. |
|
2510 | Note that %edit is also available through the alias %ed. | |
2501 |
|
2511 | |||
2502 | This is an example of creating a simple function inside the editor and |
|
2512 | This is an example of creating a simple function inside the editor and | |
2503 | then modifying it. First, start up the editor: |
|
2513 | then modifying it. First, start up the editor:: | |
2504 |
|
2514 | |||
2505 | In [1]: ed |
|
2515 | In [1]: ed | |
2506 | Editing... done. Executing edited code... |
|
2516 | Editing... done. Executing edited code... | |
2507 |
Out[1]: 'def foo():n print "foo() was defined in an editing |
|
2517 | Out[1]: 'def foo():\\n print "foo() was defined in an editing | |
|
2518 | session"\\n' | |||
2508 |
|
2519 | |||
2509 | We can then call the function foo(): |
|
2520 | We can then call the function foo():: | |
2510 |
|
2521 | |||
2511 | In [2]: foo() |
|
2522 | In [2]: foo() | |
2512 | foo() was defined in an editing session |
|
2523 | foo() was defined in an editing session | |
2513 |
|
2524 | |||
2514 | Now we edit foo. IPython automatically loads the editor with the |
|
2525 | Now we edit foo. IPython automatically loads the editor with the | |
2515 | (temporary) file where foo() was previously defined: |
|
2526 | (temporary) file where foo() was previously defined:: | |
2516 |
|
2527 | |||
2517 | In [3]: ed foo |
|
2528 | In [3]: ed foo | |
2518 | Editing... done. Executing edited code... |
|
2529 | Editing... done. Executing edited code... | |
2519 |
|
2530 | |||
2520 | And if we call foo() again we get the modified version: |
|
2531 | And if we call foo() again we get the modified version:: | |
2521 |
|
2532 | |||
2522 | In [4]: foo() |
|
2533 | In [4]: foo() | |
2523 | foo() has now been changed! |
|
2534 | foo() has now been changed! | |
2524 |
|
2535 | |||
2525 | Here is an example of how to edit a code snippet successive |
|
2536 | Here is an example of how to edit a code snippet successive | |
2526 | times. First we call the editor: |
|
2537 | times. First we call the editor:: | |
2527 |
|
2538 | |||
2528 | In [5]: ed |
|
2539 | In [5]: ed | |
2529 | Editing... done. Executing edited code... |
|
2540 | Editing... done. Executing edited code... | |
2530 | hello |
|
2541 | hello | |
2531 | Out[5]: "print 'hello'n" |
|
2542 | Out[5]: "print 'hello'\\n" | |
2532 |
|
2543 | |||
2533 | Now we call it again with the previous output (stored in _): |
|
2544 | Now we call it again with the previous output (stored in _):: | |
2534 |
|
2545 | |||
2535 | In [6]: ed _ |
|
2546 | In [6]: ed _ | |
2536 | Editing... done. Executing edited code... |
|
2547 | Editing... done. Executing edited code... | |
2537 | hello world |
|
2548 | hello world | |
2538 | Out[6]: "print 'hello world'n" |
|
2549 | Out[6]: "print 'hello world'\\n" | |
2539 |
|
2550 | |||
2540 | Now we call it with the output #8 (stored in _8, also as Out[8]): |
|
2551 | Now we call it with the output #8 (stored in _8, also as Out[8]):: | |
2541 |
|
2552 | |||
2542 | In [7]: ed _8 |
|
2553 | In [7]: ed _8 | |
2543 | Editing... done. Executing edited code... |
|
2554 | Editing... done. Executing edited code... | |
2544 | hello again |
|
2555 | hello again | |
2545 | Out[7]: "print 'hello again'n" |
|
2556 | Out[7]: "print 'hello again'\\n" | |
2546 |
|
2557 | |||
2547 |
|
2558 | |||
2548 | Changing the default editor hook: |
|
2559 | Changing the default editor hook: | |
@@ -2713,14 +2724,14 b' Defaulting color scheme to \'NoColor\'"""' | |||||
2713 | alias can not be executed until 'del foo' removes the Python variable. |
|
2724 | alias can not be executed until 'del foo' removes the Python variable. | |
2714 |
|
2725 | |||
2715 | You can use the %l specifier in an alias definition to represent the |
|
2726 | You can use the %l specifier in an alias definition to represent the | |
2716 | whole line when the alias is called. For example: |
|
2727 | whole line when the alias is called. For example:: | |
2717 |
|
2728 | |||
2718 | In [2]: alias bracket echo "Input in brackets: <%l>" |
|
2729 | In [2]: alias bracket echo "Input in brackets: <%l>" | |
2719 | In [3]: bracket hello world |
|
2730 | In [3]: bracket hello world | |
2720 | Input in brackets: <hello world> |
|
2731 | Input in brackets: <hello world> | |
2721 |
|
2732 | |||
2722 | You can also define aliases with parameters using %s specifiers (one |
|
2733 | You can also define aliases with parameters using %s specifiers (one | |
2723 | per parameter): |
|
2734 | per parameter):: | |
2724 |
|
2735 | |||
2725 | In [1]: alias parts echo first %s second %s |
|
2736 | In [1]: alias parts echo first %s second %s | |
2726 | In [2]: %parts A B |
|
2737 | In [2]: %parts A B | |
@@ -2737,14 +2748,15 b' Defaulting color scheme to \'NoColor\'"""' | |||||
2737 | the semantic rules, see PEP-215: |
|
2748 | the semantic rules, see PEP-215: | |
2738 | http://www.python.org/peps/pep-0215.html. This is the library used by |
|
2749 | 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 |
|
2750 | IPython for variable expansion. If you want to access a true shell | |
2740 |
variable, an extra $ is necessary to prevent its expansion by |
|
2751 | variable, an extra $ is necessary to prevent its expansion by | |
|
2752 | IPython:: | |||
2741 |
|
2753 | |||
2742 | In [6]: alias show echo |
|
2754 | In [6]: alias show echo | |
2743 | In [7]: PATH='A Python string' |
|
2755 | In [7]: PATH='A Python string' | |
2744 | In [8]: show $PATH |
|
2756 | In [8]: show $PATH | |
2745 | A Python string |
|
2757 | A Python string | |
2746 | In [9]: show $$PATH |
|
2758 | In [9]: show $$PATH | |
2747 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... |
|
2759 | /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:... | |
2748 |
|
2760 | |||
2749 | You can use the alias facility to acess all of $PATH. See the %rehash |
|
2761 | You can use the alias facility to acess all of $PATH. See the %rehash | |
2750 | and %rehashx functions, which automatically create aliases for the |
|
2762 | and %rehashx functions, which automatically create aliases for the | |
@@ -3122,9 +3134,7 b' Defaulting color scheme to \'NoColor\'"""' | |||||
3122 | space-separated string. These are convenient, respectively, either |
|
3134 | space-separated string. These are convenient, respectively, either | |
3123 | for sequential processing or to be passed to a shell command. |
|
3135 | for sequential processing or to be passed to a shell command. | |
3124 |
|
3136 | |||
3125 | For example: |
|
3137 | For example:: | |
3126 |
|
||||
3127 | # all-random |
|
|||
3128 |
|
3138 | |||
3129 | # Capture into variable a |
|
3139 | # Capture into variable a | |
3130 | In [1]: sc a=ls *py |
|
3140 | In [1]: sc a=ls *py | |
@@ -3156,7 +3166,7 b' Defaulting color scheme to \'NoColor\'"""' | |||||
3156 |
|
3166 | |||
3157 | Similarly, the lists returned by the -l option are also special, in |
|
3167 | Similarly, the lists returned by the -l option are also special, in | |
3158 | the sense that you can equally invoke the .s attribute on them to |
|
3168 | the sense that you can equally invoke the .s attribute on them to | |
3159 | automatically get a whitespace-separated string from their contents: |
|
3169 | automatically get a whitespace-separated string from their contents:: | |
3160 |
|
3170 | |||
3161 | In [7]: sc -l b=ls *py |
|
3171 | In [7]: sc -l b=ls *py | |
3162 |
|
3172 | |||
@@ -3167,7 +3177,7 b' Defaulting color scheme to \'NoColor\'"""' | |||||
3167 | Out[9]: 'setup.py win32_manual_post_install.py' |
|
3177 | Out[9]: 'setup.py win32_manual_post_install.py' | |
3168 |
|
3178 | |||
3169 | In summary, both the lists and strings used for output capture have |
|
3179 | In summary, both the lists and strings used for output capture have | |
3170 | the following special attributes: |
|
3180 | the following special attributes:: | |
3171 |
|
3181 | |||
3172 | .l (or .list) : value as list. |
|
3182 | .l (or .list) : value as list. | |
3173 | .n (or .nlstr): value as newline-separated string. |
|
3183 | .n (or .nlstr): value as newline-separated string. | |
@@ -3210,11 +3220,16 b' Defaulting color scheme to \'NoColor\'"""' | |||||
3210 | Notes: |
|
3220 | Notes: | |
3211 |
|
3221 | |||
3212 | 1) If an input line begins with '!!', then %sx is automatically |
|
3222 | 1) If an input line begins with '!!', then %sx is automatically | |
3213 | invoked. That is, while: |
|
3223 | invoked. That is, while:: | |
|
3224 | ||||
3214 | !ls |
|
3225 | !ls | |
3215 | causes ipython to simply issue system('ls'), typing |
|
3226 | ||
|
3227 | causes ipython to simply issue system('ls'), typing:: | |||
|
3228 | ||||
3216 | !!ls |
|
3229 | !!ls | |
3217 | is a shorthand equivalent to: |
|
3230 | ||
|
3231 | is a shorthand equivalent to:: | |||
|
3232 | ||||
3218 | %sx ls |
|
3233 | %sx ls | |
3219 |
|
3234 | |||
3220 | 2) %sx differs from %sc in that %sx automatically splits into a list, |
|
3235 | 2) %sx differs from %sc in that %sx automatically splits into a list, | |
@@ -3224,6 +3239,7 b' Defaulting color scheme to \'NoColor\'"""' | |||||
3224 | typing. |
|
3239 | typing. | |
3225 |
|
3240 | |||
3226 | 3) Just like %sc -l, this is a list with special attributes: |
|
3241 | 3) Just like %sc -l, this is a list with special attributes: | |
|
3242 | :: | |||
3227 |
|
3243 | |||
3228 | .l (or .list) : value as list. |
|
3244 | .l (or .list) : value as list. | |
3229 | .n (or .nlstr): value as newline-separated string. |
|
3245 | .n (or .nlstr): value as newline-separated string. | |
@@ -3245,8 +3261,10 b' Defaulting color scheme to \'NoColor\'"""' | |||||
3245 | %bookmark -d <name> - remove bookmark |
|
3261 | %bookmark -d <name> - remove bookmark | |
3246 | %bookmark -r - remove all bookmarks |
|
3262 | %bookmark -r - remove all bookmarks | |
3247 |
|
3263 | |||
3248 | You can later on access a bookmarked folder with: |
|
3264 | You can later on access a bookmarked folder with:: | |
|
3265 | ||||
3249 | %cd -b <name> |
|
3266 | %cd -b <name> | |
|
3267 | ||||
3250 | or simply '%cd <name>' if there is no directory called <name> AND |
|
3268 | or simply '%cd <name>' if there is no directory called <name> AND | |
3251 | there is such a bookmark defined. |
|
3269 | there is such a bookmark defined. | |
3252 |
|
3270 | |||
@@ -3691,7 +3709,8 b' Defaulting color scheme to \'NoColor\'"""' | |||||
3691 | PromptManager |
|
3709 | PromptManager | |
3692 | DisplayFormatter |
|
3710 | DisplayFormatter | |
3693 |
|
3711 | |||
3694 |
To view what is configurable on a given class, just pass the class |
|
3712 | To view what is configurable on a given class, just pass the class | |
|
3713 | name:: | |||
3695 |
|
3714 | |||
3696 | In [2]: %config IPCompleter |
|
3715 | In [2]: %config IPCompleter | |
3697 | IPCompleter options |
|
3716 | IPCompleter options |
General Comments 0
You need to be logged in to leave comments.
Login now