Show More
@@ -31,7 +31,7 b' reset and restore the tty state.' | |||||
31 |
|
31 | |||
32 | - The evaluation of the NAME.NAME... form may cause arbitrary |
|
32 | - The evaluation of the NAME.NAME... form may cause arbitrary | |
33 | application defined code to be executed if an object with a |
|
33 | application defined code to be executed if an object with a | |
34 | __getattr__ hook is found. Since it is the responsibility of the |
|
34 | ``__getattr__`` hook is found. Since it is the responsibility of the | |
35 | application (or the user) to enable this feature, I consider this an |
|
35 | application (or the user) to enable this feature, I consider this an | |
36 | acceptable risk. More complicated expressions (e.g. function calls or |
|
36 | acceptable risk. More complicated expressions (e.g. function calls or | |
37 | indexing operations) are *not* evaluated. |
|
37 | indexing operations) are *not* evaluated. |
@@ -96,18 +96,23 b' class Tracer(object):' | |||||
96 | def __init__(self,colors=None): |
|
96 | def __init__(self,colors=None): | |
97 | """Create a local debugger instance. |
|
97 | """Create a local debugger instance. | |
98 |
|
98 | |||
99 |
|
|
99 | Parameters | |
|
100 | ---------- | |||
100 |
|
101 | |||
101 | - `colors` (None): a string containing the name of the color scheme to |
|
102 | colors : str, optional | |
102 | use, it must be one of IPython's valid color schemes. If not given, the |
|
103 | The name of the color scheme to use, it must be one of IPython's | |
103 | function will default to the current IPython scheme when running inside |
|
104 | valid color schemes. If not given, the function will default to | |
104 | IPython, and to 'NoColor' otherwise. |
|
105 | the current IPython scheme when running inside IPython, and to | |
|
106 | 'NoColor' otherwise. | |||
105 |
|
107 | |||
106 |
|
|
108 | Examples | |
|
109 | -------- | |||
|
110 | :: | |||
107 |
|
111 | |||
108 | from IPython.core.debugger import Tracer; debug_here = Tracer() |
|
112 | from IPython.core.debugger import Tracer; debug_here = Tracer() | |
109 |
|
113 | |||
110 |
|
|
114 | Later in your code:: | |
|
115 | ||||
111 | debug_here() # -> will open up the debugger at that point. |
|
116 | debug_here() # -> will open up the debugger at that point. | |
112 |
|
117 | |||
113 | Once the debugger activates, you can use all of its regular commands to |
|
118 | Once the debugger activates, you can use all of its regular commands to |
@@ -3036,7 +3036,8 b' class InteractiveShell(SingletonConfigurable):' | |||||
3036 |
|
3036 | |||
3037 | N:M -> standard python form, means including items N...(M-1). |
|
3037 | N:M -> standard python form, means including items N...(M-1). | |
3038 |
|
3038 | |||
3039 |
N-M -> include items N..M (closed endpoint). |
|
3039 | N-M -> include items N..M (closed endpoint). | |
|
3040 | """ | |||
3040 | lines = self.history_manager.get_range_by_str(range_str, raw=raw) |
|
3041 | lines = self.history_manager.get_range_by_str(range_str, raw=raw) | |
3041 | return "\n".join(x for _, _, x in lines) |
|
3042 | return "\n".join(x for _, _, x in lines) | |
3042 |
|
3043 |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -102,7 +102,8 b' python-profiler package from non-free.""")' | |||||
102 |
|
102 | |||
103 | Options: |
|
103 | Options: | |
104 |
|
104 | |||
105 | -l <limit>: you can place restrictions on what or how much of the |
|
105 | -l <limit> | |
|
106 | you can place restrictions on what or how much of the | |||
106 | profile gets printed. The limit value can be: |
|
107 | profile gets printed. The limit value can be: | |
107 |
|
108 | |||
108 | * A string: only information for function names containing this string |
|
109 | * A string: only information for function names containing this string | |
@@ -114,14 +115,16 b' python-profiler package from non-free.""")' | |||||
114 | (for example, use a limit of 0.4 to see the topmost 40% only). |
|
115 | (for example, use a limit of 0.4 to see the topmost 40% only). | |
115 |
|
116 | |||
116 | You can combine several limits with repeated use of the option. For |
|
117 | You can combine several limits with repeated use of the option. For | |
117 |
example, |
|
118 | example, ``-l __init__ -l 5`` will print only the topmost 5 lines of | |
118 | information about class constructors. |
|
119 | information about class constructors. | |
119 |
|
120 | |||
120 | -r: return the pstats.Stats object generated by the profiling. This |
|
121 | -r | |
|
122 | return the pstats.Stats object generated by the profiling. This | |||
121 | object has all the information about the profile in it, and you can |
|
123 | object has all the information about the profile in it, and you can | |
122 | later use it for further analysis or in other functions. |
|
124 | later use it for further analysis or in other functions. | |
123 |
|
125 | |||
124 | -s <key>: sort profile by given key. You can provide more than one key |
|
126 | -s <key> | |
|
127 | sort profile by given key. You can provide more than one key | |||
125 | by using the option several times: '-s key1 -s key2 -s key3...'. The |
|
128 | by using the option several times: '-s key1 -s key2 -s key3...'. The | |
126 | default sorting key is 'time'. |
|
129 | default sorting key is 'time'. | |
127 |
|
130 | |||
@@ -136,7 +139,9 b' python-profiler package from non-free.""")' | |||||
136 | abbreviation is unambiguous. The following are the keys currently |
|
139 | abbreviation is unambiguous. The following are the keys currently | |
137 | defined: |
|
140 | defined: | |
138 |
|
141 | |||
|
142 | ============ ===================== | |||
139 |
|
|
143 | Valid Arg Meaning | |
|
144 | ============ ===================== | |||
140 |
|
|
145 | "calls" call count | |
141 |
|
|
146 | "cumulative" cumulative time | |
142 |
|
|
147 | "file" file name | |
@@ -147,6 +152,7 b' python-profiler package from non-free.""")' | |||||
147 |
|
|
152 | "nfl" name/file/line | |
148 |
|
|
153 | "stdname" standard name | |
149 |
|
|
154 | "time" internal time | |
|
155 | ============ ===================== | |||
150 |
|
156 | |||
151 | Note that all sorts on statistics are in descending order (placing |
|
157 | Note that all sorts on statistics are in descending order (placing | |
152 | most time consuming items first), where as name, file, and line number |
|
158 | most time consuming items first), where as name, file, and line number | |
@@ -159,18 +165,21 b' python-profiler package from non-free.""")' | |||||
159 | line numbers. In fact, sort_stats("nfl") is the same as |
|
165 | line numbers. In fact, sort_stats("nfl") is the same as | |
160 | sort_stats("name", "file", "line"). |
|
166 | sort_stats("name", "file", "line"). | |
161 |
|
167 | |||
162 | -T <filename>: save profile results as shown on screen to a text |
|
168 | -T <filename> | |
|
169 | save profile results as shown on screen to a text | |||
163 | file. The profile is still shown on screen. |
|
170 | file. The profile is still shown on screen. | |
164 |
|
171 | |||
165 | -D <filename>: save (via dump_stats) profile statistics to given |
|
172 | -D <filename> | |
|
173 | save (via dump_stats) profile statistics to given | |||
166 | filename. This data is in a format understood by the pstats module, and |
|
174 | filename. This data is in a format understood by the pstats module, and | |
167 | is generated by a call to the dump_stats() method of profile |
|
175 | is generated by a call to the dump_stats() method of profile | |
168 | objects. The profile is still shown on screen. |
|
176 | objects. The profile is still shown on screen. | |
169 |
|
177 | |||
170 | -q: suppress output to the pager. Best used with -T and/or -D above. |
|
178 | -q | |
|
179 | suppress output to the pager. Best used with -T and/or -D above. | |||
171 |
|
180 | |||
172 | If you want to run complete programs under the profiler's control, use |
|
181 | If you want to run complete programs under the profiler's control, use | |
173 |
|
|
182 | ``%run -p [prof_opts] filename.py [args to program]`` where prof_opts | |
174 | contains profiler specific options as described here. |
|
183 | contains profiler specific options as described here. | |
175 |
|
184 | |||
176 | You can read the complete documentation for the profile module with:: |
|
185 | You can read the complete documentation for the profile module with:: | |
@@ -362,7 +371,8 b' python-profiler package from non-free.""")' | |||||
362 | file_finder=get_py_filename): |
|
371 | file_finder=get_py_filename): | |
363 | """Run the named file inside IPython as a program. |
|
372 | """Run the named file inside IPython as a program. | |
364 |
|
373 | |||
365 | Usage: |
|
374 | Usage:: | |
|
375 | ||||
366 | %run [-n -i -e -G] |
|
376 | %run [-n -i -e -G] | |
367 | [( -t [-N<N>] | -d [-b<N>] | -p [profile options] )] |
|
377 | [( -t [-N<N>] | -d [-b<N>] | -p [profile options] )] | |
368 | ( -m mod | file ) [args] |
|
378 | ( -m mod | file ) [args] | |
@@ -371,14 +381,13 b' python-profiler package from non-free.""")' | |||||
371 | the program (put in sys.argv). Then, control returns to IPython's |
|
381 | the program (put in sys.argv). Then, control returns to IPython's | |
372 | prompt. |
|
382 | prompt. | |
373 |
|
383 | |||
374 |
This is similar to running at a system prompt |
|
384 | This is similar to running at a system prompt ``python file args``, | |
375 | $ python file args\\ |
|
|||
376 | but with the advantage of giving you IPython's tracebacks, and of |
|
385 | but with the advantage of giving you IPython's tracebacks, and of | |
377 | loading all variables into your interactive namespace for further use |
|
386 | loading all variables into your interactive namespace for further use | |
378 | (unless -p is used, see below). |
|
387 | (unless -p is used, see below). | |
379 |
|
388 | |||
380 | The file is executed in a namespace initially consisting only of |
|
389 | The file is executed in a namespace initially consisting only of | |
381 | __name__=='__main__' and sys.argv constructed as indicated. It thus |
|
390 | ``__name__=='__main__'`` and sys.argv constructed as indicated. It thus | |
382 | sees its environment as if it were being run as a stand-alone program |
|
391 | sees its environment as if it were being run as a stand-alone program | |
383 | (except for sharing global objects such as previously imported |
|
392 | (except for sharing global objects such as previously imported | |
384 | modules). But after execution, the IPython interactive namespace gets |
|
393 | modules). But after execution, the IPython interactive namespace gets | |
@@ -390,33 +399,37 b' python-profiler package from non-free.""")' | |||||
390 | '*', '?', '[seq]' and '[!seq]' can be used. Additionally, |
|
399 | '*', '?', '[seq]' and '[!seq]' can be used. Additionally, | |
391 | tilde '~' will be expanded into user's home directory. Unlike |
|
400 | tilde '~' will be expanded into user's home directory. Unlike | |
392 | real shells, quotation does not suppress expansions. Use |
|
401 | real shells, quotation does not suppress expansions. Use | |
393 |
*two* back slashes (e.g. |
|
402 | *two* back slashes (e.g. ``\\\\*``) to suppress expansions. | |
394 | To completely disable these expansions, you can use -G flag. |
|
403 | To completely disable these expansions, you can use -G flag. | |
395 |
|
404 | |||
396 | Options: |
|
405 | Options: | |
397 |
|
406 | |||
398 | -n: __name__ is NOT set to '__main__', but to the running file's name |
|
407 | -n | |
|
408 | __name__ is NOT set to '__main__', but to the running file's name | |||
399 | without extension (as python does under import). This allows running |
|
409 | without extension (as python does under import). This allows running | |
400 | scripts and reloading the definitions in them without calling code |
|
410 | scripts and reloading the definitions in them without calling code | |
401 |
protected by an |
|
411 | protected by an ``if __name__ == "__main__"`` clause. | |
402 |
|
412 | |||
403 | -i: run the file in IPython's namespace instead of an empty one. This |
|
413 | -i | |
|
414 | run the file in IPython's namespace instead of an empty one. This | |||
404 | is useful if you are experimenting with code written in a text editor |
|
415 | is useful if you are experimenting with code written in a text editor | |
405 | which depends on variables defined interactively. |
|
416 | which depends on variables defined interactively. | |
406 |
|
417 | |||
407 | -e: ignore sys.exit() calls or SystemExit exceptions in the script |
|
418 | -e | |
|
419 | ignore sys.exit() calls or SystemExit exceptions in the script | |||
408 | being run. This is particularly useful if IPython is being used to |
|
420 | being run. This is particularly useful if IPython is being used to | |
409 | run unittests, which always exit with a sys.exit() call. In such |
|
421 | run unittests, which always exit with a sys.exit() call. In such | |
410 | cases you are interested in the output of the test results, not in |
|
422 | cases you are interested in the output of the test results, not in | |
411 | seeing a traceback of the unittest module. |
|
423 | seeing a traceback of the unittest module. | |
412 |
|
424 | |||
413 | -t: print timing information at the end of the run. IPython will give |
|
425 | -t | |
|
426 | print timing information at the end of the run. IPython will give | |||
414 | you an estimated CPU time consumption for your script, which under |
|
427 | you an estimated CPU time consumption for your script, which under | |
415 | Unix uses the resource module to avoid the wraparound problems of |
|
428 | Unix uses the resource module to avoid the wraparound problems of | |
416 | time.clock(). Under Unix, an estimate of time spent on system tasks |
|
429 | time.clock(). Under Unix, an estimate of time spent on system tasks | |
417 | is also given (for Windows platforms this is reported as 0.0). |
|
430 | is also given (for Windows platforms this is reported as 0.0). | |
418 |
|
431 | |||
419 | If -t is given, an additional -N<N> option can be given, where <N> |
|
432 | If -t is given, an additional ``-N<N>`` option can be given, where <N> | |
420 | must be an integer indicating how many times you want the script to |
|
433 | must be an integer indicating how many times you want the script to | |
421 | run. The final timing report will include total and per run results. |
|
434 | run. The final timing report will include total and per run results. | |
422 |
|
435 | |||
@@ -424,21 +437,22 b' python-profiler package from non-free.""")' | |||||
424 |
|
437 | |||
425 | In [1]: run -t uniq_stable |
|
438 | In [1]: run -t uniq_stable | |
426 |
|
439 | |||
427 |
IPython CPU timings (estimated): |
|
440 | IPython CPU timings (estimated): | |
428 |
User : 0.19597 s. |
|
441 | User : 0.19597 s. | |
429 |
System: 0.0 s. |
|
442 | System: 0.0 s. | |
430 |
|
443 | |||
431 | In [2]: run -t -N5 uniq_stable |
|
444 | In [2]: run -t -N5 uniq_stable | |
432 |
|
445 | |||
433 |
IPython CPU timings (estimated): |
|
446 | IPython CPU timings (estimated): | |
434 |
Total runs performed: 5 |
|
447 | Total runs performed: 5 | |
435 |
Times : Total Per run |
|
448 | Times : Total Per run | |
436 |
User : 0.910862 s, 0.1821724 s. |
|
449 | User : 0.910862 s, 0.1821724 s. | |
437 | System: 0.0 s, 0.0 s. |
|
450 | System: 0.0 s, 0.0 s. | |
438 |
|
451 | |||
439 | -d: run your program under the control of pdb, the Python debugger. |
|
452 | -d | |
|
453 | run your program under the control of pdb, the Python debugger. | |||
440 | This allows you to execute your program step by step, watch variables, |
|
454 | This allows you to execute your program step by step, watch variables, | |
441 | etc. Internally, what IPython does is similar to calling: |
|
455 | etc. Internally, what IPython does is similar to calling:: | |
442 |
|
456 | |||
443 | pdb.run('execfile("YOURFILENAME")') |
|
457 | pdb.run('execfile("YOURFILENAME")') | |
444 |
|
458 | |||
@@ -464,7 +478,8 b' python-profiler package from non-free.""")' | |||||
464 | can easily see pdb's full documentation with "import pdb;pdb.help()" |
|
478 | can easily see pdb's full documentation with "import pdb;pdb.help()" | |
465 | at a prompt. |
|
479 | at a prompt. | |
466 |
|
480 | |||
467 | -p: run program under the control of the Python profiler module (which |
|
481 | -p | |
|
482 | run program under the control of the Python profiler module (which | |||
468 | prints a detailed report of execution times, function calls, etc). |
|
483 | prints a detailed report of execution times, function calls, etc). | |
469 |
|
484 | |||
470 | You can pass other options after -p which affect the behavior of the |
|
485 | You can pass other options after -p which affect the behavior of the | |
@@ -481,7 +496,8 b' python-profiler package from non-free.""")' | |||||
481 | if the filename ends with .ipy, the file is run as ipython script, |
|
496 | if the filename ends with .ipy, the file is run as ipython script, | |
482 | just as if the commands were written on IPython prompt. |
|
497 | just as if the commands were written on IPython prompt. | |
483 |
|
498 | |||
484 | -m: specify module name to load instead of script path. Similar to |
|
499 | -m | |
|
500 | specify module name to load instead of script path. Similar to | |||
485 | the -m option for the python interpreter. Use this option last if you |
|
501 | the -m option for the python interpreter. Use this option last if you | |
486 | want to combine with other %run options. Unlike the python interpreter |
|
502 | want to combine with other %run options. Unlike the python interpreter | |
487 | only source modules are allowed no .pyc or .pyo files. |
|
503 | only source modules are allowed no .pyc or .pyo files. | |
@@ -491,7 +507,8 b' python-profiler package from non-free.""")' | |||||
491 |
|
507 | |||
492 | will run the example module. |
|
508 | will run the example module. | |
493 |
|
509 | |||
494 | -G: disable shell-like glob expansion of arguments. |
|
510 | -G | |
|
511 | disable shell-like glob expansion of arguments. | |||
495 |
|
512 | |||
496 | """ |
|
513 | """ | |
497 |
|
514 |
@@ -42,16 +42,27 b' class LoggingMagics(Magics):' | |||||
42 | history up to that point and then continues logging. |
|
42 | history up to that point and then continues logging. | |
43 |
|
43 | |||
44 | %logstart takes a second optional parameter: logging mode. This can be one |
|
44 | %logstart takes a second optional parameter: logging mode. This can be one | |
45 |
of (note that the modes are given unquoted): |
|
45 | of (note that the modes are given unquoted): | |
46 | append: well, that says it.\\ |
|
46 | ||
47 | backup: rename (if exists) to name~ and start name.\\ |
|
47 | append | |
48 | global: single logfile in your home dir, appended to.\\ |
|
48 | Keep logging at the end of any existing file. | |
49 | over : overwrite existing log.\\ |
|
49 | ||
50 | rotate: create rotating logs name.1~, name.2~, etc. |
|
50 | backup | |
|
51 | Rename any existing file to name~ and start name. | |||
|
52 | ||||
|
53 | global | |||
|
54 | Append to a single logfile in your home directory. | |||
|
55 | ||||
|
56 | over | |||
|
57 | Overwrite any existing log. | |||
|
58 | ||||
|
59 | rotate | |||
|
60 | Create rotating logs: name.1~, name.2~, etc. | |||
51 |
|
61 | |||
52 | Options: |
|
62 | Options: | |
53 |
|
63 | |||
54 | -o: log also IPython's output. In this mode, all commands which |
|
64 | -o | |
|
65 | log also IPython's output. In this mode, all commands which | |||
55 | generate an Out[NN] prompt are recorded to the logfile, right after |
|
66 | generate an Out[NN] prompt are recorded to the logfile, right after | |
56 |
their corresponding input line. |
|
67 | their corresponding input line. The output lines are always | |
57 | prepended with a '#[Out]# ' marker, so that the log remains valid |
|
68 | prepended with a '#[Out]# ' marker, so that the log remains valid | |
@@ -62,14 +73,17 b' class LoggingMagics(Magics):' | |||||
62 |
|
73 | |||
63 | awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py |
|
74 | awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py | |
64 |
|
75 | |||
65 | -r: log 'raw' input. Normally, IPython's logs contain the processed |
|
76 | -r | |
|
77 | log 'raw' input. Normally, IPython's logs contain the processed | |||
66 | input, so that user lines are logged in their final form, converted |
|
78 | input, so that user lines are logged in their final form, converted | |
67 | into valid Python. For example, %Exit is logged as |
|
79 | into valid Python. For example, %Exit is logged as | |
68 | _ip.magic("Exit"). If the -r flag is given, all input is logged |
|
80 | _ip.magic("Exit"). If the -r flag is given, all input is logged | |
69 | exactly as typed, with no transformations applied. |
|
81 | exactly as typed, with no transformations applied. | |
70 |
|
82 | |||
71 | -t: put timestamps before each input line logged (these are put in |
|
83 | -t | |
72 | comments).""" |
|
84 | put timestamps before each input line logged (these are put in | |
|
85 | comments). | |||
|
86 | """ | |||
73 |
|
87 | |||
74 | opts,par = self.parse_options(parameter_s,'ort') |
|
88 | opts,par = self.parse_options(parameter_s,'ort') | |
75 | log_output = 'o' in opts |
|
89 | log_output = 'o' in opts |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -325,9 +325,11 b" def snip_print(str,width = 75,print_full = 0,header = ''):" | |||||
325 | """Print a string snipping the midsection to fit in width. |
|
325 | """Print a string snipping the midsection to fit in width. | |
326 |
|
326 | |||
327 | print_full: mode control: |
|
327 | print_full: mode control: | |
|
328 | ||||
328 | - 0: only snip long strings |
|
329 | - 0: only snip long strings | |
329 | - 1: send to page() directly. |
|
330 | - 1: send to page() directly. | |
330 | - 2: snip long strings and ask for full length viewing with page() |
|
331 | - 2: snip long strings and ask for full length viewing with page() | |
|
332 | ||||
331 | Return 1 if snipping was necessary, 0 otherwise.""" |
|
333 | Return 1 if snipping was necessary, 0 otherwise.""" | |
332 |
|
334 | |||
333 | if print_full == 1: |
|
335 | if print_full == 1: |
@@ -8,7 +8,8 b' ColorTB class is a solution to that problem. It colors the different parts of a' | |||||
8 | traceback in a manner similar to what you would expect from a syntax-highlighting |
|
8 | traceback in a manner similar to what you would expect from a syntax-highlighting | |
9 | text editor. |
|
9 | text editor. | |
10 |
|
10 | |||
11 | Installation instructions for ColorTB: |
|
11 | Installation instructions for ColorTB:: | |
|
12 | ||||
12 | import sys,ultratb |
|
13 | import sys,ultratb | |
13 | sys.excepthook = ultratb.ColorTB() |
|
14 | sys.excepthook = ultratb.ColorTB() | |
14 |
|
15 | |||
@@ -21,7 +22,7 b' but kind of neat, and maybe useful for long-running programs that you believe' | |||||
21 | are bug-free. If a crash *does* occur in that type of program you want details. |
|
22 | are bug-free. If a crash *does* occur in that type of program you want details. | |
22 | Give it a shot--you'll love it or you'll hate it. |
|
23 | Give it a shot--you'll love it or you'll hate it. | |
23 |
|
24 | |||
24 | Note: |
|
25 | .. note:: | |
25 |
|
26 | |||
26 | The Verbose mode prints the variables currently visible where the exception |
|
27 | The Verbose mode prints the variables currently visible where the exception | |
27 | happened (shortening their strings if too long). This can potentially be |
|
28 | happened (shortening their strings if too long). This can potentially be | |
@@ -36,14 +37,17 b' Note:' | |||||
36 | Verbose). |
|
37 | Verbose). | |
37 |
|
38 | |||
38 |
|
39 | |||
39 | Installation instructions for ColorTB: |
|
40 | Installation instructions for ColorTB:: | |
|
41 | ||||
40 | import sys,ultratb |
|
42 | import sys,ultratb | |
41 | sys.excepthook = ultratb.VerboseTB() |
|
43 | sys.excepthook = ultratb.VerboseTB() | |
42 |
|
44 | |||
43 | Note: Much of the code in this module was lifted verbatim from the standard |
|
45 | Note: Much of the code in this module was lifted verbatim from the standard | |
44 | library module 'traceback.py' and Ka-Ping Yee's 'cgitb.py'. |
|
46 | library module 'traceback.py' and Ka-Ping Yee's 'cgitb.py'. | |
45 |
|
47 | |||
46 |
|
|
48 | Color schemes | |
|
49 | ------------- | |||
|
50 | ||||
47 | The colors are defined in the class TBTools through the use of the |
|
51 | The colors are defined in the class TBTools through the use of the | |
48 | ColorSchemeTable class. Currently the following exist: |
|
52 | ColorSchemeTable class. Currently the following exist: | |
49 |
|
53 |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
1 | NO CONTENT: modified file |
|
NO CONTENT: modified file |
@@ -19,7 +19,8 b' def cell_preprocessor(function):' | |||||
19 | Wrap a function to be executed on all cells of a notebook |
|
19 | Wrap a function to be executed on all cells of a notebook | |
20 |
|
20 | |||
21 | Wrapped Parameters |
|
21 | Wrapped Parameters | |
22 | ---------- |
|
22 | ------------------ | |
|
23 | ||||
23 | cell : NotebookNode cell |
|
24 | cell : NotebookNode cell | |
24 | Notebook cell being processed |
|
25 | Notebook cell being processed | |
25 | resources : dictionary |
|
26 | resources : dictionary |
@@ -44,8 +44,8 b' class AvoidUNCPath(object):' | |||||
44 | change and None otherwise, so that users can apply the necessary adjustment |
|
44 | change and None otherwise, so that users can apply the necessary adjustment | |
45 | to their system calls in the event of a change. |
|
45 | to their system calls in the event of a change. | |
46 |
|
46 | |||
47 | Example |
|
47 | Examples | |
48 | ------- |
|
48 | -------- | |
49 | :: |
|
49 | :: | |
50 | cmd = 'dir' |
|
50 | cmd = 'dir' | |
51 | with AvoidUNCPath() as path: |
|
51 | with AvoidUNCPath() as path: |
@@ -161,8 +161,8 b' class AvoidUNCPath(object):' | |||||
161 | change and None otherwise, so that users can apply the necessary adjustment |
|
161 | change and None otherwise, so that users can apply the necessary adjustment | |
162 | to their system calls in the event of a change. |
|
162 | to their system calls in the event of a change. | |
163 |
|
163 | |||
164 | Example |
|
164 | Examples | |
165 | ------- |
|
165 | -------- | |
166 | :: |
|
166 | :: | |
167 | cmd = 'dir' |
|
167 | cmd = 'dir' | |
168 | with AvoidUNCPath() as path: |
|
168 | with AvoidUNCPath() as path: |
@@ -69,12 +69,12 b' class CapturedIO(object):' | |||||
69 |
|
69 | |||
70 | Each instance `c` has three attributes: |
|
70 | Each instance `c` has three attributes: | |
71 |
|
71 | |||
72 |
|
|
72 | - ``c.stdout`` : standard output as a string | |
73 |
|
|
73 | - ``c.stderr`` : standard error as a string | |
74 |
|
|
74 | - ``c.outputs``: a list of rich display outputs | |
75 |
|
75 | |||
76 | Additionally, there's a `c.show()` method which will print all of the |
|
76 | Additionally, there's a ``c.show()`` method which will print all of the | |
77 | above in the same order, and can be invoked simply via `c()`. |
|
77 | above in the same order, and can be invoked simply via ``c()``. | |
78 | """ |
|
78 | """ | |
79 |
|
79 | |||
80 | def __init__(self, stdout, stderr, outputs=None): |
|
80 | def __init__(self, stdout, stderr, outputs=None): | |
@@ -105,8 +105,8 b' class CapturedIO(object):' | |||||
105 | def outputs(self): |
|
105 | def outputs(self): | |
106 | """A list of the captured rich display outputs, if any. |
|
106 | """A list of the captured rich display outputs, if any. | |
107 |
|
107 | |||
108 | If you have a CapturedIO object `c`, these can be displayed in IPython |
|
108 | If you have a CapturedIO object ``c``, these can be displayed in IPython | |
109 | using: |
|
109 | using:: | |
110 |
|
110 | |||
111 | from IPython.display import display |
|
111 | from IPython.display import display | |
112 | for o in c.outputs: |
|
112 | for o in c.outputs: |
@@ -27,8 +27,8 b' class preserve_keys(object):' | |||||
27 | which did not exist when entering the context manager will be |
|
27 | which did not exist when entering the context manager will be | |
28 | deleted. |
|
28 | deleted. | |
29 |
|
29 | |||
30 | Example |
|
30 | Examples | |
31 | ------- |
|
31 | -------- | |
32 |
|
32 | |||
33 | >>> d = {'a': 1, 'b': 2, 'c': 3} |
|
33 | >>> d = {'a': 1, 'b': 2, 'c': 3} | |
34 | >>> with preserve_keys(d, 'b', 'c', 'd'): |
|
34 | >>> with preserve_keys(d, 'b', 'c', 'd'): |
@@ -98,8 +98,10 b' def pkg_info(pkg_path):' | |||||
98 | def sys_info(): |
|
98 | def sys_info(): | |
99 | """Return useful information about IPython and the system, as a string. |
|
99 | """Return useful information about IPython and the system, as a string. | |
100 |
|
100 | |||
101 | Example |
|
101 | Examples | |
102 | ------- |
|
102 | -------- | |
|
103 | :: | |||
|
104 | ||||
103 | In [2]: print sys_info() |
|
105 | In [2]: print sys_info() | |
104 | {'commit_hash': '144fdae', # random |
|
106 | {'commit_hash': '144fdae', # random | |
105 | 'commit_source': 'repository', |
|
107 | 'commit_source': 'repository', |
General Comments 0
You need to be logged in to leave comments.
Login now