##// END OF EJS Templates
Manual updates
fperez -
Show More
@@ -1,725 +1,727 b''
1 1 # -*- coding: utf-8 -*-
2 2 """
3 3 IPython -- An enhanced Interactive Python
4 4
5 5 Requires Python 2.1 or better.
6 6
7 7 This file contains the main make_IPython() starter function.
8 8
9 $Id: ipmaker.py 802 2005-09-06 03:49:12Z fperez $"""
9 $Id: ipmaker.py 911 2005-10-08 07:59:40Z fperez $"""
10 10
11 11 #*****************************************************************************
12 12 # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
13 13 #
14 14 # Distributed under the terms of the BSD License. The full license is in
15 15 # the file COPYING, distributed as part of this software.
16 16 #*****************************************************************************
17 17
18 18 from IPython import Release
19 19 __author__ = '%s <%s>' % Release.authors['Fernando']
20 20 __license__ = Release.license
21 21 __version__ = Release.version
22 22
23 23 credits._Printer__data = """
24 24 Python: %s
25 25
26 26 IPython: Fernando Perez, Janko Hauser, Nathan Gray, and many users.
27 27 See http://ipython.scipy.org for more information.""" \
28 28 % credits._Printer__data
29 29
30 30 copyright._Printer__data += """
31 31
32 32 Copyright (c) 2001-2004 Fernando Perez, Janko Hauser, Nathan Gray.
33 33 All Rights Reserved."""
34 34
35 35 #****************************************************************************
36 36 # Required modules
37 37
38 38 # From the standard library
39 39 import __main__, __builtin__
40 40 import os,sys,types,re
41 41 from pprint import pprint,pformat
42 42
43 43 # Our own
44 44 from IPython import DPyGetOpt
45 45 from IPython.Struct import Struct
46 46 from IPython.OutputTrap import OutputTrap
47 47 from IPython.ConfigLoader import ConfigLoader
48 48 from IPython.iplib import InteractiveShell,qw_lol,import_fail_info
49 49 from IPython.usage import cmd_line_usage,interactive_usage
50 50 from IPython.Prompts import CachedOutput
51 51 from IPython.genutils import *
52 52
53 53 #-----------------------------------------------------------------------------
54 54 def make_IPython(argv=None,user_ns=None,debug=1,rc_override=None,
55 55 shell_class=InteractiveShell,embedded=False,**kw):
56 56 """This is a dump of IPython into a single function.
57 57
58 58 Later it will have to be broken up in a sensible manner.
59 59
60 60 Arguments:
61 61
62 62 - argv: a list similar to sys.argv[1:]. It should NOT contain the desired
63 63 script name, b/c DPyGetOpt strips the first argument only for the real
64 64 sys.argv.
65 65
66 66 - user_ns: a dict to be used as the user's namespace."""
67 67
68 68 #----------------------------------------------------------------------
69 69 # Defaults and initialization
70 70
71 71 # For developer debugging, deactivates crash handler and uses pdb.
72 72 DEVDEBUG = False
73 73
74 74 if argv is None:
75 75 argv = sys.argv
76 76
77 77 # __IP is the main global that lives throughout and represents the whole
78 78 # application. If the user redefines it, all bets are off as to what
79 79 # happens.
80 80
81 81 # __IP is the name of he global which the caller will have accessible as
82 82 # __IP.name. We set its name via the first parameter passed to
83 83 # InteractiveShell:
84 84
85 85 IP = shell_class('__IP',user_ns=user_ns,**kw)
86 86
87 87 # Put 'help' in the user namespace
88 88 from site import _Helper
89 89 IP.user_ns['help'] = _Helper()
90 90
91 91 if DEVDEBUG:
92 92 # For developer debugging only (global flag)
93 93 from IPython import ultraTB
94 94 sys.excepthook = ultraTB.VerboseTB(call_pdb=1)
95 95 else:
96 96 # IPython itself shouldn't crash. This will produce a detailed
97 97 # post-mortem if it does
98 98 from IPython import CrashHandler
99 99 sys.excepthook = CrashHandler.CrashHandler(IP)
100 100
101 101 IP.BANNER_PARTS = ['Python %s\n'
102 102 'Type "copyright", "credits" or "license" '
103 103 'for more information.\n'
104 104 % (sys.version.split('\n')[0],),
105 105 "IPython %s -- An enhanced Interactive Python."
106 106 % (__version__,),
107 107 """? -> Introduction to IPython's features.
108 108 %magic -> Information about IPython's 'magic' % functions.
109 109 help -> Python's own help system.
110 110 object? -> Details about 'object'. ?object also works, ?? prints more.
111 111 """ ]
112 112
113 113 IP.usage = interactive_usage
114 114
115 # Platform-dependent suffix and directory names
115 # Platform-dependent suffix and directory names. We use _ipython instead
116 # of .ipython under win32 b/c there's software that breaks with .named
117 # directories on that platform.
116 118 if os.name == 'posix':
117 119 rc_suffix = ''
118 120 ipdir_def = '.ipython'
119 121 else:
120 122 rc_suffix = '.ini'
121 123 ipdir_def = '_ipython'
122 124
123 125 # default directory for configuration
124 126 ipythondir = os.path.abspath(os.environ.get('IPYTHONDIR',
125 127 os.path.join(IP.home_dir,ipdir_def)))
126 128
127 129 # we need the directory where IPython itself is installed
128 130 import IPython
129 131 IPython_dir = os.path.dirname(IPython.__file__)
130 132 del IPython
131 133
132 134 #-------------------------------------------------------------------------
133 135 # Command line handling
134 136
135 137 # Valid command line options (uses DPyGetOpt syntax, like Perl's
136 138 # GetOpt::Long)
137 139
138 140 # Any key not listed here gets deleted even if in the file (like session
139 141 # or profile). That's deliberate, to maintain the rc namespace clean.
140 142
141 143 # Each set of options appears twice: under _conv only the names are
142 144 # listed, indicating which type they must be converted to when reading the
143 145 # ipythonrc file. And under DPyGetOpt they are listed with the regular
144 146 # DPyGetOpt syntax (=s,=i,:f,etc).
145 147
146 148 # Make sure there's a space before each end of line (they get auto-joined!)
147 149 cmdline_opts = ('autocall! autoindent! automagic! banner! cache_size|cs=i '
148 150 'c=s classic|cl color_info! colors=s confirm_exit! '
149 151 'debug! deep_reload! editor=s log|l messages! nosep pdb! '
150 152 'pprint! prompt_in1|pi1=s prompt_in2|pi2=s prompt_out|po=s '
151 153 'quick screen_length|sl=i prompts_pad_left=i '
152 154 'logfile|lf=s logplay|lp=s profile|p=s '
153 155 'readline! readline_merge_completions! '
154 156 'readline_omit__names! '
155 157 'rcfile=s separate_in|si=s separate_out|so=s '
156 158 'separate_out2|so2=s xmode=s '
157 159 'magic_docstrings system_verbose! '
158 160 'multi_line_specials!')
159 161
160 162 # Options that can *only* appear at the cmd line (not in rcfiles).
161 163
162 164 # The "ignore" option is a kludge so that Emacs buffers don't crash, since
163 165 # the 'C-c !' command in emacs automatically appends a -i option at the end.
164 166 cmdline_only = ('help ignore|i ipythondir=s Version upgrade '
165 167 'gthread! qthread! wthread! pylab! tk!')
166 168
167 169 # Build the actual name list to be used by DPyGetOpt
168 170 opts_names = qw(cmdline_opts) + qw(cmdline_only)
169 171
170 172 # Set sensible command line defaults.
171 173 # This should have everything from cmdline_opts and cmdline_only
172 174 opts_def = Struct(autocall = 1,
173 175 autoindent=0,
174 176 automagic = 1,
175 177 banner = 1,
176 178 cache_size = 1000,
177 179 c = '',
178 180 classic = 0,
179 181 colors = 'NoColor',
180 182 color_info = 0,
181 183 confirm_exit = 1,
182 184 debug = 0,
183 185 deep_reload = 0,
184 186 editor = '0',
185 187 help = 0,
186 188 ignore = 0,
187 189 ipythondir = ipythondir,
188 190 log = 0,
189 191 logfile = '',
190 192 logplay = '',
191 193 multi_line_specials = 1,
192 194 messages = 1,
193 195 nosep = 0,
194 196 pdb = 0,
195 197 pprint = 0,
196 198 profile = '',
197 199 prompt_in1 = 'In [\\#]: ',
198 200 prompt_in2 = ' .\\D.: ',
199 201 prompt_out = 'Out[\\#]: ',
200 202 prompts_pad_left = 1,
201 203 quick = 0,
202 204 readline = 1,
203 205 readline_merge_completions = 1,
204 206 readline_omit__names = 0,
205 207 rcfile = 'ipythonrc' + rc_suffix,
206 208 screen_length = 0,
207 209 separate_in = '\n',
208 210 separate_out = '\n',
209 211 separate_out2 = '',
210 212 system_verbose = 0,
211 213 gthread = 0,
212 214 qthread = 0,
213 215 wthread = 0,
214 216 pylab = 0,
215 217 tk = 0,
216 218 upgrade = 0,
217 219 Version = 0,
218 220 xmode = 'Verbose',
219 221 magic_docstrings = 0, # undocumented, for doc generation
220 222 )
221 223
222 224 # Things that will *only* appear in rcfiles (not at the command line).
223 225 # Make sure there's a space before each end of line (they get auto-joined!)
224 226 rcfile_opts = { qwflat: 'include import_mod import_all execfile ',
225 227 qw_lol: 'import_some ',
226 228 # for things with embedded whitespace:
227 229 list_strings:'execute alias readline_parse_and_bind ',
228 230 # Regular strings need no conversion:
229 231 None:'readline_remove_delims ',
230 232 }
231 233 # Default values for these
232 234 rc_def = Struct(include = [],
233 235 import_mod = [],
234 236 import_all = [],
235 237 import_some = [[]],
236 238 execute = [],
237 239 execfile = [],
238 240 alias = [],
239 241 readline_parse_and_bind = [],
240 242 readline_remove_delims = '',
241 243 )
242 244
243 245 # Build the type conversion dictionary from the above tables:
244 246 typeconv = rcfile_opts.copy()
245 247 typeconv.update(optstr2types(cmdline_opts))
246 248
247 249 # FIXME: the None key appears in both, put that back together by hand. Ugly!
248 250 typeconv[None] += ' ' + rcfile_opts[None]
249 251
250 252 # Remove quotes at ends of all strings (used to protect spaces)
251 253 typeconv[unquote_ends] = typeconv[None]
252 254 del typeconv[None]
253 255
254 256 # Build the list we'll use to make all config decisions with defaults:
255 257 opts_all = opts_def.copy()
256 258 opts_all.update(rc_def)
257 259
258 260 # Build conflict resolver for recursive loading of config files:
259 261 # - preserve means the outermost file maintains the value, it is not
260 262 # overwritten if an included file has the same key.
261 263 # - add_flip applies + to the two values, so it better make sense to add
262 264 # those types of keys. But it flips them first so that things loaded
263 265 # deeper in the inclusion chain have lower precedence.
264 266 conflict = {'preserve': ' '.join([ typeconv[int],
265 267 typeconv[unquote_ends] ]),
266 268 'add_flip': ' '.join([ typeconv[qwflat],
267 269 typeconv[qw_lol],
268 270 typeconv[list_strings] ])
269 271 }
270 272
271 273 # Now actually process the command line
272 274 getopt = DPyGetOpt.DPyGetOpt()
273 275 getopt.setIgnoreCase(0)
274 276
275 277 getopt.parseConfiguration(opts_names)
276 278
277 279 try:
278 280 getopt.processArguments(argv)
279 281 except:
280 282 print cmd_line_usage
281 283 warn('\nError in Arguments: ' + `sys.exc_value`)
282 284 sys.exit()
283 285
284 286 # convert the options dict to a struct for much lighter syntax later
285 287 opts = Struct(getopt.optionValues)
286 288 args = getopt.freeValues
287 289
288 290 # this is the struct (which has default values at this point) with which
289 291 # we make all decisions:
290 292 opts_all.update(opts)
291 293
292 294 # Options that force an immediate exit
293 295 if opts_all.help:
294 296 page(cmd_line_usage)
295 297 sys.exit()
296 298
297 299 if opts_all.Version:
298 300 print __version__
299 301 sys.exit()
300 302
301 303 if opts_all.magic_docstrings:
302 304 IP.magic_magic('-latex')
303 305 sys.exit()
304 306
305 307 # Create user config directory if it doesn't exist. This must be done
306 308 # *after* getting the cmd line options.
307 309 if not os.path.isdir(opts_all.ipythondir):
308 310 IP.user_setup(opts_all.ipythondir,rc_suffix,'install')
309 311
310 312 # upgrade user config files while preserving a copy of the originals
311 313 if opts_all.upgrade:
312 314 IP.user_setup(opts_all.ipythondir,rc_suffix,'upgrade')
313 315
314 316 # check mutually exclusive options in the *original* command line
315 317 mutex_opts(opts,[qw('log logfile'),qw('rcfile profile'),
316 318 qw('classic profile'),qw('classic rcfile')])
317 319
318 320 # default logfilename used when -log is called.
319 321 IP.LOGDEF = 'ipython.log'
320 322
321 323 #---------------------------------------------------------------------------
322 324 # Log replay
323 325
324 326 # if -logplay, we need to 'become' the other session. That basically means
325 327 # replacing the current command line environment with that of the old
326 328 # session and moving on.
327 329
328 330 # this is needed so that later we know we're in session reload mode, as
329 331 # opts_all will get overwritten:
330 332 load_logplay = 0
331 333
332 334 if opts_all.logplay:
333 335 load_logplay = opts_all.logplay
334 336 opts_debug_save = opts_all.debug
335 337 try:
336 338 logplay = open(opts_all.logplay)
337 339 except IOError:
338 340 if opts_all.debug: IP.InteractiveTB()
339 341 warn('Could not open logplay file '+`opts_all.logplay`)
340 342 # restore state as if nothing had happened and move on, but make
341 343 # sure that later we don't try to actually load the session file
342 344 logplay = None
343 345 load_logplay = 0
344 346 del opts_all.logplay
345 347 else:
346 348 try:
347 349 logplay.readline()
348 350 logplay.readline();
349 351 # this reloads that session's command line
350 352 cmd = logplay.readline()[6:]
351 353 exec cmd
352 354 # restore the true debug flag given so that the process of
353 355 # session loading itself can be monitored.
354 356 opts.debug = opts_debug_save
355 357 # save the logplay flag so later we don't overwrite the log
356 358 opts.logplay = load_logplay
357 359 # now we must update our own structure with defaults
358 360 opts_all.update(opts)
359 361 # now load args
360 362 cmd = logplay.readline()[6:]
361 363 exec cmd
362 364 logplay.close()
363 365 except:
364 366 logplay.close()
365 367 if opts_all.debug: IP.InteractiveTB()
366 368 warn("Logplay file lacking full configuration information.\n"
367 369 "I'll try to read it, but some things may not work.")
368 370
369 371 #-------------------------------------------------------------------------
370 372 # set up output traps: catch all output from files, being run, modules
371 373 # loaded, etc. Then give it to the user in a clean form at the end.
372 374
373 375 msg_out = 'Output messages. '
374 376 msg_err = 'Error messages. '
375 377 msg_sep = '\n'
376 378 msg = Struct(config = OutputTrap('Configuration Loader',msg_out,
377 379 msg_err,msg_sep,debug,
378 380 quiet_out=1),
379 381 user_exec = OutputTrap('User File Execution',msg_out,
380 382 msg_err,msg_sep,debug),
381 383 logplay = OutputTrap('Log Loader',msg_out,
382 384 msg_err,msg_sep,debug),
383 385 summary = ''
384 386 )
385 387
386 388 #-------------------------------------------------------------------------
387 389 # Process user ipythonrc-type configuration files
388 390
389 391 # turn on output trapping and log to msg.config
390 392 # remember that with debug on, trapping is actually disabled
391 393 msg.config.trap_all()
392 394
393 395 # look for rcfile in current or default directory
394 396 try:
395 397 opts_all.rcfile = filefind(opts_all.rcfile,opts_all.ipythondir)
396 398 except IOError:
397 399 if opts_all.debug: IP.InteractiveTB()
398 400 warn('Configuration file %s not found. Ignoring request.'
399 401 % (opts_all.rcfile) )
400 402
401 403 # 'profiles' are a shorthand notation for config filenames
402 404 if opts_all.profile:
403 405 try:
404 406 opts_all.rcfile = filefind('ipythonrc-' + opts_all.profile
405 407 + rc_suffix,
406 408 opts_all.ipythondir)
407 409 except IOError:
408 410 if opts_all.debug: IP.InteractiveTB()
409 411 opts.profile = '' # remove profile from options if invalid
410 412 warn('Profile configuration file %s not found. Ignoring request.'
411 413 % (opts_all.profile) )
412 414
413 415 # load the config file
414 416 rcfiledata = None
415 417 if opts_all.quick:
416 418 print 'Launching IPython in quick mode. No config file read.'
417 419 elif opts_all.classic:
418 420 print 'Launching IPython in classic mode. No config file read.'
419 421 elif opts_all.rcfile:
420 422 try:
421 423 cfg_loader = ConfigLoader(conflict)
422 424 rcfiledata = cfg_loader.load(opts_all.rcfile,typeconv,
423 425 'include',opts_all.ipythondir,
424 426 purge = 1,
425 427 unique = conflict['preserve'])
426 428 except:
427 429 IP.InteractiveTB()
428 430 warn('Problems loading configuration file '+
429 431 `opts_all.rcfile`+
430 432 '\nStarting with default -bare bones- configuration.')
431 433 else:
432 434 warn('No valid configuration file found in either currrent directory\n'+
433 435 'or in the IPython config. directory: '+`opts_all.ipythondir`+
434 436 '\nProceeding with internal defaults.')
435 437
436 438 #------------------------------------------------------------------------
437 439 # Set exception handlers in mode requested by user.
438 440 otrap = OutputTrap(trap_out=1) # trap messages from magic_xmode
439 441 IP.magic_xmode(opts_all.xmode)
440 442 otrap.release_out()
441 443
442 444 #------------------------------------------------------------------------
443 445 # Execute user config
444 446
445 447 # first, create a valid config structure with the right precedence order:
446 448 # defaults < rcfile < command line
447 449 IP.rc = rc_def.copy()
448 450 IP.rc.update(opts_def)
449 451 if rcfiledata:
450 452 # now we can update
451 453 IP.rc.update(rcfiledata)
452 454 IP.rc.update(opts)
453 455 IP.rc.update(rc_override)
454 456
455 457 # Store the original cmd line for reference:
456 458 IP.rc.opts = opts
457 459 IP.rc.args = args
458 460
459 461 # create a *runtime* Struct like rc for holding parameters which may be
460 462 # created and/or modified by runtime user extensions.
461 463 IP.runtime_rc = Struct()
462 464
463 465 # from this point on, all config should be handled through IP.rc,
464 466 # opts* shouldn't be used anymore.
465 467
466 468 # add personal .ipython dir to sys.path so that users can put things in
467 469 # there for customization
468 470 sys.path.append(IP.rc.ipythondir)
469 471 sys.path.insert(0, '') # add . to sys.path. Fix from Prabhu Ramachandran
470 472
471 473 # update IP.rc with some special things that need manual
472 474 # tweaks. Basically options which affect other options. I guess this
473 475 # should just be written so that options are fully orthogonal and we
474 476 # wouldn't worry about this stuff!
475 477
476 478 if IP.rc.classic:
477 479 IP.rc.quick = 1
478 480 IP.rc.cache_size = 0
479 481 IP.rc.pprint = 0
480 482 IP.rc.prompt_in1 = '>>> '
481 483 IP.rc.prompt_in2 = '... '
482 484 IP.rc.prompt_out = ''
483 485 IP.rc.separate_in = IP.rc.separate_out = IP.rc.separate_out2 = '0'
484 486 IP.rc.colors = 'NoColor'
485 487 IP.rc.xmode = 'Plain'
486 488
487 489 # configure readline
488 490 # Define the history file for saving commands in between sessions
489 491 if IP.rc.profile:
490 492 histfname = 'history-%s' % IP.rc.profile
491 493 else:
492 494 histfname = 'history'
493 495 IP.histfile = os.path.join(opts_all.ipythondir,histfname)
494 496 # Load readline proper
495 497 if IP.rc.readline:
496 498 IP.init_readline()
497 499
498 500 # update exception handlers with rc file status
499 501 otrap.trap_out() # I don't want these messages ever.
500 502 IP.magic_xmode(IP.rc.xmode)
501 503 otrap.release_out()
502 504
503 505 # activate logging if requested and not reloading a log
504 506 if IP.rc.logplay:
505 507 IP.magic_logstart(IP.rc.logplay + ' append')
506 508 elif IP.rc.logfile:
507 509 IP.magic_logstart(IP.rc.logfile)
508 510 elif IP.rc.log:
509 511 IP.magic_logstart()
510 512
511 513 # find user editor so that it we don't have to look it up constantly
512 514 if IP.rc.editor.strip()=='0':
513 515 try:
514 516 ed = os.environ['EDITOR']
515 517 except KeyError:
516 518 if os.name == 'posix':
517 519 ed = 'vi' # the only one guaranteed to be there!
518 520 else:
519 521 ed = 'notepad' # same in Windows!
520 522 IP.rc.editor = ed
521 523
522 524 # Recursive reload
523 525 try:
524 526 from IPython import deep_reload
525 527 if IP.rc.deep_reload:
526 528 __builtin__.reload = deep_reload.reload
527 529 else:
528 530 __builtin__.dreload = deep_reload.reload
529 531 del deep_reload
530 532 except ImportError:
531 533 pass
532 534
533 535 # Save the current state of our namespace so that the interactive shell
534 536 # can later know which variables have been created by us from config files
535 537 # and loading. This way, loading a file (in any way) is treated just like
536 538 # defining things on the command line, and %who works as expected.
537 539
538 540 # DON'T do anything that affects the namespace beyond this point!
539 541 IP.internal_ns = __main__.__dict__.copy()
540 542
541 543 #IP.internal_ns.update(locals()) # so our stuff doesn't show up in %who
542 544
543 545 # Now run through the different sections of the users's config
544 546 if IP.rc.debug:
545 547 print 'Trying to execute the following configuration structure:'
546 548 print '(Things listed first are deeper in the inclusion tree and get'
547 549 print 'loaded first).\n'
548 550 pprint(IP.rc.__dict__)
549 551
550 552 for mod in IP.rc.import_mod:
551 553 try:
552 554 exec 'import '+mod in IP.user_ns
553 555 except :
554 556 IP.InteractiveTB()
555 557 import_fail_info(mod)
556 558
557 559 for mod_fn in IP.rc.import_some:
558 560 if mod_fn == []: break
559 561 mod,fn = mod_fn[0],','.join(mod_fn[1:])
560 562 try:
561 563 exec 'from '+mod+' import '+fn in IP.user_ns
562 564 except :
563 565 IP.InteractiveTB()
564 566 import_fail_info(mod,fn)
565 567
566 568 for mod in IP.rc.import_all:
567 569 try:
568 570 exec 'from '+mod+' import *' in IP.user_ns
569 571 except :
570 572 IP.InteractiveTB()
571 573 import_fail_info(mod)
572 574
573 575 for code in IP.rc.execute:
574 576 try:
575 577 exec code in IP.user_ns
576 578 except:
577 579 IP.InteractiveTB()
578 580 warn('Failure executing code: ' + `code`)
579 581
580 582 # Execute the files the user wants in ipythonrc
581 583 for file in IP.rc.execfile:
582 584 try:
583 585 file = filefind(file,sys.path+[IPython_dir])
584 586 except IOError:
585 587 warn(itpl('File $file not found. Skipping it.'))
586 588 else:
587 589 IP.safe_execfile(os.path.expanduser(file),IP.user_ns)
588 590
589 591 # Load user aliases
590 592 for alias in IP.rc.alias:
591 593 IP.magic_alias(alias)
592 594
593 595 # release stdout and stderr and save config log into a global summary
594 596 msg.config.release_all()
595 597 if IP.rc.messages:
596 598 msg.summary += msg.config.summary_all()
597 599
598 600 #------------------------------------------------------------------------
599 601 # Setup interactive session
600 602
601 603 # Now we should be fully configured. We can then execute files or load
602 604 # things only needed for interactive use. Then we'll open the shell.
603 605
604 606 # Take a snapshot of the user namespace before opening the shell. That way
605 607 # we'll be able to identify which things were interactively defined and
606 608 # which were defined through config files.
607 609 IP.user_config_ns = IP.user_ns.copy()
608 610
609 611 # Force reading a file as if it were a session log. Slower but safer.
610 612 if load_logplay:
611 613 print 'Replaying log...'
612 614 try:
613 615 if IP.rc.debug:
614 616 logplay_quiet = 0
615 617 else:
616 618 logplay_quiet = 1
617 619
618 620 msg.logplay.trap_all()
619 621 IP.safe_execfile(load_logplay,IP.user_ns,
620 622 islog = 1, quiet = logplay_quiet)
621 623 msg.logplay.release_all()
622 624 if IP.rc.messages:
623 625 msg.summary += msg.logplay.summary_all()
624 626 except:
625 627 warn('Problems replaying logfile %s.' % load_logplay)
626 628 IP.InteractiveTB()
627 629
628 630 # Load remaining files in command line
629 631 msg.user_exec.trap_all()
630 632
631 633 # Do NOT execute files named in the command line as scripts to be loaded
632 634 # by embedded instances. Doing so has the potential for an infinite
633 635 # recursion if there are exceptions thrown in the process.
634 636
635 637 # XXX FIXME: the execution of user files should be moved out to after
636 638 # ipython is fully initialized, just as if they were run via %run at the
637 639 # ipython prompt. This would also give them the benefit of ipython's
638 640 # nice tracebacks.
639 641
640 642 if not embedded and IP.rc.args:
641 643 name_save = IP.user_ns['__name__']
642 644 IP.user_ns['__name__'] = '__main__'
643 645 try:
644 646 # Set our own excepthook in case the user code tries to call it
645 647 # directly. This prevents triggering the IPython crash handler.
646 648 old_excepthook,sys.excepthook = sys.excepthook, IP.excepthook
647 649 for run in args:
648 650 IP.safe_execfile(run,IP.user_ns)
649 651 finally:
650 652 # Reset our crash handler in place
651 653 sys.excepthook = old_excepthook
652 654
653 655 IP.user_ns['__name__'] = name_save
654 656
655 657 msg.user_exec.release_all()
656 658 if IP.rc.messages:
657 659 msg.summary += msg.user_exec.summary_all()
658 660
659 661 # since we can't specify a null string on the cmd line, 0 is the equivalent:
660 662 if IP.rc.nosep:
661 663 IP.rc.separate_in = IP.rc.separate_out = IP.rc.separate_out2 = '0'
662 664 if IP.rc.separate_in == '0': IP.rc.separate_in = ''
663 665 if IP.rc.separate_out == '0': IP.rc.separate_out = ''
664 666 if IP.rc.separate_out2 == '0': IP.rc.separate_out2 = ''
665 667 IP.rc.separate_in = IP.rc.separate_in.replace('\\n','\n')
666 668 IP.rc.separate_out = IP.rc.separate_out.replace('\\n','\n')
667 669 IP.rc.separate_out2 = IP.rc.separate_out2.replace('\\n','\n')
668 670
669 671 # Determine how many lines at the bottom of the screen are needed for
670 672 # showing prompts, so we can know wheter long strings are to be printed or
671 673 # paged:
672 674 num_lines_bot = IP.rc.separate_in.count('\n')+1
673 675 IP.rc.screen_length = IP.rc.screen_length - num_lines_bot
674 676 # Initialize cache, set in/out prompts and printing system
675 677 IP.outputcache = CachedOutput(IP.rc.cache_size,
676 678 IP.rc.pprint,
677 679 input_sep = IP.rc.separate_in,
678 680 output_sep = IP.rc.separate_out,
679 681 output_sep2 = IP.rc.separate_out2,
680 682 ps1 = IP.rc.prompt_in1,
681 683 ps2 = IP.rc.prompt_in2,
682 684 ps_out = IP.rc.prompt_out,
683 685 user_ns = IP.user_ns,
684 686 input_hist = IP.input_hist,
685 687 pad_left = IP.rc.prompts_pad_left)
686 688
687 689 # Set user colors (don't do it in the constructor above so that it doesn't
688 690 # crash if colors option is invalid)
689 691 IP.magic_colors(IP.rc.colors)
690 692
691 693 # user may have over-ridden the default print hook:
692 694 try:
693 695 IP.outputcache.__class__.display = IP.hooks.display
694 696 except AttributeError:
695 697 pass
696 698
697 699 # Set calling of pdb on exceptions
698 700 IP.InteractiveTB.call_pdb = IP.rc.pdb
699 701
700 702 # I don't like assigning globally to sys, because it means when embedding
701 703 # instances, each embedded instance overrides the previous choice. But
702 704 # sys.displayhook seems to be called internally by exec, so I don't see a
703 705 # way around it.
704 706 sys.displayhook = IP.outputcache
705 707
706 708 # we need to know globally if we're caching i/o or not
707 709 IP.do_full_cache = IP.outputcache.do_full_cache
708 710
709 711 # configure startup banner
710 712 if IP.rc.c: # regular python doesn't print the banner with -c
711 713 IP.rc.banner = 0
712 714 if IP.rc.banner:
713 715 IP.BANNER = '\n'.join(IP.BANNER_PARTS)
714 716 else:
715 717 IP.BANNER = ''
716 718
717 719 if IP.rc.profile: IP.BANNER += '\nIPython profile: '+IP.rc.profile+'\n'
718 720
719 721 # add message log (possibly empty)
720 722 IP.BANNER += msg.summary
721 723
722 724 IP.post_config_initialization()
723 725
724 726 return IP
725 727 #************************ end of file <ipmaker.py> **************************
@@ -1,8928 +1,8964 b''
1 1 #LyX 1.3 created this file. For more info see http://www.lyx.org/
2 2 \lyxformat 221
3 3 \textclass article
4 4 \begin_preamble
5 5 %\usepackage{ae,aecompl}
6 6 \usepackage{color}
7 7
8 8 % A few colors to replace the defaults for certain link types
9 9 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
10 10 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
11 11 \definecolor{darkred}{rgb}{.52,0.08,0.01}
12 12 \definecolor{darkgreen}{rgb}{.12,.54,.11}
13 13
14 14 % Use and configure listings package for nicely formatted code
15 15 \usepackage{listings}
16 16 \lstset{
17 17 language=Python,
18 18 basicstyle=\small\ttfamily,
19 19 commentstyle=\ttfamily\color{blue},
20 20 stringstyle=\ttfamily\color{darkorange},
21 21 showstringspaces=false,
22 22 breaklines=true,
23 23 postbreak = \space\dots
24 24 }
25 25
26 26 \usepackage[%pdftex, % needed for pdflatex
27 27 breaklinks=true, % so long urls are correctly broken across lines
28 28 colorlinks=true,
29 29 urlcolor=blue,
30 30 linkcolor=darkred,
31 31 citecolor=darkgreen,
32 32 ]{hyperref}
33 33
34 34 \usepackage{html}
35 35
36 36 % This helps prevent overly long lines that stretch beyond the margins
37 37 \sloppy
38
39 % Define a \codelist command which either uses listings for latex, or
40 % plain verbatim for html (since latex2html doesn't understand the
41 % listings package).
42 \usepackage{verbatim}
43 \newcommand{\codelist}[1] {
44 \latex{\lstinputlisting{#1}}
45 \html{\verbatiminput{#1}}
46 }
38 47 \end_preamble
39 48 \language english
40 49 \inputencoding latin1
41 50 \fontscheme palatino
42 51 \graphics default
43 52 \paperfontsize 10
44 53 \spacing single
45 54 \papersize Default
46 55 \paperpackage a4
47 56 \use_geometry 1
48 57 \use_amsmath 0
49 58 \use_natbib 0
50 59 \use_numerical_citations 0
51 60 \paperorientation portrait
52 61 \leftmargin 1.1in
53 62 \topmargin 1in
54 63 \rightmargin 1.1in
55 64 \bottommargin 1in
56 65 \secnumdepth 3
57 66 \tocdepth 3
58 67 \paragraph_separation skip
59 68 \defskip medskip
60 69 \quotes_language english
61 70 \quotes_times 2
62 71 \papercolumns 1
63 72 \papersides 1
64 73 \paperpagestyle fancy
65 74
66 75 \layout Title
67 76
68 77 IPython
69 78 \newline
70 79
71 80 \size larger
72 81 An enhanced Interactive Python
73 82 \size large
74 83
75 84 \newline
76 85 User Manual, v.
77 86 __version__
78 87 \layout Author
79 88
80 89 Fernando PοΏ½rez
81 90 \layout Standard
82 91
83 92
84 93 \begin_inset ERT
85 94 status Collapsed
86 95
87 96 \layout Standard
88 97
89 98 \backslash
90 99 latex{
91 100 \end_inset
92 101
93 102
94 103 \begin_inset LatexCommand \tableofcontents{}
95 104
96 105 \end_inset
97 106
98 107
99 108 \begin_inset ERT
100 109 status Collapsed
101 110
102 111 \layout Standard
103 112 }
104 113 \end_inset
105 114
106 115
107 116 \layout Standard
108 117
109 118
110 119 \begin_inset ERT
111 120 status Open
112 121
113 122 \layout Standard
114 123
115 124 \backslash
116 125 html{
117 126 \backslash
118 127 bodytext{bgcolor=#ffffff}}
119 128 \end_inset
120 129
121 130
122 131 \layout Section
123 132 \pagebreak_top
124 133 Overview
125 134 \layout Standard
126 135
127 136 One of Python's most useful features is its interactive interpreter.
128 137 This system allows very fast testing of ideas without the overhead of creating
129 138 test files as is typical in most programming languages.
130 139 However, the interpreter supplied with the standard Python distribution
131 140 is somewhat limited for extended interactive use.
132 141 \layout Standard
133 142
134 143 IPython is a free software project (released under the BSD license) which
135 144 tries to:
136 145 \layout Enumerate
137 146
138 147 Provide an interactive shell superior to Python's default.
139 148 IPython has many features for object introspection, system shell access,
140 149 and its own special command system for adding functionality when working
141 150 interactively.
142 151 It tries to be a very efficient environment both for Python code development
143 152 and for exploration of problems using Python objects (in situations like
144 153 data analysis).
145 154 \layout Enumerate
146 155
147 156 Serve as an embeddable, ready to use interpreter for your own programs.
148 157 IPython can be started with a single call from inside another program,
149 158 providing access to the current namespace.
150 159 This can be very useful both for debugging purposes and for situations
151 160 where a blend of batch-processing and interactive exploration are needed.
152 161 \layout Enumerate
153 162
154 163 Offer a flexible framework which can be used as the base environment for
155 164 other systems with Python as the underlying language.
156 165 Specifically scientific environments like Mathematica, IDL and Matlab inspired
157 166 its design, but similar ideas can be useful in many fields.
158 167 \layout Subsection
159 168
160 169 Main features
161 170 \layout Itemize
162 171
163 172 Dynamic object introspection.
164 173 One can access docstrings, function definition prototypes, source code,
165 174 source files and other details of any object accessible to the interpreter
166 175 with a single keystroke (`
167 176 \family typewriter
168 177 ?
169 178 \family default
170 179 ').
171 180 \layout Itemize
172 181
173 182 Completion in the local namespace, by typing TAB at the prompt.
174 183 This works for keywords, methods, variables and files in the current directory.
175 184 This is supported via the readline library, and full access to configuring
176 185 readline's behavior is provided.
177 186 \layout Itemize
178 187
179 188 Numbered input/output prompts with command history (persistent across sessions
180 189 and tied to each profile), full searching in this history and caching of
181 190 all input and output.
182 191 \layout Itemize
183 192
184 193 User-extensible `magic' commands.
185 194 A set of commands prefixed with
186 195 \family typewriter
187 196 %
188 197 \family default
189 198 is available for controlling IPython itself and provides directory control,
190 199 namespace information and many aliases to common system shell commands.
191 200 \layout Itemize
192 201
193 202 Alias facility for defining your own system aliases.
194 203 \layout Itemize
195 204
196 205 Complete system shell access.
197 206 Lines starting with ! are passed directly to the system shell, and using
198 207 !! captures shell output into python variables for further use.
199 208 \layout Itemize
200 209
201 210 All calls to the system (via aliases or via !) have their standard output/error
202 211 automatically stored as strings, and also available as lists.
203 212 \layout Itemize
204 213
205 214 Background execution of Python commands in a separate thread.
206 215 IPython has an internal job manager called
207 216 \family typewriter
208 217 jobs
209 218 \family default
210 219 , and a conveninence backgrounding magic function called
211 220 \family typewriter
212 221 %bg
213 222 \family default
214 223 .
215 224 \layout Itemize
216 225
217 226 The ability to expand python variables when calling the system shell.
218 227 In a shell command, any python variable prefixed with
219 228 \family typewriter
220 229 $
221 230 \family default
222 231 is expanded.
223 232 A double
224 233 \family typewriter
225 234 $$
226 235 \family default
227 236 allows passing a literal
228 237 \family typewriter
229 238 $
230 239 \family default
231 240 to the shell (for access to shell and environment variables like
232 241 \family typewriter
233 242 $PATH
234 243 \family default
235 244 ).
236 245 \layout Itemize
237 246
238 247 Filesystem navigation, via a magic
239 248 \family typewriter
240 249 %cd
241 250 \family default
242 251 command, along with a persistent bookmark system (using
243 252 \family typewriter
244 253 %bookmark
245 254 \family default
246 255 ) for fast access to frequently visited directories.
247 256 \layout Itemize
248 257
249 258 Automatic indentation (optional) of code as you type (through the readline
250 259 library).
251 260 \layout Itemize
252 261
253 262 Macro system for quickly re-executing multiple lines of previous input with
254 263 a single name.
255 264 \layout Itemize
256 265
257 266 Session logging (you can then later use these logs as code in your programs).
258 267 \layout Itemize
259 268
260 269 Session restoring: logs can be replayed to restore a previous session to
261 270 the state where you left it.
262 271 \layout Itemize
263 272
264 273 Verbose and colored exception traceback printouts.
265 274 Easier to parse visually, and in verbose mode they produce a lot of useful
266 275 debugging information (basically a terminal version of the cgitb module).
267 276 \layout Itemize
268 277
269 278 Auto-parentheses: callable objects can be executed without parentheses:
270 279
271 280 \family typewriter
272 281 `sin 3'
273 282 \family default
274 283 is automatically converted to
275 284 \family typewriter
276 285 `sin(3)
277 286 \family default
278 287 '.
279 288 \layout Itemize
280 289
281 290 Auto-quoting: using `
282 291 \family typewriter
283 292 ,
284 293 \family default
285 294 ' or `
286 295 \family typewriter
287 296 ;
288 297 \family default
289 298 ' as the first character forces auto-quoting of the rest of the line:
290 299 \family typewriter
291 300 `,my_function a\SpecialChar ~
292 301 b'
293 302 \family default
294 303 becomes automatically
295 304 \family typewriter
296 305 `my_function("a","b")'
297 306 \family default
298 307 , while
299 308 \family typewriter
300 309 `;my_function a\SpecialChar ~
301 310 b'
302 311 \family default
303 312 becomes
304 313 \family typewriter
305 314 `my_function("a b")'
306 315 \family default
307 316 .
308 317 \layout Itemize
309 318
310 319 Extensible input syntax.
311 320 You can define filters that pre-process user input to simplify input in
312 321 special situations.
313 322 This allows for example pasting multi-line code fragments which start with
314 323
315 324 \family typewriter
316 325 `>>>'
317 326 \family default
318 327 or
319 328 \family typewriter
320 329 `...'
321 330 \family default
322 331 such as those from other python sessions or the standard Python documentation.
323 332 \layout Itemize
324 333
325 334 Flexible configuration system.
326 335 It uses a configuration file which allows permanent setting of all command-line
327 336 options, module loading, code and file execution.
328 337 The system allows recursive file inclusion, so you can have a base file
329 338 with defaults and layers which load other customizations for particular
330 339 projects.
331 340 \layout Itemize
332 341
333 342 Embeddable.
334 343 You can call IPython as a python shell inside your own python programs.
335 344 This can be used both for debugging code or for providing interactive abilities
336 345 to your programs with knowledge about the local namespaces (very useful
337 346 in debugging and data analysis situations).
338 347 \layout Itemize
339 348
340 349 Easy debugger access.
341 350 You can set IPython to call up the Python debugger (pdb) every time there
342 351 is an uncaught exception.
343 352 This drops you inside the code which triggered the exception with all the
344 353 data live and it is possible to navigate the stack to rapidly isolate the
345 354 source of a bug.
346 355 The
347 356 \family typewriter
348 357 %run
349 358 \family default
350 359 magic command --with the
351 360 \family typewriter
352 361 -d
353 362 \family default
354 363 option-- can run any script under
355 364 \family typewriter
356 365 pdb
357 366 \family default
358 367 's control, automatically setting initial breakpoints for you.
359 368 \layout Itemize
360 369
361 370 Profiler support.
362 371 You can run single statements (similar to
363 372 \family typewriter
364 373 profile.run()
365 374 \family default
366 375 ) or complete programs under the profiler's control.
367 376 While this is possible with the standard
368 377 \family typewriter
369 378 profile
370 379 \family default
371 380 module, IPython wraps this functionality with magic commands (see
372 381 \family typewriter
373 382 `%prun'
374 383 \family default
375 384 and
376 385 \family typewriter
377 386 `%run -p
378 387 \family default
379 388 ') convenient for rapid interactive work.
380 389 \layout Subsection
381 390
382 391 Portability and Python requirements
383 392 \layout Standard
384 393
385 394
386 395 \series bold
387 396 Python requirements:
388 397 \series default
389 398 IPython works with Python version 2.2 or newer.
390 399 It has been tested with Python 2.4 and no problems have been reported.
391 400 Support for Python 2.1 hasn't been recently tested, since I don't have access
392 401 to it on any of my systems.
393 402 But I suspect there may be some problems with Python 2.1, because some of
394 403 the newer code may use 2.2 features.
395 404 \layout Standard
396 405
397 406 IPython is developed under
398 407 \series bold
399 408 Linux
400 409 \series default
401 410 , but it should work in any reasonable Unix-type system (tested OK under
402 411 Solaris and the *BSD family, for which a port exists thanks to Dryice Liu).
403 412 \layout Standard
404 413
405 414
406 415 \series bold
407 416 Mac OS X
408 417 \series default
409 418 : it works, apparently without any problems (thanks to Jim Boyle at Lawrence
410 419 Livermore for the information).
411 420 Thanks to Andrea Riciputi, Fink support is available.
412 421 \layout Standard
413 422
414 423
415 424 \series bold
416 425 CygWin
417 426 \series default
418 427 : it works mostly OK, though some users have reported problems with prompt
419 428 coloring.
420 429 No satisfactory solution to this has been found so far, you may want to
421 430 disable colors permanently in the
422 431 \family typewriter
423 432 ipythonrc
424 433 \family default
425 434 configuration file if you experience problems.
426 435 If you have proper color support under cygwin, please post to the IPython
427 436 mailing list so this issue can be resolved for all users.
428 437 \layout Standard
429 438
430 439
431 440 \series bold
432 441 Windows
433 442 \series default
434 443 : it works well under Windows XP/2k, and I suspect NT should behave similarly.
435 444 Section\SpecialChar ~
436 445
437 446 \begin_inset LatexCommand \ref{sub:Under-Windows}
438 447
439 448 \end_inset
440 449
441 450 describes installation details for Windows, including some additional tools
442 451 needed on this platform.
443 452 \layout Standard
444 453
445 454 Windows 9x support is present, and has been reported to work fine (at least
446 455 on WinME).
447 456 \layout Standard
448 457
449 458 Please note, however, that I have very little access to and experience with
450 459 Windows development.
451 460 For this reason, Windows-specific bugs tend to linger far longer than I
452 461 would like, and often I just can't find a satisfactory solution.
453 462 If any Windows user wants to join in with development help, all hands are
454 463 always welcome.
455 464 \layout Subsection
456 465
457 466 Location
458 467 \layout Standard
459 468
460 469 IPython is generously hosted at
461 470 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
462 471
463 472 \end_inset
464 473
465 474 by the SciPy project.
466 475 This site offers downloads, subversion access, mailing lists and a bug
467 476 tracking system.
468 477 I am very grateful to Enthought (
469 478 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
470 479
471 480 \end_inset
472 481
473 482 ) and all of the SciPy team for their contribution.
474 483 \layout Section
475 484
476 485
477 486 \begin_inset LatexCommand \label{sec:install}
478 487
479 488 \end_inset
480 489
481 490 Installation
482 491 \layout Subsection
483 492
484 493 Instant instructions
485 494 \layout Standard
486 495
487 496 If you are of the impatient kind, under Linux/Unix simply untar/unzip the
488 497 download, then install with
489 498 \family typewriter
490 499 `python setup.py install'
491 500 \family default
492 501 .
493 502 Under Windows, double-click on the provided
494 503 \family typewriter
495 504 .exe
496 505 \family default
497 506 binary installer.
498 507 \layout Standard
499 508
500 509 Then, take a look at Sections
501 510 \begin_inset LatexCommand \ref{sec:good_config}
502 511
503 512 \end_inset
504 513
505 514 for configuring things optimally and
506 515 \begin_inset LatexCommand \ref{sec:quick_tips}
507 516
508 517 \end_inset
509 518
510 519 for quick tips on efficient use of IPython.
511 520 You can later refer to the rest of the manual for all the gory details.
512 521 \layout Standard
513 522
514 523 See the notes in sec.
515 524
516 525 \begin_inset LatexCommand \ref{sec:upgrade}
517 526
518 527 \end_inset
519 528
520 529 for upgrading IPython versions.
521 530 \layout Subsection
522 531
523 532 Detailed Unix instructions (Linux, Mac OS X, etc.)
524 533 \layout Standard
525 534
526
527 \begin_inset ERT
528 status Open
529
530 \layout Standard
531
532 \backslash
533 html{
534 \backslash
535 textbf{A warning to readers of the HTML version of this manual}: all options below are preceded with with TWO dashes and no intervening space between the dashes (e.g. Dash-Dash-home). The default HTML conversion tools mangle these into a single dash.}
536 \end_inset
537
538
539 \layout Standard
540
541 535 For RPM based systems, simply install the supplied package in the usual
542 536 manner.
543 537 If you download the tar archive, the process is:
544 538 \layout Enumerate
545 539
546 540 Unzip/untar the
547 541 \family typewriter
548 542 ipython-XXX.tar.gz
549 543 \family default
550 544 file wherever you want (
551 545 \family typewriter
552 546 XXX
553 547 \family default
554 548 is the version number).
555 549 It will make a directory called
556 550 \family typewriter
557 551 ipython-XXX.
558 552
559 553 \family default
560 554 Change into that directory where you will find the files
561 555 \family typewriter
562 556 README
563 557 \family default
564 558 and
565 559 \family typewriter
566 560 setup.py
567 561 \family default
568 562 .
569 563
570 564 \family typewriter
571 565 O
572 566 \family default
573 567 nce you've completed the installation, you can safely remove this directory.
574 568
575 569 \layout Enumerate
576 570
577 571 If you are installing over a previous installation of version 0.2.0 or earlier,
578 572 first remove your
579 573 \family typewriter
580 574 $HOME/.ipython
581 575 \family default
582 576 directory, since the configuration file format has changed somewhat (the
583 577 '=' were removed from all option specifications).
584 578 Or you can call ipython with the
585 579 \family typewriter
586 580 -upgrade
587 581 \family default
588 582 option and it will do this automatically for you.
589 583 \layout Enumerate
590 584
591 585 IPython uses distutils, so you can install it by simply typing at the system
592 586 prompt (don't type the
593 587 \family typewriter
594 588 $
595 589 \family default
596 590 )
597 591 \newline
598 592
599 593 \family typewriter
600 594 $ python setup.py install
601 595 \family default
602 596
603 597 \newline
604 598 Note that this assumes you have root access to your machine.
605 599 If you don't have root access or don't want IPython to go in the default
606 600 python directories, you'll need to use the
607 \family typewriter
608 --home
609 \family default
601 \begin_inset ERT
602 status Collapsed
603
604 \layout Standard
605
606 \backslash
607 verb|--home|
608 \end_inset
609
610 610 option (or
611 \family typewriter
612 --prefix
613 \family default
611 \begin_inset ERT
612 status Collapsed
613
614 \layout Standard
615
616 \backslash
617 verb|--prefix|
618 \end_inset
619
614 620 ).
615 621 For example:
616 622 \newline
617 623
618 \family typewriter
619 $ python setup.py install --home $HOME/local
620 \family default
621
622 \newline
623 will install
624 \begin_inset Foot
625 collapsed true
624 \begin_inset ERT
625 status Collapsed
626 626
627 627 \layout Standard
628 628
629 If you are reading these instructions in HTML format, please note that the
630 option is --home, with
631 \emph on
632 two
633 \emph default
634 dashes.
635 The automatic HTML conversion program seems to eat up one of the dashes,
636 unfortunately (it's ok in the PDF version).
629 \backslash
630 verb|$ python setup.py install --home $HOME/local|
637 631 \end_inset
638 632
639 IPython into
633
634 \newline
635 will install IPython into
640 636 \family typewriter
641 637 $HOME/local
642 638 \family default
643 639 and its subdirectories (creating them if necessary).
644 640 \newline
645 641 You can type
646 642 \newline
647 643
648 \family typewriter
649 $ python setup.py --help
650 \family default
644 \begin_inset ERT
645 status Collapsed
651 646
647 \layout Standard
648
649 \backslash
650 verb|$ python setup.py --help|
651 \end_inset
652
653
652 654 \newline
653 655 for more details.
654 656 \newline
655 657 Note that if you change the default location for
656 \family typewriter
657 --home
658 \family default
658 \begin_inset ERT
659 status Collapsed
660
661 \layout Standard
662
663 \backslash
664 verb|--home|
665 \end_inset
666
659 667 at installation, IPython may end up installed at a location which is not
660 668 part of your
661 669 \family typewriter
662 670 $PYTHONPATH
663 671 \family default
664 672 environment variable.
665 673 In this case, you'll need to configure this variable to include the actual
666 674 directory where the
667 675 \family typewriter
668 676 IPython/
669 677 \family default
670 678 directory ended (typically the value you give to
671 \family typewriter
672 --home
673 \family default
679 \begin_inset ERT
680 status Collapsed
681
682 \layout Standard
683
684 \backslash
685 verb|--home|
686 \end_inset
687
674 688 plus
675 689 \family typewriter
676 690 /lib/python
677 691 \family default
678 692 ).
679 693 \layout Subsubsection
680 694
681 695 Mac OSX information
682 696 \layout Standard
683 697
684 698 Under OSX, there is a choice you need to make.
685 699 Apple ships its own build of Python, which lives in the core OSX filesystem
686 700 hierarchy.
687 701 You can also manually install a separate Python, either purely by hand
688 702 (typically in
689 703 \family typewriter
690 704 /usr/local
691 705 \family default
692 706 ) or by using Fink, which puts everything under
693 707 \family typewriter
694 708 /sw
695 709 \family default
696 710 .
697 711 Which route to follow is a matter of personal preference, as I've seen
698 712 users who favor each of the approaches.
699 713 Here I will simply list the known installation issues under OSX, along
700 714 with their solutions.
715 \layout Standard
716
717 This page:
718 \begin_inset LatexCommand \htmlurl{http://geosci.uchicago.edu/~tobis/pylab.html}
719
720 \end_inset
721
722 contains information on this topic, with additional details on how to make
723 IPython and matplotlib play nicely under OSX.
701 724 \layout Subsubsection*
702 725
703 726 GUI problems
704 727 \layout Standard
705 728
706 729 The following instructions apply to an install of IPython under OSX from
707 730 unpacking the
708 731 \family typewriter
709 732 .tar.gz
710 733 \family default
711 734 distribution and installing it for the default Python interpreter shipped
712 735 by Apple.
713 736 If you are using a fink install, fink will take care of these details for
714 737 you, by installing IPython against fink's Python.
715 738 \layout Standard
716 739
717 740 IPython offers various forms of support for interacting with graphical applicati
718 741 ons from the command line, from simple Tk apps (which are in principle always
719 supported by Python) to interactive control of WX, QT and GTK apps.
742 supported by Python) to interactive control of WX, Qt and GTK apps.
720 743 Under OSX, however, this requires that ipython is installed by calling
721 744 the special
722 745 \family typewriter
723 746 pythonw
724 747 \family default
725 748 script at installation time, which takes care of coordinating things with
726 749 Apple's graphical environment.
727 750 \layout Standard
728 751
729 So when installing under OSX, it is best to use the following command
752 So when installing under OSX, it is best to use the following command:
753 \family typewriter
754
755 \newline
756
757 \family default
758
730 759 \begin_inset ERT
731 760 status Collapsed
732 761
733 762 \layout Standard
734 763
735 764 \backslash
736 html{
737 \backslash
738 emph{[Again, in the HTML manual, the option is called -~-install=scripts, with TWO dashes and no intervening space between the dashes]}}
765 verb| $ sudo pythonw setup.py install --install-scripts=/usr/local/bin|
739 766 \end_inset
740 767
741 :
742 \family typewriter
743 768
744 769 \newline
745 \SpecialChar ~
746 \SpecialChar ~
747 $ sudo pythonw setup.py install --install-scripts=/usr/local/bin
748 \family default
749
770 or
750 771 \newline
751 or
752 \family typewriter
753 772
754 \newline
755 \SpecialChar ~
756 \SpecialChar ~
757 $ sudo pythonw setup.py install --install-scripts=/usr/bin
758 \newline
773 \begin_inset ERT
774 status Open
759 775
760 \family default
776 \layout Standard
777
778 \backslash
779 verb| $ sudo pythonw setup.py install --install-scripts=/usr/bin|
780 \end_inset
781
782
783 \newline
761 784 depending on where you like to keep hand-installed executables.
762 785 \layout Standard
763 786
764 787 The resulting script will have an appropriate shebang line (the first line
765 788 in the script whic begins with
766 789 \family typewriter
767 790 #!...
768 791 \family default
769 792 ) such that the ipython interpreter can interact with the OS X GUI.
770 793 If the installed version does not work and has a shebang line that points
771 794 to, for example, just
772 795 \family typewriter
773 796 /usr/bin/python
774 797 \family default
775 798 , then you might have a stale, cached version in your
776 799 \family typewriter
777 800 build/scripts-<python-version>
778 801 \family default
779 802 directory.
780 803 Delete that directory and rerun the
781 804 \family typewriter
782 805 setup.py
783 806 \family default
784 807 .
785 808
786 809 \layout Standard
787 810
788 811 It is also a good idea to use the special flag
789 \family typewriter
790 --install-scripts
791 \family default
812 \begin_inset ERT
813 status Collapsed
814
815 \layout Standard
816
817 \backslash
818 verb|--install-scripts|
819 \end_inset
820
792 821 as indicated above, to ensure that the ipython scripts end up in a location
793 822 which is part of your
794 823 \family typewriter
795 824 $PATH
796 825 \family default
797 826 .
798 827 Otherwise Apple's Python will put the scripts in an internal directory
799 828 not available by default at the command line (if you use
800 829 \family typewriter
801 830 /usr/local/bin
802 831 \family default
803 832 , you need to make sure this is in your
804 833 \family typewriter
805 834 $PATH
806 835 \family default
807 836 , which may not be true by default).
808 837 \layout Subsubsection*
809 838
810 839 Readline problems
811 840 \layout Standard
812 841
813 842 By default, the Python version shipped by Apple does
814 843 \emph on
815 844 not
816 845 \emph default
817 846 include the readline library, so central to IPython's behavior.
818 847 If you install IPython against Apple's Python, you will not have arrow
819 848 keys, tab completion, etc.
820 849 For Mac OSX 10.3 (Panther), you can find a prebuilt readline library here:
821 850 \newline
822 851
823 852 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/readline-5.0-py2.3-macosx10.3.zip}
824 853
825 854 \end_inset
826 855
827 856
828 857 \layout Standard
829 858
830 859 If you are using OSX 10.4 (Tiger), after installing this package you need
831 860 to either:
832 861 \layout Enumerate
833 862
834 863 move
835 864 \family typewriter
836 865 readline.so
837 866 \family default
838 867 from
839 868 \family typewriter
840 869 /Library/Python/2.3
841 870 \family default
842 871 to
843 872 \family typewriter
844 873 /Library/Python/2.3/site-packages
845 874 \family default
846 875 , or
847 876 \layout Enumerate
848 877
849 878 install
850 879 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/TigerPython23Compat.pkg.zip}
851 880
852 881 \end_inset
853 882
854 883
855 884 \layout Standard
856 885
857 886 Users installing against Fink's Python or a properly hand-built one should
858 887 not have this problem.
859 888 \layout Subsection
860 889
861 890
862 891 \begin_inset LatexCommand \label{sub:Under-Windows}
863 892
864 893 \end_inset
865 894
866 895 Windows instructions
867 896 \layout Standard
868 897
869 898 While you can use IPython under Windows with only a stock Python installation,
870 899 there is one extension,
871 900 \family typewriter
872 901 readline
873 902 \family default
874 903 , which will make the whole experience a lot more pleasant.
875 904 It is almost a requirement, since IPython will complain in its absence
876 905 (though it will function).
877 906
878 907 \layout Standard
879 908
880 909 The
881 910 \family typewriter
882 911 readline
883 912 \family default
884 913 extension needs two other libraries to work, so in all you need:
885 914 \layout Enumerate
886 915
887 916
888 917 \family typewriter
889 918 PyWin32
890 919 \family default
891 920 from
892 921 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
893 922
894 923 \end_inset
895 924
896 925 .
897 926 \layout Enumerate
898 927
899 928
900 929 \family typewriter
901 930 CTypes
902 931 \family default
903 932 from
904 933 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
905 934
906 935 \end_inset
907 936
908 937 (you
909 938 \emph on
910 939 must
911 940 \emph default
912 941 use version 0.9.1 or newer).
913 942 \layout Enumerate
914 943
915 944
916 945 \family typewriter
917 946 Readline
918 947 \family default
919 948 for Windows from
920 949 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools}
921 950
922 951 \end_inset
923 952
924 953 .
925 954 \layout Standard
926 955
927 956
928 957 \series bold
929 958 Warning about a broken readline-like library:
930 959 \series default
931 960 several users have reported problems stemming from using the pseudo-readline
932 961 library at
933 962 \begin_inset LatexCommand \htmlurl{http://newcenturycomputers.net/projects/readline.html}
934 963
935 964 \end_inset
936 965
937 966 .
938 967 This is a broken library which, while called readline, only implements
939 968 an incomplete subset of the readline API.
940 969 Since it is still called readline, it fools IPython's detection mechanisms
941 970 and causes unpredictable crashes later.
942 971 If you wish to use IPython under Windows, you must NOT use this library,
943 972 which for all purposes is (at least as of version 1.6) terminally broken.
944 973 \layout Subsubsection
945 974
946 975 Gary Bishop's readline and color support for Windows
947 976 \layout Standard
948 977
949 978 Some of IPython's very useful features are:
950 979 \layout Itemize
951 980
952 981 Integrated readline support (Tab-based file, object and attribute completion,
953 982 input history across sessions, editable command line, etc.)
954 983 \layout Itemize
955 984
956 985 Coloring of prompts, code and tracebacks.
957 986 \layout Standard
958 987
959 988 These, by default, are only available under Unix-like operating systems.
960 989 However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit
961 990 from them.
962 991 His readline library implements both GNU readline functionality and color
963 992 support, so that IPython under Windows XP/2k can be as friendly and powerful
964 993 as under Unix-like environments.
965 994 \layout Standard
966 995
967 996 You can find Gary's tools at
968 997 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools}
969 998
970 999 \end_inset
971 1000
972 1001 ; Gary's
973 1002 \family typewriter
974 1003 readline
975 1004 \family default
976 1005 requires in turn the
977 1006 \family typewriter
978 1007 ctypes
979 1008 \family default
980 1009 library by Thomas Heller, available at
981 1010 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
982 1011
983 1012 \end_inset
984 1013
985 1014 , and Mark Hammond's
986 1015 \family typewriter
987 1016 PyWin32
988 1017 \family default
989 1018 from
990 1019 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
991 1020
992 1021 \end_inset
993 1022
994 1023 (
995 1024 \family typewriter
996 1025 PyWin32
997 1026 \family default
998 1027 is great for anything Windows-related anyway, so you might as well get
999 1028 it).
1000 1029 \layout Standard
1001 1030
1002 1031 Under MS\SpecialChar ~
1003 1032 Windows, IPython will complain if it can not find this
1004 1033 \family typewriter
1005 1034 readline
1006 1035 \family default
1007 1036 library at startup and any time the
1008 1037 \family typewriter
1009 1038 %colors
1010 1039 \family default
1011 1040 command is issued, so you can consider it to be a quasi-requirement.
1012 1041 \layout Subsubsection
1013 1042
1014 1043 Installation procedure
1015 1044 \layout Standard
1016 1045
1017 1046 Once you have the above installed, from the IPython download directory grab
1018 1047 the
1019 1048 \family typewriter
1020 1049 ipython-XXX.win32.exe
1021 1050 \family default
1022 1051 file, where
1023 1052 \family typewriter
1024 1053 XXX
1025 1054 \family default
1026 1055 represents the version number.
1027 1056 This is a regular windows executable installer, which you can simply double-cli
1028 1057 ck to install.
1029 1058 It will add an entry for IPython to your Start Menu, as well as registering
1030 1059 IPython in the Windows list of applications, so you can later uninstall
1031 1060 it from the Control Panel.
1032 1061
1033 1062 \layout Standard
1034 1063
1035 1064 IPython tries to install the configuration information in a directory named
1036 1065
1037 1066 \family typewriter
1038 1067 .ipython
1039 1068 \family default
1040 1069 (
1041 1070 \family typewriter
1042 1071 _ipython
1043 1072 \family default
1044 1073 under Windows) located in your `home' directory.
1045 1074 IPython sets this directory by looking for a
1046 1075 \family typewriter
1047 1076 HOME
1048 1077 \family default
1049 1078 environment variable; if such a variable does not exist, it uses
1050 1079 \family typewriter
1051 1080 HOMEDRIVE
1052 1081 \backslash
1053 1082 HOMEPATH
1054 1083 \family default
1055 1084 (these are always defined by Windows).
1056 1085 This typically gives something like
1057 1086 \family typewriter
1058 1087 C:
1059 1088 \backslash
1060 1089 Documents and Settings
1061 1090 \backslash
1062 1091 YourUserName
1063 1092 \family default
1064 1093 , but your local details may vary.
1065 1094 In this directory you will find all the files that configure IPython's
1066 1095 defaults, and you can put there your profiles and extensions.
1067 1096 This directory is automatically added by IPython to
1068 1097 \family typewriter
1069 1098 sys.path
1070 1099 \family default
1071 1100 , so anything you place there can be found by
1072 1101 \family typewriter
1073 1102 import
1074 1103 \family default
1075 1104 statements.
1076 1105 \layout Paragraph
1077 1106
1078 1107 Upgrading
1079 1108 \layout Standard
1080 1109
1081 1110 For an IPython upgrade, you should first uninstall the previous version.
1082 1111 This will ensure that all files and directories (such as the documentation)
1083 1112 which carry embedded version strings in their names are properly removed.
1084 1113 \layout Paragraph
1085 1114
1086 1115 Manual installation under Win32
1087 1116 \layout Standard
1088 1117
1089 1118 In case the automatic installer does not work for some reason, you can download
1090 1119 the
1091 1120 \family typewriter
1092 1121 ipython-XXX.tar.gz
1093 1122 \family default
1094 1123 file, which contains the full IPython source distribution (the popular
1095 1124 WinZip can read
1096 1125 \family typewriter
1097 1126 .tar.gz
1098 1127 \family default
1099 1128 files).
1100 1129 After uncompressing the archive, you can install it at a command terminal
1101 1130 just like any other Python module, by using
1102 1131 \family typewriter
1103 1132 `python setup.py install'
1104 1133 \family default
1105 1134 .
1106 1135
1107 1136 \layout Standard
1108 1137
1109 1138 After the installation, run the supplied
1110 1139 \family typewriter
1111 1140 win32_manual_post_install.py
1112 1141 \family default
1113 1142 script, which creates the necessary Start Menu shortcuts for you.
1114 1143 \layout Subsection
1115 1144
1116 1145
1117 1146 \begin_inset LatexCommand \label{sec:upgrade}
1118 1147
1119 1148 \end_inset
1120 1149
1121 1150 Upgrading from a previous version
1122 1151 \layout Standard
1123 1152
1124 1153 If you are upgrading from a previous version of IPython, after doing the
1125 1154 routine installation described above, you should call IPython with the
1126 1155
1127 1156 \family typewriter
1128 1157 -upgrade
1129 1158 \family default
1130 1159 option the first time you run your new copy.
1131 1160 This will automatically update your configuration directory while preserving
1132 1161 copies of your old files.
1133 1162 You can then later merge back any personal customizations you may have
1134 1163 made into the new files.
1135 1164 It is a good idea to do this as there may be new options available in the
1136 1165 new configuration files which you will not have.
1137 1166 \layout Standard
1138 1167
1139 1168 Under Windows, if you don't know how to call python scripts with arguments
1140 1169 from a command line, simply delete the old config directory and IPython
1141 1170 will make a new one.
1142 1171 Win2k and WinXP users will find it in
1143 1172 \family typewriter
1144 1173 C:
1145 1174 \backslash
1146 1175 Documents and Settings
1147 1176 \backslash
1148 1177 YourUserName
1149 1178 \backslash
1150 .ipython
1179 _ipython
1151 1180 \family default
1152 1181 , and Win 9x users under
1153 1182 \family typewriter
1154 1183 C:
1155 1184 \backslash
1156 1185 Program Files
1157 1186 \backslash
1158 1187 IPython
1159 1188 \backslash
1160 .ipython.
1189 _ipython.
1161 1190 \layout Section
1162 1191
1163 1192
1164 1193 \begin_inset LatexCommand \label{sec:good_config}
1165 1194
1166 1195 \end_inset
1167 1196
1168 1197
1169 1198 \begin_inset OptArg
1170 1199 collapsed true
1171 1200
1172 1201 \layout Standard
1173 1202
1174 1203 Initial configuration
1175 1204 \begin_inset ERT
1176 1205 status Collapsed
1177 1206
1178 1207 \layout Standard
1179 1208
1180 1209 \backslash
1181 1210 ldots
1182 1211 \end_inset
1183 1212
1184 1213
1185 1214 \end_inset
1186 1215
1187 1216 Initial configuration of your environment
1188 1217 \layout Standard
1189 1218
1190 1219 This section will help you set various things in your environment for your
1191 1220 IPython sessions to be as efficient as possible.
1192 1221 All of IPython's configuration information, along with several example
1193 1222 files, is stored in a directory named by default
1194 1223 \family typewriter
1195 1224 $HOME/.ipython
1196 1225 \family default
1197 1226 .
1198 1227 You can change this by defining the environment variable
1199 1228 \family typewriter
1200 1229 IPYTHONDIR
1201 1230 \family default
1202 1231 , or at runtime with the command line option
1203 1232 \family typewriter
1204 1233 -ipythondir
1205 1234 \family default
1206 1235 .
1207 1236 \layout Standard
1208 1237
1209 1238 If all goes well, the first time you run IPython it should automatically
1210 1239 create a user copy of the config directory for you, based on its builtin
1211 1240 defaults.
1212 1241 You can look at the files it creates to learn more about configuring the
1213 1242 system.
1214 1243 The main file you will modify to configure IPython's behavior is called
1215 1244
1216 1245 \family typewriter
1217 1246 ipythonrc
1218 1247 \family default
1219 1248 (with a
1220 1249 \family typewriter
1221 1250 .ini
1222 1251 \family default
1223 1252 extension under Windows), included for reference in Sec.
1224 1253
1225 1254 \begin_inset LatexCommand \ref{sec:ipytonrc-sample}
1226 1255
1227 1256 \end_inset
1228 1257
1229 1258 .
1230 1259 This file is very commented and has many variables you can change to suit
1231 1260 your taste, you can find more details in Sec.
1232 1261
1233 1262 \begin_inset LatexCommand \ref{sec:customization}
1234 1263
1235 1264 \end_inset
1236 1265
1237 1266 .
1238 1267 Here we discuss the basic things you will want to make sure things are
1239 1268 working properly from the beginning.
1240 1269 \layout Subsection
1241 1270
1242 1271
1243 1272 \begin_inset LatexCommand \label{sec:help-access}
1244 1273
1245 1274 \end_inset
1246 1275
1247 1276 Access to the Python help system
1248 1277 \layout Standard
1249 1278
1250 1279 This is true for Python in general (not just for IPython): you should have
1251 1280 an environment variable called
1252 1281 \family typewriter
1253 1282 PYTHONDOCS
1254 1283 \family default
1255 1284 pointing to the directory where your HTML Python documentation lives.
1256 1285 In my system it's
1257 1286 \family typewriter
1258 1287 /usr/share/doc/python-docs-2.3.4/html
1259 1288 \family default
1260 1289 , check your local details or ask your systems administrator.
1261 1290
1262 1291 \layout Standard
1263 1292
1264 1293 This is the directory which holds the HTML version of the Python manuals.
1265 1294 Unfortunately it seems that different Linux distributions package these
1266 1295 files differently, so you may have to look around a bit.
1267 1296 Below I show the contents of this directory on my system for reference:
1268 1297 \layout Standard
1269 1298
1270 1299
1271 1300 \family typewriter
1272 1301 [html]> ls
1273 1302 \newline
1274 1303 about.dat acks.html dist/ ext/ index.html lib/ modindex.html stdabout.dat tut/
1275 1304 about.html api/ doc/ icons/ inst/ mac/ ref/ style.css
1276 1305 \layout Standard
1277 1306
1278 1307 You should really make sure this variable is correctly set so that Python's
1279 1308 pydoc-based help system works.
1280 1309 It is a powerful and convenient system with full access to the Python manuals
1281 1310 and all modules accessible to you.
1282 1311 \layout Standard
1283 1312
1284 1313 Under Windows it seems that pydoc finds the documentation automatically,
1285 1314 so no extra setup appears necessary.
1286 1315 \layout Subsection
1287 1316
1288 1317 Editor
1289 1318 \layout Standard
1290 1319
1291 1320 The
1292 1321 \family typewriter
1293 1322 %edit
1294 1323 \family default
1295 1324 command (and its alias
1296 1325 \family typewriter
1297 1326 %ed
1298 1327 \family default
1299 1328 ) will invoke the editor set in your environment as
1300 1329 \family typewriter
1301 1330 EDITOR
1302 1331 \family default
1303 1332 .
1304 1333 If this variable is not set, it will default to
1305 1334 \family typewriter
1306 1335 vi
1307 1336 \family default
1308 1337 under Linux/Unix and to
1309 1338 \family typewriter
1310 1339 notepad
1311 1340 \family default
1312 1341 under Windows.
1313 1342 You may want to set this variable properly and to a lightweight editor
1314 1343 which doesn't take too long to start (that is, something other than a new
1315 1344 instance of
1316 1345 \family typewriter
1317 1346 Emacs
1318 1347 \family default
1319 1348 ).
1320 1349 This way you can edit multi-line code quickly and with the power of a real
1321 1350 editor right inside IPython.
1322 1351
1323 1352 \layout Standard
1324 1353
1325 1354 If you are a dedicated
1326 1355 \family typewriter
1327 1356 Emacs
1328 1357 \family default
1329 1358 user, you should set up the
1330 1359 \family typewriter
1331 1360 Emacs
1332 1361 \family default
1333 1362 server so that new requests are handled by the original process.
1334 1363 This means that almost no time is spent in handling the request (assuming
1335 1364 an
1336 1365 \family typewriter
1337 1366 Emacs
1338 1367 \family default
1339 1368 process is already running).
1340 1369 For this to work, you need to set your
1341 1370 \family typewriter
1342 1371 EDITOR
1343 1372 \family default
1344 1373 environment variable to
1345 1374 \family typewriter
1346 1375 'emacsclient'
1347 1376 \family default
1348 1377 .
1349 1378
1350 1379 \family typewriter
1351 1380
1352 1381 \family default
1353 1382 The code below, supplied by Francois Pinard, can then be used in your
1354 1383 \family typewriter
1355 1384 .emacs
1356 1385 \family default
1357 1386 file to enable the server:
1358 1387 \layout Standard
1359 1388
1360 1389
1361 1390 \family typewriter
1362 1391 (defvar server-buffer-clients)
1363 1392 \newline
1364 1393 (when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm))
1365 1394 \newline
1366 1395
1367 1396 \begin_inset ERT
1368 1397 status Collapsed
1369 1398
1370 1399 \layout Standard
1371 1400
1372 1401 \backslash
1373 1402 hspace*{0mm}
1374 1403 \end_inset
1375 1404
1376 1405 \SpecialChar ~
1377 1406 \SpecialChar ~
1378 1407 (server-start)
1379 1408 \newline
1380 1409
1381 1410 \begin_inset ERT
1382 1411 status Collapsed
1383 1412
1384 1413 \layout Standard
1385 1414
1386 1415 \backslash
1387 1416 hspace*{0mm}
1388 1417 \end_inset
1389 1418
1390 1419 \SpecialChar ~
1391 1420 \SpecialChar ~
1392 1421 (defun fp-kill-server-with-buffer-routine ()
1393 1422 \newline
1394 1423
1395 1424 \begin_inset ERT
1396 1425 status Collapsed
1397 1426
1398 1427 \layout Standard
1399 1428
1400 1429 \backslash
1401 1430 hspace*{0mm}
1402 1431 \end_inset
1403 1432
1404 1433 \SpecialChar ~
1405 1434 \SpecialChar ~
1406 1435 \SpecialChar ~
1407 1436 \SpecialChar ~
1408 1437 (and server-buffer-clients (server-done)))
1409 1438 \newline
1410 1439
1411 1440 \begin_inset ERT
1412 1441 status Collapsed
1413 1442
1414 1443 \layout Standard
1415 1444
1416 1445 \backslash
1417 1446 hspace*{0mm}
1418 1447 \end_inset
1419 1448
1420 1449 \SpecialChar ~
1421 1450 \SpecialChar ~
1422 1451 (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
1423 1452 \layout Standard
1424 1453
1425 1454 You can also set the value of this editor via the commmand-line option '-
1426 1455 \family typewriter
1427 1456 editor'
1428 1457 \family default
1429 1458 or in your
1430 1459 \family typewriter
1431 1460 ipythonrc
1432 1461 \family default
1433 1462 file.
1434 1463 This is useful if you wish to use specifically for IPython an editor different
1435 1464 from your typical default (and for Windows users who tend to use fewer
1436 1465 environment variables).
1437 1466 \layout Subsection
1438 1467
1439 1468 Color
1440 1469 \layout Standard
1441 1470
1442 1471 The default IPython configuration has most bells and whistles turned on
1443 1472 (they're pretty safe).
1444 1473 But there's one that
1445 1474 \emph on
1446 1475 may
1447 1476 \emph default
1448 1477 cause problems on some systems: the use of color on screen for displaying
1449 1478 information.
1450 1479 This is very useful, since IPython can show prompts and exception tracebacks
1451 1480 with various colors, display syntax-highlighted source code, and in general
1452 1481 make it easier to visually parse information.
1453 1482 \layout Standard
1454 1483
1455 1484 The following terminals seem to handle the color sequences fine:
1456 1485 \layout Itemize
1457 1486
1458 1487 Linux main text console, KDE Konsole, Gnome Terminal, E-term, rxvt, xterm.
1459 1488 \layout Itemize
1460 1489
1461 1490 CDE terminal (tested under Solaris).
1462 1491 This one boldfaces light colors.
1463 1492 \layout Itemize
1464 1493
1465 1494 (X)Emacs buffers.
1466 1495 See sec.
1467 1496 \begin_inset LatexCommand \ref{sec:emacs}
1468 1497
1469 1498 \end_inset
1470 1499
1471 1500 for more details on using IPython with (X)Emacs.
1472 1501 \layout Itemize
1473 1502
1474 1503 A Windows (XP/2k) command prompt
1475 1504 \emph on
1476 1505 with Gary Bishop's support extensions
1477 1506 \emph default
1478 1507 .
1479 1508 Gary's extensions are discussed in Sec.\SpecialChar ~
1480 1509
1481 1510 \begin_inset LatexCommand \ref{sub:Under-Windows}
1482 1511
1483 1512 \end_inset
1484 1513
1485 1514 .
1486 1515 \layout Itemize
1487 1516
1488 1517 A Windows (XP/2k) CygWin shell.
1489 1518 Although some users have reported problems; it is not clear whether there
1490 1519 is an issue for everyone or only under specific configurations.
1491 1520 If you have full color support under cygwin, please post to the IPython
1492 1521 mailing list so this issue can be resolved for all users.
1493 1522 \layout Standard
1494 1523
1495 1524 These have shown problems:
1496 1525 \layout Itemize
1497 1526
1498 1527 Windows command prompt in WinXP/2k logged into a Linux machine via telnet
1499 1528 or ssh.
1500 1529 \layout Itemize
1501 1530
1502 1531 Windows native command prompt in WinXP/2k,
1503 1532 \emph on
1504 1533 without
1505 1534 \emph default
1506 1535 Gary Bishop's extensions.
1507 1536 Once Gary's readline library is installed, the normal WinXP/2k command
1508 1537 prompt works perfectly.
1509 1538 \layout Standard
1510 1539
1511 1540 Currently the following color schemes are available:
1512 1541 \layout Itemize
1513 1542
1514 1543
1515 1544 \family typewriter
1516 1545 NoColor
1517 1546 \family default
1518 1547 : uses no color escapes at all (all escapes are empty
1519 1548 \begin_inset Quotes eld
1520 1549 \end_inset
1521 1550
1522 1551
1523 1552 \begin_inset Quotes eld
1524 1553 \end_inset
1525 1554
1526 1555 strings).
1527 1556 This 'scheme' is thus fully safe to use in any terminal.
1528 1557 \layout Itemize
1529 1558
1530 1559
1531 1560 \family typewriter
1532 1561 Linux
1533 1562 \family default
1534 1563 : works well in Linux console type environments: dark background with light
1535 1564 fonts.
1536 1565 It uses bright colors for information, so it is difficult to read if you
1537 1566 have a light colored background.
1538 1567 \layout Itemize
1539 1568
1540 1569
1541 1570 \family typewriter
1542 1571 LightBG
1543 1572 \family default
1544 1573 : the basic colors are similar to those in the
1545 1574 \family typewriter
1546 1575 Linux
1547 1576 \family default
1548 1577 scheme but darker.
1549 1578 It is easy to read in terminals with light backgrounds.
1550 1579 \layout Standard
1551 1580
1552 1581 IPython uses colors for two main groups of things: prompts and tracebacks
1553 1582 which are directly printed to the terminal, and the object introspection
1554 1583 system which passes large sets of data through a pager.
1555 1584 \layout Subsubsection
1556 1585
1557 1586 Input/Output prompts and exception tracebacks
1558 1587 \layout Standard
1559 1588
1560 1589 You can test whether the colored prompts and tracebacks work on your system
1561 1590 interactively by typing
1562 1591 \family typewriter
1563 1592 '%colors Linux'
1564 1593 \family default
1565 1594 at the prompt (use '
1566 1595 \family typewriter
1567 1596 %colors LightBG'
1568 1597 \family default
1569 1598 if your terminal has a light background).
1570 1599 If the input prompt shows garbage like:
1571 1600 \newline
1572 1601
1573 1602 \family typewriter
1574 1603 [0;32mIn [[1;32m1[0;32m]: [0;00m
1575 1604 \family default
1576 1605
1577 1606 \newline
1578 1607 instead of (in color) something like:
1579 1608 \newline
1580 1609
1581 1610 \family typewriter
1582 1611 In [1]:
1583 1612 \family default
1584 1613
1585 1614 \newline
1586 1615 this means that your terminal doesn't properly handle color escape sequences.
1587 1616 You can go to a 'no color' mode by typing '
1588 1617 \family typewriter
1589 1618 %colors NoColor
1590 1619 \family default
1591 1620 '.
1592 1621
1593 1622 \layout Standard
1594 1623
1595 1624 You can try using a different terminal emulator program.
1596 1625 To permanently set your color preferences, edit the file
1597 1626 \family typewriter
1598 1627 $HOME/.ipython/ipythonrc
1599 1628 \family default
1600 1629 and set the
1601 1630 \family typewriter
1602 1631 colors
1603 1632 \family default
1604 1633 option to the desired value.
1605 1634 \layout Subsubsection
1606 1635
1607 1636 Object details (types, docstrings, source code, etc.)
1608 1637 \layout Standard
1609 1638
1610 1639 IPython has a set of special functions for studying the objects you are
1611 1640 working with, discussed in detail in Sec.
1612 1641
1613 1642 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1614 1643
1615 1644 \end_inset
1616 1645
1617 1646 .
1618 1647 But this system relies on passing information which is longer than your
1619 1648 screen through a data pager, such as the common Unix
1620 1649 \family typewriter
1621 1650 less
1622 1651 \family default
1623 1652 and
1624 1653 \family typewriter
1625 1654 more
1626 1655 \family default
1627 1656 programs.
1628 1657 In order to be able to see this information in color, your pager needs
1629 1658 to be properly configured.
1630 1659 I strongly recommend using
1631 1660 \family typewriter
1632 1661 less
1633 1662 \family default
1634 1663 instead of
1635 1664 \family typewriter
1636 1665 more
1637 1666 \family default
1638 1667 , as it seems that
1639 1668 \family typewriter
1640 1669 more
1641 1670 \family default
1642 1671 simply can not understand colored text correctly.
1643 1672 \layout Standard
1644 1673
1645 1674 In order to configure
1646 1675 \family typewriter
1647 1676 less
1648 1677 \family default
1649 1678 as your default pager, do the following:
1650 1679 \layout Enumerate
1651 1680
1652 1681 Set the environment
1653 1682 \family typewriter
1654 1683 PAGER
1655 1684 \family default
1656 1685 variable to
1657 1686 \family typewriter
1658 1687 less
1659 1688 \family default
1660 1689 .
1661 1690 \layout Enumerate
1662 1691
1663 1692 Set the environment
1664 1693 \family typewriter
1665 1694 LESS
1666 1695 \family default
1667 1696 variable to
1668 1697 \family typewriter
1669 1698 -r
1670 1699 \family default
1671 1700 (plus any other options you always want to pass to
1672 1701 \family typewriter
1673 1702 less
1674 1703 \family default
1675 1704 by default).
1676 1705 This tells
1677 1706 \family typewriter
1678 1707 less
1679 1708 \family default
1680 1709 to properly interpret control sequences, which is how color information
1681 1710 is given to your terminal.
1682 1711 \layout Standard
1683 1712
1684 1713 For the
1685 1714 \family typewriter
1686 1715 csh
1687 1716 \family default
1688 1717 or
1689 1718 \family typewriter
1690 1719 tcsh
1691 1720 \family default
1692 1721 shells, add to your
1693 1722 \family typewriter
1694 1723 ~/.cshrc
1695 1724 \family default
1696 1725 file the lines:
1697 1726 \layout Standard
1698 1727
1699 1728
1700 1729 \family typewriter
1701 1730 setenv PAGER less
1702 1731 \newline
1703 1732 setenv LESS -r
1704 1733 \layout Standard
1705 1734
1706 1735 There is similar syntax for other Unix shells, look at your system documentation
1707 1736 for details.
1708 1737 \layout Standard
1709 1738
1710 1739 If you are on a system which lacks proper data pagers (such as Windows),
1711 1740 IPython will use a very limited builtin pager.
1712 1741 \layout Subsection
1713 1742
1714 1743
1715 1744 \begin_inset LatexCommand \label{sec:emacs}
1716 1745
1717 1746 \end_inset
1718 1747
1719 1748 (X)Emacs configuration
1720 1749 \layout Standard
1721 1750
1722 1751 Thanks to the work of Alexander Schmolck and Prabhu Ramachandran, currently
1723 1752 (X)Emacs and IPython get along very well.
1724 1753
1725 1754 \layout Standard
1726 1755
1727 1756
1728 1757 \series bold
1729 1758 Important note:
1730 1759 \series default
1731 1760 You will need to use a recent enough version of
1732 1761 \family typewriter
1733 1762 python-mode.el
1734 1763 \family default
1735 1764 , along with the file
1736 1765 \family typewriter
1737 1766 ipython.el
1738 1767 \family default
1739 1768 .
1740 1769 You can check that the version you have of
1741 1770 \family typewriter
1742 1771 python-mode.el
1743 1772 \family default
1744 1773 is new enough by either looking at the revision number in the file itself,
1745 1774 or asking for it in (X)Emacs via
1746 1775 \family typewriter
1747 1776 M-x py-version
1748 1777 \family default
1749 1778 .
1750 1779 Versions 4.68 and newer contain the necessary fixes for proper IPython support.
1751 1780 \layout Standard
1752 1781
1753 1782 The file
1754 1783 \family typewriter
1755 1784 ipython.el
1756 1785 \family default
1757 1786 is included with the IPython distribution, in the documentation directory
1758 1787 (where this manual resides in PDF and HTML formats).
1759 1788 \layout Standard
1760 1789
1761 1790 Once you put these files in your Emacs path, all you need in your
1762 1791 \family typewriter
1763 1792 .emacs
1764 1793 \family default
1765 1794 file is:
1766 1795 \layout Standard
1767 1796
1768 1797
1769 1798 \family typewriter
1770 1799 (require 'ipython)
1771 1800 \layout Standard
1772 1801
1773 1802 This should give you full support for executing code snippets via IPython,
1774 1803 opening IPython as your Python shell via
1775 1804 \family typewriter
1776 1805 C-c\SpecialChar ~
1777 1806 !
1778 1807 \family default
1779 1808 , etc.
1780 1809
1781 1810 \layout Subsubsection*
1782 1811
1783 1812 Notes
1784 1813 \layout Itemize
1785 1814
1786 1815 There is one caveat you should be aware of: you must start the IPython shell
1787 1816
1788 1817 \emph on
1789 1818 before
1790 1819 \emph default
1791 1820 attempting to execute any code regions via
1792 1821 \family typewriter
1793 1822 C-c\SpecialChar ~
1794 1823 |
1795 1824 \family default
1796 1825 .
1797 1826 Simply type
1798 1827 \family typewriter
1799 1828 C-c\SpecialChar ~
1800 1829 !
1801 1830 \family default
1802 1831 to start IPython before passing any code regions to the interpreter, and
1803 1832 you shouldn't experience any problems.
1804 1833 \newline
1805 1834 This is due to a bug in Python itself, which has been fixed for Python 2.3,
1806 1835 but exists as of Python 2.2.2 (reported as SF bug [ 737947 ]).
1807 1836 \layout Itemize
1808 1837
1809 1838 The (X)Emacs support is maintained by Alexander Schmolck, so all comments/reques
1810 1839 ts should be directed to him through the IPython mailing lists.
1811 1840
1812 1841 \layout Itemize
1813 1842
1814 1843 This code is still somewhat experimental so it's a bit rough around the
1815 1844 edges (although in practice, it works quite well).
1816 1845 \layout Itemize
1817 1846
1818 1847 Be aware that if you customize
1819 1848 \family typewriter
1820 1849 py-python-command
1821 1850 \family default
1822 1851 previously, this value will override what
1823 1852 \family typewriter
1824 1853 ipython.el
1825 1854 \family default
1826 1855 does (because loading the customization variables comes later).
1827 1856 \layout Section
1828 1857
1829 1858
1830 1859 \begin_inset LatexCommand \label{sec:quick_tips}
1831 1860
1832 1861 \end_inset
1833 1862
1834 1863 Quick tips
1835 1864 \layout Standard
1836 1865
1837 1866 IPython can be used as an improved replacement for the Python prompt, and
1838 1867 for that you don't really need to read any more of this manual.
1839 1868 But in this section we'll try to summarize a few tips on how to make the
1840 1869 most effective use of it for everyday Python development, highlighting
1841 1870 things you might miss in the rest of the manual (which is getting long).
1842 1871 We'll give references to parts in the manual which provide more detail
1843 1872 when appropriate.
1844 1873 \layout Standard
1845 1874
1846 1875 The following article by Jeremy Jones provides an introductory tutorial
1847 1876 about IPython:
1848 1877 \newline
1849 1878
1850 1879 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2005/01/27/ipython.html}
1851 1880
1852 1881 \end_inset
1853 1882
1854 1883
1855 1884 \layout Itemize
1856 1885
1857 1886 The TAB key.
1858 1887 TAB-completion, especially for attributes, is a convenient way to explore
1859 1888 the structure of any object you're dealing with.
1860 1889 Simply type
1861 1890 \family typewriter
1862 1891 object_name.<TAB>
1863 1892 \family default
1864 1893 and a list of the object's attributes will be printed (see sec.
1865 1894
1866 1895 \begin_inset LatexCommand \ref{sec:readline}
1867 1896
1868 1897 \end_inset
1869 1898
1870 1899 for more).
1871 1900 Tab completion also works on file and directory names, which combined with
1872 1901 IPython's alias system allows you to do from within IPython many of the
1873 1902 things you normally would need the system shell for.
1874 1903
1875 1904 \layout Itemize
1876 1905
1877 1906 Explore your objects.
1878 1907 Typing
1879 1908 \family typewriter
1880 1909 object_name?
1881 1910 \family default
1882 1911 will print all sorts of details about any object, including docstrings,
1883 1912 function definition lines (for call arguments) and constructor details
1884 1913 for classes.
1885 1914 The magic commands
1886 1915 \family typewriter
1887 1916 %pdoc
1888 1917 \family default
1889 1918 ,
1890 1919 \family typewriter
1891 1920 %pdef
1892 1921 \family default
1893 1922 ,
1894 1923 \family typewriter
1895 1924 %psource
1896 1925 \family default
1897 1926 and
1898 1927 \family typewriter
1899 1928 %pfile
1900 1929 \family default
1901 1930 will respectively print the docstring, function definition line, full source
1902 1931 code and the complete file for any object (when they can be found).
1903 1932 If automagic is on (it is by default), you don't need to type the '
1904 1933 \family typewriter
1905 1934 %
1906 1935 \family default
1907 1936 ' explicitly.
1908 1937 See sec.
1909 1938
1910 1939 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1911 1940
1912 1941 \end_inset
1913 1942
1914 1943 for more.
1915 1944 \layout Itemize
1916 1945
1917 1946 The
1918 1947 \family typewriter
1919 1948 %run
1920 1949 \family default
1921 1950 magic command allows you to run any python script and load all of its data
1922 1951 directly into the interactive namespace.
1923 1952 Since the file is re-read from disk each time, changes you make to it are
1924 1953 reflected immediately (in contrast to the behavior of
1925 1954 \family typewriter
1926 1955 import
1927 1956 \family default
1928 1957 ).
1929 1958 I rarely use
1930 1959 \family typewriter
1931 1960 import
1932 1961 \family default
1933 1962 for code I am testing, relying on
1934 1963 \family typewriter
1935 1964 %run
1936 1965 \family default
1937 1966 instead.
1938 1967 See sec.
1939 1968
1940 1969 \begin_inset LatexCommand \ref{sec:magic}
1941 1970
1942 1971 \end_inset
1943 1972
1944 1973 for more on this and other magic commands, or type the name of any magic
1945 1974 command and ? to get details on it.
1946 1975 See also sec.
1947 1976
1948 1977 \begin_inset LatexCommand \ref{sec:dreload}
1949 1978
1950 1979 \end_inset
1951 1980
1952 1981 for a recursive reload command.
1953 1982 \newline
1954 1983
1955 1984 \family typewriter
1956 1985 %run
1957 1986 \family default
1958 1987 also has special flags for timing the execution of your scripts (
1959 1988 \family typewriter
1960 1989 -t
1961 1990 \family default
1962 1991 ) and for executing them under the control of either Python's
1963 1992 \family typewriter
1964 1993 pdb
1965 1994 \family default
1966 1995 debugger (
1967 1996 \family typewriter
1968 1997 -d
1969 1998 \family default
1970 1999 ) or profiler (
1971 2000 \family typewriter
1972 2001 -p
1973 2002 \family default
1974 2003 ).
1975 2004 With all of these,
1976 2005 \family typewriter
1977 2006 %run
1978 2007 \family default
1979 2008 can be used as the main tool for efficient interactive development of code
1980 2009 which you write in your editor of choice.
1981 2010 \layout Itemize
1982 2011
1983 2012 Use the Python debugger,
1984 2013 \family typewriter
1985 2014 pdb
1986 2015 \family default
1987 2016
1988 2017 \begin_inset Foot
1989 2018 collapsed true
1990 2019
1991 2020 \layout Standard
1992 2021
1993 2022 Thanks to Christian Hart and Matthew Arnison for the suggestions leading
1994 2023 to IPython's improved debugger and profiler support.
1995 2024 \end_inset
1996 2025
1997 2026 .
1998 2027 The
1999 2028 \family typewriter
2000 2029 %pdb
2001 2030 \family default
2002 2031 command allows you to toggle on and off the automatic invocation of the
2003 2032 pdb debugger at any uncaught exception.
2004 2033 The advantage of this is that pdb starts
2005 2034 \emph on
2006 2035 inside
2007 2036 \emph default
2008 2037 the function where the exception occurred, with all data still available.
2009 2038 You can print variables, see code, execute statements and even walk up
2010 2039 and down the call stack to track down the true source of the problem (which
2011 2040 often is many layers in the stack above where the exception gets triggered).
2012 2041 \newline
2013 2042 Running programs with
2014 2043 \family typewriter
2015 2044 %run
2016 2045 \family default
2017 2046 and pdb active can be an efficient to develop and debug code, in many cases
2018 2047 eliminating the need for
2019 2048 \family typewriter
2020 2049 print
2021 2050 \family default
2022 2051 statements or external debugging tools.
2023 2052 I often simply put a
2024 2053 \family typewriter
2025 2054 1/0
2026 2055 \family default
2027 2056 in a place where I want to take a look so that pdb gets called, quickly
2028 2057 view whatever variables I need to or test various pieces of code and then
2029 2058 remove the
2030 2059 \family typewriter
2031 2060 1/0
2032 2061 \family default
2033 2062 .
2034 2063 \newline
2035 2064 Note also that `
2036 2065 \family typewriter
2037 2066 %run -d
2038 2067 \family default
2039 2068 ' activates
2040 2069 \family typewriter
2041 2070 pdb
2042 2071 \family default
2043 2072 and automatically sets initial breakpoints for you to step through your
2044 2073 code, watch variables, etc.
2045 2074 See Sec.\SpecialChar ~
2046 2075
2047 2076 \begin_inset LatexCommand \ref{sec:cache_output}
2048 2077
2049 2078 \end_inset
2050 2079
2051 2080 for details.
2052 2081 \layout Itemize
2053 2082
2054 2083 Use the output cache.
2055 2084 All output results are automatically stored in a global dictionary named
2056 2085
2057 2086 \family typewriter
2058 2087 Out
2059 2088 \family default
2060 2089 and variables named
2061 2090 \family typewriter
2062 2091 _1
2063 2092 \family default
2064 2093 ,
2065 2094 \family typewriter
2066 2095 _2
2067 2096 \family default
2068 2097 , etc.
2069 2098 alias them.
2070 2099 For example, the result of input line 4 is available either as
2071 2100 \family typewriter
2072 2101 Out[4]
2073 2102 \family default
2074 2103 or as
2075 2104 \family typewriter
2076 2105 _4
2077 2106 \family default
2078 2107 .
2079 2108 Additionally, three variables named
2080 2109 \family typewriter
2081 2110 _
2082 2111 \family default
2083 2112 ,
2084 2113 \family typewriter
2085 2114 __
2086 2115 \family default
2087 2116 and
2088 2117 \family typewriter
2089 2118 ___
2090 2119 \family default
2091 2120 are always kept updated with the for the last three results.
2092 2121 This allows you to recall any previous result and further use it for new
2093 2122 calculations.
2094 2123 See Sec.\SpecialChar ~
2095 2124
2096 2125 \begin_inset LatexCommand \ref{sec:cache_output}
2097 2126
2098 2127 \end_inset
2099 2128
2100 2129 for more.
2101 2130 \layout Itemize
2102 2131
2103 2132 Put a '
2104 2133 \family typewriter
2105 2134 ;
2106 2135 \family default
2107 2136 ' at the end of a line to supress the printing of output.
2108 2137 This is useful when doing calculations which generate long output you are
2109 2138 not interested in seeing.
2110 2139 The
2111 2140 \family typewriter
2112 2141 _*
2113 2142 \family default
2114 2143 variables and the
2115 2144 \family typewriter
2116 2145 Out[]
2117 2146 \family default
2118 2147 list do get updated with the contents of the output, even if it is not
2119 2148 printed.
2120 2149 You can thus still access the generated results this way for further processing.
2121 2150 \layout Itemize
2122 2151
2123 2152 A similar system exists for caching input.
2124 2153 All input is stored in a global list called
2125 2154 \family typewriter
2126 2155 In
2127 2156 \family default
2128 2157 , so you can re-execute lines 22 through 28 plus line 34 by typing
2129 2158 \family typewriter
2130 2159 'exec In[22:29]+In[34]'
2131 2160 \family default
2132 2161 (using Python slicing notation).
2133 2162 If you need to execute the same set of lines often, you can assign them
2134 2163 to a macro with the
2135 2164 \family typewriter
2136 2165 %macro
2137 2166 \family default
2138 2167
2139 2168 \family typewriter
2140 2169 function.
2141 2170
2142 2171 \family default
2143 2172 See sec.
2144 2173
2145 2174 \begin_inset LatexCommand \ref{sec:cache_input}
2146 2175
2147 2176 \end_inset
2148 2177
2149 2178 for more.
2150 2179 \layout Itemize
2151 2180
2152 2181 Use your input history.
2153 2182 The
2154 2183 \family typewriter
2155 2184 %hist
2156 2185 \family default
2157 2186 command can show you all previous input, without line numbers if desired
2158 2187 (option
2159 2188 \family typewriter
2160 2189 -n
2161 2190 \family default
2162 2191 ) so you can directly copy and paste code either back in IPython or in a
2163 2192 text editor.
2164 2193 You can also save all your history by turning on logging via
2165 2194 \family typewriter
2166 2195 %logstart
2167 2196 \family default
2168 2197 ; these logs can later be either reloaded as IPython sessions or used as
2169 2198 code for your programs.
2170 2199 \layout Itemize
2171 2200
2172 2201 Define your own macros with
2173 2202 \family typewriter
2174 2203 %macro
2175 2204 \family default
2176 2205 .
2177 2206 This can be useful for automating sequences of expressions when working
2178 2207 interactively.
2179 2208 \layout Itemize
2180 2209
2181 2210 Define your own system aliases.
2182 2211 Even though IPython gives you access to your system shell via the
2183 2212 \family typewriter
2184 2213 !
2185 2214 \family default
2186 2215 prefix, it is convenient to have aliases to the system commands you use
2187 2216 most often.
2188 2217 This allows you to work seamlessly from inside IPython with the same commands
2189 2218 you are used to in your system shell.
2190 2219 \newline
2191 2220 IPython comes with some pre-defined aliases and a complete system for changing
2192 2221 directories, both via a stack (see
2193 2222 \family typewriter
2194 2223 %pushd
2195 2224 \family default
2196 2225 ,
2197 2226 \family typewriter
2198 2227 %popd
2199 2228 \family default
2200 2229 and
2201 2230 \family typewriter
2202 2231 %ds
2203 2232 \family default
2204 2233 ) and via direct
2205 2234 \family typewriter
2206 2235 %cd
2207 2236 \family default
2208 2237 .
2209 2238 The latter keeps a history of visited directories and allows you to go
2210 2239 to any previously visited one.
2211 2240 \layout Itemize
2212 2241
2213 2242 Use Python to manipulate the results of system commands.
2214 2243 The `
2215 2244 \family typewriter
2216 2245 !!
2217 2246 \family default
2218 2247 ' special syntax, and the
2219 2248 \family typewriter
2220 2249 %sc
2221 2250 \family default
2222 2251 and
2223 2252 \family typewriter
2224 2253 %sx
2225 2254 \family default
2226 2255 magic commands allow you to capture system output into Python variables.
2227 2256 \layout Itemize
2228 2257
2229 2258 Expand python variables when calling the shell (either via
2230 2259 \family typewriter
2231 2260 `!'
2232 2261 \family default
2233 2262 and
2234 2263 \family typewriter
2235 2264 `!!'
2236 2265 \family default
2237 2266 or via aliases) by prepending a
2238 2267 \family typewriter
2239 2268 $
2240 2269 \family default
2241 2270 in front of them.
2242 2271 You can also expand complete python expressions.
2243 2272 See sec.\SpecialChar ~
2244 2273
2245 2274 \begin_inset LatexCommand \ref{sub:System-shell-access}
2246 2275
2247 2276 \end_inset
2248 2277
2249 2278 for more.
2250 2279 \layout Itemize
2251 2280
2252 2281 Use profiles to maintain different configurations (modules to load, function
2253 2282 definitions, option settings) for particular tasks.
2254 2283 You can then have customized versions of IPython for specific purposes.
2255 2284 See sec.\SpecialChar ~
2256 2285
2257 2286 \begin_inset LatexCommand \ref{sec:profiles}
2258 2287
2259 2288 \end_inset
2260 2289
2261 2290 for more.
2262 2291 \layout Itemize
2263 2292
2264 2293 Embed IPython in your programs.
2265 2294 A few lines of code are enough to load a complete IPython inside your own
2266 2295 programs, giving you the ability to work with your data interactively after
2267 2296 automatic processing has been completed.
2268 2297 See sec.\SpecialChar ~
2269 2298
2270 2299 \begin_inset LatexCommand \ref{sec:embed}
2271 2300
2272 2301 \end_inset
2273 2302
2274 2303 for more.
2275 2304 \layout Itemize
2276 2305
2277 2306 Use the Python profiler.
2278 2307 When dealing with performance issues, the
2279 2308 \family typewriter
2280 2309 %run
2281 2310 \family default
2282 2311 command with a
2283 2312 \family typewriter
2284 2313 -p
2285 2314 \family default
2286 2315 option allows you to run complete programs under the control of the Python
2287 2316 profiler.
2288 2317 The
2289 2318 \family typewriter
2290 2319 %prun
2291 2320 \family default
2292 2321 command does a similar job for single Python expressions (like function
2293 2322 calls).
2294 2323 \layout Itemize
2295 2324
2296 2325 Use
2297 2326 \family typewriter
2298 2327 %edit
2299 2328 \family default
2300 2329 to have almost multiline editing.
2301 2330 While IPython doesn't support true multiline editing, this command allows
2302 2331 you to call an editor on the spot, and IPython will execute the code you
2303 2332 type in there as if it were typed interactively.
2304 2333 \layout Itemize
2305 2334
2306 2335 Use the IPython.demo.Demo class to load any Python script as an interactive
2307 2336 demo.
2308 2337 With a minimal amount of simple markup, you can control the execution of
2309 2338 the script, stopping as needed.
2310 2339 See sec.\SpecialChar ~
2311 2340
2312 2341 \begin_inset LatexCommand \ref{sec:interactive-demos}
2313 2342
2314 2343 \end_inset
2315 2344
2316 2345 for more.
2317 2346 \layout Standard
2318 2347
2319 2348 If you have your own favorite tip on using IPython efficiently for a certain
2320 2349 task (especially things which can't be done in the normal Python interpreter),
2321 2350 don't hesitate to send it!
2322 2351 \layout Section
2323 2352
2324 2353 Command-line use
2325 2354 \layout Standard
2326 2355
2327 2356 You start IPython with the command:
2328 2357 \layout Standard
2329 2358
2330 2359
2331 2360 \family typewriter
2332 2361 $ ipython [options] files
2333 2362 \layout Standard
2334 2363
2335 2364 If invoked with no options, it executes all the files listed in sequence
2336 2365 and drops you into the interpreter while still acknowledging any options
2337 2366 you may have set in your ipythonrc file.
2338 2367 This behavior is different from standard Python, which when called as
2339 2368 \family typewriter
2340 2369 python -i
2341 2370 \family default
2342 2371 will only execute one file and ignore your configuration setup.
2343 2372 \layout Standard
2344 2373
2345 2374 Please note that some of the configuration options are not available at
2346 2375 the command line, simply because they are not practical here.
2347 2376 Look into your ipythonrc configuration file for details on those.
2348 2377 This file typically installed in the
2349 2378 \family typewriter
2350 2379 $HOME/.ipython
2351 2380 \family default
2352 2381 directory.
2353 2382 For Windows users,
2354 2383 \family typewriter
2355 2384 $HOME
2356 2385 \family default
2357 2386 resolves to
2358 2387 \family typewriter
2359 2388 C:
2360 2389 \backslash
2361 2390
2362 2391 \backslash
2363 2392 Documents and Settings
2364 2393 \backslash
2365 2394
2366 2395 \backslash
2367 2396 YourUserName
2368 2397 \family default
2369 2398 in most instances.
2370 2399 In the rest of this text, we will refer to this directory as
2371 2400 \family typewriter
2372 2401 IPYTHONDIR
2373 2402 \family default
2374 2403 .
2375 2404 \layout Subsection
2376 2405
2377 2406
2378 2407 \begin_inset LatexCommand \label{sec:threading-opts}
2379 2408
2380 2409 \end_inset
2381 2410
2382 2411 Special Threading Options
2383 2412 \layout Standard
2384 2413
2385 2414 The following special options are ONLY valid at the beginning of the command
2386 2415 line, and not later.
2387 2416 This is because they control the initial- ization of ipython itself, before
2388 2417 the normal option-handling mechanism is active.
2389 2418 \layout List
2390 2419 \labelwidthstring 00.00.0000
2391 2420
2392 2421
2393 2422 \family typewriter
2394 2423 \series bold
2395 2424 -gthread,\SpecialChar ~
2425 -qthread,\SpecialChar ~
2396 2426 -wthread,\SpecialChar ~
2397 2427 -pylab:
2398 2428 \family default
2399 2429 \series default
2400 2430 Only
2401 2431 \emph on
2402 2432 one
2403 2433 \emph default
2404 2434 of these can be given, and it can only be given as the first option passed
2405 2435 to IPython (it will have no effect in any other position).
2406 They provide threading support for the GTK and WXPython toolkits, and for
2407 the matplotlib library.
2436 They provide threading support for the GTK Qt and WXPython toolkits, and
2437 for the matplotlib library.
2408 2438 \layout List
2409 2439 \labelwidthstring 00.00.0000
2410 2440
2411 2441 \SpecialChar ~
2412 If
2413 \family typewriter
2414 -gthread
2415 \family default
2416 is given, IPython starts running a separate thread for GTK operation, so
2417 that pyGTK-based programs can open and control GUIs without blocking IPython.
2418
2419 \layout List
2420 \labelwidthstring 00.00.0000
2421
2422 \SpecialChar ~
2423 Similarly,
2424 \family typewriter
2425 -wthread
2426 \family default
2427 instantiates IPython with threading support for the WXPython toolkit.
2428 You can control WX application windows from within IPython.
2442 With any of the first three options, IPython starts running a separate
2443 thread for the graphical toolkit's operation, so that you can open and
2444 control graphical elements from within an IPython command line, without
2445 blocking.
2446 All three provide essentially the same functionality, respectively for
2447 GTK, QT and WXWidgets (via their Python interfaces).
2429 2448 \layout List
2430 2449 \labelwidthstring 00.00.0000
2431 2450
2432 2451 \SpecialChar ~
2433 2452 If
2434 2453 \family typewriter
2435 2454 -pylab
2436 2455 \family default
2437 is given, IPython loads special support for the mat- plotlib library (
2456 is given, IPython loads special support for the mat plotlib library (
2438 2457 \begin_inset LatexCommand \htmlurl{http://matplotlib.sourceforge.net}
2439 2458
2440 2459 \end_inset
2441 2460
2442 2461 ), allowing interactive usage of any of its backends as defined in the user's
2443 .matplotlibrc file.
2444 It automatically activates GTK or WX threading for IPyhton if the choice
2462
2463 \family typewriter
2464 ~/.matplotlib/matplotlibrc
2465 \family default
2466 file.
2467 It automatically activates GTK, Qt or WX threading for IPyhton if the choice
2445 2468 of matplotlib backend requires it.
2446 2469 It also modifies the
2447 2470 \family typewriter
2448 2471 %run
2449 2472 \family default
2450 2473 command to correctly execute (without blocking) any matplotlib-based script
2451 2474 which calls
2452 2475 \family typewriter
2453 2476 show()
2454 2477 \family default
2455 2478 at the end.
2456 2479
2457 2480 \layout List
2458 2481 \labelwidthstring 00.00.0000
2459 2482
2460 2483
2461 2484 \family typewriter
2462 2485 \series bold
2463 2486 -tk
2464 2487 \family default
2465 2488 \series default
2466 2489 The
2467 2490 \family typewriter
2468 -g/wthread
2491 -g/q/wthread
2469 2492 \family default
2470 2493 options, and
2471 2494 \family typewriter
2472 2495 -pylab
2473 2496 \family default
2474 (if matplotlib is configured to use WX or GTK), will normally block Tk
2475 graphical interfaces.
2476 This means that when either GTK or WX threading is active, any attempt
2477 to open a Tk GUI will result in a dead window, and pos- sibly cause the
2478 Python interpreter to crash.
2497 (if matplotlib is configured to use GTK, Qt or WX), will normally block
2498 Tk graphical interfaces.
2499 This means that when either GTK, Qt or WX threading is active, any attempt
2500 to open a Tk GUI will result in a dead window, and possibly cause the Python
2501 interpreter to crash.
2479 2502 An extra option,
2480 2503 \family typewriter
2481 2504 -tk
2482 2505 \family default
2483 2506 , is available to address this issue.
2484 2507 It can
2485 2508 \emph on
2486 2509 only
2487 2510 \emph default
2488 2511 be given as a
2489 2512 \emph on
2490 2513 second
2491 2514 \emph default
2492 2515 option after any of the above (
2493 2516 \family typewriter
2494 2517 -gthread
2495 2518 \family default
2496 2519 ,
2497 2520 \family typewriter
2498 2521 -wthread
2499 2522 \family default
2500 2523 or
2501 2524 \family typewriter
2502 2525 -pylab
2503 2526 \family default
2504 2527 ).
2505 2528 \layout List
2506 2529 \labelwidthstring 00.00.0000
2507 2530
2508 2531 \SpecialChar ~
2509 2532 If
2510 2533 \family typewriter
2511 2534 -tk
2512 2535 \family default
2513 is given, IPython will try to coordinate Tk threading with WX or GTK.
2536 is given, IPython will try to coordinate Tk threading with GTK, Qt or WX.
2514 2537 This is however potentially unreliable, and you will have to test on your
2515 2538 platform and Python configuration to determine whether it works for you.
2516 2539 Debian users have reported success, apparently due to the fact that Debian
2517 2540 builds all of Tcl, Tk, Tkinter and Python with pthreads support.
2518 Under other Linux environments (such as Fedora Core 2), this option has
2541 Under other Linux environments (such as Fedora Core 2/3), this option has
2519 2542 caused random crashes and lockups of the Python interpreter.
2520 2543 Under other operating systems (Mac OSX and Windows), you'll need to try
2521 2544 it to find out, since currently no user reports are available.
2522 2545 \layout List
2523 2546 \labelwidthstring 00.00.0000
2524 2547
2525 2548 \SpecialChar ~
2526 2549 There is unfortunately no way for IPython to determine at run time whether
2527 2550
2528 2551 \family typewriter
2529 2552 -tk
2530 2553 \family default
2531 2554 will work reliably or not, so you will need to do some experiments before
2532 2555 relying on it for regular work.
2533 2556
2534 2557 \layout Subsection
2535 2558
2536 2559
2537 2560 \begin_inset LatexCommand \label{sec:cmd-line-opts}
2538 2561
2539 2562 \end_inset
2540 2563
2541 2564 Regular Options
2542 2565 \layout Standard
2543 2566
2544 2567 After the above threading options have been given, regular options can follow
2545 2568 in any order.
2546 2569 All options can be abbreviated to their shortest non-ambiguous form and
2547 2570 are case-sensitive.
2548 2571 One or two dashes can be used.
2549 2572 Some options have an alternate short form, indicated after a
2550 2573 \family typewriter
2551 2574 |
2552 2575 \family default
2553 2576 .
2554 2577 \layout Standard
2555 2578
2556 2579 Most options can also be set from your ipythonrc configuration file.
2557 2580 See the provided example for more details on what the options do.
2558 2581 Options given at the command line override the values set in the ipythonrc
2559 2582 file.
2560 2583 \layout Standard
2561 2584
2562 2585 All options with a
2563 2586 \family typewriter
2564 2587 no|
2565 2588 \family default
2566 2589 prepended can be specified in 'no' form (
2567 2590 \family typewriter
2568 2591 -nooption
2569 2592 \family default
2570 2593 instead of
2571 2594 \family typewriter
2572 2595 -option
2573 2596 \family default
2574 2597 ) to turn the feature off.
2575 2598 \layout List
2576 2599 \labelwidthstring 00.00.0000
2577 2600
2578 2601
2579 2602 \family typewriter
2580 2603 \series bold
2581 2604 -help
2582 2605 \family default
2583 2606 \series default
2584 2607 : print a help message and exit.
2585 2608 \layout List
2586 2609 \labelwidthstring 00.00.0000
2587 2610
2588 2611
2589 2612 \family typewriter
2590 2613 \series bold
2591 2614 -pylab:
2592 2615 \family default
2593 2616 \series default
2594 2617 this can
2595 2618 \emph on
2596 2619 only
2597 2620 \emph default
2598 2621 be given as the
2599 2622 \emph on
2600 2623 first
2601 2624 \emph default
2602 2625 option passed to IPython (it will have no effect in any other position).
2603 2626 It adds special support for the matplotlib library (
2604 2627 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
2605 2628
2606 2629 \end_inset
2607 2630
2608 2631 ), allowing interactive usage of any of its backends as defined in the user's
2609 2632
2610 2633 \family typewriter
2611 2634 .matplotlibrc
2612 2635 \family default
2613 2636 file.
2614 2637 It automatically activates GTK or WX threading for IPyhton if the choice
2615 2638 of matplotlib backend requires it.
2616 2639 It also modifies the
2617 2640 \family typewriter
2618 2641 %run
2619 2642 \family default
2620 2643 command to correctly execute (without blocking) any matplotlib-based script
2621 2644 which calls
2622 2645 \family typewriter
2623 2646 show()
2624 2647 \family default
2625 2648 at the end.
2626 2649 See Sec.\SpecialChar ~
2627 2650
2628 2651 \begin_inset LatexCommand \ref{sec:matplotlib-support}
2629 2652
2630 2653 \end_inset
2631 2654
2632 2655 for more details.
2633 2656 \layout List
2634 2657 \labelwidthstring 00.00.0000
2635 2658
2636 2659
2637 2660 \family typewriter
2638 2661 \series bold
2639 2662 -no|automagic
2640 2663 \series default
2641 2664 :
2642 2665 \family default
2643 2666 make magic commands automatic (without needing their first character to
2644 2667 be
2645 2668 \family typewriter
2646 2669 %
2647 2670 \family default
2648 2671 ).
2649 2672 Type
2650 2673 \family typewriter
2651 2674 %magic
2652 2675 \family default
2653 2676 at the IPython prompt for more information.
2654 2677 \layout List
2655 2678 \labelwidthstring 00.00.0000
2656 2679
2657 2680
2658 2681 \family typewriter
2659 2682 \series bold
2660 2683 -no|banner
2661 2684 \series default
2662 2685 :
2663 2686 \family default
2664 2687 Print the initial information banner (default on).
2665 2688 \layout List
2666 2689 \labelwidthstring 00.00.0000
2667 2690
2668 2691
2669 2692 \family typewriter
2670 2693 \series bold
2671 2694 -c\SpecialChar ~
2672 2695 <command>:
2673 2696 \family default
2674 2697 \series default
2675 2698 execute the given command string, and set sys.argv to
2676 2699 \family typewriter
2677 2700 ['c']
2678 2701 \family default
2679 2702 .
2680 2703 This is similar to the
2681 2704 \family typewriter
2682 2705 -c
2683 2706 \family default
2684 2707 option in the normal Python interpreter.
2685 2708
2686 2709 \layout List
2687 2710 \labelwidthstring 00.00.0000
2688 2711
2689 2712
2690 2713 \family typewriter
2691 2714 \series bold
2692 2715 -cache_size|cs\SpecialChar ~
2693 2716 <n>
2694 2717 \series default
2695 2718 :
2696 2719 \family default
2697 2720 size of the output cache (maximum number of entries to hold in memory).
2698 2721 The default is 1000, you can change it permanently in your config file.
2699 2722 Setting it to 0 completely disables the caching system, and the minimum
2700 2723 value accepted is 20 (if you provide a value less than 20, it is reset
2701 2724 to 0 and a warning is issued) This limit is defined because otherwise you'll
2702 2725 spend more time re-flushing a too small cache than working.
2703 2726 \layout List
2704 2727 \labelwidthstring 00.00.0000
2705 2728
2706 2729
2707 2730 \family typewriter
2708 2731 \series bold
2709 2732 -classic|cl
2710 2733 \series default
2711 2734 :
2712 2735 \family default
2713 2736 Gives IPython a similar feel to the classic Python prompt.
2714 2737 \layout List
2715 2738 \labelwidthstring 00.00.0000
2716 2739
2717 2740
2718 2741 \family typewriter
2719 2742 \series bold
2720 2743 -colors\SpecialChar ~
2721 2744 <scheme>:
2722 2745 \family default
2723 2746 \series default
2724 2747 Color scheme for prompts and exception reporting.
2725 2748 Currently implemented: NoColor, Linux and LightBG.
2726 2749 \layout List
2727 2750 \labelwidthstring 00.00.0000
2728 2751
2729 2752
2730 2753 \family typewriter
2731 2754 \series bold
2732 2755 -no|color_info:
2733 2756 \family default
2734 2757 \series default
2735 2758 IPython can display information about objects via a set of functions, and
2736 2759 optionally can use colors for this, syntax highlighting source code and
2737 2760 various other elements.
2738 2761 However, because this information is passed through a pager (like 'less')
2739 2762 and many pagers get confused with color codes, this option is off by default.
2740 2763 You can test it and turn it on permanently in your ipythonrc file if it
2741 2764 works for you.
2742 2765 As a reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
2743 2766 that in RedHat 7.2 doesn't.
2744 2767 \layout List
2745 2768 \labelwidthstring 00.00.0000
2746 2769
2747 2770 \SpecialChar ~
2748 2771 Test it and turn it on permanently if it works with your system.
2749 2772 The magic function
2750 2773 \family typewriter
2751 2774 %color_info
2752 2775 \family default
2753 2776 allows you to toggle this interactively for testing.
2754 2777 \layout List
2755 2778 \labelwidthstring 00.00.0000
2756 2779
2757 2780
2758 2781 \family typewriter
2759 2782 \series bold
2760 2783 -no|debug
2761 2784 \family default
2762 2785 \series default
2763 2786 : Show information about the loading process.
2764 2787 Very useful to pin down problems with your configuration files or to get
2765 2788 details about session restores.
2766 2789 \layout List
2767 2790 \labelwidthstring 00.00.0000
2768 2791
2769 2792
2770 2793 \family typewriter
2771 2794 \series bold
2772 2795 -no|deep_reload
2773 2796 \series default
2774 2797 :
2775 2798 \family default
2776 2799 IPython can use the
2777 2800 \family typewriter
2778 2801 deep_reload
2779 2802 \family default
2780 2803 module which reloads changes in modules recursively (it replaces the
2781 2804 \family typewriter
2782 2805 reload()
2783 2806 \family default
2784 2807 function, so you don't need to change anything to use it).
2785 2808
2786 2809 \family typewriter
2787 2810 deep_reload()
2788 2811 \family default
2789 2812 forces a full reload of modules whose code may have changed, which the
2790 2813 default
2791 2814 \family typewriter
2792 2815 reload()
2793 2816 \family default
2794 2817 function does not.
2795 2818 \layout List
2796 2819 \labelwidthstring 00.00.0000
2797 2820
2798 2821 \SpecialChar ~
2799 2822 When deep_reload is off, IPython will use the normal
2800 2823 \family typewriter
2801 2824 reload()
2802 2825 \family default
2803 2826 , but deep_reload will still be available as
2804 2827 \family typewriter
2805 2828 dreload()
2806 2829 \family default
2807 2830 .
2808 2831 This feature is off by default [which means that you have both normal
2809 2832 \family typewriter
2810 2833 reload()
2811 2834 \family default
2812 2835 and
2813 2836 \family typewriter
2814 2837 dreload()
2815 2838 \family default
2816 2839 ].
2817 2840 \layout List
2818 2841 \labelwidthstring 00.00.0000
2819 2842
2820 2843
2821 2844 \family typewriter
2822 2845 \series bold
2823 2846 -editor\SpecialChar ~
2824 2847 <name>
2825 2848 \family default
2826 2849 \series default
2827 2850 : Which editor to use with the
2828 2851 \family typewriter
2829 2852 %edit
2830 2853 \family default
2831 2854 command.
2832 2855 By default, IPython will honor your
2833 2856 \family typewriter
2834 2857 EDITOR
2835 2858 \family default
2836 2859 environment variable (if not set, vi is the Unix default and notepad the
2837 2860 Windows one).
2838 2861 Since this editor is invoked on the fly by IPython and is meant for editing
2839 2862 small code snippets, you may want to use a small, lightweight editor here
2840 2863 (in case your default
2841 2864 \family typewriter
2842 2865 EDITOR
2843 2866 \family default
2844 2867 is something like Emacs).
2845 2868 \layout List
2846 2869 \labelwidthstring 00.00.0000
2847 2870
2848 2871
2849 2872 \family typewriter
2850 2873 \series bold
2851 2874 -ipythondir\SpecialChar ~
2852 2875 <name>
2853 2876 \series default
2854 2877 :
2855 2878 \family default
2856 2879 name of your IPython configuration directory
2857 2880 \family typewriter
2858 2881 IPYTHONDIR
2859 2882 \family default
2860 2883 .
2861 2884 This can also be specified through the environment variable
2862 2885 \family typewriter
2863 2886 IPYTHONDIR
2864 2887 \family default
2865 2888 .
2866 2889 \layout List
2867 2890 \labelwidthstring 00.00.0000
2868 2891
2869 2892
2870 2893 \family typewriter
2871 2894 \series bold
2872 2895 -log|l
2873 2896 \family default
2874 2897 \series default
2875 2898 : generate a log file of all input.
2876 2899 Defaults to
2877 2900 \family typewriter
2878 2901 $IPYTHONDIR/log
2879 2902 \family default
2880 2903 .
2881 2904 You can use this to later restore a session by loading your logfile as
2882 2905 a file to be executed with option
2883 2906 \family typewriter
2884 2907 -logplay
2885 2908 \family default
2886 2909 (see below).
2887 2910 \layout List
2888 2911 \labelwidthstring 00.00.0000
2889 2912
2890 2913
2891 2914 \family typewriter
2892 2915 \series bold
2893 2916 -logfile|lf\SpecialChar ~
2894 2917 <name>
2895 2918 \series default
2896 2919 :
2897 2920 \family default
2898 2921 specify the name of your logfile.
2899 2922 \layout List
2900 2923 \labelwidthstring 00.00.0000
2901 2924
2902 2925
2903 2926 \family typewriter
2904 2927 \series bold
2905 2928 -logplay|lp\SpecialChar ~
2906 2929 <name>
2907 2930 \series default
2908 2931 :
2909 2932 \family default
2910 2933 you can replay a previous log.
2911 2934 For restoring a session as close as possible to the state you left it in,
2912 2935 use this option (don't just run the logfile).
2913 2936 With
2914 2937 \family typewriter
2915 2938 -logplay
2916 2939 \family default
2917 2940 , IPython will try to reconstruct the previous working environment in full,
2918 2941 not just execute the commands in the logfile.
2919 2942 \layout List
2920 2943 \labelwidthstring 00.00.0000
2921 2944
2922 2945 \SpecialChar ~
2923 2946 When a session is restored, logging is automatically turned on again with
2924 2947 the name of the logfile it was invoked with (it is read from the log header).
2925 2948 So once you've turned logging on for a session, you can quit IPython and
2926 2949 reload it as many times as you want and it will continue to log its history
2927 2950 and restore from the beginning every time.
2928 2951 \layout List
2929 2952 \labelwidthstring 00.00.0000
2930 2953
2931 2954 \SpecialChar ~
2932 2955 Caveats: there are limitations in this option.
2933 2956 The history variables
2934 2957 \family typewriter
2935 2958 _i*
2936 2959 \family default
2937 2960 ,
2938 2961 \family typewriter
2939 2962 _*
2940 2963 \family default
2941 2964 and
2942 2965 \family typewriter
2943 2966 _dh
2944 2967 \family default
2945 2968 don't get restored properly.
2946 2969 In the future we will try to implement full session saving by writing and
2947 2970 retrieving a 'snapshot' of the memory state of IPython.
2948 2971 But our first attempts failed because of inherent limitations of Python's
2949 2972 Pickle module, so this may have to wait.
2950 2973 \layout List
2951 2974 \labelwidthstring 00.00.0000
2952 2975
2953 2976
2954 2977 \family typewriter
2955 2978 \series bold
2956 2979 -no|messages
2957 2980 \series default
2958 2981 :
2959 2982 \family default
2960 2983 Print messages which IPython collects about its startup process (default
2961 2984 on).
2962 2985 \layout List
2963 2986 \labelwidthstring 00.00.0000
2964 2987
2965 2988
2966 2989 \family typewriter
2967 2990 \series bold
2968 2991 -no|pdb
2969 2992 \family default
2970 2993 \series default
2971 2994 : Automatically call the pdb debugger after every uncaught exception.
2972 2995 If you are used to debugging using pdb, this puts you automatically inside
2973 2996 of it after any call (either in IPython or in code called by it) which
2974 2997 triggers an exception which goes uncaught.
2975 2998 \layout List
2976 2999 \labelwidthstring 00.00.0000
2977 3000
2978 3001
2979 3002 \family typewriter
2980 3003 \series bold
2981 3004 -no|pprint
2982 3005 \series default
2983 3006 :
2984 3007 \family default
2985 3008 ipython can optionally use the pprint (pretty printer) module for displaying
2986 3009 results.
2987 3010 pprint tends to give a nicer display of nested data structures.
2988 3011 If you like it, you can turn it on permanently in your config file (default
2989 3012 off).
2990 3013 \layout List
2991 3014 \labelwidthstring 00.00.0000
2992 3015
2993 3016
2994 3017 \family typewriter
2995 3018 \series bold
2996 3019 -profile|p <name>
2997 3020 \series default
2998 3021 :
2999 3022 \family default
3000 3023 assume that your config file is
3001 3024 \family typewriter
3002 3025 ipythonrc-<name>
3003 3026 \family default
3004 3027 (looks in current dir first, then in
3005 3028 \family typewriter
3006 3029 IPYTHONDIR
3007 3030 \family default
3008 3031 ).
3009 3032 This is a quick way to keep and load multiple config files for different
3010 3033 tasks, especially if you use the include option of config files.
3011 3034 You can keep a basic
3012 3035 \family typewriter
3013 3036 IPYTHONDIR/ipythonrc
3014 3037 \family default
3015 3038 file and then have other 'profiles' which include this one and load extra
3016 3039 things for particular tasks.
3017 3040 For example:
3018 3041 \layout List
3019 3042 \labelwidthstring 00.00.0000
3020 3043
3021 3044
3022 3045 \family typewriter
3023 3046 \SpecialChar ~
3024 3047
3025 3048 \family default
3026 3049 1.
3027 3050
3028 3051 \family typewriter
3029 3052 $HOME/.ipython/ipythonrc
3030 3053 \family default
3031 3054 : load basic things you always want.
3032 3055 \layout List
3033 3056 \labelwidthstring 00.00.0000
3034 3057
3035 3058
3036 3059 \family typewriter
3037 3060 \SpecialChar ~
3038 3061
3039 3062 \family default
3040 3063 2.
3041 3064
3042 3065 \family typewriter
3043 3066 $HOME/.ipython/ipythonrc-math
3044 3067 \family default
3045 3068 : load (1) and basic math-related modules.
3046 3069
3047 3070 \layout List
3048 3071 \labelwidthstring 00.00.0000
3049 3072
3050 3073
3051 3074 \family typewriter
3052 3075 \SpecialChar ~
3053 3076
3054 3077 \family default
3055 3078 3.
3056 3079
3057 3080 \family typewriter
3058 3081 $HOME/.ipython/ipythonrc-numeric
3059 3082 \family default
3060 3083 : load (1) and Numeric and plotting modules.
3061 3084 \layout List
3062 3085 \labelwidthstring 00.00.0000
3063 3086
3064 3087 \SpecialChar ~
3065 3088 Since it is possible to create an endless loop by having circular file
3066 3089 inclusions, IPython will stop if it reaches 15 recursive inclusions.
3067 3090 \layout List
3068 3091 \labelwidthstring 00.00.0000
3069 3092
3070 3093
3071 3094 \family typewriter
3072 3095 \series bold
3073 3096 -prompt_in1|pi1\SpecialChar ~
3074 3097 <string>:
3075 3098 \family default
3076 3099 \series default
3077 3100 Specify the string used for input prompts.
3078 3101 Note that if you are using numbered prompts, the number is represented
3079 3102 with a '
3080 3103 \backslash
3081 3104 #' in the string.
3082 3105 Don't forget to quote strings with spaces embedded in them.
3083 3106 Default: '
3084 3107 \family typewriter
3085 3108 In\SpecialChar ~
3086 3109 [
3087 3110 \backslash
3088 3111 #]:
3089 3112 \family default
3090 3113 '.
3091 3114 Sec.\SpecialChar ~
3092 3115
3093 3116 \begin_inset LatexCommand \ref{sec:prompts}
3094 3117
3095 3118 \end_inset
3096 3119
3097 3120 discusses in detail all the available escapes to customize your prompts.
3098 3121 \layout List
3099 3122 \labelwidthstring 00.00.0000
3100 3123
3101 3124
3102 3125 \family typewriter
3103 3126 \series bold
3104 3127 -prompt_in2|pi2\SpecialChar ~
3105 3128 <string>:
3106 3129 \family default
3107 3130 \series default
3108 3131 Similar to the previous option, but used for the continuation prompts.
3109 3132 The special sequence '
3110 3133 \family typewriter
3111 3134
3112 3135 \backslash
3113 3136 D
3114 3137 \family default
3115 3138 ' is similar to '
3116 3139 \family typewriter
3117 3140
3118 3141 \backslash
3119 3142 #
3120 3143 \family default
3121 3144 ', but with all digits replaced dots (so you can have your continuation
3122 3145 prompt aligned with your input prompt).
3123 3146 Default: '
3124 3147 \family typewriter
3125 3148 \SpecialChar ~
3126 3149 \SpecialChar ~
3127 3150 \SpecialChar ~
3128 3151 .
3129 3152 \backslash
3130 3153 D.:
3131 3154 \family default
3132 3155 ' (note three spaces at the start for alignment with '
3133 3156 \family typewriter
3134 3157 In\SpecialChar ~
3135 3158 [
3136 3159 \backslash
3137 3160 #]
3138 3161 \family default
3139 3162 ').
3140 3163 \layout List
3141 3164 \labelwidthstring 00.00.0000
3142 3165
3143 3166
3144 3167 \family typewriter
3145 3168 \series bold
3146 3169 -prompt_out|po\SpecialChar ~
3147 3170 <string>:
3148 3171 \family default
3149 3172 \series default
3150 3173 String used for output prompts, also uses numbers like
3151 3174 \family typewriter
3152 3175 prompt_in1
3153 3176 \family default
3154 3177 .
3155 3178 Default: '
3156 3179 \family typewriter
3157 3180 Out[
3158 3181 \backslash
3159 3182 #]:
3160 3183 \family default
3161 3184 '
3162 3185 \layout List
3163 3186 \labelwidthstring 00.00.0000
3164 3187
3165 3188
3166 3189 \family typewriter
3167 3190 \series bold
3168 3191 -quick
3169 3192 \family default
3170 3193 \series default
3171 3194 : start in bare bones mode (no config file loaded).
3172 3195 \layout List
3173 3196 \labelwidthstring 00.00.0000
3174 3197
3175 3198
3176 3199 \family typewriter
3177 3200 \series bold
3178 3201 -rcfile\SpecialChar ~
3179 3202 <name>
3180 3203 \series default
3181 3204 :
3182 3205 \family default
3183 3206 name of your IPython resource configuration file.
3184 3207 Normally IPython loads ipythonrc (from current directory) or
3185 3208 \family typewriter
3186 3209 IPYTHONDIR/ipythonrc
3187 3210 \family default
3188 3211 .
3189 3212 \layout List
3190 3213 \labelwidthstring 00.00.0000
3191 3214
3192 3215 \SpecialChar ~
3193 3216 If the loading of your config file fails, IPython starts with a bare bones
3194 3217 configuration (no modules loaded at all).
3195 3218 \layout List
3196 3219 \labelwidthstring 00.00.0000
3197 3220
3198 3221
3199 3222 \family typewriter
3200 3223 \series bold
3201 3224 -no|readline
3202 3225 \family default
3203 3226 \series default
3204 3227 : use the readline library, which is needed to support name completion and
3205 3228 command history, among other things.
3206 3229 It is enabled by default, but may cause problems for users of X/Emacs in
3207 3230 Python comint or shell buffers.
3208 3231 \layout List
3209 3232 \labelwidthstring 00.00.0000
3210 3233
3211 3234 \SpecialChar ~
3212 3235 Note that X/Emacs 'eterm' buffers (opened with
3213 3236 \family typewriter
3214 3237 M-x\SpecialChar ~
3215 3238 term
3216 3239 \family default
3217 3240 ) support IPython's readline and syntax coloring fine, only 'emacs' (
3218 3241 \family typewriter
3219 3242 M-x\SpecialChar ~
3220 3243 shell
3221 3244 \family default
3222 3245 and
3223 3246 \family typewriter
3224 3247 C-c\SpecialChar ~
3225 3248 !
3226 3249 \family default
3227 3250 ) buffers do not.
3228 3251 \layout List
3229 3252 \labelwidthstring 00.00.0000
3230 3253
3231 3254
3232 3255 \family typewriter
3233 3256 \series bold
3234 3257 -screen_length|sl\SpecialChar ~
3235 3258 <n>
3236 3259 \series default
3237 3260 :
3238 3261 \family default
3239 3262 number of lines of your screen.
3240 3263 This is used to control printing of very long strings.
3241 3264 Strings longer than this number of lines will be sent through a pager instead
3242 3265 of directly printed.
3243 3266 \layout List
3244 3267 \labelwidthstring 00.00.0000
3245 3268
3246 3269 \SpecialChar ~
3247 3270 The default value for this is 0, which means IPython will auto-detect your
3248 3271 screen size every time it needs to print certain potentially long strings
3249 3272 (this doesn't change the behavior of the 'print' keyword, it's only triggered
3250 3273 internally).
3251 3274 If for some reason this isn't working well (it needs curses support), specify
3252 3275 it yourself.
3253 3276 Otherwise don't change the default.
3254 3277 \layout List
3255 3278 \labelwidthstring 00.00.0000
3256 3279
3257 3280
3258 3281 \family typewriter
3259 3282 \series bold
3260 3283 -separate_in|si\SpecialChar ~
3261 3284 <string>
3262 3285 \series default
3263 3286 :
3264 3287 \family default
3265 3288 separator before input prompts.
3266 3289 Default: '
3267 3290 \family typewriter
3268 3291
3269 3292 \backslash
3270 3293 n
3271 3294 \family default
3272 3295 '
3273 3296 \layout List
3274 3297 \labelwidthstring 00.00.0000
3275 3298
3276 3299
3277 3300 \family typewriter
3278 3301 \series bold
3279 3302 -separate_out|so\SpecialChar ~
3280 3303 <string>
3281 3304 \family default
3282 3305 \series default
3283 3306 : separator before output prompts.
3284 3307 Default: nothing.
3285 3308 \layout List
3286 3309 \labelwidthstring 00.00.0000
3287 3310
3288 3311
3289 3312 \family typewriter
3290 3313 \series bold
3291 3314 -separate_out2|so2\SpecialChar ~
3292 3315 <string>
3293 3316 \series default
3294 3317 :
3295 3318 \family default
3296 3319 separator after output prompts.
3297 3320 Default: nothing.
3298 3321 \layout List
3299 3322 \labelwidthstring 00.00.0000
3300 3323
3301 3324 \SpecialChar ~
3302 3325 For these three options, use the value 0 to specify no separator.
3303 3326 \layout List
3304 3327 \labelwidthstring 00.00.0000
3305 3328
3306 3329
3307 3330 \family typewriter
3308 3331 \series bold
3309 3332 -nosep
3310 3333 \series default
3311 3334 :
3312 3335 \family default
3313 3336 shorthand for
3314 3337 \family typewriter
3315 3338 '-SeparateIn 0 -SeparateOut 0 -SeparateOut2 0'
3316 3339 \family default
3317 3340 .
3318 3341 Simply removes all input/output separators.
3319 3342 \layout List
3320 3343 \labelwidthstring 00.00.0000
3321 3344
3322 3345
3323 3346 \family typewriter
3324 3347 \series bold
3325 3348 -upgrade
3326 3349 \family default
3327 3350 \series default
3328 3351 : allows you to upgrade your
3329 3352 \family typewriter
3330 3353 IPYTHONDIR
3331 3354 \family default
3332 3355 configuration when you install a new version of IPython.
3333 3356 Since new versions may include new command line options or example files,
3334 3357 this copies updated ipythonrc-type files.
3335 3358 However, it backs up (with a
3336 3359 \family typewriter
3337 3360 .old
3338 3361 \family default
3339 3362 extension) all files which it overwrites so that you can merge back any
3340 3363 customizations you might have in your personal files.
3341 3364 \layout List
3342 3365 \labelwidthstring 00.00.0000
3343 3366
3344 3367
3345 3368 \family typewriter
3346 3369 \series bold
3347 3370 -Version
3348 3371 \series default
3349 3372 :
3350 3373 \family default
3351 3374 print version information and exit.
3352 3375 \layout List
3353 3376 \labelwidthstring 00.00.0000
3354 3377
3355 3378
3356 3379 \family typewriter
3357 3380 \series bold
3358 3381 -xmode <modename>
3359 3382 \series default
3360 3383 :
3361 3384 \family default
3362 3385 Mode for exception reporting.
3363 3386 \layout List
3364 3387 \labelwidthstring 00.00.0000
3365 3388
3366 3389 \SpecialChar ~
3367 3390 Valid modes: Plain, Context and Verbose.
3368 3391 \layout List
3369 3392 \labelwidthstring 00.00.0000
3370 3393
3371 3394 \SpecialChar ~
3372 3395 Plain: similar to python's normal traceback printing.
3373 3396 \layout List
3374 3397 \labelwidthstring 00.00.0000
3375 3398
3376 3399 \SpecialChar ~
3377 3400 Context: prints 5 lines of context source code around each line in the
3378 3401 traceback.
3379 3402 \layout List
3380 3403 \labelwidthstring 00.00.0000
3381 3404
3382 3405 \SpecialChar ~
3383 3406 Verbose: similar to Context, but additionally prints the variables currently
3384 3407 visible where the exception happened (shortening their strings if too long).
3385 3408 This can potentially be very slow, if you happen to have a huge data structure
3386 3409 whose string representation is complex to compute.
3387 3410 Your computer may appear to freeze for a while with cpu usage at 100%.
3388 3411 If this occurs, you can cancel the traceback with Ctrl-C (maybe hitting
3389 3412 it more than once).
3390 3413 \layout Section
3391 3414
3392 3415 Interactive use
3393 3416 \layout Standard
3394 3417
3395 3418
3396 3419 \series bold
3397 3420 Warning
3398 3421 \series default
3399 3422 : IPython relies on the existence of a global variable called
3400 3423 \family typewriter
3401 3424 __IP
3402 3425 \family default
3403 3426 which controls the shell itself.
3404 3427 If you redefine
3405 3428 \family typewriter
3406 3429 __IP
3407 3430 \family default
3408 3431 to anything, bizarre behavior will quickly occur.
3409 3432 \layout Standard
3410 3433
3411 3434 Other than the above warning, IPython is meant to work as a drop-in replacement
3412 3435 for the standard interactive interpreter.
3413 3436 As such, any code which is valid python should execute normally under IPython
3414 3437 (cases where this is not true should be reported as bugs).
3415 3438 It does, however, offer many features which are not available at a standard
3416 3439 python prompt.
3417 3440 What follows is a list of these.
3418 3441 \layout Subsection
3419 3442
3420 3443 Caution for Windows users
3421 3444 \layout Standard
3422 3445
3423 3446 Windows, unfortunately, uses the `
3424 3447 \family typewriter
3425 3448
3426 3449 \backslash
3427 3450
3428 3451 \family default
3429 3452 ' character as a path separator.
3430 3453 This is a terrible choice, because `
3431 3454 \family typewriter
3432 3455
3433 3456 \backslash
3434 3457
3435 3458 \family default
3436 3459 ' also represents the escape character in most modern programming languages,
3437 3460 including Python.
3438 3461 For this reason, issuing many of the commands discussed below (especially
3439 3462 magics which affect the filesystem) with `
3440 3463 \family typewriter
3441 3464
3442 3465 \backslash
3443 3466
3444 3467 \family default
3445 3468 ' in them will cause strange errors.
3446 3469 \layout Standard
3447 3470
3448 3471 A partial solution is to use instead the `
3449 3472 \family typewriter
3450 3473 /
3451 3474 \family default
3452 3475 ' character as a path separator, which Windows recognizes in
3453 3476 \emph on
3454 3477 most
3455 3478 \emph default
3456 3479 situations.
3457 3480 However, in Windows commands `
3458 3481 \family typewriter
3459 3482 /
3460 3483 \family default
3461 3484 ' flags options, so you can not use it for the root directory.
3462 3485 This means that paths beginning at the root must be typed in a contrived
3463 3486 manner like:
3464 3487 \newline
3465 3488
3466 3489 \family typewriter
3467 3490 %copy
3468 3491 \backslash
3469 3492 opt/foo/bar.txt
3470 3493 \backslash
3471 3494 tmp
3472 3495 \layout Standard
3473 3496
3474 3497 There is no sensible thing IPython can do to truly work around this flaw
3475 3498 in Windows
3476 3499 \begin_inset Foot
3477 3500 collapsed true
3478 3501
3479 3502 \layout Standard
3480 3503
3481 3504 If anyone comes up with a
3482 3505 \emph on
3483 3506 clean
3484 3507 \emph default
3485 3508 solution which works consistently and does not negatively impact other
3486 3509 platforms at all, I'll gladly accept a patch.
3487 3510 \end_inset
3488 3511
3489 3512 .
3490 3513 \layout Subsection
3491 3514
3492 3515
3493 3516 \begin_inset LatexCommand \label{sec:magic}
3494 3517
3495 3518 \end_inset
3496 3519
3497 3520 Magic command system
3498 3521 \layout Standard
3499 3522
3500 3523 IPython will treat any line whose first character is a
3501 3524 \family typewriter
3502 3525 %
3503 3526 \family default
3504 3527 as a special call to a 'magic' function.
3505 3528 These allow you to control the behavior of IPython itself, plus a lot of
3506 3529 system-type features.
3507 3530 They are all prefixed with a
3508 3531 \family typewriter
3509 3532 %
3510 3533 \family default
3511 3534 character, but parameters are given without parentheses or quotes.
3512 3535 \layout Standard
3513 3536
3514 3537 Example: typing
3515 3538 \family typewriter
3516 3539 '%cd mydir'
3517 3540 \family default
3518 3541 (without the quotes) changes you working directory to
3519 3542 \family typewriter
3520 3543 'mydir'
3521 3544 \family default
3522 3545 , if it exists.
3523 3546 \layout Standard
3524 3547
3525 3548 If you have 'automagic' enabled (in your
3526 3549 \family typewriter
3527 3550 ipythonrc
3528 3551 \family default
3529 3552 file, via the command line option
3530 3553 \family typewriter
3531 3554 -automagic
3532 3555 \family default
3533 3556 or with the
3534 3557 \family typewriter
3535 3558 %automagic
3536 3559 \family default
3537 3560 function), you don't need to type in the
3538 3561 \family typewriter
3539 3562 %
3540 3563 \family default
3541 3564 explicitly.
3542 3565 IPython will scan its internal list of magic functions and call one if
3543 3566 it exists.
3544 3567 With automagic on you can then just type '
3545 3568 \family typewriter
3546 3569 cd mydir
3547 3570 \family default
3548 3571 ' to go to directory '
3549 3572 \family typewriter
3550 3573 mydir
3551 3574 \family default
3552 3575 '.
3553 3576 The automagic system has the lowest possible precedence in name searches,
3554 3577 so defining an identifier with the same name as an existing magic function
3555 3578 will shadow it for automagic use.
3556 3579 You can still access the shadowed magic function by explicitly using the
3557 3580
3558 3581 \family typewriter
3559 3582 %
3560 3583 \family default
3561 3584 character at the beginning of the line.
3562 3585 \layout Standard
3563 3586
3564 3587 An example (with automagic on) should clarify all this:
3565 3588 \layout LyX-Code
3566 3589
3567 3590 In [1]: cd ipython # %cd is called by automagic
3568 3591 \layout LyX-Code
3569 3592
3570 3593 /home/fperez/ipython
3571 3594 \layout LyX-Code
3572 3595
3573 3596 In [2]: cd=1 # now cd is just a variable
3574 3597 \layout LyX-Code
3575 3598
3576 3599 In [3]: cd ..
3577 3600 # and doesn't work as a function anymore
3578 3601 \layout LyX-Code
3579 3602
3580 3603 ------------------------------------------------------------
3581 3604 \layout LyX-Code
3582 3605
3583 3606 File "<console>", line 1
3584 3607 \layout LyX-Code
3585 3608
3586 3609 cd ..
3587 3610 \layout LyX-Code
3588 3611
3589 3612 ^
3590 3613 \layout LyX-Code
3591 3614
3592 3615 SyntaxError: invalid syntax
3593 3616 \layout LyX-Code
3594 3617
3595 3618 \layout LyX-Code
3596 3619
3597 3620 In [4]: %cd ..
3598 3621 # but %cd always works
3599 3622 \layout LyX-Code
3600 3623
3601 3624 /home/fperez
3602 3625 \layout LyX-Code
3603 3626
3604 3627 In [5]: del cd # if you remove the cd variable
3605 3628 \layout LyX-Code
3606 3629
3607 3630 In [6]: cd ipython # automagic can work again
3608 3631 \layout LyX-Code
3609 3632
3610 3633 /home/fperez/ipython
3611 3634 \layout Standard
3612 3635
3613 3636 You can define your own magic functions to extend the system.
3614 3637 The following is a snippet of code which shows how to do it.
3615 3638 It is provided as file
3616 3639 \family typewriter
3617 3640 example-magic.py
3618 3641 \family default
3619 3642 in the examples directory:
3620 3643 \layout Standard
3621 3644
3622 3645
3623 3646 \begin_inset ERT
3624 3647 status Open
3625 3648
3626 3649 \layout Standard
3627 3650
3628 3651 \backslash
3629 lstinputlisting{examples/example-magic.py}
3652 codelist{examples/example-magic.py}
3630 3653 \end_inset
3631 3654
3632 3655
3633 3656 \layout Standard
3634 3657
3635 3658 You can also define your own aliased names for magic functions.
3636 3659 In your
3637 3660 \family typewriter
3638 3661 ipythonrc
3639 3662 \family default
3640 3663 file, placing a line like:
3641 3664 \layout Standard
3642 3665
3643 3666
3644 3667 \family typewriter
3645 3668 execute __IP.magic_cl = __IP.magic_clear
3646 3669 \layout Standard
3647 3670
3648 3671 will define
3649 3672 \family typewriter
3650 3673 %cl
3651 3674 \family default
3652 3675 as a new name for
3653 3676 \family typewriter
3654 3677 %clear
3655 3678 \family default
3656 3679 .
3657 3680 \layout Standard
3658 3681
3659 3682 Type
3660 3683 \family typewriter
3661 3684 %magic
3662 3685 \family default
3663 3686 for more information, including a list of all available magic functions
3664 3687 at any time and their docstrings.
3665 3688 You can also type
3666 3689 \family typewriter
3667 3690 %magic_function_name?
3668 3691 \family default
3669 3692 (see sec.
3670 3693
3671 3694 \begin_inset LatexCommand \ref{sec:dyn-object-info}
3672 3695
3673 3696 \end_inset
3674 3697
3675 3698 for information on the
3676 3699 \family typewriter
3677 3700 '?'
3678 3701 \family default
3679 3702 system) to get information about any particular magic function you are
3680 3703 interested in.
3681 3704 \layout Subsubsection
3682 3705
3683 3706 Magic commands
3684 3707 \layout Standard
3685 3708
3686 3709 The rest of this section is automatically generated for each release from
3687 3710 the docstrings in the IPython code.
3688 3711 Therefore the formatting is somewhat minimal, but this method has the advantage
3689 3712 of having information always in sync with the code.
3690 3713 \layout Standard
3691 3714
3692 3715 A list of all the magic commands available in IPython's
3693 3716 \emph on
3694 3717 default
3695 3718 \emph default
3696 3719 installation follows.
3697 3720 This is similar to what you'll see by simply typing
3698 3721 \family typewriter
3699 3722 %magic
3700 3723 \family default
3701 3724 at the prompt, but that will also give you information about magic commands
3702 3725 you may have added as part of your personal customizations.
3703 3726 \layout Standard
3704 3727
3705 3728
3706 3729 \begin_inset Include \input{magic.tex}
3707 3730 preview false
3708 3731
3709 3732 \end_inset
3710 3733
3711 3734
3712 3735 \layout Subsection
3713 3736
3714 3737 Access to the standard Python help
3715 3738 \layout Standard
3716 3739
3717 3740 As of Python 2.1, a help system is available with access to object docstrings
3718 3741 and the Python manuals.
3719 3742 Simply type
3720 3743 \family typewriter
3721 3744 'help'
3722 3745 \family default
3723 3746 (no quotes) to access it.
3724 3747 You can also type
3725 3748 \family typewriter
3726 3749 help(object)
3727 3750 \family default
3728 3751 to obtain information about a given object, and
3729 3752 \family typewriter
3730 3753 help('keyword')
3731 3754 \family default
3732 3755 for information on a keyword.
3733 3756 As noted in sec.
3734 3757
3735 3758 \begin_inset LatexCommand \ref{sec:help-access}
3736 3759
3737 3760 \end_inset
3738 3761
3739 3762 , you need to properly configure your environment variable
3740 3763 \family typewriter
3741 3764 PYTHONDOCS
3742 3765 \family default
3743 3766 for this feature to work correctly.
3744 3767 \layout Subsection
3745 3768
3746 3769
3747 3770 \begin_inset LatexCommand \label{sec:dyn-object-info}
3748 3771
3749 3772 \end_inset
3750 3773
3751 3774 Dynamic object information
3752 3775 \layout Standard
3753 3776
3754 3777 Typing
3755 3778 \family typewriter
3756 3779 ?word
3757 3780 \family default
3758 3781 or
3759 3782 \family typewriter
3760 3783 word?
3761 3784 \family default
3762 3785 prints detailed information about an object.
3763 3786 If certain strings in the object are too long (docstrings, code, etc.) they
3764 3787 get snipped in the center for brevity.
3765 3788 This system gives access variable types and values, full source code for
3766 3789 any object (if available), function prototypes and other useful information.
3767 3790 \layout Standard
3768 3791
3769 3792 Typing
3770 3793 \family typewriter
3771 3794 ??word
3772 3795 \family default
3773 3796 or
3774 3797 \family typewriter
3775 3798 word??
3776 3799 \family default
3777 3800 gives access to the full information without snipping long strings.
3778 3801 Long strings are sent to the screen through the
3779 3802 \family typewriter
3780 3803 less
3781 3804 \family default
3782 3805 pager if longer than the screen and printed otherwise.
3783 3806 On systems lacking the
3784 3807 \family typewriter
3785 3808 less
3786 3809 \family default
3787 3810 command, IPython uses a very basic internal pager.
3788 3811 \layout Standard
3789 3812
3790 3813 The following magic functions are particularly useful for gathering information
3791 3814 about your working environment.
3792 3815 You can get more details by typing
3793 3816 \family typewriter
3794 3817 %magic
3795 3818 \family default
3796 3819 or querying them individually (use
3797 3820 \family typewriter
3798 3821 %function_name?
3799 3822 \family default
3800 3823 with or without the
3801 3824 \family typewriter
3802 3825 %
3803 3826 \family default
3804 3827 ), this is just a summary:
3805 3828 \layout List
3806 3829 \labelwidthstring 00.00.0000
3807 3830
3808 3831
3809 3832 \family typewriter
3810 3833 \series bold
3811 3834 %pdoc\SpecialChar ~
3812 3835 <object>
3813 3836 \family default
3814 3837 \series default
3815 3838 : Print (or run through a pager if too long) the docstring for an object.
3816 3839 If the given object is a class, it will print both the class and the constructo
3817 3840 r docstrings.
3818 3841 \layout List
3819 3842 \labelwidthstring 00.00.0000
3820 3843
3821 3844
3822 3845 \family typewriter
3823 3846 \series bold
3824 3847 %pdef\SpecialChar ~
3825 3848 <object>
3826 3849 \family default
3827 3850 \series default
3828 3851 : Print the definition header for any callable object.
3829 3852 If the object is a class, print the constructor information.
3830 3853 \layout List
3831 3854 \labelwidthstring 00.00.0000
3832 3855
3833 3856
3834 3857 \family typewriter
3835 3858 \series bold
3836 3859 %psource\SpecialChar ~
3837 3860 <object>
3838 3861 \family default
3839 3862 \series default
3840 3863 : Print (or run through a pager if too long) the source code for an object.
3841 3864 \layout List
3842 3865 \labelwidthstring 00.00.0000
3843 3866
3844 3867
3845 3868 \family typewriter
3846 3869 \series bold
3847 3870 %pfile\SpecialChar ~
3848 3871 <object>
3849 3872 \family default
3850 3873 \series default
3851 3874 : Show the entire source file where an object was defined via a pager, opening
3852 3875 it at the line where the object definition begins.
3853 3876 \layout List
3854 3877 \labelwidthstring 00.00.0000
3855 3878
3856 3879
3857 3880 \family typewriter
3858 3881 \series bold
3859 3882 %who/%whos
3860 3883 \family default
3861 3884 \series default
3862 3885 : These functions give information about identifiers you have defined interactiv
3863 3886 ely (not things you loaded or defined in your configuration files).
3864 3887
3865 3888 \family typewriter
3866 3889 %who
3867 3890 \family default
3868 3891 just prints a list of identifiers and
3869 3892 \family typewriter
3870 3893 %whos
3871 3894 \family default
3872 3895 prints a table with some basic details about each identifier.
3873 3896 \layout Standard
3874 3897
3875 3898 Note that the dynamic object information functions (
3876 3899 \family typewriter
3877 3900 ?/??, %pdoc, %pfile, %pdef, %psource
3878 3901 \family default
3879 3902 ) give you access to documentation even on things which are not really defined
3880 3903 as separate identifiers.
3881 3904 Try for example typing
3882 3905 \family typewriter
3883 3906 {}.get?
3884 3907 \family default
3885 3908 or after doing
3886 3909 \family typewriter
3887 3910 import os
3888 3911 \family default
3889 3912 , type
3890 3913 \family typewriter
3891 3914 os.path.abspath??
3892 3915 \family default
3893 3916 .
3894 3917 \layout Subsection
3895 3918
3896 3919
3897 3920 \begin_inset LatexCommand \label{sec:readline}
3898 3921
3899 3922 \end_inset
3900 3923
3901 3924 Readline-based features
3902 3925 \layout Standard
3903 3926
3904 3927 These features require the GNU readline library, so they won't work if your
3905 3928 Python installation lacks readline support.
3906 3929 We will first describe the default behavior IPython uses, and then how
3907 3930 to change it to suit your preferences.
3908 3931 \layout Subsubsection
3909 3932
3910 3933 Command line completion
3911 3934 \layout Standard
3912 3935
3913 3936 At any time, hitting TAB will complete any available python commands or
3914 3937 variable names, and show you a list of the possible completions if there's
3915 3938 no unambiguous one.
3916 3939 It will also complete filenames in the current directory if no python names
3917 3940 match what you've typed so far.
3918 3941 \layout Subsubsection
3919 3942
3920 3943 Search command history
3921 3944 \layout Standard
3922 3945
3923 3946 IPython provides two ways for searching through previous input and thus
3924 3947 reduce the need for repetitive typing:
3925 3948 \layout Enumerate
3926 3949
3927 3950 Start typing, and then use
3928 3951 \family typewriter
3929 3952 Ctrl-p
3930 3953 \family default
3931 3954 (previous,up) and
3932 3955 \family typewriter
3933 3956 Ctrl-n
3934 3957 \family default
3935 3958 (next,down) to search through only the history items that match what you've
3936 3959 typed so far.
3937 3960 If you use
3938 3961 \family typewriter
3939 3962 Ctrl-p/Ctrl-n
3940 3963 \family default
3941 3964 at a blank prompt, they just behave like normal arrow keys.
3942 3965 \layout Enumerate
3943 3966
3944 3967 Hit
3945 3968 \family typewriter
3946 3969 Ctrl-r
3947 3970 \family default
3948 3971 : opens a search prompt.
3949 3972 Begin typing and the system searches your history for lines that contain
3950 3973 what you've typed so far, completing as much as it can.
3951 3974 \layout Subsubsection
3952 3975
3953 3976 Persistent command history across sessions
3954 3977 \layout Standard
3955 3978
3956 3979 IPython will save your input history when it leaves and reload it next time
3957 3980 you restart it.
3958 3981 By default, the history file is named
3959 3982 \family typewriter
3960 3983 $IPYTHONDIR/history
3961 3984 \family default
3962 3985 , but if you've loaded a named profile, '
3963 3986 \family typewriter
3964 3987 -PROFILE_NAME
3965 3988 \family default
3966 3989 ' is appended to the name.
3967 3990 This allows you to keep separate histories related to various tasks: commands
3968 3991 related to numerical work will not be clobbered by a system shell history,
3969 3992 for example.
3970 3993 \layout Subsubsection
3971 3994
3972 3995 Autoindent
3973 3996 \layout Standard
3974 3997
3975 3998 IPython can recognize lines ending in ':' and indent the next line, while
3976 3999 also un-indenting automatically after 'raise' or 'return'.
3977 4000
3978 4001 \layout Standard
3979 4002
3980 4003 This feature uses the readline library, so it will honor your
3981 4004 \family typewriter
3982 4005 ~/.inputrc
3983 4006 \family default
3984 4007 configuration (or whatever file your
3985 4008 \family typewriter
3986 4009 INPUTRC
3987 4010 \family default
3988 4011 variable points to).
3989 4012 Adding the following lines to your
3990 4013 \family typewriter
3991 4014 .inputrc
3992 4015 \family default
3993 4016 file can make indenting/unindenting more convenient (
3994 4017 \family typewriter
3995 4018 M-i
3996 4019 \family default
3997 4020 indents,
3998 4021 \family typewriter
3999 4022 M-u
4000 4023 \family default
4001 4024 unindents):
4002 4025 \layout Standard
4003 4026
4004 4027
4005 4028 \family typewriter
4006 4029 $if Python
4007 4030 \newline
4008 4031 "
4009 4032 \backslash
4010 4033 M-i": "\SpecialChar ~
4011 4034 \SpecialChar ~
4012 4035 \SpecialChar ~
4013 4036 \SpecialChar ~
4014 4037 "
4015 4038 \newline
4016 4039 "
4017 4040 \backslash
4018 4041 M-u": "
4019 4042 \backslash
4020 4043 d
4021 4044 \backslash
4022 4045 d
4023 4046 \backslash
4024 4047 d
4025 4048 \backslash
4026 4049 d"
4027 4050 \newline
4028 4051 $endif
4029 4052 \layout Standard
4030 4053
4031 4054 Note that there are 4 spaces between the quote marks after
4032 4055 \family typewriter
4033 4056 "M-i"
4034 4057 \family default
4035 4058 above.
4036 4059 \layout Standard
4037 4060
4038 4061
4039 4062 \series bold
4040 4063 Warning:
4041 4064 \series default
4042 4065 this feature is ON by default, but it can cause problems with the pasting
4043 4066 of multi-line indented code (the pasted code gets re-indented on each line).
4044 4067 A magic function
4045 4068 \family typewriter
4046 4069 %autoindent
4047 4070 \family default
4048 4071 allows you to toggle it on/off at runtime.
4049 4072 You can also disable it permanently on in your
4050 4073 \family typewriter
4051 4074 ipythonrc
4052 4075 \family default
4053 4076 file (set
4054 4077 \family typewriter
4055 4078 autoindent 0
4056 4079 \family default
4057 4080 ).
4058 4081 \layout Subsubsection
4059 4082
4060 4083 Customizing readline behavior
4061 4084 \layout Standard
4062 4085
4063 4086 All these features are based on the GNU readline library, which has an extremely
4064 4087 customizable interface.
4065 4088 Normally, readline is configured via a file which defines the behavior
4066 4089 of the library; the details of the syntax for this can be found in the
4067 4090 readline documentation available with your system or on the Internet.
4068 4091 IPython doesn't read this file (if it exists) directly, but it does support
4069 4092 passing to readline valid options via a simple interface.
4070 4093 In brief, you can customize readline by setting the following options in
4071 4094 your
4072 4095 \family typewriter
4073 4096 ipythonrc
4074 4097 \family default
4075 4098 configuration file (note that these options can
4076 4099 \emph on
4077 4100 not
4078 4101 \emph default
4079 4102 be specified at the command line):
4080 4103 \layout List
4081 4104 \labelwidthstring 00.00.0000
4082 4105
4083 4106
4084 4107 \family typewriter
4085 4108 \series bold
4086 4109 readline_parse_and_bind:
4087 4110 \family default
4088 4111 \series default
4089 4112 this option can appear as many times as you want, each time defining a
4090 4113 string to be executed via a
4091 4114 \family typewriter
4092 4115 readline.parse_and_bind()
4093 4116 \family default
4094 4117 command.
4095 4118 The syntax for valid commands of this kind can be found by reading the
4096 4119 documentation for the GNU readline library, as these commands are of the
4097 4120 kind which readline accepts in its configuration file.
4098 4121 \layout List
4099 4122 \labelwidthstring 00.00.0000
4100 4123
4101 4124
4102 4125 \family typewriter
4103 4126 \series bold
4104 4127 readline_remove_delims:
4105 4128 \family default
4106 4129 \series default
4107 4130 a string of characters to be removed from the default word-delimiters list
4108 4131 used by readline, so that completions may be performed on strings which
4109 4132 contain them.
4110 4133 Do not change the default value unless you know what you're doing.
4111 4134 \layout List
4112 4135 \labelwidthstring 00.00.0000
4113 4136
4114 4137
4115 4138 \family typewriter
4116 4139 \series bold
4117 4140 readline_omit__names
4118 4141 \family default
4119 4142 \series default
4120 4143 : when tab-completion is enabled, hitting
4121 4144 \family typewriter
4122 4145 <tab>
4123 4146 \family default
4124 4147 after a '
4125 4148 \family typewriter
4126 4149 .
4127 4150 \family default
4128 4151 ' in a name will complete all attributes of an object, including all the
4129 4152 special methods whose names include double underscores (like
4130 4153 \family typewriter
4131 4154 __getitem__
4132 4155 \family default
4133 4156 or
4134 4157 \family typewriter
4135 4158 __class__
4136 4159 \family default
4137 4160 ).
4138 4161 If you'd rather not see these names by default, you can set this option
4139 4162 to 1.
4140 4163 Note that even when this option is set, you can still see those names by
4141 4164 explicitly typing a
4142 4165 \family typewriter
4143 4166 _
4144 4167 \family default
4145 4168 after the period and hitting
4146 4169 \family typewriter
4147 4170 <tab>
4148 4171 \family default
4149 4172 : '
4150 4173 \family typewriter
4151 4174 name._<tab>
4152 4175 \family default
4153 4176 ' will always complete attribute names starting with '
4154 4177 \family typewriter
4155 4178 _
4156 4179 \family default
4157 4180 '.
4158 4181 \layout List
4159 4182 \labelwidthstring 00.00.0000
4160 4183
4161 4184 \SpecialChar ~
4162 4185 This option is off by default so that new users see all attributes of any
4163 4186 objects they are dealing with.
4164 4187 \layout Standard
4165 4188
4166 4189 You will find the default values along with a corresponding detailed explanation
4167 4190 in your
4168 4191 \family typewriter
4169 4192 ipythonrc
4170 4193 \family default
4171 4194 file.
4172 4195 \layout Subsection
4173 4196
4174 4197 Session logging and restoring
4175 4198 \layout Standard
4176 4199
4177 4200 You can log all input from a session either by starting IPython with the
4178 4201 command line switches
4179 4202 \family typewriter
4180 4203 -log
4181 4204 \family default
4182 4205 or
4183 4206 \family typewriter
4184 4207 -logfile
4185 4208 \family default
4186 4209 (see sec.
4187 4210
4188 4211 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
4189 4212
4190 4213 \end_inset
4191 4214
4192 4215 )or by activating the logging at any moment with the magic function
4193 4216 \family typewriter
4194 4217 %logstart
4195 4218 \family default
4196 4219 .
4197 4220
4198 4221 \layout Standard
4199 4222
4200 4223 Log files can later be reloaded with the
4201 4224 \family typewriter
4202 4225 -logplay
4203 4226 \family default
4204 4227 option and IPython will attempt to 'replay' the log by executing all the
4205 4228 lines in it, thus restoring the state of a previous session.
4206 4229 This feature is not quite perfect, but can still be useful in many cases.
4207 4230 \layout Standard
4208 4231
4209 4232 The log files can also be used as a way to have a permanent record of any
4210 4233 code you wrote while experimenting.
4211 4234 Log files are regular text files which you can later open in your favorite
4212 4235 text editor to extract code or to 'clean them up' before using them to
4213 4236 replay a session.
4214 4237 \layout Standard
4215 4238
4216 4239 The
4217 4240 \family typewriter
4218 4241 %logstart
4219 4242 \family default
4220 4243 function for activating logging in mid-session is used as follows:
4221 4244 \layout Standard
4222 4245
4223 4246
4224 4247 \family typewriter
4225 4248 %logstart [log_name [log_mode]]
4226 4249 \layout Standard
4227 4250
4228 4251 If no name is given, it defaults to a file named
4229 4252 \family typewriter
4230 4253 'log'
4231 4254 \family default
4232 4255 in your IPYTHONDIR directory, in
4233 4256 \family typewriter
4234 4257 'rotate'
4235 4258 \family default
4236 4259 mode (see below).
4237 4260 \layout Standard
4238 4261
4239 4262 '
4240 4263 \family typewriter
4241 4264 %logstart name
4242 4265 \family default
4243 4266 ' saves to file
4244 4267 \family typewriter
4245 4268 'name'
4246 4269 \family default
4247 4270 in
4248 4271 \family typewriter
4249 4272 'backup'
4250 4273 \family default
4251 4274 mode.
4252 4275 It saves your history up to that point and then continues logging.
4253 4276 \layout Standard
4254 4277
4255 4278
4256 4279 \family typewriter
4257 4280 %logstart
4258 4281 \family default
4259 4282 takes a second optional parameter: logging mode.
4260 4283 This can be one of (note that the modes are given unquoted):
4261 4284 \layout List
4262 4285 \labelwidthstring 00.00.0000
4263 4286
4264 4287
4265 4288 \family typewriter
4266 4289 over
4267 4290 \family default
4268 4291 : overwrite existing
4269 4292 \family typewriter
4270 4293 log_name
4271 4294 \family default
4272 4295 .
4273 4296 \layout List
4274 4297 \labelwidthstring 00.00.0000
4275 4298
4276 4299
4277 4300 \family typewriter
4278 4301 backup
4279 4302 \family default
4280 4303 : rename (if exists) to
4281 4304 \family typewriter
4282 4305 log_name~
4283 4306 \family default
4284 4307 and start
4285 4308 \family typewriter
4286 4309 log_name
4287 4310 \family default
4288 4311 .
4289 4312 \layout List
4290 4313 \labelwidthstring 00.00.0000
4291 4314
4292 4315
4293 4316 \family typewriter
4294 4317 append
4295 4318 \family default
4296 4319 : well, that says it.
4297 4320 \layout List
4298 4321 \labelwidthstring 00.00.0000
4299 4322
4300 4323
4301 4324 \family typewriter
4302 4325 rotate
4303 4326 \family default
4304 4327 : create rotating logs
4305 4328 \family typewriter
4306 4329 log_name
4307 4330 \family default
4308 4331 .
4309 4332 \family typewriter
4310 4333 1~
4311 4334 \family default
4312 4335 ,
4313 4336 \family typewriter
4314 4337 log_name.2~
4315 4338 \family default
4316 4339 , etc.
4317 4340 \layout Standard
4318 4341
4319 4342 The
4320 4343 \family typewriter
4321 4344 %logoff
4322 4345 \family default
4323 4346 and
4324 4347 \family typewriter
4325 4348 %logon
4326 4349 \family default
4327 4350 functions allow you to temporarily stop and resume logging to a file which
4328 4351 had previously been started with
4329 4352 \family typewriter
4330 4353 %logstart
4331 4354 \family default
4332 4355 .
4333 4356 They will fail (with an explanation) if you try to use them before logging
4334 4357 has been started.
4335 4358 \layout Subsection
4336 4359
4337 4360
4338 4361 \begin_inset LatexCommand \label{sub:System-shell-access}
4339 4362
4340 4363 \end_inset
4341 4364
4342 4365 System shell access
4343 4366 \layout Standard
4344 4367
4345 4368 Any input line beginning with a
4346 4369 \family typewriter
4347 4370 !
4348 4371 \family default
4349 4372 character is passed verbatim (minus the
4350 4373 \family typewriter
4351 4374 !
4352 4375 \family default
4353 4376 , of course) to the underlying operating system.
4354 4377 For example, typing
4355 4378 \family typewriter
4356 4379 !ls
4357 4380 \family default
4358 4381 will run
4359 4382 \family typewriter
4360 4383 'ls'
4361 4384 \family default
4362 4385 in the current directory.
4363 4386 \layout Subsubsection
4364 4387
4365 4388 Manual capture of command output
4366 4389 \layout Standard
4367 4390
4368 4391 If the input line begins with
4369 4392 \emph on
4370 4393 two
4371 4394 \emph default
4372 4395 exclamation marks,
4373 4396 \family typewriter
4374 4397 !!
4375 4398 \family default
4376 4399 , the command is executed but its output is captured and returned as a python
4377 4400 list, split on newlines.
4378 4401 Any output sent by the subprocess to standard error is printed separately,
4379 4402 so that the resulting list only captures standard output.
4380 4403 The
4381 4404 \family typewriter
4382 4405 !!
4383 4406 \family default
4384 4407 syntax is a shorthand for the
4385 4408 \family typewriter
4386 4409 %sx
4387 4410 \family default
4388 4411 magic command.
4389 4412 \layout Standard
4390 4413
4391 4414 Finally, the
4392 4415 \family typewriter
4393 4416 %sc
4394 4417 \family default
4395 4418 magic (short for `shell capture') is similar to
4396 4419 \family typewriter
4397 4420 %sx
4398 4421 \family default
4399 4422 , but allowing more fine-grained control of the capture details, and storing
4400 4423 the result directly into a named variable.
4401 4424 \layout Standard
4402 4425
4403 4426 See Sec.\SpecialChar ~
4404 4427
4405 4428 \begin_inset LatexCommand \ref{sec:magic}
4406 4429
4407 4430 \end_inset
4408 4431
4409 4432 for details on the magics
4410 4433 \family typewriter
4411 4434 %sc
4412 4435 \family default
4413 4436 and
4414 4437 \family typewriter
4415 4438 %sx
4416 4439 \family default
4417 4440 , or use IPython's own help (
4418 4441 \family typewriter
4419 4442 sc?
4420 4443 \family default
4421 4444 and
4422 4445 \family typewriter
4423 4446 sx?
4424 4447 \family default
4425 4448 ) for further details.
4426 4449 \layout Standard
4427 4450
4428 4451 IPython also allows you to expand the value of python variables when making
4429 4452 system calls.
4430 4453 Any python variable or expression which you prepend with
4431 4454 \family typewriter
4432 4455 $
4433 4456 \family default
4434 4457 will get expanded before the system call is made.
4435 4458
4436 4459 \layout Standard
4437 4460
4438 4461
4439 4462 \family typewriter
4440 4463 In [1]: pyvar='Hello world'
4441 4464 \newline
4442 4465 In [2]: !echo "A python variable: $pyvar"
4443 4466 \newline
4444 4467 A python variable: Hello world
4445 4468 \layout Standard
4446 4469
4447 4470 If you want the shell to actually see a literal
4448 4471 \family typewriter
4449 4472 $
4450 4473 \family default
4451 4474 , you need to type it twice:
4452 4475 \layout Standard
4453 4476
4454 4477
4455 4478 \family typewriter
4456 4479 In [3]: !echo "A system variable: $$HOME"
4457 4480 \newline
4458 4481 A system variable: /home/fperez
4459 4482 \layout Standard
4460 4483
4461 4484 You can pass arbitrary expressions, though you'll need to delimit them with
4462 4485
4463 4486 \family typewriter
4464 4487 {}
4465 4488 \family default
4466 4489 if there is ambiguity as to the extent of the expression:
4467 4490 \layout Standard
4468 4491
4469 4492
4470 4493 \family typewriter
4471 4494 In [5]: x=10
4472 4495 \newline
4473 4496 In [6]: y=20
4474 4497 \newline
4475 4498 In [13]: !echo $x+y
4476 4499 \newline
4477 4500 10+y
4478 4501 \newline
4479 4502 In [7]: !echo ${x+y}
4480 4503 \newline
4481 4504 30
4482 4505 \layout Standard
4483 4506
4484 4507 Even object attributes can be expanded:
4485 4508 \layout Standard
4486 4509
4487 4510
4488 4511 \family typewriter
4489 4512 In [12]: !echo $sys.argv
4490 4513 \newline
4491 4514 [/home/fperez/usr/bin/ipython]
4492 4515 \layout Subsection
4493 4516
4494 4517 System command aliases
4495 4518 \layout Standard
4496 4519
4497 4520 The
4498 4521 \family typewriter
4499 4522 %alias
4500 4523 \family default
4501 4524 magic function and the
4502 4525 \family typewriter
4503 4526 alias
4504 4527 \family default
4505 4528 option in the
4506 4529 \family typewriter
4507 4530 ipythonrc
4508 4531 \family default
4509 4532 configuration file allow you to define magic functions which are in fact
4510 4533 system shell commands.
4511 4534 These aliases can have parameters.
4512 4535
4513 4536 \layout Standard
4514 4537
4515 4538 '
4516 4539 \family typewriter
4517 4540 %alias alias_name cmd
4518 4541 \family default
4519 4542 ' defines '
4520 4543 \family typewriter
4521 4544 alias_name
4522 4545 \family default
4523 4546 ' as an alias for '
4524 4547 \family typewriter
4525 4548 cmd
4526 4549 \family default
4527 4550 '
4528 4551 \layout Standard
4529 4552
4530 4553 Then, typing '
4531 4554 \family typewriter
4532 4555 %alias_name params
4533 4556 \family default
4534 4557 ' will execute the system command '
4535 4558 \family typewriter
4536 4559 cmd params
4537 4560 \family default
4538 4561 ' (from your underlying operating system).
4539 4562
4540 4563 \layout Standard
4541 4564
4542 4565 You can also define aliases with parameters using
4543 4566 \family typewriter
4544 4567 %s
4545 4568 \family default
4546 4569 specifiers (one per parameter).
4547 4570 The following example defines the
4548 4571 \family typewriter
4549 4572 %parts
4550 4573 \family default
4551 4574 function as an alias to the command '
4552 4575 \family typewriter
4553 4576 echo first %s second %s
4554 4577 \family default
4555 4578 ' where each
4556 4579 \family typewriter
4557 4580 %s
4558 4581 \family default
4559 4582 will be replaced by a positional parameter to the call to
4560 4583 \family typewriter
4561 4584 %parts:
4562 4585 \layout Standard
4563 4586
4564 4587
4565 4588 \family typewriter
4566 4589 In [1]: alias parts echo first %s second %s
4567 4590 \newline
4568 4591 In [2]: %parts A B
4569 4592 \newline
4570 4593 first A second B
4571 4594 \newline
4572 4595 In [3]: %parts A
4573 4596 \newline
4574 4597 Incorrect number of arguments: 2 expected.
4575 4598
4576 4599 \newline
4577 4600 parts is an alias to: 'echo first %s second %s'
4578 4601 \layout Standard
4579 4602
4580 4603 If called with no parameters,
4581 4604 \family typewriter
4582 4605 %alias
4583 4606 \family default
4584 4607 prints the table of currently defined aliases.
4585 4608 \layout Standard
4586 4609
4587 4610 The
4588 4611 \family typewriter
4589 4612 %rehash/rehashx
4590 4613 \family default
4591 4614 magics allow you to load your entire
4592 4615 \family typewriter
4593 4616 $PATH
4594 4617 \family default
4595 4618 as ipython aliases.
4596 4619 See their respective docstrings (or sec.\SpecialChar ~
4597 4620
4598 4621 \begin_inset LatexCommand \ref{sec:magic}
4599 4622
4600 4623 \end_inset
4601 4624
4602 4625 for further details).
4603 4626 \layout Subsection
4604 4627
4605 4628
4606 4629 \begin_inset LatexCommand \label{sec:dreload}
4607 4630
4608 4631 \end_inset
4609 4632
4610 4633 Recursive reload
4611 4634 \layout Standard
4612 4635
4613 4636 The
4614 4637 \family typewriter
4615 4638 %dreload
4616 4639 \family default
4617 4640 command does a recursive reload of a module: changes made to the module
4618 4641 since you imported will actually be available without having to exit.
4619 4642 \layout Subsection
4620 4643
4621 4644 Verbose and colored exception traceback printouts
4622 4645 \layout Standard
4623 4646
4624 4647 IPython provides the option to see very detailed exception tracebacks, which
4625 4648 can be especially useful when debugging large programs.
4626 4649 You can run any Python file with the
4627 4650 \family typewriter
4628 4651 %run
4629 4652 \family default
4630 4653 function to benefit from these detailed tracebacks.
4631 4654 Furthermore, both normal and verbose tracebacks can be colored (if your
4632 4655 terminal supports it) which makes them much easier to parse visually.
4633 4656 \layout Standard
4634 4657
4635 4658 See the magic
4636 4659 \family typewriter
4637 4660 xmode
4638 4661 \family default
4639 4662 and
4640 4663 \family typewriter
4641 4664 colors
4642 4665 \family default
4643 4666 functions for details (just type
4644 4667 \family typewriter
4645 4668 %magic
4646 4669 \family default
4647 4670 ).
4648 4671 \layout Standard
4649 4672
4650 4673 These features are basically a terminal version of Ka-Ping Yee's
4651 4674 \family typewriter
4652 4675 cgitb
4653 4676 \family default
4654 4677 module, now part of the standard Python library.
4655 4678 \layout Subsection
4656 4679
4657 4680
4658 4681 \begin_inset LatexCommand \label{sec:cache_input}
4659 4682
4660 4683 \end_inset
4661 4684
4662 4685 Input caching system
4663 4686 \layout Standard
4664 4687
4665 4688 IPython offers numbered prompts (In/Out) with input and output caching.
4666 4689 All input is saved and can be retrieved as variables (besides the usual
4667 4690 arrow key recall).
4668 4691 \layout Standard
4669 4692
4670 4693 The following GLOBAL variables always exist (so don't overwrite them!):
4671 4694
4672 4695 \family typewriter
4673 4696 _i
4674 4697 \family default
4675 4698 : stores previous input.
4676 4699
4677 4700 \family typewriter
4678 4701 _ii
4679 4702 \family default
4680 4703 : next previous.
4681 4704
4682 4705 \family typewriter
4683 4706 _iii
4684 4707 \family default
4685 4708 : next-next previous.
4686 4709
4687 4710 \family typewriter
4688 4711 _ih
4689 4712 \family default
4690 4713 : a list of all input
4691 4714 \family typewriter
4692 4715 _ih[n]
4693 4716 \family default
4694 4717 is the input from line
4695 4718 \family typewriter
4696 4719 n
4697 4720 \family default
4698 4721 and this list is aliased to the global variable
4699 4722 \family typewriter
4700 4723 In
4701 4724 \family default
4702 4725 .
4703 4726 If you overwrite
4704 4727 \family typewriter
4705 4728 In
4706 4729 \family default
4707 4730 with a variable of your own, you can remake the assignment to the internal
4708 4731 list with a simple
4709 4732 \family typewriter
4710 4733 'In=_ih'
4711 4734 \family default
4712 4735 .
4713 4736 \layout Standard
4714 4737
4715 4738 Additionally, global variables named
4716 4739 \family typewriter
4717 4740 _i<n>
4718 4741 \family default
4719 4742 are dynamically created (
4720 4743 \family typewriter
4721 4744 <n>
4722 4745 \family default
4723 4746 being the prompt counter), such that
4724 4747 \newline
4725 4748
4726 4749 \family typewriter
4727 4750 _i<n> == _ih[<n>] == In[<n>].
4728 4751 \layout Standard
4729 4752
4730 4753 For example, what you typed at prompt 14 is available as
4731 4754 \family typewriter
4732 4755 _i14,
4733 4756 \family default
4734 4757
4735 4758 \family typewriter
4736 4759 _ih[14]
4737 4760 \family default
4738 4761 and
4739 4762 \family typewriter
4740 4763 In[14]
4741 4764 \family default
4742 4765 .
4743 4766 \layout Standard
4744 4767
4745 4768 This allows you to easily cut and paste multi line interactive prompts by
4746 4769 printing them out: they print like a clean string, without prompt characters.
4747 4770 You can also manipulate them like regular variables (they are strings),
4748 4771 modify or exec them (typing
4749 4772 \family typewriter
4750 4773 'exec _i9'
4751 4774 \family default
4752 4775 will re-execute the contents of input prompt 9, '
4753 4776 \family typewriter
4754 4777 exec In[9:14]+In[18]
4755 4778 \family default
4756 4779 ' will re-execute lines 9 through 13 and line 18).
4757 4780 \layout Standard
4758 4781
4759 4782 You can also re-execute multiple lines of input easily by using the magic
4760 4783
4761 4784 \family typewriter
4762 4785 %macro
4763 4786 \family default
4764 4787 function (which automates the process and allows re-execution without having
4765 4788 to type '
4766 4789 \family typewriter
4767 4790 exec
4768 4791 \family default
4769 4792 ' every time).
4770 4793 The macro system also allows you to re-execute previous lines which include
4771 4794 magic function calls (which require special processing).
4772 4795 Type
4773 4796 \family typewriter
4774 4797 %macro?
4775 4798 \family default
4776 4799 or see sec.
4777 4800
4778 4801 \begin_inset LatexCommand \ref{sec:magic}
4779 4802
4780 4803 \end_inset
4781 4804
4782 4805 for more details on the macro system.
4783 4806 \layout Standard
4784 4807
4785 4808 A history function
4786 4809 \family typewriter
4787 4810 %hist
4788 4811 \family default
4789 4812 allows you to see any part of your input history by printing a range of
4790 4813 the
4791 4814 \family typewriter
4792 4815 _i
4793 4816 \family default
4794 4817 variables.
4795 4818 \layout Subsection
4796 4819
4797 4820
4798 4821 \begin_inset LatexCommand \label{sec:cache_output}
4799 4822
4800 4823 \end_inset
4801 4824
4802 4825 Output caching system
4803 4826 \layout Standard
4804 4827
4805 4828 For output that is returned from actions, a system similar to the input
4806 4829 cache exists but using
4807 4830 \family typewriter
4808 4831 _
4809 4832 \family default
4810 4833 instead of
4811 4834 \family typewriter
4812 4835 _i
4813 4836 \family default
4814 4837 .
4815 4838 Only actions that produce a result (NOT assignments, for example) are cached.
4816 4839 If you are familiar with Mathematica, IPython's
4817 4840 \family typewriter
4818 4841 _
4819 4842 \family default
4820 4843 variables behave exactly like Mathematica's
4821 4844 \family typewriter
4822 4845 %
4823 4846 \family default
4824 4847 variables.
4825 4848 \layout Standard
4826 4849
4827 4850 The following GLOBAL variables always exist (so don't overwrite them!):
4828 4851
4829 4852 \layout List
4830 4853 \labelwidthstring 00.00.0000
4831 4854
4832 4855
4833 4856 \family typewriter
4834 4857 \series bold
4835 4858 _
4836 4859 \family default
4837 4860 \series default
4838 4861 (a
4839 4862 \emph on
4840 4863 single
4841 4864 \emph default
4842 4865 underscore) : stores previous output, like Python's default interpreter.
4843 4866 \layout List
4844 4867 \labelwidthstring 00.00.0000
4845 4868
4846 4869
4847 4870 \family typewriter
4848 4871 \series bold
4849 4872 __
4850 4873 \family default
4851 4874 \series default
4852 4875 (two underscores): next previous.
4853 4876 \layout List
4854 4877 \labelwidthstring 00.00.0000
4855 4878
4856 4879
4857 4880 \family typewriter
4858 4881 \series bold
4859 4882 ___
4860 4883 \family default
4861 4884 \series default
4862 4885 (three underscores): next-next previous.
4863 4886 \layout Standard
4864 4887
4865 4888 Additionally, global variables named
4866 4889 \family typewriter
4867 4890 _<n>
4868 4891 \family default
4869 4892 are dynamically created (
4870 4893 \family typewriter
4871 4894 <n>
4872 4895 \family default
4873 4896 being the prompt counter), such that the result of output
4874 4897 \family typewriter
4875 4898 <n>
4876 4899 \family default
4877 4900 is always available as
4878 4901 \family typewriter
4879 4902 _<n>
4880 4903 \family default
4881 4904 (don't use the angle brackets, just the number, e.g.
4882 4905
4883 4906 \family typewriter
4884 4907 _21
4885 4908 \family default
4886 4909 ).
4887 4910 \layout Standard
4888 4911
4889 4912 These global variables are all stored in a global dictionary (not a list,
4890 4913 since it only has entries for lines which returned a result) available
4891 4914 under the names
4892 4915 \family typewriter
4893 4916 _oh
4894 4917 \family default
4895 4918 and
4896 4919 \family typewriter
4897 4920 Out
4898 4921 \family default
4899 4922 (similar to
4900 4923 \family typewriter
4901 4924 _ih
4902 4925 \family default
4903 4926 and
4904 4927 \family typewriter
4905 4928 In
4906 4929 \family default
4907 4930 ).
4908 4931 So the output from line 12 can be obtained as
4909 4932 \family typewriter
4910 4933 _12
4911 4934 \family default
4912 4935 ,
4913 4936 \family typewriter
4914 4937 Out[12]
4915 4938 \family default
4916 4939 or
4917 4940 \family typewriter
4918 4941 _oh[12]
4919 4942 \family default
4920 4943 .
4921 4944 If you accidentally overwrite the
4922 4945 \family typewriter
4923 4946 Out
4924 4947 \family default
4925 4948 variable you can recover it by typing
4926 4949 \family typewriter
4927 4950 'Out=_oh
4928 4951 \family default
4929 4952 ' at the prompt.
4930 4953 \layout Standard
4931 4954
4932 4955 This system obviously can potentially put heavy memory demands on your system,
4933 4956 since it prevents Python's garbage collector from removing any previously
4934 4957 computed results.
4935 4958 You can control how many results are kept in memory with the option (at
4936 4959 the command line or in your
4937 4960 \family typewriter
4938 4961 ipythonrc
4939 4962 \family default
4940 4963 file)
4941 4964 \family typewriter
4942 4965 cache_size
4943 4966 \family default
4944 4967 .
4945 4968 If you set it to 0, the whole system is completely disabled and the prompts
4946 4969 revert to the classic
4947 4970 \family typewriter
4948 4971 '>>>'
4949 4972 \family default
4950 4973 of normal Python.
4951 4974 \layout Subsection
4952 4975
4953 4976 Directory history
4954 4977 \layout Standard
4955 4978
4956 4979 Your history of visited directories is kept in the global list
4957 4980 \family typewriter
4958 4981 _dh
4959 4982 \family default
4960 4983 , and the magic
4961 4984 \family typewriter
4962 4985 %cd
4963 4986 \family default
4964 4987 command can be used to go to any entry in that list.
4965 4988 The
4966 4989 \family typewriter
4967 4990 %dhist
4968 4991 \family default
4969 4992 command allows you to view this history.
4970 4993 \layout Subsection
4971 4994
4972 4995 Automatic parentheses and quotes
4973 4996 \layout Standard
4974 4997
4975 4998 These features were adapted from Nathan Gray's LazyPython.
4976 4999 They are meant to allow less typing for common situations.
4977 5000 \layout Subsubsection
4978 5001
4979 5002 Automatic parentheses
4980 5003 \layout Standard
4981 5004
4982 5005 Callable objects (i.e.
4983 5006 functions, methods, etc) can be invoked like this (notice the commas between
4984 5007 the arguments):
4985 5008 \layout Standard
4986 5009
4987 5010
4988 5011 \family typewriter
4989 5012 >>> callable_ob arg1, arg2, arg3
4990 5013 \layout Standard
4991 5014
4992 5015 and the input will be translated to this:
4993 5016 \layout Standard
4994 5017
4995 5018
4996 5019 \family typewriter
4997 5020 --> callable_ob(arg1, arg2, arg3)
4998 5021 \layout Standard
4999 5022
5000 5023 You can force automatic parentheses by using '/' as the first character
5001 5024 of a line.
5002 5025 For example:
5003 5026 \layout Standard
5004 5027
5005 5028
5006 5029 \family typewriter
5007 5030 >>> /globals # becomes 'globals()'
5008 5031 \layout Standard
5009 5032
5010 5033 Note that the '/' MUST be the first character on the line! This won't work:
5011 5034
5012 5035 \layout Standard
5013 5036
5014 5037
5015 5038 \family typewriter
5016 5039 >>> print /globals # syntax error
5017 5040 \layout Standard
5018 5041
5019 5042 In most cases the automatic algorithm should work, so you should rarely
5020 5043 need to explicitly invoke /.
5021 5044 One notable exception is if you are trying to call a function with a list
5022 5045 of tuples as arguments (the parenthesis will confuse IPython):
5023 5046 \layout Standard
5024 5047
5025 5048
5026 5049 \family typewriter
5027 5050 In [1]: zip (1,2,3),(4,5,6) # won't work
5028 5051 \layout Standard
5029 5052
5030 5053 but this will work:
5031 5054 \layout Standard
5032 5055
5033 5056
5034 5057 \family typewriter
5035 5058 In [2]: /zip (1,2,3),(4,5,6)
5036 5059 \newline
5037 5060 ------> zip ((1,2,3),(4,5,6))
5038 5061 \newline
5039 5062 Out[2]= [(1, 4), (2, 5), (3, 6)]
5040 5063 \layout Standard
5041 5064
5042 5065 IPython tells you that it has altered your command line by displaying the
5043 5066 new command line preceded by
5044 5067 \family typewriter
5045 5068 -->
5046 5069 \family default
5047 5070 .
5048 5071 e.g.:
5049 5072 \layout Standard
5050 5073
5051 5074
5052 5075 \family typewriter
5053 5076 In [18]: callable list
5054 5077 \newline
5055 5078 -------> callable (list)
5056 5079 \layout Subsubsection
5057 5080
5058 5081 Automatic quoting
5059 5082 \layout Standard
5060 5083
5061 5084 You can force automatic quoting of a function's arguments by using
5062 5085 \family typewriter
5063 5086 `,'
5064 5087 \family default
5065 5088 or
5066 5089 \family typewriter
5067 5090 `;'
5068 5091 \family default
5069 5092 as the first character of a line.
5070 5093 For example:
5071 5094 \layout Standard
5072 5095
5073 5096
5074 5097 \family typewriter
5075 5098 >>> ,my_function /home/me # becomes my_function("/home/me")
5076 5099 \layout Standard
5077 5100
5078 5101 If you use
5079 5102 \family typewriter
5080 5103 `;'
5081 5104 \family default
5082 5105 instead, the whole argument is quoted as a single string (while
5083 5106 \family typewriter
5084 5107 `,'
5085 5108 \family default
5086 5109 splits on whitespace):
5087 5110 \layout Standard
5088 5111
5089 5112
5090 5113 \family typewriter
5091 5114 >>> ,my_function a b c # becomes my_function("a","b","c")
5092 5115 \layout Standard
5093 5116
5094 5117
5095 5118 \family typewriter
5096 5119 >>> ;my_function a b c # becomes my_function("a b c")
5097 5120 \layout Standard
5098 5121
5099 5122 Note that the `
5100 5123 \family typewriter
5101 5124 ,
5102 5125 \family default
5103 5126 ' or `
5104 5127 \family typewriter
5105 5128 ;
5106 5129 \family default
5107 5130 ' MUST be the first character on the line! This won't work:
5108 5131 \layout Standard
5109 5132
5110 5133
5111 5134 \family typewriter
5112 5135 >>> x = ,my_function /home/me # syntax error
5113 5136 \layout Section
5114 5137
5115 5138
5116 5139 \begin_inset LatexCommand \label{sec:customization}
5117 5140
5118 5141 \end_inset
5119 5142
5120 5143 Customization
5121 5144 \layout Standard
5122 5145
5123 5146 As we've already mentioned, IPython reads a configuration file which can
5124 5147 be specified at the command line (
5125 5148 \family typewriter
5126 5149 -rcfile
5127 5150 \family default
5128 5151 ) or which by default is assumed to be called
5129 5152 \family typewriter
5130 5153 ipythonrc
5131 5154 \family default
5132 5155 .
5133 5156 Such a file is looked for in the current directory where IPython is started
5134 5157 and then in your
5135 5158 \family typewriter
5136 5159 IPYTHONDIR
5137 5160 \family default
5138 5161 , which allows you to have local configuration files for specific projects.
5139 5162 In this section we will call these types of configuration files simply
5140 5163 rcfiles (short for resource configuration file).
5141 5164 \layout Standard
5142 5165
5143 5166 The syntax of an rcfile is one of key-value pairs separated by whitespace,
5144 5167 one per line.
5145 5168 Lines beginning with a
5146 5169 \family typewriter
5147 5170 #
5148 5171 \family default
5149 5172 are ignored as comments, but comments can
5150 5173 \series bold
5151 5174 not
5152 5175 \series default
5153 5176 be put on lines with data (the parser is fairly primitive).
5154 5177 Note that these are not python files, and this is deliberate, because it
5155 5178 allows us to do some things which would be quite tricky to implement if
5156 5179 they were normal python files.
5157 5180 \layout Standard
5158 5181
5159 5182 First, an rcfile can contain permanent default values for almost all command
5160 5183 line options (except things like
5161 5184 \family typewriter
5162 5185 -help
5163 5186 \family default
5164 5187 or
5165 5188 \family typewriter
5166 5189 -Version
5167 5190 \family default
5168 5191 ).
5169 5192 Sec\SpecialChar ~
5170 5193
5171 5194 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5172 5195
5173 5196 \end_inset
5174 5197
5175 5198 contains a description of all command-line options.
5176 5199 However, values you explicitly specify at the command line override the
5177 5200 values defined in the rcfile.
5178 5201 \layout Standard
5179 5202
5180 5203 Besides command line option values, the rcfile can specify values for certain
5181 5204 extra special options which are not available at the command line.
5182 5205 These options are briefly described below.
5183 5206
5184 5207 \layout Standard
5185 5208
5186 5209 Each of these options may appear as many times as you need it in the file.
5187 5210 \layout List
5188 5211 \labelwidthstring 00.00.0000
5189 5212
5190 5213
5191 5214 \family typewriter
5192 5215 \series bold
5193 5216 include\SpecialChar ~
5194 5217 <file1>\SpecialChar ~
5195 5218 <file2>\SpecialChar ~
5196 5219 ...
5197 5220 \family default
5198 5221 \series default
5199 5222 : you can name
5200 5223 \emph on
5201 5224 other
5202 5225 \emph default
5203 5226 rcfiles you want to recursively load up to 15 levels (don't use the
5204 5227 \family typewriter
5205 5228 <>
5206 5229 \family default
5207 5230 brackets in your names!).
5208 5231 This feature allows you to define a 'base' rcfile with general options
5209 5232 and special-purpose files which can be loaded only when needed with particular
5210 5233 configuration options.
5211 5234 To make this more convenient, IPython accepts the
5212 5235 \family typewriter
5213 5236 -profile <name>
5214 5237 \family default
5215 5238 option (abbreviates to
5216 5239 \family typewriter
5217 5240 -p <name
5218 5241 \family default
5219 5242 >)
5220 5243 \family typewriter
5221 5244 which
5222 5245 \family default
5223 5246 tells it to look for an rcfile named
5224 5247 \family typewriter
5225 5248 ipythonrc-<name>
5226 5249 \family default
5227 5250 .
5228 5251
5229 5252 \layout List
5230 5253 \labelwidthstring 00.00.0000
5231 5254
5232 5255
5233 5256 \family typewriter
5234 5257 \series bold
5235 5258 import_mod\SpecialChar ~
5236 5259 <mod1>\SpecialChar ~
5237 5260 <mod2>\SpecialChar ~
5238 5261 ...
5239 5262 \family default
5240 5263 \series default
5241 5264 : import modules with '
5242 5265 \family typewriter
5243 5266 import
5244 5267 \family default
5245 5268
5246 5269 \family typewriter
5247 5270 <mod1>,<mod2>,...
5248 5271 \family default
5249 5272 '
5250 5273 \layout List
5251 5274 \labelwidthstring 00.00.0000
5252 5275
5253 5276
5254 5277 \family typewriter
5255 5278 \series bold
5256 5279 import_some\SpecialChar ~
5257 5280 <mod>\SpecialChar ~
5258 5281 <f1>\SpecialChar ~
5259 5282 <f2>\SpecialChar ~
5260 5283 ...
5261 5284 \family default
5262 5285 \series default
5263 5286 : import functions with '
5264 5287 \family typewriter
5265 5288 from <mod> import
5266 5289 \family default
5267 5290
5268 5291 \family typewriter
5269 5292 <f1>,<f2>,...
5270 5293 \family default
5271 5294 '
5272 5295 \layout List
5273 5296 \labelwidthstring 00.00.0000
5274 5297
5275 5298
5276 5299 \family typewriter
5277 5300 \series bold
5278 5301 import_all\SpecialChar ~
5279 5302 <mod1>\SpecialChar ~
5280 5303 <mod2>\SpecialChar ~
5281 5304 ...
5282 5305 \family default
5283 5306 \series default
5284 5307 : for each module listed import functions with '
5285 5308 \family typewriter
5286 5309 from <mod> import *
5287 5310 \family default
5288 5311 '
5289 5312 \layout List
5290 5313 \labelwidthstring 00.00.0000
5291 5314
5292 5315
5293 5316 \family typewriter
5294 5317 \series bold
5295 5318 execute\SpecialChar ~
5296 5319 <python\SpecialChar ~
5297 5320 code>
5298 5321 \family default
5299 5322 \series default
5300 5323 : give any single-line python code to be executed.
5301 5324 \layout List
5302 5325 \labelwidthstring 00.00.0000
5303 5326
5304 5327
5305 5328 \family typewriter
5306 5329 \series bold
5307 5330 execfile\SpecialChar ~
5308 5331 <filename>
5309 5332 \family default
5310 5333 \series default
5311 5334 : execute the python file given with an '
5312 5335 \family typewriter
5313 5336 execfile(filename)
5314 5337 \family default
5315 5338 ' command.
5316 5339 Username expansion is performed on the given names.
5317 5340 So if you need any amount of extra fancy customization that won't fit in
5318 5341 any of the above 'canned' options, you can just put it in a separate python
5319 5342 file and execute it.
5320 5343 \layout List
5321 5344 \labelwidthstring 00.00.0000
5322 5345
5323 5346
5324 5347 \family typewriter
5325 5348 \series bold
5326 5349 alias\SpecialChar ~
5327 5350 <alias_def>
5328 5351 \family default
5329 5352 \series default
5330 5353 : this is equivalent to calling '
5331 5354 \family typewriter
5332 5355 %alias\SpecialChar ~
5333 5356 <alias_def>
5334 5357 \family default
5335 5358 ' at the IPython command line.
5336 5359 This way, from within IPython you can do common system tasks without having
5337 5360 to exit it or use the
5338 5361 \family typewriter
5339 5362 !
5340 5363 \family default
5341 5364 escape.
5342 5365 IPython isn't meant to be a shell replacement, but it is often very useful
5343 5366 to be able to do things with files while testing code.
5344 5367 This gives you the flexibility to have within IPython any aliases you may
5345 5368 be used to under your normal system shell.
5346 5369 \layout Subsection
5347 5370
5348 5371
5349 5372 \begin_inset LatexCommand \label{sec:ipytonrc-sample}
5350 5373
5351 5374 \end_inset
5352 5375
5353 5376 Sample
5354 5377 \family typewriter
5355 5378 ipythonrc
5356 5379 \family default
5357 5380 file
5358 5381 \layout Standard
5359 5382
5360 5383 The default rcfile, called
5361 5384 \family typewriter
5362 5385 ipythonrc
5363 5386 \family default
5364 5387 and supplied in your
5365 5388 \family typewriter
5366 5389 IPYTHONDIR
5367 5390 \family default
5368 5391 directory contains lots of comments on all of these options.
5369 5392 We reproduce it here for reference:
5370 5393 \layout Standard
5371 5394
5372 5395
5373 5396 \begin_inset ERT
5374 5397 status Open
5375 5398
5376 5399 \layout Standard
5377 5400
5378 5401 \backslash
5379 lstinputlisting{../IPython/UserConfig/ipythonrc}
5402 codelist{../IPython/UserConfig/ipythonrc}
5380 5403 \end_inset
5381 5404
5382 5405
5383 5406 \layout Subsection
5384 5407
5385 5408
5386 5409 \begin_inset LatexCommand \label{sec:prompts}
5387 5410
5388 5411 \end_inset
5389 5412
5390 5413 Fine-tuning your prompt
5391 5414 \layout Standard
5392 5415
5393 5416 IPython's prompts can be customized using a syntax similar to that of the
5394 5417
5395 5418 \family typewriter
5396 5419 bash
5397 5420 \family default
5398 5421 shell.
5399 5422 Many of
5400 5423 \family typewriter
5401 5424 bash
5402 5425 \family default
5403 5426 's escapes are supported, as well as a few additional ones.
5404 5427 We list them below:
5405 5428 \layout Description
5406 5429
5407 5430
5408 5431 \backslash
5409 5432 # the prompt/history count number
5410 5433 \layout Description
5411 5434
5412 5435
5413 5436 \backslash
5414 5437 D the prompt/history count, with the actual digits replaced by dots.
5415 5438 Used mainly in continuation prompts (prompt_in2)
5416 5439 \layout Description
5417 5440
5418 5441
5419 5442 \backslash
5420 5443 w the current working directory
5421 5444 \layout Description
5422 5445
5423 5446
5424 5447 \backslash
5425 5448 W the basename of current working directory
5426 5449 \layout Description
5427 5450
5428 5451
5429 5452 \backslash
5430 5453 X
5431 5454 \emph on
5432 5455 n
5433 5456 \emph default
5434 5457 where
5435 5458 \begin_inset Formula $n=0\ldots5.$
5436 5459 \end_inset
5437 5460
5438 5461 The current working directory, with
5439 5462 \family typewriter
5440 5463 $HOME
5441 5464 \family default
5442 5465 replaced by
5443 5466 \family typewriter
5444 5467 ~
5445 5468 \family default
5446 5469 , and filtered out to contain only
5447 5470 \begin_inset Formula $n$
5448 5471 \end_inset
5449 5472
5450 5473 path elements
5451 5474 \layout Description
5452 5475
5453 5476
5454 5477 \backslash
5455 5478 Y
5456 5479 \emph on
5457 5480 n
5458 5481 \emph default
5459 5482 Similar to
5460 5483 \backslash
5461 5484 X
5462 5485 \emph on
5463 5486 n
5464 5487 \emph default
5465 5488 , but with the
5466 5489 \begin_inset Formula $n+1$
5467 5490 \end_inset
5468 5491
5469 5492 element included if it is
5470 5493 \family typewriter
5471 5494 ~
5472 5495 \family default
5473 5496 (this is similar to the behavior of the %c
5474 5497 \emph on
5475 5498 n
5476 5499 \emph default
5477 5500 escapes in
5478 5501 \family typewriter
5479 5502 tcsh
5480 5503 \family default
5481 5504 )
5482 5505 \layout Description
5483 5506
5484 5507
5485 5508 \backslash
5486 5509 u the username of the current user
5487 5510 \layout Description
5488 5511
5489 5512
5490 5513 \backslash
5491 5514 $ if the effective UID is 0, a #, otherwise a $
5492 5515 \layout Description
5493 5516
5494 5517
5495 5518 \backslash
5496 5519 h the hostname up to the first `.'
5497 5520 \layout Description
5498 5521
5499 5522
5500 5523 \backslash
5501 5524 H the hostname
5502 5525 \layout Description
5503 5526
5504 5527
5505 5528 \backslash
5506 5529 n a newline
5507 5530 \layout Description
5508 5531
5509 5532
5510 5533 \backslash
5511 5534 r a carriage return
5512 5535 \layout Description
5513 5536
5514 5537
5515 5538 \backslash
5516 5539 v IPython version string
5517 5540 \layout Standard
5518 5541
5519 5542 In addition to these, ANSI color escapes can be insterted into the prompts,
5520 5543 as
5521 5544 \family typewriter
5522 5545
5523 5546 \backslash
5524 5547 C_
5525 5548 \emph on
5526 5549 ColorName
5527 5550 \family default
5528 5551 \emph default
5529 5552 .
5530 5553 The list of valid color names is: Black, Blue, Brown, Cyan, DarkGray, Green,
5531 5554 LightBlue, LightCyan, LightGray, LightGreen, LightPurple, LightRed, NoColor,
5532 5555 Normal, Purple, Red, White, Yellow.
5533 5556 \layout Standard
5534 5557
5535 5558 Finally, IPython supports the evaluation of arbitrary expressions in your
5536 5559 prompt string.
5537 5560 The prompt strings are evaluated through the syntax of PEP 215, but basically
5538 5561 you can use
5539 5562 \family typewriter
5540 5563 $x.y
5541 5564 \family default
5542 5565 to expand the value of
5543 5566 \family typewriter
5544 5567 x.y
5545 5568 \family default
5546 5569 , and for more complicated expressions you can use braces:
5547 5570 \family typewriter
5548 5571 ${foo()+x}
5549 5572 \family default
5550 5573 will call function
5551 5574 \family typewriter
5552 5575 foo
5553 5576 \family default
5554 5577 and add to it the value of
5555 5578 \family typewriter
5556 5579 x
5557 5580 \family default
5558 5581 , before putting the result into your prompt.
5559 5582 For example, using
5560 5583 \newline
5561 5584
5562 5585 \family typewriter
5563 5586 prompt_in1 '${commands.getoutput("uptime")}
5564 5587 \backslash
5565 5588 nIn [
5566 5589 \backslash
5567 5590 #]: '
5568 5591 \newline
5569 5592
5570 5593 \family default
5571 5594 will print the result of the uptime command on each prompt (assuming the
5572 5595
5573 5596 \family typewriter
5574 5597 commands
5575 5598 \family default
5576 5599 module has been imported in your
5577 5600 \family typewriter
5578 5601 ipythonrc
5579 5602 \family default
5580 5603 file).
5581 5604 \layout Subsubsection
5582 5605
5583 5606 Prompt examples
5584 5607 \layout Standard
5585 5608
5586 5609 The following options in an ipythonrc file will give you IPython's default
5587 5610 prompts:
5588 5611 \layout Standard
5589 5612
5590 5613
5591 5614 \family typewriter
5592 5615 prompt_in1 'In [
5593 5616 \backslash
5594 5617 #]:'
5595 5618 \newline
5596 5619 prompt_in2 '\SpecialChar ~
5597 5620 \SpecialChar ~
5598 5621 \SpecialChar ~
5599 5622 .
5600 5623 \backslash
5601 5624 D.:'
5602 5625 \newline
5603 5626 prompt_out 'Out[
5604 5627 \backslash
5605 5628 #]:'
5606 5629 \layout Standard
5607 5630
5608 5631 which look like this:
5609 5632 \layout Standard
5610 5633
5611 5634
5612 5635 \family typewriter
5613 5636 In [1]: 1+2
5614 5637 \newline
5615 5638 Out[1]: 3
5616 5639 \layout Standard
5617 5640
5618 5641
5619 5642 \family typewriter
5620 5643 In [2]: for i in (1,2,3):
5621 5644 \newline
5622 5645
5623 5646 \begin_inset ERT
5624 5647 status Collapsed
5625 5648
5626 5649 \layout Standard
5627 5650
5628 5651 \backslash
5629 5652 hspace*{0mm}
5630 5653 \end_inset
5631 5654
5632 5655 \SpecialChar ~
5633 5656 \SpecialChar ~
5634 5657 \SpecialChar ~
5635 5658 ...: \SpecialChar ~
5636 5659 \SpecialChar ~
5637 5660 \SpecialChar ~
5638 5661 \SpecialChar ~
5639 5662 print i,
5640 5663 \newline
5641 5664
5642 5665 \begin_inset ERT
5643 5666 status Collapsed
5644 5667
5645 5668 \layout Standard
5646 5669
5647 5670 \backslash
5648 5671 hspace*{0mm}
5649 5672 \end_inset
5650 5673
5651 5674 \SpecialChar ~
5652 5675 \SpecialChar ~
5653 5676 \SpecialChar ~
5654 5677 ...:
5655 5678 \newline
5656 5679 1 2 3
5657 5680 \layout Standard
5658 5681
5659 5682 These will give you a very colorful prompt with path information:
5660 5683 \layout Standard
5661 5684
5662 5685
5663 5686 \family typewriter
5664 5687 #prompt_in1 '
5665 5688 \backslash
5666 5689 C_Red
5667 5690 \backslash
5668 5691 u
5669 5692 \backslash
5670 5693 C_Blue[
5671 5694 \backslash
5672 5695 C_Cyan
5673 5696 \backslash
5674 5697 Y1
5675 5698 \backslash
5676 5699 C_Blue]
5677 5700 \backslash
5678 5701 C_LightGreen
5679 5702 \backslash
5680 5703 #>'
5681 5704 \newline
5682 5705 prompt_in2 ' ..
5683 5706 \backslash
5684 5707 D>'
5685 5708 \newline
5686 5709 prompt_out '<
5687 5710 \backslash
5688 5711 #>'
5689 5712 \layout Standard
5690 5713
5691 5714 which look like this:
5692 5715 \layout Standard
5693 5716
5694 5717
5695 5718 \family typewriter
5696 5719 \color red
5697 5720 fperez
5698 5721 \color blue
5699 5722 [
5700 5723 \color cyan
5701 5724 ~/ipython
5702 5725 \color blue
5703 5726 ]
5704 5727 \color green
5705 5728 1>
5706 5729 \color default
5707 5730 1+2
5708 5731 \newline
5709 5732
5710 5733 \begin_inset ERT
5711 5734 status Collapsed
5712 5735
5713 5736 \layout Standard
5714 5737
5715 5738 \backslash
5716 5739 hspace*{0mm}
5717 5740 \end_inset
5718 5741
5719 5742 \SpecialChar ~
5720 5743 \SpecialChar ~
5721 5744 \SpecialChar ~
5722 5745 \SpecialChar ~
5723 5746 \SpecialChar ~
5724 5747 \SpecialChar ~
5725 5748 \SpecialChar ~
5726 5749 \SpecialChar ~
5727 5750 \SpecialChar ~
5728 5751 \SpecialChar ~
5729 5752 \SpecialChar ~
5730 5753 \SpecialChar ~
5731 5754 \SpecialChar ~
5732 5755 \SpecialChar ~
5733 5756 \SpecialChar ~
5734 5757 \SpecialChar ~
5735 5758
5736 5759 \color red
5737 5760 <1>
5738 5761 \color default
5739 5762 3
5740 5763 \newline
5741 5764
5742 5765 \color red
5743 5766 fperez
5744 5767 \color blue
5745 5768 [
5746 5769 \color cyan
5747 5770 ~/ipython
5748 5771 \color blue
5749 5772 ]
5750 5773 \color green
5751 5774 2>
5752 5775 \color default
5753 5776 for i in (1,2,3):
5754 5777 \newline
5755 5778
5756 5779 \begin_inset ERT
5757 5780 status Collapsed
5758 5781
5759 5782 \layout Standard
5760 5783
5761 5784 \backslash
5762 5785 hspace*{0mm}
5763 5786 \end_inset
5764 5787
5765 5788 \SpecialChar ~
5766 5789 \SpecialChar ~
5767 5790 \SpecialChar ~
5768 5791 \SpecialChar ~
5769 5792 \SpecialChar ~
5770 5793 \SpecialChar ~
5771 5794 \SpecialChar ~
5772 5795 \SpecialChar ~
5773 5796 \SpecialChar ~
5774 5797 \SpecialChar ~
5775 5798 \SpecialChar ~
5776 5799 \SpecialChar ~
5777 5800 \SpecialChar ~
5778 5801 \SpecialChar ~
5779 5802 \SpecialChar ~
5780 5803
5781 5804 \color green
5782 5805 ...>
5783 5806 \color default
5784 5807 \SpecialChar ~
5785 5808 \SpecialChar ~
5786 5809 \SpecialChar ~
5787 5810 \SpecialChar ~
5788 5811 print i,
5789 5812 \newline
5790 5813
5791 5814 \begin_inset ERT
5792 5815 status Collapsed
5793 5816
5794 5817 \layout Standard
5795 5818
5796 5819 \backslash
5797 5820 hspace*{0mm}
5798 5821 \end_inset
5799 5822
5800 5823 \SpecialChar ~
5801 5824 \SpecialChar ~
5802 5825 \SpecialChar ~
5803 5826 \SpecialChar ~
5804 5827 \SpecialChar ~
5805 5828 \SpecialChar ~
5806 5829 \SpecialChar ~
5807 5830 \SpecialChar ~
5808 5831 \SpecialChar ~
5809 5832 \SpecialChar ~
5810 5833 \SpecialChar ~
5811 5834 \SpecialChar ~
5812 5835 \SpecialChar ~
5813 5836 \SpecialChar ~
5814 5837 \SpecialChar ~
5815 5838
5816 5839 \color green
5817 5840 ...>
5818 5841 \color default
5819 5842
5820 5843 \newline
5821 5844 1 2 3
5822 5845 \layout Standard
5823 5846
5824 5847 The following shows the usage of dynamic expression evaluation:
5825 5848 \layout Subsection
5826 5849
5827 5850
5828 5851 \begin_inset LatexCommand \label{sec:profiles}
5829 5852
5830 5853 \end_inset
5831 5854
5832 5855 IPython profiles
5833 5856 \layout Standard
5834 5857
5835 5858 As we already mentioned, IPython supports the
5836 5859 \family typewriter
5837 5860 -profile
5838 5861 \family default
5839 5862 command-line option (see sec.
5840 5863
5841 5864 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5842 5865
5843 5866 \end_inset
5844 5867
5845 5868 ).
5846 5869 A profile is nothing more than a particular configuration file like your
5847 5870 basic
5848 5871 \family typewriter
5849 5872 ipythonrc
5850 5873 \family default
5851 5874 one, but with particular customizations for a specific purpose.
5852 5875 When you start IPython with '
5853 5876 \family typewriter
5854 5877 ipython -profile <name>
5855 5878 \family default
5856 5879 ', it assumes that in your
5857 5880 \family typewriter
5858 5881 IPYTHONDIR
5859 5882 \family default
5860 5883 there is a file called
5861 5884 \family typewriter
5862 5885 ipythonrc-<name>
5863 5886 \family default
5864 5887 , and loads it instead of the normal
5865 5888 \family typewriter
5866 5889 ipythonrc
5867 5890 \family default
5868 5891 .
5869 5892 \layout Standard
5870 5893
5871 5894 This system allows you to maintain multiple configurations which load modules,
5872 5895 set options, define functions, etc.
5873 5896 suitable for different tasks and activate them in a very simple manner.
5874 5897 In order to avoid having to repeat all of your basic options (common things
5875 5898 that don't change such as your color preferences, for example), any profile
5876 5899 can include another configuration file.
5877 5900 The most common way to use profiles is then to have each one include your
5878 5901 basic
5879 5902 \family typewriter
5880 5903 ipythonrc
5881 5904 \family default
5882 5905 file as a starting point, and then add further customizations.
5883 5906 \layout Standard
5884 5907
5885 5908 In sections
5886 5909 \begin_inset LatexCommand \ref{sec:syntax-extensions}
5887 5910
5888 5911 \end_inset
5889 5912
5890 5913 and
5891 5914 \begin_inset LatexCommand \ref{sec:Gnuplot}
5892 5915
5893 5916 \end_inset
5894 5917
5895 5918 we discuss some particular profiles which come as part of the standard
5896 5919 IPython distribution.
5897 5920 You may also look in your
5898 5921 \family typewriter
5899 5922 IPYTHONDIR
5900 5923 \family default
5901 5924 directory, any file whose name begins with
5902 5925 \family typewriter
5903 5926 ipythonrc-
5904 5927 \family default
5905 5928 is a profile.
5906 5929 You can use those as examples for further customizations to suit your own
5907 5930 needs.
5908 5931 \layout Section
5909 5932
5910 5933
5911 5934 \begin_inset OptArg
5912 5935 collapsed false
5913 5936
5914 5937 \layout Standard
5915 5938
5916 5939 IPython as default...
5917 5940 \end_inset
5918 5941
5919 5942 IPython as your default Python environment
5920 5943 \layout Standard
5921 5944
5922 5945 Python honors the environment variable
5923 5946 \family typewriter
5924 5947 PYTHONSTARTUP
5925 5948 \family default
5926 5949 and will execute at startup the file referenced by this variable.
5927 5950 If you put at the end of this file the following two lines of code:
5928 5951 \layout Standard
5929 5952
5930 5953
5931 5954 \family typewriter
5932 5955 import IPython
5933 5956 \newline
5934 5957 IPython.Shell.IPShell().mainloop(sys_exit=1)
5935 5958 \layout Standard
5936 5959
5937 5960 then IPython will be your working environment anytime you start Python.
5938 5961 The
5939 5962 \family typewriter
5940 5963 sys_exit=1
5941 5964 \family default
5942 5965 is needed to have IPython issue a call to
5943 5966 \family typewriter
5944 5967 sys.exit()
5945 5968 \family default
5946 5969 when it finishes, otherwise you'll be back at the normal Python '
5947 5970 \family typewriter
5948 5971 >>>
5949 5972 \family default
5950 5973 ' prompt
5951 5974 \begin_inset Foot
5952 5975 collapsed true
5953 5976
5954 5977 \layout Standard
5955 5978
5956 5979 Based on an idea by Holger Krekel.
5957 5980 \end_inset
5958 5981
5959 5982 .
5960 5983 \layout Standard
5961 5984
5962 5985 This is probably useful to developers who manage multiple Python versions
5963 5986 and don't want to have correspondingly multiple IPython versions.
5964 5987 Note that in this mode, there is no way to pass IPython any command-line
5965 5988 options, as those are trapped first by Python itself.
5966 5989 \layout Section
5967 5990
5968 5991
5969 5992 \begin_inset LatexCommand \label{sec:embed}
5970 5993
5971 5994 \end_inset
5972 5995
5973 5996 Embedding IPython
5974 5997 \layout Standard
5975 5998
5976 5999 It is possible to start an IPython instance
5977 6000 \emph on
5978 6001 inside
5979 6002 \emph default
5980 6003 your own Python programs.
5981 6004 This allows you to evaluate dynamically the state of your code, operate
5982 6005 with your variables, analyze them, etc.
5983 6006 Note however that any changes you make to values while in the shell do
5984 6007
5985 6008 \emph on
5986 6009 not
5987 6010 \emph default
5988 6011 propagate back to the running code, so it is safe to modify your values
5989 6012 because you won't break your code in bizarre ways by doing so.
5990 6013 \layout Standard
5991 6014
5992 6015 This feature allows you to easily have a fully functional python environment
5993 6016 for doing object introspection anywhere in your code with a simple function
5994 6017 call.
5995 6018 In some cases a simple print statement is enough, but if you need to do
5996 6019 more detailed analysis of a code fragment this feature can be very valuable.
5997 6020 \layout Standard
5998 6021
5999 6022 It can also be useful in scientific computing situations where it is common
6000 6023 to need to do some automatic, computationally intensive part and then stop
6001 6024 to look at data, plots, etc
6002 6025 \begin_inset Foot
6003 6026 collapsed true
6004 6027
6005 6028 \layout Standard
6006 6029
6007 6030 This functionality was inspired by IDL's combination of the
6008 6031 \family typewriter
6009 6032 stop
6010 6033 \family default
6011 6034 keyword and the
6012 6035 \family typewriter
6013 6036 .continue
6014 6037 \family default
6015 6038 executive command, which I have found very useful in the past, and by a
6016 6039 posting on comp.lang.python by cmkl <cmkleffner-AT-gmx.de> on Dec.
6017 6040 06/01 concerning similar uses of pyrepl.
6018 6041 \end_inset
6019 6042
6020 6043 .
6021 6044 Opening an IPython instance will give you full access to your data and
6022 6045 functions, and you can resume program execution once you are done with
6023 6046 the interactive part (perhaps to stop again later, as many times as needed).
6024 6047 \layout Standard
6025 6048
6026 6049 The following code snippet is the bare minimum you need to include in your
6027 6050 Python programs for this to work (detailed examples follow later):
6028 6051 \layout LyX-Code
6029 6052
6030 6053 from IPython.Shell import IPShellEmbed
6031 6054 \layout LyX-Code
6032 6055
6033 6056 ipshell = IPShellEmbed()
6034 6057 \layout LyX-Code
6035 6058
6036 6059 ipshell() # this call anywhere in your program will start IPython
6037 6060 \layout Standard
6038 6061
6039 6062 You can run embedded instances even in code which is itself being run at
6040 6063 the IPython interactive prompt with '
6041 6064 \family typewriter
6042 6065 %run\SpecialChar ~
6043 6066 <filename>
6044 6067 \family default
6045 6068 '.
6046 6069 Since it's easy to get lost as to where you are (in your top-level IPython
6047 6070 or in your embedded one), it's a good idea in such cases to set the in/out
6048 6071 prompts to something different for the embedded instances.
6049 6072 The code examples below illustrate this.
6050 6073 \layout Standard
6051 6074
6052 6075 You can also have multiple IPython instances in your program and open them
6053 6076 separately, for example with different options for data presentation.
6054 6077 If you close and open the same instance multiple times, its prompt counters
6055 6078 simply continue from each execution to the next.
6056 6079 \layout Standard
6057 6080
6058 6081 Please look at the docstrings in the
6059 6082 \family typewriter
6060 6083 Shell.py
6061 6084 \family default
6062 6085 module for more details on the use of this system.
6063 6086 \layout Standard
6064 6087
6065 6088 The following sample file illustrating how to use the embedding functionality
6066 6089 is provided in the examples directory as
6067 6090 \family typewriter
6068 6091 example-embed.py
6069 6092 \family default
6070 6093 .
6071 6094 It should be fairly self-explanatory:
6072 6095 \layout Standard
6073 6096
6074 6097
6075 6098 \begin_inset ERT
6076 6099 status Open
6077 6100
6078 6101 \layout Standard
6079 6102
6080 6103 \backslash
6081 lstinputlisting{examples/example-embed.py}
6104 codelist{examples/example-embed.py}
6082 6105 \end_inset
6083 6106
6084 6107
6085 6108 \layout Standard
6086 6109
6087 6110 Once you understand how the system functions, you can use the following
6088 6111 code fragments in your programs which are ready for cut and paste:
6089 6112 \layout Standard
6090 6113
6091 6114
6092 6115 \begin_inset ERT
6093 6116 status Open
6094 6117
6095 6118 \layout Standard
6096 6119
6097 6120 \backslash
6098 lstinputlisting{examples/example-embed-short.py}
6121 codelist{examples/example-embed-short.py}
6099 6122 \end_inset
6100 6123
6101 6124
6102 6125 \layout Section
6103 6126
6104 6127
6105 6128 \begin_inset LatexCommand \label{sec:using-pdb}
6106 6129
6107 6130 \end_inset
6108 6131
6109 6132 Using the Python debugger (
6110 6133 \family typewriter
6111 6134 pdb
6112 6135 \family default
6113 6136 )
6114 6137 \layout Subsection
6115 6138
6116 6139 Running entire programs via
6117 6140 \family typewriter
6118 6141 pdb
6119 6142 \layout Standard
6120 6143
6121 6144
6122 6145 \family typewriter
6123 6146 pdb
6124 6147 \family default
6125 6148 , the Python debugger, is a powerful interactive debugger which allows you
6126 6149 to step through code, set breakpoints, watch variables, etc.
6127 6150 IPython makes it very easy to start any script under the control of
6128 6151 \family typewriter
6129 6152 pdb
6130 6153 \family default
6131 6154 , regardless of whether you have wrapped it into a
6132 6155 \family typewriter
6133 6156 `main()'
6134 6157 \family default
6135 6158 function or not.
6136 6159 For this, simply type
6137 6160 \family typewriter
6138 6161 `%run -d myscript'
6139 6162 \family default
6140 6163 at an IPython prompt.
6141 6164 See the
6142 6165 \family typewriter
6143 6166 %run
6144 6167 \family default
6145 6168 command's documentation (via
6146 6169 \family typewriter
6147 6170 `%run?'
6148 6171 \family default
6149 6172 or in Sec.\SpecialChar ~
6150 6173
6151 6174 \begin_inset LatexCommand \ref{sec:magic}
6152 6175
6153 6176 \end_inset
6154 6177
6155 6178 ) for more details, including how to control where
6156 6179 \family typewriter
6157 6180 pdb
6158 6181 \family default
6159 6182 will stop execution first.
6160 6183 \layout Standard
6161 6184
6162 6185 For more information on the use of the
6163 6186 \family typewriter
6164 6187 pdb
6165 6188 \family default
6166 6189 debugger, read the included
6167 6190 \family typewriter
6168 6191 pdb.doc
6169 6192 \family default
6170 6193 file (part of the standard Python distribution).
6171 6194 On a stock Linux system it is located at
6172 6195 \family typewriter
6173 6196 /usr/lib/python2.3/pdb.doc
6174 6197 \family default
6175 6198 , but the easiest way to read it is by using the
6176 6199 \family typewriter
6177 6200 help()
6178 6201 \family default
6179 6202 function of the
6180 6203 \family typewriter
6181 6204 pdb
6182 6205 \family default
6183 6206 module as follows (in an IPython prompt):
6184 6207 \layout Standard
6185 6208
6186 6209
6187 6210 \family typewriter
6188 6211 In [1]: import pdb
6189 6212 \newline
6190 6213 In [2]: pdb.help()
6191 6214 \layout Standard
6192 6215
6193 6216 This will load the
6194 6217 \family typewriter
6195 6218 pdb.doc
6196 6219 \family default
6197 6220 document in a file viewer for you automatically.
6198 6221 \layout Subsection
6199 6222
6200 6223 Automatic invocation of
6201 6224 \family typewriter
6202 6225 pdb
6203 6226 \family default
6204 6227 on exceptions
6205 6228 \layout Standard
6206 6229
6207 6230 IPython, if started with the
6208 6231 \family typewriter
6209 6232 -pdb
6210 6233 \family default
6211 6234 option (or if the option is set in your rc file) can call the Python
6212 6235 \family typewriter
6213 6236 pdb
6214 6237 \family default
6215 6238 debugger every time your code triggers an uncaught exception
6216 6239 \begin_inset Foot
6217 6240 collapsed true
6218 6241
6219 6242 \layout Standard
6220 6243
6221 6244 Many thanks to Christopher Hart for the request which prompted adding this
6222 6245 feature to IPython.
6223 6246 \end_inset
6224 6247
6225 6248 .
6226 6249 This feature can also be toggled at any time with the
6227 6250 \family typewriter
6228 6251 %pdb
6229 6252 \family default
6230 6253 magic command.
6231 6254 This can be extremely useful in order to find the origin of subtle bugs,
6232 6255 because
6233 6256 \family typewriter
6234 6257 pdb
6235 6258 \family default
6236 6259 opens up at the point in your code which triggered the exception, and while
6237 6260 your program is at this point `dead', all the data is still available and
6238 6261 you can walk up and down the stack frame and understand the origin of the
6239 6262 problem.
6240 6263 \layout Standard
6241 6264
6242 6265 Furthermore, you can use these debugging facilities both with the embedded
6243 6266 IPython mode and without IPython at all.
6244 6267 For an embedded shell (see sec.
6245 6268
6246 6269 \begin_inset LatexCommand \ref{sec:embed}
6247 6270
6248 6271 \end_inset
6249 6272
6250 6273 ), simply call the constructor with
6251 6274 \family typewriter
6252 6275 `-pdb'
6253 6276 \family default
6254 6277 in the argument string and automatically
6255 6278 \family typewriter
6256 6279 pdb
6257 6280 \family default
6258 6281 will be called if an uncaught exception is triggered by your code.
6259 6282
6260 6283 \layout Standard
6261 6284
6262 6285 For stand-alone use of the feature in your programs which do not use IPython
6263 6286 at all, put the following lines toward the top of your `main' routine:
6264 6287 \layout Standard
6265 6288 \align left
6266 6289
6267 6290 \family typewriter
6268 6291 import sys,IPython.ultraTB
6269 6292 \newline
6270 6293 sys.excepthook = IPython.ultraTB.FormattedTB(mode=`Verbose', color_scheme=`Linux',
6271 6294 call_pdb=1)
6272 6295 \layout Standard
6273 6296
6274 6297 The
6275 6298 \family typewriter
6276 6299 mode
6277 6300 \family default
6278 6301 keyword can be either
6279 6302 \family typewriter
6280 6303 `Verbose'
6281 6304 \family default
6282 6305 or
6283 6306 \family typewriter
6284 6307 `Plain'
6285 6308 \family default
6286 6309 , giving either very detailed or normal tracebacks respectively.
6287 6310 The
6288 6311 \family typewriter
6289 6312 color_scheme
6290 6313 \family default
6291 6314 keyword can be one of
6292 6315 \family typewriter
6293 6316 `NoColor'
6294 6317 \family default
6295 6318 ,
6296 6319 \family typewriter
6297 6320 `Linux'
6298 6321 \family default
6299 6322 (default) or
6300 6323 \family typewriter
6301 6324 `LightBG'
6302 6325 \family default
6303 6326 .
6304 6327 These are the same options which can be set in IPython with
6305 6328 \family typewriter
6306 6329 -colors
6307 6330 \family default
6308 6331 and
6309 6332 \family typewriter
6310 6333 -xmode
6311 6334 \family default
6312 6335 .
6313 6336 \layout Standard
6314 6337
6315 6338 This will give any of your programs detailed, colored tracebacks with automatic
6316 6339 invocation of
6317 6340 \family typewriter
6318 6341 pdb
6319 6342 \family default
6320 6343 .
6321 6344 \layout Section
6322 6345
6323 6346
6324 6347 \begin_inset LatexCommand \label{sec:syntax-extensions}
6325 6348
6326 6349 \end_inset
6327 6350
6328 6351 Extensions for syntax processing
6329 6352 \layout Standard
6330 6353
6331 6354 This isn't for the faint of heart, because the potential for breaking things
6332 6355 is quite high.
6333 6356 But it can be a very powerful and useful feature.
6334 6357 In a nutshell, you can redefine the way IPython processes the user input
6335 6358 line to accept new, special extensions to the syntax without needing to
6336 6359 change any of IPython's own code.
6337 6360 \layout Standard
6338 6361
6339 6362 In the
6340 6363 \family typewriter
6341 6364 IPython/Extensions
6342 6365 \family default
6343 6366 directory you will find some examples supplied, which we will briefly describe
6344 6367 now.
6345 6368 These can be used `as is' (and both provide very useful functionality),
6346 6369 or you can use them as a starting point for writing your own extensions.
6347 6370 \layout Subsection
6348 6371
6349 6372 Pasting of code starting with
6350 6373 \family typewriter
6351 6374 `>>>
6352 6375 \family default
6353 6376 ' or
6354 6377 \family typewriter
6355 6378 `...
6356 6379
6357 6380 \family default
6358 6381 '
6359 6382 \layout Standard
6360 6383
6361 6384 In the python tutorial it is common to find code examples which have been
6362 6385 taken from real python sessions.
6363 6386 The problem with those is that all the lines begin with either
6364 6387 \family typewriter
6365 6388 `>>>
6366 6389 \family default
6367 6390 ' or
6368 6391 \family typewriter
6369 6392 `...
6370 6393
6371 6394 \family default
6372 6395 ', which makes it impossible to paste them all at once.
6373 6396 One must instead do a line by line manual copying, carefully removing the
6374 6397 leading extraneous characters.
6375 6398 \layout Standard
6376 6399
6377 6400 This extension identifies those starting characters and removes them from
6378 6401 the input automatically, so that one can paste multi-line examples directly
6379 6402 into IPython, saving a lot of time.
6380 6403 Please look at the file
6381 6404 \family typewriter
6382 6405 InterpreterPasteInput.py
6383 6406 \family default
6384 6407 in the
6385 6408 \family typewriter
6386 6409 IPython/Extensions
6387 6410 \family default
6388 6411 directory for details on how this is done.
6389 6412 \layout Standard
6390 6413
6391 6414 IPython comes with a special profile enabling this feature, called
6392 6415 \family typewriter
6393 6416 tutorial
6394 6417 \family default
6395 6418 \emph on
6396 6419 .
6397 6420
6398 6421 \emph default
6399 6422 Simply start IPython via
6400 6423 \family typewriter
6401 6424 `ipython\SpecialChar ~
6402 6425 -p\SpecialChar ~
6403 6426 tutorial'
6404 6427 \family default
6405 6428 and the feature will be available.
6406 6429 In a normal IPython session you can activate the feature by importing the
6407 6430 corresponding module with:
6408 6431 \newline
6409 6432
6410 6433 \family typewriter
6411 6434 In [1]: import IPython.Extensions.InterpreterPasteInput
6412 6435 \layout Standard
6413 6436
6414 6437 The following is a 'screenshot' of how things work when this extension is
6415 6438 on, copying an example from the standard tutorial:
6416 6439 \layout Standard
6417 6440
6418 6441
6419 6442 \family typewriter
6420 6443 IPython profile: tutorial
6421 6444 \newline
6422 6445 \SpecialChar ~
6423 6446
6424 6447 \newline
6425 6448 *** Pasting of code with ">>>" or "..." has been enabled.
6426 6449 \newline
6427 6450 \SpecialChar ~
6428 6451
6429 6452 \newline
6430 6453 In [1]: >>> def fib2(n): # return Fibonacci series up to n
6431 6454 \newline
6432 6455
6433 6456 \begin_inset ERT
6434 6457 status Collapsed
6435 6458
6436 6459 \layout Standard
6437 6460
6438 6461 \backslash
6439 6462 hspace*{0mm}
6440 6463 \end_inset
6441 6464
6442 6465 \SpecialChar ~
6443 6466 \SpecialChar ~
6444 6467 ...: ...\SpecialChar ~
6445 6468 \SpecialChar ~
6446 6469 \SpecialChar ~
6447 6470 \SpecialChar ~
6448 6471 """Return a list containing the Fibonacci series up to n."""
6449 6472 \newline
6450 6473
6451 6474 \begin_inset ERT
6452 6475 status Collapsed
6453 6476
6454 6477 \layout Standard
6455 6478
6456 6479 \backslash
6457 6480 hspace*{0mm}
6458 6481 \end_inset
6459 6482
6460 6483 \SpecialChar ~
6461 6484 \SpecialChar ~
6462 6485 ...: ...\SpecialChar ~
6463 6486 \SpecialChar ~
6464 6487 \SpecialChar ~
6465 6488 \SpecialChar ~
6466 6489 result = []
6467 6490 \newline
6468 6491
6469 6492 \begin_inset ERT
6470 6493 status Collapsed
6471 6494
6472 6495 \layout Standard
6473 6496
6474 6497 \backslash
6475 6498 hspace*{0mm}
6476 6499 \end_inset
6477 6500
6478 6501 \SpecialChar ~
6479 6502 \SpecialChar ~
6480 6503 ...: ...\SpecialChar ~
6481 6504 \SpecialChar ~
6482 6505 \SpecialChar ~
6483 6506 \SpecialChar ~
6484 6507 a, b = 0, 1
6485 6508 \newline
6486 6509
6487 6510 \begin_inset ERT
6488 6511 status Collapsed
6489 6512
6490 6513 \layout Standard
6491 6514
6492 6515 \backslash
6493 6516 hspace*{0mm}
6494 6517 \end_inset
6495 6518
6496 6519 \SpecialChar ~
6497 6520 \SpecialChar ~
6498 6521 ...: ...\SpecialChar ~
6499 6522 \SpecialChar ~
6500 6523 \SpecialChar ~
6501 6524 \SpecialChar ~
6502 6525 while b < n:
6503 6526 \newline
6504 6527
6505 6528 \begin_inset ERT
6506 6529 status Collapsed
6507 6530
6508 6531 \layout Standard
6509 6532
6510 6533 \backslash
6511 6534 hspace*{0mm}
6512 6535 \end_inset
6513 6536
6514 6537 \SpecialChar ~
6515 6538 \SpecialChar ~
6516 6539 ...: ...\SpecialChar ~
6517 6540 \SpecialChar ~
6518 6541 \SpecialChar ~
6519 6542 \SpecialChar ~
6520 6543 \SpecialChar ~
6521 6544 \SpecialChar ~
6522 6545 \SpecialChar ~
6523 6546 \SpecialChar ~
6524 6547 result.append(b)\SpecialChar ~
6525 6548 \SpecialChar ~
6526 6549 \SpecialChar ~
6527 6550 # see below
6528 6551 \newline
6529 6552
6530 6553 \begin_inset ERT
6531 6554 status Collapsed
6532 6555
6533 6556 \layout Standard
6534 6557
6535 6558 \backslash
6536 6559 hspace*{0mm}
6537 6560 \end_inset
6538 6561
6539 6562 \SpecialChar ~
6540 6563 \SpecialChar ~
6541 6564 ...: ...\SpecialChar ~
6542 6565 \SpecialChar ~
6543 6566 \SpecialChar ~
6544 6567 \SpecialChar ~
6545 6568 \SpecialChar ~
6546 6569 \SpecialChar ~
6547 6570 \SpecialChar ~
6548 6571 \SpecialChar ~
6549 6572 a, b = b, a+b
6550 6573 \newline
6551 6574
6552 6575 \begin_inset ERT
6553 6576 status Collapsed
6554 6577
6555 6578 \layout Standard
6556 6579
6557 6580 \backslash
6558 6581 hspace*{0mm}
6559 6582 \end_inset
6560 6583
6561 6584 \SpecialChar ~
6562 6585 \SpecialChar ~
6563 6586 ...: ...\SpecialChar ~
6564 6587 \SpecialChar ~
6565 6588 \SpecialChar ~
6566 6589 \SpecialChar ~
6567 6590 return result
6568 6591 \newline
6569 6592
6570 6593 \begin_inset ERT
6571 6594 status Collapsed
6572 6595
6573 6596 \layout Standard
6574 6597
6575 6598 \backslash
6576 6599 hspace*{0mm}
6577 6600 \end_inset
6578 6601
6579 6602 \SpecialChar ~
6580 6603 \SpecialChar ~
6581 6604 ...:
6582 6605 \newline
6583 6606 \SpecialChar ~
6584 6607
6585 6608 \newline
6586 6609 In [2]: fib2(10)
6587 6610 \newline
6588 6611 Out[2]: [1, 1, 2, 3, 5, 8]
6589 6612 \layout Standard
6590 6613
6591 6614 Note that as currently written, this extension does
6592 6615 \emph on
6593 6616 not
6594 6617 \emph default
6595 6618 recognize IPython's prompts for pasting.
6596 6619 Those are more complicated, since the user can change them very easily,
6597 6620 they involve numbers and can vary in length.
6598 6621 One could however extract all the relevant information from the IPython
6599 6622 instance and build an appropriate regular expression.
6600 6623 This is left as an exercise for the reader.
6601 6624 \layout Subsection
6602 6625
6603 6626 Input of physical quantities with units
6604 6627 \layout Standard
6605 6628
6606 6629 The module
6607 6630 \family typewriter
6608 6631 PhysicalQInput
6609 6632 \family default
6610 6633 allows a simplified form of input for physical quantities with units.
6611 6634 This file is meant to be used in conjunction with the
6612 6635 \family typewriter
6613 6636 PhysicalQInteractive
6614 6637 \family default
6615 6638 module (in the same directory) and
6616 6639 \family typewriter
6617 6640 Physics.PhysicalQuantities
6618 6641 \family default
6619 6642 from Konrad Hinsen's ScientificPython (
6620 6643 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/hinsen/scientific.html}
6621 6644
6622 6645 \end_inset
6623 6646
6624 6647 ).
6625 6648 \layout Standard
6626 6649
6627 6650 The
6628 6651 \family typewriter
6629 6652 Physics.PhysicalQuantities
6630 6653 \family default
6631 6654 module defines
6632 6655 \family typewriter
6633 6656 PhysicalQuantity
6634 6657 \family default
6635 6658 objects, but these must be declared as instances of a class.
6636 6659 For example, to define
6637 6660 \family typewriter
6638 6661 v
6639 6662 \family default
6640 6663 as a velocity of 3\SpecialChar ~
6641 6664 m/s, normally you would write:
6642 6665 \family typewriter
6643 6666
6644 6667 \newline
6645 6668 In [1]: v = PhysicalQuantity(3,'m/s')
6646 6669 \layout Standard
6647 6670
6648 6671 Using the
6649 6672 \family typewriter
6650 6673 PhysicalQ_Input
6651 6674 \family default
6652 6675 extension this can be input instead as:
6653 6676 \family typewriter
6654 6677
6655 6678 \newline
6656 6679 In [1]: v = 3 m/s
6657 6680 \family default
6658 6681
6659 6682 \newline
6660 6683 which is much more convenient for interactive use (even though it is blatantly
6661 6684 invalid Python syntax).
6662 6685 \layout Standard
6663 6686
6664 6687 The
6665 6688 \family typewriter
6666 6689 physics
6667 6690 \family default
6668 6691 profile supplied with IPython (enabled via
6669 6692 \family typewriter
6670 6693 'ipython -p physics'
6671 6694 \family default
6672 6695 ) uses these extensions, which you can also activate with:
6673 6696 \layout Standard
6674 6697
6675 6698
6676 6699 \family typewriter
6677 6700 from math import * # math MUST be imported BEFORE PhysicalQInteractive
6678 6701 \newline
6679 6702 from IPython.Extensions.PhysicalQInteractive import *
6680 6703 \newline
6681 6704 import IPython.Extensions.PhysicalQInput
6682 6705 \layout Section
6683 6706
6684 6707 IPython as a system shell
6685 6708 \layout Standard
6686 6709
6687 6710 IPython ships with a special profile called
6688 6711 \family typewriter
6689 6712 pysh
6690 6713 \family default
6691 6714 , which you can activate at the command line as
6692 6715 \family typewriter
6693 6716 `ipython -p pysh'
6694 6717 \family default
6695 6718 .
6696 6719 This loads
6697 6720 \family typewriter
6698 6721 InterpreterExec
6699 6722 \family default
6700 6723 , along with some additional facilities and a prompt customized for filesystem
6701 6724 navigation.
6702 6725 \layout Standard
6703 6726
6704 6727 Note that this does
6705 6728 \emph on
6706 6729 not
6707 6730 \emph default
6708 6731 make IPython a full-fledged system shell.
6709 6732 In particular, it has no job control, so if you type Ctrl-Z (under Unix),
6710 6733 you'll suspend pysh itself, not the process you just started.
6711 6734
6712 6735 \layout Standard
6713 6736
6714 6737 What the shell profile allows you to do is to use the convenient and powerful
6715 6738 syntax of Python to do quick scripting at the command line.
6716 6739 Below we describe some of its features.
6717 6740 \layout Subsection
6718 6741
6719 6742 Aliases
6720 6743 \layout Standard
6721 6744
6722 6745 All of your
6723 6746 \family typewriter
6724 6747 $PATH
6725 6748 \family default
6726 6749 has been loaded as IPython aliases, so you should be able to type any normal
6727 6750 system command and have it executed.
6728 6751 See
6729 6752 \family typewriter
6730 6753 %alias?
6731 6754 \family default
6732 6755 and
6733 6756 \family typewriter
6734 6757 %unalias?
6735 6758 \family default
6736 6759 for details on the alias facilities.
6737 6760 See also
6738 6761 \family typewriter
6739 6762 %rehash?
6740 6763 \family default
6741 6764 and
6742 6765 \family typewriter
6743 6766 %rehashx?
6744 6767 \family default
6745 6768 for details on the mechanism used to load
6746 6769 \family typewriter
6747 6770 $PATH
6748 6771 \family default
6749 6772 .
6750 6773 \layout Subsection
6751 6774
6752 6775 Special syntax
6753 6776 \layout Standard
6754 6777
6755 6778 Any lines which begin with
6756 6779 \family typewriter
6757 6780 `~'
6758 6781 \family default
6759 6782 ,
6760 6783 \family typewriter
6761 6784 `/'
6762 6785 \family default
6763 6786 and
6764 6787 \family typewriter
6765 6788 `.'
6766 6789 \family default
6767 6790 will be executed as shell commands instead of as Python code.
6768 6791 The special escapes below are also recognized.
6769 6792
6770 6793 \family typewriter
6771 6794 !cmd
6772 6795 \family default
6773 6796 is valid in single or multi-line input, all others are only valid in single-lin
6774 6797 e input:
6775 6798 \layout Description
6776 6799
6777 6800
6778 6801 \family typewriter
6779 6802 !cmd
6780 6803 \family default
6781 6804 pass `cmd' directly to the shell
6782 6805 \layout Description
6783 6806
6784 6807
6785 6808 \family typewriter
6786 6809 !!cmd
6787 6810 \family default
6788 6811 execute `cmd' and return output as a list (split on `
6789 6812 \backslash
6790 6813 n')
6791 6814 \layout Description
6792 6815
6793 6816
6794 6817 \family typewriter
6795 6818 $var=cmd
6796 6819 \family default
6797 6820 capture output of cmd into var, as a string
6798 6821 \layout Description
6799 6822
6800 6823
6801 6824 \family typewriter
6802 6825 $$var=cmd
6803 6826 \family default
6804 6827 capture output of cmd into var, as a list (split on `
6805 6828 \backslash
6806 6829 n')
6807 6830 \layout Standard
6808 6831
6809 6832 The
6810 6833 \family typewriter
6811 6834 $
6812 6835 \family default
6813 6836 /
6814 6837 \family typewriter
6815 6838 $$
6816 6839 \family default
6817 6840 syntaxes make Python variables from system output, which you can later
6818 6841 use for further scripting.
6819 6842 The converse is also possible: when executing an alias or calling to the
6820 6843 system via
6821 6844 \family typewriter
6822 6845 !
6823 6846 \family default
6824 6847 /
6825 6848 \family typewriter
6826 6849 !!
6827 6850 \family default
6828 6851 , you can expand any python variable or expression by prepending it with
6829 6852
6830 6853 \family typewriter
6831 6854 $
6832 6855 \family default
6833 6856 .
6834 6857 Full details of the allowed syntax can be found in Python's PEP 215.
6835 6858 \layout Standard
6836 6859
6837 6860 A few brief examples will illustrate these (note that the indentation below
6838 6861 may be incorrectly displayed):
6839 6862 \layout Standard
6840 6863
6841 6864
6842 6865 \family typewriter
6843 6866 fperez[~/test]|3> !ls *s.py
6844 6867 \newline
6845 6868 scopes.py strings.py
6846 6869 \layout Standard
6847 6870
6848 6871 ls is an internal alias, so there's no need to use
6849 6872 \family typewriter
6850 6873 !
6851 6874 \family default
6852 6875 :
6853 6876 \layout Standard
6854 6877
6855 6878
6856 6879 \family typewriter
6857 6880 fperez[~/test]|4> ls *s.py
6858 6881 \newline
6859 6882 scopes.py* strings.py
6860 6883 \layout Standard
6861 6884
6862 6885 !!ls will return the output into a Python variable:
6863 6886 \layout Standard
6864 6887
6865 6888
6866 6889 \family typewriter
6867 6890 fperez[~/test]|5> !!ls *s.py
6868 6891 \newline
6869 6892
6870 6893 \begin_inset ERT
6871 6894 status Collapsed
6872 6895
6873 6896 \layout Standard
6874 6897
6875 6898 \backslash
6876 6899 hspace*{0mm}
6877 6900 \end_inset
6878 6901
6879 6902 \SpecialChar ~
6880 6903 \SpecialChar ~
6881 6904 \SpecialChar ~
6882 6905 \SpecialChar ~
6883 6906 \SpecialChar ~
6884 6907 \SpecialChar ~
6885 6908 \SpecialChar ~
6886 6909 \SpecialChar ~
6887 6910 \SpecialChar ~
6888 6911 \SpecialChar ~
6889 6912 \SpecialChar ~
6890 6913 \SpecialChar ~
6891 6914 \SpecialChar ~
6892 6915 \SpecialChar ~
6893 6916 <5> ['scopes.py', 'strings.py']
6894 6917 \newline
6895 6918 fperez[~/test]|6> print _5
6896 6919 \newline
6897 6920 ['scopes.py', 'strings.py']
6898 6921 \layout Standard
6899 6922
6900 6923
6901 6924 \family typewriter
6902 6925 $
6903 6926 \family default
6904 6927 and
6905 6928 \family typewriter
6906 6929 $$
6907 6930 \family default
6908 6931 allow direct capture to named variables:
6909 6932 \layout Standard
6910 6933
6911 6934
6912 6935 \family typewriter
6913 6936 fperez[~/test]|7> $astr = ls *s.py
6914 6937 \newline
6915 6938 fperez[~/test]|8> astr
6916 6939 \newline
6917 6940
6918 6941 \begin_inset ERT
6919 6942 status Collapsed
6920 6943
6921 6944 \layout Standard
6922 6945
6923 6946 \backslash
6924 6947 hspace*{0mm}
6925 6948 \end_inset
6926 6949
6927 6950 \SpecialChar ~
6928 6951 \SpecialChar ~
6929 6952 \SpecialChar ~
6930 6953 \SpecialChar ~
6931 6954 \SpecialChar ~
6932 6955 \SpecialChar ~
6933 6956 \SpecialChar ~
6934 6957 \SpecialChar ~
6935 6958 \SpecialChar ~
6936 6959 \SpecialChar ~
6937 6960 \SpecialChar ~
6938 6961 \SpecialChar ~
6939 6962 \SpecialChar ~
6940 6963 \SpecialChar ~
6941 6964 <8> 'scopes.py
6942 6965 \backslash
6943 6966 nstrings.py'
6944 6967 \layout Standard
6945 6968
6946 6969
6947 6970 \family typewriter
6948 6971 fperez[~/test]|9> $$alist = ls *s.py
6949 6972 \newline
6950 6973 fperez[~/test]|10> alist
6951 6974 \newline
6952 6975
6953 6976 \begin_inset ERT
6954 6977 status Collapsed
6955 6978
6956 6979 \layout Standard
6957 6980
6958 6981 \backslash
6959 6982 hspace*{0mm}
6960 6983 \end_inset
6961 6984
6962 6985 \SpecialChar ~
6963 6986 \SpecialChar ~
6964 6987 \SpecialChar ~
6965 6988 \SpecialChar ~
6966 6989 \SpecialChar ~
6967 6990 \SpecialChar ~
6968 6991 \SpecialChar ~
6969 6992 \SpecialChar ~
6970 6993 \SpecialChar ~
6971 6994 \SpecialChar ~
6972 6995 \SpecialChar ~
6973 6996 \SpecialChar ~
6974 6997 \SpecialChar ~
6975 6998 \SpecialChar ~
6976 6999 <10> ['scopes.py', 'strings.py']
6977 7000 \layout Standard
6978 7001
6979 7002 alist is now a normal python list you can loop over.
6980 7003 Using
6981 7004 \family typewriter
6982 7005 $
6983 7006 \family default
6984 7007 will expand back the python values when alias calls are made:
6985 7008 \layout Standard
6986 7009
6987 7010
6988 7011 \family typewriter
6989 7012 fperez[~/test]|11> for f in alist:
6990 7013 \newline
6991 7014
6992 7015 \begin_inset ERT
6993 7016 status Collapsed
6994 7017
6995 7018 \layout Standard
6996 7019
6997 7020 \backslash
6998 7021 hspace*{0mm}
6999 7022 \end_inset
7000 7023
7001 7024 \SpecialChar ~
7002 7025 \SpecialChar ~
7003 7026 \SpecialChar ~
7004 7027 \SpecialChar ~
7005 7028 \SpecialChar ~
7006 7029 \SpecialChar ~
7007 7030 \SpecialChar ~
7008 7031 \SpecialChar ~
7009 7032 \SpecialChar ~
7010 7033 \SpecialChar ~
7011 7034 \SpecialChar ~
7012 7035 \SpecialChar ~
7013 7036 \SpecialChar ~
7014 7037 \SpecialChar ~
7015 7038 |..> \SpecialChar ~
7016 7039 \SpecialChar ~
7017 7040 \SpecialChar ~
7018 7041 \SpecialChar ~
7019 7042 print 'file',f,
7020 7043 \newline
7021 7044
7022 7045 \begin_inset ERT
7023 7046 status Collapsed
7024 7047
7025 7048 \layout Standard
7026 7049
7027 7050 \backslash
7028 7051 hspace*{0mm}
7029 7052 \end_inset
7030 7053
7031 7054 \SpecialChar ~
7032 7055 \SpecialChar ~
7033 7056 \SpecialChar ~
7034 7057 \SpecialChar ~
7035 7058 \SpecialChar ~
7036 7059 \SpecialChar ~
7037 7060 \SpecialChar ~
7038 7061 \SpecialChar ~
7039 7062 \SpecialChar ~
7040 7063 \SpecialChar ~
7041 7064 \SpecialChar ~
7042 7065 \SpecialChar ~
7043 7066 \SpecialChar ~
7044 7067 \SpecialChar ~
7045 7068 |..> \SpecialChar ~
7046 7069 \SpecialChar ~
7047 7070 \SpecialChar ~
7048 7071 \SpecialChar ~
7049 7072 wc -l $f
7050 7073 \newline
7051 7074
7052 7075 \begin_inset ERT
7053 7076 status Collapsed
7054 7077
7055 7078 \layout Standard
7056 7079
7057 7080 \backslash
7058 7081 hspace*{0mm}
7059 7082 \end_inset
7060 7083
7061 7084 \SpecialChar ~
7062 7085 \SpecialChar ~
7063 7086 \SpecialChar ~
7064 7087 \SpecialChar ~
7065 7088 \SpecialChar ~
7066 7089 \SpecialChar ~
7067 7090 \SpecialChar ~
7068 7091 \SpecialChar ~
7069 7092 \SpecialChar ~
7070 7093 \SpecialChar ~
7071 7094 \SpecialChar ~
7072 7095 \SpecialChar ~
7073 7096 \SpecialChar ~
7074 7097 \SpecialChar ~
7075 7098 |..>
7076 7099 \newline
7077 7100 file scopes.py 13 scopes.py
7078 7101 \newline
7079 7102 file strings.py 4 strings.py
7080 7103 \layout Standard
7081 7104
7082 7105 Note that you may need to protect your variables with braces if you want
7083 7106 to append strings to their names.
7084 7107 To copy all files in alist to
7085 7108 \family typewriter
7086 7109 .bak
7087 7110 \family default
7088 7111 extensions, you must use:
7089 7112 \layout Standard
7090 7113
7091 7114
7092 7115 \family typewriter
7093 7116 fperez[~/test]|12> for f in alist:
7094 7117 \newline
7095 7118
7096 7119 \begin_inset ERT
7097 7120 status Collapsed
7098 7121
7099 7122 \layout Standard
7100 7123
7101 7124 \backslash
7102 7125 hspace*{0mm}
7103 7126 \end_inset
7104 7127
7105 7128 \SpecialChar ~
7106 7129 \SpecialChar ~
7107 7130 \SpecialChar ~
7108 7131 \SpecialChar ~
7109 7132 \SpecialChar ~
7110 7133 \SpecialChar ~
7111 7134 \SpecialChar ~
7112 7135 \SpecialChar ~
7113 7136 \SpecialChar ~
7114 7137 \SpecialChar ~
7115 7138 \SpecialChar ~
7116 7139 \SpecialChar ~
7117 7140 \SpecialChar ~
7118 7141 \SpecialChar ~
7119 7142 |..> \SpecialChar ~
7120 7143 \SpecialChar ~
7121 7144 \SpecialChar ~
7122 7145 \SpecialChar ~
7123 7146 cp $f ${f}.bak
7124 7147 \layout Standard
7125 7148
7126 7149 If you try using
7127 7150 \family typewriter
7128 7151 $f.bak
7129 7152 \family default
7130 7153 , you'll get an AttributeError exception saying that your string object
7131 7154 doesn't have a
7132 7155 \family typewriter
7133 7156 .bak
7134 7157 \family default
7135 7158 attribute.
7136 7159 This is because the
7137 7160 \family typewriter
7138 7161 $
7139 7162 \family default
7140 7163 expansion mechanism allows you to expand full Python expressions:
7141 7164 \layout Standard
7142 7165
7143 7166
7144 7167 \family typewriter
7145 7168 fperez[~/test]|13> echo "sys.platform is: $sys.platform"
7146 7169 \newline
7147 7170 sys.platform is: linux2
7148 7171 \layout Standard
7149 7172
7150 7173 IPython's input history handling is still active, which allows you to rerun
7151 7174 a single block of multi-line input by simply using exec:
7152 7175 \newline
7153 7176
7154 7177 \family typewriter
7155 7178 fperez[~/test]|14> $$alist = ls *.eps
7156 7179 \newline
7157 7180 fperez[~/test]|15> exec _i11
7158 7181 \newline
7159 7182 file image2.eps 921 image2.eps
7160 7183 \newline
7161 7184 file image.eps 921 image.eps
7162 7185 \layout Standard
7163 7186
7164 7187 While these are new special-case syntaxes, they are designed to allow very
7165 7188 efficient use of the shell with minimal typing.
7166 7189 At an interactive shell prompt, conciseness of expression wins over readability.
7167 7190 \layout Subsection
7168 7191
7169 7192 Useful functions and modules
7170 7193 \layout Standard
7171 7194
7172 7195 The os, sys and shutil modules from the Python standard library are automaticall
7173 7196 y loaded.
7174 7197 Some additional functions, useful for shell usage, are listed below.
7175 7198 You can request more help about them with `
7176 7199 \family typewriter
7177 7200 ?
7178 7201 \family default
7179 7202 '.
7180 7203 \layout Description
7181 7204
7182 7205
7183 7206 \family typewriter
7184 7207 shell
7185 7208 \family default
7186 7209 - execute a command in the underlying system shell
7187 7210 \layout Description
7188 7211
7189 7212
7190 7213 \family typewriter
7191 7214 system
7192 7215 \family default
7193 7216 - like
7194 7217 \family typewriter
7195 7218 shell()
7196 7219 \family default
7197 7220 , but return the exit status of the command
7198 7221 \layout Description
7199 7222
7200 7223
7201 7224 \family typewriter
7202 7225 sout
7203 7226 \family default
7204 7227 - capture the output of a command as a string
7205 7228 \layout Description
7206 7229
7207 7230
7208 7231 \family typewriter
7209 7232 lout
7210 7233 \family default
7211 7234 - capture the output of a command as a list (split on `
7212 7235 \backslash
7213 7236 n')
7214 7237 \layout Description
7215 7238
7216 7239
7217 7240 \family typewriter
7218 7241 getoutputerror
7219 7242 \family default
7220 7243 - capture (output,error) of a shell commandss
7221 7244 \layout Standard
7222 7245
7223 7246
7224 7247 \family typewriter
7225 7248 sout
7226 7249 \family default
7227 7250 /
7228 7251 \family typewriter
7229 7252 lout
7230 7253 \family default
7231 7254 are the functional equivalents of
7232 7255 \family typewriter
7233 7256 $
7234 7257 \family default
7235 7258 /
7236 7259 \family typewriter
7237 7260 $$
7238 7261 \family default
7239 7262 .
7240 7263 They are provided to allow you to capture system output in the middle of
7241 7264 true python code, function definitions, etc (where
7242 7265 \family typewriter
7243 7266 $
7244 7267 \family default
7245 7268 and
7246 7269 \family typewriter
7247 7270 $$
7248 7271 \family default
7249 7272 are invalid).
7250 7273 \layout Subsection
7251 7274
7252 7275 Directory management
7253 7276 \layout Standard
7254 7277
7255 7278 Since each command passed by pysh to the underlying system is executed in
7256 7279 a subshell which exits immediately, you can NOT use !cd to navigate the
7257 7280 filesystem.
7258 7281 \layout Standard
7259 7282
7260 7283 Pysh provides its own builtin
7261 7284 \family typewriter
7262 7285 `%cd
7263 7286 \family default
7264 7287 ' magic command to move in the filesystem (the
7265 7288 \family typewriter
7266 7289 %
7267 7290 \family default
7268 7291 is not required with automagic on).
7269 7292 It also maintains a list of visited directories (use
7270 7293 \family typewriter
7271 7294 %dhist
7272 7295 \family default
7273 7296 to see it) and allows direct switching to any of them.
7274 7297 Type
7275 7298 \family typewriter
7276 7299 `cd?
7277 7300 \family default
7278 7301 ' for more details.
7279 7302 \layout Standard
7280 7303
7281 7304
7282 7305 \family typewriter
7283 7306 %pushd
7284 7307 \family default
7285 7308 ,
7286 7309 \family typewriter
7287 7310 %popd
7288 7311 \family default
7289 7312 and
7290 7313 \family typewriter
7291 7314 %dirs
7292 7315 \family default
7293 7316 are provided for directory stack handling.
7294 7317 \layout Subsection
7295 7318
7296 7319 Prompt customization
7297 7320 \layout Standard
7298 7321
7299 7322 The supplied
7300 7323 \family typewriter
7301 7324 ipythonrc-pysh
7302 7325 \family default
7303 7326 profile comes with an example of a very colored and detailed prompt, mainly
7304 7327 to serve as an illustration.
7305 7328 The valid escape sequences, besides color names, are:
7306 7329 \layout Description
7307 7330
7308 7331
7309 7332 \backslash
7310 7333 # - Prompt number.
7311 7334 \layout Description
7312 7335
7313 7336
7314 7337 \backslash
7315 7338 D - Dots, as many as there are digits in
7316 7339 \backslash
7317 7340 # (so they align).
7318 7341 \layout Description
7319 7342
7320 7343
7321 7344 \backslash
7322 7345 w - Current working directory (cwd).
7323 7346 \layout Description
7324 7347
7325 7348
7326 7349 \backslash
7327 7350 W - Basename of current working directory.
7328 7351 \layout Description
7329 7352
7330 7353
7331 7354 \backslash
7332 7355 X
7333 7356 \emph on
7334 7357 N
7335 7358 \emph default
7336 7359 - Where
7337 7360 \emph on
7338 7361 N
7339 7362 \emph default
7340 7363 =0..5.
7341 7364 N terms of the cwd, with $HOME written as ~.
7342 7365 \layout Description
7343 7366
7344 7367
7345 7368 \backslash
7346 7369 Y
7347 7370 \emph on
7348 7371 N
7349 7372 \emph default
7350 7373 - Where
7351 7374 \emph on
7352 7375 N
7353 7376 \emph default
7354 7377 =0..5.
7355 7378 Like X
7356 7379 \emph on
7357 7380 N
7358 7381 \emph default
7359 7382 , but if ~ is term
7360 7383 \emph on
7361 7384 N
7362 7385 \emph default
7363 7386 +1 it's also shown.
7364 7387 \layout Description
7365 7388
7366 7389
7367 7390 \backslash
7368 7391 u - Username.
7369 7392 \layout Description
7370 7393
7371 7394
7372 7395 \backslash
7373 7396 H - Full hostname.
7374 7397 \layout Description
7375 7398
7376 7399
7377 7400 \backslash
7378 7401 h - Hostname up to first '.'
7379 7402 \layout Description
7380 7403
7381 7404
7382 7405 \backslash
7383 7406 $ - Root symbol ($ or #).
7384 7407
7385 7408 \layout Description
7386 7409
7387 7410
7388 7411 \backslash
7389 7412 t - Current time, in H:M:S format.
7390 7413 \layout Description
7391 7414
7392 7415
7393 7416 \backslash
7394 7417 v - IPython release version.
7395 7418
7396 7419 \layout Description
7397 7420
7398 7421
7399 7422 \backslash
7400 7423 n - Newline.
7401 7424
7402 7425 \layout Description
7403 7426
7404 7427
7405 7428 \backslash
7406 7429 r - Carriage return.
7407 7430
7408 7431 \layout Description
7409 7432
7410 7433
7411 7434 \backslash
7412 7435
7413 7436 \backslash
7414 7437 - An explicitly escaped '
7415 7438 \backslash
7416 7439 '.
7417 7440 \layout Standard
7418 7441
7419 7442 You can configure your prompt colors using any ANSI color escape.
7420 7443 Each color escape sets the color for any subsequent text, until another
7421 7444 escape comes in and changes things.
7422 7445 The valid color escapes are:
7423 7446 \layout Description
7424 7447
7425 7448
7426 7449 \backslash
7427 7450 C_Black
7428 7451 \layout Description
7429 7452
7430 7453
7431 7454 \backslash
7432 7455 C_Blue
7433 7456 \layout Description
7434 7457
7435 7458
7436 7459 \backslash
7437 7460 C_Brown
7438 7461 \layout Description
7439 7462
7440 7463
7441 7464 \backslash
7442 7465 C_Cyan
7443 7466 \layout Description
7444 7467
7445 7468
7446 7469 \backslash
7447 7470 C_DarkGray
7448 7471 \layout Description
7449 7472
7450 7473
7451 7474 \backslash
7452 7475 C_Green
7453 7476 \layout Description
7454 7477
7455 7478
7456 7479 \backslash
7457 7480 C_LightBlue
7458 7481 \layout Description
7459 7482
7460 7483
7461 7484 \backslash
7462 7485 C_LightCyan
7463 7486 \layout Description
7464 7487
7465 7488
7466 7489 \backslash
7467 7490 C_LightGray
7468 7491 \layout Description
7469 7492
7470 7493
7471 7494 \backslash
7472 7495 C_LightGreen
7473 7496 \layout Description
7474 7497
7475 7498
7476 7499 \backslash
7477 7500 C_LightPurple
7478 7501 \layout Description
7479 7502
7480 7503
7481 7504 \backslash
7482 7505 C_LightRed
7483 7506 \layout Description
7484 7507
7485 7508
7486 7509 \backslash
7487 7510 C_Purple
7488 7511 \layout Description
7489 7512
7490 7513
7491 7514 \backslash
7492 7515 C_Red
7493 7516 \layout Description
7494 7517
7495 7518
7496 7519 \backslash
7497 7520 C_White
7498 7521 \layout Description
7499 7522
7500 7523
7501 7524 \backslash
7502 7525 C_Yellow
7503 7526 \layout Description
7504 7527
7505 7528
7506 7529 \backslash
7507 7530 C_Normal Stop coloring, defaults to your terminal settings.
7508 7531 \layout Section
7509 7532
7510 7533
7511 7534 \begin_inset LatexCommand \label{sec:Threading-support}
7512 7535
7513 7536 \end_inset
7514 7537
7515 7538 Threading support
7516 7539 \layout Standard
7517 7540
7518 7541
7519 7542 \series bold
7520 7543 WARNING:
7521 7544 \series default
7522 7545 The threading support is still somewhat experimental, and it has only seen
7523 7546 reasonable testing under Linux.
7524 7547 Threaded code is particularly tricky to debug, and it tends to show extremely
7525 7548 platform-dependent behavior.
7526 7549 Since I only have access to Linux machines, I will have to rely on user's
7527 7550 experiences and assistance for this area of IPython to improve under other
7528 7551 platforms.
7529 7552 \layout Standard
7530 7553
7531 7554 IPython, via the
7532 7555 \family typewriter
7533 7556 -gthread
7534 7557 \family default
7558 ,
7559 \family typewriter
7560 -qthread
7561 \family default
7535 7562 and
7536 7563 \family typewriter
7537 7564 -wthread
7538 7565 \family default
7539 7566 options (described in Sec.\SpecialChar ~
7540 7567
7541 7568 \begin_inset LatexCommand \ref{sec:threading-opts}
7542 7569
7543 7570 \end_inset
7544 7571
7545 ), can run in multithreaded mode to support pyGTK and WXPython applications
7572 ), can run in multithreaded mode to support pyGTK, Qt and WXPython applications
7546 7573 respectively.
7547 Both of these GUI toolkits need to control the python main loop of execution,
7548 so under a normal Python interpreter, starting a pyGTK (or WXPython) applicatio
7549 n will immediately freeze the shell.
7574 These GUI toolkits need to control the python main loop of execution, so
7575 under a normal Python interpreter, starting a pyGTK, Qt or WXPython application
7576 will immediately freeze the shell.
7550 7577
7551 7578 \layout Standard
7552 7579
7553 7580 IPython, with one of these options (you can only use one at a time), separates
7554 7581 the graphical loop and IPython's code execution run into different threads.
7555 7582 This allows you to test interactively (with
7556 7583 \family typewriter
7557 7584 %run
7558 7585 \family default
7559 7586 , for example) your GUI code without blocking.
7587 \layout Standard
7588
7589 A nice mini-tutorial on using IPython along with the Qt Designer application
7590 is available at the SciPy wiki:
7591 \begin_inset LatexCommand \htmlurl{http://www.scipy.org/wikis/topical_software/QtWithIPythonAndDesigner}
7592
7593 \end_inset
7594
7595 .
7560 7596 \layout Subsection
7561 7597
7562 7598 Tk issues
7563 7599 \layout Standard
7564 7600
7565 7601 As indicated in Sec.\SpecialChar ~
7566 7602
7567 7603 \begin_inset LatexCommand \ref{sec:threading-opts}
7568 7604
7569 7605 \end_inset
7570 7606
7571 7607 , a special
7572 7608 \family typewriter
7573 7609 -tk
7574 7610 \family default
7575 7611 option is provided to try and allow Tk graphical applications to coexist
7576 interactively with WX or GTK ones.
7612 interactively with WX, Qt or GTK ones.
7577 7613 Whether this works at all, however, is very platform and configuration
7578 7614 dependent.
7579 7615 Please experiment with simple test cases before committing to using this
7580 combination of Tk and WX/GTK threading in a production environment.
7616 combination of Tk and GTK/Qt/WX threading in a production environment.
7581 7617 \layout Subsection
7582 7618
7583 7619 Signals and Threads
7584 7620 \layout Standard
7585 7621
7586 When any of the thread systems (WX or GTK) are active, either directly or
7587 via
7622 When any of the thread systems (GTK, Qt or WX) are active, either directly
7623 or via
7588 7624 \family typewriter
7589 7625 -pylab
7590 7626 \family default
7591 7627 with a threaded backend, it is impossible to interrupt long-running Python
7592 7628 code via
7593 7629 \family typewriter
7594 7630 Ctrl-C
7595 7631 \family default
7596 7632 .
7597 7633 IPython can not pass the KeyboardInterrupt exception (or the underlying
7598 7634
7599 7635 \family typewriter
7600 7636 SIGINT
7601 7637 \family default
7602 7638 ) across threads, so any long-running process started from IPython will
7603 7639 run to completion, or will have to be killed via an external (OS-based)
7604 7640 mechanism.
7605 7641 \layout Standard
7606 7642
7607 7643 To the best of my knowledge, this limitation is imposed by the Python interprete
7608 7644 r itself, and it comes from the difficulty of writing portable signal/threaded
7609 7645 code.
7610 7646 If any user is an expert on this topic and can suggest a better solution,
7611 7647 I would love to hear about it.
7612 7648 In the IPython sources, look at the
7613 7649 \family typewriter
7614 7650 Shell.py
7615 7651 \family default
7616 7652 module, and in particular at the
7617 7653 \family typewriter
7618 7654 runcode()
7619 7655 \family default
7620 7656 method.
7621 7657
7622 7658 \layout Subsection
7623 7659
7624 7660 I/O pitfalls
7625 7661 \layout Standard
7626 7662
7627 7663 Be mindful that the Python interpreter switches between threads every
7628 7664 \begin_inset Formula $N$
7629 7665 \end_inset
7630 7666
7631 7667 bytecodes, where the default value as of Python\SpecialChar ~
7632 7668 2.3 is
7633 7669 \begin_inset Formula $N=100.$
7634 7670 \end_inset
7635 7671
7636 7672 This value can be read by using the
7637 7673 \family typewriter
7638 7674 sys.getcheckinterval()
7639 7675 \family default
7640 7676 function, and it can be reset via
7641 7677 \family typewriter
7642 7678 sys.setcheckinterval(
7643 7679 \emph on
7644 7680 N
7645 7681 \emph default
7646 7682 )
7647 7683 \family default
7648 7684 .
7649 7685 This switching of threads can cause subtly confusing effects if one of
7650 7686 your threads is doing file I/O.
7651 7687 In text mode, most systems only flush file buffers when they encounter
7652 7688 a
7653 7689 \family typewriter
7654 7690 `
7655 7691 \backslash
7656 7692 n'
7657 7693 \family default
7658 7694 .
7659 7695 An instruction as simple as
7660 7696 \family typewriter
7661 7697
7662 7698 \newline
7663 7699 \SpecialChar ~
7664 7700 \SpecialChar ~
7665 7701 print >> filehandle,
7666 7702 \begin_inset Quotes eld
7667 7703 \end_inset
7668 7704
7669 7705 hello world
7670 7706 \begin_inset Quotes erd
7671 7707 \end_inset
7672 7708
7673 7709
7674 7710 \family default
7675 7711
7676 7712 \newline
7677 7713 actually consists of several bytecodes, so it is possible that the newline
7678 7714 does not reach your file before the next thread switch.
7679 7715 Similarly, if you are writing to a file in binary mode, the file won't
7680 7716 be flushed until the buffer fills, and your other thread may see apparently
7681 7717 truncated files.
7682 7718
7683 7719 \layout Standard
7684 7720
7685 7721 For this reason, if you are using IPython's thread support and have (for
7686 7722 example) a GUI application which will read data generated by files written
7687 7723 to from the IPython thread, the safest approach is to open all of your
7688 7724 files in unbuffered mode (the third argument to the
7689 7725 \family typewriter
7690 7726 file/open
7691 7727 \family default
7692 7728 function is the buffering value):
7693 7729 \newline
7694 7730
7695 7731 \family typewriter
7696 7732 \SpecialChar ~
7697 7733 \SpecialChar ~
7698 7734 filehandle = open(filename,mode,0)
7699 7735 \layout Standard
7700 7736
7701 7737 This is obviously a brute force way of avoiding race conditions with the
7702 7738 file buffering.
7703 7739 If you want to do it cleanly, and you have a resource which is being shared
7704 7740 by the interactive IPython loop and your GUI thread, you should really
7705 7741 handle it with thread locking and syncrhonization properties.
7706 7742 The Python documentation discusses these.
7707 7743 \layout Section
7708 7744
7709 7745
7710 7746 \begin_inset LatexCommand \label{sec:interactive-demos}
7711 7747
7712 7748 \end_inset
7713 7749
7714 7750 Interactive demos with IPython
7715 7751 \layout Standard
7716 7752
7717 IPython ships with
7753 IPython ships with XXX
7718 7754 \layout Standard
7719 7755
7720 7756
7721 7757 \begin_inset ERT
7722 7758 status Open
7723 7759
7724 7760 \layout Standard
7725 7761
7726 7762 \backslash
7727 lstinputlisting{examples/example-demo.py}
7763 codelist{examples/example-demo.py}
7728 7764 \end_inset
7729 7765
7730 7766
7731 7767 \layout Section
7732 7768
7733 7769
7734 7770 \begin_inset LatexCommand \label{sec:matplotlib-support}
7735 7771
7736 7772 \end_inset
7737 7773
7738 7774 Plotting with
7739 7775 \family typewriter
7740 7776 matplotlib
7741 7777 \family default
7742 7778
7743 7779 \layout Standard
7744 7780
7745 7781 The matplotlib library (
7746 7782 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
7747 7783
7748 7784 \end_inset
7749 7785
7750 7786 ) provides high quality 2D plotting for Python.
7751 7787 Matplotlib can produce plots on screen using a variety of GUI toolkits,
7752 7788 including Tk, GTK and WXPython.
7753 7789 It also provides a number of commands useful for scientific computing,
7754 7790 all with a syntax compatible with that of the popular Matlab program.
7755 7791 \layout Standard
7756 7792
7757 7793 IPython accepts the special option
7758 7794 \family typewriter
7759 7795 -pylab
7760 7796 \family default
7761 7797 (Sec.\SpecialChar ~
7762 7798
7763 7799 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
7764 7800
7765 7801 \end_inset
7766 7802
7767 7803 ).
7768 7804 This configures it to support matplotlib, honoring the settings in the
7769 7805
7770 7806 \family typewriter
7771 7807 .matplotlibrc
7772 7808 \family default
7773 7809 file.
7774 7810 IPython will detect the user's choice of matplotlib GUI backend, and automatica
7775 7811 lly select the proper threading model to prevent blocking.
7776 7812 It also sets matplotlib in interactive mode and modifies
7777 7813 \family typewriter
7778 7814 %run
7779 7815 \family default
7780 7816 slightly, so that any matplotlib-based script can be executed using
7781 7817 \family typewriter
7782 7818 %run
7783 7819 \family default
7784 7820 and the final
7785 7821 \family typewriter
7786 7822 show()
7787 7823 \family default
7788 7824 command does not block the interactive shell.
7789 7825 \layout Standard
7790 7826
7791 7827 The
7792 7828 \family typewriter
7793 7829 -pylab
7794 7830 \family default
7795 7831 option must be given first in order for IPython to configure its threading
7796 7832 mode.
7797 7833 However, you can still issue other options afterwards.
7798 7834 This allows you to have a matplotlib-based environment customized with
7799 7835 additional modules using the standard IPython profile mechanism (Sec.\SpecialChar ~
7800 7836
7801 7837 \begin_inset LatexCommand \ref{sec:profiles}
7802 7838
7803 7839 \end_inset
7804 7840
7805 7841 ): ``
7806 7842 \family typewriter
7807 7843 ipython -pylab -p myprofile
7808 7844 \family default
7809 7845 '' will load the profile defined in
7810 7846 \family typewriter
7811 7847 ipythonrc-myprofile
7812 7848 \family default
7813 7849 after configuring matplotlib.
7814 7850 \layout Section
7815 7851
7816 7852
7817 7853 \begin_inset LatexCommand \label{sec:Gnuplot}
7818 7854
7819 7855 \end_inset
7820 7856
7821 7857 Plotting with
7822 7858 \family typewriter
7823 7859 Gnuplot
7824 7860 \layout Standard
7825 7861
7826 7862 Through the magic extension system described in sec.
7827 7863
7828 7864 \begin_inset LatexCommand \ref{sec:magic}
7829 7865
7830 7866 \end_inset
7831 7867
7832 7868 , IPython incorporates a mechanism for conveniently interfacing with the
7833 7869 Gnuplot system (
7834 7870 \begin_inset LatexCommand \htmlurl{http://www.gnuplot.info}
7835 7871
7836 7872 \end_inset
7837 7873
7838 7874 ).
7839 7875 Gnuplot is a very complete 2D and 3D plotting package available for many
7840 7876 operating systems and commonly included in modern Linux distributions.
7841 7877
7842 7878 \layout Standard
7843 7879
7844 7880 Besides having Gnuplot installed, this functionality requires the
7845 7881 \family typewriter
7846 7882 Gnuplot.py
7847 7883 \family default
7848 7884 module for interfacing python with Gnuplot.
7849 7885 It can be downloaded from:
7850 7886 \begin_inset LatexCommand \htmlurl{http://gnuplot-py.sourceforge.net}
7851 7887
7852 7888 \end_inset
7853 7889
7854 7890 .
7855 7891 \layout Subsection
7856 7892
7857 7893 Proper Gnuplot configuration
7858 7894 \layout Standard
7859 7895
7860 7896 As of version 4.0, Gnuplot has excellent mouse and interactive keyboard support.
7861 7897 However, as of
7862 7898 \family typewriter
7863 7899 Gnuplot.py
7864 7900 \family default
7865 7901 version 1.7, a new option was added to communicate between Python and Gnuplot
7866 7902 via FIFOs (pipes).
7867 7903 This mechanism, while fast, also breaks the mouse system.
7868 7904 You must therefore set the variable
7869 7905 \family typewriter
7870 7906 prefer_fifo_data
7871 7907 \family default
7872 7908 to
7873 7909 \family typewriter
7874 7910 0
7875 7911 \family default
7876 7912 in file
7877 7913 \family typewriter
7878 7914 gp_unix.py
7879 7915 \family default
7880 7916 if you wish to keep the interactive mouse and keyboard features working
7881 7917 properly (
7882 7918 \family typewriter
7883 7919 prefer_inline_data
7884 7920 \family default
7885 7921 also must be
7886 7922 \family typewriter
7887 7923 0
7888 7924 \family default
7889 7925 , but this is the default so unless you've changed it manually you should
7890 7926 be fine).
7891 7927 \layout Standard
7892 7928
7893 7929 'Out of the box', Gnuplot is configured with a rather poor set of size,
7894 7930 color and linewidth choices which make the graphs fairly hard to read on
7895 7931 modern high-resolution displays (although they work fine on old 640x480
7896 7932 ones).
7897 7933 Below is a section of my
7898 7934 \family typewriter
7899 7935 .Xdefaults
7900 7936 \family default
7901 7937 file which I use for having a more convenient Gnuplot setup.
7902 7938 Remember to load it by running
7903 7939 \family typewriter
7904 7940 `xrdb .Xdefaults`
7905 7941 \family default
7906 7942 :
7907 7943 \layout Standard
7908 7944
7909 7945
7910 7946 \family typewriter
7911 7947 !******************************************************************
7912 7948 \newline
7913 7949 ! gnuplot options
7914 7950 \newline
7915 7951 ! modify this for a convenient window size
7916 7952 \newline
7917 7953 gnuplot*geometry: 780x580
7918 7954 \layout Standard
7919 7955
7920 7956
7921 7957 \family typewriter
7922 7958 ! on-screen font (not for PostScript)
7923 7959 \newline
7924 7960 gnuplot*font: -misc-fixed-bold-r-normal--15-120-100-100-c-90-iso8859-1
7925 7961 \layout Standard
7926 7962
7927 7963
7928 7964 \family typewriter
7929 7965 ! color options
7930 7966 \newline
7931 7967 gnuplot*background: black
7932 7968 \newline
7933 7969 gnuplot*textColor: white
7934 7970 \newline
7935 7971 gnuplot*borderColor: white
7936 7972 \newline
7937 7973 gnuplot*axisColor: white
7938 7974 \newline
7939 7975 gnuplot*line1Color: red
7940 7976 \newline
7941 7977 gnuplot*line2Color: green
7942 7978 \newline
7943 7979 gnuplot*line3Color: blue
7944 7980 \newline
7945 7981 gnuplot*line4Color: magenta
7946 7982 \newline
7947 7983 gnuplot*line5Color: cyan
7948 7984 \newline
7949 7985 gnuplot*line6Color: sienna
7950 7986 \newline
7951 7987 gnuplot*line7Color: orange
7952 7988 \newline
7953 7989 gnuplot*line8Color: coral
7954 7990 \layout Standard
7955 7991
7956 7992
7957 7993 \family typewriter
7958 7994 ! multiplicative factor for point styles
7959 7995 \newline
7960 7996 gnuplot*pointsize: 2
7961 7997 \layout Standard
7962 7998
7963 7999
7964 8000 \family typewriter
7965 8001 ! line width options (in pixels)
7966 8002 \newline
7967 8003 gnuplot*borderWidth: 2
7968 8004 \newline
7969 8005 gnuplot*axisWidth: 2
7970 8006 \newline
7971 8007 gnuplot*line1Width: 2
7972 8008 \newline
7973 8009 gnuplot*line2Width: 2
7974 8010 \newline
7975 8011 gnuplot*line3Width: 2
7976 8012 \newline
7977 8013 gnuplot*line4Width: 2
7978 8014 \newline
7979 8015 gnuplot*line5Width: 2
7980 8016 \newline
7981 8017 gnuplot*line6Width: 2
7982 8018 \newline
7983 8019 gnuplot*line7Width: 2
7984 8020 \newline
7985 8021 gnuplot*line8Width: 2
7986 8022 \layout Subsection
7987 8023
7988 8024 The
7989 8025 \family typewriter
7990 8026 IPython.GnuplotRuntime
7991 8027 \family default
7992 8028 module
7993 8029 \layout Standard
7994 8030
7995 8031 IPython includes a module called
7996 8032 \family typewriter
7997 8033 Gnuplot2.py
7998 8034 \family default
7999 8035 which extends and improves the default
8000 8036 \family typewriter
8001 8037 Gnuplot
8002 8038 \family default
8003 8039 .
8004 8040 \family typewriter
8005 8041 py
8006 8042 \family default
8007 8043 (which it still relies upon).
8008 8044 For example, the new
8009 8045 \family typewriter
8010 8046 plot
8011 8047 \family default
8012 8048 function adds several improvements to the original making it more convenient
8013 8049 for interactive use, and
8014 8050 \family typewriter
8015 8051 hardcopy
8016 8052 \family default
8017 8053 fixes a bug in the original which under some circumstances blocks the creation
8018 8054 of PostScript output.
8019 8055 \layout Standard
8020 8056
8021 8057 For scripting use,
8022 8058 \family typewriter
8023 8059 GnuplotRuntime.py
8024 8060 \family default
8025 8061 is provided, which wraps
8026 8062 \family typewriter
8027 8063 Gnuplot2.py
8028 8064 \family default
8029 8065 and creates a series of global aliases.
8030 8066 These make it easy to control Gnuplot plotting jobs through the Python
8031 8067 language.
8032 8068 \layout Standard
8033 8069
8034 8070 Below is some example code which illustrates how to configure Gnuplot inside
8035 8071 your own programs but have it available for further interactive use through
8036 8072 an embedded IPython instance.
8037 8073 Simply run this file at a system prompt.
8038 8074 This file is provided as
8039 8075 \family typewriter
8040 8076 example-gnuplot.py
8041 8077 \family default
8042 8078 in the examples directory:
8043 8079 \layout Standard
8044 8080
8045 8081
8046 8082 \begin_inset ERT
8047 8083 status Open
8048 8084
8049 8085 \layout Standard
8050 8086
8051 8087 \backslash
8052 lstinputlisting{examples/example-gnuplot.py}
8088 codelist{examples/example-gnuplot.py}
8053 8089 \end_inset
8054 8090
8055 8091
8056 8092 \layout Subsection
8057 8093
8058 8094 The
8059 8095 \family typewriter
8060 8096 numeric
8061 8097 \family default
8062 8098 profile: a scientific computing environment
8063 8099 \layout Standard
8064 8100
8065 8101 The
8066 8102 \family typewriter
8067 8103 numeric
8068 8104 \family default
8069 8105 IPython profile, which you can activate with
8070 8106 \family typewriter
8071 8107 `ipython -p numeric
8072 8108 \family default
8073 8109 ' will automatically load the IPython Gnuplot extensions (plus Numeric and
8074 8110 other useful things for numerical computing), contained in the
8075 8111 \family typewriter
8076 8112 IPython.GnuplotInteractive
8077 8113 \family default
8078 8114 module.
8079 8115 This will create the globals
8080 8116 \family typewriter
8081 8117 Gnuplot
8082 8118 \family default
8083 8119 (an alias to the improved Gnuplot2 module),
8084 8120 \family typewriter
8085 8121 gp
8086 8122 \family default
8087 8123 (a Gnuplot active instance), the new magic commands
8088 8124 \family typewriter
8089 8125 %gpc
8090 8126 \family default
8091 8127 and
8092 8128 \family typewriter
8093 8129 %gp_set_instance
8094 8130 \family default
8095 8131 and several other convenient globals.
8096 8132 Type
8097 8133 \family typewriter
8098 8134 gphelp()
8099 8135 \family default
8100 8136 for further details.
8101 8137 \layout Standard
8102 8138
8103 8139 This should turn IPython into a convenient environment for numerical computing,
8104 8140 with all the functions in the NumPy library and the Gnuplot facilities
8105 8141 for plotting.
8106 8142 Further improvements can be obtained by loading the SciPy libraries for
8107 8143 scientific computing, available at
8108 8144 \begin_inset LatexCommand \htmlurl{http://scipy.org}
8109 8145
8110 8146 \end_inset
8111 8147
8112 8148 .
8113 8149 \layout Standard
8114 8150
8115 8151 If you are in the middle of a working session with numerical objects and
8116 8152 need to plot them but you didn't start the
8117 8153 \family typewriter
8118 8154 numeric
8119 8155 \family default
8120 8156 profile, you can load these extensions at any time by typing
8121 8157 \newline
8122 8158
8123 8159 \family typewriter
8124 8160 from IPython.GnuplotInteractive import *
8125 8161 \newline
8126 8162
8127 8163 \family default
8128 8164 at the IPython prompt.
8129 8165 This will allow you to keep your objects intact and start using Gnuplot
8130 8166 to view them.
8131 8167 \layout Section
8132 8168
8133 8169 Reporting bugs
8134 8170 \layout Subsection*
8135 8171
8136 8172 Automatic crash reports
8137 8173 \layout Standard
8138 8174
8139 8175 Ideally, IPython itself shouldn't crash.
8140 8176 It will catch exceptions produced by you, but bugs in its internals will
8141 8177 still crash it.
8142 8178 \layout Standard
8143 8179
8144 8180 In such a situation, IPython will leave a file named
8145 8181 \family typewriter
8146 8182 IPython_crash_report.txt
8147 8183 \family default
8148 8184 in your IPYTHONDIR directory (that way if crashes happen several times
8149 8185 it won't litter many directories, the post-mortem file is always located
8150 8186 in the same place and new occurrences just overwrite the previous one).
8151 8187 If you can mail this file to the developers (see sec.
8152 8188
8153 8189 \begin_inset LatexCommand \ref{sec:credits}
8154 8190
8155 8191 \end_inset
8156 8192
8157 8193 for names and addresses), it will help us
8158 8194 \emph on
8159 8195 a lot
8160 8196 \emph default
8161 8197 in understanding the cause of the problem and fixing it sooner.
8162 8198 \layout Subsection*
8163 8199
8164 8200 The bug tracker
8165 8201 \layout Standard
8166 8202
8167 8203 IPython also has an online bug-tracker, located at
8168 8204 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython}
8169 8205
8170 8206 \end_inset
8171 8207
8172 8208 .
8173 8209 In addition to mailing the developers, it would be a good idea to file
8174 8210 a bug report here.
8175 8211 This will ensure that the issue is properly followed to conclusion.
8176 8212 \layout Standard
8177 8213
8178 8214 You can also use this bug tracker to file feature requests.
8179 8215 \layout Section
8180 8216
8181 8217 Brief history
8182 8218 \layout Subsection
8183 8219
8184 8220 Origins
8185 8221 \layout Standard
8186 8222
8187 8223 The current IPython system grew out of the following three projects:
8188 8224 \layout List
8189 8225 \labelwidthstring 00.00.0000
8190 8226
8191 ipython by Fernando PοΏ½rez.
8227 ipython by Fernando PΓ©rez.
8192 8228 I was working on adding Mathematica-type prompts and a flexible configuration
8193 8229 system (something better than
8194 8230 \family typewriter
8195 8231 $PYTHONSTARTUP
8196 8232 \family default
8197 8233 ) to the standard Python interactive interpreter.
8198 8234 \layout List
8199 8235 \labelwidthstring 00.00.0000
8200 8236
8201 8237 IPP by Janko Hauser.
8202 8238 Very well organized, great usability.
8203 8239 Had an old help system.
8204 8240 IPP was used as the `container' code into which I added the functionality
8205 8241 from ipython and LazyPython.
8206 8242 \layout List
8207 8243 \labelwidthstring 00.00.0000
8208 8244
8209 8245 LazyPython by Nathan Gray.
8210 8246 Simple but
8211 8247 \emph on
8212 8248 very
8213 8249 \emph default
8214 8250 powerful.
8215 8251 The quick syntax (auto parens, auto quotes) and verbose/colored tracebacks
8216 8252 were all taken from here.
8217 8253 \layout Standard
8218 8254
8219 8255 When I found out (see sec.
8220 8256
8221 8257 \begin_inset LatexCommand \ref{figgins}
8222 8258
8223 8259 \end_inset
8224 8260
8225 8261 ) about IPP and LazyPython I tried to join all three into a unified system.
8226 8262 I thought this could provide a very nice working environment, both for
8227 8263 regular programming and scientific computing: shell-like features, IDL/Matlab
8228 8264 numerics, Mathematica-type prompt history and great object introspection
8229 8265 and help facilities.
8230 8266 I think it worked reasonably well, though it was a lot more work than I
8231 8267 had initially planned.
8232 8268 \layout Subsection
8233 8269
8234 8270 Current status
8235 8271 \layout Standard
8236 8272
8237 8273 The above listed features work, and quite well for the most part.
8238 8274 But until a major internal restructuring is done (see below), only bug
8239 8275 fixing will be done, no other features will be added (unless very minor
8240 8276 and well localized in the cleaner parts of the code).
8241 8277 \layout Standard
8242 8278
8243 8279 IPython consists of some 12000 lines of pure python code, of which roughly
8244 8280 50% are fairly clean.
8245 8281 The other 50% are fragile, messy code which needs a massive restructuring
8246 8282 before any further major work is done.
8247 8283 Even the messy code is fairly well documented though, and most of the problems
8248 8284 in the (non-existent) class design are well pointed to by a PyChecker run.
8249 8285 So the rewriting work isn't that bad, it will just be time-consuming.
8250 8286 \layout Subsection
8251 8287
8252 8288 Future
8253 8289 \layout Standard
8254 8290
8255 8291 See the separate
8256 8292 \family typewriter
8257 8293 new_design
8258 8294 \family default
8259 8295 document for details.
8260 8296 Ultimately, I would like to see IPython become part of the standard Python
8261 8297 distribution as a `big brother with batteries' to the standard Python interacti
8262 8298 ve interpreter.
8263 8299 But that will never happen with the current state of the code, so all contribut
8264 8300 ions are welcome.
8265 8301 \layout Section
8266 8302
8267 8303 License
8268 8304 \layout Standard
8269 8305
8270 8306 IPython is released under the terms of the BSD license, whose general form
8271 8307 can be found at:
8272 8308 \begin_inset LatexCommand \htmlurl{http://www.opensource.org/licenses/bsd-license.php}
8273 8309
8274 8310 \end_inset
8275 8311
8276 8312 .
8277 8313 The full text of the IPython license is reproduced below:
8278 8314 \layout Quote
8279 8315
8280 8316
8281 8317 \family typewriter
8282 8318 \size small
8283 8319 IPython is released under a BSD-type license.
8284 8320 \layout Quote
8285 8321
8286 8322
8287 8323 \family typewriter
8288 8324 \size small
8289 8325 Copyright (c) 2001, 2002, 2003, 2004 Fernando Perez <fperez@colorado.edu>.
8290 8326 \layout Quote
8291 8327
8292 8328
8293 8329 \family typewriter
8294 8330 \size small
8295 8331 Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and
8296 8332 \newline
8297 8333 Nathaniel Gray <n8gray@caltech.edu>.
8298 8334 \layout Quote
8299 8335
8300 8336
8301 8337 \family typewriter
8302 8338 \size small
8303 8339 All rights reserved.
8304 8340 \layout Quote
8305 8341
8306 8342
8307 8343 \family typewriter
8308 8344 \size small
8309 8345 Redistribution and use in source and binary forms, with or without modification,
8310 8346 are permitted provided that the following conditions are met:
8311 8347 \layout Quote
8312 8348
8313 8349
8314 8350 \family typewriter
8315 8351 \size small
8316 8352 a.
8317 8353 Redistributions of source code must retain the above copyright notice,
8318 8354 this list of conditions and the following disclaimer.
8319 8355 \layout Quote
8320 8356
8321 8357
8322 8358 \family typewriter
8323 8359 \size small
8324 8360 b.
8325 8361 Redistributions in binary form must reproduce the above copyright notice,
8326 8362 this list of conditions and the following disclaimer in the documentation
8327 8363 and/or other materials provided with the distribution.
8328 8364 \layout Quote
8329 8365
8330 8366
8331 8367 \family typewriter
8332 8368 \size small
8333 8369 c.
8334 8370 Neither the name of the copyright holders nor the names of any contributors
8335 8371 to this software may be used to endorse or promote products derived from
8336 8372 this software without specific prior written permission.
8337 8373 \layout Quote
8338 8374
8339 8375
8340 8376 \family typewriter
8341 8377 \size small
8342 8378 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
8343 8379 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
8344 8380 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
8345 8381 PURPOSE ARE DISCLAIMED.
8346 8382 IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
8347 8383 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
8348 8384 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
8349 8385 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
8350 8386 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8351 8387 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
8352 8388 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8353 8389
8354 8390 \layout Standard
8355 8391
8356 8392 Individual authors are the holders of the copyright for their code and are
8357 8393 listed in each file.
8358 8394 \layout Standard
8359 8395
8360 8396 Some files (
8361 8397 \family typewriter
8362 8398 DPyGetOpt.py
8363 8399 \family default
8364 8400 , for example) may be licensed under different conditions.
8365 8401 Ultimately each file indicates clearly the conditions under which its author/au
8366 8402 thors have decided to publish the code.
8367 8403 \layout Standard
8368 8404
8369 8405 Versions of IPython up to and including 0.6.3 were released under the GNU
8370 8406 Lesser General Public License (LGPL), available at
8371 8407 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/copyleft/lesser.html}
8372 8408
8373 8409 \end_inset
8374 8410
8375 8411 .
8376 8412 \layout Section
8377 8413
8378 8414
8379 8415 \begin_inset LatexCommand \label{sec:credits}
8380 8416
8381 8417 \end_inset
8382 8418
8383 8419 Credits
8384 8420 \layout Standard
8385 8421
8386 IPython is mainly developed by Fernando PοΏ½rez
8422 IPython is mainly developed by Fernando PΓ©rez
8387 8423 \family typewriter
8388 8424 <fperez@colorado.edu>
8389 8425 \family default
8390 8426 , but the project was born from mixing in Fernando's code with the IPP project
8391 8427 by Janko Hauser
8392 8428 \family typewriter
8393 8429 <jhauser-AT-zscout.de>
8394 8430 \family default
8395 8431 and LazyPython by Nathan Gray
8396 8432 \family typewriter
8397 8433 <n8gray-AT-caltech.edu>
8398 8434 \family default
8399 8435 .
8400 8436 For all IPython-related requests, please contact Fernando.
8401 8437
8402 8438 \layout Standard
8403 8439
8404 8440 As of late 2005, the following developers have joined the core team:
8405 8441 \layout List
8406 8442 \labelwidthstring 00.00.0000
8407 8443
8408 8444 Robert\SpecialChar ~
8409 8445 Kern
8410 8446 \family typewriter
8411 8447 <rkern-AT-enthought.com>
8412 8448 \family default
8413 8449 : co-mentored the 2005 Google Summer of Code project to develop python interacti
8414 8450 ve notebooks (XML documents) and graphical interface.
8415 8451 This project was awarded to the students Tzanko Matev
8416 8452 \family typewriter
8417 8453 <tsanko-AT-gmail.com>
8418 8454 \family default
8419 8455 and Toni Alatalo
8420 8456 \family typewriter
8421 8457 <antont-AT-an.org>
8422 8458 \layout List
8423 8459 \labelwidthstring 00.00.0000
8424 8460
8425 8461 Brian\SpecialChar ~
8426 8462 Granger
8427 8463 \family typewriter
8428 8464 <bgranger-AT-scu.edu>
8429 8465 \family default
8430 8466 : extending IPython to allow support for interactive parallel computing.
8431 8467 \layout Standard
8432 8468
8433 8469 User or development help should be requested via the IPython mailing lists:
8434 8470 \layout Description
8435 8471
8436 8472 User\SpecialChar ~
8437 8473 list:
8438 8474 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-user}
8439 8475
8440 8476 \end_inset
8441 8477
8442 8478
8443 8479 \layout Description
8444 8480
8445 8481 Developer's\SpecialChar ~
8446 8482 list:
8447 8483 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-dev}
8448 8484
8449 8485 \end_inset
8450 8486
8451 8487
8452 8488 \layout Standard
8453 8489
8454 8490 The IPython project is also very grateful to
8455 8491 \begin_inset Foot
8456 8492 collapsed true
8457 8493
8458 8494 \layout Standard
8459 8495
8460 8496 I've mangled email addresses to reduce spam, since the IPython manuals can
8461 8497 be accessed online.
8462 8498 \end_inset
8463 8499
8464 8500 :
8465 8501 \layout Standard
8466 8502
8467 8503 Bill Bumgarner
8468 8504 \family typewriter
8469 8505 <bbum-AT-friday.com>
8470 8506 \family default
8471 8507 : for providing the DPyGetOpt module which gives very powerful and convenient
8472 8508 handling of command-line options (light years ahead of what Python 2.1.1's
8473 8509 getopt module does).
8474 8510 \layout Standard
8475 8511
8476 8512 Ka-Ping Yee
8477 8513 \family typewriter
8478 8514 <ping-AT-lfw.org>
8479 8515 \family default
8480 8516 : for providing the Itpl module for convenient and powerful string interpolation
8481 8517 with a much nicer syntax than formatting through the '%' operator.
8482 8518 \layout Standard
8483 8519
8484 Arnd BοΏ½cker
8520 Arnd BΓ€cker
8485 8521 \family typewriter
8486 8522 <baecker-AT-physik.tu-dresden.de>
8487 8523 \family default
8488 8524 : for his many very useful suggestions and comments, and lots of help with
8489 8525 testing and documentation checking.
8490 8526 Many of IPython's newer features are a result of discussions with him (bugs
8491 8527 are still my fault, not his).
8492 8528 \layout Standard
8493 8529
8494 8530 Obviously Guido van\SpecialChar ~
8495 8531 Rossum and the whole Python development team, that goes
8496 8532 without saying.
8497 8533 \layout Standard
8498 8534
8499 8535 IPython's website is generously hosted at
8500 8536 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
8501 8537
8502 8538 \end_inset
8503 8539
8504 8540 by Enthought (
8505 8541 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
8506 8542
8507 8543 \end_inset
8508 8544
8509 8545 ).
8510 8546 I am very grateful to them and all of the SciPy team for their contribution.
8511 8547 \layout Standard
8512 8548
8513 8549
8514 8550 \begin_inset LatexCommand \label{figgins}
8515 8551
8516 8552 \end_inset
8517 8553
8518 8554 Fernando would also like to thank Stephen Figgins
8519 8555 \family typewriter
8520 8556 <fig-AT-monitor.net>
8521 8557 \family default
8522 8558 , an O'Reilly Python editor.
8523 8559 His Oct/11/2001 article about IPP and LazyPython, was what got this project
8524 8560 started.
8525 8561 You can read it at:
8526 8562 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html}
8527 8563
8528 8564 \end_inset
8529 8565
8530 8566 .
8531 8567 \layout Standard
8532 8568
8533 8569 And last but not least, all the kind IPython users who have emailed new
8534 8570 code, bug reports, fixes, comments and ideas.
8535 8571 A brief list follows, please let me know if I have ommitted your name by
8536 8572 accident:
8537 8573 \layout List
8538 8574 \labelwidthstring 00.00.0000
8539 8575
8540 8576 Jack\SpecialChar ~
8541 8577 Moffit
8542 8578 \family typewriter
8543 8579 <jack-AT-xiph.org>
8544 8580 \family default
8545 8581 Bug fixes, including the infamous color problem.
8546 8582 This bug alone caused many lost hours and frustration, many thanks to him
8547 8583 for the fix.
8548 8584 I've always been a fan of Ogg & friends, now I have one more reason to
8549 8585 like these folks.
8550 8586 \newline
8551 8587 Jack is also contributing with Debian packaging and many other things.
8552 8588 \layout List
8553 8589 \labelwidthstring 00.00.0000
8554 8590
8555 8591 Alexander\SpecialChar ~
8556 8592 Schmolck
8557 8593 \family typewriter
8558 8594 <a.schmolck-AT-gmx.net>
8559 8595 \family default
8560 8596 Emacs work, bug reports, bug fixes, ideas, lots more.
8561 8597 The ipython.el mode for (X)Emacs is Alex's code, providing full support
8562 8598 for IPython under (X)Emacs.
8563 8599 \layout List
8564 8600 \labelwidthstring 00.00.0000
8565 8601
8566 8602 Andrea\SpecialChar ~
8567 8603 Riciputi
8568 8604 \family typewriter
8569 8605 <andrea.riciputi-AT-libero.it>
8570 8606 \family default
8571 8607 Mac OSX information, Fink package management.
8572 8608 \layout List
8573 8609 \labelwidthstring 00.00.0000
8574 8610
8575 8611 Gary\SpecialChar ~
8576 8612 Bishop
8577 8613 \family typewriter
8578 8614 <gb-AT-cs.unc.edu>
8579 8615 \family default
8580 8616 Bug reports, and patches to work around the exception handling idiosyncracies
8581 8617 of WxPython.
8582 8618 Readline and color support for Windows.
8583 8619 \layout List
8584 8620 \labelwidthstring 00.00.0000
8585 8621
8586 8622 Jeffrey\SpecialChar ~
8587 8623 Collins
8588 8624 \family typewriter
8589 8625 <Jeff.Collins-AT-vexcel.com>
8590 8626 \family default
8591 8627 Bug reports.
8592 8628 Much improved readline support, including fixes for Python 2.3.
8593 8629 \layout List
8594 8630 \labelwidthstring 00.00.0000
8595 8631
8596 8632 Dryice\SpecialChar ~
8597 8633 Liu
8598 8634 \family typewriter
8599 8635 <dryice-AT-liu.com.cn>
8600 8636 \family default
8601 8637 FreeBSD port.
8602 8638 \layout List
8603 8639 \labelwidthstring 00.00.0000
8604 8640
8605 8641 Mike\SpecialChar ~
8606 8642 Heeter
8607 8643 \family typewriter
8608 8644 <korora-AT-SDF.LONESTAR.ORG>
8609 8645 \layout List
8610 8646 \labelwidthstring 00.00.0000
8611 8647
8612 8648 Christopher\SpecialChar ~
8613 8649 Hart
8614 8650 \family typewriter
8615 8651 <hart-AT-caltech.edu>
8616 8652 \family default
8617 8653 PDB integration.
8618 8654 \layout List
8619 8655 \labelwidthstring 00.00.0000
8620 8656
8621 8657 Milan\SpecialChar ~
8622 8658 Zamazal
8623 8659 \family typewriter
8624 8660 <pdm-AT-zamazal.org>
8625 8661 \family default
8626 8662 Emacs info.
8627 8663 \layout List
8628 8664 \labelwidthstring 00.00.0000
8629 8665
8630 8666 Philip\SpecialChar ~
8631 8667 Hisley
8632 8668 \family typewriter
8633 8669 <compsys-AT-starpower.net>
8634 8670 \layout List
8635 8671 \labelwidthstring 00.00.0000
8636 8672
8637 8673 Holger\SpecialChar ~
8638 8674 Krekel
8639 8675 \family typewriter
8640 8676 <pyth-AT-devel.trillke.net>
8641 8677 \family default
8642 8678 Tab completion, lots more.
8643 8679 \layout List
8644 8680 \labelwidthstring 00.00.0000
8645 8681
8646 8682 Robin\SpecialChar ~
8647 8683 Siebler
8648 8684 \family typewriter
8649 8685 <robinsiebler-AT-starband.net>
8650 8686 \layout List
8651 8687 \labelwidthstring 00.00.0000
8652 8688
8653 8689 Ralf\SpecialChar ~
8654 8690 Ahlbrink
8655 8691 \family typewriter
8656 8692 <ralf_ahlbrink-AT-web.de>
8657 8693 \layout List
8658 8694 \labelwidthstring 00.00.0000
8659 8695
8660 8696 Thorsten\SpecialChar ~
8661 8697 Kampe
8662 8698 \family typewriter
8663 8699 <thorsten-AT-thorstenkampe.de>
8664 8700 \layout List
8665 8701 \labelwidthstring 00.00.0000
8666 8702
8667 8703 Fredrik\SpecialChar ~
8668 8704 Kant
8669 8705 \family typewriter
8670 8706 <fredrik.kant-AT-front.com>
8671 8707 \family default
8672 8708 Windows setup.
8673 8709 \layout List
8674 8710 \labelwidthstring 00.00.0000
8675 8711
8676 8712 Syver\SpecialChar ~
8677 8713 Enstad
8678 8714 \family typewriter
8679 8715 <syver-en-AT-online.no>
8680 8716 \family default
8681 8717 Windows setup.
8682 8718 \layout List
8683 8719 \labelwidthstring 00.00.0000
8684 8720
8685 8721 Richard
8686 8722 \family typewriter
8687 8723 <rxe-AT-renre-europe.com>
8688 8724 \family default
8689 8725 Global embedding.
8690 8726 \layout List
8691 8727 \labelwidthstring 00.00.0000
8692 8728
8693 8729 Hayden\SpecialChar ~
8694 8730 Callow
8695 8731 \family typewriter
8696 8732 <h.callow-AT-elec.canterbury.ac.nz>
8697 8733 \family default
8698 8734 Gnuplot.py 1.6 compatibility.
8699 8735 \layout List
8700 8736 \labelwidthstring 00.00.0000
8701 8737
8702 8738 Leonardo\SpecialChar ~
8703 8739 Santagada
8704 8740 \family typewriter
8705 8741 <retype-AT-terra.com.br>
8706 8742 \family default
8707 8743 Fixes for Windows installation.
8708 8744 \layout List
8709 8745 \labelwidthstring 00.00.0000
8710 8746
8711 8747 Christopher\SpecialChar ~
8712 8748 Armstrong
8713 8749 \family typewriter
8714 8750 <radix-AT-twistedmatrix.com>
8715 8751 \family default
8716 8752 Bugfixes.
8717 8753 \layout List
8718 8754 \labelwidthstring 00.00.0000
8719 8755
8720 8756 Francois\SpecialChar ~
8721 8757 Pinard
8722 8758 \family typewriter
8723 8759 <pinard-AT-iro.umontreal.ca>
8724 8760 \family default
8725 8761 Code and documentation fixes.
8726 8762 \layout List
8727 8763 \labelwidthstring 00.00.0000
8728 8764
8729 8765 Cory\SpecialChar ~
8730 8766 Dodt
8731 8767 \family typewriter
8732 8768 <cdodt-AT-fcoe.k12.ca.us>
8733 8769 \family default
8734 8770 Bug reports and Windows ideas.
8735 8771 Patches for Windows installer.
8736 8772 \layout List
8737 8773 \labelwidthstring 00.00.0000
8738 8774
8739 8775 Olivier\SpecialChar ~
8740 8776 Aubert
8741 8777 \family typewriter
8742 8778 <oaubert-AT-bat710.univ-lyon1.fr>
8743 8779 \family default
8744 8780 New magics.
8745 8781 \layout List
8746 8782 \labelwidthstring 00.00.0000
8747 8783
8748 8784 King\SpecialChar ~
8749 8785 C.\SpecialChar ~
8750 8786 Shu
8751 8787 \family typewriter
8752 8788 <kingshu-AT-myrealbox.com>
8753 8789 \family default
8754 8790 Autoindent patch.
8755 8791 \layout List
8756 8792 \labelwidthstring 00.00.0000
8757 8793
8758 8794 Chris\SpecialChar ~
8759 8795 Drexler
8760 8796 \family typewriter
8761 8797 <chris-AT-ac-drexler.de>
8762 8798 \family default
8763 8799 Readline packages for Win32/CygWin.
8764 8800 \layout List
8765 8801 \labelwidthstring 00.00.0000
8766 8802
8767 8803 Gustavo\SpecialChar ~
8768 CοΏ½rdova\SpecialChar ~
8804 CΓ³rdova\SpecialChar ~
8769 8805 Avila
8770 8806 \family typewriter
8771 8807 <gcordova-AT-sismex.com>
8772 8808 \family default
8773 8809 EvalDict code for nice, lightweight string interpolation.
8774 8810 \layout List
8775 8811 \labelwidthstring 00.00.0000
8776 8812
8777 8813 Kasper\SpecialChar ~
8778 8814 Souren
8779 8815 \family typewriter
8780 8816 <Kasper.Souren-AT-ircam.fr>
8781 8817 \family default
8782 8818 Bug reports, ideas.
8783 8819 \layout List
8784 8820 \labelwidthstring 00.00.0000
8785 8821
8786 8822 Gever\SpecialChar ~
8787 8823 Tulley
8788 8824 \family typewriter
8789 8825 <gever-AT-helium.com>
8790 8826 \family default
8791 8827 Code contributions.
8792 8828 \layout List
8793 8829 \labelwidthstring 00.00.0000
8794 8830
8795 8831 Ralf\SpecialChar ~
8796 8832 Schmitt
8797 8833 \family typewriter
8798 8834 <ralf-AT-brainbot.com>
8799 8835 \family default
8800 8836 Bug reports & fixes.
8801 8837 \layout List
8802 8838 \labelwidthstring 00.00.0000
8803 8839
8804 8840 Oliver\SpecialChar ~
8805 8841 Sander
8806 8842 \family typewriter
8807 8843 <osander-AT-gmx.de>
8808 8844 \family default
8809 8845 Bug reports.
8810 8846 \layout List
8811 8847 \labelwidthstring 00.00.0000
8812 8848
8813 8849 Rod\SpecialChar ~
8814 8850 Holland
8815 8851 \family typewriter
8816 8852 <rhh-AT-structurelabs.com>
8817 8853 \family default
8818 8854 Bug reports and fixes to logging module.
8819 8855 \layout List
8820 8856 \labelwidthstring 00.00.0000
8821 8857
8822 8858 Daniel\SpecialChar ~
8823 8859 'Dang'\SpecialChar ~
8824 8860 Griffith
8825 8861 \family typewriter
8826 8862 <pythondev-dang-AT-lazytwinacres.net>
8827 8863 \family default
8828 8864 Fixes, enhancement suggestions for system shell use.
8829 8865 \layout List
8830 8866 \labelwidthstring 00.00.0000
8831 8867
8832 8868 Viktor\SpecialChar ~
8833 8869 Ransmayr
8834 8870 \family typewriter
8835 8871 <viktor.ransmayr-AT-t-online.de>
8836 8872 \family default
8837 8873 Tests and reports on Windows installation issues.
8838 8874 Contributed a true Windows binary installer.
8839 8875 \layout List
8840 8876 \labelwidthstring 00.00.0000
8841 8877
8842 8878 Mike\SpecialChar ~
8843 8879 Salib
8844 8880 \family typewriter
8845 8881 <msalib-AT-mit.edu>
8846 8882 \family default
8847 8883 Help fixing a subtle bug related to traceback printing.
8848 8884 \layout List
8849 8885 \labelwidthstring 00.00.0000
8850 8886
8851 8887 W.J.\SpecialChar ~
8852 8888 van\SpecialChar ~
8853 8889 der\SpecialChar ~
8854 8890 Laan
8855 8891 \family typewriter
8856 8892 <gnufnork-AT-hetdigitalegat.nl>
8857 8893 \family default
8858 8894 Bash-like prompt specials.
8859 8895 \layout List
8860 8896 \labelwidthstring 00.00.0000
8861 8897
8862 8898 Ville\SpecialChar ~
8863 8899 Vainio
8864 8900 \family typewriter
8865 8901 <vivainio-AT-kolumbus.fi>
8866 8902 \family default
8867 8903 Bugfixes and suggestions.
8868 8904 Excellent patches for many new features.
8869 8905 \layout List
8870 8906 \labelwidthstring 00.00.0000
8871 8907
8872 8908 Antoon\SpecialChar ~
8873 8909 Pardon
8874 8910 \family typewriter
8875 8911 <Antoon.Pardon-AT-rece.vub.ac.be>
8876 8912 \family default
8877 8913 Critical fix for the multithreaded IPython.
8878 8914 \layout List
8879 8915 \labelwidthstring 00.00.0000
8880 8916
8881 8917 John\SpecialChar ~
8882 8918 Hunter
8883 8919 \family typewriter
8884 8920 <jdhunter-AT-nitace.bsd.uchicago.edu>
8885 8921 \family default
8886 8922 Matplotlib author, helped with all the development of support for matplotlib
8887 8923 in IPyhton, including making necessary changes to matplotlib itself.
8888 8924 \layout List
8889 8925 \labelwidthstring 00.00.0000
8890 8926
8891 8927 Matthew\SpecialChar ~
8892 8928 Arnison
8893 8929 \family typewriter
8894 8930 <maffew-AT-cat.org.au>
8895 8931 \family default
8896 8932 Bug reports, `
8897 8933 \family typewriter
8898 8934 %run -d
8899 8935 \family default
8900 8936 ' idea.
8901 8937 \layout List
8902 8938 \labelwidthstring 00.00.0000
8903 8939
8904 8940 Prabhu\SpecialChar ~
8905 8941 Ramachandran
8906 8942 \family typewriter
8907 8943 <prabhu_r-AT-users.sourceforge.net>
8908 8944 \family default
8909 8945 Help with (X)Emacs support, threading patches, ideas...
8910 8946 \layout List
8911 8947 \labelwidthstring 00.00.0000
8912 8948
8913 8949 Norbert\SpecialChar ~
8914 8950 Tretkowski
8915 8951 \family typewriter
8916 8952 <tretkowski-AT-inittab.de>
8917 8953 \family default
8918 8954 help with Debian packaging and distribution.
8919 8955 \layout List
8920 8956 \labelwidthstring 00.00.0000
8921 8957
8922 8958 George\SpecialChar ~
8923 8959 Sakkis <
8924 8960 \family typewriter
8925 8961 gsakkis-AT-eden.rutgers.edu>
8926 8962 \family default
8927 8963 New matcher for tab-completing named arguments of user-defined functions.
8928 8964 \the_end
General Comments 0
You need to be logged in to leave comments. Login now