##// END OF EJS Templates
update changelog
vivainio -
Show More
@@ -1,3067 +1,3072 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Magic functions for InteractiveShell.
3 3
4 $Id: Magic.py 1918 2006-11-21 20:19:13Z vivainio $"""
4 $Id: Magic.py 1921 2006-11-21 20:49:55Z vivainio $"""
5 5
6 6 #*****************************************************************************
7 7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
8 8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
9 9 #
10 10 # Distributed under the terms of the BSD License. The full license is in
11 11 # the file COPYING, distributed as part of this software.
12 12 #*****************************************************************************
13 13
14 14 #****************************************************************************
15 15 # Modules and globals
16 16
17 17 from IPython import Release
18 18 __author__ = '%s <%s>\n%s <%s>' % \
19 19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
20 20 __license__ = Release.license
21 21
22 22 # Python standard modules
23 23 import __builtin__
24 24 import bdb
25 25 import inspect
26 26 import os
27 27 import pdb
28 28 import pydoc
29 29 import sys
30 30 import re
31 31 import tempfile
32 32 import time
33 33 import cPickle as pickle
34 34 import textwrap
35 35 from cStringIO import StringIO
36 36 from getopt import getopt,GetoptError
37 37 from pprint import pprint, pformat
38 38
39 # cProfile was added in Python2.5
40 try:
41 import cProfile as profile
42 import pstats
43 except ImportError:
39 44 # profile isn't bundled by default in Debian for license reasons
40 45 try:
41 46 import profile,pstats
42 47 except ImportError:
43 48 profile = pstats = None
44 49
45 50 # Homebrewed
46 51 import IPython
47 52 from IPython import Debugger, OInspect, wildcard
48 53 from IPython.FakeModule import FakeModule
49 54 from IPython.Itpl import Itpl, itpl, printpl,itplns
50 55 from IPython.PyColorize import Parser
51 56 from IPython.ipstruct import Struct
52 57 from IPython.macro import Macro
53 58 from IPython.genutils import *
54 59 from IPython import platutils
55 60
56 61 #***************************************************************************
57 62 # Utility functions
58 63 def on_off(tag):
59 64 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
60 65 return ['OFF','ON'][tag]
61 66
62 67 class Bunch: pass
63 68
64 69 #***************************************************************************
65 70 # Main class implementing Magic functionality
66 71 class Magic:
67 72 """Magic functions for InteractiveShell.
68 73
69 74 Shell functions which can be reached as %function_name. All magic
70 75 functions should accept a string, which they can parse for their own
71 76 needs. This can make some functions easier to type, eg `%cd ../`
72 77 vs. `%cd("../")`
73 78
74 79 ALL definitions MUST begin with the prefix magic_. The user won't need it
75 80 at the command line, but it is is needed in the definition. """
76 81
77 82 # class globals
78 83 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
79 84 'Automagic is ON, % prefix NOT needed for magic functions.']
80 85
81 86 #......................................................................
82 87 # some utility functions
83 88
84 89 def __init__(self,shell):
85 90
86 91 self.options_table = {}
87 92 if profile is None:
88 93 self.magic_prun = self.profile_missing_notice
89 94 self.shell = shell
90 95
91 96 # namespace for holding state we may need
92 97 self._magic_state = Bunch()
93 98
94 99 def profile_missing_notice(self, *args, **kwargs):
95 100 error("""\
96 101 The profile module could not be found. If you are a Debian user,
97 102 it has been removed from the standard Debian package because of its non-free
98 103 license. To use profiling, please install"python2.3-profiler" from non-free.""")
99 104
100 105 def default_option(self,fn,optstr):
101 106 """Make an entry in the options_table for fn, with value optstr"""
102 107
103 108 if fn not in self.lsmagic():
104 109 error("%s is not a magic function" % fn)
105 110 self.options_table[fn] = optstr
106 111
107 112 def lsmagic(self):
108 113 """Return a list of currently available magic functions.
109 114
110 115 Gives a list of the bare names after mangling (['ls','cd', ...], not
111 116 ['magic_ls','magic_cd',...]"""
112 117
113 118 # FIXME. This needs a cleanup, in the way the magics list is built.
114 119
115 120 # magics in class definition
116 121 class_magic = lambda fn: fn.startswith('magic_') and \
117 122 callable(Magic.__dict__[fn])
118 123 # in instance namespace (run-time user additions)
119 124 inst_magic = lambda fn: fn.startswith('magic_') and \
120 125 callable(self.__dict__[fn])
121 126 # and bound magics by user (so they can access self):
122 127 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
123 128 callable(self.__class__.__dict__[fn])
124 129 magics = filter(class_magic,Magic.__dict__.keys()) + \
125 130 filter(inst_magic,self.__dict__.keys()) + \
126 131 filter(inst_bound_magic,self.__class__.__dict__.keys())
127 132 out = []
128 133 for fn in magics:
129 134 out.append(fn.replace('magic_','',1))
130 135 out.sort()
131 136 return out
132 137
133 138 def extract_input_slices(self,slices,raw=False):
134 139 """Return as a string a set of input history slices.
135 140
136 141 Inputs:
137 142
138 143 - slices: the set of slices is given as a list of strings (like
139 144 ['1','4:8','9'], since this function is for use by magic functions
140 145 which get their arguments as strings.
141 146
142 147 Optional inputs:
143 148
144 149 - raw(False): by default, the processed input is used. If this is
145 150 true, the raw input history is used instead.
146 151
147 152 Note that slices can be called with two notations:
148 153
149 154 N:M -> standard python form, means including items N...(M-1).
150 155
151 156 N-M -> include items N..M (closed endpoint)."""
152 157
153 158 if raw:
154 159 hist = self.shell.input_hist_raw
155 160 else:
156 161 hist = self.shell.input_hist
157 162
158 163 cmds = []
159 164 for chunk in slices:
160 165 if ':' in chunk:
161 166 ini,fin = map(int,chunk.split(':'))
162 167 elif '-' in chunk:
163 168 ini,fin = map(int,chunk.split('-'))
164 169 fin += 1
165 170 else:
166 171 ini = int(chunk)
167 172 fin = ini+1
168 173 cmds.append(hist[ini:fin])
169 174 return cmds
170 175
171 176 def _ofind(self, oname, namespaces=None):
172 177 """Find an object in the available namespaces.
173 178
174 179 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
175 180
176 181 Has special code to detect magic functions.
177 182 """
178 183
179 184 oname = oname.strip()
180 185
181 186 alias_ns = None
182 187 if namespaces is None:
183 188 # Namespaces to search in:
184 189 # Put them in a list. The order is important so that we
185 190 # find things in the same order that Python finds them.
186 191 namespaces = [ ('Interactive', self.shell.user_ns),
187 192 ('IPython internal', self.shell.internal_ns),
188 193 ('Python builtin', __builtin__.__dict__),
189 194 ('Alias', self.shell.alias_table),
190 195 ]
191 196 alias_ns = self.shell.alias_table
192 197
193 198 # initialize results to 'null'
194 199 found = 0; obj = None; ospace = None; ds = None;
195 200 ismagic = 0; isalias = 0; parent = None
196 201
197 202 # Look for the given name by splitting it in parts. If the head is
198 203 # found, then we look for all the remaining parts as members, and only
199 204 # declare success if we can find them all.
200 205 oname_parts = oname.split('.')
201 206 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
202 207 for nsname,ns in namespaces:
203 208 try:
204 209 obj = ns[oname_head]
205 210 except KeyError:
206 211 continue
207 212 else:
208 213 for part in oname_rest:
209 214 try:
210 215 parent = obj
211 216 obj = getattr(obj,part)
212 217 except:
213 218 # Blanket except b/c some badly implemented objects
214 219 # allow __getattr__ to raise exceptions other than
215 220 # AttributeError, which then crashes IPython.
216 221 break
217 222 else:
218 223 # If we finish the for loop (no break), we got all members
219 224 found = 1
220 225 ospace = nsname
221 226 if ns == alias_ns:
222 227 isalias = 1
223 228 break # namespace loop
224 229
225 230 # Try to see if it's magic
226 231 if not found:
227 232 if oname.startswith(self.shell.ESC_MAGIC):
228 233 oname = oname[1:]
229 234 obj = getattr(self,'magic_'+oname,None)
230 235 if obj is not None:
231 236 found = 1
232 237 ospace = 'IPython internal'
233 238 ismagic = 1
234 239
235 240 # Last try: special-case some literals like '', [], {}, etc:
236 241 if not found and oname_head in ["''",'""','[]','{}','()']:
237 242 obj = eval(oname_head)
238 243 found = 1
239 244 ospace = 'Interactive'
240 245
241 246 return {'found':found, 'obj':obj, 'namespace':ospace,
242 247 'ismagic':ismagic, 'isalias':isalias, 'parent':parent}
243 248
244 249 def arg_err(self,func):
245 250 """Print docstring if incorrect arguments were passed"""
246 251 print 'Error in arguments:'
247 252 print OInspect.getdoc(func)
248 253
249 254 def format_latex(self,strng):
250 255 """Format a string for latex inclusion."""
251 256
252 257 # Characters that need to be escaped for latex:
253 258 escape_re = re.compile(r'(%|_|\$|#|&)',re.MULTILINE)
254 259 # Magic command names as headers:
255 260 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
256 261 re.MULTILINE)
257 262 # Magic commands
258 263 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
259 264 re.MULTILINE)
260 265 # Paragraph continue
261 266 par_re = re.compile(r'\\$',re.MULTILINE)
262 267
263 268 # The "\n" symbol
264 269 newline_re = re.compile(r'\\n')
265 270
266 271 # Now build the string for output:
267 272 #strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng)
268 273 strng = cmd_name_re.sub(r'\n\\bigskip\n\\texttt{\\textbf{ \1}}:',
269 274 strng)
270 275 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
271 276 strng = par_re.sub(r'\\\\',strng)
272 277 strng = escape_re.sub(r'\\\1',strng)
273 278 strng = newline_re.sub(r'\\textbackslash{}n',strng)
274 279 return strng
275 280
276 281 def format_screen(self,strng):
277 282 """Format a string for screen printing.
278 283
279 284 This removes some latex-type format codes."""
280 285 # Paragraph continue
281 286 par_re = re.compile(r'\\$',re.MULTILINE)
282 287 strng = par_re.sub('',strng)
283 288 return strng
284 289
285 290 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
286 291 """Parse options passed to an argument string.
287 292
288 293 The interface is similar to that of getopt(), but it returns back a
289 294 Struct with the options as keys and the stripped argument string still
290 295 as a string.
291 296
292 297 arg_str is quoted as a true sys.argv vector by using shlex.split.
293 298 This allows us to easily expand variables, glob files, quote
294 299 arguments, etc.
295 300
296 301 Options:
297 302 -mode: default 'string'. If given as 'list', the argument string is
298 303 returned as a list (split on whitespace) instead of a string.
299 304
300 305 -list_all: put all option values in lists. Normally only options
301 306 appearing more than once are put in a list.
302 307
303 308 -posix (True): whether to split the input line in POSIX mode or not,
304 309 as per the conventions outlined in the shlex module from the
305 310 standard library."""
306 311
307 312 # inject default options at the beginning of the input line
308 313 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
309 314 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
310 315
311 316 mode = kw.get('mode','string')
312 317 if mode not in ['string','list']:
313 318 raise ValueError,'incorrect mode given: %s' % mode
314 319 # Get options
315 320 list_all = kw.get('list_all',0)
316 321 posix = kw.get('posix',True)
317 322
318 323 # Check if we have more than one argument to warrant extra processing:
319 324 odict = {} # Dictionary with options
320 325 args = arg_str.split()
321 326 if len(args) >= 1:
322 327 # If the list of inputs only has 0 or 1 thing in it, there's no
323 328 # need to look for options
324 329 argv = arg_split(arg_str,posix)
325 330 # Do regular option processing
326 331 try:
327 332 opts,args = getopt(argv,opt_str,*long_opts)
328 333 except GetoptError,e:
329 334 raise GetoptError('%s ( allowed: "%s" %s)' % (e.msg,opt_str,
330 335 " ".join(long_opts)))
331 336 for o,a in opts:
332 337 if o.startswith('--'):
333 338 o = o[2:]
334 339 else:
335 340 o = o[1:]
336 341 try:
337 342 odict[o].append(a)
338 343 except AttributeError:
339 344 odict[o] = [odict[o],a]
340 345 except KeyError:
341 346 if list_all:
342 347 odict[o] = [a]
343 348 else:
344 349 odict[o] = a
345 350
346 351 # Prepare opts,args for return
347 352 opts = Struct(odict)
348 353 if mode == 'string':
349 354 args = ' '.join(args)
350 355
351 356 return opts,args
352 357
353 358 #......................................................................
354 359 # And now the actual magic functions
355 360
356 361 # Functions for IPython shell work (vars,funcs, config, etc)
357 362 def magic_lsmagic(self, parameter_s = ''):
358 363 """List currently available magic functions."""
359 364 mesc = self.shell.ESC_MAGIC
360 365 print 'Available magic functions:\n'+mesc+\
361 366 (' '+mesc).join(self.lsmagic())
362 367 print '\n' + Magic.auto_status[self.shell.rc.automagic]
363 368 return None
364 369
365 370 def magic_magic(self, parameter_s = ''):
366 371 """Print information about the magic function system."""
367 372
368 373 mode = ''
369 374 try:
370 375 if parameter_s.split()[0] == '-latex':
371 376 mode = 'latex'
372 377 if parameter_s.split()[0] == '-brief':
373 378 mode = 'brief'
374 379 except:
375 380 pass
376 381
377 382 magic_docs = []
378 383 for fname in self.lsmagic():
379 384 mname = 'magic_' + fname
380 385 for space in (Magic,self,self.__class__):
381 386 try:
382 387 fn = space.__dict__[mname]
383 388 except KeyError:
384 389 pass
385 390 else:
386 391 break
387 392 if mode == 'brief':
388 393 # only first line
389 394 fndoc = fn.__doc__.split('\n',1)[0]
390 395 else:
391 396 fndoc = fn.__doc__
392 397
393 398 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
394 399 fname,fndoc))
395 400 magic_docs = ''.join(magic_docs)
396 401
397 402 if mode == 'latex':
398 403 print self.format_latex(magic_docs)
399 404 return
400 405 else:
401 406 magic_docs = self.format_screen(magic_docs)
402 407 if mode == 'brief':
403 408 return magic_docs
404 409
405 410 outmsg = """
406 411 IPython's 'magic' functions
407 412 ===========================
408 413
409 414 The magic function system provides a series of functions which allow you to
410 415 control the behavior of IPython itself, plus a lot of system-type
411 416 features. All these functions are prefixed with a % character, but parameters
412 417 are given without parentheses or quotes.
413 418
414 419 NOTE: If you have 'automagic' enabled (via the command line option or with the
415 420 %automagic function), you don't need to type in the % explicitly. By default,
416 421 IPython ships with automagic on, so you should only rarely need the % escape.
417 422
418 423 Example: typing '%cd mydir' (without the quotes) changes you working directory
419 424 to 'mydir', if it exists.
420 425
421 426 You can define your own magic functions to extend the system. See the supplied
422 427 ipythonrc and example-magic.py files for details (in your ipython
423 428 configuration directory, typically $HOME/.ipython/).
424 429
425 430 You can also define your own aliased names for magic functions. In your
426 431 ipythonrc file, placing a line like:
427 432
428 433 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
429 434
430 435 will define %pf as a new name for %profile.
431 436
432 437 You can also call magics in code using the ipmagic() function, which IPython
433 438 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
434 439
435 440 For a list of the available magic functions, use %lsmagic. For a description
436 441 of any of them, type %magic_name?, e.g. '%cd?'.
437 442
438 443 Currently the magic system has the following functions:\n"""
439 444
440 445 mesc = self.shell.ESC_MAGIC
441 446 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
442 447 "\n\n%s%s\n\n%s" % (outmsg,
443 448 magic_docs,mesc,mesc,
444 449 (' '+mesc).join(self.lsmagic()),
445 450 Magic.auto_status[self.shell.rc.automagic] ) )
446 451
447 452 page(outmsg,screen_lines=self.shell.rc.screen_length)
448 453
449 454 def magic_automagic(self, parameter_s = ''):
450 455 """Make magic functions callable without having to type the initial %.
451 456
452 457 Toggles on/off (when off, you must call it as %automagic, of
453 458 course). Note that magic functions have lowest priority, so if there's
454 459 a variable whose name collides with that of a magic fn, automagic
455 460 won't work for that function (you get the variable instead). However,
456 461 if you delete the variable (del var), the previously shadowed magic
457 462 function becomes visible to automagic again."""
458 463
459 464 rc = self.shell.rc
460 465 rc.automagic = not rc.automagic
461 466 print '\n' + Magic.auto_status[rc.automagic]
462 467
463 468 def magic_autocall(self, parameter_s = ''):
464 469 """Make functions callable without having to type parentheses.
465 470
466 471 Usage:
467 472
468 473 %autocall [mode]
469 474
470 475 The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the
471 476 value is toggled on and off (remembering the previous state)."""
472 477
473 478 rc = self.shell.rc
474 479
475 480 if parameter_s:
476 481 arg = int(parameter_s)
477 482 else:
478 483 arg = 'toggle'
479 484
480 485 if not arg in (0,1,2,'toggle'):
481 486 error('Valid modes: (0->Off, 1->Smart, 2->Full')
482 487 return
483 488
484 489 if arg in (0,1,2):
485 490 rc.autocall = arg
486 491 else: # toggle
487 492 if rc.autocall:
488 493 self._magic_state.autocall_save = rc.autocall
489 494 rc.autocall = 0
490 495 else:
491 496 try:
492 497 rc.autocall = self._magic_state.autocall_save
493 498 except AttributeError:
494 499 rc.autocall = self._magic_state.autocall_save = 1
495 500
496 501 print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall]
497 502
498 503 def magic_autoindent(self, parameter_s = ''):
499 504 """Toggle autoindent on/off (if available)."""
500 505
501 506 self.shell.set_autoindent()
502 507 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
503 508
504 509 def magic_system_verbose(self, parameter_s = ''):
505 510 """Set verbose printing of system calls.
506 511
507 512 If called without an argument, act as a toggle"""
508 513
509 514 if parameter_s:
510 515 val = bool(eval(parameter_s))
511 516 else:
512 517 val = None
513 518
514 519 self.shell.rc_set_toggle('system_verbose',val)
515 520 print "System verbose printing is:",\
516 521 ['OFF','ON'][self.shell.rc.system_verbose]
517 522
518 523 def magic_history(self, parameter_s = ''):
519 524 """Print input history (_i<n> variables), with most recent last.
520 525
521 526 %history -> print at most 40 inputs (some may be multi-line)\\
522 527 %history n -> print at most n inputs\\
523 528 %history n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
524 529
525 530 Each input's number <n> is shown, and is accessible as the
526 531 automatically generated variable _i<n>. Multi-line statements are
527 532 printed starting at a new line for easy copy/paste.
528 533
529 534
530 535 Options:
531 536
532 537 -n: do NOT print line numbers. This is useful if you want to get a
533 538 printout of many lines which can be directly pasted into a text
534 539 editor.
535 540
536 541 This feature is only available if numbered prompts are in use.
537 542
538 543 -r: print the 'raw' history. IPython filters your input and
539 544 converts it all into valid Python source before executing it (things
540 545 like magics or aliases are turned into function calls, for
541 546 example). With this option, you'll see the unfiltered history
542 547 instead of the filtered version: '%cd /' will be seen as '%cd /'
543 548 instead of '_ip.magic("%cd /")'.
544 549 """
545 550
546 551 shell = self.shell
547 552 if not shell.outputcache.do_full_cache:
548 553 print 'This feature is only available if numbered prompts are in use.'
549 554 return
550 555 opts,args = self.parse_options(parameter_s,'nr',mode='list')
551 556
552 557 if opts.has_key('r'):
553 558 input_hist = shell.input_hist_raw
554 559 else:
555 560 input_hist = shell.input_hist
556 561
557 562 default_length = 40
558 563 if len(args) == 0:
559 564 final = len(input_hist)
560 565 init = max(1,final-default_length)
561 566 elif len(args) == 1:
562 567 final = len(input_hist)
563 568 init = max(1,final-int(args[0]))
564 569 elif len(args) == 2:
565 570 init,final = map(int,args)
566 571 else:
567 572 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
568 573 print self.magic_hist.__doc__
569 574 return
570 575 width = len(str(final))
571 576 line_sep = ['','\n']
572 577 print_nums = not opts.has_key('n')
573 578 for in_num in range(init,final):
574 579 inline = input_hist[in_num]
575 580 multiline = int(inline.count('\n') > 1)
576 581 if print_nums:
577 582 print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]),
578 583 print inline,
579 584
580 585 def magic_hist(self, parameter_s=''):
581 586 """Alternate name for %history."""
582 587 return self.magic_history(parameter_s)
583 588
584 589 def magic_p(self, parameter_s=''):
585 590 """Just a short alias for Python's 'print'."""
586 591 exec 'print ' + parameter_s in self.shell.user_ns
587 592
588 593 def magic_r(self, parameter_s=''):
589 594 """Repeat previous input.
590 595
591 596 If given an argument, repeats the previous command which starts with
592 597 the same string, otherwise it just repeats the previous input.
593 598
594 599 Shell escaped commands (with ! as first character) are not recognized
595 600 by this system, only pure python code and magic commands.
596 601 """
597 602
598 603 start = parameter_s.strip()
599 604 esc_magic = self.shell.ESC_MAGIC
600 605 # Identify magic commands even if automagic is on (which means
601 606 # the in-memory version is different from that typed by the user).
602 607 if self.shell.rc.automagic:
603 608 start_magic = esc_magic+start
604 609 else:
605 610 start_magic = start
606 611 # Look through the input history in reverse
607 612 for n in range(len(self.shell.input_hist)-2,0,-1):
608 613 input = self.shell.input_hist[n]
609 614 # skip plain 'r' lines so we don't recurse to infinity
610 615 if input != '_ip.magic("r")\n' and \
611 616 (input.startswith(start) or input.startswith(start_magic)):
612 617 #print 'match',`input` # dbg
613 618 print 'Executing:',input,
614 619 self.shell.runlines(input)
615 620 return
616 621 print 'No previous input matching `%s` found.' % start
617 622
618 623 def magic_page(self, parameter_s=''):
619 624 """Pretty print the object and display it through a pager.
620 625
621 626 %page [options] OBJECT
622 627
623 628 If no object is given, use _ (last output).
624 629
625 630 Options:
626 631
627 632 -r: page str(object), don't pretty-print it."""
628 633
629 634 # After a function contributed by Olivier Aubert, slightly modified.
630 635
631 636 # Process options/args
632 637 opts,args = self.parse_options(parameter_s,'r')
633 638 raw = 'r' in opts
634 639
635 640 oname = args and args or '_'
636 641 info = self._ofind(oname)
637 642 if info['found']:
638 643 txt = (raw and str or pformat)( info['obj'] )
639 644 page(txt)
640 645 else:
641 646 print 'Object `%s` not found' % oname
642 647
643 648 def magic_profile(self, parameter_s=''):
644 649 """Print your currently active IPyhton profile."""
645 650 if self.shell.rc.profile:
646 651 printpl('Current IPython profile: $self.shell.rc.profile.')
647 652 else:
648 653 print 'No profile active.'
649 654
650 655 def _inspect(self,meth,oname,namespaces=None,**kw):
651 656 """Generic interface to the inspector system.
652 657
653 658 This function is meant to be called by pdef, pdoc & friends."""
654 659
655 660 oname = oname.strip()
656 661 info = Struct(self._ofind(oname, namespaces))
657 662
658 663 if info.found:
659 664 # Get the docstring of the class property if it exists.
660 665 path = oname.split('.')
661 666 root = '.'.join(path[:-1])
662 667 if info.parent is not None:
663 668 try:
664 669 target = getattr(info.parent, '__class__')
665 670 # The object belongs to a class instance.
666 671 try:
667 672 target = getattr(target, path[-1])
668 673 # The class defines the object.
669 674 if isinstance(target, property):
670 675 oname = root + '.__class__.' + path[-1]
671 676 info = Struct(self._ofind(oname))
672 677 except AttributeError: pass
673 678 except AttributeError: pass
674 679
675 680 pmethod = getattr(self.shell.inspector,meth)
676 681 formatter = info.ismagic and self.format_screen or None
677 682 if meth == 'pdoc':
678 683 pmethod(info.obj,oname,formatter)
679 684 elif meth == 'pinfo':
680 685 pmethod(info.obj,oname,formatter,info,**kw)
681 686 else:
682 687 pmethod(info.obj,oname)
683 688 else:
684 689 print 'Object `%s` not found.' % oname
685 690 return 'not found' # so callers can take other action
686 691
687 692 def magic_pdef(self, parameter_s='', namespaces=None):
688 693 """Print the definition header for any callable object.
689 694
690 695 If the object is a class, print the constructor information."""
691 696 print "+++"
692 697 self._inspect('pdef',parameter_s, namespaces)
693 698
694 699 def magic_pdoc(self, parameter_s='', namespaces=None):
695 700 """Print the docstring for an object.
696 701
697 702 If the given object is a class, it will print both the class and the
698 703 constructor docstrings."""
699 704 self._inspect('pdoc',parameter_s, namespaces)
700 705
701 706 def magic_psource(self, parameter_s='', namespaces=None):
702 707 """Print (or run through pager) the source code for an object."""
703 708 self._inspect('psource',parameter_s, namespaces)
704 709
705 710 def magic_pfile(self, parameter_s=''):
706 711 """Print (or run through pager) the file where an object is defined.
707 712
708 713 The file opens at the line where the object definition begins. IPython
709 714 will honor the environment variable PAGER if set, and otherwise will
710 715 do its best to print the file in a convenient form.
711 716
712 717 If the given argument is not an object currently defined, IPython will
713 718 try to interpret it as a filename (automatically adding a .py extension
714 719 if needed). You can thus use %pfile as a syntax highlighting code
715 720 viewer."""
716 721
717 722 # first interpret argument as an object name
718 723 out = self._inspect('pfile',parameter_s)
719 724 # if not, try the input as a filename
720 725 if out == 'not found':
721 726 try:
722 727 filename = get_py_filename(parameter_s)
723 728 except IOError,msg:
724 729 print msg
725 730 return
726 731 page(self.shell.inspector.format(file(filename).read()))
727 732
728 733 def magic_pinfo(self, parameter_s='', namespaces=None):
729 734 """Provide detailed information about an object.
730 735
731 736 '%pinfo object' is just a synonym for object? or ?object."""
732 737
733 738 #print 'pinfo par: <%s>' % parameter_s # dbg
734 739
735 740 # detail_level: 0 -> obj? , 1 -> obj??
736 741 detail_level = 0
737 742 # We need to detect if we got called as 'pinfo pinfo foo', which can
738 743 # happen if the user types 'pinfo foo?' at the cmd line.
739 744 pinfo,qmark1,oname,qmark2 = \
740 745 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
741 746 if pinfo or qmark1 or qmark2:
742 747 detail_level = 1
743 748 if "*" in oname:
744 749 self.magic_psearch(oname)
745 750 else:
746 751 self._inspect('pinfo', oname, detail_level=detail_level,
747 752 namespaces=namespaces)
748 753
749 754 def magic_psearch(self, parameter_s=''):
750 755 """Search for object in namespaces by wildcard.
751 756
752 757 %psearch [options] PATTERN [OBJECT TYPE]
753 758
754 759 Note: ? can be used as a synonym for %psearch, at the beginning or at
755 760 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
756 761 rest of the command line must be unchanged (options come first), so
757 762 for example the following forms are equivalent
758 763
759 764 %psearch -i a* function
760 765 -i a* function?
761 766 ?-i a* function
762 767
763 768 Arguments:
764 769
765 770 PATTERN
766 771
767 772 where PATTERN is a string containing * as a wildcard similar to its
768 773 use in a shell. The pattern is matched in all namespaces on the
769 774 search path. By default objects starting with a single _ are not
770 775 matched, many IPython generated objects have a single
771 776 underscore. The default is case insensitive matching. Matching is
772 777 also done on the attributes of objects and not only on the objects
773 778 in a module.
774 779
775 780 [OBJECT TYPE]
776 781
777 782 Is the name of a python type from the types module. The name is
778 783 given in lowercase without the ending type, ex. StringType is
779 784 written string. By adding a type here only objects matching the
780 785 given type are matched. Using all here makes the pattern match all
781 786 types (this is the default).
782 787
783 788 Options:
784 789
785 790 -a: makes the pattern match even objects whose names start with a
786 791 single underscore. These names are normally ommitted from the
787 792 search.
788 793
789 794 -i/-c: make the pattern case insensitive/sensitive. If neither of
790 795 these options is given, the default is read from your ipythonrc
791 796 file. The option name which sets this value is
792 797 'wildcards_case_sensitive'. If this option is not specified in your
793 798 ipythonrc file, IPython's internal default is to do a case sensitive
794 799 search.
795 800
796 801 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
797 802 specifiy can be searched in any of the following namespaces:
798 803 'builtin', 'user', 'user_global','internal', 'alias', where
799 804 'builtin' and 'user' are the search defaults. Note that you should
800 805 not use quotes when specifying namespaces.
801 806
802 807 'Builtin' contains the python module builtin, 'user' contains all
803 808 user data, 'alias' only contain the shell aliases and no python
804 809 objects, 'internal' contains objects used by IPython. The
805 810 'user_global' namespace is only used by embedded IPython instances,
806 811 and it contains module-level globals. You can add namespaces to the
807 812 search with -s or exclude them with -e (these options can be given
808 813 more than once).
809 814
810 815 Examples:
811 816
812 817 %psearch a* -> objects beginning with an a
813 818 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
814 819 %psearch a* function -> all functions beginning with an a
815 820 %psearch re.e* -> objects beginning with an e in module re
816 821 %psearch r*.e* -> objects that start with e in modules starting in r
817 822 %psearch r*.* string -> all strings in modules beginning with r
818 823
819 824 Case sensitve search:
820 825
821 826 %psearch -c a* list all object beginning with lower case a
822 827
823 828 Show objects beginning with a single _:
824 829
825 830 %psearch -a _* list objects beginning with a single underscore"""
826 831
827 832 # default namespaces to be searched
828 833 def_search = ['user','builtin']
829 834
830 835 # Process options/args
831 836 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
832 837 opt = opts.get
833 838 shell = self.shell
834 839 psearch = shell.inspector.psearch
835 840
836 841 # select case options
837 842 if opts.has_key('i'):
838 843 ignore_case = True
839 844 elif opts.has_key('c'):
840 845 ignore_case = False
841 846 else:
842 847 ignore_case = not shell.rc.wildcards_case_sensitive
843 848
844 849 # Build list of namespaces to search from user options
845 850 def_search.extend(opt('s',[]))
846 851 ns_exclude = ns_exclude=opt('e',[])
847 852 ns_search = [nm for nm in def_search if nm not in ns_exclude]
848 853
849 854 # Call the actual search
850 855 try:
851 856 psearch(args,shell.ns_table,ns_search,
852 857 show_all=opt('a'),ignore_case=ignore_case)
853 858 except:
854 859 shell.showtraceback()
855 860
856 861 def magic_who_ls(self, parameter_s=''):
857 862 """Return a sorted list of all interactive variables.
858 863
859 864 If arguments are given, only variables of types matching these
860 865 arguments are returned."""
861 866
862 867 user_ns = self.shell.user_ns
863 868 internal_ns = self.shell.internal_ns
864 869 user_config_ns = self.shell.user_config_ns
865 870 out = []
866 871 typelist = parameter_s.split()
867 872
868 873 for i in user_ns:
869 874 if not (i.startswith('_') or i.startswith('_i')) \
870 875 and not (i in internal_ns or i in user_config_ns):
871 876 if typelist:
872 877 if type(user_ns[i]).__name__ in typelist:
873 878 out.append(i)
874 879 else:
875 880 out.append(i)
876 881 out.sort()
877 882 return out
878 883
879 884 def magic_who(self, parameter_s=''):
880 885 """Print all interactive variables, with some minimal formatting.
881 886
882 887 If any arguments are given, only variables whose type matches one of
883 888 these are printed. For example:
884 889
885 890 %who function str
886 891
887 892 will only list functions and strings, excluding all other types of
888 893 variables. To find the proper type names, simply use type(var) at a
889 894 command line to see how python prints type names. For example:
890 895
891 896 In [1]: type('hello')\\
892 897 Out[1]: <type 'str'>
893 898
894 899 indicates that the type name for strings is 'str'.
895 900
896 901 %who always excludes executed names loaded through your configuration
897 902 file and things which are internal to IPython.
898 903
899 904 This is deliberate, as typically you may load many modules and the
900 905 purpose of %who is to show you only what you've manually defined."""
901 906
902 907 varlist = self.magic_who_ls(parameter_s)
903 908 if not varlist:
904 909 print 'Interactive namespace is empty.'
905 910 return
906 911
907 912 # if we have variables, move on...
908 913
909 914 # stupid flushing problem: when prompts have no separators, stdout is
910 915 # getting lost. I'm starting to think this is a python bug. I'm having
911 916 # to force a flush with a print because even a sys.stdout.flush
912 917 # doesn't seem to do anything!
913 918
914 919 count = 0
915 920 for i in varlist:
916 921 print i+'\t',
917 922 count += 1
918 923 if count > 8:
919 924 count = 0
920 925 print
921 926 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
922 927
923 928 print # well, this does force a flush at the expense of an extra \n
924 929
925 930 def magic_whos(self, parameter_s=''):
926 931 """Like %who, but gives some extra information about each variable.
927 932
928 933 The same type filtering of %who can be applied here.
929 934
930 935 For all variables, the type is printed. Additionally it prints:
931 936
932 937 - For {},[],(): their length.
933 938
934 939 - For Numeric arrays, a summary with shape, number of elements,
935 940 typecode and size in memory.
936 941
937 942 - Everything else: a string representation, snipping their middle if
938 943 too long."""
939 944
940 945 varnames = self.magic_who_ls(parameter_s)
941 946 if not varnames:
942 947 print 'Interactive namespace is empty.'
943 948 return
944 949
945 950 # if we have variables, move on...
946 951
947 952 # for these types, show len() instead of data:
948 953 seq_types = [types.DictType,types.ListType,types.TupleType]
949 954
950 955 # for Numeric arrays, display summary info
951 956 try:
952 957 import Numeric
953 958 except ImportError:
954 959 array_type = None
955 960 else:
956 961 array_type = Numeric.ArrayType.__name__
957 962
958 963 # Find all variable names and types so we can figure out column sizes
959 964 get_vars = lambda i: self.shell.user_ns[i]
960 965 type_name = lambda v: type(v).__name__
961 966 varlist = map(get_vars,varnames)
962 967
963 968 typelist = []
964 969 for vv in varlist:
965 970 tt = type_name(vv)
966 971 if tt=='instance':
967 972 typelist.append(str(vv.__class__))
968 973 else:
969 974 typelist.append(tt)
970 975
971 976 # column labels and # of spaces as separator
972 977 varlabel = 'Variable'
973 978 typelabel = 'Type'
974 979 datalabel = 'Data/Info'
975 980 colsep = 3
976 981 # variable format strings
977 982 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
978 983 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
979 984 aformat = "%s: %s elems, type `%s`, %s bytes"
980 985 # find the size of the columns to format the output nicely
981 986 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
982 987 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
983 988 # table header
984 989 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
985 990 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
986 991 # and the table itself
987 992 kb = 1024
988 993 Mb = 1048576 # kb**2
989 994 for vname,var,vtype in zip(varnames,varlist,typelist):
990 995 print itpl(vformat),
991 996 if vtype in seq_types:
992 997 print len(var)
993 998 elif vtype==array_type:
994 999 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
995 1000 vsize = Numeric.size(var)
996 1001 vbytes = vsize*var.itemsize()
997 1002 if vbytes < 100000:
998 1003 print aformat % (vshape,vsize,var.typecode(),vbytes)
999 1004 else:
1000 1005 print aformat % (vshape,vsize,var.typecode(),vbytes),
1001 1006 if vbytes < Mb:
1002 1007 print '(%s kb)' % (vbytes/kb,)
1003 1008 else:
1004 1009 print '(%s Mb)' % (vbytes/Mb,)
1005 1010 else:
1006 1011 vstr = str(var).replace('\n','\\n')
1007 1012 if len(vstr) < 50:
1008 1013 print vstr
1009 1014 else:
1010 1015 printpl(vfmt_short)
1011 1016
1012 1017 def magic_reset(self, parameter_s=''):
1013 1018 """Resets the namespace by removing all names defined by the user.
1014 1019
1015 1020 Input/Output history are left around in case you need them."""
1016 1021
1017 1022 ans = self.shell.ask_yes_no(
1018 1023 "Once deleted, variables cannot be recovered. Proceed (y/[n])? ")
1019 1024 if not ans:
1020 1025 print 'Nothing done.'
1021 1026 return
1022 1027 user_ns = self.shell.user_ns
1023 1028 for i in self.magic_who_ls():
1024 1029 del(user_ns[i])
1025 1030
1026 1031 def magic_config(self,parameter_s=''):
1027 1032 """Handle IPython's internal configuration.
1028 1033
1029 1034 If called without arguments, it will print IPython's complete internal
1030 1035 configuration.
1031 1036
1032 1037 If called with one argument, it will print the value of that key in
1033 1038 the configuration.
1034 1039
1035 1040 If called with more than one argument, the first is interpreted as a
1036 1041 key and the rest as a Python expression which gets eval()'d.
1037 1042
1038 1043 Examples:
1039 1044
1040 1045 In [1]: s='A Python string'
1041 1046
1042 1047 In [2]: !echo $s
1043 1048 A Python string
1044 1049
1045 1050 In [3]: config system_verbose True
1046 1051
1047 1052 In [4]: !echo $s
1048 1053 IPython system call: echo A Python string
1049 1054 A Python string
1050 1055
1051 1056 In [5]: %config system_header 'sys> '
1052 1057
1053 1058 In [6]: !echo $s
1054 1059 sys> echo A Python string
1055 1060 A Python string
1056 1061
1057 1062 # Notice the extra quotes to protect the string after interpolation:
1058 1063 In [7]: header = "'sys2> '"
1059 1064
1060 1065 In [8]: %config system_header $header
1061 1066
1062 1067 In [9]: !echo $s
1063 1068 sys2> echo A Python string
1064 1069 A Python string
1065 1070 """
1066 1071
1067 1072 args = parameter_s.split(None,1)
1068 1073 key = args[0]
1069 1074 if len(args)==1:
1070 1075 self.shell.ipconfig(key)
1071 1076 else:
1072 1077 self.shell.ipconfig(key,eval(args[1]))
1073 1078
1074 1079 def magic_logstart(self,parameter_s=''):
1075 1080 """Start logging anywhere in a session.
1076 1081
1077 1082 %logstart [-o|-r|-t] [log_name [log_mode]]
1078 1083
1079 1084 If no name is given, it defaults to a file named 'ipython_log.py' in your
1080 1085 current directory, in 'rotate' mode (see below).
1081 1086
1082 1087 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
1083 1088 history up to that point and then continues logging.
1084 1089
1085 1090 %logstart takes a second optional parameter: logging mode. This can be one
1086 1091 of (note that the modes are given unquoted):\\
1087 1092 append: well, that says it.\\
1088 1093 backup: rename (if exists) to name~ and start name.\\
1089 1094 global: single logfile in your home dir, appended to.\\
1090 1095 over : overwrite existing log.\\
1091 1096 rotate: create rotating logs name.1~, name.2~, etc.
1092 1097
1093 1098 Options:
1094 1099
1095 1100 -o: log also IPython's output. In this mode, all commands which
1096 1101 generate an Out[NN] prompt are recorded to the logfile, right after
1097 1102 their corresponding input line. The output lines are always
1098 1103 prepended with a '#[Out]# ' marker, so that the log remains valid
1099 1104 Python code.
1100 1105
1101 1106 Since this marker is always the same, filtering only the output from
1102 1107 a log is very easy, using for example a simple awk call:
1103 1108
1104 1109 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
1105 1110
1106 1111 -r: log 'raw' input. Normally, IPython's logs contain the processed
1107 1112 input, so that user lines are logged in their final form, converted
1108 1113 into valid Python. For example, %Exit is logged as
1109 1114 '_ip.magic("Exit"). If the -r flag is given, all input is logged
1110 1115 exactly as typed, with no transformations applied.
1111 1116
1112 1117 -t: put timestamps before each input line logged (these are put in
1113 1118 comments)."""
1114 1119
1115 1120 opts,par = self.parse_options(parameter_s,'ort')
1116 1121 log_output = 'o' in opts
1117 1122 log_raw_input = 'r' in opts
1118 1123 timestamp = 't' in opts
1119 1124
1120 1125 rc = self.shell.rc
1121 1126 logger = self.shell.logger
1122 1127
1123 1128 # if no args are given, the defaults set in the logger constructor by
1124 1129 # ipytohn remain valid
1125 1130 if par:
1126 1131 try:
1127 1132 logfname,logmode = par.split()
1128 1133 except:
1129 1134 logfname = par
1130 1135 logmode = 'backup'
1131 1136 else:
1132 1137 logfname = logger.logfname
1133 1138 logmode = logger.logmode
1134 1139 # put logfname into rc struct as if it had been called on the command
1135 1140 # line, so it ends up saved in the log header Save it in case we need
1136 1141 # to restore it...
1137 1142 old_logfile = rc.opts.get('logfile','')
1138 1143 if logfname:
1139 1144 logfname = os.path.expanduser(logfname)
1140 1145 rc.opts.logfile = logfname
1141 1146 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
1142 1147 try:
1143 1148 started = logger.logstart(logfname,loghead,logmode,
1144 1149 log_output,timestamp,log_raw_input)
1145 1150 except:
1146 1151 rc.opts.logfile = old_logfile
1147 1152 warn("Couldn't start log: %s" % sys.exc_info()[1])
1148 1153 else:
1149 1154 # log input history up to this point, optionally interleaving
1150 1155 # output if requested
1151 1156
1152 1157 if timestamp:
1153 1158 # disable timestamping for the previous history, since we've
1154 1159 # lost those already (no time machine here).
1155 1160 logger.timestamp = False
1156 1161
1157 1162 if log_raw_input:
1158 1163 input_hist = self.shell.input_hist_raw
1159 1164 else:
1160 1165 input_hist = self.shell.input_hist
1161 1166
1162 1167 if log_output:
1163 1168 log_write = logger.log_write
1164 1169 output_hist = self.shell.output_hist
1165 1170 for n in range(1,len(input_hist)-1):
1166 1171 log_write(input_hist[n].rstrip())
1167 1172 if n in output_hist:
1168 1173 log_write(repr(output_hist[n]),'output')
1169 1174 else:
1170 1175 logger.log_write(input_hist[1:])
1171 1176 if timestamp:
1172 1177 # re-enable timestamping
1173 1178 logger.timestamp = True
1174 1179
1175 1180 print ('Activating auto-logging. '
1176 1181 'Current session state plus future input saved.')
1177 1182 logger.logstate()
1178 1183
1179 1184 def magic_logoff(self,parameter_s=''):
1180 1185 """Temporarily stop logging.
1181 1186
1182 1187 You must have previously started logging."""
1183 1188 self.shell.logger.switch_log(0)
1184 1189
1185 1190 def magic_logon(self,parameter_s=''):
1186 1191 """Restart logging.
1187 1192
1188 1193 This function is for restarting logging which you've temporarily
1189 1194 stopped with %logoff. For starting logging for the first time, you
1190 1195 must use the %logstart function, which allows you to specify an
1191 1196 optional log filename."""
1192 1197
1193 1198 self.shell.logger.switch_log(1)
1194 1199
1195 1200 def magic_logstate(self,parameter_s=''):
1196 1201 """Print the status of the logging system."""
1197 1202
1198 1203 self.shell.logger.logstate()
1199 1204
1200 1205 def magic_pdb(self, parameter_s=''):
1201 1206 """Control the calling of the pdb interactive debugger.
1202 1207
1203 1208 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1204 1209 argument it works as a toggle.
1205 1210
1206 1211 When an exception is triggered, IPython can optionally call the
1207 1212 interactive pdb debugger after the traceback printout. %pdb toggles
1208 1213 this feature on and off."""
1209 1214
1210 1215 par = parameter_s.strip().lower()
1211 1216
1212 1217 if par:
1213 1218 try:
1214 1219 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1215 1220 except KeyError:
1216 1221 print ('Incorrect argument. Use on/1, off/0, '
1217 1222 'or nothing for a toggle.')
1218 1223 return
1219 1224 else:
1220 1225 # toggle
1221 1226 new_pdb = not self.shell.InteractiveTB.call_pdb
1222 1227
1223 1228 # set on the shell
1224 1229 self.shell.call_pdb = new_pdb
1225 1230 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1226 1231
1227 1232 def magic_prun(self, parameter_s ='',user_mode=1,
1228 1233 opts=None,arg_lst=None,prog_ns=None):
1229 1234
1230 1235 """Run a statement through the python code profiler.
1231 1236
1232 1237 Usage:\\
1233 1238 %prun [options] statement
1234 1239
1235 1240 The given statement (which doesn't require quote marks) is run via the
1236 1241 python profiler in a manner similar to the profile.run() function.
1237 1242 Namespaces are internally managed to work correctly; profile.run
1238 1243 cannot be used in IPython because it makes certain assumptions about
1239 1244 namespaces which do not hold under IPython.
1240 1245
1241 1246 Options:
1242 1247
1243 1248 -l <limit>: you can place restrictions on what or how much of the
1244 1249 profile gets printed. The limit value can be:
1245 1250
1246 1251 * A string: only information for function names containing this string
1247 1252 is printed.
1248 1253
1249 1254 * An integer: only these many lines are printed.
1250 1255
1251 1256 * A float (between 0 and 1): this fraction of the report is printed
1252 1257 (for example, use a limit of 0.4 to see the topmost 40% only).
1253 1258
1254 1259 You can combine several limits with repeated use of the option. For
1255 1260 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1256 1261 information about class constructors.
1257 1262
1258 1263 -r: return the pstats.Stats object generated by the profiling. This
1259 1264 object has all the information about the profile in it, and you can
1260 1265 later use it for further analysis or in other functions.
1261 1266
1262 1267 -s <key>: sort profile by given key. You can provide more than one key
1263 1268 by using the option several times: '-s key1 -s key2 -s key3...'. The
1264 1269 default sorting key is 'time'.
1265 1270
1266 1271 The following is copied verbatim from the profile documentation
1267 1272 referenced below:
1268 1273
1269 1274 When more than one key is provided, additional keys are used as
1270 1275 secondary criteria when the there is equality in all keys selected
1271 1276 before them.
1272 1277
1273 1278 Abbreviations can be used for any key names, as long as the
1274 1279 abbreviation is unambiguous. The following are the keys currently
1275 1280 defined:
1276 1281
1277 1282 Valid Arg Meaning\\
1278 1283 "calls" call count\\
1279 1284 "cumulative" cumulative time\\
1280 1285 "file" file name\\
1281 1286 "module" file name\\
1282 1287 "pcalls" primitive call count\\
1283 1288 "line" line number\\
1284 1289 "name" function name\\
1285 1290 "nfl" name/file/line\\
1286 1291 "stdname" standard name\\
1287 1292 "time" internal time
1288 1293
1289 1294 Note that all sorts on statistics are in descending order (placing
1290 1295 most time consuming items first), where as name, file, and line number
1291 1296 searches are in ascending order (i.e., alphabetical). The subtle
1292 1297 distinction between "nfl" and "stdname" is that the standard name is a
1293 1298 sort of the name as printed, which means that the embedded line
1294 1299 numbers get compared in an odd way. For example, lines 3, 20, and 40
1295 1300 would (if the file names were the same) appear in the string order
1296 1301 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1297 1302 line numbers. In fact, sort_stats("nfl") is the same as
1298 1303 sort_stats("name", "file", "line").
1299 1304
1300 1305 -T <filename>: save profile results as shown on screen to a text
1301 1306 file. The profile is still shown on screen.
1302 1307
1303 1308 -D <filename>: save (via dump_stats) profile statistics to given
1304 1309 filename. This data is in a format understod by the pstats module, and
1305 1310 is generated by a call to the dump_stats() method of profile
1306 1311 objects. The profile is still shown on screen.
1307 1312
1308 1313 If you want to run complete programs under the profiler's control, use
1309 1314 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1310 1315 contains profiler specific options as described here.
1311 1316
1312 1317 You can read the complete documentation for the profile module with:\\
1313 1318 In [1]: import profile; profile.help() """
1314 1319
1315 1320 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1316 1321 # protect user quote marks
1317 1322 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1318 1323
1319 1324 if user_mode: # regular user call
1320 1325 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1321 1326 list_all=1)
1322 1327 namespace = self.shell.user_ns
1323 1328 else: # called to run a program by %run -p
1324 1329 try:
1325 1330 filename = get_py_filename(arg_lst[0])
1326 1331 except IOError,msg:
1327 1332 error(msg)
1328 1333 return
1329 1334
1330 1335 arg_str = 'execfile(filename,prog_ns)'
1331 1336 namespace = locals()
1332 1337
1333 1338 opts.merge(opts_def)
1334 1339
1335 1340 prof = profile.Profile()
1336 1341 try:
1337 1342 prof = prof.runctx(arg_str,namespace,namespace)
1338 1343 sys_exit = ''
1339 1344 except SystemExit:
1340 1345 sys_exit = """*** SystemExit exception caught in code being profiled."""
1341 1346
1342 1347 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1343 1348
1344 1349 lims = opts.l
1345 1350 if lims:
1346 1351 lims = [] # rebuild lims with ints/floats/strings
1347 1352 for lim in opts.l:
1348 1353 try:
1349 1354 lims.append(int(lim))
1350 1355 except ValueError:
1351 1356 try:
1352 1357 lims.append(float(lim))
1353 1358 except ValueError:
1354 1359 lims.append(lim)
1355 1360
1356 1361 # trap output
1357 1362 sys_stdout = sys.stdout
1358 1363 stdout_trap = StringIO()
1359 1364 try:
1360 1365 sys.stdout = stdout_trap
1361 1366 stats.print_stats(*lims)
1362 1367 finally:
1363 1368 sys.stdout = sys_stdout
1364 1369 output = stdout_trap.getvalue()
1365 1370 output = output.rstrip()
1366 1371
1367 1372 page(output,screen_lines=self.shell.rc.screen_length)
1368 1373 print sys_exit,
1369 1374
1370 1375 dump_file = opts.D[0]
1371 1376 text_file = opts.T[0]
1372 1377 if dump_file:
1373 1378 prof.dump_stats(dump_file)
1374 1379 print '\n*** Profile stats marshalled to file',\
1375 1380 `dump_file`+'.',sys_exit
1376 1381 if text_file:
1377 1382 file(text_file,'w').write(output)
1378 1383 print '\n*** Profile printout saved to text file',\
1379 1384 `text_file`+'.',sys_exit
1380 1385
1381 1386 if opts.has_key('r'):
1382 1387 return stats
1383 1388 else:
1384 1389 return None
1385 1390
1386 1391 def magic_run(self, parameter_s ='',runner=None):
1387 1392 """Run the named file inside IPython as a program.
1388 1393
1389 1394 Usage:\\
1390 1395 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1391 1396
1392 1397 Parameters after the filename are passed as command-line arguments to
1393 1398 the program (put in sys.argv). Then, control returns to IPython's
1394 1399 prompt.
1395 1400
1396 1401 This is similar to running at a system prompt:\\
1397 1402 $ python file args\\
1398 1403 but with the advantage of giving you IPython's tracebacks, and of
1399 1404 loading all variables into your interactive namespace for further use
1400 1405 (unless -p is used, see below).
1401 1406
1402 1407 The file is executed in a namespace initially consisting only of
1403 1408 __name__=='__main__' and sys.argv constructed as indicated. It thus
1404 1409 sees its environment as if it were being run as a stand-alone
1405 1410 program. But after execution, the IPython interactive namespace gets
1406 1411 updated with all variables defined in the program (except for __name__
1407 1412 and sys.argv). This allows for very convenient loading of code for
1408 1413 interactive work, while giving each program a 'clean sheet' to run in.
1409 1414
1410 1415 Options:
1411 1416
1412 1417 -n: __name__ is NOT set to '__main__', but to the running file's name
1413 1418 without extension (as python does under import). This allows running
1414 1419 scripts and reloading the definitions in them without calling code
1415 1420 protected by an ' if __name__ == "__main__" ' clause.
1416 1421
1417 1422 -i: run the file in IPython's namespace instead of an empty one. This
1418 1423 is useful if you are experimenting with code written in a text editor
1419 1424 which depends on variables defined interactively.
1420 1425
1421 1426 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1422 1427 being run. This is particularly useful if IPython is being used to
1423 1428 run unittests, which always exit with a sys.exit() call. In such
1424 1429 cases you are interested in the output of the test results, not in
1425 1430 seeing a traceback of the unittest module.
1426 1431
1427 1432 -t: print timing information at the end of the run. IPython will give
1428 1433 you an estimated CPU time consumption for your script, which under
1429 1434 Unix uses the resource module to avoid the wraparound problems of
1430 1435 time.clock(). Under Unix, an estimate of time spent on system tasks
1431 1436 is also given (for Windows platforms this is reported as 0.0).
1432 1437
1433 1438 If -t is given, an additional -N<N> option can be given, where <N>
1434 1439 must be an integer indicating how many times you want the script to
1435 1440 run. The final timing report will include total and per run results.
1436 1441
1437 1442 For example (testing the script uniq_stable.py):
1438 1443
1439 1444 In [1]: run -t uniq_stable
1440 1445
1441 1446 IPython CPU timings (estimated):\\
1442 1447 User : 0.19597 s.\\
1443 1448 System: 0.0 s.\\
1444 1449
1445 1450 In [2]: run -t -N5 uniq_stable
1446 1451
1447 1452 IPython CPU timings (estimated):\\
1448 1453 Total runs performed: 5\\
1449 1454 Times : Total Per run\\
1450 1455 User : 0.910862 s, 0.1821724 s.\\
1451 1456 System: 0.0 s, 0.0 s.
1452 1457
1453 1458 -d: run your program under the control of pdb, the Python debugger.
1454 1459 This allows you to execute your program step by step, watch variables,
1455 1460 etc. Internally, what IPython does is similar to calling:
1456 1461
1457 1462 pdb.run('execfile("YOURFILENAME")')
1458 1463
1459 1464 with a breakpoint set on line 1 of your file. You can change the line
1460 1465 number for this automatic breakpoint to be <N> by using the -bN option
1461 1466 (where N must be an integer). For example:
1462 1467
1463 1468 %run -d -b40 myscript
1464 1469
1465 1470 will set the first breakpoint at line 40 in myscript.py. Note that
1466 1471 the first breakpoint must be set on a line which actually does
1467 1472 something (not a comment or docstring) for it to stop execution.
1468 1473
1469 1474 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1470 1475 first enter 'c' (without qoutes) to start execution up to the first
1471 1476 breakpoint.
1472 1477
1473 1478 Entering 'help' gives information about the use of the debugger. You
1474 1479 can easily see pdb's full documentation with "import pdb;pdb.help()"
1475 1480 at a prompt.
1476 1481
1477 1482 -p: run program under the control of the Python profiler module (which
1478 1483 prints a detailed report of execution times, function calls, etc).
1479 1484
1480 1485 You can pass other options after -p which affect the behavior of the
1481 1486 profiler itself. See the docs for %prun for details.
1482 1487
1483 1488 In this mode, the program's variables do NOT propagate back to the
1484 1489 IPython interactive namespace (because they remain in the namespace
1485 1490 where the profiler executes them).
1486 1491
1487 1492 Internally this triggers a call to %prun, see its documentation for
1488 1493 details on the options available specifically for profiling."""
1489 1494
1490 1495 # get arguments and set sys.argv for program to be run.
1491 1496 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1492 1497 mode='list',list_all=1)
1493 1498
1494 1499 try:
1495 1500 filename = get_py_filename(arg_lst[0])
1496 1501 except IndexError:
1497 1502 warn('you must provide at least a filename.')
1498 1503 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1499 1504 return
1500 1505 except IOError,msg:
1501 1506 error(msg)
1502 1507 return
1503 1508
1504 1509 # Control the response to exit() calls made by the script being run
1505 1510 exit_ignore = opts.has_key('e')
1506 1511
1507 1512 # Make sure that the running script gets a proper sys.argv as if it
1508 1513 # were run from a system shell.
1509 1514 save_argv = sys.argv # save it for later restoring
1510 1515 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1511 1516
1512 1517 if opts.has_key('i'):
1513 1518 prog_ns = self.shell.user_ns
1514 1519 __name__save = self.shell.user_ns['__name__']
1515 1520 prog_ns['__name__'] = '__main__'
1516 1521 else:
1517 1522 if opts.has_key('n'):
1518 1523 name = os.path.splitext(os.path.basename(filename))[0]
1519 1524 else:
1520 1525 name = '__main__'
1521 1526 prog_ns = {'__name__':name}
1522 1527
1523 1528 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
1524 1529 # set the __file__ global in the script's namespace
1525 1530 prog_ns['__file__'] = filename
1526 1531
1527 1532 # pickle fix. See iplib for an explanation. But we need to make sure
1528 1533 # that, if we overwrite __main__, we replace it at the end
1529 1534 if prog_ns['__name__'] == '__main__':
1530 1535 restore_main = sys.modules['__main__']
1531 1536 else:
1532 1537 restore_main = False
1533 1538
1534 1539 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1535 1540
1536 1541 stats = None
1537 1542 try:
1538 1543 if self.shell.has_readline:
1539 1544 self.shell.savehist()
1540 1545
1541 1546 if opts.has_key('p'):
1542 1547 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1543 1548 else:
1544 1549 if opts.has_key('d'):
1545 1550 deb = Debugger.Pdb(self.shell.rc.colors)
1546 1551 # reset Breakpoint state, which is moronically kept
1547 1552 # in a class
1548 1553 bdb.Breakpoint.next = 1
1549 1554 bdb.Breakpoint.bplist = {}
1550 1555 bdb.Breakpoint.bpbynumber = [None]
1551 1556 # Set an initial breakpoint to stop execution
1552 1557 maxtries = 10
1553 1558 bp = int(opts.get('b',[1])[0])
1554 1559 checkline = deb.checkline(filename,bp)
1555 1560 if not checkline:
1556 1561 for bp in range(bp+1,bp+maxtries+1):
1557 1562 if deb.checkline(filename,bp):
1558 1563 break
1559 1564 else:
1560 1565 msg = ("\nI failed to find a valid line to set "
1561 1566 "a breakpoint\n"
1562 1567 "after trying up to line: %s.\n"
1563 1568 "Please set a valid breakpoint manually "
1564 1569 "with the -b option." % bp)
1565 1570 error(msg)
1566 1571 return
1567 1572 # if we find a good linenumber, set the breakpoint
1568 1573 deb.do_break('%s:%s' % (filename,bp))
1569 1574 # Start file run
1570 1575 print "NOTE: Enter 'c' at the",
1571 1576 print "%s prompt to start your script." % deb.prompt
1572 1577 try:
1573 1578 deb.run('execfile("%s")' % filename,prog_ns)
1574 1579
1575 1580 except:
1576 1581 etype, value, tb = sys.exc_info()
1577 1582 # Skip three frames in the traceback: the %run one,
1578 1583 # one inside bdb.py, and the command-line typed by the
1579 1584 # user (run by exec in pdb itself).
1580 1585 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1581 1586 else:
1582 1587 if runner is None:
1583 1588 runner = self.shell.safe_execfile
1584 1589 if opts.has_key('t'):
1585 1590 try:
1586 1591 nruns = int(opts['N'][0])
1587 1592 if nruns < 1:
1588 1593 error('Number of runs must be >=1')
1589 1594 return
1590 1595 except (KeyError):
1591 1596 nruns = 1
1592 1597 if nruns == 1:
1593 1598 t0 = clock2()
1594 1599 runner(filename,prog_ns,prog_ns,
1595 1600 exit_ignore=exit_ignore)
1596 1601 t1 = clock2()
1597 1602 t_usr = t1[0]-t0[0]
1598 1603 t_sys = t1[1]-t1[1]
1599 1604 print "\nIPython CPU timings (estimated):"
1600 1605 print " User : %10s s." % t_usr
1601 1606 print " System: %10s s." % t_sys
1602 1607 else:
1603 1608 runs = range(nruns)
1604 1609 t0 = clock2()
1605 1610 for nr in runs:
1606 1611 runner(filename,prog_ns,prog_ns,
1607 1612 exit_ignore=exit_ignore)
1608 1613 t1 = clock2()
1609 1614 t_usr = t1[0]-t0[0]
1610 1615 t_sys = t1[1]-t1[1]
1611 1616 print "\nIPython CPU timings (estimated):"
1612 1617 print "Total runs performed:",nruns
1613 1618 print " Times : %10s %10s" % ('Total','Per run')
1614 1619 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1615 1620 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1616 1621
1617 1622 else:
1618 1623 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1619 1624 if opts.has_key('i'):
1620 1625 self.shell.user_ns['__name__'] = __name__save
1621 1626 else:
1622 1627 # update IPython interactive namespace
1623 1628 del prog_ns['__name__']
1624 1629 self.shell.user_ns.update(prog_ns)
1625 1630 finally:
1626 1631 sys.argv = save_argv
1627 1632 if restore_main:
1628 1633 sys.modules['__main__'] = restore_main
1629 1634 if self.shell.has_readline:
1630 1635 self.shell.readline.read_history_file(self.shell.histfile)
1631 1636
1632 1637 return stats
1633 1638
1634 1639 def magic_runlog(self, parameter_s =''):
1635 1640 """Run files as logs.
1636 1641
1637 1642 Usage:\\
1638 1643 %runlog file1 file2 ...
1639 1644
1640 1645 Run the named files (treating them as log files) in sequence inside
1641 1646 the interpreter, and return to the prompt. This is much slower than
1642 1647 %run because each line is executed in a try/except block, but it
1643 1648 allows running files with syntax errors in them.
1644 1649
1645 1650 Normally IPython will guess when a file is one of its own logfiles, so
1646 1651 you can typically use %run even for logs. This shorthand allows you to
1647 1652 force any file to be treated as a log file."""
1648 1653
1649 1654 for f in parameter_s.split():
1650 1655 self.shell.safe_execfile(f,self.shell.user_ns,
1651 1656 self.shell.user_ns,islog=1)
1652 1657
1653 1658 def magic_timeit(self, parameter_s =''):
1654 1659 """Time execution of a Python statement or expression
1655 1660
1656 1661 Usage:\\
1657 1662 %timeit [-n<N> -r<R> [-t|-c]] statement
1658 1663
1659 1664 Time execution of a Python statement or expression using the timeit
1660 1665 module.
1661 1666
1662 1667 Options:
1663 1668 -n<N>: execute the given statement <N> times in a loop. If this value
1664 1669 is not given, a fitting value is chosen.
1665 1670
1666 1671 -r<R>: repeat the loop iteration <R> times and take the best result.
1667 1672 Default: 3
1668 1673
1669 1674 -t: use time.time to measure the time, which is the default on Unix.
1670 1675 This function measures wall time.
1671 1676
1672 1677 -c: use time.clock to measure the time, which is the default on
1673 1678 Windows and measures wall time. On Unix, resource.getrusage is used
1674 1679 instead and returns the CPU user time.
1675 1680
1676 1681 -p<P>: use a precision of <P> digits to display the timing result.
1677 1682 Default: 3
1678 1683
1679 1684
1680 1685 Examples:\\
1681 1686 In [1]: %timeit pass
1682 1687 10000000 loops, best of 3: 53.3 ns per loop
1683 1688
1684 1689 In [2]: u = None
1685 1690
1686 1691 In [3]: %timeit u is None
1687 1692 10000000 loops, best of 3: 184 ns per loop
1688 1693
1689 1694 In [4]: %timeit -r 4 u == None
1690 1695 1000000 loops, best of 4: 242 ns per loop
1691 1696
1692 1697 In [5]: import time
1693 1698
1694 1699 In [6]: %timeit -n1 time.sleep(2)
1695 1700 1 loops, best of 3: 2 s per loop
1696 1701
1697 1702
1698 1703 The times reported by %timeit will be slightly higher than those
1699 1704 reported by the timeit.py script when variables are accessed. This is
1700 1705 due to the fact that %timeit executes the statement in the namespace
1701 1706 of the shell, compared with timeit.py, which uses a single setup
1702 1707 statement to import function or create variables. Generally, the bias
1703 1708 does not matter as long as results from timeit.py are not mixed with
1704 1709 those from %timeit."""
1705 1710
1706 1711 import timeit
1707 1712 import math
1708 1713
1709 1714 units = ["s", "ms", "\xc2\xb5s", "ns"]
1710 1715 scaling = [1, 1e3, 1e6, 1e9]
1711 1716
1712 1717 opts, stmt = self.parse_options(parameter_s,'n:r:tcp:',
1713 1718 posix=False)
1714 1719 if stmt == "":
1715 1720 return
1716 1721 timefunc = timeit.default_timer
1717 1722 number = int(getattr(opts, "n", 0))
1718 1723 repeat = int(getattr(opts, "r", timeit.default_repeat))
1719 1724 precision = int(getattr(opts, "p", 3))
1720 1725 if hasattr(opts, "t"):
1721 1726 timefunc = time.time
1722 1727 if hasattr(opts, "c"):
1723 1728 timefunc = clock
1724 1729
1725 1730 timer = timeit.Timer(timer=timefunc)
1726 1731 # this code has tight coupling to the inner workings of timeit.Timer,
1727 1732 # but is there a better way to achieve that the code stmt has access
1728 1733 # to the shell namespace?
1729 1734
1730 1735 src = timeit.template % {'stmt': timeit.reindent(stmt, 8),
1731 1736 'setup': "pass"}
1732 1737 code = compile(src, "<magic-timeit>", "exec")
1733 1738 ns = {}
1734 1739 exec code in self.shell.user_ns, ns
1735 1740 timer.inner = ns["inner"]
1736 1741
1737 1742 if number == 0:
1738 1743 # determine number so that 0.2 <= total time < 2.0
1739 1744 number = 1
1740 1745 for i in range(1, 10):
1741 1746 number *= 10
1742 1747 if timer.timeit(number) >= 0.2:
1743 1748 break
1744 1749
1745 1750 best = min(timer.repeat(repeat, number)) / number
1746 1751
1747 1752 if best > 0.0:
1748 1753 order = min(-int(math.floor(math.log10(best)) // 3), 3)
1749 1754 else:
1750 1755 order = 3
1751 1756 print "%d loops, best of %d: %.*g %s per loop" % (number, repeat,
1752 1757 precision,
1753 1758 best * scaling[order],
1754 1759 units[order])
1755 1760
1756 1761 def magic_time(self,parameter_s = ''):
1757 1762 """Time execution of a Python statement or expression.
1758 1763
1759 1764 The CPU and wall clock times are printed, and the value of the
1760 1765 expression (if any) is returned. Note that under Win32, system time
1761 1766 is always reported as 0, since it can not be measured.
1762 1767
1763 1768 This function provides very basic timing functionality. In Python
1764 1769 2.3, the timeit module offers more control and sophistication, so this
1765 1770 could be rewritten to use it (patches welcome).
1766 1771
1767 1772 Some examples:
1768 1773
1769 1774 In [1]: time 2**128
1770 1775 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1771 1776 Wall time: 0.00
1772 1777 Out[1]: 340282366920938463463374607431768211456L
1773 1778
1774 1779 In [2]: n = 1000000
1775 1780
1776 1781 In [3]: time sum(range(n))
1777 1782 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1778 1783 Wall time: 1.37
1779 1784 Out[3]: 499999500000L
1780 1785
1781 1786 In [4]: time print 'hello world'
1782 1787 hello world
1783 1788 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1784 1789 Wall time: 0.00
1785 1790 """
1786 1791
1787 1792 # fail immediately if the given expression can't be compiled
1788 1793 try:
1789 1794 mode = 'eval'
1790 1795 code = compile(parameter_s,'<timed eval>',mode)
1791 1796 except SyntaxError:
1792 1797 mode = 'exec'
1793 1798 code = compile(parameter_s,'<timed exec>',mode)
1794 1799 # skew measurement as little as possible
1795 1800 glob = self.shell.user_ns
1796 1801 clk = clock2
1797 1802 wtime = time.time
1798 1803 # time execution
1799 1804 wall_st = wtime()
1800 1805 if mode=='eval':
1801 1806 st = clk()
1802 1807 out = eval(code,glob)
1803 1808 end = clk()
1804 1809 else:
1805 1810 st = clk()
1806 1811 exec code in glob
1807 1812 end = clk()
1808 1813 out = None
1809 1814 wall_end = wtime()
1810 1815 # Compute actual times and report
1811 1816 wall_time = wall_end-wall_st
1812 1817 cpu_user = end[0]-st[0]
1813 1818 cpu_sys = end[1]-st[1]
1814 1819 cpu_tot = cpu_user+cpu_sys
1815 1820 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1816 1821 (cpu_user,cpu_sys,cpu_tot)
1817 1822 print "Wall time: %.2f" % wall_time
1818 1823 return out
1819 1824
1820 1825 def magic_macro(self,parameter_s = ''):
1821 1826 """Define a set of input lines as a macro for future re-execution.
1822 1827
1823 1828 Usage:\\
1824 1829 %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...
1825 1830
1826 1831 Options:
1827 1832
1828 1833 -r: use 'raw' input. By default, the 'processed' history is used,
1829 1834 so that magics are loaded in their transformed version to valid
1830 1835 Python. If this option is given, the raw input as typed as the
1831 1836 command line is used instead.
1832 1837
1833 1838 This will define a global variable called `name` which is a string
1834 1839 made of joining the slices and lines you specify (n1,n2,... numbers
1835 1840 above) from your input history into a single string. This variable
1836 1841 acts like an automatic function which re-executes those lines as if
1837 1842 you had typed them. You just type 'name' at the prompt and the code
1838 1843 executes.
1839 1844
1840 1845 The notation for indicating number ranges is: n1-n2 means 'use line
1841 1846 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1842 1847 using the lines numbered 5,6 and 7.
1843 1848
1844 1849 Note: as a 'hidden' feature, you can also use traditional python slice
1845 1850 notation, where N:M means numbers N through M-1.
1846 1851
1847 1852 For example, if your history contains (%hist prints it):
1848 1853
1849 1854 44: x=1\\
1850 1855 45: y=3\\
1851 1856 46: z=x+y\\
1852 1857 47: print x\\
1853 1858 48: a=5\\
1854 1859 49: print 'x',x,'y',y\\
1855 1860
1856 1861 you can create a macro with lines 44 through 47 (included) and line 49
1857 1862 called my_macro with:
1858 1863
1859 1864 In [51]: %macro my_macro 44-47 49
1860 1865
1861 1866 Now, typing `my_macro` (without quotes) will re-execute all this code
1862 1867 in one pass.
1863 1868
1864 1869 You don't need to give the line-numbers in order, and any given line
1865 1870 number can appear multiple times. You can assemble macros with any
1866 1871 lines from your input history in any order.
1867 1872
1868 1873 The macro is a simple object which holds its value in an attribute,
1869 1874 but IPython's display system checks for macros and executes them as
1870 1875 code instead of printing them when you type their name.
1871 1876
1872 1877 You can view a macro's contents by explicitly printing it with:
1873 1878
1874 1879 'print macro_name'.
1875 1880
1876 1881 For one-off cases which DON'T contain magic function calls in them you
1877 1882 can obtain similar results by explicitly executing slices from your
1878 1883 input history with:
1879 1884
1880 1885 In [60]: exec In[44:48]+In[49]"""
1881 1886
1882 1887 opts,args = self.parse_options(parameter_s,'r',mode='list')
1883 1888 name,ranges = args[0], args[1:]
1884 1889 #print 'rng',ranges # dbg
1885 1890 lines = self.extract_input_slices(ranges,opts.has_key('r'))
1886 1891 macro = Macro(lines)
1887 1892 self.shell.user_ns.update({name:macro})
1888 1893 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1889 1894 print 'Macro contents:'
1890 1895 print macro,
1891 1896
1892 1897 def magic_save(self,parameter_s = ''):
1893 1898 """Save a set of lines to a given filename.
1894 1899
1895 1900 Usage:\\
1896 1901 %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...
1897 1902
1898 1903 Options:
1899 1904
1900 1905 -r: use 'raw' input. By default, the 'processed' history is used,
1901 1906 so that magics are loaded in their transformed version to valid
1902 1907 Python. If this option is given, the raw input as typed as the
1903 1908 command line is used instead.
1904 1909
1905 1910 This function uses the same syntax as %macro for line extraction, but
1906 1911 instead of creating a macro it saves the resulting string to the
1907 1912 filename you specify.
1908 1913
1909 1914 It adds a '.py' extension to the file if you don't do so yourself, and
1910 1915 it asks for confirmation before overwriting existing files."""
1911 1916
1912 1917 opts,args = self.parse_options(parameter_s,'r',mode='list')
1913 1918 fname,ranges = args[0], args[1:]
1914 1919 if not fname.endswith('.py'):
1915 1920 fname += '.py'
1916 1921 if os.path.isfile(fname):
1917 1922 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1918 1923 if ans.lower() not in ['y','yes']:
1919 1924 print 'Operation cancelled.'
1920 1925 return
1921 1926 cmds = ''.join(self.extract_input_slices(ranges,opts.has_key('r')))
1922 1927 f = file(fname,'w')
1923 1928 f.write(cmds)
1924 1929 f.close()
1925 1930 print 'The following commands were written to file `%s`:' % fname
1926 1931 print cmds
1927 1932
1928 1933 def _edit_macro(self,mname,macro):
1929 1934 """open an editor with the macro data in a file"""
1930 1935 filename = self.shell.mktempfile(macro.value)
1931 1936 self.shell.hooks.editor(filename)
1932 1937
1933 1938 # and make a new macro object, to replace the old one
1934 1939 mfile = open(filename)
1935 1940 mvalue = mfile.read()
1936 1941 mfile.close()
1937 1942 self.shell.user_ns[mname] = Macro(mvalue)
1938 1943
1939 1944 def magic_ed(self,parameter_s=''):
1940 1945 """Alias to %edit."""
1941 1946 return self.magic_edit(parameter_s)
1942 1947
1943 1948 def magic_edit(self,parameter_s='',last_call=['','']):
1944 1949 """Bring up an editor and execute the resulting code.
1945 1950
1946 1951 Usage:
1947 1952 %edit [options] [args]
1948 1953
1949 1954 %edit runs IPython's editor hook. The default version of this hook is
1950 1955 set to call the __IPYTHON__.rc.editor command. This is read from your
1951 1956 environment variable $EDITOR. If this isn't found, it will default to
1952 1957 vi under Linux/Unix and to notepad under Windows. See the end of this
1953 1958 docstring for how to change the editor hook.
1954 1959
1955 1960 You can also set the value of this editor via the command line option
1956 1961 '-editor' or in your ipythonrc file. This is useful if you wish to use
1957 1962 specifically for IPython an editor different from your typical default
1958 1963 (and for Windows users who typically don't set environment variables).
1959 1964
1960 1965 This command allows you to conveniently edit multi-line code right in
1961 1966 your IPython session.
1962 1967
1963 1968 If called without arguments, %edit opens up an empty editor with a
1964 1969 temporary file and will execute the contents of this file when you
1965 1970 close it (don't forget to save it!).
1966 1971
1967 1972
1968 1973 Options:
1969 1974
1970 1975 -n <number>: open the editor at a specified line number. By default,
1971 1976 the IPython editor hook uses the unix syntax 'editor +N filename', but
1972 1977 you can configure this by providing your own modified hook if your
1973 1978 favorite editor supports line-number specifications with a different
1974 1979 syntax.
1975 1980
1976 1981 -p: this will call the editor with the same data as the previous time
1977 1982 it was used, regardless of how long ago (in your current session) it
1978 1983 was.
1979 1984
1980 1985 -r: use 'raw' input. This option only applies to input taken from the
1981 1986 user's history. By default, the 'processed' history is used, so that
1982 1987 magics are loaded in their transformed version to valid Python. If
1983 1988 this option is given, the raw input as typed as the command line is
1984 1989 used instead. When you exit the editor, it will be executed by
1985 1990 IPython's own processor.
1986 1991
1987 1992 -x: do not execute the edited code immediately upon exit. This is
1988 1993 mainly useful if you are editing programs which need to be called with
1989 1994 command line arguments, which you can then do using %run.
1990 1995
1991 1996
1992 1997 Arguments:
1993 1998
1994 1999 If arguments are given, the following possibilites exist:
1995 2000
1996 2001 - The arguments are numbers or pairs of colon-separated numbers (like
1997 2002 1 4:8 9). These are interpreted as lines of previous input to be
1998 2003 loaded into the editor. The syntax is the same of the %macro command.
1999 2004
2000 2005 - If the argument doesn't start with a number, it is evaluated as a
2001 2006 variable and its contents loaded into the editor. You can thus edit
2002 2007 any string which contains python code (including the result of
2003 2008 previous edits).
2004 2009
2005 2010 - If the argument is the name of an object (other than a string),
2006 2011 IPython will try to locate the file where it was defined and open the
2007 2012 editor at the point where it is defined. You can use `%edit function`
2008 2013 to load an editor exactly at the point where 'function' is defined,
2009 2014 edit it and have the file be executed automatically.
2010 2015
2011 2016 If the object is a macro (see %macro for details), this opens up your
2012 2017 specified editor with a temporary file containing the macro's data.
2013 2018 Upon exit, the macro is reloaded with the contents of the file.
2014 2019
2015 2020 Note: opening at an exact line is only supported under Unix, and some
2016 2021 editors (like kedit and gedit up to Gnome 2.8) do not understand the
2017 2022 '+NUMBER' parameter necessary for this feature. Good editors like
2018 2023 (X)Emacs, vi, jed, pico and joe all do.
2019 2024
2020 2025 - If the argument is not found as a variable, IPython will look for a
2021 2026 file with that name (adding .py if necessary) and load it into the
2022 2027 editor. It will execute its contents with execfile() when you exit,
2023 2028 loading any code in the file into your interactive namespace.
2024 2029
2025 2030 After executing your code, %edit will return as output the code you
2026 2031 typed in the editor (except when it was an existing file). This way
2027 2032 you can reload the code in further invocations of %edit as a variable,
2028 2033 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
2029 2034 the output.
2030 2035
2031 2036 Note that %edit is also available through the alias %ed.
2032 2037
2033 2038 This is an example of creating a simple function inside the editor and
2034 2039 then modifying it. First, start up the editor:
2035 2040
2036 2041 In [1]: ed\\
2037 2042 Editing... done. Executing edited code...\\
2038 2043 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
2039 2044
2040 2045 We can then call the function foo():
2041 2046
2042 2047 In [2]: foo()\\
2043 2048 foo() was defined in an editing session
2044 2049
2045 2050 Now we edit foo. IPython automatically loads the editor with the
2046 2051 (temporary) file where foo() was previously defined:
2047 2052
2048 2053 In [3]: ed foo\\
2049 2054 Editing... done. Executing edited code...
2050 2055
2051 2056 And if we call foo() again we get the modified version:
2052 2057
2053 2058 In [4]: foo()\\
2054 2059 foo() has now been changed!
2055 2060
2056 2061 Here is an example of how to edit a code snippet successive
2057 2062 times. First we call the editor:
2058 2063
2059 2064 In [8]: ed\\
2060 2065 Editing... done. Executing edited code...\\
2061 2066 hello\\
2062 2067 Out[8]: "print 'hello'\\n"
2063 2068
2064 2069 Now we call it again with the previous output (stored in _):
2065 2070
2066 2071 In [9]: ed _\\
2067 2072 Editing... done. Executing edited code...\\
2068 2073 hello world\\
2069 2074 Out[9]: "print 'hello world'\\n"
2070 2075
2071 2076 Now we call it with the output #8 (stored in _8, also as Out[8]):
2072 2077
2073 2078 In [10]: ed _8\\
2074 2079 Editing... done. Executing edited code...\\
2075 2080 hello again\\
2076 2081 Out[10]: "print 'hello again'\\n"
2077 2082
2078 2083
2079 2084 Changing the default editor hook:
2080 2085
2081 2086 If you wish to write your own editor hook, you can put it in a
2082 2087 configuration file which you load at startup time. The default hook
2083 2088 is defined in the IPython.hooks module, and you can use that as a
2084 2089 starting example for further modifications. That file also has
2085 2090 general instructions on how to set a new hook for use once you've
2086 2091 defined it."""
2087 2092
2088 2093 # FIXME: This function has become a convoluted mess. It needs a
2089 2094 # ground-up rewrite with clean, simple logic.
2090 2095
2091 2096 def make_filename(arg):
2092 2097 "Make a filename from the given args"
2093 2098 try:
2094 2099 filename = get_py_filename(arg)
2095 2100 except IOError:
2096 2101 if args.endswith('.py'):
2097 2102 filename = arg
2098 2103 else:
2099 2104 filename = None
2100 2105 return filename
2101 2106
2102 2107 # custom exceptions
2103 2108 class DataIsObject(Exception): pass
2104 2109
2105 2110 opts,args = self.parse_options(parameter_s,'prxn:')
2106 2111 # Set a few locals from the options for convenience:
2107 2112 opts_p = opts.has_key('p')
2108 2113 opts_r = opts.has_key('r')
2109 2114
2110 2115 # Default line number value
2111 2116 lineno = opts.get('n',None)
2112 2117
2113 2118 if opts_p:
2114 2119 args = '_%s' % last_call[0]
2115 2120 if not self.shell.user_ns.has_key(args):
2116 2121 args = last_call[1]
2117 2122
2118 2123 # use last_call to remember the state of the previous call, but don't
2119 2124 # let it be clobbered by successive '-p' calls.
2120 2125 try:
2121 2126 last_call[0] = self.shell.outputcache.prompt_count
2122 2127 if not opts_p:
2123 2128 last_call[1] = parameter_s
2124 2129 except:
2125 2130 pass
2126 2131
2127 2132 # by default this is done with temp files, except when the given
2128 2133 # arg is a filename
2129 2134 use_temp = 1
2130 2135
2131 2136 if re.match(r'\d',args):
2132 2137 # Mode where user specifies ranges of lines, like in %macro.
2133 2138 # This means that you can't edit files whose names begin with
2134 2139 # numbers this way. Tough.
2135 2140 ranges = args.split()
2136 2141 data = ''.join(self.extract_input_slices(ranges,opts_r))
2137 2142 elif args.endswith('.py'):
2138 2143 filename = make_filename(args)
2139 2144 data = ''
2140 2145 use_temp = 0
2141 2146 elif args:
2142 2147 try:
2143 2148 # Load the parameter given as a variable. If not a string,
2144 2149 # process it as an object instead (below)
2145 2150
2146 2151 #print '*** args',args,'type',type(args) # dbg
2147 2152 data = eval(args,self.shell.user_ns)
2148 2153 if not type(data) in StringTypes:
2149 2154 raise DataIsObject
2150 2155
2151 2156 except (NameError,SyntaxError):
2152 2157 # given argument is not a variable, try as a filename
2153 2158 filename = make_filename(args)
2154 2159 if filename is None:
2155 2160 warn("Argument given (%s) can't be found as a variable "
2156 2161 "or as a filename." % args)
2157 2162 return
2158 2163
2159 2164 data = ''
2160 2165 use_temp = 0
2161 2166 except DataIsObject:
2162 2167
2163 2168 # macros have a special edit function
2164 2169 if isinstance(data,Macro):
2165 2170 self._edit_macro(args,data)
2166 2171 return
2167 2172
2168 2173 # For objects, try to edit the file where they are defined
2169 2174 try:
2170 2175 filename = inspect.getabsfile(data)
2171 2176 datafile = 1
2172 2177 except TypeError:
2173 2178 filename = make_filename(args)
2174 2179 datafile = 1
2175 2180 warn('Could not find file where `%s` is defined.\n'
2176 2181 'Opening a file named `%s`' % (args,filename))
2177 2182 # Now, make sure we can actually read the source (if it was in
2178 2183 # a temp file it's gone by now).
2179 2184 if datafile:
2180 2185 try:
2181 2186 if lineno is None:
2182 2187 lineno = inspect.getsourcelines(data)[1]
2183 2188 except IOError:
2184 2189 filename = make_filename(args)
2185 2190 if filename is None:
2186 2191 warn('The file `%s` where `%s` was defined cannot '
2187 2192 'be read.' % (filename,data))
2188 2193 return
2189 2194 use_temp = 0
2190 2195 else:
2191 2196 data = ''
2192 2197
2193 2198 if use_temp:
2194 2199 filename = self.shell.mktempfile(data)
2195 2200 print 'IPython will make a temporary file named:',filename
2196 2201
2197 2202 # do actual editing here
2198 2203 print 'Editing...',
2199 2204 sys.stdout.flush()
2200 2205 self.shell.hooks.editor(filename,lineno)
2201 2206 if opts.has_key('x'): # -x prevents actual execution
2202 2207 print
2203 2208 else:
2204 2209 print 'done. Executing edited code...'
2205 2210 if opts_r:
2206 2211 self.shell.runlines(file_read(filename))
2207 2212 else:
2208 2213 self.shell.safe_execfile(filename,self.shell.user_ns)
2209 2214 if use_temp:
2210 2215 try:
2211 2216 return open(filename).read()
2212 2217 except IOError,msg:
2213 2218 if msg.filename == filename:
2214 2219 warn('File not found. Did you forget to save?')
2215 2220 return
2216 2221 else:
2217 2222 self.shell.showtraceback()
2218 2223
2219 2224 def magic_xmode(self,parameter_s = ''):
2220 2225 """Switch modes for the exception handlers.
2221 2226
2222 2227 Valid modes: Plain, Context and Verbose.
2223 2228
2224 2229 If called without arguments, acts as a toggle."""
2225 2230
2226 2231 def xmode_switch_err(name):
2227 2232 warn('Error changing %s exception modes.\n%s' %
2228 2233 (name,sys.exc_info()[1]))
2229 2234
2230 2235 shell = self.shell
2231 2236 new_mode = parameter_s.strip().capitalize()
2232 2237 try:
2233 2238 shell.InteractiveTB.set_mode(mode=new_mode)
2234 2239 print 'Exception reporting mode:',shell.InteractiveTB.mode
2235 2240 except:
2236 2241 xmode_switch_err('user')
2237 2242
2238 2243 # threaded shells use a special handler in sys.excepthook
2239 2244 if shell.isthreaded:
2240 2245 try:
2241 2246 shell.sys_excepthook.set_mode(mode=new_mode)
2242 2247 except:
2243 2248 xmode_switch_err('threaded')
2244 2249
2245 2250 def magic_colors(self,parameter_s = ''):
2246 2251 """Switch color scheme for prompts, info system and exception handlers.
2247 2252
2248 2253 Currently implemented schemes: NoColor, Linux, LightBG.
2249 2254
2250 2255 Color scheme names are not case-sensitive."""
2251 2256
2252 2257 def color_switch_err(name):
2253 2258 warn('Error changing %s color schemes.\n%s' %
2254 2259 (name,sys.exc_info()[1]))
2255 2260
2256 2261
2257 2262 new_scheme = parameter_s.strip()
2258 2263 if not new_scheme:
2259 2264 print 'You must specify a color scheme.'
2260 2265 return
2261 2266 import IPython.rlineimpl as readline
2262 2267 if not readline.have_readline:
2263 2268 msg = """\
2264 2269 Proper color support under MS Windows requires the pyreadline library.
2265 2270 You can find it at:
2266 2271 http://ipython.scipy.org/moin/PyReadline/Intro
2267 2272 Gary's readline needs the ctypes module, from:
2268 2273 http://starship.python.net/crew/theller/ctypes
2269 2274 (Note that ctypes is already part of Python versions 2.5 and newer).
2270 2275
2271 2276 Defaulting color scheme to 'NoColor'"""
2272 2277 new_scheme = 'NoColor'
2273 2278 warn(msg)
2274 2279 # local shortcut
2275 2280 shell = self.shell
2276 2281
2277 2282 # Set prompt colors
2278 2283 try:
2279 2284 shell.outputcache.set_colors(new_scheme)
2280 2285 except:
2281 2286 color_switch_err('prompt')
2282 2287 else:
2283 2288 shell.rc.colors = \
2284 2289 shell.outputcache.color_table.active_scheme_name
2285 2290 # Set exception colors
2286 2291 try:
2287 2292 shell.InteractiveTB.set_colors(scheme = new_scheme)
2288 2293 shell.SyntaxTB.set_colors(scheme = new_scheme)
2289 2294 except:
2290 2295 color_switch_err('exception')
2291 2296
2292 2297 # threaded shells use a verbose traceback in sys.excepthook
2293 2298 if shell.isthreaded:
2294 2299 try:
2295 2300 shell.sys_excepthook.set_colors(scheme=new_scheme)
2296 2301 except:
2297 2302 color_switch_err('system exception handler')
2298 2303
2299 2304 # Set info (for 'object?') colors
2300 2305 if shell.rc.color_info:
2301 2306 try:
2302 2307 shell.inspector.set_active_scheme(new_scheme)
2303 2308 except:
2304 2309 color_switch_err('object inspector')
2305 2310 else:
2306 2311 shell.inspector.set_active_scheme('NoColor')
2307 2312
2308 2313 def magic_color_info(self,parameter_s = ''):
2309 2314 """Toggle color_info.
2310 2315
2311 2316 The color_info configuration parameter controls whether colors are
2312 2317 used for displaying object details (by things like %psource, %pfile or
2313 2318 the '?' system). This function toggles this value with each call.
2314 2319
2315 2320 Note that unless you have a fairly recent pager (less works better
2316 2321 than more) in your system, using colored object information displays
2317 2322 will not work properly. Test it and see."""
2318 2323
2319 2324 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2320 2325 self.magic_colors(self.shell.rc.colors)
2321 2326 print 'Object introspection functions have now coloring:',
2322 2327 print ['OFF','ON'][self.shell.rc.color_info]
2323 2328
2324 2329 def magic_Pprint(self, parameter_s=''):
2325 2330 """Toggle pretty printing on/off."""
2326 2331
2327 2332 self.shell.rc.pprint = 1 - self.shell.rc.pprint
2328 2333 print 'Pretty printing has been turned', \
2329 2334 ['OFF','ON'][self.shell.rc.pprint]
2330 2335
2331 2336 def magic_exit(self, parameter_s=''):
2332 2337 """Exit IPython, confirming if configured to do so.
2333 2338
2334 2339 You can configure whether IPython asks for confirmation upon exit by
2335 2340 setting the confirm_exit flag in the ipythonrc file."""
2336 2341
2337 2342 self.shell.exit()
2338 2343
2339 2344 def magic_quit(self, parameter_s=''):
2340 2345 """Exit IPython, confirming if configured to do so (like %exit)"""
2341 2346
2342 2347 self.shell.exit()
2343 2348
2344 2349 def magic_Exit(self, parameter_s=''):
2345 2350 """Exit IPython without confirmation."""
2346 2351
2347 2352 self.shell.exit_now = True
2348 2353
2349 2354 def magic_Quit(self, parameter_s=''):
2350 2355 """Exit IPython without confirmation (like %Exit)."""
2351 2356
2352 2357 self.shell.exit_now = True
2353 2358
2354 2359 #......................................................................
2355 2360 # Functions to implement unix shell-type things
2356 2361
2357 2362 def magic_alias(self, parameter_s = ''):
2358 2363 """Define an alias for a system command.
2359 2364
2360 2365 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2361 2366
2362 2367 Then, typing 'alias_name params' will execute the system command 'cmd
2363 2368 params' (from your underlying operating system).
2364 2369
2365 2370 Aliases have lower precedence than magic functions and Python normal
2366 2371 variables, so if 'foo' is both a Python variable and an alias, the
2367 2372 alias can not be executed until 'del foo' removes the Python variable.
2368 2373
2369 2374 You can use the %l specifier in an alias definition to represent the
2370 2375 whole line when the alias is called. For example:
2371 2376
2372 2377 In [2]: alias all echo "Input in brackets: <%l>"\\
2373 2378 In [3]: all hello world\\
2374 2379 Input in brackets: <hello world>
2375 2380
2376 2381 You can also define aliases with parameters using %s specifiers (one
2377 2382 per parameter):
2378 2383
2379 2384 In [1]: alias parts echo first %s second %s\\
2380 2385 In [2]: %parts A B\\
2381 2386 first A second B\\
2382 2387 In [3]: %parts A\\
2383 2388 Incorrect number of arguments: 2 expected.\\
2384 2389 parts is an alias to: 'echo first %s second %s'
2385 2390
2386 2391 Note that %l and %s are mutually exclusive. You can only use one or
2387 2392 the other in your aliases.
2388 2393
2389 2394 Aliases expand Python variables just like system calls using ! or !!
2390 2395 do: all expressions prefixed with '$' get expanded. For details of
2391 2396 the semantic rules, see PEP-215:
2392 2397 http://www.python.org/peps/pep-0215.html. This is the library used by
2393 2398 IPython for variable expansion. If you want to access a true shell
2394 2399 variable, an extra $ is necessary to prevent its expansion by IPython:
2395 2400
2396 2401 In [6]: alias show echo\\
2397 2402 In [7]: PATH='A Python string'\\
2398 2403 In [8]: show $PATH\\
2399 2404 A Python string\\
2400 2405 In [9]: show $$PATH\\
2401 2406 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2402 2407
2403 2408 You can use the alias facility to acess all of $PATH. See the %rehash
2404 2409 and %rehashx functions, which automatically create aliases for the
2405 2410 contents of your $PATH.
2406 2411
2407 2412 If called with no parameters, %alias prints the current alias table."""
2408 2413
2409 2414 par = parameter_s.strip()
2410 2415 if not par:
2411 2416 stored = self.db.get('stored_aliases', {} )
2412 2417 atab = self.shell.alias_table
2413 2418 aliases = atab.keys()
2414 2419 aliases.sort()
2415 2420 res = []
2416 2421 showlast = []
2417 2422 for alias in aliases:
2418 2423 tgt = atab[alias][1]
2419 2424 # 'interesting' aliases
2420 2425 if (alias in stored or
2421 2426 alias != os.path.splitext(tgt)[0] or
2422 2427 ' ' in tgt):
2423 2428 showlast.append((alias, tgt))
2424 2429 else:
2425 2430 res.append((alias, tgt ))
2426 2431
2427 2432 # show most interesting aliases last
2428 2433 res.extend(showlast)
2429 2434 print "Total number of aliases:",len(aliases)
2430 2435 return res
2431 2436 try:
2432 2437 alias,cmd = par.split(None,1)
2433 2438 except:
2434 2439 print OInspect.getdoc(self.magic_alias)
2435 2440 else:
2436 2441 nargs = cmd.count('%s')
2437 2442 if nargs>0 and cmd.find('%l')>=0:
2438 2443 error('The %s and %l specifiers are mutually exclusive '
2439 2444 'in alias definitions.')
2440 2445 else: # all looks OK
2441 2446 self.shell.alias_table[alias] = (nargs,cmd)
2442 2447 self.shell.alias_table_validate(verbose=0)
2443 2448 # end magic_alias
2444 2449
2445 2450 def magic_unalias(self, parameter_s = ''):
2446 2451 """Remove an alias"""
2447 2452
2448 2453 aname = parameter_s.strip()
2449 2454 if aname in self.shell.alias_table:
2450 2455 del self.shell.alias_table[aname]
2451 2456 stored = self.db.get('stored_aliases', {} )
2452 2457 if aname in stored:
2453 2458 print "Removing %stored alias",aname
2454 2459 del stored[aname]
2455 2460 self.db['stored_aliases'] = stored
2456 2461
2457 2462 def magic_rehash(self, parameter_s = ''):
2458 2463 """Update the alias table with all entries in $PATH.
2459 2464
2460 2465 This version does no checks on execute permissions or whether the
2461 2466 contents of $PATH are truly files (instead of directories or something
2462 2467 else). For such a safer (but slower) version, use %rehashx."""
2463 2468
2464 2469 # This function (and rehashx) manipulate the alias_table directly
2465 2470 # rather than calling magic_alias, for speed reasons. A rehash on a
2466 2471 # typical Linux box involves several thousand entries, so efficiency
2467 2472 # here is a top concern.
2468 2473
2469 2474 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2470 2475 alias_table = self.shell.alias_table
2471 2476 for pdir in path:
2472 2477 for ff in os.listdir(pdir):
2473 2478 # each entry in the alias table must be (N,name), where
2474 2479 # N is the number of positional arguments of the alias.
2475 2480 alias_table[ff] = (0,ff)
2476 2481 # Make sure the alias table doesn't contain keywords or builtins
2477 2482 self.shell.alias_table_validate()
2478 2483 # Call again init_auto_alias() so we get 'rm -i' and other modified
2479 2484 # aliases since %rehash will probably clobber them
2480 2485 self.shell.init_auto_alias()
2481 2486
2482 2487 def magic_rehashx(self, parameter_s = ''):
2483 2488 """Update the alias table with all executable files in $PATH.
2484 2489
2485 2490 This version explicitly checks that every entry in $PATH is a file
2486 2491 with execute access (os.X_OK), so it is much slower than %rehash.
2487 2492
2488 2493 Under Windows, it checks executability as a match agains a
2489 2494 '|'-separated string of extensions, stored in the IPython config
2490 2495 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2491 2496
2492 2497 path = [os.path.abspath(os.path.expanduser(p)) for p in
2493 2498 os.environ['PATH'].split(os.pathsep)]
2494 2499 path = filter(os.path.isdir,path)
2495 2500
2496 2501 alias_table = self.shell.alias_table
2497 2502 syscmdlist = []
2498 2503 if os.name == 'posix':
2499 2504 isexec = lambda fname:os.path.isfile(fname) and \
2500 2505 os.access(fname,os.X_OK)
2501 2506 else:
2502 2507
2503 2508 try:
2504 2509 winext = os.environ['pathext'].replace(';','|').replace('.','')
2505 2510 except KeyError:
2506 2511 winext = 'exe|com|bat|py'
2507 2512 if 'py' not in winext:
2508 2513 winext += '|py'
2509 2514 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2510 2515 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2511 2516 savedir = os.getcwd()
2512 2517 try:
2513 2518 # write the whole loop for posix/Windows so we don't have an if in
2514 2519 # the innermost part
2515 2520 if os.name == 'posix':
2516 2521 for pdir in path:
2517 2522 os.chdir(pdir)
2518 2523 for ff in os.listdir(pdir):
2519 2524 if isexec(ff) and ff not in self.shell.no_alias:
2520 2525 # each entry in the alias table must be (N,name),
2521 2526 # where N is the number of positional arguments of the
2522 2527 # alias.
2523 2528 alias_table[ff] = (0,ff)
2524 2529 syscmdlist.append(ff)
2525 2530 else:
2526 2531 for pdir in path:
2527 2532 os.chdir(pdir)
2528 2533 for ff in os.listdir(pdir):
2529 2534 if isexec(ff) and os.path.splitext(ff)[0] not in self.shell.no_alias:
2530 2535 alias_table[execre.sub(r'\1',ff)] = (0,ff)
2531 2536 syscmdlist.append(ff)
2532 2537 # Make sure the alias table doesn't contain keywords or builtins
2533 2538 self.shell.alias_table_validate()
2534 2539 # Call again init_auto_alias() so we get 'rm -i' and other
2535 2540 # modified aliases since %rehashx will probably clobber them
2536 2541 self.shell.init_auto_alias()
2537 2542 db = self.getapi().db
2538 2543 db['syscmdlist'] = syscmdlist
2539 2544 finally:
2540 2545 os.chdir(savedir)
2541 2546
2542 2547 def magic_pwd(self, parameter_s = ''):
2543 2548 """Return the current working directory path."""
2544 2549 return os.getcwd()
2545 2550
2546 2551 def magic_cd(self, parameter_s=''):
2547 2552 """Change the current working directory.
2548 2553
2549 2554 This command automatically maintains an internal list of directories
2550 2555 you visit during your IPython session, in the variable _dh. The
2551 2556 command %dhist shows this history nicely formatted.
2552 2557
2553 2558 Usage:
2554 2559
2555 2560 cd 'dir': changes to directory 'dir'.
2556 2561
2557 2562 cd -: changes to the last visited directory.
2558 2563
2559 2564 cd -<n>: changes to the n-th directory in the directory history.
2560 2565
2561 2566 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2562 2567 (note: cd <bookmark_name> is enough if there is no
2563 2568 directory <bookmark_name>, but a bookmark with the name exists.)
2564 2569
2565 2570 Options:
2566 2571
2567 2572 -q: quiet. Do not print the working directory after the cd command is
2568 2573 executed. By default IPython's cd command does print this directory,
2569 2574 since the default prompts do not display path information.
2570 2575
2571 2576 Note that !cd doesn't work for this purpose because the shell where
2572 2577 !command runs is immediately discarded after executing 'command'."""
2573 2578
2574 2579 parameter_s = parameter_s.strip()
2575 2580 #bkms = self.shell.persist.get("bookmarks",{})
2576 2581
2577 2582 numcd = re.match(r'(-)(\d+)$',parameter_s)
2578 2583 # jump in directory history by number
2579 2584 if numcd:
2580 2585 nn = int(numcd.group(2))
2581 2586 try:
2582 2587 ps = self.shell.user_ns['_dh'][nn]
2583 2588 except IndexError:
2584 2589 print 'The requested directory does not exist in history.'
2585 2590 return
2586 2591 else:
2587 2592 opts = {}
2588 2593 else:
2589 2594 #turn all non-space-escaping backslashes to slashes,
2590 2595 # for c:\windows\directory\names\
2591 2596 parameter_s = re.sub(r'\\(?! )','/', parameter_s)
2592 2597 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2593 2598 # jump to previous
2594 2599 if ps == '-':
2595 2600 try:
2596 2601 ps = self.shell.user_ns['_dh'][-2]
2597 2602 except IndexError:
2598 2603 print 'No previous directory to change to.'
2599 2604 return
2600 2605 # jump to bookmark if needed
2601 2606 else:
2602 2607 if not os.path.isdir(ps) or opts.has_key('b'):
2603 2608 bkms = self.db.get('bookmarks', {})
2604 2609
2605 2610 if bkms.has_key(ps):
2606 2611 target = bkms[ps]
2607 2612 print '(bookmark:%s) -> %s' % (ps,target)
2608 2613 ps = target
2609 2614 else:
2610 2615 if opts.has_key('b'):
2611 2616 error("Bookmark '%s' not found. "
2612 2617 "Use '%%bookmark -l' to see your bookmarks." % ps)
2613 2618 return
2614 2619
2615 2620 # at this point ps should point to the target dir
2616 2621 if ps:
2617 2622 try:
2618 2623 os.chdir(os.path.expanduser(ps))
2619 2624 ttitle = ("IPy:" + (
2620 2625 os.getcwd() == '/' and '/' or os.path.basename(os.getcwd())))
2621 2626 platutils.set_term_title(ttitle)
2622 2627 except OSError:
2623 2628 print sys.exc_info()[1]
2624 2629 else:
2625 2630 self.shell.user_ns['_dh'].append(os.getcwd())
2626 2631 else:
2627 2632 os.chdir(self.shell.home_dir)
2628 2633 platutils.set_term_title("IPy:~")
2629 2634 self.shell.user_ns['_dh'].append(os.getcwd())
2630 2635 if not 'q' in opts:
2631 2636 print self.shell.user_ns['_dh'][-1]
2632 2637
2633 2638 def magic_dhist(self, parameter_s=''):
2634 2639 """Print your history of visited directories.
2635 2640
2636 2641 %dhist -> print full history\\
2637 2642 %dhist n -> print last n entries only\\
2638 2643 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2639 2644
2640 2645 This history is automatically maintained by the %cd command, and
2641 2646 always available as the global list variable _dh. You can use %cd -<n>
2642 2647 to go to directory number <n>."""
2643 2648
2644 2649 dh = self.shell.user_ns['_dh']
2645 2650 if parameter_s:
2646 2651 try:
2647 2652 args = map(int,parameter_s.split())
2648 2653 except:
2649 2654 self.arg_err(Magic.magic_dhist)
2650 2655 return
2651 2656 if len(args) == 1:
2652 2657 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2653 2658 elif len(args) == 2:
2654 2659 ini,fin = args
2655 2660 else:
2656 2661 self.arg_err(Magic.magic_dhist)
2657 2662 return
2658 2663 else:
2659 2664 ini,fin = 0,len(dh)
2660 2665 nlprint(dh,
2661 2666 header = 'Directory history (kept in _dh)',
2662 2667 start=ini,stop=fin)
2663 2668
2664 2669 def magic_env(self, parameter_s=''):
2665 2670 """List environment variables."""
2666 2671
2667 2672 return os.environ.data
2668 2673
2669 2674 def magic_pushd(self, parameter_s=''):
2670 2675 """Place the current dir on stack and change directory.
2671 2676
2672 2677 Usage:\\
2673 2678 %pushd ['dirname']
2674 2679
2675 2680 %pushd with no arguments does a %pushd to your home directory.
2676 2681 """
2677 2682 if parameter_s == '': parameter_s = '~'
2678 2683 dir_s = self.shell.dir_stack
2679 2684 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2680 2685 os.path.expanduser(self.shell.dir_stack[0]):
2681 2686 try:
2682 2687 self.magic_cd(parameter_s)
2683 2688 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2684 2689 self.magic_dirs()
2685 2690 except:
2686 2691 print 'Invalid directory'
2687 2692 else:
2688 2693 print 'You are already there!'
2689 2694
2690 2695 def magic_popd(self, parameter_s=''):
2691 2696 """Change to directory popped off the top of the stack.
2692 2697 """
2693 2698 if len (self.shell.dir_stack) > 1:
2694 2699 self.shell.dir_stack.pop(0)
2695 2700 self.magic_cd(self.shell.dir_stack[0])
2696 2701 print self.shell.dir_stack[0]
2697 2702 else:
2698 2703 print "You can't remove the starting directory from the stack:",\
2699 2704 self.shell.dir_stack
2700 2705
2701 2706 def magic_dirs(self, parameter_s=''):
2702 2707 """Return the current directory stack."""
2703 2708
2704 2709 return self.shell.dir_stack[:]
2705 2710
2706 2711 def magic_sc(self, parameter_s=''):
2707 2712 """Shell capture - execute a shell command and capture its output.
2708 2713
2709 2714 DEPRECATED. Suboptimal, retained for backwards compatibility.
2710 2715
2711 2716 You should use the form 'var = !command' instead. Example:
2712 2717
2713 2718 "%sc -l myfiles = ls ~" should now be written as
2714 2719
2715 2720 "myfiles = !ls ~"
2716 2721
2717 2722 myfiles.s, myfiles.l and myfiles.n still apply as documented
2718 2723 below.
2719 2724
2720 2725 --
2721 2726 %sc [options] varname=command
2722 2727
2723 2728 IPython will run the given command using commands.getoutput(), and
2724 2729 will then update the user's interactive namespace with a variable
2725 2730 called varname, containing the value of the call. Your command can
2726 2731 contain shell wildcards, pipes, etc.
2727 2732
2728 2733 The '=' sign in the syntax is mandatory, and the variable name you
2729 2734 supply must follow Python's standard conventions for valid names.
2730 2735
2731 2736 (A special format without variable name exists for internal use)
2732 2737
2733 2738 Options:
2734 2739
2735 2740 -l: list output. Split the output on newlines into a list before
2736 2741 assigning it to the given variable. By default the output is stored
2737 2742 as a single string.
2738 2743
2739 2744 -v: verbose. Print the contents of the variable.
2740 2745
2741 2746 In most cases you should not need to split as a list, because the
2742 2747 returned value is a special type of string which can automatically
2743 2748 provide its contents either as a list (split on newlines) or as a
2744 2749 space-separated string. These are convenient, respectively, either
2745 2750 for sequential processing or to be passed to a shell command.
2746 2751
2747 2752 For example:
2748 2753
2749 2754 # Capture into variable a
2750 2755 In [9]: sc a=ls *py
2751 2756
2752 2757 # a is a string with embedded newlines
2753 2758 In [10]: a
2754 2759 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2755 2760
2756 2761 # which can be seen as a list:
2757 2762 In [11]: a.l
2758 2763 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2759 2764
2760 2765 # or as a whitespace-separated string:
2761 2766 In [12]: a.s
2762 2767 Out[12]: 'setup.py win32_manual_post_install.py'
2763 2768
2764 2769 # a.s is useful to pass as a single command line:
2765 2770 In [13]: !wc -l $a.s
2766 2771 146 setup.py
2767 2772 130 win32_manual_post_install.py
2768 2773 276 total
2769 2774
2770 2775 # while the list form is useful to loop over:
2771 2776 In [14]: for f in a.l:
2772 2777 ....: !wc -l $f
2773 2778 ....:
2774 2779 146 setup.py
2775 2780 130 win32_manual_post_install.py
2776 2781
2777 2782 Similiarly, the lists returned by the -l option are also special, in
2778 2783 the sense that you can equally invoke the .s attribute on them to
2779 2784 automatically get a whitespace-separated string from their contents:
2780 2785
2781 2786 In [1]: sc -l b=ls *py
2782 2787
2783 2788 In [2]: b
2784 2789 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2785 2790
2786 2791 In [3]: b.s
2787 2792 Out[3]: 'setup.py win32_manual_post_install.py'
2788 2793
2789 2794 In summary, both the lists and strings used for ouptut capture have
2790 2795 the following special attributes:
2791 2796
2792 2797 .l (or .list) : value as list.
2793 2798 .n (or .nlstr): value as newline-separated string.
2794 2799 .s (or .spstr): value as space-separated string.
2795 2800 """
2796 2801
2797 2802 opts,args = self.parse_options(parameter_s,'lv')
2798 2803 # Try to get a variable name and command to run
2799 2804 try:
2800 2805 # the variable name must be obtained from the parse_options
2801 2806 # output, which uses shlex.split to strip options out.
2802 2807 var,_ = args.split('=',1)
2803 2808 var = var.strip()
2804 2809 # But the the command has to be extracted from the original input
2805 2810 # parameter_s, not on what parse_options returns, to avoid the
2806 2811 # quote stripping which shlex.split performs on it.
2807 2812 _,cmd = parameter_s.split('=',1)
2808 2813 except ValueError:
2809 2814 var,cmd = '',''
2810 2815 # If all looks ok, proceed
2811 2816 out,err = self.shell.getoutputerror(cmd)
2812 2817 if err:
2813 2818 print >> Term.cerr,err
2814 2819 if opts.has_key('l'):
2815 2820 out = SList(out.split('\n'))
2816 2821 else:
2817 2822 out = LSString(out)
2818 2823 if opts.has_key('v'):
2819 2824 print '%s ==\n%s' % (var,pformat(out))
2820 2825 if var:
2821 2826 self.shell.user_ns.update({var:out})
2822 2827 else:
2823 2828 return out
2824 2829
2825 2830 def magic_sx(self, parameter_s=''):
2826 2831 """Shell execute - run a shell command and capture its output.
2827 2832
2828 2833 %sx command
2829 2834
2830 2835 IPython will run the given command using commands.getoutput(), and
2831 2836 return the result formatted as a list (split on '\\n'). Since the
2832 2837 output is _returned_, it will be stored in ipython's regular output
2833 2838 cache Out[N] and in the '_N' automatic variables.
2834 2839
2835 2840 Notes:
2836 2841
2837 2842 1) If an input line begins with '!!', then %sx is automatically
2838 2843 invoked. That is, while:
2839 2844 !ls
2840 2845 causes ipython to simply issue system('ls'), typing
2841 2846 !!ls
2842 2847 is a shorthand equivalent to:
2843 2848 %sx ls
2844 2849
2845 2850 2) %sx differs from %sc in that %sx automatically splits into a list,
2846 2851 like '%sc -l'. The reason for this is to make it as easy as possible
2847 2852 to process line-oriented shell output via further python commands.
2848 2853 %sc is meant to provide much finer control, but requires more
2849 2854 typing.
2850 2855
2851 2856 3) Just like %sc -l, this is a list with special attributes:
2852 2857
2853 2858 .l (or .list) : value as list.
2854 2859 .n (or .nlstr): value as newline-separated string.
2855 2860 .s (or .spstr): value as whitespace-separated string.
2856 2861
2857 2862 This is very useful when trying to use such lists as arguments to
2858 2863 system commands."""
2859 2864
2860 2865 if parameter_s:
2861 2866 out,err = self.shell.getoutputerror(parameter_s)
2862 2867 if err:
2863 2868 print >> Term.cerr,err
2864 2869 return SList(out.split('\n'))
2865 2870
2866 2871 def magic_bg(self, parameter_s=''):
2867 2872 """Run a job in the background, in a separate thread.
2868 2873
2869 2874 For example,
2870 2875
2871 2876 %bg myfunc(x,y,z=1)
2872 2877
2873 2878 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2874 2879 execution starts, a message will be printed indicating the job
2875 2880 number. If your job number is 5, you can use
2876 2881
2877 2882 myvar = jobs.result(5) or myvar = jobs[5].result
2878 2883
2879 2884 to assign this result to variable 'myvar'.
2880 2885
2881 2886 IPython has a job manager, accessible via the 'jobs' object. You can
2882 2887 type jobs? to get more information about it, and use jobs.<TAB> to see
2883 2888 its attributes. All attributes not starting with an underscore are
2884 2889 meant for public use.
2885 2890
2886 2891 In particular, look at the jobs.new() method, which is used to create
2887 2892 new jobs. This magic %bg function is just a convenience wrapper
2888 2893 around jobs.new(), for expression-based jobs. If you want to create a
2889 2894 new job with an explicit function object and arguments, you must call
2890 2895 jobs.new() directly.
2891 2896
2892 2897 The jobs.new docstring also describes in detail several important
2893 2898 caveats associated with a thread-based model for background job
2894 2899 execution. Type jobs.new? for details.
2895 2900
2896 2901 You can check the status of all jobs with jobs.status().
2897 2902
2898 2903 The jobs variable is set by IPython into the Python builtin namespace.
2899 2904 If you ever declare a variable named 'jobs', you will shadow this
2900 2905 name. You can either delete your global jobs variable to regain
2901 2906 access to the job manager, or make a new name and assign it manually
2902 2907 to the manager (stored in IPython's namespace). For example, to
2903 2908 assign the job manager to the Jobs name, use:
2904 2909
2905 2910 Jobs = __builtins__.jobs"""
2906 2911
2907 2912 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2908 2913
2909 2914
2910 2915 def magic_bookmark(self, parameter_s=''):
2911 2916 """Manage IPython's bookmark system.
2912 2917
2913 2918 %bookmark <name> - set bookmark to current dir
2914 2919 %bookmark <name> <dir> - set bookmark to <dir>
2915 2920 %bookmark -l - list all bookmarks
2916 2921 %bookmark -d <name> - remove bookmark
2917 2922 %bookmark -r - remove all bookmarks
2918 2923
2919 2924 You can later on access a bookmarked folder with:
2920 2925 %cd -b <name>
2921 2926 or simply '%cd <name>' if there is no directory called <name> AND
2922 2927 there is such a bookmark defined.
2923 2928
2924 2929 Your bookmarks persist through IPython sessions, but they are
2925 2930 associated with each profile."""
2926 2931
2927 2932 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2928 2933 if len(args) > 2:
2929 2934 error('You can only give at most two arguments')
2930 2935 return
2931 2936
2932 2937 bkms = self.db.get('bookmarks',{})
2933 2938
2934 2939 if opts.has_key('d'):
2935 2940 try:
2936 2941 todel = args[0]
2937 2942 except IndexError:
2938 2943 error('You must provide a bookmark to delete')
2939 2944 else:
2940 2945 try:
2941 2946 del bkms[todel]
2942 2947 except:
2943 2948 error("Can't delete bookmark '%s'" % todel)
2944 2949 elif opts.has_key('r'):
2945 2950 bkms = {}
2946 2951 elif opts.has_key('l'):
2947 2952 bks = bkms.keys()
2948 2953 bks.sort()
2949 2954 if bks:
2950 2955 size = max(map(len,bks))
2951 2956 else:
2952 2957 size = 0
2953 2958 fmt = '%-'+str(size)+'s -> %s'
2954 2959 print 'Current bookmarks:'
2955 2960 for bk in bks:
2956 2961 print fmt % (bk,bkms[bk])
2957 2962 else:
2958 2963 if not args:
2959 2964 error("You must specify the bookmark name")
2960 2965 elif len(args)==1:
2961 2966 bkms[args[0]] = os.getcwd()
2962 2967 elif len(args)==2:
2963 2968 bkms[args[0]] = args[1]
2964 2969 self.db['bookmarks'] = bkms
2965 2970
2966 2971 def magic_pycat(self, parameter_s=''):
2967 2972 """Show a syntax-highlighted file through a pager.
2968 2973
2969 2974 This magic is similar to the cat utility, but it will assume the file
2970 2975 to be Python source and will show it with syntax highlighting. """
2971 2976
2972 2977 try:
2973 2978 filename = get_py_filename(parameter_s)
2974 2979 cont = file_read(filename)
2975 2980 except IOError:
2976 2981 try:
2977 2982 cont = eval(parameter_s,self.user_ns)
2978 2983 except NameError:
2979 2984 cont = None
2980 2985 if cont is None:
2981 2986 print "Error: no such file or variable"
2982 2987 return
2983 2988
2984 2989 page(self.shell.pycolorize(cont),
2985 2990 screen_lines=self.shell.rc.screen_length)
2986 2991
2987 2992 def magic_cpaste(self, parameter_s=''):
2988 2993 """Allows you to paste & execute a pre-formatted code block from clipboard
2989 2994
2990 2995 You must terminate the block with '--' (two minus-signs) alone on the
2991 2996 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
2992 2997 is the new sentinel for this operation)
2993 2998
2994 2999 The block is dedented prior to execution to enable execution of
2995 3000 method definitions. '>' characters at the beginning of a line is
2996 3001 ignored, to allow pasting directly from e-mails. The executed block
2997 3002 is also assigned to variable named 'pasted_block' for later editing
2998 3003 with '%edit pasted_block'.
2999 3004
3000 3005 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
3001 3006 This assigns the pasted block to variable 'foo' as string, without
3002 3007 dedenting or executing it.
3003 3008
3004 3009 Do not be alarmed by garbled output on Windows (it's a readline bug).
3005 3010 Just press enter and type -- (and press enter again) and the block
3006 3011 will be what was just pasted.
3007 3012
3008 3013 IPython statements (magics, shell escapes) are not supported (yet).
3009 3014 """
3010 3015 opts,args = self.parse_options(parameter_s,'s:',mode='string')
3011 3016 par = args.strip()
3012 3017 sentinel = opts.get('s','--')
3013 3018
3014 3019 from IPython import iplib
3015 3020 lines = []
3016 3021 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
3017 3022 while 1:
3018 3023 l = iplib.raw_input_original(':')
3019 3024 if l ==sentinel:
3020 3025 break
3021 3026 lines.append(l.lstrip('>'))
3022 3027 block = "\n".join(lines) + '\n'
3023 3028 #print "block:\n",block
3024 3029 if not par:
3025 3030 b = textwrap.dedent(block)
3026 3031 exec b in self.user_ns
3027 3032 self.user_ns['pasted_block'] = b
3028 3033 else:
3029 3034 self.user_ns[par] = block
3030 3035 print "Block assigned to '%s'" % par
3031 3036
3032 3037 def magic_quickref(self,arg):
3033 3038 """ Show a quick reference sheet """
3034 3039 import IPython.usage
3035 3040 qr = IPython.usage.quick_reference + self.magic_magic('-brief')
3036 3041
3037 3042 page(qr)
3038 3043
3039 3044 def magic_upgrade(self,arg):
3040 3045 """ Upgrade your IPython installation
3041 3046
3042 3047 This will copy the config files that don't yet exist in your
3043 3048 ipython dir from the system config dir. Use this after upgrading
3044 3049 IPython if you don't wish to delete your .ipython dir.
3045 3050
3046 3051 Call with -nolegacy to get rid of ipythonrc* files (recommended for
3047 3052 new users)
3048 3053
3049 3054 """
3050 3055 ip = self.getapi()
3051 3056 ipinstallation = path(IPython.__file__).dirname()
3052 3057 upgrade_script = '%s "%s"' % (sys.executable,ipinstallation / 'upgrade_dir.py')
3053 3058 src_config = ipinstallation / 'UserConfig'
3054 3059 userdir = path(ip.options.ipythondir)
3055 3060 cmd = '%s "%s" "%s"' % (upgrade_script, src_config, userdir)
3056 3061 print ">",cmd
3057 3062 shell(cmd)
3058 3063 if arg == '-nolegacy':
3059 3064 legacy = userdir.files('ipythonrc*')
3060 3065 print "Nuking legacy files:",legacy
3061 3066
3062 3067 [p.remove() for p in legacy]
3063 3068 suffix = (sys.platform == 'win32' and '.ini' or '')
3064 3069 (userdir / ('ipythonrc' + suffix)).write_text('# Empty, see ipy_user_conf.py\n')
3065 3070
3066 3071
3067 3072 # end Magic
@@ -1,5953 +1,5968 b''
1
1 2 2006-11-21 Ville Vainio <vivainio@gmail.com>
2 3
3 4 * upgrade_dir.py: Now actually overwrites a nonmodified user file
4 5 with one from UserConfig.
5 6
6 7 * ipy_profile_sh.py: Add dummy "depth" to var_expand lambda,
7 8 it was missing which broke the sh profile.
8 9
9 10 * completer.py: file completer now uses explicit '/' instead
10 11 of os.path.join, expansion of 'foo' was broken on win32
11 12 if there was one directory with name 'foobar'.
12 13
14 * A bunch of patches from Kirill Smelkov:
15
16 * [patch 9/9] doc: point bug-tracker URL to IPythons trac-tickets.
17
18 * [patch 7/9] Implement %page -r (page in raw mode) -
19
20 * [patch 5/9] ScientificPython webpage has moved
21
22 * [patch 4/9] The manual mentions %ds, should be %dhist
23
24 * [patch 3/9] Kill old bits from %prun doc.
25
26 * [patch 1/9] Fix typos here and there.
27
13 28 2006-11-08 Ville Vainio <vivainio@gmail.com>
14 29
15 30 * completer.py (attr_matches): catch all exceptions raised
16 31 by eval of expr with dots.
17 32
18 33 2006-11-07 Fernando Perez <Fernando.Perez@colorado.edu>
19 34
20 35 * IPython/iplib.py (runsource): Prepend an 'if 1:' to the user
21 36 input if it starts with whitespace. This allows you to paste
22 37 indented input from any editor without manually having to type in
23 38 the 'if 1:', which is convenient when working interactively.
24 39 Slightly modifed version of a patch by Bo Peng
25 40 <bpeng-AT-rice.edu>.
26 41
27 42 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
28 43
29 44 * IPython/irunner.py (main): modified irunner so it automatically
30 45 recognizes the right runner to use based on the extension (.py for
31 46 python, .ipy for ipython and .sage for sage).
32 47
33 48 * IPython/iplib.py (InteractiveShell.ipconfig): new builtin, also
34 49 visible in ipapi as ip.config(), to programatically control the
35 50 internal rc object. There's an accompanying %config magic for
36 51 interactive use, which has been enhanced to match the
37 52 funtionality in ipconfig.
38 53
39 54 * IPython/Magic.py (magic_system_verbose): Change %system_verbose
40 55 so it's not just a toggle, it now takes an argument. Add support
41 56 for a customizable header when making system calls, as the new
42 57 system_header variable in the ipythonrc file.
43 58
44 59 2006-11-03 Walter Doerwald <walter@livinglogic.de>
45 60
46 61 * IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now
47 62 generic functions (using Philip J. Eby's simplegeneric package).
48 63 This makes it possible to customize the display of third-party classes
49 64 without having to monkeypatch them. xiter() no longer supports a mode
50 65 argument and the XMode class has been removed. The same functionality can
51 66 be implemented via IterAttributeDescriptor and IterMethodDescriptor.
52 67 One consequence of the switch to generic functions is that xrepr() and
53 68 xattrs() implementation must define the default value for the mode
54 69 argument themselves and xattrs() implementations must return real
55 70 descriptors.
56 71
57 72 * IPython/external: This new subpackage will contain all third-party
58 73 packages that are bundled with IPython. (The first one is simplegeneric).
59 74
60 75 * IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent
61 76 directory which as been dropped in r1703.
62 77
63 78 * IPython/Extensions/ipipe.py (iless): Fixed.
64 79
65 80 * IPython/Extensions/ibrowse: Fixed sorting under Python 2.3.
66 81
67 82 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
68 83
69 84 * IPython/iplib.py (InteractiveShell.var_expand): fix stack
70 85 handling in variable expansion so that shells and magics recognize
71 86 function local scopes correctly. Bug reported by Brian.
72 87
73 88 * scripts/ipython: remove the very first entry in sys.path which
74 89 Python auto-inserts for scripts, so that sys.path under IPython is
75 90 as similar as possible to that under plain Python.
76 91
77 92 * IPython/completer.py (IPCompleter.file_matches): Fix
78 93 tab-completion so that quotes are not closed unless the completion
79 94 is unambiguous. After a request by Stefan. Minor cleanups in
80 95 ipy_stock_completers.
81 96
82 97 2006-11-02 Ville Vainio <vivainio@gmail.com>
83 98
84 99 * ipy_stock_completers.py: Add %run and %cd completers.
85 100
86 101 * completer.py: Try running custom completer for both
87 102 "foo" and "%foo" if the command is just "foo". Ignore case
88 103 when filtering possible completions.
89 104
90 105 * UserConfig/ipy_user_conf.py: install stock completers as default
91 106
92 107 * iplib.py (history_saving_wrapper), debugger(), ipy_pydb.py:
93 108 simplified readline history save / restore through a wrapper
94 109 function
95 110
96 111
97 112 2006-10-31 Ville Vainio <vivainio@gmail.com>
98 113
99 114 * strdispatch.py, completer.py, ipy_stock_completers.py:
100 115 Allow str_key ("command") in completer hooks. Implement
101 116 trivial completer for 'import' (stdlib modules only). Rename
102 117 ipy_linux_package_managers.py to ipy_stock_completers.py.
103 118 SVN completer.
104 119
105 120 * Extensions/ledit.py: %magic line editor for easily and
106 121 incrementally manipulating lists of strings. The magic command
107 122 name is %led.
108 123
109 124 2006-10-30 Ville Vainio <vivainio@gmail.com>
110 125
111 126 * Debugger.py, iplib.py (debugger()): Add last set of Rocky
112 127 Bernsteins's patches for pydb integration.
113 128 http://bashdb.sourceforge.net/pydb/
114 129
115 130 * strdispatch.py, iplib.py, completer.py, IPython/__init__.py,
116 131 Extensions/ipy_linux_package_managers.py, hooks.py: Implement
117 132 custom completer hook to allow the users to implement their own
118 133 completers. See ipy_linux_package_managers.py for example. The
119 134 hook name is 'complete_command'.
120 135
121 136 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
122 137
123 138 * IPython/UserConfig/ipythonrc-scipy: minor cleanups to remove old
124 139 Numeric leftovers.
125 140
126 141 * ipython.el (py-execute-region): apply Stefan's patch to fix
127 142 garbled results if the python shell hasn't been previously started.
128 143
129 144 * IPython/genutils.py (arg_split): moved to genutils, since it's a
130 145 pretty generic function and useful for other things.
131 146
132 147 * IPython/OInspect.py (getsource): Add customizable source
133 148 extractor. After a request/patch form W. Stein (SAGE).
134 149
135 150 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
136 151 window size to a more reasonable value from what pexpect does,
137 152 since their choice causes wrapping bugs with long input lines.
138 153
139 154 2006-10-28 Ville Vainio <vivainio@gmail.com>
140 155
141 156 * Magic.py (%run): Save and restore the readline history from
142 157 file around %run commands to prevent side effects from
143 158 %runned programs that might use readline (e.g. pydb).
144 159
145 160 * extensions/ipy_pydb.py: Adds %pydb magic when imported, for
146 161 invoking the pydb enhanced debugger.
147 162
148 163 2006-10-23 Walter Doerwald <walter@livinglogic.de>
149 164
150 165 * IPython/Extensions/ipipe.py (ifile): Remove all methods that
151 166 call the base class method and propagate the return value to
152 167 ifile. This is now done by path itself.
153 168
154 169 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
155 170
156 171 * IPython/ipapi.py (IPApi.__init__): Added new entry to public
157 172 api: set_crash_handler(), to expose the ability to change the
158 173 internal crash handler.
159 174
160 175 * IPython/CrashHandler.py (CrashHandler.__init__): abstract out
161 176 the various parameters of the crash handler so that apps using
162 177 IPython as their engine can customize crash handling. Ipmlemented
163 178 at the request of SAGE.
164 179
165 180 2006-10-14 Ville Vainio <vivainio@gmail.com>
166 181
167 182 * Magic.py, ipython.el: applied first "safe" part of Rocky
168 183 Bernstein's patch set for pydb integration.
169 184
170 185 * Magic.py (%unalias, %alias): %store'd aliases can now be
171 186 removed with '%unalias'. %alias w/o args now shows most
172 187 interesting (stored / manually defined) aliases last
173 188 where they catch the eye w/o scrolling.
174 189
175 190 * Magic.py (%rehashx), ext_rehashdir.py: files with
176 191 'py' extension are always considered executable, even
177 192 when not in PATHEXT environment variable.
178 193
179 194 2006-10-12 Ville Vainio <vivainio@gmail.com>
180 195
181 196 * jobctrl.py: Add new "jobctrl" extension for spawning background
182 197 processes with "&find /". 'import jobctrl' to try it out. Requires
183 198 'subprocess' module, standard in python 2.4+.
184 199
185 200 * iplib.py (expand_aliases, handle_alias): Aliases expand transitively,
186 201 so if foo -> bar and bar -> baz, then foo -> baz.
187 202
188 203 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
189 204
190 205 * IPython/Magic.py (Magic.parse_options): add a new posix option
191 206 to allow parsing of input args in magics that doesn't strip quotes
192 207 (if posix=False). This also closes %timeit bug reported by
193 208 Stefan.
194 209
195 210 2006-10-03 Ville Vainio <vivainio@gmail.com>
196 211
197 212 * iplib.py (raw_input, interact): Return ValueError catching for
198 213 raw_input. Fixes infinite loop for sys.stdin.close() or
199 214 sys.stdout.close().
200 215
201 216 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
202 217
203 218 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
204 219 to help in handling doctests. irunner is now pretty useful for
205 220 running standalone scripts and simulate a full interactive session
206 221 in a format that can be then pasted as a doctest.
207 222
208 223 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
209 224 on top of the default (useless) ones. This also fixes the nasty
210 225 way in which 2.5's Quitter() exits (reverted [1785]).
211 226
212 227 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
213 228 2.5.
214 229
215 230 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
216 231 color scheme is updated as well when color scheme is changed
217 232 interactively.
218 233
219 234 2006-09-27 Ville Vainio <vivainio@gmail.com>
220 235
221 236 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
222 237 infinite loop and just exit. It's a hack, but will do for a while.
223 238
224 239 2006-08-25 Walter Doerwald <walter@livinglogic.de>
225 240
226 241 * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to
227 242 the constructor, this makes it possible to get a list of only directories
228 243 or only files.
229 244
230 245 2006-08-12 Ville Vainio <vivainio@gmail.com>
231 246
232 247 * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,
233 248 they broke unittest
234 249
235 250 2006-08-11 Ville Vainio <vivainio@gmail.com>
236 251
237 252 * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch
238 253 by resolving issue properly, i.e. by inheriting FakeModule
239 254 from types.ModuleType. Pickling ipython interactive data
240 255 should still work as usual (testing appreciated).
241 256
242 257 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
243 258
244 259 * IPython/OInspect.py: monkeypatch inspect from the stdlib if
245 260 running under python 2.3 with code from 2.4 to fix a bug with
246 261 help(). Reported by the Debian maintainers, Norbert Tretkowski
247 262 <norbert-AT-tretkowski.de> and Alexandre Fayolle
248 263 <afayolle-AT-debian.org>.
249 264
250 265 2006-08-04 Walter Doerwald <walter@livinglogic.de>
251 266
252 267 * IPython/Extensions/ibrowse.py: Fixed the help message in the footer
253 268 (which was displaying "quit" twice).
254 269
255 270 2006-07-28 Walter Doerwald <walter@livinglogic.de>
256 271
257 272 * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using
258 273 the mode argument).
259 274
260 275 2006-07-27 Walter Doerwald <walter@livinglogic.de>
261 276
262 277 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
263 278 not running under IPython.
264 279
265 280 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
266 281 and make it iterable (iterating over the attribute itself). Add two new
267 282 magic strings for __xattrs__(): If the string starts with "-", the attribute
268 283 will not be displayed in ibrowse's detail view (but it can still be
269 284 iterated over). This makes it possible to add attributes that are large
270 285 lists or generator methods to the detail view. Replace magic attribute names
271 286 and _attrname() and _getattr() with "descriptors": For each type of magic
272 287 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
273 288 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
274 289 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
275 290 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
276 291 are still supported.
277 292
278 293 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
279 294 fails in ibrowse.fetch(), the exception object is added as the last item
280 295 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
281 296 a generator throws an exception midway through execution.
282 297
283 298 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
284 299 encoding into methods.
285 300
286 301 2006-07-26 Ville Vainio <vivainio@gmail.com>
287 302
288 303 * iplib.py: history now stores multiline input as single
289 304 history entries. Patch by Jorgen Cederlof.
290 305
291 306 2006-07-18 Walter Doerwald <walter@livinglogic.de>
292 307
293 308 * IPython/Extensions/ibrowse.py: Make cursor visible over
294 309 non existing attributes.
295 310
296 311 2006-07-14 Walter Doerwald <walter@livinglogic.de>
297 312
298 313 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
299 314 error output of the running command doesn't mess up the screen.
300 315
301 316 2006-07-13 Walter Doerwald <walter@livinglogic.de>
302 317
303 318 * IPython/Extensions/ipipe.py (isort): Make isort usable without
304 319 argument. This sorts the items themselves.
305 320
306 321 2006-07-12 Walter Doerwald <walter@livinglogic.de>
307 322
308 323 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
309 324 Compile expression strings into code objects. This should speed
310 325 up ifilter and friends somewhat.
311 326
312 327 2006-07-08 Ville Vainio <vivainio@gmail.com>
313 328
314 329 * Magic.py: %cpaste now strips > from the beginning of lines
315 330 to ease pasting quoted code from emails. Contributed by
316 331 Stefan van der Walt.
317 332
318 333 2006-06-29 Ville Vainio <vivainio@gmail.com>
319 334
320 335 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
321 336 mode, patch contributed by Darren Dale. NEEDS TESTING!
322 337
323 338 2006-06-28 Walter Doerwald <walter@livinglogic.de>
324 339
325 340 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
326 341 a blue background. Fix fetching new display rows when the browser
327 342 scrolls more than a screenful (e.g. by using the goto command).
328 343
329 344 2006-06-27 Ville Vainio <vivainio@gmail.com>
330 345
331 346 * Magic.py (_inspect, _ofind) Apply David Huard's
332 347 patch for displaying the correct docstring for 'property'
333 348 attributes.
334 349
335 350 2006-06-23 Walter Doerwald <walter@livinglogic.de>
336 351
337 352 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
338 353 commands into the methods implementing them.
339 354
340 355 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
341 356
342 357 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
343 358 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
344 359 autoindent support was authored by Jin Liu.
345 360
346 361 2006-06-22 Walter Doerwald <walter@livinglogic.de>
347 362
348 363 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
349 364 for keymaps with a custom class that simplifies handling.
350 365
351 366 2006-06-19 Walter Doerwald <walter@livinglogic.de>
352 367
353 368 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
354 369 resizing. This requires Python 2.5 to work.
355 370
356 371 2006-06-16 Walter Doerwald <walter@livinglogic.de>
357 372
358 373 * IPython/Extensions/ibrowse.py: Add two new commands to
359 374 ibrowse: "hideattr" (mapped to "h") hides the attribute under
360 375 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
361 376 attributes again. Remapped the help command to "?". Display
362 377 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
363 378 as keys for the "home" and "end" commands. Add three new commands
364 379 to the input mode for "find" and friends: "delend" (CTRL-K)
365 380 deletes to the end of line. "incsearchup" searches upwards in the
366 381 command history for an input that starts with the text before the cursor.
367 382 "incsearchdown" does the same downwards. Removed a bogus mapping of
368 383 the x key to "delete".
369 384
370 385 2006-06-15 Ville Vainio <vivainio@gmail.com>
371 386
372 387 * iplib.py, hooks.py: Added new generate_prompt hook that can be
373 388 used to create prompts dynamically, instead of the "old" way of
374 389 assigning "magic" strings to prompt_in1 and prompt_in2. The old
375 390 way still works (it's invoked by the default hook), of course.
376 391
377 392 * Prompts.py: added generate_output_prompt hook for altering output
378 393 prompt
379 394
380 395 * Release.py: Changed version string to 0.7.3.svn.
381 396
382 397 2006-06-15 Walter Doerwald <walter@livinglogic.de>
383 398
384 399 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
385 400 the call to fetch() always tries to fetch enough data for at least one
386 401 full screen. This makes it possible to simply call moveto(0,0,True) in
387 402 the constructor. Fix typos and removed the obsolete goto attribute.
388 403
389 404 2006-06-12 Ville Vainio <vivainio@gmail.com>
390 405
391 406 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
392 407 allowing $variable interpolation within multiline statements,
393 408 though so far only with "sh" profile for a testing period.
394 409 The patch also enables splitting long commands with \ but it
395 410 doesn't work properly yet.
396 411
397 412 2006-06-12 Walter Doerwald <walter@livinglogic.de>
398 413
399 414 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
400 415 input history and the position of the cursor in the input history for
401 416 the find, findbackwards and goto command.
402 417
403 418 2006-06-10 Walter Doerwald <walter@livinglogic.de>
404 419
405 420 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
406 421 implements the basic functionality of browser commands that require
407 422 input. Reimplement the goto, find and findbackwards commands as
408 423 subclasses of _CommandInput. Add an input history and keymaps to those
409 424 commands. Add "\r" as a keyboard shortcut for the enterdefault and
410 425 execute commands.
411 426
412 427 2006-06-07 Ville Vainio <vivainio@gmail.com>
413 428
414 429 * iplib.py: ipython mybatch.ipy exits ipython immediately after
415 430 running the batch files instead of leaving the session open.
416 431
417 432 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
418 433
419 434 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
420 435 the original fix was incomplete. Patch submitted by W. Maier.
421 436
422 437 2006-06-07 Ville Vainio <vivainio@gmail.com>
423 438
424 439 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
425 440 Confirmation prompts can be supressed by 'quiet' option.
426 441 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
427 442
428 443 2006-06-06 *** Released version 0.7.2
429 444
430 445 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
431 446
432 447 * IPython/Release.py (version): Made 0.7.2 final for release.
433 448 Repo tagged and release cut.
434 449
435 450 2006-06-05 Ville Vainio <vivainio@gmail.com>
436 451
437 452 * Magic.py (magic_rehashx): Honor no_alias list earlier in
438 453 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
439 454
440 455 * upgrade_dir.py: try import 'path' module a bit harder
441 456 (for %upgrade)
442 457
443 458 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
444 459
445 460 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
446 461 instead of looping 20 times.
447 462
448 463 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
449 464 correctly at initialization time. Bug reported by Krishna Mohan
450 465 Gundu <gkmohan-AT-gmail.com> on the user list.
451 466
452 467 * IPython/Release.py (version): Mark 0.7.2 version to start
453 468 testing for release on 06/06.
454 469
455 470 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
456 471
457 472 * scripts/irunner: thin script interface so users don't have to
458 473 find the module and call it as an executable, since modules rarely
459 474 live in people's PATH.
460 475
461 476 * IPython/irunner.py (InteractiveRunner.__init__): added
462 477 delaybeforesend attribute to control delays with newer versions of
463 478 pexpect. Thanks to detailed help from pexpect's author, Noah
464 479 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
465 480 correctly (it works in NoColor mode).
466 481
467 482 * IPython/iplib.py (handle_normal): fix nasty crash reported on
468 483 SAGE list, from improper log() calls.
469 484
470 485 2006-05-31 Ville Vainio <vivainio@gmail.com>
471 486
472 487 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
473 488 with args in parens to work correctly with dirs that have spaces.
474 489
475 490 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
476 491
477 492 * IPython/Logger.py (Logger.logstart): add option to log raw input
478 493 instead of the processed one. A -r flag was added to the
479 494 %logstart magic used for controlling logging.
480 495
481 496 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
482 497
483 498 * IPython/iplib.py (InteractiveShell.__init__): add check for the
484 499 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
485 500 recognize the option. After a bug report by Will Maier. This
486 501 closes #64 (will do it after confirmation from W. Maier).
487 502
488 503 * IPython/irunner.py: New module to run scripts as if manually
489 504 typed into an interactive environment, based on pexpect. After a
490 505 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
491 506 ipython-user list. Simple unittests in the tests/ directory.
492 507
493 508 * tools/release: add Will Maier, OpenBSD port maintainer, to
494 509 recepients list. We are now officially part of the OpenBSD ports:
495 510 http://www.openbsd.org/ports.html ! Many thanks to Will for the
496 511 work.
497 512
498 513 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
499 514
500 515 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
501 516 so that it doesn't break tkinter apps.
502 517
503 518 * IPython/iplib.py (_prefilter): fix bug where aliases would
504 519 shadow variables when autocall was fully off. Reported by SAGE
505 520 author William Stein.
506 521
507 522 * IPython/OInspect.py (Inspector.__init__): add a flag to control
508 523 at what detail level strings are computed when foo? is requested.
509 524 This allows users to ask for example that the string form of an
510 525 object is only computed when foo?? is called, or even never, by
511 526 setting the object_info_string_level >= 2 in the configuration
512 527 file. This new option has been added and documented. After a
513 528 request by SAGE to be able to control the printing of very large
514 529 objects more easily.
515 530
516 531 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
517 532
518 533 * IPython/ipmaker.py (make_IPython): remove the ipython call path
519 534 from sys.argv, to be 100% consistent with how Python itself works
520 535 (as seen for example with python -i file.py). After a bug report
521 536 by Jeffrey Collins.
522 537
523 538 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
524 539 nasty bug which was preventing custom namespaces with -pylab,
525 540 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
526 541 compatibility (long gone from mpl).
527 542
528 543 * IPython/ipapi.py (make_session): name change: create->make. We
529 544 use make in other places (ipmaker,...), it's shorter and easier to
530 545 type and say, etc. I'm trying to clean things before 0.7.2 so
531 546 that I can keep things stable wrt to ipapi in the chainsaw branch.
532 547
533 548 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
534 549 python-mode recognizes our debugger mode. Add support for
535 550 autoindent inside (X)emacs. After a patch sent in by Jin Liu
536 551 <m.liu.jin-AT-gmail.com> originally written by
537 552 doxgen-AT-newsmth.net (with minor modifications for xemacs
538 553 compatibility)
539 554
540 555 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
541 556 tracebacks when walking the stack so that the stack tracking system
542 557 in emacs' python-mode can identify the frames correctly.
543 558
544 559 * IPython/ipmaker.py (make_IPython): make the internal (and
545 560 default config) autoedit_syntax value false by default. Too many
546 561 users have complained to me (both on and off-list) about problems
547 562 with this option being on by default, so I'm making it default to
548 563 off. It can still be enabled by anyone via the usual mechanisms.
549 564
550 565 * IPython/completer.py (Completer.attr_matches): add support for
551 566 PyCrust-style _getAttributeNames magic method. Patch contributed
552 567 by <mscott-AT-goldenspud.com>. Closes #50.
553 568
554 569 * IPython/iplib.py (InteractiveShell.__init__): remove the
555 570 deletion of exit/quit from __builtin__, which can break
556 571 third-party tools like the Zope debugging console. The
557 572 %exit/%quit magics remain. In general, it's probably a good idea
558 573 not to delete anything from __builtin__, since we never know what
559 574 that will break. In any case, python now (for 2.5) will support
560 575 'real' exit/quit, so this issue is moot. Closes #55.
561 576
562 577 * IPython/genutils.py (with_obj): rename the 'with' function to
563 578 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
564 579 becomes a language keyword. Closes #53.
565 580
566 581 * IPython/FakeModule.py (FakeModule.__init__): add a proper
567 582 __file__ attribute to this so it fools more things into thinking
568 583 it is a real module. Closes #59.
569 584
570 585 * IPython/Magic.py (magic_edit): add -n option to open the editor
571 586 at a specific line number. After a patch by Stefan van der Walt.
572 587
573 588 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
574 589
575 590 * IPython/iplib.py (edit_syntax_error): fix crash when for some
576 591 reason the file could not be opened. After automatic crash
577 592 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
578 593 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
579 594 (_should_recompile): Don't fire editor if using %bg, since there
580 595 is no file in the first place. From the same report as above.
581 596 (raw_input): protect against faulty third-party prefilters. After
582 597 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
583 598 while running under SAGE.
584 599
585 600 2006-05-23 Ville Vainio <vivainio@gmail.com>
586 601
587 602 * ipapi.py: Stripped down ip.to_user_ns() to work only as
588 603 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
589 604 now returns None (again), unless dummy is specifically allowed by
590 605 ipapi.get(allow_dummy=True).
591 606
592 607 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
593 608
594 609 * IPython: remove all 2.2-compatibility objects and hacks from
595 610 everywhere, since we only support 2.3 at this point. Docs
596 611 updated.
597 612
598 613 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
599 614 Anything requiring extra validation can be turned into a Python
600 615 property in the future. I used a property for the db one b/c
601 616 there was a nasty circularity problem with the initialization
602 617 order, which right now I don't have time to clean up.
603 618
604 619 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
605 620 another locking bug reported by Jorgen. I'm not 100% sure though,
606 621 so more testing is needed...
607 622
608 623 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
609 624
610 625 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
611 626 local variables from any routine in user code (typically executed
612 627 with %run) directly into the interactive namespace. Very useful
613 628 when doing complex debugging.
614 629 (IPythonNotRunning): Changed the default None object to a dummy
615 630 whose attributes can be queried as well as called without
616 631 exploding, to ease writing code which works transparently both in
617 632 and out of ipython and uses some of this API.
618 633
619 634 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
620 635
621 636 * IPython/hooks.py (result_display): Fix the fact that our display
622 637 hook was using str() instead of repr(), as the default python
623 638 console does. This had gone unnoticed b/c it only happened if
624 639 %Pprint was off, but the inconsistency was there.
625 640
626 641 2006-05-15 Ville Vainio <vivainio@gmail.com>
627 642
628 643 * Oinspect.py: Only show docstring for nonexisting/binary files
629 644 when doing object??, closing ticket #62
630 645
631 646 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
632 647
633 648 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
634 649 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
635 650 was being released in a routine which hadn't checked if it had
636 651 been the one to acquire it.
637 652
638 653 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
639 654
640 655 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
641 656
642 657 2006-04-11 Ville Vainio <vivainio@gmail.com>
643 658
644 659 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
645 660 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
646 661 prefilters, allowing stuff like magics and aliases in the file.
647 662
648 663 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
649 664 added. Supported now are "%clear in" and "%clear out" (clear input and
650 665 output history, respectively). Also fixed CachedOutput.flush to
651 666 properly flush the output cache.
652 667
653 668 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
654 669 half-success (and fail explicitly).
655 670
656 671 2006-03-28 Ville Vainio <vivainio@gmail.com>
657 672
658 673 * iplib.py: Fix quoting of aliases so that only argless ones
659 674 are quoted
660 675
661 676 2006-03-28 Ville Vainio <vivainio@gmail.com>
662 677
663 678 * iplib.py: Quote aliases with spaces in the name.
664 679 "c:\program files\blah\bin" is now legal alias target.
665 680
666 681 * ext_rehashdir.py: Space no longer allowed as arg
667 682 separator, since space is legal in path names.
668 683
669 684 2006-03-16 Ville Vainio <vivainio@gmail.com>
670 685
671 686 * upgrade_dir.py: Take path.py from Extensions, correcting
672 687 %upgrade magic
673 688
674 689 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
675 690
676 691 * hooks.py: Only enclose editor binary in quotes if legal and
677 692 necessary (space in the name, and is an existing file). Fixes a bug
678 693 reported by Zachary Pincus.
679 694
680 695 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
681 696
682 697 * Manual: thanks to a tip on proper color handling for Emacs, by
683 698 Eric J Haywiser <ejh1-AT-MIT.EDU>.
684 699
685 700 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
686 701 by applying the provided patch. Thanks to Liu Jin
687 702 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
688 703 XEmacs/Linux, I'm trusting the submitter that it actually helps
689 704 under win32/GNU Emacs. Will revisit if any problems are reported.
690 705
691 706 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
692 707
693 708 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
694 709 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
695 710
696 711 2006-03-12 Ville Vainio <vivainio@gmail.com>
697 712
698 713 * Magic.py (magic_timeit): Added %timeit magic, contributed by
699 714 Torsten Marek.
700 715
701 716 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
702 717
703 718 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
704 719 line ranges works again.
705 720
706 721 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
707 722
708 723 * IPython/iplib.py (showtraceback): add back sys.last_traceback
709 724 and friends, after a discussion with Zach Pincus on ipython-user.
710 725 I'm not 100% sure, but after thinking about it quite a bit, it may
711 726 be OK. Testing with the multithreaded shells didn't reveal any
712 727 problems, but let's keep an eye out.
713 728
714 729 In the process, I fixed a few things which were calling
715 730 self.InteractiveTB() directly (like safe_execfile), which is a
716 731 mistake: ALL exception reporting should be done by calling
717 732 self.showtraceback(), which handles state and tab-completion and
718 733 more.
719 734
720 735 2006-03-01 Ville Vainio <vivainio@gmail.com>
721 736
722 737 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
723 738 To use, do "from ipipe import *".
724 739
725 740 2006-02-24 Ville Vainio <vivainio@gmail.com>
726 741
727 742 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
728 743 "cleanly" and safely than the older upgrade mechanism.
729 744
730 745 2006-02-21 Ville Vainio <vivainio@gmail.com>
731 746
732 747 * Magic.py: %save works again.
733 748
734 749 2006-02-15 Ville Vainio <vivainio@gmail.com>
735 750
736 751 * Magic.py: %Pprint works again
737 752
738 753 * Extensions/ipy_sane_defaults.py: Provide everything provided
739 754 in default ipythonrc, to make it possible to have a completely empty
740 755 ipythonrc (and thus completely rc-file free configuration)
741 756
742 757 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
743 758
744 759 * IPython/hooks.py (editor): quote the call to the editor command,
745 760 to allow commands with spaces in them. Problem noted by watching
746 761 Ian Oswald's video about textpad under win32 at
747 762 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
748 763
749 764 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
750 765 describing magics (we haven't used @ for a loong time).
751 766
752 767 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
753 768 contributed by marienz to close
754 769 http://www.scipy.net/roundup/ipython/issue53.
755 770
756 771 2006-02-10 Ville Vainio <vivainio@gmail.com>
757 772
758 773 * genutils.py: getoutput now works in win32 too
759 774
760 775 * completer.py: alias and magic completion only invoked
761 776 at the first "item" in the line, to avoid "cd %store"
762 777 nonsense.
763 778
764 779 2006-02-09 Ville Vainio <vivainio@gmail.com>
765 780
766 781 * test/*: Added a unit testing framework (finally).
767 782 '%run runtests.py' to run test_*.
768 783
769 784 * ipapi.py: Exposed runlines and set_custom_exc
770 785
771 786 2006-02-07 Ville Vainio <vivainio@gmail.com>
772 787
773 788 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
774 789 instead use "f(1 2)" as before.
775 790
776 791 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
777 792
778 793 * IPython/demo.py (IPythonDemo): Add new classes to the demo
779 794 facilities, for demos processed by the IPython input filter
780 795 (IPythonDemo), and for running a script one-line-at-a-time as a
781 796 demo, both for pure Python (LineDemo) and for IPython-processed
782 797 input (IPythonLineDemo). After a request by Dave Kohel, from the
783 798 SAGE team.
784 799 (Demo.edit): added an edit() method to the demo objects, to edit
785 800 the in-memory copy of the last executed block.
786 801
787 802 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
788 803 processing to %edit, %macro and %save. These commands can now be
789 804 invoked on the unprocessed input as it was typed by the user
790 805 (without any prefilters applied). After requests by the SAGE team
791 806 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
792 807
793 808 2006-02-01 Ville Vainio <vivainio@gmail.com>
794 809
795 810 * setup.py, eggsetup.py: easy_install ipython==dev works
796 811 correctly now (on Linux)
797 812
798 813 * ipy_user_conf,ipmaker: user config changes, removed spurious
799 814 warnings
800 815
801 816 * iplib: if rc.banner is string, use it as is.
802 817
803 818 * Magic: %pycat accepts a string argument and pages it's contents.
804 819
805 820
806 821 2006-01-30 Ville Vainio <vivainio@gmail.com>
807 822
808 823 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
809 824 Now %store and bookmarks work through PickleShare, meaning that
810 825 concurrent access is possible and all ipython sessions see the
811 826 same database situation all the time, instead of snapshot of
812 827 the situation when the session was started. Hence, %bookmark
813 828 results are immediately accessible from othes sessions. The database
814 829 is also available for use by user extensions. See:
815 830 http://www.python.org/pypi/pickleshare
816 831
817 832 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
818 833
819 834 * aliases can now be %store'd
820 835
821 836 * path.py moved to Extensions so that pickleshare does not need
822 837 IPython-specific import. Extensions added to pythonpath right
823 838 at __init__.
824 839
825 840 * iplib.py: ipalias deprecated/redundant; aliases are converted and
826 841 called with _ip.system and the pre-transformed command string.
827 842
828 843 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
829 844
830 845 * IPython/iplib.py (interact): Fix that we were not catching
831 846 KeyboardInterrupt exceptions properly. I'm not quite sure why the
832 847 logic here had to change, but it's fixed now.
833 848
834 849 2006-01-29 Ville Vainio <vivainio@gmail.com>
835 850
836 851 * iplib.py: Try to import pyreadline on Windows.
837 852
838 853 2006-01-27 Ville Vainio <vivainio@gmail.com>
839 854
840 855 * iplib.py: Expose ipapi as _ip in builtin namespace.
841 856 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
842 857 and ip_set_hook (-> _ip.set_hook) redundant. % and !
843 858 syntax now produce _ip.* variant of the commands.
844 859
845 860 * "_ip.options().autoedit_syntax = 2" automatically throws
846 861 user to editor for syntax error correction without prompting.
847 862
848 863 2006-01-27 Ville Vainio <vivainio@gmail.com>
849 864
850 865 * ipmaker.py: Give "realistic" sys.argv for scripts (without
851 866 'ipython' at argv[0]) executed through command line.
852 867 NOTE: this DEPRECATES calling ipython with multiple scripts
853 868 ("ipython a.py b.py c.py")
854 869
855 870 * iplib.py, hooks.py: Added configurable input prefilter,
856 871 named 'input_prefilter'. See ext_rescapture.py for example
857 872 usage.
858 873
859 874 * ext_rescapture.py, Magic.py: Better system command output capture
860 875 through 'var = !ls' (deprecates user-visible %sc). Same notation
861 876 applies for magics, 'var = %alias' assigns alias list to var.
862 877
863 878 * ipapi.py: added meta() for accessing extension-usable data store.
864 879
865 880 * iplib.py: added InteractiveShell.getapi(). New magics should be
866 881 written doing self.getapi() instead of using the shell directly.
867 882
868 883 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
869 884 %store foo >> ~/myfoo.txt to store variables to files (in clean
870 885 textual form, not a restorable pickle).
871 886
872 887 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
873 888
874 889 * usage.py, Magic.py: added %quickref
875 890
876 891 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
877 892
878 893 * GetoptErrors when invoking magics etc. with wrong args
879 894 are now more helpful:
880 895 GetoptError: option -l not recognized (allowed: "qb" )
881 896
882 897 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
883 898
884 899 * IPython/demo.py (Demo.show): Flush stdout after each block, so
885 900 computationally intensive blocks don't appear to stall the demo.
886 901
887 902 2006-01-24 Ville Vainio <vivainio@gmail.com>
888 903
889 904 * iplib.py, hooks.py: 'result_display' hook can return a non-None
890 905 value to manipulate resulting history entry.
891 906
892 907 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
893 908 to instance methods of IPApi class, to make extending an embedded
894 909 IPython feasible. See ext_rehashdir.py for example usage.
895 910
896 911 * Merged 1071-1076 from branches/0.7.1
897 912
898 913
899 914 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
900 915
901 916 * tools/release (daystamp): Fix build tools to use the new
902 917 eggsetup.py script to build lightweight eggs.
903 918
904 919 * Applied changesets 1062 and 1064 before 0.7.1 release.
905 920
906 921 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
907 922 see the raw input history (without conversions like %ls ->
908 923 ipmagic("ls")). After a request from W. Stein, SAGE
909 924 (http://modular.ucsd.edu/sage) developer. This information is
910 925 stored in the input_hist_raw attribute of the IPython instance, so
911 926 developers can access it if needed (it's an InputList instance).
912 927
913 928 * Versionstring = 0.7.2.svn
914 929
915 930 * eggsetup.py: A separate script for constructing eggs, creates
916 931 proper launch scripts even on Windows (an .exe file in
917 932 \python24\scripts).
918 933
919 934 * ipapi.py: launch_new_instance, launch entry point needed for the
920 935 egg.
921 936
922 937 2006-01-23 Ville Vainio <vivainio@gmail.com>
923 938
924 939 * Added %cpaste magic for pasting python code
925 940
926 941 2006-01-22 Ville Vainio <vivainio@gmail.com>
927 942
928 943 * Merge from branches/0.7.1 into trunk, revs 1052-1057
929 944
930 945 * Versionstring = 0.7.2.svn
931 946
932 947 * eggsetup.py: A separate script for constructing eggs, creates
933 948 proper launch scripts even on Windows (an .exe file in
934 949 \python24\scripts).
935 950
936 951 * ipapi.py: launch_new_instance, launch entry point needed for the
937 952 egg.
938 953
939 954 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
940 955
941 956 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
942 957 %pfile foo would print the file for foo even if it was a binary.
943 958 Now, extensions '.so' and '.dll' are skipped.
944 959
945 960 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
946 961 bug, where macros would fail in all threaded modes. I'm not 100%
947 962 sure, so I'm going to put out an rc instead of making a release
948 963 today, and wait for feedback for at least a few days.
949 964
950 965 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
951 966 it...) the handling of pasting external code with autoindent on.
952 967 To get out of a multiline input, the rule will appear for most
953 968 users unchanged: two blank lines or change the indent level
954 969 proposed by IPython. But there is a twist now: you can
955 970 add/subtract only *one or two spaces*. If you add/subtract three
956 971 or more (unless you completely delete the line), IPython will
957 972 accept that line, and you'll need to enter a second one of pure
958 973 whitespace. I know it sounds complicated, but I can't find a
959 974 different solution that covers all the cases, with the right
960 975 heuristics. Hopefully in actual use, nobody will really notice
961 976 all these strange rules and things will 'just work'.
962 977
963 978 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
964 979
965 980 * IPython/iplib.py (interact): catch exceptions which can be
966 981 triggered asynchronously by signal handlers. Thanks to an
967 982 automatic crash report, submitted by Colin Kingsley
968 983 <tercel-AT-gentoo.org>.
969 984
970 985 2006-01-20 Ville Vainio <vivainio@gmail.com>
971 986
972 987 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
973 988 (%rehashdir, very useful, try it out) of how to extend ipython
974 989 with new magics. Also added Extensions dir to pythonpath to make
975 990 importing extensions easy.
976 991
977 992 * %store now complains when trying to store interactively declared
978 993 classes / instances of those classes.
979 994
980 995 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
981 996 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
982 997 if they exist, and ipy_user_conf.py with some defaults is created for
983 998 the user.
984 999
985 1000 * Startup rehashing done by the config file, not InterpreterExec.
986 1001 This means system commands are available even without selecting the
987 1002 pysh profile. It's the sensible default after all.
988 1003
989 1004 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
990 1005
991 1006 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
992 1007 multiline code with autoindent on working. But I am really not
993 1008 sure, so this needs more testing. Will commit a debug-enabled
994 1009 version for now, while I test it some more, so that Ville and
995 1010 others may also catch any problems. Also made
996 1011 self.indent_current_str() a method, to ensure that there's no
997 1012 chance of the indent space count and the corresponding string
998 1013 falling out of sync. All code needing the string should just call
999 1014 the method.
1000 1015
1001 1016 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
1002 1017
1003 1018 * IPython/Magic.py (magic_edit): fix check for when users don't
1004 1019 save their output files, the try/except was in the wrong section.
1005 1020
1006 1021 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
1007 1022
1008 1023 * IPython/Magic.py (magic_run): fix __file__ global missing from
1009 1024 script's namespace when executed via %run. After a report by
1010 1025 Vivian.
1011 1026
1012 1027 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
1013 1028 when using python 2.4. The parent constructor changed in 2.4, and
1014 1029 we need to track it directly (we can't call it, as it messes up
1015 1030 readline and tab-completion inside our pdb would stop working).
1016 1031 After a bug report by R. Bernstein <rocky-AT-panix.com>.
1017 1032
1018 1033 2006-01-16 Ville Vainio <vivainio@gmail.com>
1019 1034
1020 1035 * Ipython/magic.py: Reverted back to old %edit functionality
1021 1036 that returns file contents on exit.
1022 1037
1023 1038 * IPython/path.py: Added Jason Orendorff's "path" module to
1024 1039 IPython tree, http://www.jorendorff.com/articles/python/path/.
1025 1040 You can get path objects conveniently through %sc, and !!, e.g.:
1026 1041 sc files=ls
1027 1042 for p in files.paths: # or files.p
1028 1043 print p,p.mtime
1029 1044
1030 1045 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
1031 1046 now work again without considering the exclusion regexp -
1032 1047 hence, things like ',foo my/path' turn to 'foo("my/path")'
1033 1048 instead of syntax error.
1034 1049
1035 1050
1036 1051 2006-01-14 Ville Vainio <vivainio@gmail.com>
1037 1052
1038 1053 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
1039 1054 ipapi decorators for python 2.4 users, options() provides access to rc
1040 1055 data.
1041 1056
1042 1057 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
1043 1058 as path separators (even on Linux ;-). Space character after
1044 1059 backslash (as yielded by tab completer) is still space;
1045 1060 "%cd long\ name" works as expected.
1046 1061
1047 1062 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
1048 1063 as "chain of command", with priority. API stays the same,
1049 1064 TryNext exception raised by a hook function signals that
1050 1065 current hook failed and next hook should try handling it, as
1051 1066 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
1052 1067 requested configurable display hook, which is now implemented.
1053 1068
1054 1069 2006-01-13 Ville Vainio <vivainio@gmail.com>
1055 1070
1056 1071 * IPython/platutils*.py: platform specific utility functions,
1057 1072 so far only set_term_title is implemented (change terminal
1058 1073 label in windowing systems). %cd now changes the title to
1059 1074 current dir.
1060 1075
1061 1076 * IPython/Release.py: Added myself to "authors" list,
1062 1077 had to create new files.
1063 1078
1064 1079 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
1065 1080 shell escape; not a known bug but had potential to be one in the
1066 1081 future.
1067 1082
1068 1083 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
1069 1084 extension API for IPython! See the module for usage example. Fix
1070 1085 OInspect for docstring-less magic functions.
1071 1086
1072 1087
1073 1088 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
1074 1089
1075 1090 * IPython/iplib.py (raw_input): temporarily deactivate all
1076 1091 attempts at allowing pasting of code with autoindent on. It
1077 1092 introduced bugs (reported by Prabhu) and I can't seem to find a
1078 1093 robust combination which works in all cases. Will have to revisit
1079 1094 later.
1080 1095
1081 1096 * IPython/genutils.py: remove isspace() function. We've dropped
1082 1097 2.2 compatibility, so it's OK to use the string method.
1083 1098
1084 1099 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1085 1100
1086 1101 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
1087 1102 matching what NOT to autocall on, to include all python binary
1088 1103 operators (including things like 'and', 'or', 'is' and 'in').
1089 1104 Prompted by a bug report on 'foo & bar', but I realized we had
1090 1105 many more potential bug cases with other operators. The regexp is
1091 1106 self.re_exclude_auto, it's fairly commented.
1092 1107
1093 1108 2006-01-12 Ville Vainio <vivainio@gmail.com>
1094 1109
1095 1110 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
1096 1111 Prettified and hardened string/backslash quoting with ipsystem(),
1097 1112 ipalias() and ipmagic(). Now even \ characters are passed to
1098 1113 %magics, !shell escapes and aliases exactly as they are in the
1099 1114 ipython command line. Should improve backslash experience,
1100 1115 particularly in Windows (path delimiter for some commands that
1101 1116 won't understand '/'), but Unix benefits as well (regexps). %cd
1102 1117 magic still doesn't support backslash path delimiters, though. Also
1103 1118 deleted all pretense of supporting multiline command strings in
1104 1119 !system or %magic commands. Thanks to Jerry McRae for suggestions.
1105 1120
1106 1121 * doc/build_doc_instructions.txt added. Documentation on how to
1107 1122 use doc/update_manual.py, added yesterday. Both files contributed
1108 1123 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
1109 1124 doc/*.sh for deprecation at a later date.
1110 1125
1111 1126 * /ipython.py Added ipython.py to root directory for
1112 1127 zero-installation (tar xzvf ipython.tgz; cd ipython; python
1113 1128 ipython.py) and development convenience (no need to keep doing
1114 1129 "setup.py install" between changes).
1115 1130
1116 1131 * Made ! and !! shell escapes work (again) in multiline expressions:
1117 1132 if 1:
1118 1133 !ls
1119 1134 !!ls
1120 1135
1121 1136 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1122 1137
1123 1138 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
1124 1139 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
1125 1140 module in case-insensitive installation. Was causing crashes
1126 1141 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
1127 1142
1128 1143 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
1129 1144 <marienz-AT-gentoo.org>, closes
1130 1145 http://www.scipy.net/roundup/ipython/issue51.
1131 1146
1132 1147 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
1133 1148
1134 1149 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
1135 1150 problem of excessive CPU usage under *nix and keyboard lag under
1136 1151 win32.
1137 1152
1138 1153 2006-01-10 *** Released version 0.7.0
1139 1154
1140 1155 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
1141 1156
1142 1157 * IPython/Release.py (revision): tag version number to 0.7.0,
1143 1158 ready for release.
1144 1159
1145 1160 * IPython/Magic.py (magic_edit): Add print statement to %edit so
1146 1161 it informs the user of the name of the temp. file used. This can
1147 1162 help if you decide later to reuse that same file, so you know
1148 1163 where to copy the info from.
1149 1164
1150 1165 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
1151 1166
1152 1167 * setup_bdist_egg.py: little script to build an egg. Added
1153 1168 support in the release tools as well.
1154 1169
1155 1170 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
1156 1171
1157 1172 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
1158 1173 version selection (new -wxversion command line and ipythonrc
1159 1174 parameter). Patch contributed by Arnd Baecker
1160 1175 <arnd.baecker-AT-web.de>.
1161 1176
1162 1177 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1163 1178 embedded instances, for variables defined at the interactive
1164 1179 prompt of the embedded ipython. Reported by Arnd.
1165 1180
1166 1181 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
1167 1182 it can be used as a (stateful) toggle, or with a direct parameter.
1168 1183
1169 1184 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
1170 1185 could be triggered in certain cases and cause the traceback
1171 1186 printer not to work.
1172 1187
1173 1188 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
1174 1189
1175 1190 * IPython/iplib.py (_should_recompile): Small fix, closes
1176 1191 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
1177 1192
1178 1193 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
1179 1194
1180 1195 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
1181 1196 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
1182 1197 Moad for help with tracking it down.
1183 1198
1184 1199 * IPython/iplib.py (handle_auto): fix autocall handling for
1185 1200 objects which support BOTH __getitem__ and __call__ (so that f [x]
1186 1201 is left alone, instead of becoming f([x]) automatically).
1187 1202
1188 1203 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
1189 1204 Ville's patch.
1190 1205
1191 1206 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
1192 1207
1193 1208 * IPython/iplib.py (handle_auto): changed autocall semantics to
1194 1209 include 'smart' mode, where the autocall transformation is NOT
1195 1210 applied if there are no arguments on the line. This allows you to
1196 1211 just type 'foo' if foo is a callable to see its internal form,
1197 1212 instead of having it called with no arguments (typically a
1198 1213 mistake). The old 'full' autocall still exists: for that, you
1199 1214 need to set the 'autocall' parameter to 2 in your ipythonrc file.
1200 1215
1201 1216 * IPython/completer.py (Completer.attr_matches): add
1202 1217 tab-completion support for Enthoughts' traits. After a report by
1203 1218 Arnd and a patch by Prabhu.
1204 1219
1205 1220 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
1206 1221
1207 1222 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
1208 1223 Schmolck's patch to fix inspect.getinnerframes().
1209 1224
1210 1225 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
1211 1226 for embedded instances, regarding handling of namespaces and items
1212 1227 added to the __builtin__ one. Multiple embedded instances and
1213 1228 recursive embeddings should work better now (though I'm not sure
1214 1229 I've got all the corner cases fixed, that code is a bit of a brain
1215 1230 twister).
1216 1231
1217 1232 * IPython/Magic.py (magic_edit): added support to edit in-memory
1218 1233 macros (automatically creates the necessary temp files). %edit
1219 1234 also doesn't return the file contents anymore, it's just noise.
1220 1235
1221 1236 * IPython/completer.py (Completer.attr_matches): revert change to
1222 1237 complete only on attributes listed in __all__. I realized it
1223 1238 cripples the tab-completion system as a tool for exploring the
1224 1239 internals of unknown libraries (it renders any non-__all__
1225 1240 attribute off-limits). I got bit by this when trying to see
1226 1241 something inside the dis module.
1227 1242
1228 1243 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
1229 1244
1230 1245 * IPython/iplib.py (InteractiveShell.__init__): add .meta
1231 1246 namespace for users and extension writers to hold data in. This
1232 1247 follows the discussion in
1233 1248 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
1234 1249
1235 1250 * IPython/completer.py (IPCompleter.complete): small patch to help
1236 1251 tab-completion under Emacs, after a suggestion by John Barnard
1237 1252 <barnarj-AT-ccf.org>.
1238 1253
1239 1254 * IPython/Magic.py (Magic.extract_input_slices): added support for
1240 1255 the slice notation in magics to use N-M to represent numbers N...M
1241 1256 (closed endpoints). This is used by %macro and %save.
1242 1257
1243 1258 * IPython/completer.py (Completer.attr_matches): for modules which
1244 1259 define __all__, complete only on those. After a patch by Jeffrey
1245 1260 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
1246 1261 speed up this routine.
1247 1262
1248 1263 * IPython/Logger.py (Logger.log): fix a history handling bug. I
1249 1264 don't know if this is the end of it, but the behavior now is
1250 1265 certainly much more correct. Note that coupled with macros,
1251 1266 slightly surprising (at first) behavior may occur: a macro will in
1252 1267 general expand to multiple lines of input, so upon exiting, the
1253 1268 in/out counters will both be bumped by the corresponding amount
1254 1269 (as if the macro's contents had been typed interactively). Typing
1255 1270 %hist will reveal the intermediate (silently processed) lines.
1256 1271
1257 1272 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
1258 1273 pickle to fail (%run was overwriting __main__ and not restoring
1259 1274 it, but pickle relies on __main__ to operate).
1260 1275
1261 1276 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
1262 1277 using properties, but forgot to make the main InteractiveShell
1263 1278 class a new-style class. Properties fail silently, and
1264 1279 mysteriously, with old-style class (getters work, but
1265 1280 setters don't do anything).
1266 1281
1267 1282 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
1268 1283
1269 1284 * IPython/Magic.py (magic_history): fix history reporting bug (I
1270 1285 know some nasties are still there, I just can't seem to find a
1271 1286 reproducible test case to track them down; the input history is
1272 1287 falling out of sync...)
1273 1288
1274 1289 * IPython/iplib.py (handle_shell_escape): fix bug where both
1275 1290 aliases and system accesses where broken for indented code (such
1276 1291 as loops).
1277 1292
1278 1293 * IPython/genutils.py (shell): fix small but critical bug for
1279 1294 win32 system access.
1280 1295
1281 1296 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
1282 1297
1283 1298 * IPython/iplib.py (showtraceback): remove use of the
1284 1299 sys.last_{type/value/traceback} structures, which are non
1285 1300 thread-safe.
1286 1301 (_prefilter): change control flow to ensure that we NEVER
1287 1302 introspect objects when autocall is off. This will guarantee that
1288 1303 having an input line of the form 'x.y', where access to attribute
1289 1304 'y' has side effects, doesn't trigger the side effect TWICE. It
1290 1305 is important to note that, with autocall on, these side effects
1291 1306 can still happen.
1292 1307 (ipsystem): new builtin, to complete the ip{magic/alias/system}
1293 1308 trio. IPython offers these three kinds of special calls which are
1294 1309 not python code, and it's a good thing to have their call method
1295 1310 be accessible as pure python functions (not just special syntax at
1296 1311 the command line). It gives us a better internal implementation
1297 1312 structure, as well as exposing these for user scripting more
1298 1313 cleanly.
1299 1314
1300 1315 * IPython/macro.py (Macro.__init__): moved macros to a standalone
1301 1316 file. Now that they'll be more likely to be used with the
1302 1317 persistance system (%store), I want to make sure their module path
1303 1318 doesn't change in the future, so that we don't break things for
1304 1319 users' persisted data.
1305 1320
1306 1321 * IPython/iplib.py (autoindent_update): move indentation
1307 1322 management into the _text_ processing loop, not the keyboard
1308 1323 interactive one. This is necessary to correctly process non-typed
1309 1324 multiline input (such as macros).
1310 1325
1311 1326 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
1312 1327 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
1313 1328 which was producing problems in the resulting manual.
1314 1329 (magic_whos): improve reporting of instances (show their class,
1315 1330 instead of simply printing 'instance' which isn't terribly
1316 1331 informative).
1317 1332
1318 1333 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
1319 1334 (minor mods) to support network shares under win32.
1320 1335
1321 1336 * IPython/winconsole.py (get_console_size): add new winconsole
1322 1337 module and fixes to page_dumb() to improve its behavior under
1323 1338 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
1324 1339
1325 1340 * IPython/Magic.py (Macro): simplified Macro class to just
1326 1341 subclass list. We've had only 2.2 compatibility for a very long
1327 1342 time, yet I was still avoiding subclassing the builtin types. No
1328 1343 more (I'm also starting to use properties, though I won't shift to
1329 1344 2.3-specific features quite yet).
1330 1345 (magic_store): added Ville's patch for lightweight variable
1331 1346 persistence, after a request on the user list by Matt Wilkie
1332 1347 <maphew-AT-gmail.com>. The new %store magic's docstring has full
1333 1348 details.
1334 1349
1335 1350 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1336 1351 changed the default logfile name from 'ipython.log' to
1337 1352 'ipython_log.py'. These logs are real python files, and now that
1338 1353 we have much better multiline support, people are more likely to
1339 1354 want to use them as such. Might as well name them correctly.
1340 1355
1341 1356 * IPython/Magic.py: substantial cleanup. While we can't stop
1342 1357 using magics as mixins, due to the existing customizations 'out
1343 1358 there' which rely on the mixin naming conventions, at least I
1344 1359 cleaned out all cross-class name usage. So once we are OK with
1345 1360 breaking compatibility, the two systems can be separated.
1346 1361
1347 1362 * IPython/Logger.py: major cleanup. This one is NOT a mixin
1348 1363 anymore, and the class is a fair bit less hideous as well. New
1349 1364 features were also introduced: timestamping of input, and logging
1350 1365 of output results. These are user-visible with the -t and -o
1351 1366 options to %logstart. Closes
1352 1367 http://www.scipy.net/roundup/ipython/issue11 and a request by
1353 1368 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
1354 1369
1355 1370 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
1356 1371
1357 1372 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
1358 1373 better handle backslashes in paths. See the thread 'More Windows
1359 1374 questions part 2 - \/ characters revisited' on the iypthon user
1360 1375 list:
1361 1376 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
1362 1377
1363 1378 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
1364 1379
1365 1380 (InteractiveShell.__init__): change threaded shells to not use the
1366 1381 ipython crash handler. This was causing more problems than not,
1367 1382 as exceptions in the main thread (GUI code, typically) would
1368 1383 always show up as a 'crash', when they really weren't.
1369 1384
1370 1385 The colors and exception mode commands (%colors/%xmode) have been
1371 1386 synchronized to also take this into account, so users can get
1372 1387 verbose exceptions for their threaded code as well. I also added
1373 1388 support for activating pdb inside this exception handler as well,
1374 1389 so now GUI authors can use IPython's enhanced pdb at runtime.
1375 1390
1376 1391 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
1377 1392 true by default, and add it to the shipped ipythonrc file. Since
1378 1393 this asks the user before proceeding, I think it's OK to make it
1379 1394 true by default.
1380 1395
1381 1396 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
1382 1397 of the previous special-casing of input in the eval loop. I think
1383 1398 this is cleaner, as they really are commands and shouldn't have
1384 1399 a special role in the middle of the core code.
1385 1400
1386 1401 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
1387 1402
1388 1403 * IPython/iplib.py (edit_syntax_error): added support for
1389 1404 automatically reopening the editor if the file had a syntax error
1390 1405 in it. Thanks to scottt who provided the patch at:
1391 1406 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
1392 1407 version committed).
1393 1408
1394 1409 * IPython/iplib.py (handle_normal): add suport for multi-line
1395 1410 input with emtpy lines. This fixes
1396 1411 http://www.scipy.net/roundup/ipython/issue43 and a similar
1397 1412 discussion on the user list.
1398 1413
1399 1414 WARNING: a behavior change is necessarily introduced to support
1400 1415 blank lines: now a single blank line with whitespace does NOT
1401 1416 break the input loop, which means that when autoindent is on, by
1402 1417 default hitting return on the next (indented) line does NOT exit.
1403 1418
1404 1419 Instead, to exit a multiline input you can either have:
1405 1420
1406 1421 - TWO whitespace lines (just hit return again), or
1407 1422 - a single whitespace line of a different length than provided
1408 1423 by the autoindent (add or remove a space).
1409 1424
1410 1425 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
1411 1426 module to better organize all readline-related functionality.
1412 1427 I've deleted FlexCompleter and put all completion clases here.
1413 1428
1414 1429 * IPython/iplib.py (raw_input): improve indentation management.
1415 1430 It is now possible to paste indented code with autoindent on, and
1416 1431 the code is interpreted correctly (though it still looks bad on
1417 1432 screen, due to the line-oriented nature of ipython).
1418 1433 (MagicCompleter.complete): change behavior so that a TAB key on an
1419 1434 otherwise empty line actually inserts a tab, instead of completing
1420 1435 on the entire global namespace. This makes it easier to use the
1421 1436 TAB key for indentation. After a request by Hans Meine
1422 1437 <hans_meine-AT-gmx.net>
1423 1438 (_prefilter): add support so that typing plain 'exit' or 'quit'
1424 1439 does a sensible thing. Originally I tried to deviate as little as
1425 1440 possible from the default python behavior, but even that one may
1426 1441 change in this direction (thread on python-dev to that effect).
1427 1442 Regardless, ipython should do the right thing even if CPython's
1428 1443 '>>>' prompt doesn't.
1429 1444 (InteractiveShell): removed subclassing code.InteractiveConsole
1430 1445 class. By now we'd overridden just about all of its methods: I've
1431 1446 copied the remaining two over, and now ipython is a standalone
1432 1447 class. This will provide a clearer picture for the chainsaw
1433 1448 branch refactoring.
1434 1449
1435 1450 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
1436 1451
1437 1452 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
1438 1453 failures for objects which break when dir() is called on them.
1439 1454
1440 1455 * IPython/FlexCompleter.py (Completer.__init__): Added support for
1441 1456 distinct local and global namespaces in the completer API. This
1442 1457 change allows us to properly handle completion with distinct
1443 1458 scopes, including in embedded instances (this had never really
1444 1459 worked correctly).
1445 1460
1446 1461 Note: this introduces a change in the constructor for
1447 1462 MagicCompleter, as a new global_namespace parameter is now the
1448 1463 second argument (the others were bumped one position).
1449 1464
1450 1465 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
1451 1466
1452 1467 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1453 1468 embedded instances (which can be done now thanks to Vivian's
1454 1469 frame-handling fixes for pdb).
1455 1470 (InteractiveShell.__init__): Fix namespace handling problem in
1456 1471 embedded instances. We were overwriting __main__ unconditionally,
1457 1472 and this should only be done for 'full' (non-embedded) IPython;
1458 1473 embedded instances must respect the caller's __main__. Thanks to
1459 1474 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
1460 1475
1461 1476 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
1462 1477
1463 1478 * setup.py: added download_url to setup(). This registers the
1464 1479 download address at PyPI, which is not only useful to humans
1465 1480 browsing the site, but is also picked up by setuptools (the Eggs
1466 1481 machinery). Thanks to Ville and R. Kern for the info/discussion
1467 1482 on this.
1468 1483
1469 1484 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
1470 1485
1471 1486 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
1472 1487 This brings a lot of nice functionality to the pdb mode, which now
1473 1488 has tab-completion, syntax highlighting, and better stack handling
1474 1489 than before. Many thanks to Vivian De Smedt
1475 1490 <vivian-AT-vdesmedt.com> for the original patches.
1476 1491
1477 1492 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
1478 1493
1479 1494 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
1480 1495 sequence to consistently accept the banner argument. The
1481 1496 inconsistency was tripping SAGE, thanks to Gary Zablackis
1482 1497 <gzabl-AT-yahoo.com> for the report.
1483 1498
1484 1499 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1485 1500
1486 1501 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1487 1502 Fix bug where a naked 'alias' call in the ipythonrc file would
1488 1503 cause a crash. Bug reported by Jorgen Stenarson.
1489 1504
1490 1505 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1491 1506
1492 1507 * IPython/ipmaker.py (make_IPython): cleanups which should improve
1493 1508 startup time.
1494 1509
1495 1510 * IPython/iplib.py (runcode): my globals 'fix' for embedded
1496 1511 instances had introduced a bug with globals in normal code. Now
1497 1512 it's working in all cases.
1498 1513
1499 1514 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
1500 1515 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
1501 1516 has been introduced to set the default case sensitivity of the
1502 1517 searches. Users can still select either mode at runtime on a
1503 1518 per-search basis.
1504 1519
1505 1520 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
1506 1521
1507 1522 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
1508 1523 attributes in wildcard searches for subclasses. Modified version
1509 1524 of a patch by Jorgen.
1510 1525
1511 1526 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
1512 1527
1513 1528 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
1514 1529 embedded instances. I added a user_global_ns attribute to the
1515 1530 InteractiveShell class to handle this.
1516 1531
1517 1532 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
1518 1533
1519 1534 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
1520 1535 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
1521 1536 (reported under win32, but may happen also in other platforms).
1522 1537 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
1523 1538
1524 1539 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
1525 1540
1526 1541 * IPython/Magic.py (magic_psearch): new support for wildcard
1527 1542 patterns. Now, typing ?a*b will list all names which begin with a
1528 1543 and end in b, for example. The %psearch magic has full
1529 1544 docstrings. Many thanks to JΓΆrgen Stenarson
1530 1545 <jorgen.stenarson-AT-bostream.nu>, author of the patches
1531 1546 implementing this functionality.
1532 1547
1533 1548 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1534 1549
1535 1550 * Manual: fixed long-standing annoyance of double-dashes (as in
1536 1551 --prefix=~, for example) being stripped in the HTML version. This
1537 1552 is a latex2html bug, but a workaround was provided. Many thanks
1538 1553 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
1539 1554 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
1540 1555 rolling. This seemingly small issue had tripped a number of users
1541 1556 when first installing, so I'm glad to see it gone.
1542 1557
1543 1558 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1544 1559
1545 1560 * IPython/Extensions/numeric_formats.py: fix missing import,
1546 1561 reported by Stephen Walton.
1547 1562
1548 1563 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
1549 1564
1550 1565 * IPython/demo.py: finish demo module, fully documented now.
1551 1566
1552 1567 * IPython/genutils.py (file_read): simple little utility to read a
1553 1568 file and ensure it's closed afterwards.
1554 1569
1555 1570 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
1556 1571
1557 1572 * IPython/demo.py (Demo.__init__): added support for individually
1558 1573 tagging blocks for automatic execution.
1559 1574
1560 1575 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
1561 1576 syntax-highlighted python sources, requested by John.
1562 1577
1563 1578 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
1564 1579
1565 1580 * IPython/demo.py (Demo.again): fix bug where again() blocks after
1566 1581 finishing.
1567 1582
1568 1583 * IPython/genutils.py (shlex_split): moved from Magic to here,
1569 1584 where all 2.2 compatibility stuff lives. I needed it for demo.py.
1570 1585
1571 1586 * IPython/demo.py (Demo.__init__): added support for silent
1572 1587 blocks, improved marks as regexps, docstrings written.
1573 1588 (Demo.__init__): better docstring, added support for sys.argv.
1574 1589
1575 1590 * IPython/genutils.py (marquee): little utility used by the demo
1576 1591 code, handy in general.
1577 1592
1578 1593 * IPython/demo.py (Demo.__init__): new class for interactive
1579 1594 demos. Not documented yet, I just wrote it in a hurry for
1580 1595 scipy'05. Will docstring later.
1581 1596
1582 1597 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
1583 1598
1584 1599 * IPython/Shell.py (sigint_handler): Drastic simplification which
1585 1600 also seems to make Ctrl-C work correctly across threads! This is
1586 1601 so simple, that I can't beleive I'd missed it before. Needs more
1587 1602 testing, though.
1588 1603 (KBINT): Never mind, revert changes. I'm sure I'd tried something
1589 1604 like this before...
1590 1605
1591 1606 * IPython/genutils.py (get_home_dir): add protection against
1592 1607 non-dirs in win32 registry.
1593 1608
1594 1609 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
1595 1610 bug where dict was mutated while iterating (pysh crash).
1596 1611
1597 1612 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
1598 1613
1599 1614 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
1600 1615 spurious newlines added by this routine. After a report by
1601 1616 F. Mantegazza.
1602 1617
1603 1618 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
1604 1619
1605 1620 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
1606 1621 calls. These were a leftover from the GTK 1.x days, and can cause
1607 1622 problems in certain cases (after a report by John Hunter).
1608 1623
1609 1624 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
1610 1625 os.getcwd() fails at init time. Thanks to patch from David Remahl
1611 1626 <chmod007-AT-mac.com>.
1612 1627 (InteractiveShell.__init__): prevent certain special magics from
1613 1628 being shadowed by aliases. Closes
1614 1629 http://www.scipy.net/roundup/ipython/issue41.
1615 1630
1616 1631 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
1617 1632
1618 1633 * IPython/iplib.py (InteractiveShell.complete): Added new
1619 1634 top-level completion method to expose the completion mechanism
1620 1635 beyond readline-based environments.
1621 1636
1622 1637 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
1623 1638
1624 1639 * tools/ipsvnc (svnversion): fix svnversion capture.
1625 1640
1626 1641 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
1627 1642 attribute to self, which was missing. Before, it was set by a
1628 1643 routine which in certain cases wasn't being called, so the
1629 1644 instance could end up missing the attribute. This caused a crash.
1630 1645 Closes http://www.scipy.net/roundup/ipython/issue40.
1631 1646
1632 1647 2005-08-16 Fernando Perez <fperez@colorado.edu>
1633 1648
1634 1649 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
1635 1650 contains non-string attribute. Closes
1636 1651 http://www.scipy.net/roundup/ipython/issue38.
1637 1652
1638 1653 2005-08-14 Fernando Perez <fperez@colorado.edu>
1639 1654
1640 1655 * tools/ipsvnc: Minor improvements, to add changeset info.
1641 1656
1642 1657 2005-08-12 Fernando Perez <fperez@colorado.edu>
1643 1658
1644 1659 * IPython/iplib.py (runsource): remove self.code_to_run_src
1645 1660 attribute. I realized this is nothing more than
1646 1661 '\n'.join(self.buffer), and having the same data in two different
1647 1662 places is just asking for synchronization bugs. This may impact
1648 1663 people who have custom exception handlers, so I need to warn
1649 1664 ipython-dev about it (F. Mantegazza may use them).
1650 1665
1651 1666 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
1652 1667
1653 1668 * IPython/genutils.py: fix 2.2 compatibility (generators)
1654 1669
1655 1670 2005-07-18 Fernando Perez <fperez@colorado.edu>
1656 1671
1657 1672 * IPython/genutils.py (get_home_dir): fix to help users with
1658 1673 invalid $HOME under win32.
1659 1674
1660 1675 2005-07-17 Fernando Perez <fperez@colorado.edu>
1661 1676
1662 1677 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
1663 1678 some old hacks and clean up a bit other routines; code should be
1664 1679 simpler and a bit faster.
1665 1680
1666 1681 * IPython/iplib.py (interact): removed some last-resort attempts
1667 1682 to survive broken stdout/stderr. That code was only making it
1668 1683 harder to abstract out the i/o (necessary for gui integration),
1669 1684 and the crashes it could prevent were extremely rare in practice
1670 1685 (besides being fully user-induced in a pretty violent manner).
1671 1686
1672 1687 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
1673 1688 Nothing major yet, but the code is simpler to read; this should
1674 1689 make it easier to do more serious modifications in the future.
1675 1690
1676 1691 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
1677 1692 which broke in .15 (thanks to a report by Ville).
1678 1693
1679 1694 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
1680 1695 be quite correct, I know next to nothing about unicode). This
1681 1696 will allow unicode strings to be used in prompts, amongst other
1682 1697 cases. It also will prevent ipython from crashing when unicode
1683 1698 shows up unexpectedly in many places. If ascii encoding fails, we
1684 1699 assume utf_8. Currently the encoding is not a user-visible
1685 1700 setting, though it could be made so if there is demand for it.
1686 1701
1687 1702 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
1688 1703
1689 1704 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
1690 1705
1691 1706 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
1692 1707
1693 1708 * IPython/genutils.py: Add 2.2 compatibility here, so all other
1694 1709 code can work transparently for 2.2/2.3.
1695 1710
1696 1711 2005-07-16 Fernando Perez <fperez@colorado.edu>
1697 1712
1698 1713 * IPython/ultraTB.py (ExceptionColors): Make a global variable
1699 1714 out of the color scheme table used for coloring exception
1700 1715 tracebacks. This allows user code to add new schemes at runtime.
1701 1716 This is a minimally modified version of the patch at
1702 1717 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
1703 1718 for the contribution.
1704 1719
1705 1720 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
1706 1721 slightly modified version of the patch in
1707 1722 http://www.scipy.net/roundup/ipython/issue34, which also allows me
1708 1723 to remove the previous try/except solution (which was costlier).
1709 1724 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
1710 1725
1711 1726 2005-06-08 Fernando Perez <fperez@colorado.edu>
1712 1727
1713 1728 * IPython/iplib.py (write/write_err): Add methods to abstract all
1714 1729 I/O a bit more.
1715 1730
1716 1731 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
1717 1732 warning, reported by Aric Hagberg, fix by JD Hunter.
1718 1733
1719 1734 2005-06-02 *** Released version 0.6.15
1720 1735
1721 1736 2005-06-01 Fernando Perez <fperez@colorado.edu>
1722 1737
1723 1738 * IPython/iplib.py (MagicCompleter.file_matches): Fix
1724 1739 tab-completion of filenames within open-quoted strings. Note that
1725 1740 this requires that in ~/.ipython/ipythonrc, users change the
1726 1741 readline delimiters configuration to read:
1727 1742
1728 1743 readline_remove_delims -/~
1729 1744
1730 1745
1731 1746 2005-05-31 *** Released version 0.6.14
1732 1747
1733 1748 2005-05-29 Fernando Perez <fperez@colorado.edu>
1734 1749
1735 1750 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
1736 1751 with files not on the filesystem. Reported by Eliyahu Sandler
1737 1752 <eli@gondolin.net>
1738 1753
1739 1754 2005-05-22 Fernando Perez <fperez@colorado.edu>
1740 1755
1741 1756 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
1742 1757 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
1743 1758
1744 1759 2005-05-19 Fernando Perez <fperez@colorado.edu>
1745 1760
1746 1761 * IPython/iplib.py (safe_execfile): close a file which could be
1747 1762 left open (causing problems in win32, which locks open files).
1748 1763 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
1749 1764
1750 1765 2005-05-18 Fernando Perez <fperez@colorado.edu>
1751 1766
1752 1767 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
1753 1768 keyword arguments correctly to safe_execfile().
1754 1769
1755 1770 2005-05-13 Fernando Perez <fperez@colorado.edu>
1756 1771
1757 1772 * ipython.1: Added info about Qt to manpage, and threads warning
1758 1773 to usage page (invoked with --help).
1759 1774
1760 1775 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
1761 1776 new matcher (it goes at the end of the priority list) to do
1762 1777 tab-completion on named function arguments. Submitted by George
1763 1778 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
1764 1779 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
1765 1780 for more details.
1766 1781
1767 1782 * IPython/Magic.py (magic_run): Added new -e flag to ignore
1768 1783 SystemExit exceptions in the script being run. Thanks to a report
1769 1784 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
1770 1785 producing very annoying behavior when running unit tests.
1771 1786
1772 1787 2005-05-12 Fernando Perez <fperez@colorado.edu>
1773 1788
1774 1789 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
1775 1790 which I'd broken (again) due to a changed regexp. In the process,
1776 1791 added ';' as an escape to auto-quote the whole line without
1777 1792 splitting its arguments. Thanks to a report by Jerry McRae
1778 1793 <qrs0xyc02-AT-sneakemail.com>.
1779 1794
1780 1795 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
1781 1796 possible crashes caused by a TokenError. Reported by Ed Schofield
1782 1797 <schofield-AT-ftw.at>.
1783 1798
1784 1799 2005-05-06 Fernando Perez <fperez@colorado.edu>
1785 1800
1786 1801 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
1787 1802
1788 1803 2005-04-29 Fernando Perez <fperez@colorado.edu>
1789 1804
1790 1805 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
1791 1806 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
1792 1807 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
1793 1808 which provides support for Qt interactive usage (similar to the
1794 1809 existing one for WX and GTK). This had been often requested.
1795 1810
1796 1811 2005-04-14 *** Released version 0.6.13
1797 1812
1798 1813 2005-04-08 Fernando Perez <fperez@colorado.edu>
1799 1814
1800 1815 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
1801 1816 from _ofind, which gets called on almost every input line. Now,
1802 1817 we only try to get docstrings if they are actually going to be
1803 1818 used (the overhead of fetching unnecessary docstrings can be
1804 1819 noticeable for certain objects, such as Pyro proxies).
1805 1820
1806 1821 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
1807 1822 for completers. For some reason I had been passing them the state
1808 1823 variable, which completers never actually need, and was in
1809 1824 conflict with the rlcompleter API. Custom completers ONLY need to
1810 1825 take the text parameter.
1811 1826
1812 1827 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
1813 1828 work correctly in pysh. I've also moved all the logic which used
1814 1829 to be in pysh.py here, which will prevent problems with future
1815 1830 upgrades. However, this time I must warn users to update their
1816 1831 pysh profile to include the line
1817 1832
1818 1833 import_all IPython.Extensions.InterpreterExec
1819 1834
1820 1835 because otherwise things won't work for them. They MUST also
1821 1836 delete pysh.py and the line
1822 1837
1823 1838 execfile pysh.py
1824 1839
1825 1840 from their ipythonrc-pysh.
1826 1841
1827 1842 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
1828 1843 robust in the face of objects whose dir() returns non-strings
1829 1844 (which it shouldn't, but some broken libs like ITK do). Thanks to
1830 1845 a patch by John Hunter (implemented differently, though). Also
1831 1846 minor improvements by using .extend instead of + on lists.
1832 1847
1833 1848 * pysh.py:
1834 1849
1835 1850 2005-04-06 Fernando Perez <fperez@colorado.edu>
1836 1851
1837 1852 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
1838 1853 by default, so that all users benefit from it. Those who don't
1839 1854 want it can still turn it off.
1840 1855
1841 1856 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
1842 1857 config file, I'd forgotten about this, so users were getting it
1843 1858 off by default.
1844 1859
1845 1860 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
1846 1861 consistency. Now magics can be called in multiline statements,
1847 1862 and python variables can be expanded in magic calls via $var.
1848 1863 This makes the magic system behave just like aliases or !system
1849 1864 calls.
1850 1865
1851 1866 2005-03-28 Fernando Perez <fperez@colorado.edu>
1852 1867
1853 1868 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
1854 1869 expensive string additions for building command. Add support for
1855 1870 trailing ';' when autocall is used.
1856 1871
1857 1872 2005-03-26 Fernando Perez <fperez@colorado.edu>
1858 1873
1859 1874 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
1860 1875 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
1861 1876 ipython.el robust against prompts with any number of spaces
1862 1877 (including 0) after the ':' character.
1863 1878
1864 1879 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
1865 1880 continuation prompt, which misled users to think the line was
1866 1881 already indented. Closes debian Bug#300847, reported to me by
1867 1882 Norbert Tretkowski <tretkowski-AT-inittab.de>.
1868 1883
1869 1884 2005-03-23 Fernando Perez <fperez@colorado.edu>
1870 1885
1871 1886 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
1872 1887 properly aligned if they have embedded newlines.
1873 1888
1874 1889 * IPython/iplib.py (runlines): Add a public method to expose
1875 1890 IPython's code execution machinery, so that users can run strings
1876 1891 as if they had been typed at the prompt interactively.
1877 1892 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
1878 1893 methods which can call the system shell, but with python variable
1879 1894 expansion. The three such methods are: __IPYTHON__.system,
1880 1895 .getoutput and .getoutputerror. These need to be documented in a
1881 1896 'public API' section (to be written) of the manual.
1882 1897
1883 1898 2005-03-20 Fernando Perez <fperez@colorado.edu>
1884 1899
1885 1900 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
1886 1901 for custom exception handling. This is quite powerful, and it
1887 1902 allows for user-installable exception handlers which can trap
1888 1903 custom exceptions at runtime and treat them separately from
1889 1904 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
1890 1905 Mantegazza <mantegazza-AT-ill.fr>.
1891 1906 (InteractiveShell.set_custom_completer): public API function to
1892 1907 add new completers at runtime.
1893 1908
1894 1909 2005-03-19 Fernando Perez <fperez@colorado.edu>
1895 1910
1896 1911 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
1897 1912 allow objects which provide their docstrings via non-standard
1898 1913 mechanisms (like Pyro proxies) to still be inspected by ipython's
1899 1914 ? system.
1900 1915
1901 1916 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
1902 1917 automatic capture system. I tried quite hard to make it work
1903 1918 reliably, and simply failed. I tried many combinations with the
1904 1919 subprocess module, but eventually nothing worked in all needed
1905 1920 cases (not blocking stdin for the child, duplicating stdout
1906 1921 without blocking, etc). The new %sc/%sx still do capture to these
1907 1922 magical list/string objects which make shell use much more
1908 1923 conveninent, so not all is lost.
1909 1924
1910 1925 XXX - FIX MANUAL for the change above!
1911 1926
1912 1927 (runsource): I copied code.py's runsource() into ipython to modify
1913 1928 it a bit. Now the code object and source to be executed are
1914 1929 stored in ipython. This makes this info accessible to third-party
1915 1930 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
1916 1931 Mantegazza <mantegazza-AT-ill.fr>.
1917 1932
1918 1933 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
1919 1934 history-search via readline (like C-p/C-n). I'd wanted this for a
1920 1935 long time, but only recently found out how to do it. For users
1921 1936 who already have their ipythonrc files made and want this, just
1922 1937 add:
1923 1938
1924 1939 readline_parse_and_bind "\e[A": history-search-backward
1925 1940 readline_parse_and_bind "\e[B": history-search-forward
1926 1941
1927 1942 2005-03-18 Fernando Perez <fperez@colorado.edu>
1928 1943
1929 1944 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
1930 1945 LSString and SList classes which allow transparent conversions
1931 1946 between list mode and whitespace-separated string.
1932 1947 (magic_r): Fix recursion problem in %r.
1933 1948
1934 1949 * IPython/genutils.py (LSString): New class to be used for
1935 1950 automatic storage of the results of all alias/system calls in _o
1936 1951 and _e (stdout/err). These provide a .l/.list attribute which
1937 1952 does automatic splitting on newlines. This means that for most
1938 1953 uses, you'll never need to do capturing of output with %sc/%sx
1939 1954 anymore, since ipython keeps this always done for you. Note that
1940 1955 only the LAST results are stored, the _o/e variables are
1941 1956 overwritten on each call. If you need to save their contents
1942 1957 further, simply bind them to any other name.
1943 1958
1944 1959 2005-03-17 Fernando Perez <fperez@colorado.edu>
1945 1960
1946 1961 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
1947 1962 prompt namespace handling.
1948 1963
1949 1964 2005-03-16 Fernando Perez <fperez@colorado.edu>
1950 1965
1951 1966 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
1952 1967 classic prompts to be '>>> ' (final space was missing, and it
1953 1968 trips the emacs python mode).
1954 1969 (BasePrompt.__str__): Added safe support for dynamic prompt
1955 1970 strings. Now you can set your prompt string to be '$x', and the
1956 1971 value of x will be printed from your interactive namespace. The
1957 1972 interpolation syntax includes the full Itpl support, so
1958 1973 ${foo()+x+bar()} is a valid prompt string now, and the function
1959 1974 calls will be made at runtime.
1960 1975
1961 1976 2005-03-15 Fernando Perez <fperez@colorado.edu>
1962 1977
1963 1978 * IPython/Magic.py (magic_history): renamed %hist to %history, to
1964 1979 avoid name clashes in pylab. %hist still works, it just forwards
1965 1980 the call to %history.
1966 1981
1967 1982 2005-03-02 *** Released version 0.6.12
1968 1983
1969 1984 2005-03-02 Fernando Perez <fperez@colorado.edu>
1970 1985
1971 1986 * IPython/iplib.py (handle_magic): log magic calls properly as
1972 1987 ipmagic() function calls.
1973 1988
1974 1989 * IPython/Magic.py (magic_time): Improved %time to support
1975 1990 statements and provide wall-clock as well as CPU time.
1976 1991
1977 1992 2005-02-27 Fernando Perez <fperez@colorado.edu>
1978 1993
1979 1994 * IPython/hooks.py: New hooks module, to expose user-modifiable
1980 1995 IPython functionality in a clean manner. For now only the editor
1981 1996 hook is actually written, and other thigns which I intend to turn
1982 1997 into proper hooks aren't yet there. The display and prefilter
1983 1998 stuff, for example, should be hooks. But at least now the
1984 1999 framework is in place, and the rest can be moved here with more
1985 2000 time later. IPython had had a .hooks variable for a long time for
1986 2001 this purpose, but I'd never actually used it for anything.
1987 2002
1988 2003 2005-02-26 Fernando Perez <fperez@colorado.edu>
1989 2004
1990 2005 * IPython/ipmaker.py (make_IPython): make the default ipython
1991 2006 directory be called _ipython under win32, to follow more the
1992 2007 naming peculiarities of that platform (where buggy software like
1993 2008 Visual Sourcesafe breaks with .named directories). Reported by
1994 2009 Ville Vainio.
1995 2010
1996 2011 2005-02-23 Fernando Perez <fperez@colorado.edu>
1997 2012
1998 2013 * IPython/iplib.py (InteractiveShell.__init__): removed a few
1999 2014 auto_aliases for win32 which were causing problems. Users can
2000 2015 define the ones they personally like.
2001 2016
2002 2017 2005-02-21 Fernando Perez <fperez@colorado.edu>
2003 2018
2004 2019 * IPython/Magic.py (magic_time): new magic to time execution of
2005 2020 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
2006 2021
2007 2022 2005-02-19 Fernando Perez <fperez@colorado.edu>
2008 2023
2009 2024 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
2010 2025 into keys (for prompts, for example).
2011 2026
2012 2027 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
2013 2028 prompts in case users want them. This introduces a small behavior
2014 2029 change: ipython does not automatically add a space to all prompts
2015 2030 anymore. To get the old prompts with a space, users should add it
2016 2031 manually to their ipythonrc file, so for example prompt_in1 should
2017 2032 now read 'In [\#]: ' instead of 'In [\#]:'.
2018 2033 (BasePrompt.__init__): New option prompts_pad_left (only in rc
2019 2034 file) to control left-padding of secondary prompts.
2020 2035
2021 2036 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
2022 2037 the profiler can't be imported. Fix for Debian, which removed
2023 2038 profile.py because of License issues. I applied a slightly
2024 2039 modified version of the original Debian patch at
2025 2040 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
2026 2041
2027 2042 2005-02-17 Fernando Perez <fperez@colorado.edu>
2028 2043
2029 2044 * IPython/genutils.py (native_line_ends): Fix bug which would
2030 2045 cause improper line-ends under win32 b/c I was not opening files
2031 2046 in binary mode. Bug report and fix thanks to Ville.
2032 2047
2033 2048 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
2034 2049 trying to catch spurious foo[1] autocalls. My fix actually broke
2035 2050 ',/' autoquote/call with explicit escape (bad regexp).
2036 2051
2037 2052 2005-02-15 *** Released version 0.6.11
2038 2053
2039 2054 2005-02-14 Fernando Perez <fperez@colorado.edu>
2040 2055
2041 2056 * IPython/background_jobs.py: New background job management
2042 2057 subsystem. This is implemented via a new set of classes, and
2043 2058 IPython now provides a builtin 'jobs' object for background job
2044 2059 execution. A convenience %bg magic serves as a lightweight
2045 2060 frontend for starting the more common type of calls. This was
2046 2061 inspired by discussions with B. Granger and the BackgroundCommand
2047 2062 class described in the book Python Scripting for Computational
2048 2063 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
2049 2064 (although ultimately no code from this text was used, as IPython's
2050 2065 system is a separate implementation).
2051 2066
2052 2067 * IPython/iplib.py (MagicCompleter.python_matches): add new option
2053 2068 to control the completion of single/double underscore names
2054 2069 separately. As documented in the example ipytonrc file, the
2055 2070 readline_omit__names variable can now be set to 2, to omit even
2056 2071 single underscore names. Thanks to a patch by Brian Wong
2057 2072 <BrianWong-AT-AirgoNetworks.Com>.
2058 2073 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
2059 2074 be autocalled as foo([1]) if foo were callable. A problem for
2060 2075 things which are both callable and implement __getitem__.
2061 2076 (init_readline): Fix autoindentation for win32. Thanks to a patch
2062 2077 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
2063 2078
2064 2079 2005-02-12 Fernando Perez <fperez@colorado.edu>
2065 2080
2066 2081 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
2067 2082 which I had written long ago to sort out user error messages which
2068 2083 may occur during startup. This seemed like a good idea initially,
2069 2084 but it has proven a disaster in retrospect. I don't want to
2070 2085 change much code for now, so my fix is to set the internal 'debug'
2071 2086 flag to true everywhere, whose only job was precisely to control
2072 2087 this subsystem. This closes issue 28 (as well as avoiding all
2073 2088 sorts of strange hangups which occur from time to time).
2074 2089
2075 2090 2005-02-07 Fernando Perez <fperez@colorado.edu>
2076 2091
2077 2092 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
2078 2093 previous call produced a syntax error.
2079 2094
2080 2095 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2081 2096 classes without constructor.
2082 2097
2083 2098 2005-02-06 Fernando Perez <fperez@colorado.edu>
2084 2099
2085 2100 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
2086 2101 completions with the results of each matcher, so we return results
2087 2102 to the user from all namespaces. This breaks with ipython
2088 2103 tradition, but I think it's a nicer behavior. Now you get all
2089 2104 possible completions listed, from all possible namespaces (python,
2090 2105 filesystem, magics...) After a request by John Hunter
2091 2106 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2092 2107
2093 2108 2005-02-05 Fernando Perez <fperez@colorado.edu>
2094 2109
2095 2110 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
2096 2111 the call had quote characters in it (the quotes were stripped).
2097 2112
2098 2113 2005-01-31 Fernando Perez <fperez@colorado.edu>
2099 2114
2100 2115 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
2101 2116 Itpl.itpl() to make the code more robust against psyco
2102 2117 optimizations.
2103 2118
2104 2119 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
2105 2120 of causing an exception. Quicker, cleaner.
2106 2121
2107 2122 2005-01-28 Fernando Perez <fperez@colorado.edu>
2108 2123
2109 2124 * scripts/ipython_win_post_install.py (install): hardcode
2110 2125 sys.prefix+'python.exe' as the executable path. It turns out that
2111 2126 during the post-installation run, sys.executable resolves to the
2112 2127 name of the binary installer! I should report this as a distutils
2113 2128 bug, I think. I updated the .10 release with this tiny fix, to
2114 2129 avoid annoying the lists further.
2115 2130
2116 2131 2005-01-27 *** Released version 0.6.10
2117 2132
2118 2133 2005-01-27 Fernando Perez <fperez@colorado.edu>
2119 2134
2120 2135 * IPython/numutils.py (norm): Added 'inf' as optional name for
2121 2136 L-infinity norm, included references to mathworld.com for vector
2122 2137 norm definitions.
2123 2138 (amin/amax): added amin/amax for array min/max. Similar to what
2124 2139 pylab ships with after the recent reorganization of names.
2125 2140 (spike/spike_odd): removed deprecated spike/spike_odd functions.
2126 2141
2127 2142 * ipython.el: committed Alex's recent fixes and improvements.
2128 2143 Tested with python-mode from CVS, and it looks excellent. Since
2129 2144 python-mode hasn't released anything in a while, I'm temporarily
2130 2145 putting a copy of today's CVS (v 4.70) of python-mode in:
2131 2146 http://ipython.scipy.org/tmp/python-mode.el
2132 2147
2133 2148 * scripts/ipython_win_post_install.py (install): Win32 fix to use
2134 2149 sys.executable for the executable name, instead of assuming it's
2135 2150 called 'python.exe' (the post-installer would have produced broken
2136 2151 setups on systems with a differently named python binary).
2137 2152
2138 2153 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
2139 2154 references to os.linesep, to make the code more
2140 2155 platform-independent. This is also part of the win32 coloring
2141 2156 fixes.
2142 2157
2143 2158 * IPython/genutils.py (page_dumb): Remove attempts to chop long
2144 2159 lines, which actually cause coloring bugs because the length of
2145 2160 the line is very difficult to correctly compute with embedded
2146 2161 escapes. This was the source of all the coloring problems under
2147 2162 Win32. I think that _finally_, Win32 users have a properly
2148 2163 working ipython in all respects. This would never have happened
2149 2164 if not for Gary Bishop and Viktor Ransmayr's great help and work.
2150 2165
2151 2166 2005-01-26 *** Released version 0.6.9
2152 2167
2153 2168 2005-01-25 Fernando Perez <fperez@colorado.edu>
2154 2169
2155 2170 * setup.py: finally, we have a true Windows installer, thanks to
2156 2171 the excellent work of Viktor Ransmayr
2157 2172 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
2158 2173 Windows users. The setup routine is quite a bit cleaner thanks to
2159 2174 this, and the post-install script uses the proper functions to
2160 2175 allow a clean de-installation using the standard Windows Control
2161 2176 Panel.
2162 2177
2163 2178 * IPython/genutils.py (get_home_dir): changed to use the $HOME
2164 2179 environment variable under all OSes (including win32) if
2165 2180 available. This will give consistency to win32 users who have set
2166 2181 this variable for any reason. If os.environ['HOME'] fails, the
2167 2182 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
2168 2183
2169 2184 2005-01-24 Fernando Perez <fperez@colorado.edu>
2170 2185
2171 2186 * IPython/numutils.py (empty_like): add empty_like(), similar to
2172 2187 zeros_like() but taking advantage of the new empty() Numeric routine.
2173 2188
2174 2189 2005-01-23 *** Released version 0.6.8
2175 2190
2176 2191 2005-01-22 Fernando Perez <fperez@colorado.edu>
2177 2192
2178 2193 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
2179 2194 automatic show() calls. After discussing things with JDH, it
2180 2195 turns out there are too many corner cases where this can go wrong.
2181 2196 It's best not to try to be 'too smart', and simply have ipython
2182 2197 reproduce as much as possible the default behavior of a normal
2183 2198 python shell.
2184 2199
2185 2200 * IPython/iplib.py (InteractiveShell.__init__): Modified the
2186 2201 line-splitting regexp and _prefilter() to avoid calling getattr()
2187 2202 on assignments. This closes
2188 2203 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
2189 2204 readline uses getattr(), so a simple <TAB> keypress is still
2190 2205 enough to trigger getattr() calls on an object.
2191 2206
2192 2207 2005-01-21 Fernando Perez <fperez@colorado.edu>
2193 2208
2194 2209 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
2195 2210 docstring under pylab so it doesn't mask the original.
2196 2211
2197 2212 2005-01-21 *** Released version 0.6.7
2198 2213
2199 2214 2005-01-21 Fernando Perez <fperez@colorado.edu>
2200 2215
2201 2216 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
2202 2217 signal handling for win32 users in multithreaded mode.
2203 2218
2204 2219 2005-01-17 Fernando Perez <fperez@colorado.edu>
2205 2220
2206 2221 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2207 2222 instances with no __init__. After a crash report by Norbert Nemec
2208 2223 <Norbert-AT-nemec-online.de>.
2209 2224
2210 2225 2005-01-14 Fernando Perez <fperez@colorado.edu>
2211 2226
2212 2227 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
2213 2228 names for verbose exceptions, when multiple dotted names and the
2214 2229 'parent' object were present on the same line.
2215 2230
2216 2231 2005-01-11 Fernando Perez <fperez@colorado.edu>
2217 2232
2218 2233 * IPython/genutils.py (flag_calls): new utility to trap and flag
2219 2234 calls in functions. I need it to clean up matplotlib support.
2220 2235 Also removed some deprecated code in genutils.
2221 2236
2222 2237 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
2223 2238 that matplotlib scripts called with %run, which don't call show()
2224 2239 themselves, still have their plotting windows open.
2225 2240
2226 2241 2005-01-05 Fernando Perez <fperez@colorado.edu>
2227 2242
2228 2243 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
2229 2244 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
2230 2245
2231 2246 2004-12-19 Fernando Perez <fperez@colorado.edu>
2232 2247
2233 2248 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
2234 2249 parent_runcode, which was an eyesore. The same result can be
2235 2250 obtained with Python's regular superclass mechanisms.
2236 2251
2237 2252 2004-12-17 Fernando Perez <fperez@colorado.edu>
2238 2253
2239 2254 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
2240 2255 reported by Prabhu.
2241 2256 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
2242 2257 sys.stderr) instead of explicitly calling sys.stderr. This helps
2243 2258 maintain our I/O abstractions clean, for future GUI embeddings.
2244 2259
2245 2260 * IPython/genutils.py (info): added new utility for sys.stderr
2246 2261 unified info message handling (thin wrapper around warn()).
2247 2262
2248 2263 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
2249 2264 composite (dotted) names on verbose exceptions.
2250 2265 (VerboseTB.nullrepr): harden against another kind of errors which
2251 2266 Python's inspect module can trigger, and which were crashing
2252 2267 IPython. Thanks to a report by Marco Lombardi
2253 2268 <mlombard-AT-ma010192.hq.eso.org>.
2254 2269
2255 2270 2004-12-13 *** Released version 0.6.6
2256 2271
2257 2272 2004-12-12 Fernando Perez <fperez@colorado.edu>
2258 2273
2259 2274 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
2260 2275 generated by pygtk upon initialization if it was built without
2261 2276 threads (for matplotlib users). After a crash reported by
2262 2277 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
2263 2278
2264 2279 * IPython/ipmaker.py (make_IPython): fix small bug in the
2265 2280 import_some parameter for multiple imports.
2266 2281
2267 2282 * IPython/iplib.py (ipmagic): simplified the interface of
2268 2283 ipmagic() to take a single string argument, just as it would be
2269 2284 typed at the IPython cmd line.
2270 2285 (ipalias): Added new ipalias() with an interface identical to
2271 2286 ipmagic(). This completes exposing a pure python interface to the
2272 2287 alias and magic system, which can be used in loops or more complex
2273 2288 code where IPython's automatic line mangling is not active.
2274 2289
2275 2290 * IPython/genutils.py (timing): changed interface of timing to
2276 2291 simply run code once, which is the most common case. timings()
2277 2292 remains unchanged, for the cases where you want multiple runs.
2278 2293
2279 2294 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
2280 2295 bug where Python2.2 crashes with exec'ing code which does not end
2281 2296 in a single newline. Python 2.3 is OK, so I hadn't noticed this
2282 2297 before.
2283 2298
2284 2299 2004-12-10 Fernando Perez <fperez@colorado.edu>
2285 2300
2286 2301 * IPython/Magic.py (Magic.magic_prun): changed name of option from
2287 2302 -t to -T, to accomodate the new -t flag in %run (the %run and
2288 2303 %prun options are kind of intermixed, and it's not easy to change
2289 2304 this with the limitations of python's getopt).
2290 2305
2291 2306 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
2292 2307 the execution of scripts. It's not as fine-tuned as timeit.py,
2293 2308 but it works from inside ipython (and under 2.2, which lacks
2294 2309 timeit.py). Optionally a number of runs > 1 can be given for
2295 2310 timing very short-running code.
2296 2311
2297 2312 * IPython/genutils.py (uniq_stable): new routine which returns a
2298 2313 list of unique elements in any iterable, but in stable order of
2299 2314 appearance. I needed this for the ultraTB fixes, and it's a handy
2300 2315 utility.
2301 2316
2302 2317 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
2303 2318 dotted names in Verbose exceptions. This had been broken since
2304 2319 the very start, now x.y will properly be printed in a Verbose
2305 2320 traceback, instead of x being shown and y appearing always as an
2306 2321 'undefined global'. Getting this to work was a bit tricky,
2307 2322 because by default python tokenizers are stateless. Saved by
2308 2323 python's ability to easily add a bit of state to an arbitrary
2309 2324 function (without needing to build a full-blown callable object).
2310 2325
2311 2326 Also big cleanup of this code, which had horrendous runtime
2312 2327 lookups of zillions of attributes for colorization. Moved all
2313 2328 this code into a few templates, which make it cleaner and quicker.
2314 2329
2315 2330 Printout quality was also improved for Verbose exceptions: one
2316 2331 variable per line, and memory addresses are printed (this can be
2317 2332 quite handy in nasty debugging situations, which is what Verbose
2318 2333 is for).
2319 2334
2320 2335 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
2321 2336 the command line as scripts to be loaded by embedded instances.
2322 2337 Doing so has the potential for an infinite recursion if there are
2323 2338 exceptions thrown in the process. This fixes a strange crash
2324 2339 reported by Philippe MULLER <muller-AT-irit.fr>.
2325 2340
2326 2341 2004-12-09 Fernando Perez <fperez@colorado.edu>
2327 2342
2328 2343 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
2329 2344 to reflect new names in matplotlib, which now expose the
2330 2345 matlab-compatible interface via a pylab module instead of the
2331 2346 'matlab' name. The new code is backwards compatible, so users of
2332 2347 all matplotlib versions are OK. Patch by J. Hunter.
2333 2348
2334 2349 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
2335 2350 of __init__ docstrings for instances (class docstrings are already
2336 2351 automatically printed). Instances with customized docstrings
2337 2352 (indep. of the class) are also recognized and all 3 separate
2338 2353 docstrings are printed (instance, class, constructor). After some
2339 2354 comments/suggestions by J. Hunter.
2340 2355
2341 2356 2004-12-05 Fernando Perez <fperez@colorado.edu>
2342 2357
2343 2358 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
2344 2359 warnings when tab-completion fails and triggers an exception.
2345 2360
2346 2361 2004-12-03 Fernando Perez <fperez@colorado.edu>
2347 2362
2348 2363 * IPython/Magic.py (magic_prun): Fix bug where an exception would
2349 2364 be triggered when using 'run -p'. An incorrect option flag was
2350 2365 being set ('d' instead of 'D').
2351 2366 (manpage): fix missing escaped \- sign.
2352 2367
2353 2368 2004-11-30 *** Released version 0.6.5
2354 2369
2355 2370 2004-11-30 Fernando Perez <fperez@colorado.edu>
2356 2371
2357 2372 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
2358 2373 setting with -d option.
2359 2374
2360 2375 * setup.py (docfiles): Fix problem where the doc glob I was using
2361 2376 was COMPLETELY BROKEN. It was giving the right files by pure
2362 2377 accident, but failed once I tried to include ipython.el. Note:
2363 2378 glob() does NOT allow you to do exclusion on multiple endings!
2364 2379
2365 2380 2004-11-29 Fernando Perez <fperez@colorado.edu>
2366 2381
2367 2382 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
2368 2383 the manpage as the source. Better formatting & consistency.
2369 2384
2370 2385 * IPython/Magic.py (magic_run): Added new -d option, to run
2371 2386 scripts under the control of the python pdb debugger. Note that
2372 2387 this required changing the %prun option -d to -D, to avoid a clash
2373 2388 (since %run must pass options to %prun, and getopt is too dumb to
2374 2389 handle options with string values with embedded spaces). Thanks
2375 2390 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
2376 2391 (magic_who_ls): added type matching to %who and %whos, so that one
2377 2392 can filter their output to only include variables of certain
2378 2393 types. Another suggestion by Matthew.
2379 2394 (magic_whos): Added memory summaries in kb and Mb for arrays.
2380 2395 (magic_who): Improve formatting (break lines every 9 vars).
2381 2396
2382 2397 2004-11-28 Fernando Perez <fperez@colorado.edu>
2383 2398
2384 2399 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
2385 2400 cache when empty lines were present.
2386 2401
2387 2402 2004-11-24 Fernando Perez <fperez@colorado.edu>
2388 2403
2389 2404 * IPython/usage.py (__doc__): document the re-activated threading
2390 2405 options for WX and GTK.
2391 2406
2392 2407 2004-11-23 Fernando Perez <fperez@colorado.edu>
2393 2408
2394 2409 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
2395 2410 the -wthread and -gthread options, along with a new -tk one to try
2396 2411 and coordinate Tk threading with wx/gtk. The tk support is very
2397 2412 platform dependent, since it seems to require Tcl and Tk to be
2398 2413 built with threads (Fedora1/2 appears NOT to have it, but in
2399 2414 Prabhu's Debian boxes it works OK). But even with some Tk
2400 2415 limitations, this is a great improvement.
2401 2416
2402 2417 * IPython/Prompts.py (prompt_specials_color): Added \t for time
2403 2418 info in user prompts. Patch by Prabhu.
2404 2419
2405 2420 2004-11-18 Fernando Perez <fperez@colorado.edu>
2406 2421
2407 2422 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
2408 2423 EOFErrors and bail, to avoid infinite loops if a non-terminating
2409 2424 file is fed into ipython. Patch submitted in issue 19 by user,
2410 2425 many thanks.
2411 2426
2412 2427 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
2413 2428 autoquote/parens in continuation prompts, which can cause lots of
2414 2429 problems. Closes roundup issue 20.
2415 2430
2416 2431 2004-11-17 Fernando Perez <fperez@colorado.edu>
2417 2432
2418 2433 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
2419 2434 reported as debian bug #280505. I'm not sure my local changelog
2420 2435 entry has the proper debian format (Jack?).
2421 2436
2422 2437 2004-11-08 *** Released version 0.6.4
2423 2438
2424 2439 2004-11-08 Fernando Perez <fperez@colorado.edu>
2425 2440
2426 2441 * IPython/iplib.py (init_readline): Fix exit message for Windows
2427 2442 when readline is active. Thanks to a report by Eric Jones
2428 2443 <eric-AT-enthought.com>.
2429 2444
2430 2445 2004-11-07 Fernando Perez <fperez@colorado.edu>
2431 2446
2432 2447 * IPython/genutils.py (page): Add a trap for OSError exceptions,
2433 2448 sometimes seen by win2k/cygwin users.
2434 2449
2435 2450 2004-11-06 Fernando Perez <fperez@colorado.edu>
2436 2451
2437 2452 * IPython/iplib.py (interact): Change the handling of %Exit from
2438 2453 trying to propagate a SystemExit to an internal ipython flag.
2439 2454 This is less elegant than using Python's exception mechanism, but
2440 2455 I can't get that to work reliably with threads, so under -pylab
2441 2456 %Exit was hanging IPython. Cross-thread exception handling is
2442 2457 really a bitch. Thaks to a bug report by Stephen Walton
2443 2458 <stephen.walton-AT-csun.edu>.
2444 2459
2445 2460 2004-11-04 Fernando Perez <fperez@colorado.edu>
2446 2461
2447 2462 * IPython/iplib.py (raw_input_original): store a pointer to the
2448 2463 true raw_input to harden against code which can modify it
2449 2464 (wx.py.PyShell does this and would otherwise crash ipython).
2450 2465 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
2451 2466
2452 2467 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
2453 2468 Ctrl-C problem, which does not mess up the input line.
2454 2469
2455 2470 2004-11-03 Fernando Perez <fperez@colorado.edu>
2456 2471
2457 2472 * IPython/Release.py: Changed licensing to BSD, in all files.
2458 2473 (name): lowercase name for tarball/RPM release.
2459 2474
2460 2475 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
2461 2476 use throughout ipython.
2462 2477
2463 2478 * IPython/Magic.py (Magic._ofind): Switch to using the new
2464 2479 OInspect.getdoc() function.
2465 2480
2466 2481 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
2467 2482 of the line currently being canceled via Ctrl-C. It's extremely
2468 2483 ugly, but I don't know how to do it better (the problem is one of
2469 2484 handling cross-thread exceptions).
2470 2485
2471 2486 2004-10-28 Fernando Perez <fperez@colorado.edu>
2472 2487
2473 2488 * IPython/Shell.py (signal_handler): add signal handlers to trap
2474 2489 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
2475 2490 report by Francesc Alted.
2476 2491
2477 2492 2004-10-21 Fernando Perez <fperez@colorado.edu>
2478 2493
2479 2494 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
2480 2495 to % for pysh syntax extensions.
2481 2496
2482 2497 2004-10-09 Fernando Perez <fperez@colorado.edu>
2483 2498
2484 2499 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
2485 2500 arrays to print a more useful summary, without calling str(arr).
2486 2501 This avoids the problem of extremely lengthy computations which
2487 2502 occur if arr is large, and appear to the user as a system lockup
2488 2503 with 100% cpu activity. After a suggestion by Kristian Sandberg
2489 2504 <Kristian.Sandberg@colorado.edu>.
2490 2505 (Magic.__init__): fix bug in global magic escapes not being
2491 2506 correctly set.
2492 2507
2493 2508 2004-10-08 Fernando Perez <fperez@colorado.edu>
2494 2509
2495 2510 * IPython/Magic.py (__license__): change to absolute imports of
2496 2511 ipython's own internal packages, to start adapting to the absolute
2497 2512 import requirement of PEP-328.
2498 2513
2499 2514 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
2500 2515 files, and standardize author/license marks through the Release
2501 2516 module instead of having per/file stuff (except for files with
2502 2517 particular licenses, like the MIT/PSF-licensed codes).
2503 2518
2504 2519 * IPython/Debugger.py: remove dead code for python 2.1
2505 2520
2506 2521 2004-10-04 Fernando Perez <fperez@colorado.edu>
2507 2522
2508 2523 * IPython/iplib.py (ipmagic): New function for accessing magics
2509 2524 via a normal python function call.
2510 2525
2511 2526 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
2512 2527 from '@' to '%', to accomodate the new @decorator syntax of python
2513 2528 2.4.
2514 2529
2515 2530 2004-09-29 Fernando Perez <fperez@colorado.edu>
2516 2531
2517 2532 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
2518 2533 matplotlib.use to prevent running scripts which try to switch
2519 2534 interactive backends from within ipython. This will just crash
2520 2535 the python interpreter, so we can't allow it (but a detailed error
2521 2536 is given to the user).
2522 2537
2523 2538 2004-09-28 Fernando Perez <fperez@colorado.edu>
2524 2539
2525 2540 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
2526 2541 matplotlib-related fixes so that using @run with non-matplotlib
2527 2542 scripts doesn't pop up spurious plot windows. This requires
2528 2543 matplotlib >= 0.63, where I had to make some changes as well.
2529 2544
2530 2545 * IPython/ipmaker.py (make_IPython): update version requirement to
2531 2546 python 2.2.
2532 2547
2533 2548 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
2534 2549 banner arg for embedded customization.
2535 2550
2536 2551 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
2537 2552 explicit uses of __IP as the IPython's instance name. Now things
2538 2553 are properly handled via the shell.name value. The actual code
2539 2554 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
2540 2555 is much better than before. I'll clean things completely when the
2541 2556 magic stuff gets a real overhaul.
2542 2557
2543 2558 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
2544 2559 minor changes to debian dir.
2545 2560
2546 2561 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
2547 2562 pointer to the shell itself in the interactive namespace even when
2548 2563 a user-supplied dict is provided. This is needed for embedding
2549 2564 purposes (found by tests with Michel Sanner).
2550 2565
2551 2566 2004-09-27 Fernando Perez <fperez@colorado.edu>
2552 2567
2553 2568 * IPython/UserConfig/ipythonrc: remove []{} from
2554 2569 readline_remove_delims, so that things like [modname.<TAB> do
2555 2570 proper completion. This disables [].TAB, but that's a less common
2556 2571 case than module names in list comprehensions, for example.
2557 2572 Thanks to a report by Andrea Riciputi.
2558 2573
2559 2574 2004-09-09 Fernando Perez <fperez@colorado.edu>
2560 2575
2561 2576 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
2562 2577 blocking problems in win32 and osx. Fix by John.
2563 2578
2564 2579 2004-09-08 Fernando Perez <fperez@colorado.edu>
2565 2580
2566 2581 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
2567 2582 for Win32 and OSX. Fix by John Hunter.
2568 2583
2569 2584 2004-08-30 *** Released version 0.6.3
2570 2585
2571 2586 2004-08-30 Fernando Perez <fperez@colorado.edu>
2572 2587
2573 2588 * setup.py (isfile): Add manpages to list of dependent files to be
2574 2589 updated.
2575 2590
2576 2591 2004-08-27 Fernando Perez <fperez@colorado.edu>
2577 2592
2578 2593 * IPython/Shell.py (start): I've disabled -wthread and -gthread
2579 2594 for now. They don't really work with standalone WX/GTK code
2580 2595 (though matplotlib IS working fine with both of those backends).
2581 2596 This will neeed much more testing. I disabled most things with
2582 2597 comments, so turning it back on later should be pretty easy.
2583 2598
2584 2599 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
2585 2600 autocalling of expressions like r'foo', by modifying the line
2586 2601 split regexp. Closes
2587 2602 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
2588 2603 Riley <ipythonbugs-AT-sabi.net>.
2589 2604 (InteractiveShell.mainloop): honor --nobanner with banner
2590 2605 extensions.
2591 2606
2592 2607 * IPython/Shell.py: Significant refactoring of all classes, so
2593 2608 that we can really support ALL matplotlib backends and threading
2594 2609 models (John spotted a bug with Tk which required this). Now we
2595 2610 should support single-threaded, WX-threads and GTK-threads, both
2596 2611 for generic code and for matplotlib.
2597 2612
2598 2613 * IPython/ipmaker.py (__call__): Changed -mpthread option to
2599 2614 -pylab, to simplify things for users. Will also remove the pylab
2600 2615 profile, since now all of matplotlib configuration is directly
2601 2616 handled here. This also reduces startup time.
2602 2617
2603 2618 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
2604 2619 shell wasn't being correctly called. Also in IPShellWX.
2605 2620
2606 2621 * IPython/iplib.py (InteractiveShell.__init__): Added option to
2607 2622 fine-tune banner.
2608 2623
2609 2624 * IPython/numutils.py (spike): Deprecate these spike functions,
2610 2625 delete (long deprecated) gnuplot_exec handler.
2611 2626
2612 2627 2004-08-26 Fernando Perez <fperez@colorado.edu>
2613 2628
2614 2629 * ipython.1: Update for threading options, plus some others which
2615 2630 were missing.
2616 2631
2617 2632 * IPython/ipmaker.py (__call__): Added -wthread option for
2618 2633 wxpython thread handling. Make sure threading options are only
2619 2634 valid at the command line.
2620 2635
2621 2636 * scripts/ipython: moved shell selection into a factory function
2622 2637 in Shell.py, to keep the starter script to a minimum.
2623 2638
2624 2639 2004-08-25 Fernando Perez <fperez@colorado.edu>
2625 2640
2626 2641 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
2627 2642 John. Along with some recent changes he made to matplotlib, the
2628 2643 next versions of both systems should work very well together.
2629 2644
2630 2645 2004-08-24 Fernando Perez <fperez@colorado.edu>
2631 2646
2632 2647 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
2633 2648 tried to switch the profiling to using hotshot, but I'm getting
2634 2649 strange errors from prof.runctx() there. I may be misreading the
2635 2650 docs, but it looks weird. For now the profiling code will
2636 2651 continue to use the standard profiler.
2637 2652
2638 2653 2004-08-23 Fernando Perez <fperez@colorado.edu>
2639 2654
2640 2655 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
2641 2656 threaded shell, by John Hunter. It's not quite ready yet, but
2642 2657 close.
2643 2658
2644 2659 2004-08-22 Fernando Perez <fperez@colorado.edu>
2645 2660
2646 2661 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
2647 2662 in Magic and ultraTB.
2648 2663
2649 2664 * ipython.1: document threading options in manpage.
2650 2665
2651 2666 * scripts/ipython: Changed name of -thread option to -gthread,
2652 2667 since this is GTK specific. I want to leave the door open for a
2653 2668 -wthread option for WX, which will most likely be necessary. This
2654 2669 change affects usage and ipmaker as well.
2655 2670
2656 2671 * IPython/Shell.py (matplotlib_shell): Add a factory function to
2657 2672 handle the matplotlib shell issues. Code by John Hunter
2658 2673 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2659 2674 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
2660 2675 broken (and disabled for end users) for now, but it puts the
2661 2676 infrastructure in place.
2662 2677
2663 2678 2004-08-21 Fernando Perez <fperez@colorado.edu>
2664 2679
2665 2680 * ipythonrc-pylab: Add matplotlib support.
2666 2681
2667 2682 * matplotlib_config.py: new files for matplotlib support, part of
2668 2683 the pylab profile.
2669 2684
2670 2685 * IPython/usage.py (__doc__): documented the threading options.
2671 2686
2672 2687 2004-08-20 Fernando Perez <fperez@colorado.edu>
2673 2688
2674 2689 * ipython: Modified the main calling routine to handle the -thread
2675 2690 and -mpthread options. This needs to be done as a top-level hack,
2676 2691 because it determines which class to instantiate for IPython
2677 2692 itself.
2678 2693
2679 2694 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
2680 2695 classes to support multithreaded GTK operation without blocking,
2681 2696 and matplotlib with all backends. This is a lot of still very
2682 2697 experimental code, and threads are tricky. So it may still have a
2683 2698 few rough edges... This code owes a lot to
2684 2699 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
2685 2700 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
2686 2701 to John Hunter for all the matplotlib work.
2687 2702
2688 2703 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
2689 2704 options for gtk thread and matplotlib support.
2690 2705
2691 2706 2004-08-16 Fernando Perez <fperez@colorado.edu>
2692 2707
2693 2708 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
2694 2709 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
2695 2710 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
2696 2711
2697 2712 2004-08-11 Fernando Perez <fperez@colorado.edu>
2698 2713
2699 2714 * setup.py (isfile): Fix build so documentation gets updated for
2700 2715 rpms (it was only done for .tgz builds).
2701 2716
2702 2717 2004-08-10 Fernando Perez <fperez@colorado.edu>
2703 2718
2704 2719 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
2705 2720
2706 2721 * iplib.py : Silence syntax error exceptions in tab-completion.
2707 2722
2708 2723 2004-08-05 Fernando Perez <fperez@colorado.edu>
2709 2724
2710 2725 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
2711 2726 'color off' mark for continuation prompts. This was causing long
2712 2727 continuation lines to mis-wrap.
2713 2728
2714 2729 2004-08-01 Fernando Perez <fperez@colorado.edu>
2715 2730
2716 2731 * IPython/ipmaker.py (make_IPython): Allow the shell class used
2717 2732 for building ipython to be a parameter. All this is necessary
2718 2733 right now to have a multithreaded version, but this insane
2719 2734 non-design will be cleaned up soon. For now, it's a hack that
2720 2735 works.
2721 2736
2722 2737 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
2723 2738 args in various places. No bugs so far, but it's a dangerous
2724 2739 practice.
2725 2740
2726 2741 2004-07-31 Fernando Perez <fperez@colorado.edu>
2727 2742
2728 2743 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
2729 2744 fix completion of files with dots in their names under most
2730 2745 profiles (pysh was OK because the completion order is different).
2731 2746
2732 2747 2004-07-27 Fernando Perez <fperez@colorado.edu>
2733 2748
2734 2749 * IPython/iplib.py (InteractiveShell.__init__): build dict of
2735 2750 keywords manually, b/c the one in keyword.py was removed in python
2736 2751 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
2737 2752 This is NOT a bug under python 2.3 and earlier.
2738 2753
2739 2754 2004-07-26 Fernando Perez <fperez@colorado.edu>
2740 2755
2741 2756 * IPython/ultraTB.py (VerboseTB.text): Add another
2742 2757 linecache.checkcache() call to try to prevent inspect.py from
2743 2758 crashing under python 2.3. I think this fixes
2744 2759 http://www.scipy.net/roundup/ipython/issue17.
2745 2760
2746 2761 2004-07-26 *** Released version 0.6.2
2747 2762
2748 2763 2004-07-26 Fernando Perez <fperez@colorado.edu>
2749 2764
2750 2765 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
2751 2766 fail for any number.
2752 2767 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
2753 2768 empty bookmarks.
2754 2769
2755 2770 2004-07-26 *** Released version 0.6.1
2756 2771
2757 2772 2004-07-26 Fernando Perez <fperez@colorado.edu>
2758 2773
2759 2774 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
2760 2775
2761 2776 * IPython/iplib.py (protect_filename): Applied Ville's patch for
2762 2777 escaping '()[]{}' in filenames.
2763 2778
2764 2779 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
2765 2780 Python 2.2 users who lack a proper shlex.split.
2766 2781
2767 2782 2004-07-19 Fernando Perez <fperez@colorado.edu>
2768 2783
2769 2784 * IPython/iplib.py (InteractiveShell.init_readline): Add support
2770 2785 for reading readline's init file. I follow the normal chain:
2771 2786 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
2772 2787 report by Mike Heeter. This closes
2773 2788 http://www.scipy.net/roundup/ipython/issue16.
2774 2789
2775 2790 2004-07-18 Fernando Perez <fperez@colorado.edu>
2776 2791
2777 2792 * IPython/iplib.py (__init__): Add better handling of '\' under
2778 2793 Win32 for filenames. After a patch by Ville.
2779 2794
2780 2795 2004-07-17 Fernando Perez <fperez@colorado.edu>
2781 2796
2782 2797 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2783 2798 autocalling would be triggered for 'foo is bar' if foo is
2784 2799 callable. I also cleaned up the autocall detection code to use a
2785 2800 regexp, which is faster. Bug reported by Alexander Schmolck.
2786 2801
2787 2802 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
2788 2803 '?' in them would confuse the help system. Reported by Alex
2789 2804 Schmolck.
2790 2805
2791 2806 2004-07-16 Fernando Perez <fperez@colorado.edu>
2792 2807
2793 2808 * IPython/GnuplotInteractive.py (__all__): added plot2.
2794 2809
2795 2810 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
2796 2811 plotting dictionaries, lists or tuples of 1d arrays.
2797 2812
2798 2813 * IPython/Magic.py (Magic.magic_hist): small clenaups and
2799 2814 optimizations.
2800 2815
2801 2816 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
2802 2817 the information which was there from Janko's original IPP code:
2803 2818
2804 2819 03.05.99 20:53 porto.ifm.uni-kiel.de
2805 2820 --Started changelog.
2806 2821 --make clear do what it say it does
2807 2822 --added pretty output of lines from inputcache
2808 2823 --Made Logger a mixin class, simplifies handling of switches
2809 2824 --Added own completer class. .string<TAB> expands to last history
2810 2825 line which starts with string. The new expansion is also present
2811 2826 with Ctrl-r from the readline library. But this shows, who this
2812 2827 can be done for other cases.
2813 2828 --Added convention that all shell functions should accept a
2814 2829 parameter_string This opens the door for different behaviour for
2815 2830 each function. @cd is a good example of this.
2816 2831
2817 2832 04.05.99 12:12 porto.ifm.uni-kiel.de
2818 2833 --added logfile rotation
2819 2834 --added new mainloop method which freezes first the namespace
2820 2835
2821 2836 07.05.99 21:24 porto.ifm.uni-kiel.de
2822 2837 --added the docreader classes. Now there is a help system.
2823 2838 -This is only a first try. Currently it's not easy to put new
2824 2839 stuff in the indices. But this is the way to go. Info would be
2825 2840 better, but HTML is every where and not everybody has an info
2826 2841 system installed and it's not so easy to change html-docs to info.
2827 2842 --added global logfile option
2828 2843 --there is now a hook for object inspection method pinfo needs to
2829 2844 be provided for this. Can be reached by two '??'.
2830 2845
2831 2846 08.05.99 20:51 porto.ifm.uni-kiel.de
2832 2847 --added a README
2833 2848 --bug in rc file. Something has changed so functions in the rc
2834 2849 file need to reference the shell and not self. Not clear if it's a
2835 2850 bug or feature.
2836 2851 --changed rc file for new behavior
2837 2852
2838 2853 2004-07-15 Fernando Perez <fperez@colorado.edu>
2839 2854
2840 2855 * IPython/Logger.py (Logger.log): fixed recent bug where the input
2841 2856 cache was falling out of sync in bizarre manners when multi-line
2842 2857 input was present. Minor optimizations and cleanup.
2843 2858
2844 2859 (Logger): Remove old Changelog info for cleanup. This is the
2845 2860 information which was there from Janko's original code:
2846 2861
2847 2862 Changes to Logger: - made the default log filename a parameter
2848 2863
2849 2864 - put a check for lines beginning with !@? in log(). Needed
2850 2865 (even if the handlers properly log their lines) for mid-session
2851 2866 logging activation to work properly. Without this, lines logged
2852 2867 in mid session, which get read from the cache, would end up
2853 2868 'bare' (with !@? in the open) in the log. Now they are caught
2854 2869 and prepended with a #.
2855 2870
2856 2871 * IPython/iplib.py (InteractiveShell.init_readline): added check
2857 2872 in case MagicCompleter fails to be defined, so we don't crash.
2858 2873
2859 2874 2004-07-13 Fernando Perez <fperez@colorado.edu>
2860 2875
2861 2876 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
2862 2877 of EPS if the requested filename ends in '.eps'.
2863 2878
2864 2879 2004-07-04 Fernando Perez <fperez@colorado.edu>
2865 2880
2866 2881 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
2867 2882 escaping of quotes when calling the shell.
2868 2883
2869 2884 2004-07-02 Fernando Perez <fperez@colorado.edu>
2870 2885
2871 2886 * IPython/Prompts.py (CachedOutput.update): Fix problem with
2872 2887 gettext not working because we were clobbering '_'. Fixes
2873 2888 http://www.scipy.net/roundup/ipython/issue6.
2874 2889
2875 2890 2004-07-01 Fernando Perez <fperez@colorado.edu>
2876 2891
2877 2892 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
2878 2893 into @cd. Patch by Ville.
2879 2894
2880 2895 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2881 2896 new function to store things after ipmaker runs. Patch by Ville.
2882 2897 Eventually this will go away once ipmaker is removed and the class
2883 2898 gets cleaned up, but for now it's ok. Key functionality here is
2884 2899 the addition of the persistent storage mechanism, a dict for
2885 2900 keeping data across sessions (for now just bookmarks, but more can
2886 2901 be implemented later).
2887 2902
2888 2903 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
2889 2904 persistent across sections. Patch by Ville, I modified it
2890 2905 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
2891 2906 added a '-l' option to list all bookmarks.
2892 2907
2893 2908 * IPython/iplib.py (InteractiveShell.atexit_operations): new
2894 2909 center for cleanup. Registered with atexit.register(). I moved
2895 2910 here the old exit_cleanup(). After a patch by Ville.
2896 2911
2897 2912 * IPython/Magic.py (get_py_filename): added '~' to the accepted
2898 2913 characters in the hacked shlex_split for python 2.2.
2899 2914
2900 2915 * IPython/iplib.py (file_matches): more fixes to filenames with
2901 2916 whitespace in them. It's not perfect, but limitations in python's
2902 2917 readline make it impossible to go further.
2903 2918
2904 2919 2004-06-29 Fernando Perez <fperez@colorado.edu>
2905 2920
2906 2921 * IPython/iplib.py (file_matches): escape whitespace correctly in
2907 2922 filename completions. Bug reported by Ville.
2908 2923
2909 2924 2004-06-28 Fernando Perez <fperez@colorado.edu>
2910 2925
2911 2926 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
2912 2927 the history file will be called 'history-PROFNAME' (or just
2913 2928 'history' if no profile is loaded). I was getting annoyed at
2914 2929 getting my Numerical work history clobbered by pysh sessions.
2915 2930
2916 2931 * IPython/iplib.py (InteractiveShell.__init__): Internal
2917 2932 getoutputerror() function so that we can honor the system_verbose
2918 2933 flag for _all_ system calls. I also added escaping of #
2919 2934 characters here to avoid confusing Itpl.
2920 2935
2921 2936 * IPython/Magic.py (shlex_split): removed call to shell in
2922 2937 parse_options and replaced it with shlex.split(). The annoying
2923 2938 part was that in Python 2.2, shlex.split() doesn't exist, so I had
2924 2939 to backport it from 2.3, with several frail hacks (the shlex
2925 2940 module is rather limited in 2.2). Thanks to a suggestion by Ville
2926 2941 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
2927 2942 problem.
2928 2943
2929 2944 (Magic.magic_system_verbose): new toggle to print the actual
2930 2945 system calls made by ipython. Mainly for debugging purposes.
2931 2946
2932 2947 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
2933 2948 doesn't support persistence. Reported (and fix suggested) by
2934 2949 Travis Caldwell <travis_caldwell2000@yahoo.com>.
2935 2950
2936 2951 2004-06-26 Fernando Perez <fperez@colorado.edu>
2937 2952
2938 2953 * IPython/Logger.py (Logger.log): fix to handle correctly empty
2939 2954 continue prompts.
2940 2955
2941 2956 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
2942 2957 function (basically a big docstring) and a few more things here to
2943 2958 speedup startup. pysh.py is now very lightweight. We want because
2944 2959 it gets execfile'd, while InterpreterExec gets imported, so
2945 2960 byte-compilation saves time.
2946 2961
2947 2962 2004-06-25 Fernando Perez <fperez@colorado.edu>
2948 2963
2949 2964 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
2950 2965 -NUM', which was recently broken.
2951 2966
2952 2967 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
2953 2968 in multi-line input (but not !!, which doesn't make sense there).
2954 2969
2955 2970 * IPython/UserConfig/ipythonrc: made autoindent on by default.
2956 2971 It's just too useful, and people can turn it off in the less
2957 2972 common cases where it's a problem.
2958 2973
2959 2974 2004-06-24 Fernando Perez <fperez@colorado.edu>
2960 2975
2961 2976 * IPython/iplib.py (InteractiveShell._prefilter): big change -
2962 2977 special syntaxes (like alias calling) is now allied in multi-line
2963 2978 input. This is still _very_ experimental, but it's necessary for
2964 2979 efficient shell usage combining python looping syntax with system
2965 2980 calls. For now it's restricted to aliases, I don't think it
2966 2981 really even makes sense to have this for magics.
2967 2982
2968 2983 2004-06-23 Fernando Perez <fperez@colorado.edu>
2969 2984
2970 2985 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
2971 2986 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
2972 2987
2973 2988 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
2974 2989 extensions under Windows (after code sent by Gary Bishop). The
2975 2990 extensions considered 'executable' are stored in IPython's rc
2976 2991 structure as win_exec_ext.
2977 2992
2978 2993 * IPython/genutils.py (shell): new function, like system() but
2979 2994 without return value. Very useful for interactive shell work.
2980 2995
2981 2996 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
2982 2997 delete aliases.
2983 2998
2984 2999 * IPython/iplib.py (InteractiveShell.alias_table_update): make
2985 3000 sure that the alias table doesn't contain python keywords.
2986 3001
2987 3002 2004-06-21 Fernando Perez <fperez@colorado.edu>
2988 3003
2989 3004 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
2990 3005 non-existent items are found in $PATH. Reported by Thorsten.
2991 3006
2992 3007 2004-06-20 Fernando Perez <fperez@colorado.edu>
2993 3008
2994 3009 * IPython/iplib.py (complete): modified the completer so that the
2995 3010 order of priorities can be easily changed at runtime.
2996 3011
2997 3012 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
2998 3013 Modified to auto-execute all lines beginning with '~', '/' or '.'.
2999 3014
3000 3015 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
3001 3016 expand Python variables prepended with $ in all system calls. The
3002 3017 same was done to InteractiveShell.handle_shell_escape. Now all
3003 3018 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
3004 3019 expansion of python variables and expressions according to the
3005 3020 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
3006 3021
3007 3022 Though PEP-215 has been rejected, a similar (but simpler) one
3008 3023 seems like it will go into Python 2.4, PEP-292 -
3009 3024 http://www.python.org/peps/pep-0292.html.
3010 3025
3011 3026 I'll keep the full syntax of PEP-215, since IPython has since the
3012 3027 start used Ka-Ping Yee's reference implementation discussed there
3013 3028 (Itpl), and I actually like the powerful semantics it offers.
3014 3029
3015 3030 In order to access normal shell variables, the $ has to be escaped
3016 3031 via an extra $. For example:
3017 3032
3018 3033 In [7]: PATH='a python variable'
3019 3034
3020 3035 In [8]: !echo $PATH
3021 3036 a python variable
3022 3037
3023 3038 In [9]: !echo $$PATH
3024 3039 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
3025 3040
3026 3041 (Magic.parse_options): escape $ so the shell doesn't evaluate
3027 3042 things prematurely.
3028 3043
3029 3044 * IPython/iplib.py (InteractiveShell.call_alias): added the
3030 3045 ability for aliases to expand python variables via $.
3031 3046
3032 3047 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
3033 3048 system, now there's a @rehash/@rehashx pair of magics. These work
3034 3049 like the csh rehash command, and can be invoked at any time. They
3035 3050 build a table of aliases to everything in the user's $PATH
3036 3051 (@rehash uses everything, @rehashx is slower but only adds
3037 3052 executable files). With this, the pysh.py-based shell profile can
3038 3053 now simply call rehash upon startup, and full access to all
3039 3054 programs in the user's path is obtained.
3040 3055
3041 3056 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
3042 3057 functionality is now fully in place. I removed the old dynamic
3043 3058 code generation based approach, in favor of a much lighter one
3044 3059 based on a simple dict. The advantage is that this allows me to
3045 3060 now have thousands of aliases with negligible cost (unthinkable
3046 3061 with the old system).
3047 3062
3048 3063 2004-06-19 Fernando Perez <fperez@colorado.edu>
3049 3064
3050 3065 * IPython/iplib.py (__init__): extended MagicCompleter class to
3051 3066 also complete (last in priority) on user aliases.
3052 3067
3053 3068 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
3054 3069 call to eval.
3055 3070 (ItplNS.__init__): Added a new class which functions like Itpl,
3056 3071 but allows configuring the namespace for the evaluation to occur
3057 3072 in.
3058 3073
3059 3074 2004-06-18 Fernando Perez <fperez@colorado.edu>
3060 3075
3061 3076 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
3062 3077 better message when 'exit' or 'quit' are typed (a common newbie
3063 3078 confusion).
3064 3079
3065 3080 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
3066 3081 check for Windows users.
3067 3082
3068 3083 * IPython/iplib.py (InteractiveShell.user_setup): removed
3069 3084 disabling of colors for Windows. I'll test at runtime and issue a
3070 3085 warning if Gary's readline isn't found, as to nudge users to
3071 3086 download it.
3072 3087
3073 3088 2004-06-16 Fernando Perez <fperez@colorado.edu>
3074 3089
3075 3090 * IPython/genutils.py (Stream.__init__): changed to print errors
3076 3091 to sys.stderr. I had a circular dependency here. Now it's
3077 3092 possible to run ipython as IDLE's shell (consider this pre-alpha,
3078 3093 since true stdout things end up in the starting terminal instead
3079 3094 of IDLE's out).
3080 3095
3081 3096 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
3082 3097 users who haven't # updated their prompt_in2 definitions. Remove
3083 3098 eventually.
3084 3099 (multiple_replace): added credit to original ASPN recipe.
3085 3100
3086 3101 2004-06-15 Fernando Perez <fperez@colorado.edu>
3087 3102
3088 3103 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
3089 3104 list of auto-defined aliases.
3090 3105
3091 3106 2004-06-13 Fernando Perez <fperez@colorado.edu>
3092 3107
3093 3108 * setup.py (scriptfiles): Don't trigger win_post_install unless an
3094 3109 install was really requested (so setup.py can be used for other
3095 3110 things under Windows).
3096 3111
3097 3112 2004-06-10 Fernando Perez <fperez@colorado.edu>
3098 3113
3099 3114 * IPython/Logger.py (Logger.create_log): Manually remove any old
3100 3115 backup, since os.remove may fail under Windows. Fixes bug
3101 3116 reported by Thorsten.
3102 3117
3103 3118 2004-06-09 Fernando Perez <fperez@colorado.edu>
3104 3119
3105 3120 * examples/example-embed.py: fixed all references to %n (replaced
3106 3121 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
3107 3122 for all examples and the manual as well.
3108 3123
3109 3124 2004-06-08 Fernando Perez <fperez@colorado.edu>
3110 3125
3111 3126 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
3112 3127 alignment and color management. All 3 prompt subsystems now
3113 3128 inherit from BasePrompt.
3114 3129
3115 3130 * tools/release: updates for windows installer build and tag rpms
3116 3131 with python version (since paths are fixed).
3117 3132
3118 3133 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
3119 3134 which will become eventually obsolete. Also fixed the default
3120 3135 prompt_in2 to use \D, so at least new users start with the correct
3121 3136 defaults.
3122 3137 WARNING: Users with existing ipythonrc files will need to apply
3123 3138 this fix manually!
3124 3139
3125 3140 * setup.py: make windows installer (.exe). This is finally the
3126 3141 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
3127 3142 which I hadn't included because it required Python 2.3 (or recent
3128 3143 distutils).
3129 3144
3130 3145 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
3131 3146 usage of new '\D' escape.
3132 3147
3133 3148 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
3134 3149 lacks os.getuid())
3135 3150 (CachedOutput.set_colors): Added the ability to turn coloring
3136 3151 on/off with @colors even for manually defined prompt colors. It
3137 3152 uses a nasty global, but it works safely and via the generic color
3138 3153 handling mechanism.
3139 3154 (Prompt2.__init__): Introduced new escape '\D' for continuation
3140 3155 prompts. It represents the counter ('\#') as dots.
3141 3156 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
3142 3157 need to update their ipythonrc files and replace '%n' with '\D' in
3143 3158 their prompt_in2 settings everywhere. Sorry, but there's
3144 3159 otherwise no clean way to get all prompts to properly align. The
3145 3160 ipythonrc shipped with IPython has been updated.
3146 3161
3147 3162 2004-06-07 Fernando Perez <fperez@colorado.edu>
3148 3163
3149 3164 * setup.py (isfile): Pass local_icons option to latex2html, so the
3150 3165 resulting HTML file is self-contained. Thanks to
3151 3166 dryice-AT-liu.com.cn for the tip.
3152 3167
3153 3168 * pysh.py: I created a new profile 'shell', which implements a
3154 3169 _rudimentary_ IPython-based shell. This is in NO WAY a realy
3155 3170 system shell, nor will it become one anytime soon. It's mainly
3156 3171 meant to illustrate the use of the new flexible bash-like prompts.
3157 3172 I guess it could be used by hardy souls for true shell management,
3158 3173 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
3159 3174 profile. This uses the InterpreterExec extension provided by
3160 3175 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
3161 3176
3162 3177 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
3163 3178 auto-align itself with the length of the previous input prompt
3164 3179 (taking into account the invisible color escapes).
3165 3180 (CachedOutput.__init__): Large restructuring of this class. Now
3166 3181 all three prompts (primary1, primary2, output) are proper objects,
3167 3182 managed by the 'parent' CachedOutput class. The code is still a
3168 3183 bit hackish (all prompts share state via a pointer to the cache),
3169 3184 but it's overall far cleaner than before.
3170 3185
3171 3186 * IPython/genutils.py (getoutputerror): modified to add verbose,
3172 3187 debug and header options. This makes the interface of all getout*
3173 3188 functions uniform.
3174 3189 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
3175 3190
3176 3191 * IPython/Magic.py (Magic.default_option): added a function to
3177 3192 allow registering default options for any magic command. This
3178 3193 makes it easy to have profiles which customize the magics globally
3179 3194 for a certain use. The values set through this function are
3180 3195 picked up by the parse_options() method, which all magics should
3181 3196 use to parse their options.
3182 3197
3183 3198 * IPython/genutils.py (warn): modified the warnings framework to
3184 3199 use the Term I/O class. I'm trying to slowly unify all of
3185 3200 IPython's I/O operations to pass through Term.
3186 3201
3187 3202 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
3188 3203 the secondary prompt to correctly match the length of the primary
3189 3204 one for any prompt. Now multi-line code will properly line up
3190 3205 even for path dependent prompts, such as the new ones available
3191 3206 via the prompt_specials.
3192 3207
3193 3208 2004-06-06 Fernando Perez <fperez@colorado.edu>
3194 3209
3195 3210 * IPython/Prompts.py (prompt_specials): Added the ability to have
3196 3211 bash-like special sequences in the prompts, which get
3197 3212 automatically expanded. Things like hostname, current working
3198 3213 directory and username are implemented already, but it's easy to
3199 3214 add more in the future. Thanks to a patch by W.J. van der Laan
3200 3215 <gnufnork-AT-hetdigitalegat.nl>
3201 3216 (prompt_specials): Added color support for prompt strings, so
3202 3217 users can define arbitrary color setups for their prompts.
3203 3218
3204 3219 2004-06-05 Fernando Perez <fperez@colorado.edu>
3205 3220
3206 3221 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
3207 3222 code to load Gary Bishop's readline and configure it
3208 3223 automatically. Thanks to Gary for help on this.
3209 3224
3210 3225 2004-06-01 Fernando Perez <fperez@colorado.edu>
3211 3226
3212 3227 * IPython/Logger.py (Logger.create_log): fix bug for logging
3213 3228 with no filename (previous fix was incomplete).
3214 3229
3215 3230 2004-05-25 Fernando Perez <fperez@colorado.edu>
3216 3231
3217 3232 * IPython/Magic.py (Magic.parse_options): fix bug where naked
3218 3233 parens would get passed to the shell.
3219 3234
3220 3235 2004-05-20 Fernando Perez <fperez@colorado.edu>
3221 3236
3222 3237 * IPython/Magic.py (Magic.magic_prun): changed default profile
3223 3238 sort order to 'time' (the more common profiling need).
3224 3239
3225 3240 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
3226 3241 so that source code shown is guaranteed in sync with the file on
3227 3242 disk (also changed in psource). Similar fix to the one for
3228 3243 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
3229 3244 <yann.ledu-AT-noos.fr>.
3230 3245
3231 3246 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
3232 3247 with a single option would not be correctly parsed. Closes
3233 3248 http://www.scipy.net/roundup/ipython/issue14. This bug had been
3234 3249 introduced in 0.6.0 (on 2004-05-06).
3235 3250
3236 3251 2004-05-13 *** Released version 0.6.0
3237 3252
3238 3253 2004-05-13 Fernando Perez <fperez@colorado.edu>
3239 3254
3240 3255 * debian/: Added debian/ directory to CVS, so that debian support
3241 3256 is publicly accessible. The debian package is maintained by Jack
3242 3257 Moffit <jack-AT-xiph.org>.
3243 3258
3244 3259 * Documentation: included the notes about an ipython-based system
3245 3260 shell (the hypothetical 'pysh') into the new_design.pdf document,
3246 3261 so that these ideas get distributed to users along with the
3247 3262 official documentation.
3248 3263
3249 3264 2004-05-10 Fernando Perez <fperez@colorado.edu>
3250 3265
3251 3266 * IPython/Logger.py (Logger.create_log): fix recently introduced
3252 3267 bug (misindented line) where logstart would fail when not given an
3253 3268 explicit filename.
3254 3269
3255 3270 2004-05-09 Fernando Perez <fperez@colorado.edu>
3256 3271
3257 3272 * IPython/Magic.py (Magic.parse_options): skip system call when
3258 3273 there are no options to look for. Faster, cleaner for the common
3259 3274 case.
3260 3275
3261 3276 * Documentation: many updates to the manual: describing Windows
3262 3277 support better, Gnuplot updates, credits, misc small stuff. Also
3263 3278 updated the new_design doc a bit.
3264 3279
3265 3280 2004-05-06 *** Released version 0.6.0.rc1
3266 3281
3267 3282 2004-05-06 Fernando Perez <fperez@colorado.edu>
3268 3283
3269 3284 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
3270 3285 operations to use the vastly more efficient list/''.join() method.
3271 3286 (FormattedTB.text): Fix
3272 3287 http://www.scipy.net/roundup/ipython/issue12 - exception source
3273 3288 extract not updated after reload. Thanks to Mike Salib
3274 3289 <msalib-AT-mit.edu> for pinning the source of the problem.
3275 3290 Fortunately, the solution works inside ipython and doesn't require
3276 3291 any changes to python proper.
3277 3292
3278 3293 * IPython/Magic.py (Magic.parse_options): Improved to process the
3279 3294 argument list as a true shell would (by actually using the
3280 3295 underlying system shell). This way, all @magics automatically get
3281 3296 shell expansion for variables. Thanks to a comment by Alex
3282 3297 Schmolck.
3283 3298
3284 3299 2004-04-04 Fernando Perez <fperez@colorado.edu>
3285 3300
3286 3301 * IPython/iplib.py (InteractiveShell.interact): Added a special
3287 3302 trap for a debugger quit exception, which is basically impossible
3288 3303 to handle by normal mechanisms, given what pdb does to the stack.
3289 3304 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
3290 3305
3291 3306 2004-04-03 Fernando Perez <fperez@colorado.edu>
3292 3307
3293 3308 * IPython/genutils.py (Term): Standardized the names of the Term
3294 3309 class streams to cin/cout/cerr, following C++ naming conventions
3295 3310 (I can't use in/out/err because 'in' is not a valid attribute
3296 3311 name).
3297 3312
3298 3313 * IPython/iplib.py (InteractiveShell.interact): don't increment
3299 3314 the prompt if there's no user input. By Daniel 'Dang' Griffith
3300 3315 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
3301 3316 Francois Pinard.
3302 3317
3303 3318 2004-04-02 Fernando Perez <fperez@colorado.edu>
3304 3319
3305 3320 * IPython/genutils.py (Stream.__init__): Modified to survive at
3306 3321 least importing in contexts where stdin/out/err aren't true file
3307 3322 objects, such as PyCrust (they lack fileno() and mode). However,
3308 3323 the recovery facilities which rely on these things existing will
3309 3324 not work.
3310 3325
3311 3326 2004-04-01 Fernando Perez <fperez@colorado.edu>
3312 3327
3313 3328 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
3314 3329 use the new getoutputerror() function, so it properly
3315 3330 distinguishes stdout/err.
3316 3331
3317 3332 * IPython/genutils.py (getoutputerror): added a function to
3318 3333 capture separately the standard output and error of a command.
3319 3334 After a comment from dang on the mailing lists. This code is
3320 3335 basically a modified version of commands.getstatusoutput(), from
3321 3336 the standard library.
3322 3337
3323 3338 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
3324 3339 '!!' as a special syntax (shorthand) to access @sx.
3325 3340
3326 3341 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
3327 3342 command and return its output as a list split on '\n'.
3328 3343
3329 3344 2004-03-31 Fernando Perez <fperez@colorado.edu>
3330 3345
3331 3346 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
3332 3347 method to dictionaries used as FakeModule instances if they lack
3333 3348 it. At least pydoc in python2.3 breaks for runtime-defined
3334 3349 functions without this hack. At some point I need to _really_
3335 3350 understand what FakeModule is doing, because it's a gross hack.
3336 3351 But it solves Arnd's problem for now...
3337 3352
3338 3353 2004-02-27 Fernando Perez <fperez@colorado.edu>
3339 3354
3340 3355 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
3341 3356 mode would behave erratically. Also increased the number of
3342 3357 possible logs in rotate mod to 999. Thanks to Rod Holland
3343 3358 <rhh@StructureLABS.com> for the report and fixes.
3344 3359
3345 3360 2004-02-26 Fernando Perez <fperez@colorado.edu>
3346 3361
3347 3362 * IPython/genutils.py (page): Check that the curses module really
3348 3363 has the initscr attribute before trying to use it. For some
3349 3364 reason, the Solaris curses module is missing this. I think this
3350 3365 should be considered a Solaris python bug, but I'm not sure.
3351 3366
3352 3367 2004-01-17 Fernando Perez <fperez@colorado.edu>
3353 3368
3354 3369 * IPython/genutils.py (Stream.__init__): Changes to try to make
3355 3370 ipython robust against stdin/out/err being closed by the user.
3356 3371 This is 'user error' (and blocks a normal python session, at least
3357 3372 the stdout case). However, Ipython should be able to survive such
3358 3373 instances of abuse as gracefully as possible. To simplify the
3359 3374 coding and maintain compatibility with Gary Bishop's Term
3360 3375 contributions, I've made use of classmethods for this. I think
3361 3376 this introduces a dependency on python 2.2.
3362 3377
3363 3378 2004-01-13 Fernando Perez <fperez@colorado.edu>
3364 3379
3365 3380 * IPython/numutils.py (exp_safe): simplified the code a bit and
3366 3381 removed the need for importing the kinds module altogether.
3367 3382
3368 3383 2004-01-06 Fernando Perez <fperez@colorado.edu>
3369 3384
3370 3385 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
3371 3386 a magic function instead, after some community feedback. No
3372 3387 special syntax will exist for it, but its name is deliberately
3373 3388 very short.
3374 3389
3375 3390 2003-12-20 Fernando Perez <fperez@colorado.edu>
3376 3391
3377 3392 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
3378 3393 new functionality, to automagically assign the result of a shell
3379 3394 command to a variable. I'll solicit some community feedback on
3380 3395 this before making it permanent.
3381 3396
3382 3397 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
3383 3398 requested about callables for which inspect couldn't obtain a
3384 3399 proper argspec. Thanks to a crash report sent by Etienne
3385 3400 Posthumus <etienne-AT-apple01.cs.vu.nl>.
3386 3401
3387 3402 2003-12-09 Fernando Perez <fperez@colorado.edu>
3388 3403
3389 3404 * IPython/genutils.py (page): patch for the pager to work across
3390 3405 various versions of Windows. By Gary Bishop.
3391 3406
3392 3407 2003-12-04 Fernando Perez <fperez@colorado.edu>
3393 3408
3394 3409 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
3395 3410 Gnuplot.py version 1.7, whose internal names changed quite a bit.
3396 3411 While I tested this and it looks ok, there may still be corner
3397 3412 cases I've missed.
3398 3413
3399 3414 2003-12-01 Fernando Perez <fperez@colorado.edu>
3400 3415
3401 3416 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
3402 3417 where a line like 'p,q=1,2' would fail because the automagic
3403 3418 system would be triggered for @p.
3404 3419
3405 3420 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
3406 3421 cleanups, code unmodified.
3407 3422
3408 3423 * IPython/genutils.py (Term): added a class for IPython to handle
3409 3424 output. In most cases it will just be a proxy for stdout/err, but
3410 3425 having this allows modifications to be made for some platforms,
3411 3426 such as handling color escapes under Windows. All of this code
3412 3427 was contributed by Gary Bishop, with minor modifications by me.
3413 3428 The actual changes affect many files.
3414 3429
3415 3430 2003-11-30 Fernando Perez <fperez@colorado.edu>
3416 3431
3417 3432 * IPython/iplib.py (file_matches): new completion code, courtesy
3418 3433 of Jeff Collins. This enables filename completion again under
3419 3434 python 2.3, which disabled it at the C level.
3420 3435
3421 3436 2003-11-11 Fernando Perez <fperez@colorado.edu>
3422 3437
3423 3438 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
3424 3439 for Numeric.array(map(...)), but often convenient.
3425 3440
3426 3441 2003-11-05 Fernando Perez <fperez@colorado.edu>
3427 3442
3428 3443 * IPython/numutils.py (frange): Changed a call from int() to
3429 3444 int(round()) to prevent a problem reported with arange() in the
3430 3445 numpy list.
3431 3446
3432 3447 2003-10-06 Fernando Perez <fperez@colorado.edu>
3433 3448
3434 3449 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
3435 3450 prevent crashes if sys lacks an argv attribute (it happens with
3436 3451 embedded interpreters which build a bare-bones sys module).
3437 3452 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
3438 3453
3439 3454 2003-09-24 Fernando Perez <fperez@colorado.edu>
3440 3455
3441 3456 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
3442 3457 to protect against poorly written user objects where __getattr__
3443 3458 raises exceptions other than AttributeError. Thanks to a bug
3444 3459 report by Oliver Sander <osander-AT-gmx.de>.
3445 3460
3446 3461 * IPython/FakeModule.py (FakeModule.__repr__): this method was
3447 3462 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
3448 3463
3449 3464 2003-09-09 Fernando Perez <fperez@colorado.edu>
3450 3465
3451 3466 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3452 3467 unpacking a list whith a callable as first element would
3453 3468 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
3454 3469 Collins.
3455 3470
3456 3471 2003-08-25 *** Released version 0.5.0
3457 3472
3458 3473 2003-08-22 Fernando Perez <fperez@colorado.edu>
3459 3474
3460 3475 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
3461 3476 improperly defined user exceptions. Thanks to feedback from Mark
3462 3477 Russell <mrussell-AT-verio.net>.
3463 3478
3464 3479 2003-08-20 Fernando Perez <fperez@colorado.edu>
3465 3480
3466 3481 * IPython/OInspect.py (Inspector.pinfo): changed String Form
3467 3482 printing so that it would print multi-line string forms starting
3468 3483 with a new line. This way the formatting is better respected for
3469 3484 objects which work hard to make nice string forms.
3470 3485
3471 3486 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
3472 3487 autocall would overtake data access for objects with both
3473 3488 __getitem__ and __call__.
3474 3489
3475 3490 2003-08-19 *** Released version 0.5.0-rc1
3476 3491
3477 3492 2003-08-19 Fernando Perez <fperez@colorado.edu>
3478 3493
3479 3494 * IPython/deep_reload.py (load_tail): single tiny change here
3480 3495 seems to fix the long-standing bug of dreload() failing to work
3481 3496 for dotted names. But this module is pretty tricky, so I may have
3482 3497 missed some subtlety. Needs more testing!.
3483 3498
3484 3499 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
3485 3500 exceptions which have badly implemented __str__ methods.
3486 3501 (VerboseTB.text): harden against inspect.getinnerframes crashing,
3487 3502 which I've been getting reports about from Python 2.3 users. I
3488 3503 wish I had a simple test case to reproduce the problem, so I could
3489 3504 either write a cleaner workaround or file a bug report if
3490 3505 necessary.
3491 3506
3492 3507 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
3493 3508 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
3494 3509 a bug report by Tjabo Kloppenburg.
3495 3510
3496 3511 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
3497 3512 crashes. Wrapped the pdb call in a blanket try/except, since pdb
3498 3513 seems rather unstable. Thanks to a bug report by Tjabo
3499 3514 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
3500 3515
3501 3516 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
3502 3517 this out soon because of the critical fixes in the inner loop for
3503 3518 generators.
3504 3519
3505 3520 * IPython/Magic.py (Magic.getargspec): removed. This (and
3506 3521 _get_def) have been obsoleted by OInspect for a long time, I
3507 3522 hadn't noticed that they were dead code.
3508 3523 (Magic._ofind): restored _ofind functionality for a few literals
3509 3524 (those in ["''",'""','[]','{}','()']). But it won't work anymore
3510 3525 for things like "hello".capitalize?, since that would require a
3511 3526 potentially dangerous eval() again.
3512 3527
3513 3528 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
3514 3529 logic a bit more to clean up the escapes handling and minimize the
3515 3530 use of _ofind to only necessary cases. The interactive 'feel' of
3516 3531 IPython should have improved quite a bit with the changes in
3517 3532 _prefilter and _ofind (besides being far safer than before).
3518 3533
3519 3534 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
3520 3535 obscure, never reported). Edit would fail to find the object to
3521 3536 edit under some circumstances.
3522 3537 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
3523 3538 which were causing double-calling of generators. Those eval calls
3524 3539 were _very_ dangerous, since code with side effects could be
3525 3540 triggered. As they say, 'eval is evil'... These were the
3526 3541 nastiest evals in IPython. Besides, _ofind is now far simpler,
3527 3542 and it should also be quite a bit faster. Its use of inspect is
3528 3543 also safer, so perhaps some of the inspect-related crashes I've
3529 3544 seen lately with Python 2.3 might be taken care of. That will
3530 3545 need more testing.
3531 3546
3532 3547 2003-08-17 Fernando Perez <fperez@colorado.edu>
3533 3548
3534 3549 * IPython/iplib.py (InteractiveShell._prefilter): significant
3535 3550 simplifications to the logic for handling user escapes. Faster
3536 3551 and simpler code.
3537 3552
3538 3553 2003-08-14 Fernando Perez <fperez@colorado.edu>
3539 3554
3540 3555 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
3541 3556 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
3542 3557 but it should be quite a bit faster. And the recursive version
3543 3558 generated O(log N) intermediate storage for all rank>1 arrays,
3544 3559 even if they were contiguous.
3545 3560 (l1norm): Added this function.
3546 3561 (norm): Added this function for arbitrary norms (including
3547 3562 l-infinity). l1 and l2 are still special cases for convenience
3548 3563 and speed.
3549 3564
3550 3565 2003-08-03 Fernando Perez <fperez@colorado.edu>
3551 3566
3552 3567 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
3553 3568 exceptions, which now raise PendingDeprecationWarnings in Python
3554 3569 2.3. There were some in Magic and some in Gnuplot2.
3555 3570
3556 3571 2003-06-30 Fernando Perez <fperez@colorado.edu>
3557 3572
3558 3573 * IPython/genutils.py (page): modified to call curses only for
3559 3574 terminals where TERM=='xterm'. After problems under many other
3560 3575 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
3561 3576
3562 3577 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
3563 3578 would be triggered when readline was absent. This was just an old
3564 3579 debugging statement I'd forgotten to take out.
3565 3580
3566 3581 2003-06-20 Fernando Perez <fperez@colorado.edu>
3567 3582
3568 3583 * IPython/genutils.py (clock): modified to return only user time
3569 3584 (not counting system time), after a discussion on scipy. While
3570 3585 system time may be a useful quantity occasionally, it may much
3571 3586 more easily be skewed by occasional swapping or other similar
3572 3587 activity.
3573 3588
3574 3589 2003-06-05 Fernando Perez <fperez@colorado.edu>
3575 3590
3576 3591 * IPython/numutils.py (identity): new function, for building
3577 3592 arbitrary rank Kronecker deltas (mostly backwards compatible with
3578 3593 Numeric.identity)
3579 3594
3580 3595 2003-06-03 Fernando Perez <fperez@colorado.edu>
3581 3596
3582 3597 * IPython/iplib.py (InteractiveShell.handle_magic): protect
3583 3598 arguments passed to magics with spaces, to allow trailing '\' to
3584 3599 work normally (mainly for Windows users).
3585 3600
3586 3601 2003-05-29 Fernando Perez <fperez@colorado.edu>
3587 3602
3588 3603 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
3589 3604 instead of pydoc.help. This fixes a bizarre behavior where
3590 3605 printing '%s' % locals() would trigger the help system. Now
3591 3606 ipython behaves like normal python does.
3592 3607
3593 3608 Note that if one does 'from pydoc import help', the bizarre
3594 3609 behavior returns, but this will also happen in normal python, so
3595 3610 it's not an ipython bug anymore (it has to do with how pydoc.help
3596 3611 is implemented).
3597 3612
3598 3613 2003-05-22 Fernando Perez <fperez@colorado.edu>
3599 3614
3600 3615 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
3601 3616 return [] instead of None when nothing matches, also match to end
3602 3617 of line. Patch by Gary Bishop.
3603 3618
3604 3619 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
3605 3620 protection as before, for files passed on the command line. This
3606 3621 prevents the CrashHandler from kicking in if user files call into
3607 3622 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
3608 3623 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
3609 3624
3610 3625 2003-05-20 *** Released version 0.4.0
3611 3626
3612 3627 2003-05-20 Fernando Perez <fperez@colorado.edu>
3613 3628
3614 3629 * setup.py: added support for manpages. It's a bit hackish b/c of
3615 3630 a bug in the way the bdist_rpm distutils target handles gzipped
3616 3631 manpages, but it works. After a patch by Jack.
3617 3632
3618 3633 2003-05-19 Fernando Perez <fperez@colorado.edu>
3619 3634
3620 3635 * IPython/numutils.py: added a mockup of the kinds module, since
3621 3636 it was recently removed from Numeric. This way, numutils will
3622 3637 work for all users even if they are missing kinds.
3623 3638
3624 3639 * IPython/Magic.py (Magic._ofind): Harden against an inspect
3625 3640 failure, which can occur with SWIG-wrapped extensions. After a
3626 3641 crash report from Prabhu.
3627 3642
3628 3643 2003-05-16 Fernando Perez <fperez@colorado.edu>
3629 3644
3630 3645 * IPython/iplib.py (InteractiveShell.excepthook): New method to
3631 3646 protect ipython from user code which may call directly
3632 3647 sys.excepthook (this looks like an ipython crash to the user, even
3633 3648 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
3634 3649 This is especially important to help users of WxWindows, but may
3635 3650 also be useful in other cases.
3636 3651
3637 3652 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
3638 3653 an optional tb_offset to be specified, and to preserve exception
3639 3654 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
3640 3655
3641 3656 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
3642 3657
3643 3658 2003-05-15 Fernando Perez <fperez@colorado.edu>
3644 3659
3645 3660 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
3646 3661 installing for a new user under Windows.
3647 3662
3648 3663 2003-05-12 Fernando Perez <fperez@colorado.edu>
3649 3664
3650 3665 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
3651 3666 handler for Emacs comint-based lines. Currently it doesn't do
3652 3667 much (but importantly, it doesn't update the history cache). In
3653 3668 the future it may be expanded if Alex needs more functionality
3654 3669 there.
3655 3670
3656 3671 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
3657 3672 info to crash reports.
3658 3673
3659 3674 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
3660 3675 just like Python's -c. Also fixed crash with invalid -color
3661 3676 option value at startup. Thanks to Will French
3662 3677 <wfrench-AT-bestweb.net> for the bug report.
3663 3678
3664 3679 2003-05-09 Fernando Perez <fperez@colorado.edu>
3665 3680
3666 3681 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
3667 3682 to EvalDict (it's a mapping, after all) and simplified its code
3668 3683 quite a bit, after a nice discussion on c.l.py where Gustavo
3669 3684 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
3670 3685
3671 3686 2003-04-30 Fernando Perez <fperez@colorado.edu>
3672 3687
3673 3688 * IPython/genutils.py (timings_out): modified it to reduce its
3674 3689 overhead in the common reps==1 case.
3675 3690
3676 3691 2003-04-29 Fernando Perez <fperez@colorado.edu>
3677 3692
3678 3693 * IPython/genutils.py (timings_out): Modified to use the resource
3679 3694 module, which avoids the wraparound problems of time.clock().
3680 3695
3681 3696 2003-04-17 *** Released version 0.2.15pre4
3682 3697
3683 3698 2003-04-17 Fernando Perez <fperez@colorado.edu>
3684 3699
3685 3700 * setup.py (scriptfiles): Split windows-specific stuff over to a
3686 3701 separate file, in an attempt to have a Windows GUI installer.
3687 3702 That didn't work, but part of the groundwork is done.
3688 3703
3689 3704 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
3690 3705 indent/unindent with 4 spaces. Particularly useful in combination
3691 3706 with the new auto-indent option.
3692 3707
3693 3708 2003-04-16 Fernando Perez <fperez@colorado.edu>
3694 3709
3695 3710 * IPython/Magic.py: various replacements of self.rc for
3696 3711 self.shell.rc. A lot more remains to be done to fully disentangle
3697 3712 this class from the main Shell class.
3698 3713
3699 3714 * IPython/GnuplotRuntime.py: added checks for mouse support so
3700 3715 that we don't try to enable it if the current gnuplot doesn't
3701 3716 really support it. Also added checks so that we don't try to
3702 3717 enable persist under Windows (where Gnuplot doesn't recognize the
3703 3718 option).
3704 3719
3705 3720 * IPython/iplib.py (InteractiveShell.interact): Added optional
3706 3721 auto-indenting code, after a patch by King C. Shu
3707 3722 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
3708 3723 get along well with pasting indented code. If I ever figure out
3709 3724 how to make that part go well, it will become on by default.
3710 3725
3711 3726 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
3712 3727 crash ipython if there was an unmatched '%' in the user's prompt
3713 3728 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3714 3729
3715 3730 * IPython/iplib.py (InteractiveShell.interact): removed the
3716 3731 ability to ask the user whether he wants to crash or not at the
3717 3732 'last line' exception handler. Calling functions at that point
3718 3733 changes the stack, and the error reports would have incorrect
3719 3734 tracebacks.
3720 3735
3721 3736 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
3722 3737 pass through a peger a pretty-printed form of any object. After a
3723 3738 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
3724 3739
3725 3740 2003-04-14 Fernando Perez <fperez@colorado.edu>
3726 3741
3727 3742 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
3728 3743 all files in ~ would be modified at first install (instead of
3729 3744 ~/.ipython). This could be potentially disastrous, as the
3730 3745 modification (make line-endings native) could damage binary files.
3731 3746
3732 3747 2003-04-10 Fernando Perez <fperez@colorado.edu>
3733 3748
3734 3749 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
3735 3750 handle only lines which are invalid python. This now means that
3736 3751 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
3737 3752 for the bug report.
3738 3753
3739 3754 2003-04-01 Fernando Perez <fperez@colorado.edu>
3740 3755
3741 3756 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
3742 3757 where failing to set sys.last_traceback would crash pdb.pm().
3743 3758 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
3744 3759 report.
3745 3760
3746 3761 2003-03-25 Fernando Perez <fperez@colorado.edu>
3747 3762
3748 3763 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
3749 3764 before printing it (it had a lot of spurious blank lines at the
3750 3765 end).
3751 3766
3752 3767 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
3753 3768 output would be sent 21 times! Obviously people don't use this
3754 3769 too often, or I would have heard about it.
3755 3770
3756 3771 2003-03-24 Fernando Perez <fperez@colorado.edu>
3757 3772
3758 3773 * setup.py (scriptfiles): renamed the data_files parameter from
3759 3774 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
3760 3775 for the patch.
3761 3776
3762 3777 2003-03-20 Fernando Perez <fperez@colorado.edu>
3763 3778
3764 3779 * IPython/genutils.py (error): added error() and fatal()
3765 3780 functions.
3766 3781
3767 3782 2003-03-18 *** Released version 0.2.15pre3
3768 3783
3769 3784 2003-03-18 Fernando Perez <fperez@colorado.edu>
3770 3785
3771 3786 * setupext/install_data_ext.py
3772 3787 (install_data_ext.initialize_options): Class contributed by Jack
3773 3788 Moffit for fixing the old distutils hack. He is sending this to
3774 3789 the distutils folks so in the future we may not need it as a
3775 3790 private fix.
3776 3791
3777 3792 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
3778 3793 changes for Debian packaging. See his patch for full details.
3779 3794 The old distutils hack of making the ipythonrc* files carry a
3780 3795 bogus .py extension is gone, at last. Examples were moved to a
3781 3796 separate subdir under doc/, and the separate executable scripts
3782 3797 now live in their own directory. Overall a great cleanup. The
3783 3798 manual was updated to use the new files, and setup.py has been
3784 3799 fixed for this setup.
3785 3800
3786 3801 * IPython/PyColorize.py (Parser.usage): made non-executable and
3787 3802 created a pycolor wrapper around it to be included as a script.
3788 3803
3789 3804 2003-03-12 *** Released version 0.2.15pre2
3790 3805
3791 3806 2003-03-12 Fernando Perez <fperez@colorado.edu>
3792 3807
3793 3808 * IPython/ColorANSI.py (make_color_table): Finally fixed the
3794 3809 long-standing problem with garbage characters in some terminals.
3795 3810 The issue was really that the \001 and \002 escapes must _only_ be
3796 3811 passed to input prompts (which call readline), but _never_ to
3797 3812 normal text to be printed on screen. I changed ColorANSI to have
3798 3813 two classes: TermColors and InputTermColors, each with the
3799 3814 appropriate escapes for input prompts or normal text. The code in
3800 3815 Prompts.py got slightly more complicated, but this very old and
3801 3816 annoying bug is finally fixed.
3802 3817
3803 3818 All the credit for nailing down the real origin of this problem
3804 3819 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
3805 3820 *Many* thanks to him for spending quite a bit of effort on this.
3806 3821
3807 3822 2003-03-05 *** Released version 0.2.15pre1
3808 3823
3809 3824 2003-03-03 Fernando Perez <fperez@colorado.edu>
3810 3825
3811 3826 * IPython/FakeModule.py: Moved the former _FakeModule to a
3812 3827 separate file, because it's also needed by Magic (to fix a similar
3813 3828 pickle-related issue in @run).
3814 3829
3815 3830 2003-03-02 Fernando Perez <fperez@colorado.edu>
3816 3831
3817 3832 * IPython/Magic.py (Magic.magic_autocall): new magic to control
3818 3833 the autocall option at runtime.
3819 3834 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
3820 3835 across Magic.py to start separating Magic from InteractiveShell.
3821 3836 (Magic._ofind): Fixed to return proper namespace for dotted
3822 3837 names. Before, a dotted name would always return 'not currently
3823 3838 defined', because it would find the 'parent'. s.x would be found,
3824 3839 but since 'x' isn't defined by itself, it would get confused.
3825 3840 (Magic.magic_run): Fixed pickling problems reported by Ralf
3826 3841 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
3827 3842 that I'd used when Mike Heeter reported similar issues at the
3828 3843 top-level, but now for @run. It boils down to injecting the
3829 3844 namespace where code is being executed with something that looks
3830 3845 enough like a module to fool pickle.dump(). Since a pickle stores
3831 3846 a named reference to the importing module, we need this for
3832 3847 pickles to save something sensible.
3833 3848
3834 3849 * IPython/ipmaker.py (make_IPython): added an autocall option.
3835 3850
3836 3851 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
3837 3852 the auto-eval code. Now autocalling is an option, and the code is
3838 3853 also vastly safer. There is no more eval() involved at all.
3839 3854
3840 3855 2003-03-01 Fernando Perez <fperez@colorado.edu>
3841 3856
3842 3857 * IPython/Magic.py (Magic._ofind): Changed interface to return a
3843 3858 dict with named keys instead of a tuple.
3844 3859
3845 3860 * IPython: Started using CVS for IPython as of 0.2.15pre1.
3846 3861
3847 3862 * setup.py (make_shortcut): Fixed message about directories
3848 3863 created during Windows installation (the directories were ok, just
3849 3864 the printed message was misleading). Thanks to Chris Liechti
3850 3865 <cliechti-AT-gmx.net> for the heads up.
3851 3866
3852 3867 2003-02-21 Fernando Perez <fperez@colorado.edu>
3853 3868
3854 3869 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
3855 3870 of ValueError exception when checking for auto-execution. This
3856 3871 one is raised by things like Numeric arrays arr.flat when the
3857 3872 array is non-contiguous.
3858 3873
3859 3874 2003-01-31 Fernando Perez <fperez@colorado.edu>
3860 3875
3861 3876 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
3862 3877 not return any value at all (even though the command would get
3863 3878 executed).
3864 3879 (xsys): Flush stdout right after printing the command to ensure
3865 3880 proper ordering of commands and command output in the total
3866 3881 output.
3867 3882 (SystemExec/xsys/bq): Switched the names of xsys/bq and
3868 3883 system/getoutput as defaults. The old ones are kept for
3869 3884 compatibility reasons, so no code which uses this library needs
3870 3885 changing.
3871 3886
3872 3887 2003-01-27 *** Released version 0.2.14
3873 3888
3874 3889 2003-01-25 Fernando Perez <fperez@colorado.edu>
3875 3890
3876 3891 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
3877 3892 functions defined in previous edit sessions could not be re-edited
3878 3893 (because the temp files were immediately removed). Now temp files
3879 3894 are removed only at IPython's exit.
3880 3895 (Magic.magic_run): Improved @run to perform shell-like expansions
3881 3896 on its arguments (~users and $VARS). With this, @run becomes more
3882 3897 like a normal command-line.
3883 3898
3884 3899 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
3885 3900 bugs related to embedding and cleaned up that code. A fairly
3886 3901 important one was the impossibility to access the global namespace
3887 3902 through the embedded IPython (only local variables were visible).
3888 3903
3889 3904 2003-01-14 Fernando Perez <fperez@colorado.edu>
3890 3905
3891 3906 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
3892 3907 auto-calling to be a bit more conservative. Now it doesn't get
3893 3908 triggered if any of '!=()<>' are in the rest of the input line, to
3894 3909 allow comparing callables. Thanks to Alex for the heads up.
3895 3910
3896 3911 2003-01-07 Fernando Perez <fperez@colorado.edu>
3897 3912
3898 3913 * IPython/genutils.py (page): fixed estimation of the number of
3899 3914 lines in a string to be paged to simply count newlines. This
3900 3915 prevents over-guessing due to embedded escape sequences. A better
3901 3916 long-term solution would involve stripping out the control chars
3902 3917 for the count, but it's potentially so expensive I just don't
3903 3918 think it's worth doing.
3904 3919
3905 3920 2002-12-19 *** Released version 0.2.14pre50
3906 3921
3907 3922 2002-12-19 Fernando Perez <fperez@colorado.edu>
3908 3923
3909 3924 * tools/release (version): Changed release scripts to inform
3910 3925 Andrea and build a NEWS file with a list of recent changes.
3911 3926
3912 3927 * IPython/ColorANSI.py (__all__): changed terminal detection
3913 3928 code. Seems to work better for xterms without breaking
3914 3929 konsole. Will need more testing to determine if WinXP and Mac OSX
3915 3930 also work ok.
3916 3931
3917 3932 2002-12-18 *** Released version 0.2.14pre49
3918 3933
3919 3934 2002-12-18 Fernando Perez <fperez@colorado.edu>
3920 3935
3921 3936 * Docs: added new info about Mac OSX, from Andrea.
3922 3937
3923 3938 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
3924 3939 allow direct plotting of python strings whose format is the same
3925 3940 of gnuplot data files.
3926 3941
3927 3942 2002-12-16 Fernando Perez <fperez@colorado.edu>
3928 3943
3929 3944 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
3930 3945 value of exit question to be acknowledged.
3931 3946
3932 3947 2002-12-03 Fernando Perez <fperez@colorado.edu>
3933 3948
3934 3949 * IPython/ipmaker.py: removed generators, which had been added
3935 3950 by mistake in an earlier debugging run. This was causing trouble
3936 3951 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
3937 3952 for pointing this out.
3938 3953
3939 3954 2002-11-17 Fernando Perez <fperez@colorado.edu>
3940 3955
3941 3956 * Manual: updated the Gnuplot section.
3942 3957
3943 3958 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
3944 3959 a much better split of what goes in Runtime and what goes in
3945 3960 Interactive.
3946 3961
3947 3962 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
3948 3963 being imported from iplib.
3949 3964
3950 3965 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
3951 3966 for command-passing. Now the global Gnuplot instance is called
3952 3967 'gp' instead of 'g', which was really a far too fragile and
3953 3968 common name.
3954 3969
3955 3970 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
3956 3971 bounding boxes generated by Gnuplot for square plots.
3957 3972
3958 3973 * IPython/genutils.py (popkey): new function added. I should
3959 3974 suggest this on c.l.py as a dict method, it seems useful.
3960 3975
3961 3976 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
3962 3977 to transparently handle PostScript generation. MUCH better than
3963 3978 the previous plot_eps/replot_eps (which I removed now). The code
3964 3979 is also fairly clean and well documented now (including
3965 3980 docstrings).
3966 3981
3967 3982 2002-11-13 Fernando Perez <fperez@colorado.edu>
3968 3983
3969 3984 * IPython/Magic.py (Magic.magic_edit): fixed docstring
3970 3985 (inconsistent with options).
3971 3986
3972 3987 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
3973 3988 manually disabled, I don't know why. Fixed it.
3974 3989 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
3975 3990 eps output.
3976 3991
3977 3992 2002-11-12 Fernando Perez <fperez@colorado.edu>
3978 3993
3979 3994 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
3980 3995 don't propagate up to caller. Fixes crash reported by François
3981 3996 Pinard.
3982 3997
3983 3998 2002-11-09 Fernando Perez <fperez@colorado.edu>
3984 3999
3985 4000 * IPython/ipmaker.py (make_IPython): fixed problem with writing
3986 4001 history file for new users.
3987 4002 (make_IPython): fixed bug where initial install would leave the
3988 4003 user running in the .ipython dir.
3989 4004 (make_IPython): fixed bug where config dir .ipython would be
3990 4005 created regardless of the given -ipythondir option. Thanks to Cory
3991 4006 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
3992 4007
3993 4008 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
3994 4009 type confirmations. Will need to use it in all of IPython's code
3995 4010 consistently.
3996 4011
3997 4012 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
3998 4013 context to print 31 lines instead of the default 5. This will make
3999 4014 the crash reports extremely detailed in case the problem is in
4000 4015 libraries I don't have access to.
4001 4016
4002 4017 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
4003 4018 line of defense' code to still crash, but giving users fair
4004 4019 warning. I don't want internal errors to go unreported: if there's
4005 4020 an internal problem, IPython should crash and generate a full
4006 4021 report.
4007 4022
4008 4023 2002-11-08 Fernando Perez <fperez@colorado.edu>
4009 4024
4010 4025 * IPython/iplib.py (InteractiveShell.interact): added code to trap
4011 4026 otherwise uncaught exceptions which can appear if people set
4012 4027 sys.stdout to something badly broken. Thanks to a crash report
4013 4028 from henni-AT-mail.brainbot.com.
4014 4029
4015 4030 2002-11-04 Fernando Perez <fperez@colorado.edu>
4016 4031
4017 4032 * IPython/iplib.py (InteractiveShell.interact): added
4018 4033 __IPYTHON__active to the builtins. It's a flag which goes on when
4019 4034 the interaction starts and goes off again when it stops. This
4020 4035 allows embedding code to detect being inside IPython. Before this
4021 4036 was done via __IPYTHON__, but that only shows that an IPython
4022 4037 instance has been created.
4023 4038
4024 4039 * IPython/Magic.py (Magic.magic_env): I realized that in a
4025 4040 UserDict, instance.data holds the data as a normal dict. So I
4026 4041 modified @env to return os.environ.data instead of rebuilding a
4027 4042 dict by hand.
4028 4043
4029 4044 2002-11-02 Fernando Perez <fperez@colorado.edu>
4030 4045
4031 4046 * IPython/genutils.py (warn): changed so that level 1 prints no
4032 4047 header. Level 2 is now the default (with 'WARNING' header, as
4033 4048 before). I think I tracked all places where changes were needed in
4034 4049 IPython, but outside code using the old level numbering may have
4035 4050 broken.
4036 4051
4037 4052 * IPython/iplib.py (InteractiveShell.runcode): added this to
4038 4053 handle the tracebacks in SystemExit traps correctly. The previous
4039 4054 code (through interact) was printing more of the stack than
4040 4055 necessary, showing IPython internal code to the user.
4041 4056
4042 4057 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
4043 4058 default. Now that the default at the confirmation prompt is yes,
4044 4059 it's not so intrusive. François' argument that ipython sessions
4045 4060 tend to be complex enough not to lose them from an accidental C-d,
4046 4061 is a valid one.
4047 4062
4048 4063 * IPython/iplib.py (InteractiveShell.interact): added a
4049 4064 showtraceback() call to the SystemExit trap, and modified the exit
4050 4065 confirmation to have yes as the default.
4051 4066
4052 4067 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
4053 4068 this file. It's been gone from the code for a long time, this was
4054 4069 simply leftover junk.
4055 4070
4056 4071 2002-11-01 Fernando Perez <fperez@colorado.edu>
4057 4072
4058 4073 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
4059 4074 added. If set, IPython now traps EOF and asks for
4060 4075 confirmation. After a request by François Pinard.
4061 4076
4062 4077 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
4063 4078 of @abort, and with a new (better) mechanism for handling the
4064 4079 exceptions.
4065 4080
4066 4081 2002-10-27 Fernando Perez <fperez@colorado.edu>
4067 4082
4068 4083 * IPython/usage.py (__doc__): updated the --help information and
4069 4084 the ipythonrc file to indicate that -log generates
4070 4085 ./ipython.log. Also fixed the corresponding info in @logstart.
4071 4086 This and several other fixes in the manuals thanks to reports by
4072 4087 François Pinard <pinard-AT-iro.umontreal.ca>.
4073 4088
4074 4089 * IPython/Logger.py (Logger.switch_log): Fixed error message to
4075 4090 refer to @logstart (instead of @log, which doesn't exist).
4076 4091
4077 4092 * IPython/iplib.py (InteractiveShell._prefilter): fixed
4078 4093 AttributeError crash. Thanks to Christopher Armstrong
4079 4094 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
4080 4095 introduced recently (in 0.2.14pre37) with the fix to the eval
4081 4096 problem mentioned below.
4082 4097
4083 4098 2002-10-17 Fernando Perez <fperez@colorado.edu>
4084 4099
4085 4100 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
4086 4101 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
4087 4102
4088 4103 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
4089 4104 this function to fix a problem reported by Alex Schmolck. He saw
4090 4105 it with list comprehensions and generators, which were getting
4091 4106 called twice. The real problem was an 'eval' call in testing for
4092 4107 automagic which was evaluating the input line silently.
4093 4108
4094 4109 This is a potentially very nasty bug, if the input has side
4095 4110 effects which must not be repeated. The code is much cleaner now,
4096 4111 without any blanket 'except' left and with a regexp test for
4097 4112 actual function names.
4098 4113
4099 4114 But an eval remains, which I'm not fully comfortable with. I just
4100 4115 don't know how to find out if an expression could be a callable in
4101 4116 the user's namespace without doing an eval on the string. However
4102 4117 that string is now much more strictly checked so that no code
4103 4118 slips by, so the eval should only happen for things that can
4104 4119 really be only function/method names.
4105 4120
4106 4121 2002-10-15 Fernando Perez <fperez@colorado.edu>
4107 4122
4108 4123 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
4109 4124 OSX information to main manual, removed README_Mac_OSX file from
4110 4125 distribution. Also updated credits for recent additions.
4111 4126
4112 4127 2002-10-10 Fernando Perez <fperez@colorado.edu>
4113 4128
4114 4129 * README_Mac_OSX: Added a README for Mac OSX users for fixing
4115 4130 terminal-related issues. Many thanks to Andrea Riciputi
4116 4131 <andrea.riciputi-AT-libero.it> for writing it.
4117 4132
4118 4133 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
4119 4134 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4120 4135
4121 4136 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
4122 4137 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
4123 4138 <syver-en-AT-online.no> who both submitted patches for this problem.
4124 4139
4125 4140 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
4126 4141 global embedding to make sure that things don't overwrite user
4127 4142 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
4128 4143
4129 4144 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
4130 4145 compatibility. Thanks to Hayden Callow
4131 4146 <h.callow-AT-elec.canterbury.ac.nz>
4132 4147
4133 4148 2002-10-04 Fernando Perez <fperez@colorado.edu>
4134 4149
4135 4150 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
4136 4151 Gnuplot.File objects.
4137 4152
4138 4153 2002-07-23 Fernando Perez <fperez@colorado.edu>
4139 4154
4140 4155 * IPython/genutils.py (timing): Added timings() and timing() for
4141 4156 quick access to the most commonly needed data, the execution
4142 4157 times. Old timing() renamed to timings_out().
4143 4158
4144 4159 2002-07-18 Fernando Perez <fperez@colorado.edu>
4145 4160
4146 4161 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
4147 4162 bug with nested instances disrupting the parent's tab completion.
4148 4163
4149 4164 * IPython/iplib.py (all_completions): Added Alex Schmolck's
4150 4165 all_completions code to begin the emacs integration.
4151 4166
4152 4167 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
4153 4168 argument to allow titling individual arrays when plotting.
4154 4169
4155 4170 2002-07-15 Fernando Perez <fperez@colorado.edu>
4156 4171
4157 4172 * setup.py (make_shortcut): changed to retrieve the value of
4158 4173 'Program Files' directory from the registry (this value changes in
4159 4174 non-english versions of Windows). Thanks to Thomas Fanslau
4160 4175 <tfanslau-AT-gmx.de> for the report.
4161 4176
4162 4177 2002-07-10 Fernando Perez <fperez@colorado.edu>
4163 4178
4164 4179 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
4165 4180 a bug in pdb, which crashes if a line with only whitespace is
4166 4181 entered. Bug report submitted to sourceforge.
4167 4182
4168 4183 2002-07-09 Fernando Perez <fperez@colorado.edu>
4169 4184
4170 4185 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
4171 4186 reporting exceptions (it's a bug in inspect.py, I just set a
4172 4187 workaround).
4173 4188
4174 4189 2002-07-08 Fernando Perez <fperez@colorado.edu>
4175 4190
4176 4191 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
4177 4192 __IPYTHON__ in __builtins__ to show up in user_ns.
4178 4193
4179 4194 2002-07-03 Fernando Perez <fperez@colorado.edu>
4180 4195
4181 4196 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
4182 4197 name from @gp_set_instance to @gp_set_default.
4183 4198
4184 4199 * IPython/ipmaker.py (make_IPython): default editor value set to
4185 4200 '0' (a string), to match the rc file. Otherwise will crash when
4186 4201 .strip() is called on it.
4187 4202
4188 4203
4189 4204 2002-06-28 Fernando Perez <fperez@colorado.edu>
4190 4205
4191 4206 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
4192 4207 of files in current directory when a file is executed via
4193 4208 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
4194 4209
4195 4210 * setup.py (manfiles): fix for rpm builds, submitted by RA
4196 4211 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
4197 4212
4198 4213 * IPython/ipmaker.py (make_IPython): fixed lookup of default
4199 4214 editor when set to '0'. Problem was, '0' evaluates to True (it's a
4200 4215 string!). A. Schmolck caught this one.
4201 4216
4202 4217 2002-06-27 Fernando Perez <fperez@colorado.edu>
4203 4218
4204 4219 * IPython/ipmaker.py (make_IPython): fixed bug when running user
4205 4220 defined files at the cmd line. __name__ wasn't being set to
4206 4221 __main__.
4207 4222
4208 4223 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
4209 4224 regular lists and tuples besides Numeric arrays.
4210 4225
4211 4226 * IPython/Prompts.py (CachedOutput.__call__): Added output
4212 4227 supression for input ending with ';'. Similar to Mathematica and
4213 4228 Matlab. The _* vars and Out[] list are still updated, just like
4214 4229 Mathematica behaves.
4215 4230
4216 4231 2002-06-25 Fernando Perez <fperez@colorado.edu>
4217 4232
4218 4233 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
4219 4234 .ini extensions for profiels under Windows.
4220 4235
4221 4236 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
4222 4237 string form. Fix contributed by Alexander Schmolck
4223 4238 <a.schmolck-AT-gmx.net>
4224 4239
4225 4240 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
4226 4241 pre-configured Gnuplot instance.
4227 4242
4228 4243 2002-06-21 Fernando Perez <fperez@colorado.edu>
4229 4244
4230 4245 * IPython/numutils.py (exp_safe): new function, works around the
4231 4246 underflow problems in Numeric.
4232 4247 (log2): New fn. Safe log in base 2: returns exact integer answer
4233 4248 for exact integer powers of 2.
4234 4249
4235 4250 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
4236 4251 properly.
4237 4252
4238 4253 2002-06-20 Fernando Perez <fperez@colorado.edu>
4239 4254
4240 4255 * IPython/genutils.py (timing): new function like
4241 4256 Mathematica's. Similar to time_test, but returns more info.
4242 4257
4243 4258 2002-06-18 Fernando Perez <fperez@colorado.edu>
4244 4259
4245 4260 * IPython/Magic.py (Magic.magic_save): modified @save and @r
4246 4261 according to Mike Heeter's suggestions.
4247 4262
4248 4263 2002-06-16 Fernando Perez <fperez@colorado.edu>
4249 4264
4250 4265 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
4251 4266 system. GnuplotMagic is gone as a user-directory option. New files
4252 4267 make it easier to use all the gnuplot stuff both from external
4253 4268 programs as well as from IPython. Had to rewrite part of
4254 4269 hardcopy() b/c of a strange bug: often the ps files simply don't
4255 4270 get created, and require a repeat of the command (often several
4256 4271 times).
4257 4272
4258 4273 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
4259 4274 resolve output channel at call time, so that if sys.stderr has
4260 4275 been redirected by user this gets honored.
4261 4276
4262 4277 2002-06-13 Fernando Perez <fperez@colorado.edu>
4263 4278
4264 4279 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
4265 4280 IPShell. Kept a copy with the old names to avoid breaking people's
4266 4281 embedded code.
4267 4282
4268 4283 * IPython/ipython: simplified it to the bare minimum after
4269 4284 Holger's suggestions. Added info about how to use it in
4270 4285 PYTHONSTARTUP.
4271 4286
4272 4287 * IPython/Shell.py (IPythonShell): changed the options passing
4273 4288 from a string with funky %s replacements to a straight list. Maybe
4274 4289 a bit more typing, but it follows sys.argv conventions, so there's
4275 4290 less special-casing to remember.
4276 4291
4277 4292 2002-06-12 Fernando Perez <fperez@colorado.edu>
4278 4293
4279 4294 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
4280 4295 command. Thanks to a suggestion by Mike Heeter.
4281 4296 (Magic.magic_pfile): added behavior to look at filenames if given
4282 4297 arg is not a defined object.
4283 4298 (Magic.magic_save): New @save function to save code snippets. Also
4284 4299 a Mike Heeter idea.
4285 4300
4286 4301 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
4287 4302 plot() and replot(). Much more convenient now, especially for
4288 4303 interactive use.
4289 4304
4290 4305 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
4291 4306 filenames.
4292 4307
4293 4308 2002-06-02 Fernando Perez <fperez@colorado.edu>
4294 4309
4295 4310 * IPython/Struct.py (Struct.__init__): modified to admit
4296 4311 initialization via another struct.
4297 4312
4298 4313 * IPython/genutils.py (SystemExec.__init__): New stateful
4299 4314 interface to xsys and bq. Useful for writing system scripts.
4300 4315
4301 4316 2002-05-30 Fernando Perez <fperez@colorado.edu>
4302 4317
4303 4318 * MANIFEST.in: Changed docfile selection to exclude all the lyx
4304 4319 documents. This will make the user download smaller (it's getting
4305 4320 too big).
4306 4321
4307 4322 2002-05-29 Fernando Perez <fperez@colorado.edu>
4308 4323
4309 4324 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
4310 4325 fix problems with shelve and pickle. Seems to work, but I don't
4311 4326 know if corner cases break it. Thanks to Mike Heeter
4312 4327 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
4313 4328
4314 4329 2002-05-24 Fernando Perez <fperez@colorado.edu>
4315 4330
4316 4331 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
4317 4332 macros having broken.
4318 4333
4319 4334 2002-05-21 Fernando Perez <fperez@colorado.edu>
4320 4335
4321 4336 * IPython/Magic.py (Magic.magic_logstart): fixed recently
4322 4337 introduced logging bug: all history before logging started was
4323 4338 being written one character per line! This came from the redesign
4324 4339 of the input history as a special list which slices to strings,
4325 4340 not to lists.
4326 4341
4327 4342 2002-05-20 Fernando Perez <fperez@colorado.edu>
4328 4343
4329 4344 * IPython/Prompts.py (CachedOutput.__init__): made the color table
4330 4345 be an attribute of all classes in this module. The design of these
4331 4346 classes needs some serious overhauling.
4332 4347
4333 4348 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
4334 4349 which was ignoring '_' in option names.
4335 4350
4336 4351 * IPython/ultraTB.py (FormattedTB.__init__): Changed
4337 4352 'Verbose_novars' to 'Context' and made it the new default. It's a
4338 4353 bit more readable and also safer than verbose.
4339 4354
4340 4355 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
4341 4356 triple-quoted strings.
4342 4357
4343 4358 * IPython/OInspect.py (__all__): new module exposing the object
4344 4359 introspection facilities. Now the corresponding magics are dummy
4345 4360 wrappers around this. Having this module will make it much easier
4346 4361 to put these functions into our modified pdb.
4347 4362 This new object inspector system uses the new colorizing module,
4348 4363 so source code and other things are nicely syntax highlighted.
4349 4364
4350 4365 2002-05-18 Fernando Perez <fperez@colorado.edu>
4351 4366
4352 4367 * IPython/ColorANSI.py: Split the coloring tools into a separate
4353 4368 module so I can use them in other code easier (they were part of
4354 4369 ultraTB).
4355 4370
4356 4371 2002-05-17 Fernando Perez <fperez@colorado.edu>
4357 4372
4358 4373 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4359 4374 fixed it to set the global 'g' also to the called instance, as
4360 4375 long as 'g' was still a gnuplot instance (so it doesn't overwrite
4361 4376 user's 'g' variables).
4362 4377
4363 4378 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
4364 4379 global variables (aliases to _ih,_oh) so that users which expect
4365 4380 In[5] or Out[7] to work aren't unpleasantly surprised.
4366 4381 (InputList.__getslice__): new class to allow executing slices of
4367 4382 input history directly. Very simple class, complements the use of
4368 4383 macros.
4369 4384
4370 4385 2002-05-16 Fernando Perez <fperez@colorado.edu>
4371 4386
4372 4387 * setup.py (docdirbase): make doc directory be just doc/IPython
4373 4388 without version numbers, it will reduce clutter for users.
4374 4389
4375 4390 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
4376 4391 execfile call to prevent possible memory leak. See for details:
4377 4392 http://mail.python.org/pipermail/python-list/2002-February/088476.html
4378 4393
4379 4394 2002-05-15 Fernando Perez <fperez@colorado.edu>
4380 4395
4381 4396 * IPython/Magic.py (Magic.magic_psource): made the object
4382 4397 introspection names be more standard: pdoc, pdef, pfile and
4383 4398 psource. They all print/page their output, and it makes
4384 4399 remembering them easier. Kept old names for compatibility as
4385 4400 aliases.
4386 4401
4387 4402 2002-05-14 Fernando Perez <fperez@colorado.edu>
4388 4403
4389 4404 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
4390 4405 what the mouse problem was. The trick is to use gnuplot with temp
4391 4406 files and NOT with pipes (for data communication), because having
4392 4407 both pipes and the mouse on is bad news.
4393 4408
4394 4409 2002-05-13 Fernando Perez <fperez@colorado.edu>
4395 4410
4396 4411 * IPython/Magic.py (Magic._ofind): fixed namespace order search
4397 4412 bug. Information would be reported about builtins even when
4398 4413 user-defined functions overrode them.
4399 4414
4400 4415 2002-05-11 Fernando Perez <fperez@colorado.edu>
4401 4416
4402 4417 * IPython/__init__.py (__all__): removed FlexCompleter from
4403 4418 __all__ so that things don't fail in platforms without readline.
4404 4419
4405 4420 2002-05-10 Fernando Perez <fperez@colorado.edu>
4406 4421
4407 4422 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
4408 4423 it requires Numeric, effectively making Numeric a dependency for
4409 4424 IPython.
4410 4425
4411 4426 * Released 0.2.13
4412 4427
4413 4428 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
4414 4429 profiler interface. Now all the major options from the profiler
4415 4430 module are directly supported in IPython, both for single
4416 4431 expressions (@prun) and for full programs (@run -p).
4417 4432
4418 4433 2002-05-09 Fernando Perez <fperez@colorado.edu>
4419 4434
4420 4435 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
4421 4436 magic properly formatted for screen.
4422 4437
4423 4438 * setup.py (make_shortcut): Changed things to put pdf version in
4424 4439 doc/ instead of doc/manual (had to change lyxport a bit).
4425 4440
4426 4441 * IPython/Magic.py (Profile.string_stats): made profile runs go
4427 4442 through pager (they are long and a pager allows searching, saving,
4428 4443 etc.)
4429 4444
4430 4445 2002-05-08 Fernando Perez <fperez@colorado.edu>
4431 4446
4432 4447 * Released 0.2.12
4433 4448
4434 4449 2002-05-06 Fernando Perez <fperez@colorado.edu>
4435 4450
4436 4451 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
4437 4452 introduced); 'hist n1 n2' was broken.
4438 4453 (Magic.magic_pdb): added optional on/off arguments to @pdb
4439 4454 (Magic.magic_run): added option -i to @run, which executes code in
4440 4455 the IPython namespace instead of a clean one. Also added @irun as
4441 4456 an alias to @run -i.
4442 4457
4443 4458 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4444 4459 fixed (it didn't really do anything, the namespaces were wrong).
4445 4460
4446 4461 * IPython/Debugger.py (__init__): Added workaround for python 2.1
4447 4462
4448 4463 * IPython/__init__.py (__all__): Fixed package namespace, now
4449 4464 'import IPython' does give access to IPython.<all> as
4450 4465 expected. Also renamed __release__ to Release.
4451 4466
4452 4467 * IPython/Debugger.py (__license__): created new Pdb class which
4453 4468 functions like a drop-in for the normal pdb.Pdb but does NOT
4454 4469 import readline by default. This way it doesn't muck up IPython's
4455 4470 readline handling, and now tab-completion finally works in the
4456 4471 debugger -- sort of. It completes things globally visible, but the
4457 4472 completer doesn't track the stack as pdb walks it. That's a bit
4458 4473 tricky, and I'll have to implement it later.
4459 4474
4460 4475 2002-05-05 Fernando Perez <fperez@colorado.edu>
4461 4476
4462 4477 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
4463 4478 magic docstrings when printed via ? (explicit \'s were being
4464 4479 printed).
4465 4480
4466 4481 * IPython/ipmaker.py (make_IPython): fixed namespace
4467 4482 identification bug. Now variables loaded via logs or command-line
4468 4483 files are recognized in the interactive namespace by @who.
4469 4484
4470 4485 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
4471 4486 log replay system stemming from the string form of Structs.
4472 4487
4473 4488 * IPython/Magic.py (Macro.__init__): improved macros to properly
4474 4489 handle magic commands in them.
4475 4490 (Magic.magic_logstart): usernames are now expanded so 'logstart
4476 4491 ~/mylog' now works.
4477 4492
4478 4493 * IPython/iplib.py (complete): fixed bug where paths starting with
4479 4494 '/' would be completed as magic names.
4480 4495
4481 4496 2002-05-04 Fernando Perez <fperez@colorado.edu>
4482 4497
4483 4498 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
4484 4499 allow running full programs under the profiler's control.
4485 4500
4486 4501 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
4487 4502 mode to report exceptions verbosely but without formatting
4488 4503 variables. This addresses the issue of ipython 'freezing' (it's
4489 4504 not frozen, but caught in an expensive formatting loop) when huge
4490 4505 variables are in the context of an exception.
4491 4506 (VerboseTB.text): Added '--->' markers at line where exception was
4492 4507 triggered. Much clearer to read, especially in NoColor modes.
4493 4508
4494 4509 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
4495 4510 implemented in reverse when changing to the new parse_options().
4496 4511
4497 4512 2002-05-03 Fernando Perez <fperez@colorado.edu>
4498 4513
4499 4514 * IPython/Magic.py (Magic.parse_options): new function so that
4500 4515 magics can parse options easier.
4501 4516 (Magic.magic_prun): new function similar to profile.run(),
4502 4517 suggested by Chris Hart.
4503 4518 (Magic.magic_cd): fixed behavior so that it only changes if
4504 4519 directory actually is in history.
4505 4520
4506 4521 * IPython/usage.py (__doc__): added information about potential
4507 4522 slowness of Verbose exception mode when there are huge data
4508 4523 structures to be formatted (thanks to Archie Paulson).
4509 4524
4510 4525 * IPython/ipmaker.py (make_IPython): Changed default logging
4511 4526 (when simply called with -log) to use curr_dir/ipython.log in
4512 4527 rotate mode. Fixed crash which was occuring with -log before
4513 4528 (thanks to Jim Boyle).
4514 4529
4515 4530 2002-05-01 Fernando Perez <fperez@colorado.edu>
4516 4531
4517 4532 * Released 0.2.11 for these fixes (mainly the ultraTB one which
4518 4533 was nasty -- though somewhat of a corner case).
4519 4534
4520 4535 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
4521 4536 text (was a bug).
4522 4537
4523 4538 2002-04-30 Fernando Perez <fperez@colorado.edu>
4524 4539
4525 4540 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
4526 4541 a print after ^D or ^C from the user so that the In[] prompt
4527 4542 doesn't over-run the gnuplot one.
4528 4543
4529 4544 2002-04-29 Fernando Perez <fperez@colorado.edu>
4530 4545
4531 4546 * Released 0.2.10
4532 4547
4533 4548 * IPython/__release__.py (version): get date dynamically.
4534 4549
4535 4550 * Misc. documentation updates thanks to Arnd's comments. Also ran
4536 4551 a full spellcheck on the manual (hadn't been done in a while).
4537 4552
4538 4553 2002-04-27 Fernando Perez <fperez@colorado.edu>
4539 4554
4540 4555 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
4541 4556 starting a log in mid-session would reset the input history list.
4542 4557
4543 4558 2002-04-26 Fernando Perez <fperez@colorado.edu>
4544 4559
4545 4560 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
4546 4561 all files were being included in an update. Now anything in
4547 4562 UserConfig that matches [A-Za-z]*.py will go (this excludes
4548 4563 __init__.py)
4549 4564
4550 4565 2002-04-25 Fernando Perez <fperez@colorado.edu>
4551 4566
4552 4567 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
4553 4568 to __builtins__ so that any form of embedded or imported code can
4554 4569 test for being inside IPython.
4555 4570
4556 4571 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
4557 4572 changed to GnuplotMagic because it's now an importable module,
4558 4573 this makes the name follow that of the standard Gnuplot module.
4559 4574 GnuplotMagic can now be loaded at any time in mid-session.
4560 4575
4561 4576 2002-04-24 Fernando Perez <fperez@colorado.edu>
4562 4577
4563 4578 * IPython/numutils.py: removed SIUnits. It doesn't properly set
4564 4579 the globals (IPython has its own namespace) and the
4565 4580 PhysicalQuantity stuff is much better anyway.
4566 4581
4567 4582 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
4568 4583 embedding example to standard user directory for
4569 4584 distribution. Also put it in the manual.
4570 4585
4571 4586 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
4572 4587 instance as first argument (so it doesn't rely on some obscure
4573 4588 hidden global).
4574 4589
4575 4590 * IPython/UserConfig/ipythonrc.py: put () back in accepted
4576 4591 delimiters. While it prevents ().TAB from working, it allows
4577 4592 completions in open (... expressions. This is by far a more common
4578 4593 case.
4579 4594
4580 4595 2002-04-23 Fernando Perez <fperez@colorado.edu>
4581 4596
4582 4597 * IPython/Extensions/InterpreterPasteInput.py: new
4583 4598 syntax-processing module for pasting lines with >>> or ... at the
4584 4599 start.
4585 4600
4586 4601 * IPython/Extensions/PhysicalQ_Interactive.py
4587 4602 (PhysicalQuantityInteractive.__int__): fixed to work with either
4588 4603 Numeric or math.
4589 4604
4590 4605 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
4591 4606 provided profiles. Now we have:
4592 4607 -math -> math module as * and cmath with its own namespace.
4593 4608 -numeric -> Numeric as *, plus gnuplot & grace
4594 4609 -physics -> same as before
4595 4610
4596 4611 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
4597 4612 user-defined magics wouldn't be found by @magic if they were
4598 4613 defined as class methods. Also cleaned up the namespace search
4599 4614 logic and the string building (to use %s instead of many repeated
4600 4615 string adds).
4601 4616
4602 4617 * IPython/UserConfig/example-magic.py (magic_foo): updated example
4603 4618 of user-defined magics to operate with class methods (cleaner, in
4604 4619 line with the gnuplot code).
4605 4620
4606 4621 2002-04-22 Fernando Perez <fperez@colorado.edu>
4607 4622
4608 4623 * setup.py: updated dependency list so that manual is updated when
4609 4624 all included files change.
4610 4625
4611 4626 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
4612 4627 the delimiter removal option (the fix is ugly right now).
4613 4628
4614 4629 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
4615 4630 all of the math profile (quicker loading, no conflict between
4616 4631 g-9.8 and g-gnuplot).
4617 4632
4618 4633 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
4619 4634 name of post-mortem files to IPython_crash_report.txt.
4620 4635
4621 4636 * Cleanup/update of the docs. Added all the new readline info and
4622 4637 formatted all lists as 'real lists'.
4623 4638
4624 4639 * IPython/ipmaker.py (make_IPython): removed now-obsolete
4625 4640 tab-completion options, since the full readline parse_and_bind is
4626 4641 now accessible.
4627 4642
4628 4643 * IPython/iplib.py (InteractiveShell.init_readline): Changed
4629 4644 handling of readline options. Now users can specify any string to
4630 4645 be passed to parse_and_bind(), as well as the delimiters to be
4631 4646 removed.
4632 4647 (InteractiveShell.__init__): Added __name__ to the global
4633 4648 namespace so that things like Itpl which rely on its existence
4634 4649 don't crash.
4635 4650 (InteractiveShell._prefilter): Defined the default with a _ so
4636 4651 that prefilter() is easier to override, while the default one
4637 4652 remains available.
4638 4653
4639 4654 2002-04-18 Fernando Perez <fperez@colorado.edu>
4640 4655
4641 4656 * Added information about pdb in the docs.
4642 4657
4643 4658 2002-04-17 Fernando Perez <fperez@colorado.edu>
4644 4659
4645 4660 * IPython/ipmaker.py (make_IPython): added rc_override option to
4646 4661 allow passing config options at creation time which may override
4647 4662 anything set in the config files or command line. This is
4648 4663 particularly useful for configuring embedded instances.
4649 4664
4650 4665 2002-04-15 Fernando Perez <fperez@colorado.edu>
4651 4666
4652 4667 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
4653 4668 crash embedded instances because of the input cache falling out of
4654 4669 sync with the output counter.
4655 4670
4656 4671 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
4657 4672 mode which calls pdb after an uncaught exception in IPython itself.
4658 4673
4659 4674 2002-04-14 Fernando Perez <fperez@colorado.edu>
4660 4675
4661 4676 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
4662 4677 readline, fix it back after each call.
4663 4678
4664 4679 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
4665 4680 method to force all access via __call__(), which guarantees that
4666 4681 traceback references are properly deleted.
4667 4682
4668 4683 * IPython/Prompts.py (CachedOutput._display): minor fixes to
4669 4684 improve printing when pprint is in use.
4670 4685
4671 4686 2002-04-13 Fernando Perez <fperez@colorado.edu>
4672 4687
4673 4688 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
4674 4689 exceptions aren't caught anymore. If the user triggers one, he
4675 4690 should know why he's doing it and it should go all the way up,
4676 4691 just like any other exception. So now @abort will fully kill the
4677 4692 embedded interpreter and the embedding code (unless that happens
4678 4693 to catch SystemExit).
4679 4694
4680 4695 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
4681 4696 and a debugger() method to invoke the interactive pdb debugger
4682 4697 after printing exception information. Also added the corresponding
4683 4698 -pdb option and @pdb magic to control this feature, and updated
4684 4699 the docs. After a suggestion from Christopher Hart
4685 4700 (hart-AT-caltech.edu).
4686 4701
4687 4702 2002-04-12 Fernando Perez <fperez@colorado.edu>
4688 4703
4689 4704 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
4690 4705 the exception handlers defined by the user (not the CrashHandler)
4691 4706 so that user exceptions don't trigger an ipython bug report.
4692 4707
4693 4708 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
4694 4709 configurable (it should have always been so).
4695 4710
4696 4711 2002-03-26 Fernando Perez <fperez@colorado.edu>
4697 4712
4698 4713 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
4699 4714 and there to fix embedding namespace issues. This should all be
4700 4715 done in a more elegant way.
4701 4716
4702 4717 2002-03-25 Fernando Perez <fperez@colorado.edu>
4703 4718
4704 4719 * IPython/genutils.py (get_home_dir): Try to make it work under
4705 4720 win9x also.
4706 4721
4707 4722 2002-03-20 Fernando Perez <fperez@colorado.edu>
4708 4723
4709 4724 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
4710 4725 sys.displayhook untouched upon __init__.
4711 4726
4712 4727 2002-03-19 Fernando Perez <fperez@colorado.edu>
4713 4728
4714 4729 * Released 0.2.9 (for embedding bug, basically).
4715 4730
4716 4731 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
4717 4732 exceptions so that enclosing shell's state can be restored.
4718 4733
4719 4734 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
4720 4735 naming conventions in the .ipython/ dir.
4721 4736
4722 4737 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
4723 4738 from delimiters list so filenames with - in them get expanded.
4724 4739
4725 4740 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
4726 4741 sys.displayhook not being properly restored after an embedded call.
4727 4742
4728 4743 2002-03-18 Fernando Perez <fperez@colorado.edu>
4729 4744
4730 4745 * Released 0.2.8
4731 4746
4732 4747 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
4733 4748 some files weren't being included in a -upgrade.
4734 4749 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
4735 4750 on' so that the first tab completes.
4736 4751 (InteractiveShell.handle_magic): fixed bug with spaces around
4737 4752 quotes breaking many magic commands.
4738 4753
4739 4754 * setup.py: added note about ignoring the syntax error messages at
4740 4755 installation.
4741 4756
4742 4757 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
4743 4758 streamlining the gnuplot interface, now there's only one magic @gp.
4744 4759
4745 4760 2002-03-17 Fernando Perez <fperez@colorado.edu>
4746 4761
4747 4762 * IPython/UserConfig/magic_gnuplot.py: new name for the
4748 4763 example-magic_pm.py file. Much enhanced system, now with a shell
4749 4764 for communicating directly with gnuplot, one command at a time.
4750 4765
4751 4766 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
4752 4767 setting __name__=='__main__'.
4753 4768
4754 4769 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
4755 4770 mini-shell for accessing gnuplot from inside ipython. Should
4756 4771 extend it later for grace access too. Inspired by Arnd's
4757 4772 suggestion.
4758 4773
4759 4774 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
4760 4775 calling magic functions with () in their arguments. Thanks to Arnd
4761 4776 Baecker for pointing this to me.
4762 4777
4763 4778 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
4764 4779 infinitely for integer or complex arrays (only worked with floats).
4765 4780
4766 4781 2002-03-16 Fernando Perez <fperez@colorado.edu>
4767 4782
4768 4783 * setup.py: Merged setup and setup_windows into a single script
4769 4784 which properly handles things for windows users.
4770 4785
4771 4786 2002-03-15 Fernando Perez <fperez@colorado.edu>
4772 4787
4773 4788 * Big change to the manual: now the magics are all automatically
4774 4789 documented. This information is generated from their docstrings
4775 4790 and put in a latex file included by the manual lyx file. This way
4776 4791 we get always up to date information for the magics. The manual
4777 4792 now also has proper version information, also auto-synced.
4778 4793
4779 4794 For this to work, an undocumented --magic_docstrings option was added.
4780 4795
4781 4796 2002-03-13 Fernando Perez <fperez@colorado.edu>
4782 4797
4783 4798 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
4784 4799 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
4785 4800
4786 4801 2002-03-12 Fernando Perez <fperez@colorado.edu>
4787 4802
4788 4803 * IPython/ultraTB.py (TermColors): changed color escapes again to
4789 4804 fix the (old, reintroduced) line-wrapping bug. Basically, if
4790 4805 \001..\002 aren't given in the color escapes, lines get wrapped
4791 4806 weirdly. But giving those screws up old xterms and emacs terms. So
4792 4807 I added some logic for emacs terms to be ok, but I can't identify old
4793 4808 xterms separately ($TERM=='xterm' for many terminals, like konsole).
4794 4809
4795 4810 2002-03-10 Fernando Perez <fperez@colorado.edu>
4796 4811
4797 4812 * IPython/usage.py (__doc__): Various documentation cleanups and
4798 4813 updates, both in usage docstrings and in the manual.
4799 4814
4800 4815 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
4801 4816 handling of caching. Set minimum acceptabe value for having a
4802 4817 cache at 20 values.
4803 4818
4804 4819 * IPython/iplib.py (InteractiveShell.user_setup): moved the
4805 4820 install_first_time function to a method, renamed it and added an
4806 4821 'upgrade' mode. Now people can update their config directory with
4807 4822 a simple command line switch (-upgrade, also new).
4808 4823
4809 4824 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
4810 4825 @file (convenient for automagic users under Python >= 2.2).
4811 4826 Removed @files (it seemed more like a plural than an abbrev. of
4812 4827 'file show').
4813 4828
4814 4829 * IPython/iplib.py (install_first_time): Fixed crash if there were
4815 4830 backup files ('~') in .ipython/ install directory.
4816 4831
4817 4832 * IPython/ipmaker.py (make_IPython): fixes for new prompt
4818 4833 system. Things look fine, but these changes are fairly
4819 4834 intrusive. Test them for a few days.
4820 4835
4821 4836 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
4822 4837 the prompts system. Now all in/out prompt strings are user
4823 4838 controllable. This is particularly useful for embedding, as one
4824 4839 can tag embedded instances with particular prompts.
4825 4840
4826 4841 Also removed global use of sys.ps1/2, which now allows nested
4827 4842 embeddings without any problems. Added command-line options for
4828 4843 the prompt strings.
4829 4844
4830 4845 2002-03-08 Fernando Perez <fperez@colorado.edu>
4831 4846
4832 4847 * IPython/UserConfig/example-embed-short.py (ipshell): added
4833 4848 example file with the bare minimum code for embedding.
4834 4849
4835 4850 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
4836 4851 functionality for the embeddable shell to be activated/deactivated
4837 4852 either globally or at each call.
4838 4853
4839 4854 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
4840 4855 rewriting the prompt with '--->' for auto-inputs with proper
4841 4856 coloring. Now the previous UGLY hack in handle_auto() is gone, and
4842 4857 this is handled by the prompts class itself, as it should.
4843 4858
4844 4859 2002-03-05 Fernando Perez <fperez@colorado.edu>
4845 4860
4846 4861 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
4847 4862 @logstart to avoid name clashes with the math log function.
4848 4863
4849 4864 * Big updates to X/Emacs section of the manual.
4850 4865
4851 4866 * Removed ipython_emacs. Milan explained to me how to pass
4852 4867 arguments to ipython through Emacs. Some day I'm going to end up
4853 4868 learning some lisp...
4854 4869
4855 4870 2002-03-04 Fernando Perez <fperez@colorado.edu>
4856 4871
4857 4872 * IPython/ipython_emacs: Created script to be used as the
4858 4873 py-python-command Emacs variable so we can pass IPython
4859 4874 parameters. I can't figure out how to tell Emacs directly to pass
4860 4875 parameters to IPython, so a dummy shell script will do it.
4861 4876
4862 4877 Other enhancements made for things to work better under Emacs'
4863 4878 various types of terminals. Many thanks to Milan Zamazal
4864 4879 <pdm-AT-zamazal.org> for all the suggestions and pointers.
4865 4880
4866 4881 2002-03-01 Fernando Perez <fperez@colorado.edu>
4867 4882
4868 4883 * IPython/ipmaker.py (make_IPython): added a --readline! option so
4869 4884 that loading of readline is now optional. This gives better
4870 4885 control to emacs users.
4871 4886
4872 4887 * IPython/ultraTB.py (__date__): Modified color escape sequences
4873 4888 and now things work fine under xterm and in Emacs' term buffers
4874 4889 (though not shell ones). Well, in emacs you get colors, but all
4875 4890 seem to be 'light' colors (no difference between dark and light
4876 4891 ones). But the garbage chars are gone, and also in xterms. It
4877 4892 seems that now I'm using 'cleaner' ansi sequences.
4878 4893
4879 4894 2002-02-21 Fernando Perez <fperez@colorado.edu>
4880 4895
4881 4896 * Released 0.2.7 (mainly to publish the scoping fix).
4882 4897
4883 4898 * IPython/Logger.py (Logger.logstate): added. A corresponding
4884 4899 @logstate magic was created.
4885 4900
4886 4901 * IPython/Magic.py: fixed nested scoping problem under Python
4887 4902 2.1.x (automagic wasn't working).
4888 4903
4889 4904 2002-02-20 Fernando Perez <fperez@colorado.edu>
4890 4905
4891 4906 * Released 0.2.6.
4892 4907
4893 4908 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
4894 4909 option so that logs can come out without any headers at all.
4895 4910
4896 4911 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
4897 4912 SciPy.
4898 4913
4899 4914 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
4900 4915 that embedded IPython calls don't require vars() to be explicitly
4901 4916 passed. Now they are extracted from the caller's frame (code
4902 4917 snatched from Eric Jones' weave). Added better documentation to
4903 4918 the section on embedding and the example file.
4904 4919
4905 4920 * IPython/genutils.py (page): Changed so that under emacs, it just
4906 4921 prints the string. You can then page up and down in the emacs
4907 4922 buffer itself. This is how the builtin help() works.
4908 4923
4909 4924 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
4910 4925 macro scoping: macros need to be executed in the user's namespace
4911 4926 to work as if they had been typed by the user.
4912 4927
4913 4928 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
4914 4929 execute automatically (no need to type 'exec...'). They then
4915 4930 behave like 'true macros'. The printing system was also modified
4916 4931 for this to work.
4917 4932
4918 4933 2002-02-19 Fernando Perez <fperez@colorado.edu>
4919 4934
4920 4935 * IPython/genutils.py (page_file): new function for paging files
4921 4936 in an OS-independent way. Also necessary for file viewing to work
4922 4937 well inside Emacs buffers.
4923 4938 (page): Added checks for being in an emacs buffer.
4924 4939 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
4925 4940 same bug in iplib.
4926 4941
4927 4942 2002-02-18 Fernando Perez <fperez@colorado.edu>
4928 4943
4929 4944 * IPython/iplib.py (InteractiveShell.init_readline): modified use
4930 4945 of readline so that IPython can work inside an Emacs buffer.
4931 4946
4932 4947 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
4933 4948 method signatures (they weren't really bugs, but it looks cleaner
4934 4949 and keeps PyChecker happy).
4935 4950
4936 4951 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
4937 4952 for implementing various user-defined hooks. Currently only
4938 4953 display is done.
4939 4954
4940 4955 * IPython/Prompts.py (CachedOutput._display): changed display
4941 4956 functions so that they can be dynamically changed by users easily.
4942 4957
4943 4958 * IPython/Extensions/numeric_formats.py (num_display): added an
4944 4959 extension for printing NumPy arrays in flexible manners. It
4945 4960 doesn't do anything yet, but all the structure is in
4946 4961 place. Ultimately the plan is to implement output format control
4947 4962 like in Octave.
4948 4963
4949 4964 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
4950 4965 methods are found at run-time by all the automatic machinery.
4951 4966
4952 4967 2002-02-17 Fernando Perez <fperez@colorado.edu>
4953 4968
4954 4969 * setup_Windows.py (make_shortcut): documented. Cleaned up the
4955 4970 whole file a little.
4956 4971
4957 4972 * ToDo: closed this document. Now there's a new_design.lyx
4958 4973 document for all new ideas. Added making a pdf of it for the
4959 4974 end-user distro.
4960 4975
4961 4976 * IPython/Logger.py (Logger.switch_log): Created this to replace
4962 4977 logon() and logoff(). It also fixes a nasty crash reported by
4963 4978 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
4964 4979
4965 4980 * IPython/iplib.py (complete): got auto-completion to work with
4966 4981 automagic (I had wanted this for a long time).
4967 4982
4968 4983 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
4969 4984 to @file, since file() is now a builtin and clashes with automagic
4970 4985 for @file.
4971 4986
4972 4987 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
4973 4988 of this was previously in iplib, which had grown to more than 2000
4974 4989 lines, way too long. No new functionality, but it makes managing
4975 4990 the code a bit easier.
4976 4991
4977 4992 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
4978 4993 information to crash reports.
4979 4994
4980 4995 2002-02-12 Fernando Perez <fperez@colorado.edu>
4981 4996
4982 4997 * Released 0.2.5.
4983 4998
4984 4999 2002-02-11 Fernando Perez <fperez@colorado.edu>
4985 5000
4986 5001 * Wrote a relatively complete Windows installer. It puts
4987 5002 everything in place, creates Start Menu entries and fixes the
4988 5003 color issues. Nothing fancy, but it works.
4989 5004
4990 5005 2002-02-10 Fernando Perez <fperez@colorado.edu>
4991 5006
4992 5007 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
4993 5008 os.path.expanduser() call so that we can type @run ~/myfile.py and
4994 5009 have thigs work as expected.
4995 5010
4996 5011 * IPython/genutils.py (page): fixed exception handling so things
4997 5012 work both in Unix and Windows correctly. Quitting a pager triggers
4998 5013 an IOError/broken pipe in Unix, and in windows not finding a pager
4999 5014 is also an IOError, so I had to actually look at the return value
5000 5015 of the exception, not just the exception itself. Should be ok now.
5001 5016
5002 5017 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
5003 5018 modified to allow case-insensitive color scheme changes.
5004 5019
5005 5020 2002-02-09 Fernando Perez <fperez@colorado.edu>
5006 5021
5007 5022 * IPython/genutils.py (native_line_ends): new function to leave
5008 5023 user config files with os-native line-endings.
5009 5024
5010 5025 * README and manual updates.
5011 5026
5012 5027 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
5013 5028 instead of StringType to catch Unicode strings.
5014 5029
5015 5030 * IPython/genutils.py (filefind): fixed bug for paths with
5016 5031 embedded spaces (very common in Windows).
5017 5032
5018 5033 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
5019 5034 files under Windows, so that they get automatically associated
5020 5035 with a text editor. Windows makes it a pain to handle
5021 5036 extension-less files.
5022 5037
5023 5038 * IPython/iplib.py (InteractiveShell.init_readline): Made the
5024 5039 warning about readline only occur for Posix. In Windows there's no
5025 5040 way to get readline, so why bother with the warning.
5026 5041
5027 5042 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
5028 5043 for __str__ instead of dir(self), since dir() changed in 2.2.
5029 5044
5030 5045 * Ported to Windows! Tested on XP, I suspect it should work fine
5031 5046 on NT/2000, but I don't think it will work on 98 et al. That
5032 5047 series of Windows is such a piece of junk anyway that I won't try
5033 5048 porting it there. The XP port was straightforward, showed a few
5034 5049 bugs here and there (fixed all), in particular some string
5035 5050 handling stuff which required considering Unicode strings (which
5036 5051 Windows uses). This is good, but hasn't been too tested :) No
5037 5052 fancy installer yet, I'll put a note in the manual so people at
5038 5053 least make manually a shortcut.
5039 5054
5040 5055 * IPython/iplib.py (Magic.magic_colors): Unified the color options
5041 5056 into a single one, "colors". This now controls both prompt and
5042 5057 exception color schemes, and can be changed both at startup
5043 5058 (either via command-line switches or via ipythonrc files) and at
5044 5059 runtime, with @colors.
5045 5060 (Magic.magic_run): renamed @prun to @run and removed the old
5046 5061 @run. The two were too similar to warrant keeping both.
5047 5062
5048 5063 2002-02-03 Fernando Perez <fperez@colorado.edu>
5049 5064
5050 5065 * IPython/iplib.py (install_first_time): Added comment on how to
5051 5066 configure the color options for first-time users. Put a <return>
5052 5067 request at the end so that small-terminal users get a chance to
5053 5068 read the startup info.
5054 5069
5055 5070 2002-01-23 Fernando Perez <fperez@colorado.edu>
5056 5071
5057 5072 * IPython/iplib.py (CachedOutput.update): Changed output memory
5058 5073 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
5059 5074 input history we still use _i. Did this b/c these variable are
5060 5075 very commonly used in interactive work, so the less we need to
5061 5076 type the better off we are.
5062 5077 (Magic.magic_prun): updated @prun to better handle the namespaces
5063 5078 the file will run in, including a fix for __name__ not being set
5064 5079 before.
5065 5080
5066 5081 2002-01-20 Fernando Perez <fperez@colorado.edu>
5067 5082
5068 5083 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
5069 5084 extra garbage for Python 2.2. Need to look more carefully into
5070 5085 this later.
5071 5086
5072 5087 2002-01-19 Fernando Perez <fperez@colorado.edu>
5073 5088
5074 5089 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
5075 5090 display SyntaxError exceptions properly formatted when they occur
5076 5091 (they can be triggered by imported code).
5077 5092
5078 5093 2002-01-18 Fernando Perez <fperez@colorado.edu>
5079 5094
5080 5095 * IPython/iplib.py (InteractiveShell.safe_execfile): now
5081 5096 SyntaxError exceptions are reported nicely formatted, instead of
5082 5097 spitting out only offset information as before.
5083 5098 (Magic.magic_prun): Added the @prun function for executing
5084 5099 programs with command line args inside IPython.
5085 5100
5086 5101 2002-01-16 Fernando Perez <fperez@colorado.edu>
5087 5102
5088 5103 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
5089 5104 to *not* include the last item given in a range. This brings their
5090 5105 behavior in line with Python's slicing:
5091 5106 a[n1:n2] -> a[n1]...a[n2-1]
5092 5107 It may be a bit less convenient, but I prefer to stick to Python's
5093 5108 conventions *everywhere*, so users never have to wonder.
5094 5109 (Magic.magic_macro): Added @macro function to ease the creation of
5095 5110 macros.
5096 5111
5097 5112 2002-01-05 Fernando Perez <fperez@colorado.edu>
5098 5113
5099 5114 * Released 0.2.4.
5100 5115
5101 5116 * IPython/iplib.py (Magic.magic_pdef):
5102 5117 (InteractiveShell.safe_execfile): report magic lines and error
5103 5118 lines without line numbers so one can easily copy/paste them for
5104 5119 re-execution.
5105 5120
5106 5121 * Updated manual with recent changes.
5107 5122
5108 5123 * IPython/iplib.py (Magic.magic_oinfo): added constructor
5109 5124 docstring printing when class? is called. Very handy for knowing
5110 5125 how to create class instances (as long as __init__ is well
5111 5126 documented, of course :)
5112 5127 (Magic.magic_doc): print both class and constructor docstrings.
5113 5128 (Magic.magic_pdef): give constructor info if passed a class and
5114 5129 __call__ info for callable object instances.
5115 5130
5116 5131 2002-01-04 Fernando Perez <fperez@colorado.edu>
5117 5132
5118 5133 * Made deep_reload() off by default. It doesn't always work
5119 5134 exactly as intended, so it's probably safer to have it off. It's
5120 5135 still available as dreload() anyway, so nothing is lost.
5121 5136
5122 5137 2002-01-02 Fernando Perez <fperez@colorado.edu>
5123 5138
5124 5139 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
5125 5140 so I wanted an updated release).
5126 5141
5127 5142 2001-12-27 Fernando Perez <fperez@colorado.edu>
5128 5143
5129 5144 * IPython/iplib.py (InteractiveShell.interact): Added the original
5130 5145 code from 'code.py' for this module in order to change the
5131 5146 handling of a KeyboardInterrupt. This was necessary b/c otherwise
5132 5147 the history cache would break when the user hit Ctrl-C, and
5133 5148 interact() offers no way to add any hooks to it.
5134 5149
5135 5150 2001-12-23 Fernando Perez <fperez@colorado.edu>
5136 5151
5137 5152 * setup.py: added check for 'MANIFEST' before trying to remove
5138 5153 it. Thanks to Sean Reifschneider.
5139 5154
5140 5155 2001-12-22 Fernando Perez <fperez@colorado.edu>
5141 5156
5142 5157 * Released 0.2.2.
5143 5158
5144 5159 * Finished (reasonably) writing the manual. Later will add the
5145 5160 python-standard navigation stylesheets, but for the time being
5146 5161 it's fairly complete. Distribution will include html and pdf
5147 5162 versions.
5148 5163
5149 5164 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
5150 5165 (MayaVi author).
5151 5166
5152 5167 2001-12-21 Fernando Perez <fperez@colorado.edu>
5153 5168
5154 5169 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
5155 5170 good public release, I think (with the manual and the distutils
5156 5171 installer). The manual can use some work, but that can go
5157 5172 slowly. Otherwise I think it's quite nice for end users. Next
5158 5173 summer, rewrite the guts of it...
5159 5174
5160 5175 * Changed format of ipythonrc files to use whitespace as the
5161 5176 separator instead of an explicit '='. Cleaner.
5162 5177
5163 5178 2001-12-20 Fernando Perez <fperez@colorado.edu>
5164 5179
5165 5180 * Started a manual in LyX. For now it's just a quick merge of the
5166 5181 various internal docstrings and READMEs. Later it may grow into a
5167 5182 nice, full-blown manual.
5168 5183
5169 5184 * Set up a distutils based installer. Installation should now be
5170 5185 trivially simple for end-users.
5171 5186
5172 5187 2001-12-11 Fernando Perez <fperez@colorado.edu>
5173 5188
5174 5189 * Released 0.2.0. First public release, announced it at
5175 5190 comp.lang.python. From now on, just bugfixes...
5176 5191
5177 5192 * Went through all the files, set copyright/license notices and
5178 5193 cleaned up things. Ready for release.
5179 5194
5180 5195 2001-12-10 Fernando Perez <fperez@colorado.edu>
5181 5196
5182 5197 * Changed the first-time installer not to use tarfiles. It's more
5183 5198 robust now and less unix-dependent. Also makes it easier for
5184 5199 people to later upgrade versions.
5185 5200
5186 5201 * Changed @exit to @abort to reflect the fact that it's pretty
5187 5202 brutal (a sys.exit()). The difference between @abort and Ctrl-D
5188 5203 becomes significant only when IPyhton is embedded: in that case,
5189 5204 C-D closes IPython only, but @abort kills the enclosing program
5190 5205 too (unless it had called IPython inside a try catching
5191 5206 SystemExit).
5192 5207
5193 5208 * Created Shell module which exposes the actuall IPython Shell
5194 5209 classes, currently the normal and the embeddable one. This at
5195 5210 least offers a stable interface we won't need to change when
5196 5211 (later) the internals are rewritten. That rewrite will be confined
5197 5212 to iplib and ipmaker, but the Shell interface should remain as is.
5198 5213
5199 5214 * Added embed module which offers an embeddable IPShell object,
5200 5215 useful to fire up IPython *inside* a running program. Great for
5201 5216 debugging or dynamical data analysis.
5202 5217
5203 5218 2001-12-08 Fernando Perez <fperez@colorado.edu>
5204 5219
5205 5220 * Fixed small bug preventing seeing info from methods of defined
5206 5221 objects (incorrect namespace in _ofind()).
5207 5222
5208 5223 * Documentation cleanup. Moved the main usage docstrings to a
5209 5224 separate file, usage.py (cleaner to maintain, and hopefully in the
5210 5225 future some perlpod-like way of producing interactive, man and
5211 5226 html docs out of it will be found).
5212 5227
5213 5228 * Added @profile to see your profile at any time.
5214 5229
5215 5230 * Added @p as an alias for 'print'. It's especially convenient if
5216 5231 using automagic ('p x' prints x).
5217 5232
5218 5233 * Small cleanups and fixes after a pychecker run.
5219 5234
5220 5235 * Changed the @cd command to handle @cd - and @cd -<n> for
5221 5236 visiting any directory in _dh.
5222 5237
5223 5238 * Introduced _dh, a history of visited directories. @dhist prints
5224 5239 it out with numbers.
5225 5240
5226 5241 2001-12-07 Fernando Perez <fperez@colorado.edu>
5227 5242
5228 5243 * Released 0.1.22
5229 5244
5230 5245 * Made initialization a bit more robust against invalid color
5231 5246 options in user input (exit, not traceback-crash).
5232 5247
5233 5248 * Changed the bug crash reporter to write the report only in the
5234 5249 user's .ipython directory. That way IPython won't litter people's
5235 5250 hard disks with crash files all over the place. Also print on
5236 5251 screen the necessary mail command.
5237 5252
5238 5253 * With the new ultraTB, implemented LightBG color scheme for light
5239 5254 background terminals. A lot of people like white backgrounds, so I
5240 5255 guess we should at least give them something readable.
5241 5256
5242 5257 2001-12-06 Fernando Perez <fperez@colorado.edu>
5243 5258
5244 5259 * Modified the structure of ultraTB. Now there's a proper class
5245 5260 for tables of color schemes which allow adding schemes easily and
5246 5261 switching the active scheme without creating a new instance every
5247 5262 time (which was ridiculous). The syntax for creating new schemes
5248 5263 is also cleaner. I think ultraTB is finally done, with a clean
5249 5264 class structure. Names are also much cleaner (now there's proper
5250 5265 color tables, no need for every variable to also have 'color' in
5251 5266 its name).
5252 5267
5253 5268 * Broke down genutils into separate files. Now genutils only
5254 5269 contains utility functions, and classes have been moved to their
5255 5270 own files (they had enough independent functionality to warrant
5256 5271 it): ConfigLoader, OutputTrap, Struct.
5257 5272
5258 5273 2001-12-05 Fernando Perez <fperez@colorado.edu>
5259 5274
5260 5275 * IPython turns 21! Released version 0.1.21, as a candidate for
5261 5276 public consumption. If all goes well, release in a few days.
5262 5277
5263 5278 * Fixed path bug (files in Extensions/ directory wouldn't be found
5264 5279 unless IPython/ was explicitly in sys.path).
5265 5280
5266 5281 * Extended the FlexCompleter class as MagicCompleter to allow
5267 5282 completion of @-starting lines.
5268 5283
5269 5284 * Created __release__.py file as a central repository for release
5270 5285 info that other files can read from.
5271 5286
5272 5287 * Fixed small bug in logging: when logging was turned on in
5273 5288 mid-session, old lines with special meanings (!@?) were being
5274 5289 logged without the prepended comment, which is necessary since
5275 5290 they are not truly valid python syntax. This should make session
5276 5291 restores produce less errors.
5277 5292
5278 5293 * The namespace cleanup forced me to make a FlexCompleter class
5279 5294 which is nothing but a ripoff of rlcompleter, but with selectable
5280 5295 namespace (rlcompleter only works in __main__.__dict__). I'll try
5281 5296 to submit a note to the authors to see if this change can be
5282 5297 incorporated in future rlcompleter releases (Dec.6: done)
5283 5298
5284 5299 * More fixes to namespace handling. It was a mess! Now all
5285 5300 explicit references to __main__.__dict__ are gone (except when
5286 5301 really needed) and everything is handled through the namespace
5287 5302 dicts in the IPython instance. We seem to be getting somewhere
5288 5303 with this, finally...
5289 5304
5290 5305 * Small documentation updates.
5291 5306
5292 5307 * Created the Extensions directory under IPython (with an
5293 5308 __init__.py). Put the PhysicalQ stuff there. This directory should
5294 5309 be used for all special-purpose extensions.
5295 5310
5296 5311 * File renaming:
5297 5312 ipythonlib --> ipmaker
5298 5313 ipplib --> iplib
5299 5314 This makes a bit more sense in terms of what these files actually do.
5300 5315
5301 5316 * Moved all the classes and functions in ipythonlib to ipplib, so
5302 5317 now ipythonlib only has make_IPython(). This will ease up its
5303 5318 splitting in smaller functional chunks later.
5304 5319
5305 5320 * Cleaned up (done, I think) output of @whos. Better column
5306 5321 formatting, and now shows str(var) for as much as it can, which is
5307 5322 typically what one gets with a 'print var'.
5308 5323
5309 5324 2001-12-04 Fernando Perez <fperez@colorado.edu>
5310 5325
5311 5326 * Fixed namespace problems. Now builtin/IPyhton/user names get
5312 5327 properly reported in their namespace. Internal namespace handling
5313 5328 is finally getting decent (not perfect yet, but much better than
5314 5329 the ad-hoc mess we had).
5315 5330
5316 5331 * Removed -exit option. If people just want to run a python
5317 5332 script, that's what the normal interpreter is for. Less
5318 5333 unnecessary options, less chances for bugs.
5319 5334
5320 5335 * Added a crash handler which generates a complete post-mortem if
5321 5336 IPython crashes. This will help a lot in tracking bugs down the
5322 5337 road.
5323 5338
5324 5339 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
5325 5340 which were boud to functions being reassigned would bypass the
5326 5341 logger, breaking the sync of _il with the prompt counter. This
5327 5342 would then crash IPython later when a new line was logged.
5328 5343
5329 5344 2001-12-02 Fernando Perez <fperez@colorado.edu>
5330 5345
5331 5346 * Made IPython a package. This means people don't have to clutter
5332 5347 their sys.path with yet another directory. Changed the INSTALL
5333 5348 file accordingly.
5334 5349
5335 5350 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
5336 5351 sorts its output (so @who shows it sorted) and @whos formats the
5337 5352 table according to the width of the first column. Nicer, easier to
5338 5353 read. Todo: write a generic table_format() which takes a list of
5339 5354 lists and prints it nicely formatted, with optional row/column
5340 5355 separators and proper padding and justification.
5341 5356
5342 5357 * Released 0.1.20
5343 5358
5344 5359 * Fixed bug in @log which would reverse the inputcache list (a
5345 5360 copy operation was missing).
5346 5361
5347 5362 * Code cleanup. @config was changed to use page(). Better, since
5348 5363 its output is always quite long.
5349 5364
5350 5365 * Itpl is back as a dependency. I was having too many problems
5351 5366 getting the parametric aliases to work reliably, and it's just
5352 5367 easier to code weird string operations with it than playing %()s
5353 5368 games. It's only ~6k, so I don't think it's too big a deal.
5354 5369
5355 5370 * Found (and fixed) a very nasty bug with history. !lines weren't
5356 5371 getting cached, and the out of sync caches would crash
5357 5372 IPython. Fixed it by reorganizing the prefilter/handlers/logger
5358 5373 division of labor a bit better. Bug fixed, cleaner structure.
5359 5374
5360 5375 2001-12-01 Fernando Perez <fperez@colorado.edu>
5361 5376
5362 5377 * Released 0.1.19
5363 5378
5364 5379 * Added option -n to @hist to prevent line number printing. Much
5365 5380 easier to copy/paste code this way.
5366 5381
5367 5382 * Created global _il to hold the input list. Allows easy
5368 5383 re-execution of blocks of code by slicing it (inspired by Janko's
5369 5384 comment on 'macros').
5370 5385
5371 5386 * Small fixes and doc updates.
5372 5387
5373 5388 * Rewrote @history function (was @h). Renamed it to @hist, @h is
5374 5389 much too fragile with automagic. Handles properly multi-line
5375 5390 statements and takes parameters.
5376 5391
5377 5392 2001-11-30 Fernando Perez <fperez@colorado.edu>
5378 5393
5379 5394 * Version 0.1.18 released.
5380 5395
5381 5396 * Fixed nasty namespace bug in initial module imports.
5382 5397
5383 5398 * Added copyright/license notes to all code files (except
5384 5399 DPyGetOpt). For the time being, LGPL. That could change.
5385 5400
5386 5401 * Rewrote a much nicer README, updated INSTALL, cleaned up
5387 5402 ipythonrc-* samples.
5388 5403
5389 5404 * Overall code/documentation cleanup. Basically ready for
5390 5405 release. Only remaining thing: licence decision (LGPL?).
5391 5406
5392 5407 * Converted load_config to a class, ConfigLoader. Now recursion
5393 5408 control is better organized. Doesn't include the same file twice.
5394 5409
5395 5410 2001-11-29 Fernando Perez <fperez@colorado.edu>
5396 5411
5397 5412 * Got input history working. Changed output history variables from
5398 5413 _p to _o so that _i is for input and _o for output. Just cleaner
5399 5414 convention.
5400 5415
5401 5416 * Implemented parametric aliases. This pretty much allows the
5402 5417 alias system to offer full-blown shell convenience, I think.
5403 5418
5404 5419 * Version 0.1.17 released, 0.1.18 opened.
5405 5420
5406 5421 * dot_ipython/ipythonrc (alias): added documentation.
5407 5422 (xcolor): Fixed small bug (xcolors -> xcolor)
5408 5423
5409 5424 * Changed the alias system. Now alias is a magic command to define
5410 5425 aliases just like the shell. Rationale: the builtin magics should
5411 5426 be there for things deeply connected to IPython's
5412 5427 architecture. And this is a much lighter system for what I think
5413 5428 is the really important feature: allowing users to define quickly
5414 5429 magics that will do shell things for them, so they can customize
5415 5430 IPython easily to match their work habits. If someone is really
5416 5431 desperate to have another name for a builtin alias, they can
5417 5432 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
5418 5433 works.
5419 5434
5420 5435 2001-11-28 Fernando Perez <fperez@colorado.edu>
5421 5436
5422 5437 * Changed @file so that it opens the source file at the proper
5423 5438 line. Since it uses less, if your EDITOR environment is
5424 5439 configured, typing v will immediately open your editor of choice
5425 5440 right at the line where the object is defined. Not as quick as
5426 5441 having a direct @edit command, but for all intents and purposes it
5427 5442 works. And I don't have to worry about writing @edit to deal with
5428 5443 all the editors, less does that.
5429 5444
5430 5445 * Version 0.1.16 released, 0.1.17 opened.
5431 5446
5432 5447 * Fixed some nasty bugs in the page/page_dumb combo that could
5433 5448 crash IPython.
5434 5449
5435 5450 2001-11-27 Fernando Perez <fperez@colorado.edu>
5436 5451
5437 5452 * Version 0.1.15 released, 0.1.16 opened.
5438 5453
5439 5454 * Finally got ? and ?? to work for undefined things: now it's
5440 5455 possible to type {}.get? and get information about the get method
5441 5456 of dicts, or os.path? even if only os is defined (so technically
5442 5457 os.path isn't). Works at any level. For example, after import os,
5443 5458 os?, os.path?, os.path.abspath? all work. This is great, took some
5444 5459 work in _ofind.
5445 5460
5446 5461 * Fixed more bugs with logging. The sanest way to do it was to add
5447 5462 to @log a 'mode' parameter. Killed two in one shot (this mode
5448 5463 option was a request of Janko's). I think it's finally clean
5449 5464 (famous last words).
5450 5465
5451 5466 * Added a page_dumb() pager which does a decent job of paging on
5452 5467 screen, if better things (like less) aren't available. One less
5453 5468 unix dependency (someday maybe somebody will port this to
5454 5469 windows).
5455 5470
5456 5471 * Fixed problem in magic_log: would lock of logging out if log
5457 5472 creation failed (because it would still think it had succeeded).
5458 5473
5459 5474 * Improved the page() function using curses to auto-detect screen
5460 5475 size. Now it can make a much better decision on whether to print
5461 5476 or page a string. Option screen_length was modified: a value 0
5462 5477 means auto-detect, and that's the default now.
5463 5478
5464 5479 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
5465 5480 go out. I'll test it for a few days, then talk to Janko about
5466 5481 licences and announce it.
5467 5482
5468 5483 * Fixed the length of the auto-generated ---> prompt which appears
5469 5484 for auto-parens and auto-quotes. Getting this right isn't trivial,
5470 5485 with all the color escapes, different prompt types and optional
5471 5486 separators. But it seems to be working in all the combinations.
5472 5487
5473 5488 2001-11-26 Fernando Perez <fperez@colorado.edu>
5474 5489
5475 5490 * Wrote a regexp filter to get option types from the option names
5476 5491 string. This eliminates the need to manually keep two duplicate
5477 5492 lists.
5478 5493
5479 5494 * Removed the unneeded check_option_names. Now options are handled
5480 5495 in a much saner manner and it's easy to visually check that things
5481 5496 are ok.
5482 5497
5483 5498 * Updated version numbers on all files I modified to carry a
5484 5499 notice so Janko and Nathan have clear version markers.
5485 5500
5486 5501 * Updated docstring for ultraTB with my changes. I should send
5487 5502 this to Nathan.
5488 5503
5489 5504 * Lots of small fixes. Ran everything through pychecker again.
5490 5505
5491 5506 * Made loading of deep_reload an cmd line option. If it's not too
5492 5507 kosher, now people can just disable it. With -nodeep_reload it's
5493 5508 still available as dreload(), it just won't overwrite reload().
5494 5509
5495 5510 * Moved many options to the no| form (-opt and -noopt
5496 5511 accepted). Cleaner.
5497 5512
5498 5513 * Changed magic_log so that if called with no parameters, it uses
5499 5514 'rotate' mode. That way auto-generated logs aren't automatically
5500 5515 over-written. For normal logs, now a backup is made if it exists
5501 5516 (only 1 level of backups). A new 'backup' mode was added to the
5502 5517 Logger class to support this. This was a request by Janko.
5503 5518
5504 5519 * Added @logoff/@logon to stop/restart an active log.
5505 5520
5506 5521 * Fixed a lot of bugs in log saving/replay. It was pretty
5507 5522 broken. Now special lines (!@,/) appear properly in the command
5508 5523 history after a log replay.
5509 5524
5510 5525 * Tried and failed to implement full session saving via pickle. My
5511 5526 idea was to pickle __main__.__dict__, but modules can't be
5512 5527 pickled. This would be a better alternative to replaying logs, but
5513 5528 seems quite tricky to get to work. Changed -session to be called
5514 5529 -logplay, which more accurately reflects what it does. And if we
5515 5530 ever get real session saving working, -session is now available.
5516 5531
5517 5532 * Implemented color schemes for prompts also. As for tracebacks,
5518 5533 currently only NoColor and Linux are supported. But now the
5519 5534 infrastructure is in place, based on a generic ColorScheme
5520 5535 class. So writing and activating new schemes both for the prompts
5521 5536 and the tracebacks should be straightforward.
5522 5537
5523 5538 * Version 0.1.13 released, 0.1.14 opened.
5524 5539
5525 5540 * Changed handling of options for output cache. Now counter is
5526 5541 hardwired starting at 1 and one specifies the maximum number of
5527 5542 entries *in the outcache* (not the max prompt counter). This is
5528 5543 much better, since many statements won't increase the cache
5529 5544 count. It also eliminated some confusing options, now there's only
5530 5545 one: cache_size.
5531 5546
5532 5547 * Added 'alias' magic function and magic_alias option in the
5533 5548 ipythonrc file. Now the user can easily define whatever names he
5534 5549 wants for the magic functions without having to play weird
5535 5550 namespace games. This gives IPython a real shell-like feel.
5536 5551
5537 5552 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
5538 5553 @ or not).
5539 5554
5540 5555 This was one of the last remaining 'visible' bugs (that I know
5541 5556 of). I think if I can clean up the session loading so it works
5542 5557 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
5543 5558 about licensing).
5544 5559
5545 5560 2001-11-25 Fernando Perez <fperez@colorado.edu>
5546 5561
5547 5562 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
5548 5563 there's a cleaner distinction between what ? and ?? show.
5549 5564
5550 5565 * Added screen_length option. Now the user can define his own
5551 5566 screen size for page() operations.
5552 5567
5553 5568 * Implemented magic shell-like functions with automatic code
5554 5569 generation. Now adding another function is just a matter of adding
5555 5570 an entry to a dict, and the function is dynamically generated at
5556 5571 run-time. Python has some really cool features!
5557 5572
5558 5573 * Renamed many options to cleanup conventions a little. Now all
5559 5574 are lowercase, and only underscores where needed. Also in the code
5560 5575 option name tables are clearer.
5561 5576
5562 5577 * Changed prompts a little. Now input is 'In [n]:' instead of
5563 5578 'In[n]:='. This allows it the numbers to be aligned with the
5564 5579 Out[n] numbers, and removes usage of ':=' which doesn't exist in
5565 5580 Python (it was a Mathematica thing). The '...' continuation prompt
5566 5581 was also changed a little to align better.
5567 5582
5568 5583 * Fixed bug when flushing output cache. Not all _p<n> variables
5569 5584 exist, so their deletion needs to be wrapped in a try:
5570 5585
5571 5586 * Figured out how to properly use inspect.formatargspec() (it
5572 5587 requires the args preceded by *). So I removed all the code from
5573 5588 _get_pdef in Magic, which was just replicating that.
5574 5589
5575 5590 * Added test to prefilter to allow redefining magic function names
5576 5591 as variables. This is ok, since the @ form is always available,
5577 5592 but whe should allow the user to define a variable called 'ls' if
5578 5593 he needs it.
5579 5594
5580 5595 * Moved the ToDo information from README into a separate ToDo.
5581 5596
5582 5597 * General code cleanup and small bugfixes. I think it's close to a
5583 5598 state where it can be released, obviously with a big 'beta'
5584 5599 warning on it.
5585 5600
5586 5601 * Got the magic function split to work. Now all magics are defined
5587 5602 in a separate class. It just organizes things a bit, and now
5588 5603 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
5589 5604 was too long).
5590 5605
5591 5606 * Changed @clear to @reset to avoid potential confusions with
5592 5607 the shell command clear. Also renamed @cl to @clear, which does
5593 5608 exactly what people expect it to from their shell experience.
5594 5609
5595 5610 Added a check to the @reset command (since it's so
5596 5611 destructive, it's probably a good idea to ask for confirmation).
5597 5612 But now reset only works for full namespace resetting. Since the
5598 5613 del keyword is already there for deleting a few specific
5599 5614 variables, I don't see the point of having a redundant magic
5600 5615 function for the same task.
5601 5616
5602 5617 2001-11-24 Fernando Perez <fperez@colorado.edu>
5603 5618
5604 5619 * Updated the builtin docs (esp. the ? ones).
5605 5620
5606 5621 * Ran all the code through pychecker. Not terribly impressed with
5607 5622 it: lots of spurious warnings and didn't really find anything of
5608 5623 substance (just a few modules being imported and not used).
5609 5624
5610 5625 * Implemented the new ultraTB functionality into IPython. New
5611 5626 option: xcolors. This chooses color scheme. xmode now only selects
5612 5627 between Plain and Verbose. Better orthogonality.
5613 5628
5614 5629 * Large rewrite of ultraTB. Much cleaner now, with a separation of
5615 5630 mode and color scheme for the exception handlers. Now it's
5616 5631 possible to have the verbose traceback with no coloring.
5617 5632
5618 5633 2001-11-23 Fernando Perez <fperez@colorado.edu>
5619 5634
5620 5635 * Version 0.1.12 released, 0.1.13 opened.
5621 5636
5622 5637 * Removed option to set auto-quote and auto-paren escapes by
5623 5638 user. The chances of breaking valid syntax are just too high. If
5624 5639 someone *really* wants, they can always dig into the code.
5625 5640
5626 5641 * Made prompt separators configurable.
5627 5642
5628 5643 2001-11-22 Fernando Perez <fperez@colorado.edu>
5629 5644
5630 5645 * Small bugfixes in many places.
5631 5646
5632 5647 * Removed the MyCompleter class from ipplib. It seemed redundant
5633 5648 with the C-p,C-n history search functionality. Less code to
5634 5649 maintain.
5635 5650
5636 5651 * Moved all the original ipython.py code into ipythonlib.py. Right
5637 5652 now it's just one big dump into a function called make_IPython, so
5638 5653 no real modularity has been gained. But at least it makes the
5639 5654 wrapper script tiny, and since ipythonlib is a module, it gets
5640 5655 compiled and startup is much faster.
5641 5656
5642 5657 This is a reasobably 'deep' change, so we should test it for a
5643 5658 while without messing too much more with the code.
5644 5659
5645 5660 2001-11-21 Fernando Perez <fperez@colorado.edu>
5646 5661
5647 5662 * Version 0.1.11 released, 0.1.12 opened for further work.
5648 5663
5649 5664 * Removed dependency on Itpl. It was only needed in one place. It
5650 5665 would be nice if this became part of python, though. It makes life
5651 5666 *a lot* easier in some cases.
5652 5667
5653 5668 * Simplified the prefilter code a bit. Now all handlers are
5654 5669 expected to explicitly return a value (at least a blank string).
5655 5670
5656 5671 * Heavy edits in ipplib. Removed the help system altogether. Now
5657 5672 obj?/?? is used for inspecting objects, a magic @doc prints
5658 5673 docstrings, and full-blown Python help is accessed via the 'help'
5659 5674 keyword. This cleans up a lot of code (less to maintain) and does
5660 5675 the job. Since 'help' is now a standard Python component, might as
5661 5676 well use it and remove duplicate functionality.
5662 5677
5663 5678 Also removed the option to use ipplib as a standalone program. By
5664 5679 now it's too dependent on other parts of IPython to function alone.
5665 5680
5666 5681 * Fixed bug in genutils.pager. It would crash if the pager was
5667 5682 exited immediately after opening (broken pipe).
5668 5683
5669 5684 * Trimmed down the VerboseTB reporting a little. The header is
5670 5685 much shorter now and the repeated exception arguments at the end
5671 5686 have been removed. For interactive use the old header seemed a bit
5672 5687 excessive.
5673 5688
5674 5689 * Fixed small bug in output of @whos for variables with multi-word
5675 5690 types (only first word was displayed).
5676 5691
5677 5692 2001-11-17 Fernando Perez <fperez@colorado.edu>
5678 5693
5679 5694 * Version 0.1.10 released, 0.1.11 opened for further work.
5680 5695
5681 5696 * Modified dirs and friends. dirs now *returns* the stack (not
5682 5697 prints), so one can manipulate it as a variable. Convenient to
5683 5698 travel along many directories.
5684 5699
5685 5700 * Fixed bug in magic_pdef: would only work with functions with
5686 5701 arguments with default values.
5687 5702
5688 5703 2001-11-14 Fernando Perez <fperez@colorado.edu>
5689 5704
5690 5705 * Added the PhysicsInput stuff to dot_ipython so it ships as an
5691 5706 example with IPython. Various other minor fixes and cleanups.
5692 5707
5693 5708 * Version 0.1.9 released, 0.1.10 opened for further work.
5694 5709
5695 5710 * Added sys.path to the list of directories searched in the
5696 5711 execfile= option. It used to be the current directory and the
5697 5712 user's IPYTHONDIR only.
5698 5713
5699 5714 2001-11-13 Fernando Perez <fperez@colorado.edu>
5700 5715
5701 5716 * Reinstated the raw_input/prefilter separation that Janko had
5702 5717 initially. This gives a more convenient setup for extending the
5703 5718 pre-processor from the outside: raw_input always gets a string,
5704 5719 and prefilter has to process it. We can then redefine prefilter
5705 5720 from the outside and implement extensions for special
5706 5721 purposes.
5707 5722
5708 5723 Today I got one for inputting PhysicalQuantity objects
5709 5724 (from Scientific) without needing any function calls at
5710 5725 all. Extremely convenient, and it's all done as a user-level
5711 5726 extension (no IPython code was touched). Now instead of:
5712 5727 a = PhysicalQuantity(4.2,'m/s**2')
5713 5728 one can simply say
5714 5729 a = 4.2 m/s**2
5715 5730 or even
5716 5731 a = 4.2 m/s^2
5717 5732
5718 5733 I use this, but it's also a proof of concept: IPython really is
5719 5734 fully user-extensible, even at the level of the parsing of the
5720 5735 command line. It's not trivial, but it's perfectly doable.
5721 5736
5722 5737 * Added 'add_flip' method to inclusion conflict resolver. Fixes
5723 5738 the problem of modules being loaded in the inverse order in which
5724 5739 they were defined in
5725 5740
5726 5741 * Version 0.1.8 released, 0.1.9 opened for further work.
5727 5742
5728 5743 * Added magics pdef, source and file. They respectively show the
5729 5744 definition line ('prototype' in C), source code and full python
5730 5745 file for any callable object. The object inspector oinfo uses
5731 5746 these to show the same information.
5732 5747
5733 5748 * Version 0.1.7 released, 0.1.8 opened for further work.
5734 5749
5735 5750 * Separated all the magic functions into a class called Magic. The
5736 5751 InteractiveShell class was becoming too big for Xemacs to handle
5737 5752 (de-indenting a line would lock it up for 10 seconds while it
5738 5753 backtracked on the whole class!)
5739 5754
5740 5755 FIXME: didn't work. It can be done, but right now namespaces are
5741 5756 all messed up. Do it later (reverted it for now, so at least
5742 5757 everything works as before).
5743 5758
5744 5759 * Got the object introspection system (magic_oinfo) working! I
5745 5760 think this is pretty much ready for release to Janko, so he can
5746 5761 test it for a while and then announce it. Pretty much 100% of what
5747 5762 I wanted for the 'phase 1' release is ready. Happy, tired.
5748 5763
5749 5764 2001-11-12 Fernando Perez <fperez@colorado.edu>
5750 5765
5751 5766 * Version 0.1.6 released, 0.1.7 opened for further work.
5752 5767
5753 5768 * Fixed bug in printing: it used to test for truth before
5754 5769 printing, so 0 wouldn't print. Now checks for None.
5755 5770
5756 5771 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
5757 5772 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
5758 5773 reaches by hand into the outputcache. Think of a better way to do
5759 5774 this later.
5760 5775
5761 5776 * Various small fixes thanks to Nathan's comments.
5762 5777
5763 5778 * Changed magic_pprint to magic_Pprint. This way it doesn't
5764 5779 collide with pprint() and the name is consistent with the command
5765 5780 line option.
5766 5781
5767 5782 * Changed prompt counter behavior to be fully like
5768 5783 Mathematica's. That is, even input that doesn't return a result
5769 5784 raises the prompt counter. The old behavior was kind of confusing
5770 5785 (getting the same prompt number several times if the operation
5771 5786 didn't return a result).
5772 5787
5773 5788 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
5774 5789
5775 5790 * Fixed -Classic mode (wasn't working anymore).
5776 5791
5777 5792 * Added colored prompts using Nathan's new code. Colors are
5778 5793 currently hardwired, they can be user-configurable. For
5779 5794 developers, they can be chosen in file ipythonlib.py, at the
5780 5795 beginning of the CachedOutput class def.
5781 5796
5782 5797 2001-11-11 Fernando Perez <fperez@colorado.edu>
5783 5798
5784 5799 * Version 0.1.5 released, 0.1.6 opened for further work.
5785 5800
5786 5801 * Changed magic_env to *return* the environment as a dict (not to
5787 5802 print it). This way it prints, but it can also be processed.
5788 5803
5789 5804 * Added Verbose exception reporting to interactive
5790 5805 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
5791 5806 traceback. Had to make some changes to the ultraTB file. This is
5792 5807 probably the last 'big' thing in my mental todo list. This ties
5793 5808 in with the next entry:
5794 5809
5795 5810 * Changed -Xi and -Xf to a single -xmode option. Now all the user
5796 5811 has to specify is Plain, Color or Verbose for all exception
5797 5812 handling.
5798 5813
5799 5814 * Removed ShellServices option. All this can really be done via
5800 5815 the magic system. It's easier to extend, cleaner and has automatic
5801 5816 namespace protection and documentation.
5802 5817
5803 5818 2001-11-09 Fernando Perez <fperez@colorado.edu>
5804 5819
5805 5820 * Fixed bug in output cache flushing (missing parameter to
5806 5821 __init__). Other small bugs fixed (found using pychecker).
5807 5822
5808 5823 * Version 0.1.4 opened for bugfixing.
5809 5824
5810 5825 2001-11-07 Fernando Perez <fperez@colorado.edu>
5811 5826
5812 5827 * Version 0.1.3 released, mainly because of the raw_input bug.
5813 5828
5814 5829 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
5815 5830 and when testing for whether things were callable, a call could
5816 5831 actually be made to certain functions. They would get called again
5817 5832 once 'really' executed, with a resulting double call. A disaster
5818 5833 in many cases (list.reverse() would never work!).
5819 5834
5820 5835 * Removed prefilter() function, moved its code to raw_input (which
5821 5836 after all was just a near-empty caller for prefilter). This saves
5822 5837 a function call on every prompt, and simplifies the class a tiny bit.
5823 5838
5824 5839 * Fix _ip to __ip name in magic example file.
5825 5840
5826 5841 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
5827 5842 work with non-gnu versions of tar.
5828 5843
5829 5844 2001-11-06 Fernando Perez <fperez@colorado.edu>
5830 5845
5831 5846 * Version 0.1.2. Just to keep track of the recent changes.
5832 5847
5833 5848 * Fixed nasty bug in output prompt routine. It used to check 'if
5834 5849 arg != None...'. Problem is, this fails if arg implements a
5835 5850 special comparison (__cmp__) which disallows comparing to
5836 5851 None. Found it when trying to use the PhysicalQuantity module from
5837 5852 ScientificPython.
5838 5853
5839 5854 2001-11-05 Fernando Perez <fperez@colorado.edu>
5840 5855
5841 5856 * Also added dirs. Now the pushd/popd/dirs family functions
5842 5857 basically like the shell, with the added convenience of going home
5843 5858 when called with no args.
5844 5859
5845 5860 * pushd/popd slightly modified to mimic shell behavior more
5846 5861 closely.
5847 5862
5848 5863 * Added env,pushd,popd from ShellServices as magic functions. I
5849 5864 think the cleanest will be to port all desired functions from
5850 5865 ShellServices as magics and remove ShellServices altogether. This
5851 5866 will provide a single, clean way of adding functionality
5852 5867 (shell-type or otherwise) to IP.
5853 5868
5854 5869 2001-11-04 Fernando Perez <fperez@colorado.edu>
5855 5870
5856 5871 * Added .ipython/ directory to sys.path. This way users can keep
5857 5872 customizations there and access them via import.
5858 5873
5859 5874 2001-11-03 Fernando Perez <fperez@colorado.edu>
5860 5875
5861 5876 * Opened version 0.1.1 for new changes.
5862 5877
5863 5878 * Changed version number to 0.1.0: first 'public' release, sent to
5864 5879 Nathan and Janko.
5865 5880
5866 5881 * Lots of small fixes and tweaks.
5867 5882
5868 5883 * Minor changes to whos format. Now strings are shown, snipped if
5869 5884 too long.
5870 5885
5871 5886 * Changed ShellServices to work on __main__ so they show up in @who
5872 5887
5873 5888 * Help also works with ? at the end of a line:
5874 5889 ?sin and sin?
5875 5890 both produce the same effect. This is nice, as often I use the
5876 5891 tab-complete to find the name of a method, but I used to then have
5877 5892 to go to the beginning of the line to put a ? if I wanted more
5878 5893 info. Now I can just add the ? and hit return. Convenient.
5879 5894
5880 5895 2001-11-02 Fernando Perez <fperez@colorado.edu>
5881 5896
5882 5897 * Python version check (>=2.1) added.
5883 5898
5884 5899 * Added LazyPython documentation. At this point the docs are quite
5885 5900 a mess. A cleanup is in order.
5886 5901
5887 5902 * Auto-installer created. For some bizarre reason, the zipfiles
5888 5903 module isn't working on my system. So I made a tar version
5889 5904 (hopefully the command line options in various systems won't kill
5890 5905 me).
5891 5906
5892 5907 * Fixes to Struct in genutils. Now all dictionary-like methods are
5893 5908 protected (reasonably).
5894 5909
5895 5910 * Added pager function to genutils and changed ? to print usage
5896 5911 note through it (it was too long).
5897 5912
5898 5913 * Added the LazyPython functionality. Works great! I changed the
5899 5914 auto-quote escape to ';', it's on home row and next to '. But
5900 5915 both auto-quote and auto-paren (still /) escapes are command-line
5901 5916 parameters.
5902 5917
5903 5918
5904 5919 2001-11-01 Fernando Perez <fperez@colorado.edu>
5905 5920
5906 5921 * Version changed to 0.0.7. Fairly large change: configuration now
5907 5922 is all stored in a directory, by default .ipython. There, all
5908 5923 config files have normal looking names (not .names)
5909 5924
5910 5925 * Version 0.0.6 Released first to Lucas and Archie as a test
5911 5926 run. Since it's the first 'semi-public' release, change version to
5912 5927 > 0.0.6 for any changes now.
5913 5928
5914 5929 * Stuff I had put in the ipplib.py changelog:
5915 5930
5916 5931 Changes to InteractiveShell:
5917 5932
5918 5933 - Made the usage message a parameter.
5919 5934
5920 5935 - Require the name of the shell variable to be given. It's a bit
5921 5936 of a hack, but allows the name 'shell' not to be hardwired in the
5922 5937 magic (@) handler, which is problematic b/c it requires
5923 5938 polluting the global namespace with 'shell'. This in turn is
5924 5939 fragile: if a user redefines a variable called shell, things
5925 5940 break.
5926 5941
5927 5942 - magic @: all functions available through @ need to be defined
5928 5943 as magic_<name>, even though they can be called simply as
5929 5944 @<name>. This allows the special command @magic to gather
5930 5945 information automatically about all existing magic functions,
5931 5946 even if they are run-time user extensions, by parsing the shell
5932 5947 instance __dict__ looking for special magic_ names.
5933 5948
5934 5949 - mainloop: added *two* local namespace parameters. This allows
5935 5950 the class to differentiate between parameters which were there
5936 5951 before and after command line initialization was processed. This
5937 5952 way, later @who can show things loaded at startup by the
5938 5953 user. This trick was necessary to make session saving/reloading
5939 5954 really work: ideally after saving/exiting/reloading a session,
5940 5955 *everything* should look the same, including the output of @who. I
5941 5956 was only able to make this work with this double namespace
5942 5957 trick.
5943 5958
5944 5959 - added a header to the logfile which allows (almost) full
5945 5960 session restoring.
5946 5961
5947 5962 - prepend lines beginning with @ or !, with a and log
5948 5963 them. Why? !lines: may be useful to know what you did @lines:
5949 5964 they may affect session state. So when restoring a session, at
5950 5965 least inform the user of their presence. I couldn't quite get
5951 5966 them to properly re-execute, but at least the user is warned.
5952 5967
5953 5968 * Started ChangeLog.
@@ -1,9545 +1,9549 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 38
39 39 % Define a \codelist command which either uses listings for latex, or
40 40 % plain verbatim for html (since latex2html doesn't understand the
41 41 % listings package).
42 42 \usepackage{verbatim}
43 43 \newcommand{\codelist}[1] {
44 44 \latex{\lstinputlisting{#1}}
45 45 \html{\verbatiminput{#1}}
46 46 }
47 47 \end_preamble
48 48 \language english
49 49 \inputencoding latin1
50 50 \fontscheme palatino
51 51 \graphics default
52 52 \paperfontsize 11
53 53 \spacing single
54 54 \papersize Default
55 55 \paperpackage a4
56 56 \use_geometry 1
57 57 \use_amsmath 0
58 58 \use_natbib 0
59 59 \use_numerical_citations 0
60 60 \paperorientation portrait
61 61 \leftmargin 1in
62 62 \topmargin 1in
63 63 \rightmargin 1in
64 64 \bottommargin 1in
65 65 \secnumdepth 3
66 66 \tocdepth 3
67 67 \paragraph_separation skip
68 68 \defskip medskip
69 69 \quotes_language english
70 70 \quotes_times 2
71 71 \papercolumns 1
72 72 \papersides 2
73 73 \paperpagestyle fancy
74 74
75 75 \layout Title
76 76
77 77 IPython
78 78 \newline
79 79
80 80 \size larger
81 81 An enhanced Interactive Python
82 82 \size large
83 83
84 84 \newline
85 85 User Manual, v.
86 86 __version__
87 87 \layout Author
88 88
89 89 Fernando PοΏ½rez
90 90 \begin_inset Foot
91 91 collapsed true
92 92
93 93 \layout Standard
94 94
95 95
96 96 \size scriptsize
97 97 Department of Applied Mathematics, University of Colorado at Boulder.
98 98
99 99 \family typewriter
100 100 <Fernando.Perez@colorado.edu>
101 101 \end_inset
102 102
103 103
104 104 \layout Standard
105 105
106 106
107 107 \begin_inset ERT
108 108 status Collapsed
109 109
110 110 \layout Standard
111 111
112 112 \backslash
113 113 latex{
114 114 \end_inset
115 115
116 116
117 117 \begin_inset LatexCommand \tableofcontents{}
118 118
119 119 \end_inset
120 120
121 121
122 122 \begin_inset ERT
123 123 status Collapsed
124 124
125 125 \layout Standard
126 126 }
127 127 \end_inset
128 128
129 129
130 130 \layout Standard
131 131
132 132
133 133 \begin_inset ERT
134 134 status Open
135 135
136 136 \layout Standard
137 137
138 138 \backslash
139 139 html{
140 140 \backslash
141 141 bodytext{bgcolor=#ffffff}}
142 142 \end_inset
143 143
144 144
145 145 \layout Section
146 146 \pagebreak_top
147 147 Overview
148 148 \layout Standard
149 149
150 150 One of Python's most useful features is its interactive interpreter.
151 151 This system allows very fast testing of ideas without the overhead of creating
152 152 test files as is typical in most programming languages.
153 153 However, the interpreter supplied with the standard Python distribution
154 154 is somewhat limited for extended interactive use.
155 155 \layout Standard
156 156
157 157 IPython is a free software project (released under the BSD license) which
158 158 tries to:
159 159 \layout Enumerate
160 160
161 161 Provide an interactive shell superior to Python's default.
162 162 IPython has many features for object introspection, system shell access,
163 163 and its own special command system for adding functionality when working
164 164 interactively.
165 165 It tries to be a very efficient environment both for Python code development
166 166 and for exploration of problems using Python objects (in situations like
167 167 data analysis).
168 168 \layout Enumerate
169 169
170 170 Serve as an embeddable, ready to use interpreter for your own programs.
171 171 IPython can be started with a single call from inside another program,
172 172 providing access to the current namespace.
173 173 This can be very useful both for debugging purposes and for situations
174 174 where a blend of batch-processing and interactive exploration are needed.
175 175 \layout Enumerate
176 176
177 177 Offer a flexible framework which can be used as the base environment for
178 178 other systems with Python as the underlying language.
179 179 Specifically scientific environments like Mathematica, IDL and Matlab inspired
180 180 its design, but similar ideas can be useful in many fields.
181 181 \layout Enumerate
182 182
183 183 Allow interactive testing of threaded graphical toolkits.
184 184 IPython has support for interactive, non-blocking control of GTK, Qt and
185 185 WX applications via special threading flags.
186 186 The normal Python shell can only do this for Tkinter applications.
187 187 \layout Subsection
188 188
189 189 Main features
190 190 \layout Itemize
191 191
192 192 Dynamic object introspection.
193 193 One can access docstrings, function definition prototypes, source code,
194 194 source files and other details of any object accessible to the interpreter
195 195 with a single keystroke (`
196 196 \family typewriter
197 197 ?
198 198 \family default
199 199 ', and using `
200 200 \family typewriter
201 201 ??
202 202 \family default
203 203 ' provides additional detail).
204 204 \layout Itemize
205 205
206 206 Searching through modules and namespaces with `
207 207 \family typewriter
208 208 *
209 209 \family default
210 210 ' wildcards, both when using the `
211 211 \family typewriter
212 212 ?
213 213 \family default
214 214 ' system and via the
215 215 \family typewriter
216 216 %psearch
217 217 \family default
218 218 command.
219 219 \layout Itemize
220 220
221 221 Completion in the local namespace, by typing TAB at the prompt.
222 222 This works for keywords, methods, variables and files in the current directory.
223 223 This is supported via the readline library, and full access to configuring
224 224 readline's behavior is provided.
225 225 \layout Itemize
226 226
227 227 Numbered input/output prompts with command history (persistent across sessions
228 228 and tied to each profile), full searching in this history and caching of
229 229 all input and output.
230 230 \layout Itemize
231 231
232 232 User-extensible `magic' commands.
233 233 A set of commands prefixed with
234 234 \family typewriter
235 235 %
236 236 \family default
237 237 is available for controlling IPython itself and provides directory control,
238 238 namespace information and many aliases to common system shell commands.
239 239 \layout Itemize
240 240
241 241 Alias facility for defining your own system aliases.
242 242 \layout Itemize
243 243
244 244 Complete system shell access.
245 245 Lines starting with ! are passed directly to the system shell, and using
246 246 !! captures shell output into python variables for further use.
247 247 \layout Itemize
248 248
249 249 Background execution of Python commands in a separate thread.
250 250 IPython has an internal job manager called
251 251 \family typewriter
252 252 jobs
253 253 \family default
254 254 , and a conveninence backgrounding magic function called
255 255 \family typewriter
256 256 %bg
257 257 \family default
258 258 .
259 259 \layout Itemize
260 260
261 261 The ability to expand python variables when calling the system shell.
262 262 In a shell command, any python variable prefixed with
263 263 \family typewriter
264 264 $
265 265 \family default
266 266 is expanded.
267 267 A double
268 268 \family typewriter
269 269 $$
270 270 \family default
271 271 allows passing a literal
272 272 \family typewriter
273 273 $
274 274 \family default
275 275 to the shell (for access to shell and environment variables like
276 276 \family typewriter
277 277 $PATH
278 278 \family default
279 279 ).
280 280 \layout Itemize
281 281
282 282 Filesystem navigation, via a magic
283 283 \family typewriter
284 284 %cd
285 285 \family default
286 286 command, along with a persistent bookmark system (using
287 287 \family typewriter
288 288 %bookmark
289 289 \family default
290 290 ) for fast access to frequently visited directories.
291 291 \layout Itemize
292 292
293 293 A lightweight persistence framework via the
294 294 \family typewriter
295 295 %store
296 296 \family default
297 297 command, which allows you to save arbitrary Python variables.
298 298 These get restored automatically when your session restarts.
299 299 \layout Itemize
300 300
301 301 Automatic indentation (optional) of code as you type (through the readline
302 302 library).
303 303 \layout Itemize
304 304
305 305 Macro system for quickly re-executing multiple lines of previous input with
306 306 a single name.
307 307 Macros can be stored persistently via
308 308 \family typewriter
309 309 %store
310 310 \family default
311 311 and edited via
312 312 \family typewriter
313 313 %edit
314 314 \family default
315 315 .
316 316
317 317 \layout Itemize
318 318
319 319 Session logging (you can then later use these logs as code in your programs).
320 320 Logs can optionally timestamp all input, and also store session output
321 321 (marked as comments, so the log remains valid Python source code).
322 322 \layout Itemize
323 323
324 324 Session restoring: logs can be replayed to restore a previous session to
325 325 the state where you left it.
326 326 \layout Itemize
327 327
328 328 Verbose and colored exception traceback printouts.
329 329 Easier to parse visually, and in verbose mode they produce a lot of useful
330 330 debugging information (basically a terminal version of the cgitb module).
331 331 \layout Itemize
332 332
333 333 Auto-parentheses: callable objects can be executed without parentheses:
334 334
335 335 \family typewriter
336 336 `sin 3'
337 337 \family default
338 338 is automatically converted to
339 339 \family typewriter
340 340 `sin(3)
341 341 \family default
342 342 '.
343 343 \layout Itemize
344 344
345 345 Auto-quoting: using `
346 346 \family typewriter
347 347 ,
348 348 \family default
349 349 ' or `
350 350 \family typewriter
351 351 ;
352 352 \family default
353 353 ' as the first character forces auto-quoting of the rest of the line:
354 354 \family typewriter
355 355 `,my_function a\SpecialChar ~
356 356 b'
357 357 \family default
358 358 becomes automatically
359 359 \family typewriter
360 360 `my_function("a","b")'
361 361 \family default
362 362 , while
363 363 \family typewriter
364 364 `;my_function a\SpecialChar ~
365 365 b'
366 366 \family default
367 367 becomes
368 368 \family typewriter
369 369 `my_function("a b")'
370 370 \family default
371 371 .
372 372 \layout Itemize
373 373
374 374 Extensible input syntax.
375 375 You can define filters that pre-process user input to simplify input in
376 376 special situations.
377 377 This allows for example pasting multi-line code fragments which start with
378 378
379 379 \family typewriter
380 380 `>>>'
381 381 \family default
382 382 or
383 383 \family typewriter
384 384 `...'
385 385 \family default
386 386 such as those from other python sessions or the standard Python documentation.
387 387 \layout Itemize
388 388
389 389 Flexible configuration system.
390 390 It uses a configuration file which allows permanent setting of all command-line
391 391 options, module loading, code and file execution.
392 392 The system allows recursive file inclusion, so you can have a base file
393 393 with defaults and layers which load other customizations for particular
394 394 projects.
395 395 \layout Itemize
396 396
397 397 Embeddable.
398 398 You can call IPython as a python shell inside your own python programs.
399 399 This can be used both for debugging code or for providing interactive abilities
400 400 to your programs with knowledge about the local namespaces (very useful
401 401 in debugging and data analysis situations).
402 402 \layout Itemize
403 403
404 404 Easy debugger access.
405 405 You can set IPython to call up an enhanced version of the Python debugger
406 406 (
407 407 \family typewriter
408 408 pdb
409 409 \family default
410 410 ) every time there is an uncaught exception.
411 411 This drops you inside the code which triggered the exception with all the
412 412 data live and it is possible to navigate the stack to rapidly isolate the
413 413 source of a bug.
414 414 The
415 415 \family typewriter
416 416 %run
417 417 \family default
418 418 magic command --with the
419 419 \family typewriter
420 420 -d
421 421 \family default
422 422 option-- can run any script under
423 423 \family typewriter
424 424 pdb
425 425 \family default
426 426 's control, automatically setting initial breakpoints for you.
427 427 This version of
428 428 \family typewriter
429 429 pdb
430 430 \family default
431 431 has IPython-specific improvements, including tab-completion and traceback
432 432 coloring support.
433 433 \layout Itemize
434 434
435 435 Profiler support.
436 436 You can run single statements (similar to
437 437 \family typewriter
438 438 profile.run()
439 439 \family default
440 440 ) or complete programs under the profiler's control.
441 While this is possible with the standard
441 While this is possible with standard
442 \family typewriter
443 cProfile
444 \family default
445 or
442 446 \family typewriter
443 447 profile
444 448 \family default
445 module, IPython wraps this functionality with magic commands (see
449 modules, IPython wraps this functionality with magic commands (see
446 450 \family typewriter
447 451 `%prun'
448 452 \family default
449 453 and
450 454 \family typewriter
451 455 `%run -p
452 456 \family default
453 457 ') convenient for rapid interactive work.
454 458 \layout Subsection
455 459
456 460 Portability and Python requirements
457 461 \layout Standard
458 462
459 463
460 464 \series bold
461 465 Python requirements:
462 466 \series default
463 467 IPython requires with Python version 2.3 or newer.
464 468 If you are still using Python 2.2 and can not upgrade, the last version
465 469 of IPython which worked with Python 2.2 was 0.6.15, so you will have to use
466 470 that.
467 471 \layout Standard
468 472
469 473 IPython is developed under
470 474 \series bold
471 475 Linux
472 476 \series default
473 477 , but it should work in any reasonable Unix-type system (tested OK under
474 478 Solaris and the *BSD family, for which a port exists thanks to Dryice Liu).
475 479 \layout Standard
476 480
477 481
478 482 \series bold
479 483 Mac OS X
480 484 \series default
481 485 : it works, apparently without any problems (thanks to Jim Boyle at Lawrence
482 486 Livermore for the information).
483 487 Thanks to Andrea Riciputi, Fink support is available.
484 488 \layout Standard
485 489
486 490
487 491 \series bold
488 492 CygWin
489 493 \series default
490 494 : it works mostly OK, though some users have reported problems with prompt
491 495 coloring.
492 496 No satisfactory solution to this has been found so far, you may want to
493 497 disable colors permanently in the
494 498 \family typewriter
495 499 ipythonrc
496 500 \family default
497 501 configuration file if you experience problems.
498 502 If you have proper color support under cygwin, please post to the IPython
499 503 mailing list so this issue can be resolved for all users.
500 504 \layout Standard
501 505
502 506
503 507 \series bold
504 508 Windows
505 509 \series default
506 510 : it works well under Windows XP/2k, and I suspect NT should behave similarly.
507 511 Section\SpecialChar ~
508 512
509 513 \begin_inset LatexCommand \ref{sub:Under-Windows}
510 514
511 515 \end_inset
512 516
513 517 describes installation details for Windows, including some additional tools
514 518 needed on this platform.
515 519 \layout Standard
516 520
517 521 Windows 9x support is present, and has been reported to work fine (at least
518 522 on WinME).
519 523 \layout Standard
520 524
521 525 Note, that I have very little access to and experience with Windows development.
522 526 However, an excellent group of Win32 users (led by Ville Vainio), consistently
523 527 contribute bugfixes and platform-specific enhancements, so they more than
524 528 make up for my deficiencies on that front.
525 529 In fact, Win32 users report using IPython as a system shell (see Sec.\SpecialChar ~
526 530
527 531 \begin_inset LatexCommand \ref{sec:IPython-as-shell}
528 532
529 533 \end_inset
530 534
531 535 for details), as it offers a level of control and features which the default
532 536
533 537 \family typewriter
534 538 cmd.exe
535 539 \family default
536 540 doesn't provide.
537 541 \layout Subsection
538 542
539 543 Location
540 544 \layout Standard
541 545
542 546 IPython is generously hosted at
543 547 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
544 548
545 549 \end_inset
546 550
547 551 by the Enthought, Inc and the SciPy project.
548 552 This site offers downloads, subversion access, mailing lists and a bug
549 553 tracking system.
550 554 I am very grateful to Enthought (
551 555 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
552 556
553 557 \end_inset
554 558
555 559 ) and all of the SciPy team for their contribution.
556 560 \layout Section
557 561
558 562
559 563 \begin_inset LatexCommand \label{sec:install}
560 564
561 565 \end_inset
562 566
563 567 Installation
564 568 \layout Subsection
565 569
566 570 Instant instructions
567 571 \layout Standard
568 572
569 573 If you are of the impatient kind, under Linux/Unix simply untar/unzip the
570 574 download, then install with
571 575 \family typewriter
572 576 `python setup.py install'
573 577 \family default
574 578 .
575 579 Under Windows, double-click on the provided
576 580 \family typewriter
577 581 .exe
578 582 \family default
579 583 binary installer.
580 584 \layout Standard
581 585
582 586 Then, take a look at Sections
583 587 \begin_inset LatexCommand \ref{sec:good_config}
584 588
585 589 \end_inset
586 590
587 591 for configuring things optimally and
588 592 \begin_inset LatexCommand \ref{sec:quick_tips}
589 593
590 594 \end_inset
591 595
592 596 for quick tips on efficient use of IPython.
593 597 You can later refer to the rest of the manual for all the gory details.
594 598 \layout Standard
595 599
596 600 See the notes in sec.
597 601
598 602 \begin_inset LatexCommand \ref{sec:upgrade}
599 603
600 604 \end_inset
601 605
602 606 for upgrading IPython versions.
603 607 \layout Subsection
604 608
605 609 Detailed Unix instructions (Linux, Mac OS X, etc.)
606 610 \layout Standard
607 611
608 612 For RPM based systems, simply install the supplied package in the usual
609 613 manner.
610 614 If you download the tar archive, the process is:
611 615 \layout Enumerate
612 616
613 617 Unzip/untar the
614 618 \family typewriter
615 619 ipython-XXX.tar.gz
616 620 \family default
617 621 file wherever you want (
618 622 \family typewriter
619 623 XXX
620 624 \family default
621 625 is the version number).
622 626 It will make a directory called
623 627 \family typewriter
624 628 ipython-XXX.
625 629
626 630 \family default
627 631 Change into that directory where you will find the files
628 632 \family typewriter
629 633 README
630 634 \family default
631 635 and
632 636 \family typewriter
633 637 setup.py
634 638 \family default
635 639 .
636 640
637 641 \family typewriter
638 642 O
639 643 \family default
640 644 nce you've completed the installation, you can safely remove this directory.
641 645
642 646 \layout Enumerate
643 647
644 648 If you are installing over a previous installation of version 0.2.0 or earlier,
645 649 first remove your
646 650 \family typewriter
647 651 $HOME/.ipython
648 652 \family default
649 653 directory, since the configuration file format has changed somewhat (the
650 654 '=' were removed from all option specifications).
651 655 Or you can call ipython with the
652 656 \family typewriter
653 657 -upgrade
654 658 \family default
655 659 option and it will do this automatically for you.
656 660 \layout Enumerate
657 661
658 662 IPython uses distutils, so you can install it by simply typing at the system
659 663 prompt (don't type the
660 664 \family typewriter
661 665 $
662 666 \family default
663 667 )
664 668 \newline
665 669
666 670 \family typewriter
667 671 $ python setup.py install
668 672 \family default
669 673
670 674 \newline
671 675 Note that this assumes you have root access to your machine.
672 676 If you don't have root access or don't want IPython to go in the default
673 677 python directories, you'll need to use the
674 678 \begin_inset ERT
675 679 status Collapsed
676 680
677 681 \layout Standard
678 682
679 683 \backslash
680 684 verb|--home|
681 685 \end_inset
682 686
683 687 option (or
684 688 \begin_inset ERT
685 689 status Collapsed
686 690
687 691 \layout Standard
688 692
689 693 \backslash
690 694 verb|--prefix|
691 695 \end_inset
692 696
693 697 ).
694 698 For example:
695 699 \newline
696 700
697 701 \begin_inset ERT
698 702 status Collapsed
699 703
700 704 \layout Standard
701 705
702 706 \backslash
703 707 verb|$ python setup.py install --home $HOME/local|
704 708 \end_inset
705 709
706 710
707 711 \newline
708 712 will install IPython into
709 713 \family typewriter
710 714 $HOME/local
711 715 \family default
712 716 and its subdirectories (creating them if necessary).
713 717 \newline
714 718 You can type
715 719 \newline
716 720
717 721 \begin_inset ERT
718 722 status Collapsed
719 723
720 724 \layout Standard
721 725
722 726 \backslash
723 727 verb|$ python setup.py --help|
724 728 \end_inset
725 729
726 730
727 731 \newline
728 732 for more details.
729 733 \newline
730 734 Note that if you change the default location for
731 735 \begin_inset ERT
732 736 status Collapsed
733 737
734 738 \layout Standard
735 739
736 740 \backslash
737 741 verb|--home|
738 742 \end_inset
739 743
740 744 at installation, IPython may end up installed at a location which is not
741 745 part of your
742 746 \family typewriter
743 747 $PYTHONPATH
744 748 \family default
745 749 environment variable.
746 750 In this case, you'll need to configure this variable to include the actual
747 751 directory where the
748 752 \family typewriter
749 753 IPython/
750 754 \family default
751 755 directory ended (typically the value you give to
752 756 \begin_inset ERT
753 757 status Collapsed
754 758
755 759 \layout Standard
756 760
757 761 \backslash
758 762 verb|--home|
759 763 \end_inset
760 764
761 765 plus
762 766 \family typewriter
763 767 /lib/python
764 768 \family default
765 769 ).
766 770 \layout Subsubsection
767 771
768 772 Mac OSX information
769 773 \layout Standard
770 774
771 775 Under OSX, there is a choice you need to make.
772 776 Apple ships its own build of Python, which lives in the core OSX filesystem
773 777 hierarchy.
774 778 You can also manually install a separate Python, either purely by hand
775 779 (typically in
776 780 \family typewriter
777 781 /usr/local
778 782 \family default
779 783 ) or by using Fink, which puts everything under
780 784 \family typewriter
781 785 /sw
782 786 \family default
783 787 .
784 788 Which route to follow is a matter of personal preference, as I've seen
785 789 users who favor each of the approaches.
786 790 Here I will simply list the known installation issues under OSX, along
787 791 with their solutions.
788 792 \layout Standard
789 793
790 794 This page:
791 795 \begin_inset LatexCommand \htmlurl{http://geosci.uchicago.edu/~tobis/pylab.html}
792 796
793 797 \end_inset
794 798
795 799 contains information on this topic, with additional details on how to make
796 800 IPython and matplotlib play nicely under OSX.
797 801 \layout Subsubsection*
798 802
799 803 GUI problems
800 804 \layout Standard
801 805
802 806 The following instructions apply to an install of IPython under OSX from
803 807 unpacking the
804 808 \family typewriter
805 809 .tar.gz
806 810 \family default
807 811 distribution and installing it for the default Python interpreter shipped
808 812 by Apple.
809 813 If you are using a fink install, fink will take care of these details for
810 814 you, by installing IPython against fink's Python.
811 815 \layout Standard
812 816
813 817 IPython offers various forms of support for interacting with graphical applicati
814 818 ons from the command line, from simple Tk apps (which are in principle always
815 819 supported by Python) to interactive control of WX, Qt and GTK apps.
816 820 Under OSX, however, this requires that ipython is installed by calling
817 821 the special
818 822 \family typewriter
819 823 pythonw
820 824 \family default
821 825 script at installation time, which takes care of coordinating things with
822 826 Apple's graphical environment.
823 827 \layout Standard
824 828
825 829 So when installing under OSX, it is best to use the following command:
826 830 \family typewriter
827 831
828 832 \newline
829 833
830 834 \family default
831 835
832 836 \begin_inset ERT
833 837 status Collapsed
834 838
835 839 \layout Standard
836 840
837 841 \backslash
838 842 verb| $ sudo pythonw setup.py install --install-scripts=/usr/local/bin|
839 843 \end_inset
840 844
841 845
842 846 \newline
843 847 or
844 848 \newline
845 849
846 850 \begin_inset ERT
847 851 status Collapsed
848 852
849 853 \layout Standard
850 854
851 855 \backslash
852 856 verb| $ sudo pythonw setup.py install --install-scripts=/usr/bin|
853 857 \end_inset
854 858
855 859
856 860 \newline
857 861 depending on where you like to keep hand-installed executables.
858 862 \layout Standard
859 863
860 864 The resulting script will have an appropriate shebang line (the first line
861 865 in the script whic begins with
862 866 \family typewriter
863 867 #!...
864 868 \family default
865 869 ) such that the ipython interpreter can interact with the OS X GUI.
866 870 If the installed version does not work and has a shebang line that points
867 871 to, for example, just
868 872 \family typewriter
869 873 /usr/bin/python
870 874 \family default
871 875 , then you might have a stale, cached version in your
872 876 \family typewriter
873 877 build/scripts-<python-version>
874 878 \family default
875 879 directory.
876 880 Delete that directory and rerun the
877 881 \family typewriter
878 882 setup.py
879 883 \family default
880 884 .
881 885
882 886 \layout Standard
883 887
884 888 It is also a good idea to use the special flag
885 889 \begin_inset ERT
886 890 status Collapsed
887 891
888 892 \layout Standard
889 893
890 894 \backslash
891 895 verb|--install-scripts|
892 896 \end_inset
893 897
894 898 as indicated above, to ensure that the ipython scripts end up in a location
895 899 which is part of your
896 900 \family typewriter
897 901 $PATH
898 902 \family default
899 903 .
900 904 Otherwise Apple's Python will put the scripts in an internal directory
901 905 not available by default at the command line (if you use
902 906 \family typewriter
903 907 /usr/local/bin
904 908 \family default
905 909 , you need to make sure this is in your
906 910 \family typewriter
907 911 $PATH
908 912 \family default
909 913 , which may not be true by default).
910 914 \layout Subsubsection*
911 915
912 916 Readline problems
913 917 \layout Standard
914 918
915 919 By default, the Python version shipped by Apple does
916 920 \emph on
917 921 not
918 922 \emph default
919 923 include the readline library, so central to IPython's behavior.
920 924 If you install IPython against Apple's Python, you will not have arrow
921 925 keys, tab completion, etc.
922 926 For Mac OSX 10.3 (Panther), you can find a prebuilt readline library here:
923 927 \newline
924 928
925 929 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/readline-5.0-py2.3-macosx10.3.zip}
926 930
927 931 \end_inset
928 932
929 933
930 934 \layout Standard
931 935
932 936 If you are using OSX 10.4 (Tiger), after installing this package you need
933 937 to either:
934 938 \layout Enumerate
935 939
936 940 move
937 941 \family typewriter
938 942 readline.so
939 943 \family default
940 944 from
941 945 \family typewriter
942 946 /Library/Python/2.3
943 947 \family default
944 948 to
945 949 \family typewriter
946 950 /Library/Python/2.3/site-packages
947 951 \family default
948 952 , or
949 953 \layout Enumerate
950 954
951 955 install
952 956 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/TigerPython23Compat.pkg.zip}
953 957
954 958 \end_inset
955 959
956 960
957 961 \layout Standard
958 962
959 963 Users installing against Fink's Python or a properly hand-built one should
960 964 not have this problem.
961 965 \layout Subsubsection*
962 966
963 967 DarwinPorts
964 968 \layout Standard
965 969
966 970 I report here a message from an OSX user, who suggests an alternative means
967 971 of using IPython under this operating system with good results.
968 972 Please let me know of any updates that may be useful for this section.
969 973 His message is reproduced verbatim below:
970 974 \layout Quote
971 975
972 976 From: Markus Banfi
973 977 \family typewriter
974 978 <markus.banfi-AT-mospheira.net>
975 979 \layout Quote
976 980
977 981 As a MacOS X (10.4.2) user I prefer to install software using DawinPorts instead
978 982 of Fink.
979 983 I had no problems installing ipython with DarwinPorts.
980 984 It's just:
981 985 \layout Quote
982 986
983 987
984 988 \family typewriter
985 989 sudo port install py-ipython
986 990 \layout Quote
987 991
988 992 It automatically resolved all dependencies (python24, readline, py-readline).
989 993 So far I did not encounter any problems with the DarwinPorts port of ipython.
990 994
991 995 \layout Subsection
992 996
993 997
994 998 \begin_inset LatexCommand \label{sub:Under-Windows}
995 999
996 1000 \end_inset
997 1001
998 1002 Windows instructions
999 1003 \layout Standard
1000 1004
1001 1005 Some of IPython's very useful features are:
1002 1006 \layout Itemize
1003 1007
1004 1008 Integrated readline support (Tab-based file, object and attribute completion,
1005 1009 input history across sessions, editable command line, etc.)
1006 1010 \layout Itemize
1007 1011
1008 1012 Coloring of prompts, code and tracebacks.
1009 1013 \layout Standard
1010 1014
1011 1015 These, by default, are only available under Unix-like operating systems.
1012 1016 However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit
1013 1017 from them.
1014 1018 His readline library originally implemented both GNU readline functionality
1015 1019 and color support, so that IPython under Windows XP/2k can be as friendly
1016 1020 and powerful as under Unix-like environments.
1017 1021
1018 1022 \layout Standard
1019 1023
1020 1024 This library, now named
1021 1025 \family typewriter
1022 1026 PyReadline
1023 1027 \family default
1024 1028 , has been absorbed by the IPython team (JοΏ½rgen Stenarson, in particular),
1025 1029 and it continues to be developed with new features, as well as being distribute
1026 1030 d directly from the IPython site.
1027 1031 \layout Standard
1028 1032
1029 1033 The
1030 1034 \family typewriter
1031 1035 PyReadline
1032 1036 \family default
1033 1037 extension requires
1034 1038 \family typewriter
1035 1039 CTypes
1036 1040 \family default
1037 1041 and the windows IPython installer needs
1038 1042 \family typewriter
1039 1043 PyWin32
1040 1044 \family default
1041 1045 , so in all you need:
1042 1046 \layout Enumerate
1043 1047
1044 1048
1045 1049 \family typewriter
1046 1050 PyWin32
1047 1051 \family default
1048 1052 from
1049 1053 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
1050 1054
1051 1055 \end_inset
1052 1056
1053 1057 .
1054 1058 \layout Enumerate
1055 1059
1056 1060
1057 1061 \family typewriter
1058 1062 CTypes
1059 1063 \family default
1060 1064 from
1061 1065 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
1062 1066
1063 1067 \end_inset
1064 1068
1065 1069 (you
1066 1070 \emph on
1067 1071 must
1068 1072 \emph default
1069 1073 use version 0.9.1 or newer).
1070 1074 \layout Enumerate
1071 1075
1072 1076
1073 1077 \family typewriter
1074 1078 PyReadline
1075 1079 \family default
1076 1080 for Windows from
1077 1081 \begin_inset LatexCommand \htmlurl{http://projects.scipy.org/ipython/ipython/wiki/PyReadline/Intro}
1078 1082
1079 1083 \end_inset
1080 1084
1081 1085 .
1082 1086 That page contains further details on using and configuring the system
1083 1087 to your liking.
1084 1088 \layout Standard
1085 1089
1086 1090
1087 1091 \series bold
1088 1092 Warning about a broken readline-like library:
1089 1093 \series default
1090 1094 several users have reported problems stemming from using the pseudo-readline
1091 1095 library at
1092 1096 \begin_inset LatexCommand \htmlurl{http://newcenturycomputers.net/projects/readline.html}
1093 1097
1094 1098 \end_inset
1095 1099
1096 1100 .
1097 1101 This is a broken library which, while called readline, only implements
1098 1102 an incomplete subset of the readline API.
1099 1103 Since it is still called readline, it fools IPython's detection mechanisms
1100 1104 and causes unpredictable crashes later.
1101 1105 If you wish to use IPython under Windows, you must NOT use this library,
1102 1106 which for all purposes is (at least as of version 1.6) terminally broken.
1103 1107 \layout Subsubsection
1104 1108
1105 1109 Installation procedure
1106 1110 \layout Standard
1107 1111
1108 1112 Once you have the above installed, from the IPython download directory grab
1109 1113 the
1110 1114 \family typewriter
1111 1115 ipython-XXX.win32.exe
1112 1116 \family default
1113 1117 file, where
1114 1118 \family typewriter
1115 1119 XXX
1116 1120 \family default
1117 1121 represents the version number.
1118 1122 This is a regular windows executable installer, which you can simply double-cli
1119 1123 ck to install.
1120 1124 It will add an entry for IPython to your Start Menu, as well as registering
1121 1125 IPython in the Windows list of applications, so you can later uninstall
1122 1126 it from the Control Panel.
1123 1127
1124 1128 \layout Standard
1125 1129
1126 1130 IPython tries to install the configuration information in a directory named
1127 1131
1128 1132 \family typewriter
1129 1133 .ipython
1130 1134 \family default
1131 1135 (
1132 1136 \family typewriter
1133 1137 _ipython
1134 1138 \family default
1135 1139 under Windows) located in your `home' directory.
1136 1140 IPython sets this directory by looking for a
1137 1141 \family typewriter
1138 1142 HOME
1139 1143 \family default
1140 1144 environment variable; if such a variable does not exist, it uses
1141 1145 \family typewriter
1142 1146 HOMEDRIVE
1143 1147 \backslash
1144 1148 HOMEPATH
1145 1149 \family default
1146 1150 (these are always defined by Windows).
1147 1151 This typically gives something like
1148 1152 \family typewriter
1149 1153 C:
1150 1154 \backslash
1151 1155 Documents and Settings
1152 1156 \backslash
1153 1157 YourUserName
1154 1158 \family default
1155 1159 , but your local details may vary.
1156 1160 In this directory you will find all the files that configure IPython's
1157 1161 defaults, and you can put there your profiles and extensions.
1158 1162 This directory is automatically added by IPython to
1159 1163 \family typewriter
1160 1164 sys.path
1161 1165 \family default
1162 1166 , so anything you place there can be found by
1163 1167 \family typewriter
1164 1168 import
1165 1169 \family default
1166 1170 statements.
1167 1171 \layout Paragraph
1168 1172
1169 1173 Upgrading
1170 1174 \layout Standard
1171 1175
1172 1176 For an IPython upgrade, you should first uninstall the previous version.
1173 1177 This will ensure that all files and directories (such as the documentation)
1174 1178 which carry embedded version strings in their names are properly removed.
1175 1179 \layout Paragraph
1176 1180
1177 1181 Manual installation under Win32
1178 1182 \layout Standard
1179 1183
1180 1184 In case the automatic installer does not work for some reason, you can download
1181 1185 the
1182 1186 \family typewriter
1183 1187 ipython-XXX.tar.gz
1184 1188 \family default
1185 1189 file, which contains the full IPython source distribution (the popular
1186 1190 WinZip can read
1187 1191 \family typewriter
1188 1192 .tar.gz
1189 1193 \family default
1190 1194 files).
1191 1195 After uncompressing the archive, you can install it at a command terminal
1192 1196 just like any other Python module, by using
1193 1197 \family typewriter
1194 1198 `python setup.py install'
1195 1199 \family default
1196 1200 .
1197 1201
1198 1202 \layout Standard
1199 1203
1200 1204 After the installation, run the supplied
1201 1205 \family typewriter
1202 1206 win32_manual_post_install.py
1203 1207 \family default
1204 1208 script, which creates the necessary Start Menu shortcuts for you.
1205 1209 \layout Subsection
1206 1210
1207 1211
1208 1212 \begin_inset LatexCommand \label{sec:upgrade}
1209 1213
1210 1214 \end_inset
1211 1215
1212 1216 Upgrading from a previous version
1213 1217 \layout Standard
1214 1218
1215 1219 If you are upgrading from a previous version of IPython, after doing the
1216 1220 routine installation described above, you should call IPython with the
1217 1221
1218 1222 \family typewriter
1219 1223 -upgrade
1220 1224 \family default
1221 1225 option the first time you run your new copy.
1222 1226 This will automatically update your configuration directory while preserving
1223 1227 copies of your old files.
1224 1228 You can then later merge back any personal customizations you may have
1225 1229 made into the new files.
1226 1230 It is a good idea to do this as there may be new options available in the
1227 1231 new configuration files which you will not have.
1228 1232 \layout Standard
1229 1233
1230 1234 Under Windows, if you don't know how to call python scripts with arguments
1231 1235 from a command line, simply delete the old config directory and IPython
1232 1236 will make a new one.
1233 1237 Win2k and WinXP users will find it in
1234 1238 \family typewriter
1235 1239 C:
1236 1240 \backslash
1237 1241 Documents and Settings
1238 1242 \backslash
1239 1243 YourUserName
1240 1244 \backslash
1241 1245 _ipython
1242 1246 \family default
1243 1247 , and Win 9x users under
1244 1248 \family typewriter
1245 1249 C:
1246 1250 \backslash
1247 1251 Program Files
1248 1252 \backslash
1249 1253 IPython
1250 1254 \backslash
1251 1255 _ipython.
1252 1256 \layout Section
1253 1257
1254 1258
1255 1259 \begin_inset LatexCommand \label{sec:good_config}
1256 1260
1257 1261 \end_inset
1258 1262
1259 1263
1260 1264 \begin_inset OptArg
1261 1265 collapsed true
1262 1266
1263 1267 \layout Standard
1264 1268
1265 1269 Initial configuration
1266 1270 \begin_inset ERT
1267 1271 status Collapsed
1268 1272
1269 1273 \layout Standard
1270 1274
1271 1275 \backslash
1272 1276 ldots
1273 1277 \end_inset
1274 1278
1275 1279
1276 1280 \end_inset
1277 1281
1278 1282 Initial configuration of your environment
1279 1283 \layout Standard
1280 1284
1281 1285 This section will help you set various things in your environment for your
1282 1286 IPython sessions to be as efficient as possible.
1283 1287 All of IPython's configuration information, along with several example
1284 1288 files, is stored in a directory named by default
1285 1289 \family typewriter
1286 1290 $HOME/.ipython
1287 1291 \family default
1288 1292 .
1289 1293 You can change this by defining the environment variable
1290 1294 \family typewriter
1291 1295 IPYTHONDIR
1292 1296 \family default
1293 1297 , or at runtime with the command line option
1294 1298 \family typewriter
1295 1299 -ipythondir
1296 1300 \family default
1297 1301 .
1298 1302 \layout Standard
1299 1303
1300 1304 If all goes well, the first time you run IPython it should automatically
1301 1305 create a user copy of the config directory for you, based on its builtin
1302 1306 defaults.
1303 1307 You can look at the files it creates to learn more about configuring the
1304 1308 system.
1305 1309 The main file you will modify to configure IPython's behavior is called
1306 1310
1307 1311 \family typewriter
1308 1312 ipythonrc
1309 1313 \family default
1310 1314 (with a
1311 1315 \family typewriter
1312 1316 .ini
1313 1317 \family default
1314 1318 extension under Windows), included for reference in Sec.
1315 1319
1316 1320 \begin_inset LatexCommand \ref{sec:ipytonrc-sample}
1317 1321
1318 1322 \end_inset
1319 1323
1320 1324 .
1321 1325 This file is very commented and has many variables you can change to suit
1322 1326 your taste, you can find more details in Sec.
1323 1327
1324 1328 \begin_inset LatexCommand \ref{sec:customization}
1325 1329
1326 1330 \end_inset
1327 1331
1328 1332 .
1329 1333 Here we discuss the basic things you will want to make sure things are
1330 1334 working properly from the beginning.
1331 1335 \layout Subsection
1332 1336
1333 1337
1334 1338 \begin_inset LatexCommand \label{sec:help-access}
1335 1339
1336 1340 \end_inset
1337 1341
1338 1342 Access to the Python help system
1339 1343 \layout Standard
1340 1344
1341 1345 This is true for Python in general (not just for IPython): you should have
1342 1346 an environment variable called
1343 1347 \family typewriter
1344 1348 PYTHONDOCS
1345 1349 \family default
1346 1350 pointing to the directory where your HTML Python documentation lives.
1347 1351 In my system it's
1348 1352 \family typewriter
1349 1353 /usr/share/doc/python-docs-2.3.4/html
1350 1354 \family default
1351 1355 , check your local details or ask your systems administrator.
1352 1356
1353 1357 \layout Standard
1354 1358
1355 1359 This is the directory which holds the HTML version of the Python manuals.
1356 1360 Unfortunately it seems that different Linux distributions package these
1357 1361 files differently, so you may have to look around a bit.
1358 1362 Below I show the contents of this directory on my system for reference:
1359 1363 \layout Standard
1360 1364
1361 1365
1362 1366 \family typewriter
1363 1367 [html]> ls
1364 1368 \newline
1365 1369 about.dat acks.html dist/ ext/ index.html lib/ modindex.html stdabout.dat tut/
1366 1370 about.html api/ doc/ icons/ inst/ mac/ ref/ style.css
1367 1371 \layout Standard
1368 1372
1369 1373 You should really make sure this variable is correctly set so that Python's
1370 1374 pydoc-based help system works.
1371 1375 It is a powerful and convenient system with full access to the Python manuals
1372 1376 and all modules accessible to you.
1373 1377 \layout Standard
1374 1378
1375 1379 Under Windows it seems that pydoc finds the documentation automatically,
1376 1380 so no extra setup appears necessary.
1377 1381 \layout Subsection
1378 1382
1379 1383 Editor
1380 1384 \layout Standard
1381 1385
1382 1386 The
1383 1387 \family typewriter
1384 1388 %edit
1385 1389 \family default
1386 1390 command (and its alias
1387 1391 \family typewriter
1388 1392 %ed
1389 1393 \family default
1390 1394 ) will invoke the editor set in your environment as
1391 1395 \family typewriter
1392 1396 EDITOR
1393 1397 \family default
1394 1398 .
1395 1399 If this variable is not set, it will default to
1396 1400 \family typewriter
1397 1401 vi
1398 1402 \family default
1399 1403 under Linux/Unix and to
1400 1404 \family typewriter
1401 1405 notepad
1402 1406 \family default
1403 1407 under Windows.
1404 1408 You may want to set this variable properly and to a lightweight editor
1405 1409 which doesn't take too long to start (that is, something other than a new
1406 1410 instance of
1407 1411 \family typewriter
1408 1412 Emacs
1409 1413 \family default
1410 1414 ).
1411 1415 This way you can edit multi-line code quickly and with the power of a real
1412 1416 editor right inside IPython.
1413 1417
1414 1418 \layout Standard
1415 1419
1416 1420 If you are a dedicated
1417 1421 \family typewriter
1418 1422 Emacs
1419 1423 \family default
1420 1424 user, you should set up the
1421 1425 \family typewriter
1422 1426 Emacs
1423 1427 \family default
1424 1428 server so that new requests are handled by the original process.
1425 1429 This means that almost no time is spent in handling the request (assuming
1426 1430 an
1427 1431 \family typewriter
1428 1432 Emacs
1429 1433 \family default
1430 1434 process is already running).
1431 1435 For this to work, you need to set your
1432 1436 \family typewriter
1433 1437 EDITOR
1434 1438 \family default
1435 1439 environment variable to
1436 1440 \family typewriter
1437 1441 'emacsclient'
1438 1442 \family default
1439 1443 .
1440 1444
1441 1445 \family typewriter
1442 1446
1443 1447 \family default
1444 1448 The code below, supplied by Francois Pinard, can then be used in your
1445 1449 \family typewriter
1446 1450 .emacs
1447 1451 \family default
1448 1452 file to enable the server:
1449 1453 \layout Standard
1450 1454
1451 1455
1452 1456 \family typewriter
1453 1457 (defvar server-buffer-clients)
1454 1458 \newline
1455 1459 (when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm))
1456 1460 \newline
1457 1461
1458 1462 \begin_inset ERT
1459 1463 status Collapsed
1460 1464
1461 1465 \layout Standard
1462 1466
1463 1467 \backslash
1464 1468 hspace*{0mm}
1465 1469 \end_inset
1466 1470
1467 1471 \SpecialChar ~
1468 1472 \SpecialChar ~
1469 1473 (server-start)
1470 1474 \newline
1471 1475
1472 1476 \begin_inset ERT
1473 1477 status Collapsed
1474 1478
1475 1479 \layout Standard
1476 1480
1477 1481 \backslash
1478 1482 hspace*{0mm}
1479 1483 \end_inset
1480 1484
1481 1485 \SpecialChar ~
1482 1486 \SpecialChar ~
1483 1487 (defun fp-kill-server-with-buffer-routine ()
1484 1488 \newline
1485 1489
1486 1490 \begin_inset ERT
1487 1491 status Collapsed
1488 1492
1489 1493 \layout Standard
1490 1494
1491 1495 \backslash
1492 1496 hspace*{0mm}
1493 1497 \end_inset
1494 1498
1495 1499 \SpecialChar ~
1496 1500 \SpecialChar ~
1497 1501 \SpecialChar ~
1498 1502 \SpecialChar ~
1499 1503 (and server-buffer-clients (server-done)))
1500 1504 \newline
1501 1505
1502 1506 \begin_inset ERT
1503 1507 status Collapsed
1504 1508
1505 1509 \layout Standard
1506 1510
1507 1511 \backslash
1508 1512 hspace*{0mm}
1509 1513 \end_inset
1510 1514
1511 1515 \SpecialChar ~
1512 1516 \SpecialChar ~
1513 1517 (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
1514 1518 \layout Standard
1515 1519
1516 1520 You can also set the value of this editor via the commmand-line option '-
1517 1521 \family typewriter
1518 1522 editor'
1519 1523 \family default
1520 1524 or in your
1521 1525 \family typewriter
1522 1526 ipythonrc
1523 1527 \family default
1524 1528 file.
1525 1529 This is useful if you wish to use specifically for IPython an editor different
1526 1530 from your typical default (and for Windows users who tend to use fewer
1527 1531 environment variables).
1528 1532 \layout Subsection
1529 1533
1530 1534 Color
1531 1535 \layout Standard
1532 1536
1533 1537 The default IPython configuration has most bells and whistles turned on
1534 1538 (they're pretty safe).
1535 1539 But there's one that
1536 1540 \emph on
1537 1541 may
1538 1542 \emph default
1539 1543 cause problems on some systems: the use of color on screen for displaying
1540 1544 information.
1541 1545 This is very useful, since IPython can show prompts and exception tracebacks
1542 1546 with various colors, display syntax-highlighted source code, and in general
1543 1547 make it easier to visually parse information.
1544 1548 \layout Standard
1545 1549
1546 1550 The following terminals seem to handle the color sequences fine:
1547 1551 \layout Itemize
1548 1552
1549 1553 Linux main text console, KDE Konsole, Gnome Terminal, E-term, rxvt, xterm.
1550 1554 \layout Itemize
1551 1555
1552 1556 CDE terminal (tested under Solaris).
1553 1557 This one boldfaces light colors.
1554 1558 \layout Itemize
1555 1559
1556 1560 (X)Emacs buffers.
1557 1561 See sec.
1558 1562 \begin_inset LatexCommand \ref{sec:emacs}
1559 1563
1560 1564 \end_inset
1561 1565
1562 1566 for more details on using IPython with (X)Emacs.
1563 1567 \layout Itemize
1564 1568
1565 1569 A Windows (XP/2k) command prompt
1566 1570 \emph on
1567 1571 with Gary Bishop's support extensions
1568 1572 \emph default
1569 1573 .
1570 1574 Gary's extensions are discussed in Sec.\SpecialChar ~
1571 1575
1572 1576 \begin_inset LatexCommand \ref{sub:Under-Windows}
1573 1577
1574 1578 \end_inset
1575 1579
1576 1580 .
1577 1581 \layout Itemize
1578 1582
1579 1583 A Windows (XP/2k) CygWin shell.
1580 1584 Although some users have reported problems; it is not clear whether there
1581 1585 is an issue for everyone or only under specific configurations.
1582 1586 If you have full color support under cygwin, please post to the IPython
1583 1587 mailing list so this issue can be resolved for all users.
1584 1588 \layout Standard
1585 1589
1586 1590 These have shown problems:
1587 1591 \layout Itemize
1588 1592
1589 1593 Windows command prompt in WinXP/2k logged into a Linux machine via telnet
1590 1594 or ssh.
1591 1595 \layout Itemize
1592 1596
1593 1597 Windows native command prompt in WinXP/2k,
1594 1598 \emph on
1595 1599 without
1596 1600 \emph default
1597 1601 Gary Bishop's extensions.
1598 1602 Once Gary's readline library is installed, the normal WinXP/2k command
1599 1603 prompt works perfectly.
1600 1604 \layout Standard
1601 1605
1602 1606 Currently the following color schemes are available:
1603 1607 \layout Itemize
1604 1608
1605 1609
1606 1610 \family typewriter
1607 1611 NoColor
1608 1612 \family default
1609 1613 : uses no color escapes at all (all escapes are empty
1610 1614 \begin_inset Quotes eld
1611 1615 \end_inset
1612 1616
1613 1617
1614 1618 \begin_inset Quotes eld
1615 1619 \end_inset
1616 1620
1617 1621 strings).
1618 1622 This 'scheme' is thus fully safe to use in any terminal.
1619 1623 \layout Itemize
1620 1624
1621 1625
1622 1626 \family typewriter
1623 1627 Linux
1624 1628 \family default
1625 1629 : works well in Linux console type environments: dark background with light
1626 1630 fonts.
1627 1631 It uses bright colors for information, so it is difficult to read if you
1628 1632 have a light colored background.
1629 1633 \layout Itemize
1630 1634
1631 1635
1632 1636 \family typewriter
1633 1637 LightBG
1634 1638 \family default
1635 1639 : the basic colors are similar to those in the
1636 1640 \family typewriter
1637 1641 Linux
1638 1642 \family default
1639 1643 scheme but darker.
1640 1644 It is easy to read in terminals with light backgrounds.
1641 1645 \layout Standard
1642 1646
1643 1647 IPython uses colors for two main groups of things: prompts and tracebacks
1644 1648 which are directly printed to the terminal, and the object introspection
1645 1649 system which passes large sets of data through a pager.
1646 1650 \layout Subsubsection
1647 1651
1648 1652 Input/Output prompts and exception tracebacks
1649 1653 \layout Standard
1650 1654
1651 1655 You can test whether the colored prompts and tracebacks work on your system
1652 1656 interactively by typing
1653 1657 \family typewriter
1654 1658 '%colors Linux'
1655 1659 \family default
1656 1660 at the prompt (use '
1657 1661 \family typewriter
1658 1662 %colors LightBG'
1659 1663 \family default
1660 1664 if your terminal has a light background).
1661 1665 If the input prompt shows garbage like:
1662 1666 \newline
1663 1667
1664 1668 \family typewriter
1665 1669 [0;32mIn [[1;32m1[0;32m]: [0;00m
1666 1670 \family default
1667 1671
1668 1672 \newline
1669 1673 instead of (in color) something like:
1670 1674 \newline
1671 1675
1672 1676 \family typewriter
1673 1677 In [1]:
1674 1678 \family default
1675 1679
1676 1680 \newline
1677 1681 this means that your terminal doesn't properly handle color escape sequences.
1678 1682 You can go to a 'no color' mode by typing '
1679 1683 \family typewriter
1680 1684 %colors NoColor
1681 1685 \family default
1682 1686 '.
1683 1687
1684 1688 \layout Standard
1685 1689
1686 1690 You can try using a different terminal emulator program (Emacs users, see
1687 1691 below).
1688 1692 To permanently set your color preferences, edit the file
1689 1693 \family typewriter
1690 1694 $HOME/.ipython/ipythonrc
1691 1695 \family default
1692 1696 and set the
1693 1697 \family typewriter
1694 1698 colors
1695 1699 \family default
1696 1700 option to the desired value.
1697 1701 \layout Subsubsection
1698 1702
1699 1703 Object details (types, docstrings, source code, etc.)
1700 1704 \layout Standard
1701 1705
1702 1706 IPython has a set of special functions for studying the objects you are
1703 1707 working with, discussed in detail in Sec.
1704 1708
1705 1709 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1706 1710
1707 1711 \end_inset
1708 1712
1709 1713 .
1710 1714 But this system relies on passing information which is longer than your
1711 1715 screen through a data pager, such as the common Unix
1712 1716 \family typewriter
1713 1717 less
1714 1718 \family default
1715 1719 and
1716 1720 \family typewriter
1717 1721 more
1718 1722 \family default
1719 1723 programs.
1720 1724 In order to be able to see this information in color, your pager needs
1721 1725 to be properly configured.
1722 1726 I strongly recommend using
1723 1727 \family typewriter
1724 1728 less
1725 1729 \family default
1726 1730 instead of
1727 1731 \family typewriter
1728 1732 more
1729 1733 \family default
1730 1734 , as it seems that
1731 1735 \family typewriter
1732 1736 more
1733 1737 \family default
1734 1738 simply can not understand colored text correctly.
1735 1739 \layout Standard
1736 1740
1737 1741 In order to configure
1738 1742 \family typewriter
1739 1743 less
1740 1744 \family default
1741 1745 as your default pager, do the following:
1742 1746 \layout Enumerate
1743 1747
1744 1748 Set the environment
1745 1749 \family typewriter
1746 1750 PAGER
1747 1751 \family default
1748 1752 variable to
1749 1753 \family typewriter
1750 1754 less
1751 1755 \family default
1752 1756 .
1753 1757 \layout Enumerate
1754 1758
1755 1759 Set the environment
1756 1760 \family typewriter
1757 1761 LESS
1758 1762 \family default
1759 1763 variable to
1760 1764 \family typewriter
1761 1765 -r
1762 1766 \family default
1763 1767 (plus any other options you always want to pass to
1764 1768 \family typewriter
1765 1769 less
1766 1770 \family default
1767 1771 by default).
1768 1772 This tells
1769 1773 \family typewriter
1770 1774 less
1771 1775 \family default
1772 1776 to properly interpret control sequences, which is how color information
1773 1777 is given to your terminal.
1774 1778 \layout Standard
1775 1779
1776 1780 For the
1777 1781 \family typewriter
1778 1782 csh
1779 1783 \family default
1780 1784 or
1781 1785 \family typewriter
1782 1786 tcsh
1783 1787 \family default
1784 1788 shells, add to your
1785 1789 \family typewriter
1786 1790 ~/.cshrc
1787 1791 \family default
1788 1792 file the lines:
1789 1793 \layout Standard
1790 1794
1791 1795
1792 1796 \family typewriter
1793 1797 setenv PAGER less
1794 1798 \newline
1795 1799 setenv LESS -r
1796 1800 \layout Standard
1797 1801
1798 1802 There is similar syntax for other Unix shells, look at your system documentation
1799 1803 for details.
1800 1804 \layout Standard
1801 1805
1802 1806 If you are on a system which lacks proper data pagers (such as Windows),
1803 1807 IPython will use a very limited builtin pager.
1804 1808 \layout Subsection
1805 1809
1806 1810
1807 1811 \begin_inset LatexCommand \label{sec:emacs}
1808 1812
1809 1813 \end_inset
1810 1814
1811 1815 (X)Emacs configuration
1812 1816 \layout Standard
1813 1817
1814 1818 Thanks to the work of Alexander Schmolck and Prabhu Ramachandran, currently
1815 1819 (X)Emacs and IPython get along very well.
1816 1820
1817 1821 \layout Standard
1818 1822
1819 1823
1820 1824 \series bold
1821 1825 Important note:
1822 1826 \series default
1823 1827 You will need to use a recent enough version of
1824 1828 \family typewriter
1825 1829 python-mode.el
1826 1830 \family default
1827 1831 , along with the file
1828 1832 \family typewriter
1829 1833 ipython.el
1830 1834 \family default
1831 1835 .
1832 1836 You can check that the version you have of
1833 1837 \family typewriter
1834 1838 python-mode.el
1835 1839 \family default
1836 1840 is new enough by either looking at the revision number in the file itself,
1837 1841 or asking for it in (X)Emacs via
1838 1842 \family typewriter
1839 1843 M-x py-version
1840 1844 \family default
1841 1845 .
1842 1846 Versions 4.68 and newer contain the necessary fixes for proper IPython support.
1843 1847 \layout Standard
1844 1848
1845 1849 The file
1846 1850 \family typewriter
1847 1851 ipython.el
1848 1852 \family default
1849 1853 is included with the IPython distribution, in the documentation directory
1850 1854 (where this manual resides in PDF and HTML formats).
1851 1855 \layout Standard
1852 1856
1853 1857 Once you put these files in your Emacs path, all you need in your
1854 1858 \family typewriter
1855 1859 .emacs
1856 1860 \family default
1857 1861 file is:
1858 1862 \layout LyX-Code
1859 1863
1860 1864 (require 'ipython)
1861 1865 \layout Standard
1862 1866
1863 1867 This should give you full support for executing code snippets via IPython,
1864 1868 opening IPython as your Python shell via
1865 1869 \family typewriter
1866 1870 C-c\SpecialChar ~
1867 1871 !
1868 1872 \family default
1869 1873 , etc.
1870 1874
1871 1875 \layout Standard
1872 1876
1873 1877 If you happen to get garbage instead of colored prompts as described in
1874 1878 the previous section, you may need to set also in your
1875 1879 \family typewriter
1876 1880 .emacs
1877 1881 \family default
1878 1882 file:
1879 1883 \layout LyX-Code
1880 1884
1881 1885 (setq ansi-color-for-comint-mode t)
1882 1886 \layout Subsubsection*
1883 1887
1884 1888 Notes
1885 1889 \layout Itemize
1886 1890
1887 1891 There is one caveat you should be aware of: you must start the IPython shell
1888 1892
1889 1893 \emph on
1890 1894 before
1891 1895 \emph default
1892 1896 attempting to execute any code regions via
1893 1897 \family typewriter
1894 1898 C-c\SpecialChar ~
1895 1899 |
1896 1900 \family default
1897 1901 .
1898 1902 Simply type
1899 1903 \family typewriter
1900 1904 C-c\SpecialChar ~
1901 1905 !
1902 1906 \family default
1903 1907 to start IPython before passing any code regions to the interpreter, and
1904 1908 you shouldn't experience any problems.
1905 1909 \newline
1906 1910 This is due to a bug in Python itself, which has been fixed for Python 2.3,
1907 1911 but exists as of Python 2.2.2 (reported as SF bug [ 737947 ]).
1908 1912 \layout Itemize
1909 1913
1910 1914 The (X)Emacs support is maintained by Alexander Schmolck, so all comments/reques
1911 1915 ts should be directed to him through the IPython mailing lists.
1912 1916
1913 1917 \layout Itemize
1914 1918
1915 1919 This code is still somewhat experimental so it's a bit rough around the
1916 1920 edges (although in practice, it works quite well).
1917 1921 \layout Itemize
1918 1922
1919 1923 Be aware that if you customize
1920 1924 \family typewriter
1921 1925 py-python-command
1922 1926 \family default
1923 1927 previously, this value will override what
1924 1928 \family typewriter
1925 1929 ipython.el
1926 1930 \family default
1927 1931 does (because loading the customization variables comes later).
1928 1932 \layout Section
1929 1933
1930 1934
1931 1935 \begin_inset LatexCommand \label{sec:quick_tips}
1932 1936
1933 1937 \end_inset
1934 1938
1935 1939 Quick tips
1936 1940 \layout Standard
1937 1941
1938 1942 IPython can be used as an improved replacement for the Python prompt, and
1939 1943 for that you don't really need to read any more of this manual.
1940 1944 But in this section we'll try to summarize a few tips on how to make the
1941 1945 most effective use of it for everyday Python development, highlighting
1942 1946 things you might miss in the rest of the manual (which is getting long).
1943 1947 We'll give references to parts in the manual which provide more detail
1944 1948 when appropriate.
1945 1949 \layout Standard
1946 1950
1947 1951 The following article by Jeremy Jones provides an introductory tutorial
1948 1952 about IPython:
1949 1953 \newline
1950 1954
1951 1955 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2005/01/27/ipython.html}
1952 1956
1953 1957 \end_inset
1954 1958
1955 1959
1956 1960 \layout Itemize
1957 1961
1958 1962 The TAB key.
1959 1963 TAB-completion, especially for attributes, is a convenient way to explore
1960 1964 the structure of any object you're dealing with.
1961 1965 Simply type
1962 1966 \family typewriter
1963 1967 object_name.<TAB>
1964 1968 \family default
1965 1969 and a list of the object's attributes will be printed (see sec.
1966 1970
1967 1971 \begin_inset LatexCommand \ref{sec:readline}
1968 1972
1969 1973 \end_inset
1970 1974
1971 1975 for more).
1972 1976 Tab completion also works on file and directory names, which combined with
1973 1977 IPython's alias system allows you to do from within IPython many of the
1974 1978 things you normally would need the system shell for.
1975 1979
1976 1980 \layout Itemize
1977 1981
1978 1982 Explore your objects.
1979 1983 Typing
1980 1984 \family typewriter
1981 1985 object_name?
1982 1986 \family default
1983 1987 will print all sorts of details about any object, including docstrings,
1984 1988 function definition lines (for call arguments) and constructor details
1985 1989 for classes.
1986 1990 The magic commands
1987 1991 \family typewriter
1988 1992 %pdoc
1989 1993 \family default
1990 1994 ,
1991 1995 \family typewriter
1992 1996 %pdef
1993 1997 \family default
1994 1998 ,
1995 1999 \family typewriter
1996 2000 %psource
1997 2001 \family default
1998 2002 and
1999 2003 \family typewriter
2000 2004 %pfile
2001 2005 \family default
2002 2006 will respectively print the docstring, function definition line, full source
2003 2007 code and the complete file for any object (when they can be found).
2004 2008 If automagic is on (it is by default), you don't need to type the '
2005 2009 \family typewriter
2006 2010 %
2007 2011 \family default
2008 2012 ' explicitly.
2009 2013 See sec.
2010 2014
2011 2015 \begin_inset LatexCommand \ref{sec:dyn-object-info}
2012 2016
2013 2017 \end_inset
2014 2018
2015 2019 for more.
2016 2020 \layout Itemize
2017 2021
2018 2022 The
2019 2023 \family typewriter
2020 2024 %run
2021 2025 \family default
2022 2026 magic command allows you to run any python script and load all of its data
2023 2027 directly into the interactive namespace.
2024 2028 Since the file is re-read from disk each time, changes you make to it are
2025 2029 reflected immediately (in contrast to the behavior of
2026 2030 \family typewriter
2027 2031 import
2028 2032 \family default
2029 2033 ).
2030 2034 I rarely use
2031 2035 \family typewriter
2032 2036 import
2033 2037 \family default
2034 2038 for code I am testing, relying on
2035 2039 \family typewriter
2036 2040 %run
2037 2041 \family default
2038 2042 instead.
2039 2043 See sec.
2040 2044
2041 2045 \begin_inset LatexCommand \ref{sec:magic}
2042 2046
2043 2047 \end_inset
2044 2048
2045 2049 for more on this and other magic commands, or type the name of any magic
2046 2050 command and ? to get details on it.
2047 2051 See also sec.
2048 2052
2049 2053 \begin_inset LatexCommand \ref{sec:dreload}
2050 2054
2051 2055 \end_inset
2052 2056
2053 2057 for a recursive reload command.
2054 2058 \newline
2055 2059
2056 2060 \family typewriter
2057 2061 %run
2058 2062 \family default
2059 2063 also has special flags for timing the execution of your scripts (
2060 2064 \family typewriter
2061 2065 -t
2062 2066 \family default
2063 2067 ) and for executing them under the control of either Python's
2064 2068 \family typewriter
2065 2069 pdb
2066 2070 \family default
2067 2071 debugger (
2068 2072 \family typewriter
2069 2073 -d
2070 2074 \family default
2071 2075 ) or profiler (
2072 2076 \family typewriter
2073 2077 -p
2074 2078 \family default
2075 2079 ).
2076 2080 With all of these,
2077 2081 \family typewriter
2078 2082 %run
2079 2083 \family default
2080 2084 can be used as the main tool for efficient interactive development of code
2081 2085 which you write in your editor of choice.
2082 2086 \layout Itemize
2083 2087
2084 2088 Use the Python debugger,
2085 2089 \family typewriter
2086 2090 pdb
2087 2091 \family default
2088 2092
2089 2093 \begin_inset Foot
2090 2094 collapsed true
2091 2095
2092 2096 \layout Standard
2093 2097
2094 2098 Thanks to Christian Hart and Matthew Arnison for the suggestions leading
2095 2099 to IPython's improved debugger and profiler support.
2096 2100 \end_inset
2097 2101
2098 2102 .
2099 2103 The
2100 2104 \family typewriter
2101 2105 %pdb
2102 2106 \family default
2103 2107 command allows you to toggle on and off the automatic invocation of an
2104 2108 IPython-enhanced
2105 2109 \family typewriter
2106 2110 pdb
2107 2111 \family default
2108 2112 debugger (with coloring, tab completion and more) at any uncaught exception.
2109 2113 The advantage of this is that
2110 2114 \family typewriter
2111 2115 pdb
2112 2116 \family default
2113 2117 starts
2114 2118 \emph on
2115 2119 inside
2116 2120 \emph default
2117 2121 the function where the exception occurred, with all data still available.
2118 2122 You can print variables, see code, execute statements and even walk up
2119 2123 and down the call stack to track down the true source of the problem (which
2120 2124 often is many layers in the stack above where the exception gets triggered).
2121 2125 \newline
2122 2126 Running programs with
2123 2127 \family typewriter
2124 2128 %run
2125 2129 \family default
2126 2130 and pdb active can be an efficient to develop and debug code, in many cases
2127 2131 eliminating the need for
2128 2132 \family typewriter
2129 2133 print
2130 2134 \family default
2131 2135 statements or external debugging tools.
2132 2136 I often simply put a
2133 2137 \family typewriter
2134 2138 1/0
2135 2139 \family default
2136 2140 in a place where I want to take a look so that pdb gets called, quickly
2137 2141 view whatever variables I need to or test various pieces of code and then
2138 2142 remove the
2139 2143 \family typewriter
2140 2144 1/0
2141 2145 \family default
2142 2146 .
2143 2147 \newline
2144 2148 Note also that `
2145 2149 \family typewriter
2146 2150 %run -d
2147 2151 \family default
2148 2152 ' activates
2149 2153 \family typewriter
2150 2154 pdb
2151 2155 \family default
2152 2156 and automatically sets initial breakpoints for you to step through your
2153 2157 code, watch variables, etc.
2154 2158 See Sec.\SpecialChar ~
2155 2159
2156 2160 \begin_inset LatexCommand \ref{sec:cache_output}
2157 2161
2158 2162 \end_inset
2159 2163
2160 2164 for details.
2161 2165 \layout Itemize
2162 2166
2163 2167 Use the output cache.
2164 2168 All output results are automatically stored in a global dictionary named
2165 2169
2166 2170 \family typewriter
2167 2171 Out
2168 2172 \family default
2169 2173 and variables named
2170 2174 \family typewriter
2171 2175 _1
2172 2176 \family default
2173 2177 ,
2174 2178 \family typewriter
2175 2179 _2
2176 2180 \family default
2177 2181 , etc.
2178 2182 alias them.
2179 2183 For example, the result of input line 4 is available either as
2180 2184 \family typewriter
2181 2185 Out[4]
2182 2186 \family default
2183 2187 or as
2184 2188 \family typewriter
2185 2189 _4
2186 2190 \family default
2187 2191 .
2188 2192 Additionally, three variables named
2189 2193 \family typewriter
2190 2194 _
2191 2195 \family default
2192 2196 ,
2193 2197 \family typewriter
2194 2198 __
2195 2199 \family default
2196 2200 and
2197 2201 \family typewriter
2198 2202 ___
2199 2203 \family default
2200 2204 are always kept updated with the for the last three results.
2201 2205 This allows you to recall any previous result and further use it for new
2202 2206 calculations.
2203 2207 See Sec.\SpecialChar ~
2204 2208
2205 2209 \begin_inset LatexCommand \ref{sec:cache_output}
2206 2210
2207 2211 \end_inset
2208 2212
2209 2213 for more.
2210 2214 \layout Itemize
2211 2215
2212 2216 Put a '
2213 2217 \family typewriter
2214 2218 ;
2215 2219 \family default
2216 2220 ' at the end of a line to supress the printing of output.
2217 2221 This is useful when doing calculations which generate long output you are
2218 2222 not interested in seeing.
2219 2223 The
2220 2224 \family typewriter
2221 2225 _*
2222 2226 \family default
2223 2227 variables and the
2224 2228 \family typewriter
2225 2229 Out[]
2226 2230 \family default
2227 2231 list do get updated with the contents of the output, even if it is not
2228 2232 printed.
2229 2233 You can thus still access the generated results this way for further processing.
2230 2234 \layout Itemize
2231 2235
2232 2236 A similar system exists for caching input.
2233 2237 All input is stored in a global list called
2234 2238 \family typewriter
2235 2239 In
2236 2240 \family default
2237 2241 , so you can re-execute lines 22 through 28 plus line 34 by typing
2238 2242 \family typewriter
2239 2243 'exec In[22:29]+In[34]'
2240 2244 \family default
2241 2245 (using Python slicing notation).
2242 2246 If you need to execute the same set of lines often, you can assign them
2243 2247 to a macro with the
2244 2248 \family typewriter
2245 2249 %macro
2246 2250 \family default
2247 2251
2248 2252 \family typewriter
2249 2253 function.
2250 2254
2251 2255 \family default
2252 2256 See sec.
2253 2257
2254 2258 \begin_inset LatexCommand \ref{sec:cache_input}
2255 2259
2256 2260 \end_inset
2257 2261
2258 2262 for more.
2259 2263 \layout Itemize
2260 2264
2261 2265 Use your input history.
2262 2266 The
2263 2267 \family typewriter
2264 2268 %hist
2265 2269 \family default
2266 2270 command can show you all previous input, without line numbers if desired
2267 2271 (option
2268 2272 \family typewriter
2269 2273 -n
2270 2274 \family default
2271 2275 ) so you can directly copy and paste code either back in IPython or in a
2272 2276 text editor.
2273 2277 You can also save all your history by turning on logging via
2274 2278 \family typewriter
2275 2279 %logstart
2276 2280 \family default
2277 2281 ; these logs can later be either reloaded as IPython sessions or used as
2278 2282 code for your programs.
2279 2283 \layout Itemize
2280 2284
2281 2285 Define your own system aliases.
2282 2286 Even though IPython gives you access to your system shell via the
2283 2287 \family typewriter
2284 2288 !
2285 2289 \family default
2286 2290 prefix, it is convenient to have aliases to the system commands you use
2287 2291 most often.
2288 2292 This allows you to work seamlessly from inside IPython with the same commands
2289 2293 you are used to in your system shell.
2290 2294 \newline
2291 2295 IPython comes with some pre-defined aliases and a complete system for changing
2292 2296 directories, both via a stack (see
2293 2297 \family typewriter
2294 2298 %pushd
2295 2299 \family default
2296 2300 ,
2297 2301 \family typewriter
2298 2302 %popd
2299 2303 \family default
2300 2304 and
2301 2305 \family typewriter
2302 2306 %dhist
2303 2307 \family default
2304 2308 ) and via direct
2305 2309 \family typewriter
2306 2310 %cd
2307 2311 \family default
2308 2312 .
2309 2313 The latter keeps a history of visited directories and allows you to go
2310 2314 to any previously visited one.
2311 2315 \layout Itemize
2312 2316
2313 2317 Use Python to manipulate the results of system commands.
2314 2318 The `
2315 2319 \family typewriter
2316 2320 !!
2317 2321 \family default
2318 2322 ' special syntax, and the
2319 2323 \family typewriter
2320 2324 %sc
2321 2325 \family default
2322 2326 and
2323 2327 \family typewriter
2324 2328 %sx
2325 2329 \family default
2326 2330 magic commands allow you to capture system output into Python variables.
2327 2331 \layout Itemize
2328 2332
2329 2333 Expand python variables when calling the shell (either via
2330 2334 \family typewriter
2331 2335 `!'
2332 2336 \family default
2333 2337 and
2334 2338 \family typewriter
2335 2339 `!!'
2336 2340 \family default
2337 2341 or via aliases) by prepending a
2338 2342 \family typewriter
2339 2343 $
2340 2344 \family default
2341 2345 in front of them.
2342 2346 You can also expand complete python expressions.
2343 2347 See sec.\SpecialChar ~
2344 2348
2345 2349 \begin_inset LatexCommand \ref{sub:System-shell-access}
2346 2350
2347 2351 \end_inset
2348 2352
2349 2353 for more.
2350 2354 \layout Itemize
2351 2355
2352 2356 Use profiles to maintain different configurations (modules to load, function
2353 2357 definitions, option settings) for particular tasks.
2354 2358 You can then have customized versions of IPython for specific purposes.
2355 2359 See sec.\SpecialChar ~
2356 2360
2357 2361 \begin_inset LatexCommand \ref{sec:profiles}
2358 2362
2359 2363 \end_inset
2360 2364
2361 2365 for more.
2362 2366 \layout Itemize
2363 2367
2364 2368 Embed IPython in your programs.
2365 2369 A few lines of code are enough to load a complete IPython inside your own
2366 2370 programs, giving you the ability to work with your data interactively after
2367 2371 automatic processing has been completed.
2368 2372 See sec.\SpecialChar ~
2369 2373
2370 2374 \begin_inset LatexCommand \ref{sec:embed}
2371 2375
2372 2376 \end_inset
2373 2377
2374 2378 for more.
2375 2379 \layout Itemize
2376 2380
2377 2381 Use the Python profiler.
2378 2382 When dealing with performance issues, the
2379 2383 \family typewriter
2380 2384 %run
2381 2385 \family default
2382 2386 command with a
2383 2387 \family typewriter
2384 2388 -p
2385 2389 \family default
2386 2390 option allows you to run complete programs under the control of the Python
2387 2391 profiler.
2388 2392 The
2389 2393 \family typewriter
2390 2394 %prun
2391 2395 \family default
2392 2396 command does a similar job for single Python expressions (like function
2393 2397 calls).
2394 2398 \layout Itemize
2395 2399
2396 2400 Use the IPython.demo.Demo class to load any Python script as an interactive
2397 2401 demo.
2398 2402 With a minimal amount of simple markup, you can control the execution of
2399 2403 the script, stopping as needed.
2400 2404 See sec.\SpecialChar ~
2401 2405
2402 2406 \begin_inset LatexCommand \ref{sec:interactive-demos}
2403 2407
2404 2408 \end_inset
2405 2409
2406 2410 for more.
2407 2411 \layout Subsection
2408 2412
2409 2413 Source code handling tips
2410 2414 \layout Standard
2411 2415
2412 2416 IPython is a line-oriented program, without full control of the terminal.
2413 2417 Therefore, it doesn't support true multiline editing.
2414 2418 However, it has a number of useful tools to help you in dealing effectively
2415 2419 with more complex editing.
2416 2420 \layout Standard
2417 2421
2418 2422 The
2419 2423 \family typewriter
2420 2424 %edit
2421 2425 \family default
2422 2426 command gives a reasonable approximation of multiline editing, by invoking
2423 2427 your favorite editor on the spot.
2424 2428 IPython will execute the code you type in there as if it were typed interactive
2425 2429 ly.
2426 2430 Type
2427 2431 \family typewriter
2428 2432 %edit?
2429 2433 \family default
2430 2434 for the full details on the edit command.
2431 2435 \layout Standard
2432 2436
2433 2437 If you have typed various commands during a session, which you'd like to
2434 2438 reuse, IPython provides you with a number of tools.
2435 2439 Start by using
2436 2440 \family typewriter
2437 2441 %hist
2438 2442 \family default
2439 2443 to see your input history, so you can see the line numbers of all input.
2440 2444 Let us say that you'd like to reuse lines 10 through 20, plus lines 24
2441 2445 and 28.
2442 2446 All the commands below can operate on these with the syntax
2443 2447 \layout LyX-Code
2444 2448
2445 2449 %command 10-20 24 28
2446 2450 \layout Standard
2447 2451
2448 2452 where the command given can be:
2449 2453 \layout Itemize
2450 2454
2451 2455
2452 2456 \family typewriter
2453 2457 %macro <macroname>
2454 2458 \family default
2455 2459 : this stores the lines into a variable which, when called at the prompt,
2456 2460 re-executes the input.
2457 2461 Macros can be edited later using
2458 2462 \family typewriter
2459 2463 `%edit macroname
2460 2464 \family default
2461 2465 ', and they can be stored persistently across sessions with `
2462 2466 \family typewriter
2463 2467 %store macroname
2464 2468 \family default
2465 2469 ' (the storage system is per-profile).
2466 2470 The combination of quick macros, persistent storage and editing, allows
2467 2471 you to easily refine quick-and-dirty interactive input into permanent utilities
2468 2472 , always available both in IPython and as files for general reuse.
2469 2473 \layout Itemize
2470 2474
2471 2475
2472 2476 \family typewriter
2473 2477 %edit
2474 2478 \family default
2475 2479 : this will open a text editor with those lines pre-loaded for further modificat
2476 2480 ion.
2477 2481 It will then execute the resulting file's contents as if you had typed
2478 2482 it at the prompt.
2479 2483 \layout Itemize
2480 2484
2481 2485
2482 2486 \family typewriter
2483 2487 %save <filename>
2484 2488 \family default
2485 2489 : this saves the lines directly to a named file on disk.
2486 2490 \layout Standard
2487 2491
2488 2492 While
2489 2493 \family typewriter
2490 2494 %macro
2491 2495 \family default
2492 2496 saves input lines into memory for interactive re-execution, sometimes you'd
2493 2497 like to save your input directly to a file.
2494 2498 The
2495 2499 \family typewriter
2496 2500 %save
2497 2501 \family default
2498 2502 magic does this: its input sytnax is the same as
2499 2503 \family typewriter
2500 2504 %macro
2501 2505 \family default
2502 2506 , but it saves your input directly to a Python file.
2503 2507 Note that the
2504 2508 \family typewriter
2505 2509 %logstart
2506 2510 \family default
2507 2511 command also saves input, but it logs
2508 2512 \emph on
2509 2513 all
2510 2514 \emph default
2511 2515 input to disk (though you can temporarily suspend it and reactivate it
2512 2516 with
2513 2517 \family typewriter
2514 2518 %logoff/%logon
2515 2519 \family default
2516 2520 );
2517 2521 \family typewriter
2518 2522 %save
2519 2523 \family default
2520 2524 allows you to select which lines of input you need to save.
2521 2525 \layout Subsubsection*
2522 2526
2523 2527 Lightweight 'version control'
2524 2528 \layout Standard
2525 2529
2526 2530 When you call
2527 2531 \family typewriter
2528 2532 %edit
2529 2533 \family default
2530 2534 with no arguments, IPython opens an empty editor with a temporary file,
2531 2535 and it returns the contents of your editing session as a string variable.
2532 2536 Thanks to IPython's output caching mechanism, this is automatically stored:
2533 2537 \layout LyX-Code
2534 2538
2535 2539 In [1]: %edit
2536 2540 \layout LyX-Code
2537 2541
2538 2542 IPython will make a temporary file named: /tmp/ipython_edit_yR-HCN.py
2539 2543 \layout LyX-Code
2540 2544
2541 2545 Editing...
2542 2546 done.
2543 2547 Executing edited code...
2544 2548 \layout LyX-Code
2545 2549
2546 2550 hello - this is a temporary file
2547 2551 \layout LyX-Code
2548 2552
2549 2553 Out[1]: "print 'hello - this is a temporary file'
2550 2554 \backslash
2551 2555 n"
2552 2556 \layout Standard
2553 2557
2554 2558 Now, if you call
2555 2559 \family typewriter
2556 2560 `%edit -p'
2557 2561 \family default
2558 2562 , IPython tries to open an editor with the same data as the last time you
2559 2563 used
2560 2564 \family typewriter
2561 2565 %edit
2562 2566 \family default
2563 2567 .
2564 2568 So if you haven't used
2565 2569 \family typewriter
2566 2570 %edit
2567 2571 \family default
2568 2572 in the meantime, this same contents will reopen; however, it will be done
2569 2573 in a
2570 2574 \emph on
2571 2575 new file
2572 2576 \emph default
2573 2577 .
2574 2578 This means that if you make changes and you later want to find an old version,
2575 2579 you can always retrieve it by using its output number, via
2576 2580 \family typewriter
2577 2581 `%edit _NN'
2578 2582 \family default
2579 2583 , where
2580 2584 \family typewriter
2581 2585 NN
2582 2586 \family default
2583 2587 is the number of the output prompt.
2584 2588 \layout Standard
2585 2589
2586 2590 Continuing with the example above, this should illustrate this idea:
2587 2591 \layout LyX-Code
2588 2592
2589 2593 In [2]: edit -p
2590 2594 \layout LyX-Code
2591 2595
2592 2596 IPython will make a temporary file named: /tmp/ipython_edit_nA09Qk.py
2593 2597 \layout LyX-Code
2594 2598
2595 2599 Editing...
2596 2600 done.
2597 2601 Executing edited code...
2598 2602 \layout LyX-Code
2599 2603
2600 2604 hello - now I made some changes
2601 2605 \layout LyX-Code
2602 2606
2603 2607 Out[2]: "print 'hello - now I made some changes'
2604 2608 \backslash
2605 2609 n"
2606 2610 \layout LyX-Code
2607 2611
2608 2612 In [3]: edit _1
2609 2613 \layout LyX-Code
2610 2614
2611 2615 IPython will make a temporary file named: /tmp/ipython_edit_gy6-zD.py
2612 2616 \layout LyX-Code
2613 2617
2614 2618 Editing...
2615 2619 done.
2616 2620 Executing edited code...
2617 2621 \layout LyX-Code
2618 2622
2619 2623 hello - this is a temporary file
2620 2624 \layout LyX-Code
2621 2625
2622 2626 IPython version control at work :)
2623 2627 \layout LyX-Code
2624 2628
2625 2629 Out[3]: "print 'hello - this is a temporary file'
2626 2630 \backslash
2627 2631 nprint 'IPython version control at work :)'
2628 2632 \backslash
2629 2633 n"
2630 2634 \layout Standard
2631 2635
2632 2636 This section was written after a contribution by Alexander Belchenko on
2633 2637 the IPython user list.
2634 2638 \layout LyX-Code
2635 2639
2636 2640 \layout Subsection
2637 2641
2638 2642 Effective logging
2639 2643 \layout Standard
2640 2644
2641 2645 A very useful suggestion sent in by Robert Kern follows:
2642 2646 \layout Standard
2643 2647
2644 2648 I recently happened on a nifty way to keep tidy per-project log files.
2645 2649 I made a profile for my project (which is called "parkfield").
2646 2650 \layout LyX-Code
2647 2651
2648 2652 include ipythonrc
2649 2653 \layout LyX-Code
2650 2654
2651 2655 # cancel earlier logfile invocation:
2652 2656 \layout LyX-Code
2653 2657
2654 2658 logfile ''
2655 2659 \layout LyX-Code
2656 2660
2657 2661 execute import time
2658 2662 \layout LyX-Code
2659 2663
2660 2664 execute __cmd = '/Users/kern/research/logfiles/parkfield-%s.log rotate'
2661 2665 \layout LyX-Code
2662 2666
2663 2667 execute __IP.magic_logstart(__cmd % time.strftime('%Y-%m-%d'))
2664 2668 \layout Standard
2665 2669
2666 2670 I also added a shell alias for convenience:
2667 2671 \layout LyX-Code
2668 2672
2669 2673 alias parkfield="ipython -pylab -profile parkfield"
2670 2674 \layout Standard
2671 2675
2672 2676 Now I have a nice little directory with everything I ever type in, organized
2673 2677 by project and date.
2674 2678 \layout Standard
2675 2679
2676 2680
2677 2681 \series bold
2678 2682 Contribute your own:
2679 2683 \series default
2680 2684 If you have your own favorite tip on using IPython efficiently for a certain
2681 2685 task (especially things which can't be done in the normal Python interpreter),
2682 2686 don't hesitate to send it!
2683 2687 \layout Section
2684 2688
2685 2689 Command-line use
2686 2690 \layout Standard
2687 2691
2688 2692 You start IPython with the command:
2689 2693 \layout Standard
2690 2694
2691 2695
2692 2696 \family typewriter
2693 2697 $ ipython [options] files
2694 2698 \layout Standard
2695 2699
2696 2700 If invoked with no options, it executes all the files listed in sequence
2697 2701 and drops you into the interpreter while still acknowledging any options
2698 2702 you may have set in your ipythonrc file.
2699 2703 This behavior is different from standard Python, which when called as
2700 2704 \family typewriter
2701 2705 python -i
2702 2706 \family default
2703 2707 will only execute one file and ignore your configuration setup.
2704 2708 \layout Standard
2705 2709
2706 2710 Please note that some of the configuration options are not available at
2707 2711 the command line, simply because they are not practical here.
2708 2712 Look into your ipythonrc configuration file for details on those.
2709 2713 This file typically installed in the
2710 2714 \family typewriter
2711 2715 $HOME/.ipython
2712 2716 \family default
2713 2717 directory.
2714 2718 For Windows users,
2715 2719 \family typewriter
2716 2720 $HOME
2717 2721 \family default
2718 2722 resolves to
2719 2723 \family typewriter
2720 2724 C:
2721 2725 \backslash
2722 2726
2723 2727 \backslash
2724 2728 Documents and Settings
2725 2729 \backslash
2726 2730
2727 2731 \backslash
2728 2732 YourUserName
2729 2733 \family default
2730 2734 in most instances.
2731 2735 In the rest of this text, we will refer to this directory as
2732 2736 \family typewriter
2733 2737 IPYTHONDIR
2734 2738 \family default
2735 2739 .
2736 2740 \layout Subsection
2737 2741
2738 2742
2739 2743 \begin_inset LatexCommand \label{sec:threading-opts}
2740 2744
2741 2745 \end_inset
2742 2746
2743 2747 Special Threading Options
2744 2748 \layout Standard
2745 2749
2746 2750 The following special options are ONLY valid at the beginning of the command
2747 2751 line, and not later.
2748 2752 This is because they control the initial- ization of ipython itself, before
2749 2753 the normal option-handling mechanism is active.
2750 2754 \layout List
2751 2755 \labelwidthstring 00.00.0000
2752 2756
2753 2757
2754 2758 \family typewriter
2755 2759 \series bold
2756 2760 -gthread,\SpecialChar ~
2757 2761 -qthread,\SpecialChar ~
2758 2762 -wthread,\SpecialChar ~
2759 2763 -pylab:
2760 2764 \family default
2761 2765 \series default
2762 2766 Only
2763 2767 \emph on
2764 2768 one
2765 2769 \emph default
2766 2770 of these can be given, and it can only be given as the first option passed
2767 2771 to IPython (it will have no effect in any other position).
2768 2772 They provide threading support for the GTK Qt and WXPython toolkits, and
2769 2773 for the matplotlib library.
2770 2774 \layout List
2771 2775 \labelwidthstring 00.00.0000
2772 2776
2773 2777 \SpecialChar ~
2774 2778 With any of the first three options, IPython starts running a separate
2775 2779 thread for the graphical toolkit's operation, so that you can open and
2776 2780 control graphical elements from within an IPython command line, without
2777 2781 blocking.
2778 2782 All three provide essentially the same functionality, respectively for
2779 2783 GTK, QT and WXWidgets (via their Python interfaces).
2780 2784 \layout List
2781 2785 \labelwidthstring 00.00.0000
2782 2786
2783 2787 \SpecialChar ~
2784 2788 Note that with
2785 2789 \family typewriter
2786 2790 -wthread
2787 2791 \family default
2788 2792 , you can additionally use the -wxversion option to request a specific version
2789 2793 of wx to be used.
2790 2794 This requires that you have the
2791 2795 \family typewriter
2792 2796 wxversion
2793 2797 \family default
2794 2798 Python module installed, which is part of recent wxPython distributions.
2795 2799 \layout List
2796 2800 \labelwidthstring 00.00.0000
2797 2801
2798 2802 \SpecialChar ~
2799 2803 If
2800 2804 \family typewriter
2801 2805 -pylab
2802 2806 \family default
2803 2807 is given, IPython loads special support for the mat plotlib library (
2804 2808 \begin_inset LatexCommand \htmlurl{http://matplotlib.sourceforge.net}
2805 2809
2806 2810 \end_inset
2807 2811
2808 2812 ), allowing interactive usage of any of its backends as defined in the user's
2809 2813
2810 2814 \family typewriter
2811 2815 ~/.matplotlib/matplotlibrc
2812 2816 \family default
2813 2817 file.
2814 2818 It automatically activates GTK, Qt or WX threading for IPyhton if the choice
2815 2819 of matplotlib backend requires it.
2816 2820 It also modifies the
2817 2821 \family typewriter
2818 2822 %run
2819 2823 \family default
2820 2824 command to correctly execute (without blocking) any matplotlib-based script
2821 2825 which calls
2822 2826 \family typewriter
2823 2827 show()
2824 2828 \family default
2825 2829 at the end.
2826 2830
2827 2831 \layout List
2828 2832 \labelwidthstring 00.00.0000
2829 2833
2830 2834
2831 2835 \family typewriter
2832 2836 \series bold
2833 2837 -tk
2834 2838 \family default
2835 2839 \series default
2836 2840 The
2837 2841 \family typewriter
2838 2842 -g/q/wthread
2839 2843 \family default
2840 2844 options, and
2841 2845 \family typewriter
2842 2846 -pylab
2843 2847 \family default
2844 2848 (if matplotlib is configured to use GTK, Qt or WX), will normally block
2845 2849 Tk graphical interfaces.
2846 2850 This means that when either GTK, Qt or WX threading is active, any attempt
2847 2851 to open a Tk GUI will result in a dead window, and possibly cause the Python
2848 2852 interpreter to crash.
2849 2853 An extra option,
2850 2854 \family typewriter
2851 2855 -tk
2852 2856 \family default
2853 2857 , is available to address this issue.
2854 2858 It can
2855 2859 \emph on
2856 2860 only
2857 2861 \emph default
2858 2862 be given as a
2859 2863 \emph on
2860 2864 second
2861 2865 \emph default
2862 2866 option after any of the above (
2863 2867 \family typewriter
2864 2868 -gthread
2865 2869 \family default
2866 2870 ,
2867 2871 \family typewriter
2868 2872 -wthread
2869 2873 \family default
2870 2874 or
2871 2875 \family typewriter
2872 2876 -pylab
2873 2877 \family default
2874 2878 ).
2875 2879 \layout List
2876 2880 \labelwidthstring 00.00.0000
2877 2881
2878 2882 \SpecialChar ~
2879 2883 If
2880 2884 \family typewriter
2881 2885 -tk
2882 2886 \family default
2883 2887 is given, IPython will try to coordinate Tk threading with GTK, Qt or WX.
2884 2888 This is however potentially unreliable, and you will have to test on your
2885 2889 platform and Python configuration to determine whether it works for you.
2886 2890 Debian users have reported success, apparently due to the fact that Debian
2887 2891 builds all of Tcl, Tk, Tkinter and Python with pthreads support.
2888 2892 Under other Linux environments (such as Fedora Core 2/3), this option has
2889 2893 caused random crashes and lockups of the Python interpreter.
2890 2894 Under other operating systems (Mac OSX and Windows), you'll need to try
2891 2895 it to find out, since currently no user reports are available.
2892 2896 \layout List
2893 2897 \labelwidthstring 00.00.0000
2894 2898
2895 2899 \SpecialChar ~
2896 2900 There is unfortunately no way for IPython to determine at run time whether
2897 2901
2898 2902 \family typewriter
2899 2903 -tk
2900 2904 \family default
2901 2905 will work reliably or not, so you will need to do some experiments before
2902 2906 relying on it for regular work.
2903 2907
2904 2908 \layout Subsection
2905 2909
2906 2910
2907 2911 \begin_inset LatexCommand \label{sec:cmd-line-opts}
2908 2912
2909 2913 \end_inset
2910 2914
2911 2915 Regular Options
2912 2916 \layout Standard
2913 2917
2914 2918 After the above threading options have been given, regular options can follow
2915 2919 in any order.
2916 2920 All options can be abbreviated to their shortest non-ambiguous form and
2917 2921 are case-sensitive.
2918 2922 One or two dashes can be used.
2919 2923 Some options have an alternate short form, indicated after a
2920 2924 \family typewriter
2921 2925 |
2922 2926 \family default
2923 2927 .
2924 2928 \layout Standard
2925 2929
2926 2930 Most options can also be set from your ipythonrc configuration file.
2927 2931 See the provided example for more details on what the options do.
2928 2932 Options given at the command line override the values set in the ipythonrc
2929 2933 file.
2930 2934 \layout Standard
2931 2935
2932 2936 All options with a
2933 2937 \family typewriter
2934 2938 [no]
2935 2939 \family default
2936 2940 prepended can be specified in negated form (
2937 2941 \family typewriter
2938 2942 -nooption
2939 2943 \family default
2940 2944 instead of
2941 2945 \family typewriter
2942 2946 -option
2943 2947 \family default
2944 2948 ) to turn the feature off.
2945 2949 \layout List
2946 2950 \labelwidthstring 00.00.0000
2947 2951
2948 2952
2949 2953 \family typewriter
2950 2954 \series bold
2951 2955 -help
2952 2956 \family default
2953 2957 \series default
2954 2958 : print a help message and exit.
2955 2959 \layout List
2956 2960 \labelwidthstring 00.00.0000
2957 2961
2958 2962
2959 2963 \family typewriter
2960 2964 \series bold
2961 2965 -pylab:
2962 2966 \family default
2963 2967 \series default
2964 2968 this can
2965 2969 \emph on
2966 2970 only
2967 2971 \emph default
2968 2972 be given as the
2969 2973 \emph on
2970 2974 first
2971 2975 \emph default
2972 2976 option passed to IPython (it will have no effect in any other position).
2973 2977 It adds special support for the matplotlib library (
2974 2978 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
2975 2979
2976 2980 \end_inset
2977 2981
2978 2982 ), allowing interactive usage of any of its backends as defined in the user's
2979 2983
2980 2984 \family typewriter
2981 2985 .matplotlibrc
2982 2986 \family default
2983 2987 file.
2984 2988 It automatically activates GTK or WX threading for IPyhton if the choice
2985 2989 of matplotlib backend requires it.
2986 2990 It also modifies the
2987 2991 \family typewriter
2988 2992 %run
2989 2993 \family default
2990 2994 command to correctly execute (without blocking) any matplotlib-based script
2991 2995 which calls
2992 2996 \family typewriter
2993 2997 show()
2994 2998 \family default
2995 2999 at the end.
2996 3000 See Sec.\SpecialChar ~
2997 3001
2998 3002 \begin_inset LatexCommand \ref{sec:matplotlib-support}
2999 3003
3000 3004 \end_inset
3001 3005
3002 3006 for more details.
3003 3007 \layout List
3004 3008 \labelwidthstring 00.00.0000
3005 3009
3006 3010
3007 3011 \family typewriter
3008 3012 \series bold
3009 3013 -autocall <val>:
3010 3014 \family default
3011 3015 \series default
3012 3016 Make IPython automatically call any callable object even if you didn't
3013 3017 type explicit parentheses.
3014 3018 For example, `str 43' becomes `str(43)' automatically.
3015 3019 The value can be `0' to disable the feature, `1' for
3016 3020 \emph on
3017 3021 smart
3018 3022 \emph default
3019 3023 autocall, where it is not applied if there are no more arguments on the
3020 3024 line, and `2' for
3021 3025 \emph on
3022 3026 full
3023 3027 \emph default
3024 3028 autocall, where all callable objects are automatically called (even if
3025 3029 no arguments are present).
3026 3030 The default is `1'.
3027 3031 \layout List
3028 3032 \labelwidthstring 00.00.0000
3029 3033
3030 3034
3031 3035 \family typewriter
3032 3036 \series bold
3033 3037 -[no]autoindent:
3034 3038 \family default
3035 3039 \series default
3036 3040 Turn automatic indentation on/off.
3037 3041 \layout List
3038 3042 \labelwidthstring 00.00.0000
3039 3043
3040 3044
3041 3045 \family typewriter
3042 3046 \series bold
3043 3047 -[no]automagic
3044 3048 \series default
3045 3049 :
3046 3050 \family default
3047 3051 make magic commands automatic (without needing their first character to
3048 3052 be
3049 3053 \family typewriter
3050 3054 %
3051 3055 \family default
3052 3056 ).
3053 3057 Type
3054 3058 \family typewriter
3055 3059 %magic
3056 3060 \family default
3057 3061 at the IPython prompt for more information.
3058 3062 \layout List
3059 3063 \labelwidthstring 00.00.0000
3060 3064
3061 3065
3062 3066 \family typewriter
3063 3067 \series bold
3064 3068 -[no]autoedit_syntax:
3065 3069 \family default
3066 3070 \series default
3067 3071 When a syntax error occurs after editing a file, automatically open the
3068 3072 file to the trouble causing line for convenient fixing.
3069 3073
3070 3074 \layout List
3071 3075 \labelwidthstring 00.00.0000
3072 3076
3073 3077
3074 3078 \family typewriter
3075 3079 \series bold
3076 3080 -[no]banner
3077 3081 \series default
3078 3082 :
3079 3083 \family default
3080 3084 Print the initial information banner (default on).
3081 3085 \layout List
3082 3086 \labelwidthstring 00.00.0000
3083 3087
3084 3088
3085 3089 \family typewriter
3086 3090 \series bold
3087 3091 -c\SpecialChar ~
3088 3092 <command>:
3089 3093 \family default
3090 3094 \series default
3091 3095 execute the given command string, and set sys.argv to
3092 3096 \family typewriter
3093 3097 ['c']
3094 3098 \family default
3095 3099 .
3096 3100 This is similar to the
3097 3101 \family typewriter
3098 3102 -c
3099 3103 \family default
3100 3104 option in the normal Python interpreter.
3101 3105
3102 3106 \layout List
3103 3107 \labelwidthstring 00.00.0000
3104 3108
3105 3109
3106 3110 \family typewriter
3107 3111 \series bold
3108 3112 -cache_size|cs\SpecialChar ~
3109 3113 <n>
3110 3114 \series default
3111 3115 :
3112 3116 \family default
3113 3117 size of the output cache (maximum number of entries to hold in memory).
3114 3118 The default is 1000, you can change it permanently in your config file.
3115 3119 Setting it to 0 completely disables the caching system, and the minimum
3116 3120 value accepted is 20 (if you provide a value less than 20, it is reset
3117 3121 to 0 and a warning is issued) This limit is defined because otherwise you'll
3118 3122 spend more time re-flushing a too small cache than working.
3119 3123 \layout List
3120 3124 \labelwidthstring 00.00.0000
3121 3125
3122 3126
3123 3127 \family typewriter
3124 3128 \series bold
3125 3129 -classic|cl
3126 3130 \series default
3127 3131 :
3128 3132 \family default
3129 3133 Gives IPython a similar feel to the classic Python prompt.
3130 3134 \layout List
3131 3135 \labelwidthstring 00.00.0000
3132 3136
3133 3137
3134 3138 \family typewriter
3135 3139 \series bold
3136 3140 -colors\SpecialChar ~
3137 3141 <scheme>:
3138 3142 \family default
3139 3143 \series default
3140 3144 Color scheme for prompts and exception reporting.
3141 3145 Currently implemented: NoColor, Linux and LightBG.
3142 3146 \layout List
3143 3147 \labelwidthstring 00.00.0000
3144 3148
3145 3149
3146 3150 \family typewriter
3147 3151 \series bold
3148 3152 -[no]color_info:
3149 3153 \family default
3150 3154 \series default
3151 3155 IPython can display information about objects via a set of functions, and
3152 3156 optionally can use colors for this, syntax highlighting source code and
3153 3157 various other elements.
3154 3158 However, because this information is passed through a pager (like 'less')
3155 3159 and many pagers get confused with color codes, this option is off by default.
3156 3160 You can test it and turn it on permanently in your ipythonrc file if it
3157 3161 works for you.
3158 3162 As a reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
3159 3163 that in RedHat 7.2 doesn't.
3160 3164 \layout List
3161 3165 \labelwidthstring 00.00.0000
3162 3166
3163 3167 \SpecialChar ~
3164 3168 Test it and turn it on permanently if it works with your system.
3165 3169 The magic function
3166 3170 \family typewriter
3167 3171 %color_info
3168 3172 \family default
3169 3173 allows you to toggle this interactively for testing.
3170 3174 \layout List
3171 3175 \labelwidthstring 00.00.0000
3172 3176
3173 3177
3174 3178 \family typewriter
3175 3179 \series bold
3176 3180 -[no]debug
3177 3181 \family default
3178 3182 \series default
3179 3183 : Show information about the loading process.
3180 3184 Very useful to pin down problems with your configuration files or to get
3181 3185 details about session restores.
3182 3186 \layout List
3183 3187 \labelwidthstring 00.00.0000
3184 3188
3185 3189
3186 3190 \family typewriter
3187 3191 \series bold
3188 3192 -[no]deep_reload
3189 3193 \series default
3190 3194 :
3191 3195 \family default
3192 3196 IPython can use the
3193 3197 \family typewriter
3194 3198 deep_reload
3195 3199 \family default
3196 3200 module which reloads changes in modules recursively (it replaces the
3197 3201 \family typewriter
3198 3202 reload()
3199 3203 \family default
3200 3204 function, so you don't need to change anything to use it).
3201 3205
3202 3206 \family typewriter
3203 3207 deep_reload()
3204 3208 \family default
3205 3209 forces a full reload of modules whose code may have changed, which the
3206 3210 default
3207 3211 \family typewriter
3208 3212 reload()
3209 3213 \family default
3210 3214 function does not.
3211 3215 \layout List
3212 3216 \labelwidthstring 00.00.0000
3213 3217
3214 3218 \SpecialChar ~
3215 3219 When deep_reload is off, IPython will use the normal
3216 3220 \family typewriter
3217 3221 reload()
3218 3222 \family default
3219 3223 , but deep_reload will still be available as
3220 3224 \family typewriter
3221 3225 dreload()
3222 3226 \family default
3223 3227 .
3224 3228 This feature is off by default [which means that you have both normal
3225 3229 \family typewriter
3226 3230 reload()
3227 3231 \family default
3228 3232 and
3229 3233 \family typewriter
3230 3234 dreload()
3231 3235 \family default
3232 3236 ].
3233 3237 \layout List
3234 3238 \labelwidthstring 00.00.0000
3235 3239
3236 3240
3237 3241 \family typewriter
3238 3242 \series bold
3239 3243 -editor\SpecialChar ~
3240 3244 <name>
3241 3245 \family default
3242 3246 \series default
3243 3247 : Which editor to use with the
3244 3248 \family typewriter
3245 3249 %edit
3246 3250 \family default
3247 3251 command.
3248 3252 By default, IPython will honor your
3249 3253 \family typewriter
3250 3254 EDITOR
3251 3255 \family default
3252 3256 environment variable (if not set, vi is the Unix default and notepad the
3253 3257 Windows one).
3254 3258 Since this editor is invoked on the fly by IPython and is meant for editing
3255 3259 small code snippets, you may want to use a small, lightweight editor here
3256 3260 (in case your default
3257 3261 \family typewriter
3258 3262 EDITOR
3259 3263 \family default
3260 3264 is something like Emacs).
3261 3265 \layout List
3262 3266 \labelwidthstring 00.00.0000
3263 3267
3264 3268
3265 3269 \family typewriter
3266 3270 \series bold
3267 3271 -ipythondir\SpecialChar ~
3268 3272 <name>
3269 3273 \series default
3270 3274 :
3271 3275 \family default
3272 3276 name of your IPython configuration directory
3273 3277 \family typewriter
3274 3278 IPYTHONDIR
3275 3279 \family default
3276 3280 .
3277 3281 This can also be specified through the environment variable
3278 3282 \family typewriter
3279 3283 IPYTHONDIR
3280 3284 \family default
3281 3285 .
3282 3286 \layout List
3283 3287 \labelwidthstring 00.00.0000
3284 3288
3285 3289
3286 3290 \family typewriter
3287 3291 \series bold
3288 3292 -log|l
3289 3293 \family default
3290 3294 \series default
3291 3295 : generate a log file of all input.
3292 3296 The file is named
3293 3297 \family typewriter
3294 3298 ipython_log.py
3295 3299 \family default
3296 3300 in your current directory (which prevents logs from multiple IPython sessions
3297 3301 from trampling each other).
3298 3302 You can use this to later restore a session by loading your logfile as
3299 3303 a file to be executed with option
3300 3304 \family typewriter
3301 3305 -logplay
3302 3306 \family default
3303 3307 (see below).
3304 3308 \layout List
3305 3309 \labelwidthstring 00.00.0000
3306 3310
3307 3311
3308 3312 \family typewriter
3309 3313 \series bold
3310 3314 -logfile|lf\SpecialChar ~
3311 3315 <name>
3312 3316 \series default
3313 3317 :
3314 3318 \family default
3315 3319 specify the name of your logfile.
3316 3320 \layout List
3317 3321 \labelwidthstring 00.00.0000
3318 3322
3319 3323
3320 3324 \family typewriter
3321 3325 \series bold
3322 3326 -logplay|lp\SpecialChar ~
3323 3327 <name>
3324 3328 \series default
3325 3329 :
3326 3330 \family default
3327 3331 you can replay a previous log.
3328 3332 For restoring a session as close as possible to the state you left it in,
3329 3333 use this option (don't just run the logfile).
3330 3334 With
3331 3335 \family typewriter
3332 3336 -logplay
3333 3337 \family default
3334 3338 , IPython will try to reconstruct the previous working environment in full,
3335 3339 not just execute the commands in the logfile.
3336 3340 \layout List
3337 3341 \labelwidthstring 00.00.0000
3338 3342
3339 3343 \SpecialChar ~
3340 3344 When a session is restored, logging is automatically turned on again with
3341 3345 the name of the logfile it was invoked with (it is read from the log header).
3342 3346 So once you've turned logging on for a session, you can quit IPython and
3343 3347 reload it as many times as you want and it will continue to log its history
3344 3348 and restore from the beginning every time.
3345 3349 \layout List
3346 3350 \labelwidthstring 00.00.0000
3347 3351
3348 3352 \SpecialChar ~
3349 3353 Caveats: there are limitations in this option.
3350 3354 The history variables
3351 3355 \family typewriter
3352 3356 _i*
3353 3357 \family default
3354 3358 ,
3355 3359 \family typewriter
3356 3360 _*
3357 3361 \family default
3358 3362 and
3359 3363 \family typewriter
3360 3364 _dh
3361 3365 \family default
3362 3366 don't get restored properly.
3363 3367 In the future we will try to implement full session saving by writing and
3364 3368 retrieving a 'snapshot' of the memory state of IPython.
3365 3369 But our first attempts failed because of inherent limitations of Python's
3366 3370 Pickle module, so this may have to wait.
3367 3371 \layout List
3368 3372 \labelwidthstring 00.00.0000
3369 3373
3370 3374
3371 3375 \family typewriter
3372 3376 \series bold
3373 3377 -[no]messages
3374 3378 \series default
3375 3379 :
3376 3380 \family default
3377 3381 Print messages which IPython collects about its startup process (default
3378 3382 on).
3379 3383 \layout List
3380 3384 \labelwidthstring 00.00.0000
3381 3385
3382 3386
3383 3387 \family typewriter
3384 3388 \series bold
3385 3389 -[no]pdb
3386 3390 \family default
3387 3391 \series default
3388 3392 : Automatically call the pdb debugger after every uncaught exception.
3389 3393 If you are used to debugging using pdb, this puts you automatically inside
3390 3394 of it after any call (either in IPython or in code called by it) which
3391 3395 triggers an exception which goes uncaught.
3392 3396 \layout List
3393 3397 \labelwidthstring 00.00.0000
3394 3398
3395 3399
3396 3400 \family typewriter
3397 3401 \series bold
3398 3402 -[no]pprint
3399 3403 \series default
3400 3404 :
3401 3405 \family default
3402 3406 ipython can optionally use the pprint (pretty printer) module for displaying
3403 3407 results.
3404 3408 pprint tends to give a nicer display of nested data structures.
3405 3409 If you like it, you can turn it on permanently in your config file (default
3406 3410 off).
3407 3411 \layout List
3408 3412 \labelwidthstring 00.00.0000
3409 3413
3410 3414
3411 3415 \family typewriter
3412 3416 \series bold
3413 3417 -profile|p <name>
3414 3418 \series default
3415 3419 :
3416 3420 \family default
3417 3421 assume that your config file is
3418 3422 \family typewriter
3419 3423 ipythonrc-<name>
3420 3424 \family default
3421 3425 (looks in current dir first, then in
3422 3426 \family typewriter
3423 3427 IPYTHONDIR
3424 3428 \family default
3425 3429 ).
3426 3430 This is a quick way to keep and load multiple config files for different
3427 3431 tasks, especially if you use the include option of config files.
3428 3432 You can keep a basic
3429 3433 \family typewriter
3430 3434 IPYTHONDIR/ipythonrc
3431 3435 \family default
3432 3436 file and then have other 'profiles' which include this one and load extra
3433 3437 things for particular tasks.
3434 3438 For example:
3435 3439 \layout List
3436 3440 \labelwidthstring 00.00.0000
3437 3441
3438 3442
3439 3443 \family typewriter
3440 3444 \SpecialChar ~
3441 3445
3442 3446 \family default
3443 3447 1.
3444 3448
3445 3449 \family typewriter
3446 3450 $HOME/.ipython/ipythonrc
3447 3451 \family default
3448 3452 : load basic things you always want.
3449 3453 \layout List
3450 3454 \labelwidthstring 00.00.0000
3451 3455
3452 3456
3453 3457 \family typewriter
3454 3458 \SpecialChar ~
3455 3459
3456 3460 \family default
3457 3461 2.
3458 3462
3459 3463 \family typewriter
3460 3464 $HOME/.ipython/ipythonrc-math
3461 3465 \family default
3462 3466 : load (1) and basic math-related modules.
3463 3467
3464 3468 \layout List
3465 3469 \labelwidthstring 00.00.0000
3466 3470
3467 3471
3468 3472 \family typewriter
3469 3473 \SpecialChar ~
3470 3474
3471 3475 \family default
3472 3476 3.
3473 3477
3474 3478 \family typewriter
3475 3479 $HOME/.ipython/ipythonrc-numeric
3476 3480 \family default
3477 3481 : load (1) and Numeric and plotting modules.
3478 3482 \layout List
3479 3483 \labelwidthstring 00.00.0000
3480 3484
3481 3485 \SpecialChar ~
3482 3486 Since it is possible to create an endless loop by having circular file
3483 3487 inclusions, IPython will stop if it reaches 15 recursive inclusions.
3484 3488 \layout List
3485 3489 \labelwidthstring 00.00.0000
3486 3490
3487 3491
3488 3492 \family typewriter
3489 3493 \series bold
3490 3494 -prompt_in1|pi1\SpecialChar ~
3491 3495 <string>:
3492 3496 \family default
3493 3497 \series default
3494 3498 Specify the string used for input prompts.
3495 3499 Note that if you are using numbered prompts, the number is represented
3496 3500 with a '
3497 3501 \backslash
3498 3502 #' in the string.
3499 3503 Don't forget to quote strings with spaces embedded in them.
3500 3504 Default: '
3501 3505 \family typewriter
3502 3506 In\SpecialChar ~
3503 3507 [
3504 3508 \backslash
3505 3509 #]:
3506 3510 \family default
3507 3511 '.
3508 3512 Sec.\SpecialChar ~
3509 3513
3510 3514 \begin_inset LatexCommand \ref{sec:prompts}
3511 3515
3512 3516 \end_inset
3513 3517
3514 3518 discusses in detail all the available escapes to customize your prompts.
3515 3519 \layout List
3516 3520 \labelwidthstring 00.00.0000
3517 3521
3518 3522
3519 3523 \family typewriter
3520 3524 \series bold
3521 3525 -prompt_in2|pi2\SpecialChar ~
3522 3526 <string>:
3523 3527 \family default
3524 3528 \series default
3525 3529 Similar to the previous option, but used for the continuation prompts.
3526 3530 The special sequence '
3527 3531 \family typewriter
3528 3532
3529 3533 \backslash
3530 3534 D
3531 3535 \family default
3532 3536 ' is similar to '
3533 3537 \family typewriter
3534 3538
3535 3539 \backslash
3536 3540 #
3537 3541 \family default
3538 3542 ', but with all digits replaced dots (so you can have your continuation
3539 3543 prompt aligned with your input prompt).
3540 3544 Default: '
3541 3545 \family typewriter
3542 3546 \SpecialChar ~
3543 3547 \SpecialChar ~
3544 3548 \SpecialChar ~
3545 3549 .
3546 3550 \backslash
3547 3551 D.:
3548 3552 \family default
3549 3553 ' (note three spaces at the start for alignment with '
3550 3554 \family typewriter
3551 3555 In\SpecialChar ~
3552 3556 [
3553 3557 \backslash
3554 3558 #]
3555 3559 \family default
3556 3560 ').
3557 3561 \layout List
3558 3562 \labelwidthstring 00.00.0000
3559 3563
3560 3564
3561 3565 \family typewriter
3562 3566 \series bold
3563 3567 -prompt_out|po\SpecialChar ~
3564 3568 <string>:
3565 3569 \family default
3566 3570 \series default
3567 3571 String used for output prompts, also uses numbers like
3568 3572 \family typewriter
3569 3573 prompt_in1
3570 3574 \family default
3571 3575 .
3572 3576 Default: '
3573 3577 \family typewriter
3574 3578 Out[
3575 3579 \backslash
3576 3580 #]:
3577 3581 \family default
3578 3582 '
3579 3583 \layout List
3580 3584 \labelwidthstring 00.00.0000
3581 3585
3582 3586
3583 3587 \family typewriter
3584 3588 \series bold
3585 3589 -quick
3586 3590 \family default
3587 3591 \series default
3588 3592 : start in bare bones mode (no config file loaded).
3589 3593 \layout List
3590 3594 \labelwidthstring 00.00.0000
3591 3595
3592 3596
3593 3597 \family typewriter
3594 3598 \series bold
3595 3599 -rcfile\SpecialChar ~
3596 3600 <name>
3597 3601 \series default
3598 3602 :
3599 3603 \family default
3600 3604 name of your IPython resource configuration file.
3601 3605 Normally IPython loads ipythonrc (from current directory) or
3602 3606 \family typewriter
3603 3607 IPYTHONDIR/ipythonrc
3604 3608 \family default
3605 3609 .
3606 3610 \layout List
3607 3611 \labelwidthstring 00.00.0000
3608 3612
3609 3613 \SpecialChar ~
3610 3614 If the loading of your config file fails, IPython starts with a bare bones
3611 3615 configuration (no modules loaded at all).
3612 3616 \layout List
3613 3617 \labelwidthstring 00.00.0000
3614 3618
3615 3619
3616 3620 \family typewriter
3617 3621 \series bold
3618 3622 -[no]readline
3619 3623 \family default
3620 3624 \series default
3621 3625 : use the readline library, which is needed to support name completion and
3622 3626 command history, among other things.
3623 3627 It is enabled by default, but may cause problems for users of X/Emacs in
3624 3628 Python comint or shell buffers.
3625 3629 \layout List
3626 3630 \labelwidthstring 00.00.0000
3627 3631
3628 3632 \SpecialChar ~
3629 3633 Note that X/Emacs 'eterm' buffers (opened with
3630 3634 \family typewriter
3631 3635 M-x\SpecialChar ~
3632 3636 term
3633 3637 \family default
3634 3638 ) support IPython's readline and syntax coloring fine, only 'emacs' (
3635 3639 \family typewriter
3636 3640 M-x\SpecialChar ~
3637 3641 shell
3638 3642 \family default
3639 3643 and
3640 3644 \family typewriter
3641 3645 C-c\SpecialChar ~
3642 3646 !
3643 3647 \family default
3644 3648 ) buffers do not.
3645 3649 \layout List
3646 3650 \labelwidthstring 00.00.0000
3647 3651
3648 3652
3649 3653 \family typewriter
3650 3654 \series bold
3651 3655 -screen_length|sl\SpecialChar ~
3652 3656 <n>
3653 3657 \series default
3654 3658 :
3655 3659 \family default
3656 3660 number of lines of your screen.
3657 3661 This is used to control printing of very long strings.
3658 3662 Strings longer than this number of lines will be sent through a pager instead
3659 3663 of directly printed.
3660 3664 \layout List
3661 3665 \labelwidthstring 00.00.0000
3662 3666
3663 3667 \SpecialChar ~
3664 3668 The default value for this is 0, which means IPython will auto-detect your
3665 3669 screen size every time it needs to print certain potentially long strings
3666 3670 (this doesn't change the behavior of the 'print' keyword, it's only triggered
3667 3671 internally).
3668 3672 If for some reason this isn't working well (it needs curses support), specify
3669 3673 it yourself.
3670 3674 Otherwise don't change the default.
3671 3675 \layout List
3672 3676 \labelwidthstring 00.00.0000
3673 3677
3674 3678
3675 3679 \family typewriter
3676 3680 \series bold
3677 3681 -separate_in|si\SpecialChar ~
3678 3682 <string>
3679 3683 \series default
3680 3684 :
3681 3685 \family default
3682 3686 separator before input prompts.
3683 3687 Default: '
3684 3688 \family typewriter
3685 3689
3686 3690 \backslash
3687 3691 n
3688 3692 \family default
3689 3693 '
3690 3694 \layout List
3691 3695 \labelwidthstring 00.00.0000
3692 3696
3693 3697
3694 3698 \family typewriter
3695 3699 \series bold
3696 3700 -separate_out|so\SpecialChar ~
3697 3701 <string>
3698 3702 \family default
3699 3703 \series default
3700 3704 : separator before output prompts.
3701 3705 Default: nothing.
3702 3706 \layout List
3703 3707 \labelwidthstring 00.00.0000
3704 3708
3705 3709
3706 3710 \family typewriter
3707 3711 \series bold
3708 3712 -separate_out2|so2\SpecialChar ~
3709 3713 <string>
3710 3714 \series default
3711 3715 :
3712 3716 \family default
3713 3717 separator after output prompts.
3714 3718 Default: nothing.
3715 3719 \layout List
3716 3720 \labelwidthstring 00.00.0000
3717 3721
3718 3722 \SpecialChar ~
3719 3723 For these three options, use the value 0 to specify no separator.
3720 3724 \layout List
3721 3725 \labelwidthstring 00.00.0000
3722 3726
3723 3727
3724 3728 \family typewriter
3725 3729 \series bold
3726 3730 -nosep
3727 3731 \series default
3728 3732 :
3729 3733 \family default
3730 3734 shorthand for
3731 3735 \family typewriter
3732 3736 '-SeparateIn 0 -SeparateOut 0 -SeparateOut2 0'
3733 3737 \family default
3734 3738 .
3735 3739 Simply removes all input/output separators.
3736 3740 \layout List
3737 3741 \labelwidthstring 00.00.0000
3738 3742
3739 3743
3740 3744 \family typewriter
3741 3745 \series bold
3742 3746 -upgrade
3743 3747 \family default
3744 3748 \series default
3745 3749 : allows you to upgrade your
3746 3750 \family typewriter
3747 3751 IPYTHONDIR
3748 3752 \family default
3749 3753 configuration when you install a new version of IPython.
3750 3754 Since new versions may include new command line options or example files,
3751 3755 this copies updated ipythonrc-type files.
3752 3756 However, it backs up (with a
3753 3757 \family typewriter
3754 3758 .old
3755 3759 \family default
3756 3760 extension) all files which it overwrites so that you can merge back any
3757 3761 customizations you might have in your personal files.
3758 3762 \layout List
3759 3763 \labelwidthstring 00.00.0000
3760 3764
3761 3765
3762 3766 \family typewriter
3763 3767 \series bold
3764 3768 -Version
3765 3769 \series default
3766 3770 :
3767 3771 \family default
3768 3772 print version information and exit.
3769 3773 \layout List
3770 3774 \labelwidthstring 00.00.0000
3771 3775
3772 3776
3773 3777 \family typewriter
3774 3778 \series bold
3775 3779 -wxversion\SpecialChar ~
3776 3780 <string>:
3777 3781 \family default
3778 3782 \series default
3779 3783 Select a specific version of wxPython (used in conjunction with
3780 3784 \family typewriter
3781 3785 -wthread
3782 3786 \family default
3783 3787 ).
3784 3788 Requires the wxversion module, part of recent wxPython distributions
3785 3789 \layout List
3786 3790 \labelwidthstring 00.00.0000
3787 3791
3788 3792
3789 3793 \family typewriter
3790 3794 \series bold
3791 3795 -xmode\SpecialChar ~
3792 3796 <modename>
3793 3797 \series default
3794 3798 :
3795 3799 \family default
3796 3800 Mode for exception reporting.
3797 3801 \layout List
3798 3802 \labelwidthstring 00.00.0000
3799 3803
3800 3804 \SpecialChar ~
3801 3805 Valid modes: Plain, Context and Verbose.
3802 3806 \layout List
3803 3807 \labelwidthstring 00.00.0000
3804 3808
3805 3809 \SpecialChar ~
3806 3810 Plain: similar to python's normal traceback printing.
3807 3811 \layout List
3808 3812 \labelwidthstring 00.00.0000
3809 3813
3810 3814 \SpecialChar ~
3811 3815 Context: prints 5 lines of context source code around each line in the
3812 3816 traceback.
3813 3817 \layout List
3814 3818 \labelwidthstring 00.00.0000
3815 3819
3816 3820 \SpecialChar ~
3817 3821 Verbose: similar to Context, but additionally prints the variables currently
3818 3822 visible where the exception happened (shortening their strings if too long).
3819 3823 This can potentially be very slow, if you happen to have a huge data structure
3820 3824 whose string representation is complex to compute.
3821 3825 Your computer may appear to freeze for a while with cpu usage at 100%.
3822 3826 If this occurs, you can cancel the traceback with Ctrl-C (maybe hitting
3823 3827 it more than once).
3824 3828 \layout Section
3825 3829
3826 3830 Interactive use
3827 3831 \layout Standard
3828 3832
3829 3833
3830 3834 \series bold
3831 3835 Warning
3832 3836 \series default
3833 3837 : IPython relies on the existence of a global variable called
3834 3838 \family typewriter
3835 3839 __IP
3836 3840 \family default
3837 3841 which controls the shell itself.
3838 3842 If you redefine
3839 3843 \family typewriter
3840 3844 __IP
3841 3845 \family default
3842 3846 to anything, bizarre behavior will quickly occur.
3843 3847 \layout Standard
3844 3848
3845 3849 Other than the above warning, IPython is meant to work as a drop-in replacement
3846 3850 for the standard interactive interpreter.
3847 3851 As such, any code which is valid python should execute normally under IPython
3848 3852 (cases where this is not true should be reported as bugs).
3849 3853 It does, however, offer many features which are not available at a standard
3850 3854 python prompt.
3851 3855 What follows is a list of these.
3852 3856 \layout Subsection
3853 3857
3854 3858 Caution for Windows users
3855 3859 \layout Standard
3856 3860
3857 3861 Windows, unfortunately, uses the `
3858 3862 \family typewriter
3859 3863
3860 3864 \backslash
3861 3865
3862 3866 \family default
3863 3867 ' character as a path separator.
3864 3868 This is a terrible choice, because `
3865 3869 \family typewriter
3866 3870
3867 3871 \backslash
3868 3872
3869 3873 \family default
3870 3874 ' also represents the escape character in most modern programming languages,
3871 3875 including Python.
3872 3876 For this reason, issuing many of the commands discussed below (especially
3873 3877 magics which affect the filesystem) with `
3874 3878 \family typewriter
3875 3879
3876 3880 \backslash
3877 3881
3878 3882 \family default
3879 3883 ' in them will cause strange errors.
3880 3884 \layout Standard
3881 3885
3882 3886 A partial solution is to use instead the `
3883 3887 \family typewriter
3884 3888 /
3885 3889 \family default
3886 3890 ' character as a path separator, which Windows recognizes in
3887 3891 \emph on
3888 3892 most
3889 3893 \emph default
3890 3894 situations.
3891 3895 However, in Windows commands `
3892 3896 \family typewriter
3893 3897 /
3894 3898 \family default
3895 3899 ' flags options, so you can not use it for the root directory.
3896 3900 This means that paths beginning at the root must be typed in a contrived
3897 3901 manner like:
3898 3902 \newline
3899 3903
3900 3904 \family typewriter
3901 3905 %copy
3902 3906 \backslash
3903 3907 opt/foo/bar.txt
3904 3908 \backslash
3905 3909 tmp
3906 3910 \layout Standard
3907 3911
3908 3912 There is no sensible thing IPython can do to truly work around this flaw
3909 3913 in Windows
3910 3914 \begin_inset Foot
3911 3915 collapsed true
3912 3916
3913 3917 \layout Standard
3914 3918
3915 3919 If anyone comes up with a
3916 3920 \emph on
3917 3921 clean
3918 3922 \emph default
3919 3923 solution which works consistently and does not negatively impact other
3920 3924 platforms at all, I'll gladly accept a patch.
3921 3925 \end_inset
3922 3926
3923 3927 .
3924 3928 \layout Subsection
3925 3929
3926 3930
3927 3931 \begin_inset LatexCommand \label{sec:magic}
3928 3932
3929 3933 \end_inset
3930 3934
3931 3935 Magic command system
3932 3936 \layout Standard
3933 3937
3934 3938 IPython will treat any line whose first character is a
3935 3939 \family typewriter
3936 3940 %
3937 3941 \family default
3938 3942 as a special call to a 'magic' function.
3939 3943 These allow you to control the behavior of IPython itself, plus a lot of
3940 3944 system-type features.
3941 3945 They are all prefixed with a
3942 3946 \family typewriter
3943 3947 %
3944 3948 \family default
3945 3949 character, but parameters are given without parentheses or quotes.
3946 3950 \layout Standard
3947 3951
3948 3952 Example: typing
3949 3953 \family typewriter
3950 3954 '%cd mydir'
3951 3955 \family default
3952 3956 (without the quotes) changes you working directory to
3953 3957 \family typewriter
3954 3958 'mydir'
3955 3959 \family default
3956 3960 , if it exists.
3957 3961 \layout Standard
3958 3962
3959 3963 If you have 'automagic' enabled (in your
3960 3964 \family typewriter
3961 3965 ipythonrc
3962 3966 \family default
3963 3967 file, via the command line option
3964 3968 \family typewriter
3965 3969 -automagic
3966 3970 \family default
3967 3971 or with the
3968 3972 \family typewriter
3969 3973 %automagic
3970 3974 \family default
3971 3975 function), you don't need to type in the
3972 3976 \family typewriter
3973 3977 %
3974 3978 \family default
3975 3979 explicitly.
3976 3980 IPython will scan its internal list of magic functions and call one if
3977 3981 it exists.
3978 3982 With automagic on you can then just type '
3979 3983 \family typewriter
3980 3984 cd mydir
3981 3985 \family default
3982 3986 ' to go to directory '
3983 3987 \family typewriter
3984 3988 mydir
3985 3989 \family default
3986 3990 '.
3987 3991 The automagic system has the lowest possible precedence in name searches,
3988 3992 so defining an identifier with the same name as an existing magic function
3989 3993 will shadow it for automagic use.
3990 3994 You can still access the shadowed magic function by explicitly using the
3991 3995
3992 3996 \family typewriter
3993 3997 %
3994 3998 \family default
3995 3999 character at the beginning of the line.
3996 4000 \layout Standard
3997 4001
3998 4002 An example (with automagic on) should clarify all this:
3999 4003 \layout LyX-Code
4000 4004
4001 4005 In [1]: cd ipython # %cd is called by automagic
4002 4006 \layout LyX-Code
4003 4007
4004 4008 /home/fperez/ipython
4005 4009 \layout LyX-Code
4006 4010
4007 4011 In [2]: cd=1 # now cd is just a variable
4008 4012 \layout LyX-Code
4009 4013
4010 4014 In [3]: cd ..
4011 4015 # and doesn't work as a function anymore
4012 4016 \layout LyX-Code
4013 4017
4014 4018 ------------------------------------------------------------
4015 4019 \layout LyX-Code
4016 4020
4017 4021 File "<console>", line 1
4018 4022 \layout LyX-Code
4019 4023
4020 4024 cd ..
4021 4025 \layout LyX-Code
4022 4026
4023 4027 ^
4024 4028 \layout LyX-Code
4025 4029
4026 4030 SyntaxError: invalid syntax
4027 4031 \layout LyX-Code
4028 4032
4029 4033 \layout LyX-Code
4030 4034
4031 4035 In [4]: %cd ..
4032 4036 # but %cd always works
4033 4037 \layout LyX-Code
4034 4038
4035 4039 /home/fperez
4036 4040 \layout LyX-Code
4037 4041
4038 4042 In [5]: del cd # if you remove the cd variable
4039 4043 \layout LyX-Code
4040 4044
4041 4045 In [6]: cd ipython # automagic can work again
4042 4046 \layout LyX-Code
4043 4047
4044 4048 /home/fperez/ipython
4045 4049 \layout Standard
4046 4050
4047 4051 You can define your own magic functions to extend the system.
4048 4052 The following is a snippet of code which shows how to do it.
4049 4053 It is provided as file
4050 4054 \family typewriter
4051 4055 example-magic.py
4052 4056 \family default
4053 4057 in the examples directory:
4054 4058 \layout Standard
4055 4059
4056 4060
4057 4061 \begin_inset ERT
4058 4062 status Open
4059 4063
4060 4064 \layout Standard
4061 4065
4062 4066 \backslash
4063 4067 codelist{examples/example-magic.py}
4064 4068 \end_inset
4065 4069
4066 4070
4067 4071 \layout Standard
4068 4072
4069 4073 You can also define your own aliased names for magic functions.
4070 4074 In your
4071 4075 \family typewriter
4072 4076 ipythonrc
4073 4077 \family default
4074 4078 file, placing a line like:
4075 4079 \layout Standard
4076 4080
4077 4081
4078 4082 \family typewriter
4079 4083 execute __IP.magic_cl = __IP.magic_clear
4080 4084 \layout Standard
4081 4085
4082 4086 will define
4083 4087 \family typewriter
4084 4088 %cl
4085 4089 \family default
4086 4090 as a new name for
4087 4091 \family typewriter
4088 4092 %clear
4089 4093 \family default
4090 4094 .
4091 4095 \layout Standard
4092 4096
4093 4097 Type
4094 4098 \family typewriter
4095 4099 %magic
4096 4100 \family default
4097 4101 for more information, including a list of all available magic functions
4098 4102 at any time and their docstrings.
4099 4103 You can also type
4100 4104 \family typewriter
4101 4105 %magic_function_name?
4102 4106 \family default
4103 4107 (see sec.
4104 4108
4105 4109 \begin_inset LatexCommand \ref{sec:dyn-object-info}
4106 4110
4107 4111 \end_inset
4108 4112
4109 4113 for information on the
4110 4114 \family typewriter
4111 4115 '?'
4112 4116 \family default
4113 4117 system) to get information about any particular magic function you are
4114 4118 interested in.
4115 4119 \layout Subsubsection
4116 4120
4117 4121 Magic commands
4118 4122 \layout Standard
4119 4123
4120 4124 The rest of this section is automatically generated for each release from
4121 4125 the docstrings in the IPython code.
4122 4126 Therefore the formatting is somewhat minimal, but this method has the advantage
4123 4127 of having information always in sync with the code.
4124 4128 \layout Standard
4125 4129
4126 4130 A list of all the magic commands available in IPython's
4127 4131 \emph on
4128 4132 default
4129 4133 \emph default
4130 4134 installation follows.
4131 4135 This is similar to what you'll see by simply typing
4132 4136 \family typewriter
4133 4137 %magic
4134 4138 \family default
4135 4139 at the prompt, but that will also give you information about magic commands
4136 4140 you may have added as part of your personal customizations.
4137 4141 \layout Standard
4138 4142
4139 4143
4140 4144 \begin_inset Include \input{magic.tex}
4141 4145 preview false
4142 4146
4143 4147 \end_inset
4144 4148
4145 4149
4146 4150 \layout Subsection
4147 4151
4148 4152 Access to the standard Python help
4149 4153 \layout Standard
4150 4154
4151 4155 As of Python 2.1, a help system is available with access to object docstrings
4152 4156 and the Python manuals.
4153 4157 Simply type
4154 4158 \family typewriter
4155 4159 'help'
4156 4160 \family default
4157 4161 (no quotes) to access it.
4158 4162 You can also type
4159 4163 \family typewriter
4160 4164 help(object)
4161 4165 \family default
4162 4166 to obtain information about a given object, and
4163 4167 \family typewriter
4164 4168 help('keyword')
4165 4169 \family default
4166 4170 for information on a keyword.
4167 4171 As noted in sec.
4168 4172
4169 4173 \begin_inset LatexCommand \ref{sec:help-access}
4170 4174
4171 4175 \end_inset
4172 4176
4173 4177 , you need to properly configure your environment variable
4174 4178 \family typewriter
4175 4179 PYTHONDOCS
4176 4180 \family default
4177 4181 for this feature to work correctly.
4178 4182 \layout Subsection
4179 4183
4180 4184
4181 4185 \begin_inset LatexCommand \label{sec:dyn-object-info}
4182 4186
4183 4187 \end_inset
4184 4188
4185 4189 Dynamic object information
4186 4190 \layout Standard
4187 4191
4188 4192 Typing
4189 4193 \family typewriter
4190 4194 ?word
4191 4195 \family default
4192 4196 or
4193 4197 \family typewriter
4194 4198 word?
4195 4199 \family default
4196 4200 prints detailed information about an object.
4197 4201 If certain strings in the object are too long (docstrings, code, etc.) they
4198 4202 get snipped in the center for brevity.
4199 4203 This system gives access variable types and values, full source code for
4200 4204 any object (if available), function prototypes and other useful information.
4201 4205 \layout Standard
4202 4206
4203 4207 Typing
4204 4208 \family typewriter
4205 4209 ??word
4206 4210 \family default
4207 4211 or
4208 4212 \family typewriter
4209 4213 word??
4210 4214 \family default
4211 4215 gives access to the full information without snipping long strings.
4212 4216 Long strings are sent to the screen through the
4213 4217 \family typewriter
4214 4218 less
4215 4219 \family default
4216 4220 pager if longer than the screen and printed otherwise.
4217 4221 On systems lacking the
4218 4222 \family typewriter
4219 4223 less
4220 4224 \family default
4221 4225 command, IPython uses a very basic internal pager.
4222 4226 \layout Standard
4223 4227
4224 4228 The following magic functions are particularly useful for gathering information
4225 4229 about your working environment.
4226 4230 You can get more details by typing
4227 4231 \family typewriter
4228 4232 %magic
4229 4233 \family default
4230 4234 or querying them individually (use
4231 4235 \family typewriter
4232 4236 %function_name?
4233 4237 \family default
4234 4238 with or without the
4235 4239 \family typewriter
4236 4240 %
4237 4241 \family default
4238 4242 ), this is just a summary:
4239 4243 \layout List
4240 4244 \labelwidthstring 00.00.0000
4241 4245
4242 4246
4243 4247 \family typewriter
4244 4248 \series bold
4245 4249 %pdoc\SpecialChar ~
4246 4250 <object>
4247 4251 \family default
4248 4252 \series default
4249 4253 : Print (or run through a pager if too long) the docstring for an object.
4250 4254 If the given object is a class, it will print both the class and the constructo
4251 4255 r docstrings.
4252 4256 \layout List
4253 4257 \labelwidthstring 00.00.0000
4254 4258
4255 4259
4256 4260 \family typewriter
4257 4261 \series bold
4258 4262 %pdef\SpecialChar ~
4259 4263 <object>
4260 4264 \family default
4261 4265 \series default
4262 4266 : Print the definition header for any callable object.
4263 4267 If the object is a class, print the constructor information.
4264 4268 \layout List
4265 4269 \labelwidthstring 00.00.0000
4266 4270
4267 4271
4268 4272 \family typewriter
4269 4273 \series bold
4270 4274 %psource\SpecialChar ~
4271 4275 <object>
4272 4276 \family default
4273 4277 \series default
4274 4278 : Print (or run through a pager if too long) the source code for an object.
4275 4279 \layout List
4276 4280 \labelwidthstring 00.00.0000
4277 4281
4278 4282
4279 4283 \family typewriter
4280 4284 \series bold
4281 4285 %pfile\SpecialChar ~
4282 4286 <object>
4283 4287 \family default
4284 4288 \series default
4285 4289 : Show the entire source file where an object was defined via a pager, opening
4286 4290 it at the line where the object definition begins.
4287 4291 \layout List
4288 4292 \labelwidthstring 00.00.0000
4289 4293
4290 4294
4291 4295 \family typewriter
4292 4296 \series bold
4293 4297 %who/%whos
4294 4298 \family default
4295 4299 \series default
4296 4300 : These functions give information about identifiers you have defined interactiv
4297 4301 ely (not things you loaded or defined in your configuration files).
4298 4302
4299 4303 \family typewriter
4300 4304 %who
4301 4305 \family default
4302 4306 just prints a list of identifiers and
4303 4307 \family typewriter
4304 4308 %whos
4305 4309 \family default
4306 4310 prints a table with some basic details about each identifier.
4307 4311 \layout Standard
4308 4312
4309 4313 Note that the dynamic object information functions (
4310 4314 \family typewriter
4311 4315 ?/??, %pdoc, %pfile, %pdef, %psource
4312 4316 \family default
4313 4317 ) give you access to documentation even on things which are not really defined
4314 4318 as separate identifiers.
4315 4319 Try for example typing
4316 4320 \family typewriter
4317 4321 {}.get?
4318 4322 \family default
4319 4323 or after doing
4320 4324 \family typewriter
4321 4325 import os
4322 4326 \family default
4323 4327 , type
4324 4328 \family typewriter
4325 4329 os.path.abspath??
4326 4330 \family default
4327 4331 .
4328 4332 \layout Subsection
4329 4333
4330 4334
4331 4335 \begin_inset LatexCommand \label{sec:readline}
4332 4336
4333 4337 \end_inset
4334 4338
4335 4339 Readline-based features
4336 4340 \layout Standard
4337 4341
4338 4342 These features require the GNU readline library, so they won't work if your
4339 4343 Python installation lacks readline support.
4340 4344 We will first describe the default behavior IPython uses, and then how
4341 4345 to change it to suit your preferences.
4342 4346 \layout Subsubsection
4343 4347
4344 4348 Command line completion
4345 4349 \layout Standard
4346 4350
4347 4351 At any time, hitting TAB will complete any available python commands or
4348 4352 variable names, and show you a list of the possible completions if there's
4349 4353 no unambiguous one.
4350 4354 It will also complete filenames in the current directory if no python names
4351 4355 match what you've typed so far.
4352 4356 \layout Subsubsection
4353 4357
4354 4358 Search command history
4355 4359 \layout Standard
4356 4360
4357 4361 IPython provides two ways for searching through previous input and thus
4358 4362 reduce the need for repetitive typing:
4359 4363 \layout Enumerate
4360 4364
4361 4365 Start typing, and then use
4362 4366 \family typewriter
4363 4367 Ctrl-p
4364 4368 \family default
4365 4369 (previous,up) and
4366 4370 \family typewriter
4367 4371 Ctrl-n
4368 4372 \family default
4369 4373 (next,down) to search through only the history items that match what you've
4370 4374 typed so far.
4371 4375 If you use
4372 4376 \family typewriter
4373 4377 Ctrl-p/Ctrl-n
4374 4378 \family default
4375 4379 at a blank prompt, they just behave like normal arrow keys.
4376 4380 \layout Enumerate
4377 4381
4378 4382 Hit
4379 4383 \family typewriter
4380 4384 Ctrl-r
4381 4385 \family default
4382 4386 : opens a search prompt.
4383 4387 Begin typing and the system searches your history for lines that contain
4384 4388 what you've typed so far, completing as much as it can.
4385 4389 \layout Subsubsection
4386 4390
4387 4391 Persistent command history across sessions
4388 4392 \layout Standard
4389 4393
4390 4394 IPython will save your input history when it leaves and reload it next time
4391 4395 you restart it.
4392 4396 By default, the history file is named
4393 4397 \family typewriter
4394 4398 $IPYTHONDIR/history
4395 4399 \family default
4396 4400 , but if you've loaded a named profile, '
4397 4401 \family typewriter
4398 4402 -PROFILE_NAME
4399 4403 \family default
4400 4404 ' is appended to the name.
4401 4405 This allows you to keep separate histories related to various tasks: commands
4402 4406 related to numerical work will not be clobbered by a system shell history,
4403 4407 for example.
4404 4408 \layout Subsubsection
4405 4409
4406 4410 Autoindent
4407 4411 \layout Standard
4408 4412
4409 4413 IPython can recognize lines ending in ':' and indent the next line, while
4410 4414 also un-indenting automatically after 'raise' or 'return'.
4411 4415
4412 4416 \layout Standard
4413 4417
4414 4418 This feature uses the readline library, so it will honor your
4415 4419 \family typewriter
4416 4420 ~/.inputrc
4417 4421 \family default
4418 4422 configuration (or whatever file your
4419 4423 \family typewriter
4420 4424 INPUTRC
4421 4425 \family default
4422 4426 variable points to).
4423 4427 Adding the following lines to your
4424 4428 \family typewriter
4425 4429 .inputrc
4426 4430 \family default
4427 4431 file can make indenting/unindenting more convenient (
4428 4432 \family typewriter
4429 4433 M-i
4430 4434 \family default
4431 4435 indents,
4432 4436 \family typewriter
4433 4437 M-u
4434 4438 \family default
4435 4439 unindents):
4436 4440 \layout Standard
4437 4441
4438 4442
4439 4443 \family typewriter
4440 4444 $if Python
4441 4445 \newline
4442 4446 "
4443 4447 \backslash
4444 4448 M-i": "\SpecialChar ~
4445 4449 \SpecialChar ~
4446 4450 \SpecialChar ~
4447 4451 \SpecialChar ~
4448 4452 "
4449 4453 \newline
4450 4454 "
4451 4455 \backslash
4452 4456 M-u": "
4453 4457 \backslash
4454 4458 d
4455 4459 \backslash
4456 4460 d
4457 4461 \backslash
4458 4462 d
4459 4463 \backslash
4460 4464 d"
4461 4465 \newline
4462 4466 $endif
4463 4467 \layout Standard
4464 4468
4465 4469 Note that there are 4 spaces between the quote marks after
4466 4470 \family typewriter
4467 4471 "M-i"
4468 4472 \family default
4469 4473 above.
4470 4474 \layout Standard
4471 4475
4472 4476
4473 4477 \series bold
4474 4478 Warning:
4475 4479 \series default
4476 4480 this feature is ON by default, but it can cause problems with the pasting
4477 4481 of multi-line indented code (the pasted code gets re-indented on each line).
4478 4482 A magic function
4479 4483 \family typewriter
4480 4484 %autoindent
4481 4485 \family default
4482 4486 allows you to toggle it on/off at runtime.
4483 4487 You can also disable it permanently on in your
4484 4488 \family typewriter
4485 4489 ipythonrc
4486 4490 \family default
4487 4491 file (set
4488 4492 \family typewriter
4489 4493 autoindent 0
4490 4494 \family default
4491 4495 ).
4492 4496 \layout Subsubsection
4493 4497
4494 4498 Customizing readline behavior
4495 4499 \layout Standard
4496 4500
4497 4501 All these features are based on the GNU readline library, which has an extremely
4498 4502 customizable interface.
4499 4503 Normally, readline is configured via a file which defines the behavior
4500 4504 of the library; the details of the syntax for this can be found in the
4501 4505 readline documentation available with your system or on the Internet.
4502 4506 IPython doesn't read this file (if it exists) directly, but it does support
4503 4507 passing to readline valid options via a simple interface.
4504 4508 In brief, you can customize readline by setting the following options in
4505 4509 your
4506 4510 \family typewriter
4507 4511 ipythonrc
4508 4512 \family default
4509 4513 configuration file (note that these options can
4510 4514 \emph on
4511 4515 not
4512 4516 \emph default
4513 4517 be specified at the command line):
4514 4518 \layout List
4515 4519 \labelwidthstring 00.00.0000
4516 4520
4517 4521
4518 4522 \family typewriter
4519 4523 \series bold
4520 4524 readline_parse_and_bind:
4521 4525 \family default
4522 4526 \series default
4523 4527 this option can appear as many times as you want, each time defining a
4524 4528 string to be executed via a
4525 4529 \family typewriter
4526 4530 readline.parse_and_bind()
4527 4531 \family default
4528 4532 command.
4529 4533 The syntax for valid commands of this kind can be found by reading the
4530 4534 documentation for the GNU readline library, as these commands are of the
4531 4535 kind which readline accepts in its configuration file.
4532 4536 \layout List
4533 4537 \labelwidthstring 00.00.0000
4534 4538
4535 4539
4536 4540 \family typewriter
4537 4541 \series bold
4538 4542 readline_remove_delims:
4539 4543 \family default
4540 4544 \series default
4541 4545 a string of characters to be removed from the default word-delimiters list
4542 4546 used by readline, so that completions may be performed on strings which
4543 4547 contain them.
4544 4548 Do not change the default value unless you know what you're doing.
4545 4549 \layout List
4546 4550 \labelwidthstring 00.00.0000
4547 4551
4548 4552
4549 4553 \family typewriter
4550 4554 \series bold
4551 4555 readline_omit__names
4552 4556 \family default
4553 4557 \series default
4554 4558 : when tab-completion is enabled, hitting
4555 4559 \family typewriter
4556 4560 <tab>
4557 4561 \family default
4558 4562 after a '
4559 4563 \family typewriter
4560 4564 .
4561 4565 \family default
4562 4566 ' in a name will complete all attributes of an object, including all the
4563 4567 special methods whose names include double underscores (like
4564 4568 \family typewriter
4565 4569 __getitem__
4566 4570 \family default
4567 4571 or
4568 4572 \family typewriter
4569 4573 __class__
4570 4574 \family default
4571 4575 ).
4572 4576 If you'd rather not see these names by default, you can set this option
4573 4577 to 1.
4574 4578 Note that even when this option is set, you can still see those names by
4575 4579 explicitly typing a
4576 4580 \family typewriter
4577 4581 _
4578 4582 \family default
4579 4583 after the period and hitting
4580 4584 \family typewriter
4581 4585 <tab>
4582 4586 \family default
4583 4587 : '
4584 4588 \family typewriter
4585 4589 name._<tab>
4586 4590 \family default
4587 4591 ' will always complete attribute names starting with '
4588 4592 \family typewriter
4589 4593 _
4590 4594 \family default
4591 4595 '.
4592 4596 \layout List
4593 4597 \labelwidthstring 00.00.0000
4594 4598
4595 4599 \SpecialChar ~
4596 4600 This option is off by default so that new users see all attributes of any
4597 4601 objects they are dealing with.
4598 4602 \layout Standard
4599 4603
4600 4604 You will find the default values along with a corresponding detailed explanation
4601 4605 in your
4602 4606 \family typewriter
4603 4607 ipythonrc
4604 4608 \family default
4605 4609 file.
4606 4610 \layout Subsection
4607 4611
4608 4612 Session logging and restoring
4609 4613 \layout Standard
4610 4614
4611 4615 You can log all input from a session either by starting IPython with the
4612 4616 command line switches
4613 4617 \family typewriter
4614 4618 -log
4615 4619 \family default
4616 4620 or
4617 4621 \family typewriter
4618 4622 -logfile
4619 4623 \family default
4620 4624 (see sec.
4621 4625
4622 4626 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
4623 4627
4624 4628 \end_inset
4625 4629
4626 4630 )or by activating the logging at any moment with the magic function
4627 4631 \family typewriter
4628 4632 %logstart
4629 4633 \family default
4630 4634 .
4631 4635
4632 4636 \layout Standard
4633 4637
4634 4638 Log files can later be reloaded with the
4635 4639 \family typewriter
4636 4640 -logplay
4637 4641 \family default
4638 4642 option and IPython will attempt to 'replay' the log by executing all the
4639 4643 lines in it, thus restoring the state of a previous session.
4640 4644 This feature is not quite perfect, but can still be useful in many cases.
4641 4645 \layout Standard
4642 4646
4643 4647 The log files can also be used as a way to have a permanent record of any
4644 4648 code you wrote while experimenting.
4645 4649 Log files are regular text files which you can later open in your favorite
4646 4650 text editor to extract code or to 'clean them up' before using them to
4647 4651 replay a session.
4648 4652 \layout Standard
4649 4653
4650 4654 The
4651 4655 \family typewriter
4652 4656 %logstart
4653 4657 \family default
4654 4658 function for activating logging in mid-session is used as follows:
4655 4659 \layout Standard
4656 4660
4657 4661
4658 4662 \family typewriter
4659 4663 %logstart [log_name [log_mode]]
4660 4664 \layout Standard
4661 4665
4662 4666 If no name is given, it defaults to a file named
4663 4667 \family typewriter
4664 4668 'log'
4665 4669 \family default
4666 4670 in your IPYTHONDIR directory, in
4667 4671 \family typewriter
4668 4672 'rotate'
4669 4673 \family default
4670 4674 mode (see below).
4671 4675 \layout Standard
4672 4676
4673 4677 '
4674 4678 \family typewriter
4675 4679 %logstart name
4676 4680 \family default
4677 4681 ' saves to file
4678 4682 \family typewriter
4679 4683 'name'
4680 4684 \family default
4681 4685 in
4682 4686 \family typewriter
4683 4687 'backup'
4684 4688 \family default
4685 4689 mode.
4686 4690 It saves your history up to that point and then continues logging.
4687 4691 \layout Standard
4688 4692
4689 4693
4690 4694 \family typewriter
4691 4695 %logstart
4692 4696 \family default
4693 4697 takes a second optional parameter: logging mode.
4694 4698 This can be one of (note that the modes are given unquoted):
4695 4699 \layout List
4696 4700 \labelwidthstring 00.00.0000
4697 4701
4698 4702
4699 4703 \family typewriter
4700 4704 over
4701 4705 \family default
4702 4706 : overwrite existing
4703 4707 \family typewriter
4704 4708 log_name
4705 4709 \family default
4706 4710 .
4707 4711 \layout List
4708 4712 \labelwidthstring 00.00.0000
4709 4713
4710 4714
4711 4715 \family typewriter
4712 4716 backup
4713 4717 \family default
4714 4718 : rename (if exists) to
4715 4719 \family typewriter
4716 4720 log_name~
4717 4721 \family default
4718 4722 and start
4719 4723 \family typewriter
4720 4724 log_name
4721 4725 \family default
4722 4726 .
4723 4727 \layout List
4724 4728 \labelwidthstring 00.00.0000
4725 4729
4726 4730
4727 4731 \family typewriter
4728 4732 append
4729 4733 \family default
4730 4734 : well, that says it.
4731 4735 \layout List
4732 4736 \labelwidthstring 00.00.0000
4733 4737
4734 4738
4735 4739 \family typewriter
4736 4740 rotate
4737 4741 \family default
4738 4742 : create rotating logs
4739 4743 \family typewriter
4740 4744 log_name
4741 4745 \family default
4742 4746 .
4743 4747 \family typewriter
4744 4748 1~
4745 4749 \family default
4746 4750 ,
4747 4751 \family typewriter
4748 4752 log_name.2~
4749 4753 \family default
4750 4754 , etc.
4751 4755 \layout Standard
4752 4756
4753 4757 The
4754 4758 \family typewriter
4755 4759 %logoff
4756 4760 \family default
4757 4761 and
4758 4762 \family typewriter
4759 4763 %logon
4760 4764 \family default
4761 4765 functions allow you to temporarily stop and resume logging to a file which
4762 4766 had previously been started with
4763 4767 \family typewriter
4764 4768 %logstart
4765 4769 \family default
4766 4770 .
4767 4771 They will fail (with an explanation) if you try to use them before logging
4768 4772 has been started.
4769 4773 \layout Subsection
4770 4774
4771 4775
4772 4776 \begin_inset LatexCommand \label{sub:System-shell-access}
4773 4777
4774 4778 \end_inset
4775 4779
4776 4780 System shell access
4777 4781 \layout Standard
4778 4782
4779 4783 Any input line beginning with a
4780 4784 \family typewriter
4781 4785 !
4782 4786 \family default
4783 4787 character is passed verbatim (minus the
4784 4788 \family typewriter
4785 4789 !
4786 4790 \family default
4787 4791 , of course) to the underlying operating system.
4788 4792 For example, typing
4789 4793 \family typewriter
4790 4794 !ls
4791 4795 \family default
4792 4796 will run
4793 4797 \family typewriter
4794 4798 'ls'
4795 4799 \family default
4796 4800 in the current directory.
4797 4801 \layout Subsubsection
4798 4802
4799 4803 Manual capture of command output
4800 4804 \layout Standard
4801 4805
4802 4806 If the input line begins with
4803 4807 \emph on
4804 4808 two
4805 4809 \emph default
4806 4810 exclamation marks,
4807 4811 \family typewriter
4808 4812 !!
4809 4813 \family default
4810 4814 , the command is executed but its output is captured and returned as a python
4811 4815 list, split on newlines.
4812 4816 Any output sent by the subprocess to standard error is printed separately,
4813 4817 so that the resulting list only captures standard output.
4814 4818 The
4815 4819 \family typewriter
4816 4820 !!
4817 4821 \family default
4818 4822 syntax is a shorthand for the
4819 4823 \family typewriter
4820 4824 %sx
4821 4825 \family default
4822 4826 magic command.
4823 4827 \layout Standard
4824 4828
4825 4829 Finally, the
4826 4830 \family typewriter
4827 4831 %sc
4828 4832 \family default
4829 4833 magic (short for `shell capture') is similar to
4830 4834 \family typewriter
4831 4835 %sx
4832 4836 \family default
4833 4837 , but allowing more fine-grained control of the capture details, and storing
4834 4838 the result directly into a named variable.
4835 4839 \layout Standard
4836 4840
4837 4841 See Sec.\SpecialChar ~
4838 4842
4839 4843 \begin_inset LatexCommand \ref{sec:magic}
4840 4844
4841 4845 \end_inset
4842 4846
4843 4847 for details on the magics
4844 4848 \family typewriter
4845 4849 %sc
4846 4850 \family default
4847 4851 and
4848 4852 \family typewriter
4849 4853 %sx
4850 4854 \family default
4851 4855 , or use IPython's own help (
4852 4856 \family typewriter
4853 4857 sc?
4854 4858 \family default
4855 4859 and
4856 4860 \family typewriter
4857 4861 sx?
4858 4862 \family default
4859 4863 ) for further details.
4860 4864 \layout Standard
4861 4865
4862 4866 IPython also allows you to expand the value of python variables when making
4863 4867 system calls.
4864 4868 Any python variable or expression which you prepend with
4865 4869 \family typewriter
4866 4870 $
4867 4871 \family default
4868 4872 will get expanded before the system call is made.
4869 4873
4870 4874 \layout Standard
4871 4875
4872 4876
4873 4877 \family typewriter
4874 4878 In [1]: pyvar='Hello world'
4875 4879 \newline
4876 4880 In [2]: !echo "A python variable: $pyvar"
4877 4881 \newline
4878 4882 A python variable: Hello world
4879 4883 \layout Standard
4880 4884
4881 4885 If you want the shell to actually see a literal
4882 4886 \family typewriter
4883 4887 $
4884 4888 \family default
4885 4889 , you need to type it twice:
4886 4890 \layout Standard
4887 4891
4888 4892
4889 4893 \family typewriter
4890 4894 In [3]: !echo "A system variable: $$HOME"
4891 4895 \newline
4892 4896 A system variable: /home/fperez
4893 4897 \layout Standard
4894 4898
4895 4899 You can pass arbitrary expressions, though you'll need to delimit them with
4896 4900
4897 4901 \family typewriter
4898 4902 {}
4899 4903 \family default
4900 4904 if there is ambiguity as to the extent of the expression:
4901 4905 \layout Standard
4902 4906
4903 4907
4904 4908 \family typewriter
4905 4909 In [5]: x=10
4906 4910 \newline
4907 4911 In [6]: y=20
4908 4912 \newline
4909 4913 In [13]: !echo $x+y
4910 4914 \newline
4911 4915 10+y
4912 4916 \newline
4913 4917 In [7]: !echo ${x+y}
4914 4918 \newline
4915 4919 30
4916 4920 \layout Standard
4917 4921
4918 4922 Even object attributes can be expanded:
4919 4923 \layout Standard
4920 4924
4921 4925
4922 4926 \family typewriter
4923 4927 In [12]: !echo $sys.argv
4924 4928 \newline
4925 4929 [/home/fperez/usr/bin/ipython]
4926 4930 \layout Subsection
4927 4931
4928 4932 System command aliases
4929 4933 \layout Standard
4930 4934
4931 4935 The
4932 4936 \family typewriter
4933 4937 %alias
4934 4938 \family default
4935 4939 magic function and the
4936 4940 \family typewriter
4937 4941 alias
4938 4942 \family default
4939 4943 option in the
4940 4944 \family typewriter
4941 4945 ipythonrc
4942 4946 \family default
4943 4947 configuration file allow you to define magic functions which are in fact
4944 4948 system shell commands.
4945 4949 These aliases can have parameters.
4946 4950
4947 4951 \layout Standard
4948 4952
4949 4953 '
4950 4954 \family typewriter
4951 4955 %alias alias_name cmd
4952 4956 \family default
4953 4957 ' defines '
4954 4958 \family typewriter
4955 4959 alias_name
4956 4960 \family default
4957 4961 ' as an alias for '
4958 4962 \family typewriter
4959 4963 cmd
4960 4964 \family default
4961 4965 '
4962 4966 \layout Standard
4963 4967
4964 4968 Then, typing '
4965 4969 \family typewriter
4966 4970 %alias_name params
4967 4971 \family default
4968 4972 ' will execute the system command '
4969 4973 \family typewriter
4970 4974 cmd params
4971 4975 \family default
4972 4976 ' (from your underlying operating system).
4973 4977
4974 4978 \layout Standard
4975 4979
4976 4980 You can also define aliases with parameters using
4977 4981 \family typewriter
4978 4982 %s
4979 4983 \family default
4980 4984 specifiers (one per parameter).
4981 4985 The following example defines the
4982 4986 \family typewriter
4983 4987 %parts
4984 4988 \family default
4985 4989 function as an alias to the command '
4986 4990 \family typewriter
4987 4991 echo first %s second %s
4988 4992 \family default
4989 4993 ' where each
4990 4994 \family typewriter
4991 4995 %s
4992 4996 \family default
4993 4997 will be replaced by a positional parameter to the call to
4994 4998 \family typewriter
4995 4999 %parts:
4996 5000 \layout Standard
4997 5001
4998 5002
4999 5003 \family typewriter
5000 5004 In [1]: alias parts echo first %s second %s
5001 5005 \newline
5002 5006 In [2]: %parts A B
5003 5007 \newline
5004 5008 first A second B
5005 5009 \newline
5006 5010 In [3]: %parts A
5007 5011 \newline
5008 5012 Incorrect number of arguments: 2 expected.
5009 5013
5010 5014 \newline
5011 5015 parts is an alias to: 'echo first %s second %s'
5012 5016 \layout Standard
5013 5017
5014 5018 If called with no parameters,
5015 5019 \family typewriter
5016 5020 %alias
5017 5021 \family default
5018 5022 prints the table of currently defined aliases.
5019 5023 \layout Standard
5020 5024
5021 5025 The
5022 5026 \family typewriter
5023 5027 %rehash/rehashx
5024 5028 \family default
5025 5029 magics allow you to load your entire
5026 5030 \family typewriter
5027 5031 $PATH
5028 5032 \family default
5029 5033 as ipython aliases.
5030 5034 See their respective docstrings (or sec.\SpecialChar ~
5031 5035
5032 5036 \begin_inset LatexCommand \ref{sec:magic}
5033 5037
5034 5038 \end_inset
5035 5039
5036 5040 for further details).
5037 5041 \layout Subsection
5038 5042
5039 5043
5040 5044 \begin_inset LatexCommand \label{sec:dreload}
5041 5045
5042 5046 \end_inset
5043 5047
5044 5048 Recursive reload
5045 5049 \layout Standard
5046 5050
5047 5051 The
5048 5052 \family typewriter
5049 5053 dreload
5050 5054 \family default
5051 5055 function does a recursive reload of a module: changes made to the module
5052 5056 since you imported will actually be available without having to exit.
5053 5057 \layout Subsection
5054 5058
5055 5059 Verbose and colored exception traceback printouts
5056 5060 \layout Standard
5057 5061
5058 5062 IPython provides the option to see very detailed exception tracebacks, which
5059 5063 can be especially useful when debugging large programs.
5060 5064 You can run any Python file with the
5061 5065 \family typewriter
5062 5066 %run
5063 5067 \family default
5064 5068 function to benefit from these detailed tracebacks.
5065 5069 Furthermore, both normal and verbose tracebacks can be colored (if your
5066 5070 terminal supports it) which makes them much easier to parse visually.
5067 5071 \layout Standard
5068 5072
5069 5073 See the magic
5070 5074 \family typewriter
5071 5075 xmode
5072 5076 \family default
5073 5077 and
5074 5078 \family typewriter
5075 5079 colors
5076 5080 \family default
5077 5081 functions for details (just type
5078 5082 \family typewriter
5079 5083 %magic
5080 5084 \family default
5081 5085 ).
5082 5086 \layout Standard
5083 5087
5084 5088 These features are basically a terminal version of Ka-Ping Yee's
5085 5089 \family typewriter
5086 5090 cgitb
5087 5091 \family default
5088 5092 module, now part of the standard Python library.
5089 5093 \layout Subsection
5090 5094
5091 5095
5092 5096 \begin_inset LatexCommand \label{sec:cache_input}
5093 5097
5094 5098 \end_inset
5095 5099
5096 5100 Input caching system
5097 5101 \layout Standard
5098 5102
5099 5103 IPython offers numbered prompts (In/Out) with input and output caching.
5100 5104 All input is saved and can be retrieved as variables (besides the usual
5101 5105 arrow key recall).
5102 5106 \layout Standard
5103 5107
5104 5108 The following GLOBAL variables always exist (so don't overwrite them!):
5105 5109
5106 5110 \family typewriter
5107 5111 _i
5108 5112 \family default
5109 5113 : stores previous input.
5110 5114
5111 5115 \family typewriter
5112 5116 _ii
5113 5117 \family default
5114 5118 : next previous.
5115 5119
5116 5120 \family typewriter
5117 5121 _iii
5118 5122 \family default
5119 5123 : next-next previous.
5120 5124
5121 5125 \family typewriter
5122 5126 _ih
5123 5127 \family default
5124 5128 : a list of all input
5125 5129 \family typewriter
5126 5130 _ih[n]
5127 5131 \family default
5128 5132 is the input from line
5129 5133 \family typewriter
5130 5134 n
5131 5135 \family default
5132 5136 and this list is aliased to the global variable
5133 5137 \family typewriter
5134 5138 In
5135 5139 \family default
5136 5140 .
5137 5141 If you overwrite
5138 5142 \family typewriter
5139 5143 In
5140 5144 \family default
5141 5145 with a variable of your own, you can remake the assignment to the internal
5142 5146 list with a simple
5143 5147 \family typewriter
5144 5148 'In=_ih'
5145 5149 \family default
5146 5150 .
5147 5151 \layout Standard
5148 5152
5149 5153 Additionally, global variables named
5150 5154 \family typewriter
5151 5155 _i<n>
5152 5156 \family default
5153 5157 are dynamically created (
5154 5158 \family typewriter
5155 5159 <n>
5156 5160 \family default
5157 5161 being the prompt counter), such that
5158 5162 \newline
5159 5163
5160 5164 \family typewriter
5161 5165 _i<n> == _ih[<n>] == In[<n>].
5162 5166 \layout Standard
5163 5167
5164 5168 For example, what you typed at prompt 14 is available as
5165 5169 \family typewriter
5166 5170 _i14,
5167 5171 \family default
5168 5172
5169 5173 \family typewriter
5170 5174 _ih[14]
5171 5175 \family default
5172 5176 and
5173 5177 \family typewriter
5174 5178 In[14]
5175 5179 \family default
5176 5180 .
5177 5181 \layout Standard
5178 5182
5179 5183 This allows you to easily cut and paste multi line interactive prompts by
5180 5184 printing them out: they print like a clean string, without prompt characters.
5181 5185 You can also manipulate them like regular variables (they are strings),
5182 5186 modify or exec them (typing
5183 5187 \family typewriter
5184 5188 'exec _i9'
5185 5189 \family default
5186 5190 will re-execute the contents of input prompt 9, '
5187 5191 \family typewriter
5188 5192 exec In[9:14]+In[18]
5189 5193 \family default
5190 5194 ' will re-execute lines 9 through 13 and line 18).
5191 5195 \layout Standard
5192 5196
5193 5197 You can also re-execute multiple lines of input easily by using the magic
5194 5198
5195 5199 \family typewriter
5196 5200 %macro
5197 5201 \family default
5198 5202 function (which automates the process and allows re-execution without having
5199 5203 to type '
5200 5204 \family typewriter
5201 5205 exec
5202 5206 \family default
5203 5207 ' every time).
5204 5208 The macro system also allows you to re-execute previous lines which include
5205 5209 magic function calls (which require special processing).
5206 5210 Type
5207 5211 \family typewriter
5208 5212 %macro?
5209 5213 \family default
5210 5214 or see sec.
5211 5215
5212 5216 \begin_inset LatexCommand \ref{sec:magic}
5213 5217
5214 5218 \end_inset
5215 5219
5216 5220 for more details on the macro system.
5217 5221 \layout Standard
5218 5222
5219 5223 A history function
5220 5224 \family typewriter
5221 5225 %hist
5222 5226 \family default
5223 5227 allows you to see any part of your input history by printing a range of
5224 5228 the
5225 5229 \family typewriter
5226 5230 _i
5227 5231 \family default
5228 5232 variables.
5229 5233 \layout Subsection
5230 5234
5231 5235
5232 5236 \begin_inset LatexCommand \label{sec:cache_output}
5233 5237
5234 5238 \end_inset
5235 5239
5236 5240 Output caching system
5237 5241 \layout Standard
5238 5242
5239 5243 For output that is returned from actions, a system similar to the input
5240 5244 cache exists but using
5241 5245 \family typewriter
5242 5246 _
5243 5247 \family default
5244 5248 instead of
5245 5249 \family typewriter
5246 5250 _i
5247 5251 \family default
5248 5252 .
5249 5253 Only actions that produce a result (NOT assignments, for example) are cached.
5250 5254 If you are familiar with Mathematica, IPython's
5251 5255 \family typewriter
5252 5256 _
5253 5257 \family default
5254 5258 variables behave exactly like Mathematica's
5255 5259 \family typewriter
5256 5260 %
5257 5261 \family default
5258 5262 variables.
5259 5263 \layout Standard
5260 5264
5261 5265 The following GLOBAL variables always exist (so don't overwrite them!):
5262 5266
5263 5267 \layout List
5264 5268 \labelwidthstring 00.00.0000
5265 5269
5266 5270
5267 5271 \family typewriter
5268 5272 \series bold
5269 5273 _
5270 5274 \family default
5271 5275 \series default
5272 5276 (a
5273 5277 \emph on
5274 5278 single
5275 5279 \emph default
5276 5280 underscore) : stores previous output, like Python's default interpreter.
5277 5281 \layout List
5278 5282 \labelwidthstring 00.00.0000
5279 5283
5280 5284
5281 5285 \family typewriter
5282 5286 \series bold
5283 5287 __
5284 5288 \family default
5285 5289 \series default
5286 5290 (two underscores): next previous.
5287 5291 \layout List
5288 5292 \labelwidthstring 00.00.0000
5289 5293
5290 5294
5291 5295 \family typewriter
5292 5296 \series bold
5293 5297 ___
5294 5298 \family default
5295 5299 \series default
5296 5300 (three underscores): next-next previous.
5297 5301 \layout Standard
5298 5302
5299 5303 Additionally, global variables named
5300 5304 \family typewriter
5301 5305 _<n>
5302 5306 \family default
5303 5307 are dynamically created (
5304 5308 \family typewriter
5305 5309 <n>
5306 5310 \family default
5307 5311 being the prompt counter), such that the result of output
5308 5312 \family typewriter
5309 5313 <n>
5310 5314 \family default
5311 5315 is always available as
5312 5316 \family typewriter
5313 5317 _<n>
5314 5318 \family default
5315 5319 (don't use the angle brackets, just the number, e.g.
5316 5320
5317 5321 \family typewriter
5318 5322 _21
5319 5323 \family default
5320 5324 ).
5321 5325 \layout Standard
5322 5326
5323 5327 These global variables are all stored in a global dictionary (not a list,
5324 5328 since it only has entries for lines which returned a result) available
5325 5329 under the names
5326 5330 \family typewriter
5327 5331 _oh
5328 5332 \family default
5329 5333 and
5330 5334 \family typewriter
5331 5335 Out
5332 5336 \family default
5333 5337 (similar to
5334 5338 \family typewriter
5335 5339 _ih
5336 5340 \family default
5337 5341 and
5338 5342 \family typewriter
5339 5343 In
5340 5344 \family default
5341 5345 ).
5342 5346 So the output from line 12 can be obtained as
5343 5347 \family typewriter
5344 5348 _12
5345 5349 \family default
5346 5350 ,
5347 5351 \family typewriter
5348 5352 Out[12]
5349 5353 \family default
5350 5354 or
5351 5355 \family typewriter
5352 5356 _oh[12]
5353 5357 \family default
5354 5358 .
5355 5359 If you accidentally overwrite the
5356 5360 \family typewriter
5357 5361 Out
5358 5362 \family default
5359 5363 variable you can recover it by typing
5360 5364 \family typewriter
5361 5365 'Out=_oh
5362 5366 \family default
5363 5367 ' at the prompt.
5364 5368 \layout Standard
5365 5369
5366 5370 This system obviously can potentially put heavy memory demands on your system,
5367 5371 since it prevents Python's garbage collector from removing any previously
5368 5372 computed results.
5369 5373 You can control how many results are kept in memory with the option (at
5370 5374 the command line or in your
5371 5375 \family typewriter
5372 5376 ipythonrc
5373 5377 \family default
5374 5378 file)
5375 5379 \family typewriter
5376 5380 cache_size
5377 5381 \family default
5378 5382 .
5379 5383 If you set it to 0, the whole system is completely disabled and the prompts
5380 5384 revert to the classic
5381 5385 \family typewriter
5382 5386 '>>>'
5383 5387 \family default
5384 5388 of normal Python.
5385 5389 \layout Subsection
5386 5390
5387 5391 Directory history
5388 5392 \layout Standard
5389 5393
5390 5394 Your history of visited directories is kept in the global list
5391 5395 \family typewriter
5392 5396 _dh
5393 5397 \family default
5394 5398 , and the magic
5395 5399 \family typewriter
5396 5400 %cd
5397 5401 \family default
5398 5402 command can be used to go to any entry in that list.
5399 5403 The
5400 5404 \family typewriter
5401 5405 %dhist
5402 5406 \family default
5403 5407 command allows you to view this history.
5404 5408 \layout Subsection
5405 5409
5406 5410 Automatic parentheses and quotes
5407 5411 \layout Standard
5408 5412
5409 5413 These features were adapted from Nathan Gray's LazyPython.
5410 5414 They are meant to allow less typing for common situations.
5411 5415 \layout Subsubsection
5412 5416
5413 5417 Automatic parentheses
5414 5418 \layout Standard
5415 5419
5416 5420 Callable objects (i.e.
5417 5421 functions, methods, etc) can be invoked like this (notice the commas between
5418 5422 the arguments):
5419 5423 \layout Standard
5420 5424
5421 5425
5422 5426 \family typewriter
5423 5427 >>> callable_ob arg1, arg2, arg3
5424 5428 \layout Standard
5425 5429
5426 5430 and the input will be translated to this:
5427 5431 \layout Standard
5428 5432
5429 5433
5430 5434 \family typewriter
5431 5435 --> callable_ob(arg1, arg2, arg3)
5432 5436 \layout Standard
5433 5437
5434 5438 You can force automatic parentheses by using '/' as the first character
5435 5439 of a line.
5436 5440 For example:
5437 5441 \layout Standard
5438 5442
5439 5443
5440 5444 \family typewriter
5441 5445 >>> /globals # becomes 'globals()'
5442 5446 \layout Standard
5443 5447
5444 5448 Note that the '/' MUST be the first character on the line! This won't work:
5445 5449
5446 5450 \layout Standard
5447 5451
5448 5452
5449 5453 \family typewriter
5450 5454 >>> print /globals # syntax error
5451 5455 \layout Standard
5452 5456
5453 5457 In most cases the automatic algorithm should work, so you should rarely
5454 5458 need to explicitly invoke /.
5455 5459 One notable exception is if you are trying to call a function with a list
5456 5460 of tuples as arguments (the parenthesis will confuse IPython):
5457 5461 \layout Standard
5458 5462
5459 5463
5460 5464 \family typewriter
5461 5465 In [1]: zip (1,2,3),(4,5,6) # won't work
5462 5466 \layout Standard
5463 5467
5464 5468 but this will work:
5465 5469 \layout Standard
5466 5470
5467 5471
5468 5472 \family typewriter
5469 5473 In [2]: /zip (1,2,3),(4,5,6)
5470 5474 \newline
5471 5475 ------> zip ((1,2,3),(4,5,6))
5472 5476 \newline
5473 5477 Out[2]= [(1, 4), (2, 5), (3, 6)]
5474 5478 \layout Standard
5475 5479
5476 5480 IPython tells you that it has altered your command line by displaying the
5477 5481 new command line preceded by
5478 5482 \family typewriter
5479 5483 -->
5480 5484 \family default
5481 5485 .
5482 5486 e.g.:
5483 5487 \layout Standard
5484 5488
5485 5489
5486 5490 \family typewriter
5487 5491 In [18]: callable list
5488 5492 \newline
5489 5493 -------> callable (list)
5490 5494 \layout Subsubsection
5491 5495
5492 5496 Automatic quoting
5493 5497 \layout Standard
5494 5498
5495 5499 You can force automatic quoting of a function's arguments by using
5496 5500 \family typewriter
5497 5501 `,'
5498 5502 \family default
5499 5503 or
5500 5504 \family typewriter
5501 5505 `;'
5502 5506 \family default
5503 5507 as the first character of a line.
5504 5508 For example:
5505 5509 \layout Standard
5506 5510
5507 5511
5508 5512 \family typewriter
5509 5513 >>> ,my_function /home/me # becomes my_function("/home/me")
5510 5514 \layout Standard
5511 5515
5512 5516 If you use
5513 5517 \family typewriter
5514 5518 `;'
5515 5519 \family default
5516 5520 instead, the whole argument is quoted as a single string (while
5517 5521 \family typewriter
5518 5522 `,'
5519 5523 \family default
5520 5524 splits on whitespace):
5521 5525 \layout Standard
5522 5526
5523 5527
5524 5528 \family typewriter
5525 5529 >>> ,my_function a b c # becomes my_function("a","b","c")
5526 5530 \layout Standard
5527 5531
5528 5532
5529 5533 \family typewriter
5530 5534 >>> ;my_function a b c # becomes my_function("a b c")
5531 5535 \layout Standard
5532 5536
5533 5537 Note that the `
5534 5538 \family typewriter
5535 5539 ,
5536 5540 \family default
5537 5541 ' or `
5538 5542 \family typewriter
5539 5543 ;
5540 5544 \family default
5541 5545 ' MUST be the first character on the line! This won't work:
5542 5546 \layout Standard
5543 5547
5544 5548
5545 5549 \family typewriter
5546 5550 >>> x = ,my_function /home/me # syntax error
5547 5551 \layout Section
5548 5552
5549 5553
5550 5554 \begin_inset LatexCommand \label{sec:customization}
5551 5555
5552 5556 \end_inset
5553 5557
5554 5558 Customization
5555 5559 \layout Standard
5556 5560
5557 5561 As we've already mentioned, IPython reads a configuration file which can
5558 5562 be specified at the command line (
5559 5563 \family typewriter
5560 5564 -rcfile
5561 5565 \family default
5562 5566 ) or which by default is assumed to be called
5563 5567 \family typewriter
5564 5568 ipythonrc
5565 5569 \family default
5566 5570 .
5567 5571 Such a file is looked for in the current directory where IPython is started
5568 5572 and then in your
5569 5573 \family typewriter
5570 5574 IPYTHONDIR
5571 5575 \family default
5572 5576 , which allows you to have local configuration files for specific projects.
5573 5577 In this section we will call these types of configuration files simply
5574 5578 rcfiles (short for resource configuration file).
5575 5579 \layout Standard
5576 5580
5577 5581 The syntax of an rcfile is one of key-value pairs separated by whitespace,
5578 5582 one per line.
5579 5583 Lines beginning with a
5580 5584 \family typewriter
5581 5585 #
5582 5586 \family default
5583 5587 are ignored as comments, but comments can
5584 5588 \series bold
5585 5589 not
5586 5590 \series default
5587 5591 be put on lines with data (the parser is fairly primitive).
5588 5592 Note that these are not python files, and this is deliberate, because it
5589 5593 allows us to do some things which would be quite tricky to implement if
5590 5594 they were normal python files.
5591 5595 \layout Standard
5592 5596
5593 5597 First, an rcfile can contain permanent default values for almost all command
5594 5598 line options (except things like
5595 5599 \family typewriter
5596 5600 -help
5597 5601 \family default
5598 5602 or
5599 5603 \family typewriter
5600 5604 -Version
5601 5605 \family default
5602 5606 ).
5603 5607 Sec\SpecialChar ~
5604 5608
5605 5609 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5606 5610
5607 5611 \end_inset
5608 5612
5609 5613 contains a description of all command-line options.
5610 5614 However, values you explicitly specify at the command line override the
5611 5615 values defined in the rcfile.
5612 5616 \layout Standard
5613 5617
5614 5618 Besides command line option values, the rcfile can specify values for certain
5615 5619 extra special options which are not available at the command line.
5616 5620 These options are briefly described below.
5617 5621
5618 5622 \layout Standard
5619 5623
5620 5624 Each of these options may appear as many times as you need it in the file.
5621 5625 \layout List
5622 5626 \labelwidthstring 00.00.0000
5623 5627
5624 5628
5625 5629 \family typewriter
5626 5630 \series bold
5627 5631 include\SpecialChar ~
5628 5632 <file1>\SpecialChar ~
5629 5633 <file2>\SpecialChar ~
5630 5634 ...
5631 5635 \family default
5632 5636 \series default
5633 5637 : you can name
5634 5638 \emph on
5635 5639 other
5636 5640 \emph default
5637 5641 rcfiles you want to recursively load up to 15 levels (don't use the
5638 5642 \family typewriter
5639 5643 <>
5640 5644 \family default
5641 5645 brackets in your names!).
5642 5646 This feature allows you to define a 'base' rcfile with general options
5643 5647 and special-purpose files which can be loaded only when needed with particular
5644 5648 configuration options.
5645 5649 To make this more convenient, IPython accepts the
5646 5650 \family typewriter
5647 5651 -profile <name>
5648 5652 \family default
5649 5653 option (abbreviates to
5650 5654 \family typewriter
5651 5655 -p <name
5652 5656 \family default
5653 5657 >)
5654 5658 \family typewriter
5655 5659 which
5656 5660 \family default
5657 5661 tells it to look for an rcfile named
5658 5662 \family typewriter
5659 5663 ipythonrc-<name>
5660 5664 \family default
5661 5665 .
5662 5666
5663 5667 \layout List
5664 5668 \labelwidthstring 00.00.0000
5665 5669
5666 5670
5667 5671 \family typewriter
5668 5672 \series bold
5669 5673 import_mod\SpecialChar ~
5670 5674 <mod1>\SpecialChar ~
5671 5675 <mod2>\SpecialChar ~
5672 5676 ...
5673 5677 \family default
5674 5678 \series default
5675 5679 : import modules with '
5676 5680 \family typewriter
5677 5681 import
5678 5682 \family default
5679 5683
5680 5684 \family typewriter
5681 5685 <mod1>,<mod2>,...
5682 5686 \family default
5683 5687 '
5684 5688 \layout List
5685 5689 \labelwidthstring 00.00.0000
5686 5690
5687 5691
5688 5692 \family typewriter
5689 5693 \series bold
5690 5694 import_some\SpecialChar ~
5691 5695 <mod>\SpecialChar ~
5692 5696 <f1>\SpecialChar ~
5693 5697 <f2>\SpecialChar ~
5694 5698 ...
5695 5699 \family default
5696 5700 \series default
5697 5701 : import functions with '
5698 5702 \family typewriter
5699 5703 from <mod> import
5700 5704 \family default
5701 5705
5702 5706 \family typewriter
5703 5707 <f1>,<f2>,...
5704 5708 \family default
5705 5709 '
5706 5710 \layout List
5707 5711 \labelwidthstring 00.00.0000
5708 5712
5709 5713
5710 5714 \family typewriter
5711 5715 \series bold
5712 5716 import_all\SpecialChar ~
5713 5717 <mod1>\SpecialChar ~
5714 5718 <mod2>\SpecialChar ~
5715 5719 ...
5716 5720 \family default
5717 5721 \series default
5718 5722 : for each module listed import functions with '
5719 5723 \family typewriter
5720 5724 from <mod> import *
5721 5725 \family default
5722 5726 '
5723 5727 \layout List
5724 5728 \labelwidthstring 00.00.0000
5725 5729
5726 5730
5727 5731 \family typewriter
5728 5732 \series bold
5729 5733 execute\SpecialChar ~
5730 5734 <python\SpecialChar ~
5731 5735 code>
5732 5736 \family default
5733 5737 \series default
5734 5738 : give any single-line python code to be executed.
5735 5739 \layout List
5736 5740 \labelwidthstring 00.00.0000
5737 5741
5738 5742
5739 5743 \family typewriter
5740 5744 \series bold
5741 5745 execfile\SpecialChar ~
5742 5746 <filename>
5743 5747 \family default
5744 5748 \series default
5745 5749 : execute the python file given with an '
5746 5750 \family typewriter
5747 5751 execfile(filename)
5748 5752 \family default
5749 5753 ' command.
5750 5754 Username expansion is performed on the given names.
5751 5755 So if you need any amount of extra fancy customization that won't fit in
5752 5756 any of the above 'canned' options, you can just put it in a separate python
5753 5757 file and execute it.
5754 5758 \layout List
5755 5759 \labelwidthstring 00.00.0000
5756 5760
5757 5761
5758 5762 \family typewriter
5759 5763 \series bold
5760 5764 alias\SpecialChar ~
5761 5765 <alias_def>
5762 5766 \family default
5763 5767 \series default
5764 5768 : this is equivalent to calling '
5765 5769 \family typewriter
5766 5770 %alias\SpecialChar ~
5767 5771 <alias_def>
5768 5772 \family default
5769 5773 ' at the IPython command line.
5770 5774 This way, from within IPython you can do common system tasks without having
5771 5775 to exit it or use the
5772 5776 \family typewriter
5773 5777 !
5774 5778 \family default
5775 5779 escape.
5776 5780 IPython isn't meant to be a shell replacement, but it is often very useful
5777 5781 to be able to do things with files while testing code.
5778 5782 This gives you the flexibility to have within IPython any aliases you may
5779 5783 be used to under your normal system shell.
5780 5784 \layout Subsection
5781 5785
5782 5786
5783 5787 \begin_inset LatexCommand \label{sec:ipytonrc-sample}
5784 5788
5785 5789 \end_inset
5786 5790
5787 5791 Sample
5788 5792 \family typewriter
5789 5793 ipythonrc
5790 5794 \family default
5791 5795 file
5792 5796 \layout Standard
5793 5797
5794 5798 The default rcfile, called
5795 5799 \family typewriter
5796 5800 ipythonrc
5797 5801 \family default
5798 5802 and supplied in your
5799 5803 \family typewriter
5800 5804 IPYTHONDIR
5801 5805 \family default
5802 5806 directory contains lots of comments on all of these options.
5803 5807 We reproduce it here for reference:
5804 5808 \layout Standard
5805 5809
5806 5810
5807 5811 \begin_inset ERT
5808 5812 status Open
5809 5813
5810 5814 \layout Standard
5811 5815
5812 5816 \backslash
5813 5817 codelist{../IPython/UserConfig/ipythonrc}
5814 5818 \end_inset
5815 5819
5816 5820
5817 5821 \layout Subsection
5818 5822
5819 5823
5820 5824 \begin_inset LatexCommand \label{sec:prompts}
5821 5825
5822 5826 \end_inset
5823 5827
5824 5828 Fine-tuning your prompt
5825 5829 \layout Standard
5826 5830
5827 5831 IPython's prompts can be customized using a syntax similar to that of the
5828 5832
5829 5833 \family typewriter
5830 5834 bash
5831 5835 \family default
5832 5836 shell.
5833 5837 Many of
5834 5838 \family typewriter
5835 5839 bash
5836 5840 \family default
5837 5841 's escapes are supported, as well as a few additional ones.
5838 5842 We list them below:
5839 5843 \layout Description
5840 5844
5841 5845
5842 5846 \backslash
5843 5847 # the prompt/history count number
5844 5848 \layout Description
5845 5849
5846 5850
5847 5851 \backslash
5848 5852 D the prompt/history count, with the actual digits replaced by dots.
5849 5853 Used mainly in continuation prompts (prompt_in2)
5850 5854 \layout Description
5851 5855
5852 5856
5853 5857 \backslash
5854 5858 w the current working directory
5855 5859 \layout Description
5856 5860
5857 5861
5858 5862 \backslash
5859 5863 W the basename of current working directory
5860 5864 \layout Description
5861 5865
5862 5866
5863 5867 \backslash
5864 5868 X
5865 5869 \emph on
5866 5870 n
5867 5871 \emph default
5868 5872 where
5869 5873 \begin_inset Formula $n=0\ldots5.$
5870 5874 \end_inset
5871 5875
5872 5876 The current working directory, with
5873 5877 \family typewriter
5874 5878 $HOME
5875 5879 \family default
5876 5880 replaced by
5877 5881 \family typewriter
5878 5882 ~
5879 5883 \family default
5880 5884 , and filtered out to contain only
5881 5885 \begin_inset Formula $n$
5882 5886 \end_inset
5883 5887
5884 5888 path elements
5885 5889 \layout Description
5886 5890
5887 5891
5888 5892 \backslash
5889 5893 Y
5890 5894 \emph on
5891 5895 n
5892 5896 \emph default
5893 5897 Similar to
5894 5898 \backslash
5895 5899 X
5896 5900 \emph on
5897 5901 n
5898 5902 \emph default
5899 5903 , but with the
5900 5904 \begin_inset Formula $n+1$
5901 5905 \end_inset
5902 5906
5903 5907 element included if it is
5904 5908 \family typewriter
5905 5909 ~
5906 5910 \family default
5907 5911 (this is similar to the behavior of the %c
5908 5912 \emph on
5909 5913 n
5910 5914 \emph default
5911 5915 escapes in
5912 5916 \family typewriter
5913 5917 tcsh
5914 5918 \family default
5915 5919 )
5916 5920 \layout Description
5917 5921
5918 5922
5919 5923 \backslash
5920 5924 u the username of the current user
5921 5925 \layout Description
5922 5926
5923 5927
5924 5928 \backslash
5925 5929 $ if the effective UID is 0, a #, otherwise a $
5926 5930 \layout Description
5927 5931
5928 5932
5929 5933 \backslash
5930 5934 h the hostname up to the first `.'
5931 5935 \layout Description
5932 5936
5933 5937
5934 5938 \backslash
5935 5939 H the hostname
5936 5940 \layout Description
5937 5941
5938 5942
5939 5943 \backslash
5940 5944 n a newline
5941 5945 \layout Description
5942 5946
5943 5947
5944 5948 \backslash
5945 5949 r a carriage return
5946 5950 \layout Description
5947 5951
5948 5952
5949 5953 \backslash
5950 5954 v IPython version string
5951 5955 \layout Standard
5952 5956
5953 5957 In addition to these, ANSI color escapes can be insterted into the prompts,
5954 5958 as
5955 5959 \family typewriter
5956 5960
5957 5961 \backslash
5958 5962 C_
5959 5963 \emph on
5960 5964 ColorName
5961 5965 \family default
5962 5966 \emph default
5963 5967 .
5964 5968 The list of valid color names is: Black, Blue, Brown, Cyan, DarkGray, Green,
5965 5969 LightBlue, LightCyan, LightGray, LightGreen, LightPurple, LightRed, NoColor,
5966 5970 Normal, Purple, Red, White, Yellow.
5967 5971 \layout Standard
5968 5972
5969 5973 Finally, IPython supports the evaluation of arbitrary expressions in your
5970 5974 prompt string.
5971 5975 The prompt strings are evaluated through the syntax of PEP 215, but basically
5972 5976 you can use
5973 5977 \family typewriter
5974 5978 $x.y
5975 5979 \family default
5976 5980 to expand the value of
5977 5981 \family typewriter
5978 5982 x.y
5979 5983 \family default
5980 5984 , and for more complicated expressions you can use braces:
5981 5985 \family typewriter
5982 5986 ${foo()+x}
5983 5987 \family default
5984 5988 will call function
5985 5989 \family typewriter
5986 5990 foo
5987 5991 \family default
5988 5992 and add to it the value of
5989 5993 \family typewriter
5990 5994 x
5991 5995 \family default
5992 5996 , before putting the result into your prompt.
5993 5997 For example, using
5994 5998 \newline
5995 5999
5996 6000 \family typewriter
5997 6001 prompt_in1 '${commands.getoutput("uptime")}
5998 6002 \backslash
5999 6003 nIn [
6000 6004 \backslash
6001 6005 #]: '
6002 6006 \newline
6003 6007
6004 6008 \family default
6005 6009 will print the result of the uptime command on each prompt (assuming the
6006 6010
6007 6011 \family typewriter
6008 6012 commands
6009 6013 \family default
6010 6014 module has been imported in your
6011 6015 \family typewriter
6012 6016 ipythonrc
6013 6017 \family default
6014 6018 file).
6015 6019 \layout Subsubsection
6016 6020
6017 6021 Prompt examples
6018 6022 \layout Standard
6019 6023
6020 6024 The following options in an ipythonrc file will give you IPython's default
6021 6025 prompts:
6022 6026 \layout Standard
6023 6027
6024 6028
6025 6029 \family typewriter
6026 6030 prompt_in1 'In [
6027 6031 \backslash
6028 6032 #]:'
6029 6033 \newline
6030 6034 prompt_in2 '\SpecialChar ~
6031 6035 \SpecialChar ~
6032 6036 \SpecialChar ~
6033 6037 .
6034 6038 \backslash
6035 6039 D.:'
6036 6040 \newline
6037 6041 prompt_out 'Out[
6038 6042 \backslash
6039 6043 #]:'
6040 6044 \layout Standard
6041 6045
6042 6046 which look like this:
6043 6047 \layout Standard
6044 6048
6045 6049
6046 6050 \family typewriter
6047 6051 In [1]: 1+2
6048 6052 \newline
6049 6053 Out[1]: 3
6050 6054 \layout Standard
6051 6055
6052 6056
6053 6057 \family typewriter
6054 6058 In [2]: for i in (1,2,3):
6055 6059 \newline
6056 6060
6057 6061 \begin_inset ERT
6058 6062 status Collapsed
6059 6063
6060 6064 \layout Standard
6061 6065
6062 6066 \backslash
6063 6067 hspace*{0mm}
6064 6068 \end_inset
6065 6069
6066 6070 \SpecialChar ~
6067 6071 \SpecialChar ~
6068 6072 \SpecialChar ~
6069 6073 ...: \SpecialChar ~
6070 6074 \SpecialChar ~
6071 6075 \SpecialChar ~
6072 6076 \SpecialChar ~
6073 6077 print i,
6074 6078 \newline
6075 6079
6076 6080 \begin_inset ERT
6077 6081 status Collapsed
6078 6082
6079 6083 \layout Standard
6080 6084
6081 6085 \backslash
6082 6086 hspace*{0mm}
6083 6087 \end_inset
6084 6088
6085 6089 \SpecialChar ~
6086 6090 \SpecialChar ~
6087 6091 \SpecialChar ~
6088 6092 ...:
6089 6093 \newline
6090 6094 1 2 3
6091 6095 \layout Standard
6092 6096
6093 6097 These will give you a very colorful prompt with path information:
6094 6098 \layout Standard
6095 6099
6096 6100
6097 6101 \family typewriter
6098 6102 #prompt_in1 '
6099 6103 \backslash
6100 6104 C_Red
6101 6105 \backslash
6102 6106 u
6103 6107 \backslash
6104 6108 C_Blue[
6105 6109 \backslash
6106 6110 C_Cyan
6107 6111 \backslash
6108 6112 Y1
6109 6113 \backslash
6110 6114 C_Blue]
6111 6115 \backslash
6112 6116 C_LightGreen
6113 6117 \backslash
6114 6118 #>'
6115 6119 \newline
6116 6120 prompt_in2 ' ..
6117 6121 \backslash
6118 6122 D>'
6119 6123 \newline
6120 6124 prompt_out '<
6121 6125 \backslash
6122 6126 #>'
6123 6127 \layout Standard
6124 6128
6125 6129 which look like this:
6126 6130 \layout Standard
6127 6131
6128 6132
6129 6133 \family typewriter
6130 6134 \color red
6131 6135 fperez
6132 6136 \color blue
6133 6137 [
6134 6138 \color cyan
6135 6139 ~/ipython
6136 6140 \color blue
6137 6141 ]
6138 6142 \color green
6139 6143 1>
6140 6144 \color default
6141 6145 1+2
6142 6146 \newline
6143 6147
6144 6148 \begin_inset ERT
6145 6149 status Collapsed
6146 6150
6147 6151 \layout Standard
6148 6152
6149 6153 \backslash
6150 6154 hspace*{0mm}
6151 6155 \end_inset
6152 6156
6153 6157 \SpecialChar ~
6154 6158 \SpecialChar ~
6155 6159 \SpecialChar ~
6156 6160 \SpecialChar ~
6157 6161 \SpecialChar ~
6158 6162 \SpecialChar ~
6159 6163 \SpecialChar ~
6160 6164 \SpecialChar ~
6161 6165 \SpecialChar ~
6162 6166 \SpecialChar ~
6163 6167 \SpecialChar ~
6164 6168 \SpecialChar ~
6165 6169 \SpecialChar ~
6166 6170 \SpecialChar ~
6167 6171 \SpecialChar ~
6168 6172 \SpecialChar ~
6169 6173
6170 6174 \color red
6171 6175 <1>
6172 6176 \color default
6173 6177 3
6174 6178 \newline
6175 6179
6176 6180 \color red
6177 6181 fperez
6178 6182 \color blue
6179 6183 [
6180 6184 \color cyan
6181 6185 ~/ipython
6182 6186 \color blue
6183 6187 ]
6184 6188 \color green
6185 6189 2>
6186 6190 \color default
6187 6191 for i in (1,2,3):
6188 6192 \newline
6189 6193
6190 6194 \begin_inset ERT
6191 6195 status Collapsed
6192 6196
6193 6197 \layout Standard
6194 6198
6195 6199 \backslash
6196 6200 hspace*{0mm}
6197 6201 \end_inset
6198 6202
6199 6203 \SpecialChar ~
6200 6204 \SpecialChar ~
6201 6205 \SpecialChar ~
6202 6206 \SpecialChar ~
6203 6207 \SpecialChar ~
6204 6208 \SpecialChar ~
6205 6209 \SpecialChar ~
6206 6210 \SpecialChar ~
6207 6211 \SpecialChar ~
6208 6212 \SpecialChar ~
6209 6213 \SpecialChar ~
6210 6214 \SpecialChar ~
6211 6215 \SpecialChar ~
6212 6216 \SpecialChar ~
6213 6217 \SpecialChar ~
6214 6218
6215 6219 \color green
6216 6220 ...>
6217 6221 \color default
6218 6222 \SpecialChar ~
6219 6223 \SpecialChar ~
6220 6224 \SpecialChar ~
6221 6225 \SpecialChar ~
6222 6226 print i,
6223 6227 \newline
6224 6228
6225 6229 \begin_inset ERT
6226 6230 status Collapsed
6227 6231
6228 6232 \layout Standard
6229 6233
6230 6234 \backslash
6231 6235 hspace*{0mm}
6232 6236 \end_inset
6233 6237
6234 6238 \SpecialChar ~
6235 6239 \SpecialChar ~
6236 6240 \SpecialChar ~
6237 6241 \SpecialChar ~
6238 6242 \SpecialChar ~
6239 6243 \SpecialChar ~
6240 6244 \SpecialChar ~
6241 6245 \SpecialChar ~
6242 6246 \SpecialChar ~
6243 6247 \SpecialChar ~
6244 6248 \SpecialChar ~
6245 6249 \SpecialChar ~
6246 6250 \SpecialChar ~
6247 6251 \SpecialChar ~
6248 6252 \SpecialChar ~
6249 6253
6250 6254 \color green
6251 6255 ...>
6252 6256 \color default
6253 6257
6254 6258 \newline
6255 6259 1 2 3
6256 6260 \layout Standard
6257 6261
6258 6262 The following shows the usage of dynamic expression evaluation:
6259 6263 \layout Subsection
6260 6264
6261 6265
6262 6266 \begin_inset LatexCommand \label{sec:profiles}
6263 6267
6264 6268 \end_inset
6265 6269
6266 6270 IPython profiles
6267 6271 \layout Standard
6268 6272
6269 6273 As we already mentioned, IPython supports the
6270 6274 \family typewriter
6271 6275 -profile
6272 6276 \family default
6273 6277 command-line option (see sec.
6274 6278
6275 6279 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
6276 6280
6277 6281 \end_inset
6278 6282
6279 6283 ).
6280 6284 A profile is nothing more than a particular configuration file like your
6281 6285 basic
6282 6286 \family typewriter
6283 6287 ipythonrc
6284 6288 \family default
6285 6289 one, but with particular customizations for a specific purpose.
6286 6290 When you start IPython with '
6287 6291 \family typewriter
6288 6292 ipython -profile <name>
6289 6293 \family default
6290 6294 ', it assumes that in your
6291 6295 \family typewriter
6292 6296 IPYTHONDIR
6293 6297 \family default
6294 6298 there is a file called
6295 6299 \family typewriter
6296 6300 ipythonrc-<name>
6297 6301 \family default
6298 6302 , and loads it instead of the normal
6299 6303 \family typewriter
6300 6304 ipythonrc
6301 6305 \family default
6302 6306 .
6303 6307 \layout Standard
6304 6308
6305 6309 This system allows you to maintain multiple configurations which load modules,
6306 6310 set options, define functions, etc.
6307 6311 suitable for different tasks and activate them in a very simple manner.
6308 6312 In order to avoid having to repeat all of your basic options (common things
6309 6313 that don't change such as your color preferences, for example), any profile
6310 6314 can include another configuration file.
6311 6315 The most common way to use profiles is then to have each one include your
6312 6316 basic
6313 6317 \family typewriter
6314 6318 ipythonrc
6315 6319 \family default
6316 6320 file as a starting point, and then add further customizations.
6317 6321 \layout Standard
6318 6322
6319 6323 In sections
6320 6324 \begin_inset LatexCommand \ref{sec:syntax-extensions}
6321 6325
6322 6326 \end_inset
6323 6327
6324 6328 and
6325 6329 \begin_inset LatexCommand \ref{sec:Gnuplot}
6326 6330
6327 6331 \end_inset
6328 6332
6329 6333 we discuss some particular profiles which come as part of the standard
6330 6334 IPython distribution.
6331 6335 You may also look in your
6332 6336 \family typewriter
6333 6337 IPYTHONDIR
6334 6338 \family default
6335 6339 directory, any file whose name begins with
6336 6340 \family typewriter
6337 6341 ipythonrc-
6338 6342 \family default
6339 6343 is a profile.
6340 6344 You can use those as examples for further customizations to suit your own
6341 6345 needs.
6342 6346 \layout Section
6343 6347
6344 6348
6345 6349 \begin_inset OptArg
6346 6350 collapsed false
6347 6351
6348 6352 \layout Standard
6349 6353
6350 6354 IPython as default...
6351 6355 \end_inset
6352 6356
6353 6357 IPython as your default Python environment
6354 6358 \layout Standard
6355 6359
6356 6360 Python honors the environment variable
6357 6361 \family typewriter
6358 6362 PYTHONSTARTUP
6359 6363 \family default
6360 6364 and will execute at startup the file referenced by this variable.
6361 6365 If you put at the end of this file the following two lines of code:
6362 6366 \layout Standard
6363 6367
6364 6368
6365 6369 \family typewriter
6366 6370 import IPython
6367 6371 \newline
6368 6372 IPython.Shell.IPShell().mainloop(sys_exit=1)
6369 6373 \layout Standard
6370 6374
6371 6375 then IPython will be your working environment anytime you start Python.
6372 6376 The
6373 6377 \family typewriter
6374 6378 sys_exit=1
6375 6379 \family default
6376 6380 is needed to have IPython issue a call to
6377 6381 \family typewriter
6378 6382 sys.exit()
6379 6383 \family default
6380 6384 when it finishes, otherwise you'll be back at the normal Python '
6381 6385 \family typewriter
6382 6386 >>>
6383 6387 \family default
6384 6388 ' prompt
6385 6389 \begin_inset Foot
6386 6390 collapsed true
6387 6391
6388 6392 \layout Standard
6389 6393
6390 6394 Based on an idea by Holger Krekel.
6391 6395 \end_inset
6392 6396
6393 6397 .
6394 6398 \layout Standard
6395 6399
6396 6400 This is probably useful to developers who manage multiple Python versions
6397 6401 and don't want to have correspondingly multiple IPython versions.
6398 6402 Note that in this mode, there is no way to pass IPython any command-line
6399 6403 options, as those are trapped first by Python itself.
6400 6404 \layout Section
6401 6405
6402 6406
6403 6407 \begin_inset LatexCommand \label{sec:embed}
6404 6408
6405 6409 \end_inset
6406 6410
6407 6411 Embedding IPython
6408 6412 \layout Standard
6409 6413
6410 6414 It is possible to start an IPython instance
6411 6415 \emph on
6412 6416 inside
6413 6417 \emph default
6414 6418 your own Python programs.
6415 6419 This allows you to evaluate dynamically the state of your code, operate
6416 6420 with your variables, analyze them, etc.
6417 6421 Note however that any changes you make to values while in the shell do
6418 6422
6419 6423 \emph on
6420 6424 not
6421 6425 \emph default
6422 6426 propagate back to the running code, so it is safe to modify your values
6423 6427 because you won't break your code in bizarre ways by doing so.
6424 6428 \layout Standard
6425 6429
6426 6430 This feature allows you to easily have a fully functional python environment
6427 6431 for doing object introspection anywhere in your code with a simple function
6428 6432 call.
6429 6433 In some cases a simple print statement is enough, but if you need to do
6430 6434 more detailed analysis of a code fragment this feature can be very valuable.
6431 6435 \layout Standard
6432 6436
6433 6437 It can also be useful in scientific computing situations where it is common
6434 6438 to need to do some automatic, computationally intensive part and then stop
6435 6439 to look at data, plots, etc
6436 6440 \begin_inset Foot
6437 6441 collapsed true
6438 6442
6439 6443 \layout Standard
6440 6444
6441 6445 This functionality was inspired by IDL's combination of the
6442 6446 \family typewriter
6443 6447 stop
6444 6448 \family default
6445 6449 keyword and the
6446 6450 \family typewriter
6447 6451 .continue
6448 6452 \family default
6449 6453 executive command, which I have found very useful in the past, and by a
6450 6454 posting on comp.lang.python by cmkl <cmkleffner-AT-gmx.de> on Dec.
6451 6455 06/01 concerning similar uses of pyrepl.
6452 6456 \end_inset
6453 6457
6454 6458 .
6455 6459 Opening an IPython instance will give you full access to your data and
6456 6460 functions, and you can resume program execution once you are done with
6457 6461 the interactive part (perhaps to stop again later, as many times as needed).
6458 6462 \layout Standard
6459 6463
6460 6464 The following code snippet is the bare minimum you need to include in your
6461 6465 Python programs for this to work (detailed examples follow later):
6462 6466 \layout LyX-Code
6463 6467
6464 6468 from IPython.Shell import IPShellEmbed
6465 6469 \layout LyX-Code
6466 6470
6467 6471 ipshell = IPShellEmbed()
6468 6472 \layout LyX-Code
6469 6473
6470 6474 ipshell() # this call anywhere in your program will start IPython
6471 6475 \layout Standard
6472 6476
6473 6477 You can run embedded instances even in code which is itself being run at
6474 6478 the IPython interactive prompt with '
6475 6479 \family typewriter
6476 6480 %run\SpecialChar ~
6477 6481 <filename>
6478 6482 \family default
6479 6483 '.
6480 6484 Since it's easy to get lost as to where you are (in your top-level IPython
6481 6485 or in your embedded one), it's a good idea in such cases to set the in/out
6482 6486 prompts to something different for the embedded instances.
6483 6487 The code examples below illustrate this.
6484 6488 \layout Standard
6485 6489
6486 6490 You can also have multiple IPython instances in your program and open them
6487 6491 separately, for example with different options for data presentation.
6488 6492 If you close and open the same instance multiple times, its prompt counters
6489 6493 simply continue from each execution to the next.
6490 6494 \layout Standard
6491 6495
6492 6496 Please look at the docstrings in the
6493 6497 \family typewriter
6494 6498 Shell.py
6495 6499 \family default
6496 6500 module for more details on the use of this system.
6497 6501 \layout Standard
6498 6502
6499 6503 The following sample file illustrating how to use the embedding functionality
6500 6504 is provided in the examples directory as
6501 6505 \family typewriter
6502 6506 example-embed.py
6503 6507 \family default
6504 6508 .
6505 6509 It should be fairly self-explanatory:
6506 6510 \layout Standard
6507 6511
6508 6512
6509 6513 \begin_inset ERT
6510 6514 status Open
6511 6515
6512 6516 \layout Standard
6513 6517
6514 6518 \backslash
6515 6519 codelist{examples/example-embed.py}
6516 6520 \end_inset
6517 6521
6518 6522
6519 6523 \layout Standard
6520 6524
6521 6525 Once you understand how the system functions, you can use the following
6522 6526 code fragments in your programs which are ready for cut and paste:
6523 6527 \layout Standard
6524 6528
6525 6529
6526 6530 \begin_inset ERT
6527 6531 status Open
6528 6532
6529 6533 \layout Standard
6530 6534
6531 6535 \backslash
6532 6536 codelist{examples/example-embed-short.py}
6533 6537 \end_inset
6534 6538
6535 6539
6536 6540 \layout Section
6537 6541
6538 6542
6539 6543 \begin_inset LatexCommand \label{sec:using-pdb}
6540 6544
6541 6545 \end_inset
6542 6546
6543 6547 Using the Python debugger (
6544 6548 \family typewriter
6545 6549 pdb
6546 6550 \family default
6547 6551 )
6548 6552 \layout Subsection
6549 6553
6550 6554 Running entire programs via
6551 6555 \family typewriter
6552 6556 pdb
6553 6557 \layout Standard
6554 6558
6555 6559
6556 6560 \family typewriter
6557 6561 pdb
6558 6562 \family default
6559 6563 , the Python debugger, is a powerful interactive debugger which allows you
6560 6564 to step through code, set breakpoints, watch variables, etc.
6561 6565 IPython makes it very easy to start any script under the control of
6562 6566 \family typewriter
6563 6567 pdb
6564 6568 \family default
6565 6569 , regardless of whether you have wrapped it into a
6566 6570 \family typewriter
6567 6571 `main()'
6568 6572 \family default
6569 6573 function or not.
6570 6574 For this, simply type
6571 6575 \family typewriter
6572 6576 `%run -d myscript'
6573 6577 \family default
6574 6578 at an IPython prompt.
6575 6579 See the
6576 6580 \family typewriter
6577 6581 %run
6578 6582 \family default
6579 6583 command's documentation (via
6580 6584 \family typewriter
6581 6585 `%run?'
6582 6586 \family default
6583 6587 or in Sec.\SpecialChar ~
6584 6588
6585 6589 \begin_inset LatexCommand \ref{sec:magic}
6586 6590
6587 6591 \end_inset
6588 6592
6589 6593 ) for more details, including how to control where
6590 6594 \family typewriter
6591 6595 pdb
6592 6596 \family default
6593 6597 will stop execution first.
6594 6598 \layout Standard
6595 6599
6596 6600 For more information on the use of the
6597 6601 \family typewriter
6598 6602 pdb
6599 6603 \family default
6600 6604 debugger, read the included
6601 6605 \family typewriter
6602 6606 pdb.doc
6603 6607 \family default
6604 6608 file (part of the standard Python distribution).
6605 6609 On a stock Linux system it is located at
6606 6610 \family typewriter
6607 6611 /usr/lib/python2.3/pdb.doc
6608 6612 \family default
6609 6613 , but the easiest way to read it is by using the
6610 6614 \family typewriter
6611 6615 help()
6612 6616 \family default
6613 6617 function of the
6614 6618 \family typewriter
6615 6619 pdb
6616 6620 \family default
6617 6621 module as follows (in an IPython prompt):
6618 6622 \layout Standard
6619 6623
6620 6624
6621 6625 \family typewriter
6622 6626 In [1]: import pdb
6623 6627 \newline
6624 6628 In [2]: pdb.help()
6625 6629 \layout Standard
6626 6630
6627 6631 This will load the
6628 6632 \family typewriter
6629 6633 pdb.doc
6630 6634 \family default
6631 6635 document in a file viewer for you automatically.
6632 6636 \layout Subsection
6633 6637
6634 6638 Automatic invocation of
6635 6639 \family typewriter
6636 6640 pdb
6637 6641 \family default
6638 6642 on exceptions
6639 6643 \layout Standard
6640 6644
6641 6645 IPython, if started with the
6642 6646 \family typewriter
6643 6647 -pdb
6644 6648 \family default
6645 6649 option (or if the option is set in your rc file) can call the Python
6646 6650 \family typewriter
6647 6651 pdb
6648 6652 \family default
6649 6653 debugger every time your code triggers an uncaught exception
6650 6654 \begin_inset Foot
6651 6655 collapsed true
6652 6656
6653 6657 \layout Standard
6654 6658
6655 6659 Many thanks to Christopher Hart for the request which prompted adding this
6656 6660 feature to IPython.
6657 6661 \end_inset
6658 6662
6659 6663 .
6660 6664 This feature can also be toggled at any time with the
6661 6665 \family typewriter
6662 6666 %pdb
6663 6667 \family default
6664 6668 magic command.
6665 6669 This can be extremely useful in order to find the origin of subtle bugs,
6666 6670 because
6667 6671 \family typewriter
6668 6672 pdb
6669 6673 \family default
6670 6674 opens up at the point in your code which triggered the exception, and while
6671 6675 your program is at this point `dead', all the data is still available and
6672 6676 you can walk up and down the stack frame and understand the origin of the
6673 6677 problem.
6674 6678 \layout Standard
6675 6679
6676 6680 Furthermore, you can use these debugging facilities both with the embedded
6677 6681 IPython mode and without IPython at all.
6678 6682 For an embedded shell (see sec.
6679 6683
6680 6684 \begin_inset LatexCommand \ref{sec:embed}
6681 6685
6682 6686 \end_inset
6683 6687
6684 6688 ), simply call the constructor with
6685 6689 \family typewriter
6686 6690 `-pdb'
6687 6691 \family default
6688 6692 in the argument string and automatically
6689 6693 \family typewriter
6690 6694 pdb
6691 6695 \family default
6692 6696 will be called if an uncaught exception is triggered by your code.
6693 6697
6694 6698 \layout Standard
6695 6699
6696 6700 For stand-alone use of the feature in your programs which do not use IPython
6697 6701 at all, put the following lines toward the top of your `main' routine:
6698 6702 \layout Standard
6699 6703 \align left
6700 6704
6701 6705 \family typewriter
6702 6706 import sys,IPython.ultraTB
6703 6707 \newline
6704 6708 sys.excepthook = IPython.ultraTB.FormattedTB(mode=`Verbose', color_scheme=`Linux',
6705 6709 call_pdb=1)
6706 6710 \layout Standard
6707 6711
6708 6712 The
6709 6713 \family typewriter
6710 6714 mode
6711 6715 \family default
6712 6716 keyword can be either
6713 6717 \family typewriter
6714 6718 `Verbose'
6715 6719 \family default
6716 6720 or
6717 6721 \family typewriter
6718 6722 `Plain'
6719 6723 \family default
6720 6724 , giving either very detailed or normal tracebacks respectively.
6721 6725 The
6722 6726 \family typewriter
6723 6727 color_scheme
6724 6728 \family default
6725 6729 keyword can be one of
6726 6730 \family typewriter
6727 6731 `NoColor'
6728 6732 \family default
6729 6733 ,
6730 6734 \family typewriter
6731 6735 `Linux'
6732 6736 \family default
6733 6737 (default) or
6734 6738 \family typewriter
6735 6739 `LightBG'
6736 6740 \family default
6737 6741 .
6738 6742 These are the same options which can be set in IPython with
6739 6743 \family typewriter
6740 6744 -colors
6741 6745 \family default
6742 6746 and
6743 6747 \family typewriter
6744 6748 -xmode
6745 6749 \family default
6746 6750 .
6747 6751 \layout Standard
6748 6752
6749 6753 This will give any of your programs detailed, colored tracebacks with automatic
6750 6754 invocation of
6751 6755 \family typewriter
6752 6756 pdb
6753 6757 \family default
6754 6758 .
6755 6759 \layout Section
6756 6760
6757 6761
6758 6762 \begin_inset LatexCommand \label{sec:syntax-extensions}
6759 6763
6760 6764 \end_inset
6761 6765
6762 6766 Extensions for syntax processing
6763 6767 \layout Standard
6764 6768
6765 6769 This isn't for the faint of heart, because the potential for breaking things
6766 6770 is quite high.
6767 6771 But it can be a very powerful and useful feature.
6768 6772 In a nutshell, you can redefine the way IPython processes the user input
6769 6773 line to accept new, special extensions to the syntax without needing to
6770 6774 change any of IPython's own code.
6771 6775 \layout Standard
6772 6776
6773 6777 In the
6774 6778 \family typewriter
6775 6779 IPython/Extensions
6776 6780 \family default
6777 6781 directory you will find some examples supplied, which we will briefly describe
6778 6782 now.
6779 6783 These can be used `as is' (and both provide very useful functionality),
6780 6784 or you can use them as a starting point for writing your own extensions.
6781 6785 \layout Subsection
6782 6786
6783 6787 Pasting of code starting with
6784 6788 \family typewriter
6785 6789 `>>>
6786 6790 \family default
6787 6791 ' or
6788 6792 \family typewriter
6789 6793 `...
6790 6794
6791 6795 \family default
6792 6796 '
6793 6797 \layout Standard
6794 6798
6795 6799 In the python tutorial it is common to find code examples which have been
6796 6800 taken from real python sessions.
6797 6801 The problem with those is that all the lines begin with either
6798 6802 \family typewriter
6799 6803 `>>>
6800 6804 \family default
6801 6805 ' or
6802 6806 \family typewriter
6803 6807 `...
6804 6808
6805 6809 \family default
6806 6810 ', which makes it impossible to paste them all at once.
6807 6811 One must instead do a line by line manual copying, carefully removing the
6808 6812 leading extraneous characters.
6809 6813 \layout Standard
6810 6814
6811 6815 This extension identifies those starting characters and removes them from
6812 6816 the input automatically, so that one can paste multi-line examples directly
6813 6817 into IPython, saving a lot of time.
6814 6818 Please look at the file
6815 6819 \family typewriter
6816 6820 InterpreterPasteInput.py
6817 6821 \family default
6818 6822 in the
6819 6823 \family typewriter
6820 6824 IPython/Extensions
6821 6825 \family default
6822 6826 directory for details on how this is done.
6823 6827 \layout Standard
6824 6828
6825 6829 IPython comes with a special profile enabling this feature, called
6826 6830 \family typewriter
6827 6831 tutorial
6828 6832 \family default
6829 6833 \emph on
6830 6834 .
6831 6835
6832 6836 \emph default
6833 6837 Simply start IPython via
6834 6838 \family typewriter
6835 6839 `ipython\SpecialChar ~
6836 6840 -p\SpecialChar ~
6837 6841 tutorial'
6838 6842 \family default
6839 6843 and the feature will be available.
6840 6844 In a normal IPython session you can activate the feature by importing the
6841 6845 corresponding module with:
6842 6846 \newline
6843 6847
6844 6848 \family typewriter
6845 6849 In [1]: import IPython.Extensions.InterpreterPasteInput
6846 6850 \layout Standard
6847 6851
6848 6852 The following is a 'screenshot' of how things work when this extension is
6849 6853 on, copying an example from the standard tutorial:
6850 6854 \layout Standard
6851 6855
6852 6856
6853 6857 \family typewriter
6854 6858 IPython profile: tutorial
6855 6859 \newline
6856 6860 \SpecialChar ~
6857 6861
6858 6862 \newline
6859 6863 *** Pasting of code with ">>>" or "..." has been enabled.
6860 6864 \newline
6861 6865 \SpecialChar ~
6862 6866
6863 6867 \newline
6864 6868 In [1]: >>> def fib2(n): # return Fibonacci series up to n
6865 6869 \newline
6866 6870
6867 6871 \begin_inset ERT
6868 6872 status Collapsed
6869 6873
6870 6874 \layout Standard
6871 6875
6872 6876 \backslash
6873 6877 hspace*{0mm}
6874 6878 \end_inset
6875 6879
6876 6880 \SpecialChar ~
6877 6881 \SpecialChar ~
6878 6882 ...: ...\SpecialChar ~
6879 6883 \SpecialChar ~
6880 6884 \SpecialChar ~
6881 6885 \SpecialChar ~
6882 6886 """Return a list containing the Fibonacci series up to n."""
6883 6887 \newline
6884 6888
6885 6889 \begin_inset ERT
6886 6890 status Collapsed
6887 6891
6888 6892 \layout Standard
6889 6893
6890 6894 \backslash
6891 6895 hspace*{0mm}
6892 6896 \end_inset
6893 6897
6894 6898 \SpecialChar ~
6895 6899 \SpecialChar ~
6896 6900 ...: ...\SpecialChar ~
6897 6901 \SpecialChar ~
6898 6902 \SpecialChar ~
6899 6903 \SpecialChar ~
6900 6904 result = []
6901 6905 \newline
6902 6906
6903 6907 \begin_inset ERT
6904 6908 status Collapsed
6905 6909
6906 6910 \layout Standard
6907 6911
6908 6912 \backslash
6909 6913 hspace*{0mm}
6910 6914 \end_inset
6911 6915
6912 6916 \SpecialChar ~
6913 6917 \SpecialChar ~
6914 6918 ...: ...\SpecialChar ~
6915 6919 \SpecialChar ~
6916 6920 \SpecialChar ~
6917 6921 \SpecialChar ~
6918 6922 a, b = 0, 1
6919 6923 \newline
6920 6924
6921 6925 \begin_inset ERT
6922 6926 status Collapsed
6923 6927
6924 6928 \layout Standard
6925 6929
6926 6930 \backslash
6927 6931 hspace*{0mm}
6928 6932 \end_inset
6929 6933
6930 6934 \SpecialChar ~
6931 6935 \SpecialChar ~
6932 6936 ...: ...\SpecialChar ~
6933 6937 \SpecialChar ~
6934 6938 \SpecialChar ~
6935 6939 \SpecialChar ~
6936 6940 while b < n:
6937 6941 \newline
6938 6942
6939 6943 \begin_inset ERT
6940 6944 status Collapsed
6941 6945
6942 6946 \layout Standard
6943 6947
6944 6948 \backslash
6945 6949 hspace*{0mm}
6946 6950 \end_inset
6947 6951
6948 6952 \SpecialChar ~
6949 6953 \SpecialChar ~
6950 6954 ...: ...\SpecialChar ~
6951 6955 \SpecialChar ~
6952 6956 \SpecialChar ~
6953 6957 \SpecialChar ~
6954 6958 \SpecialChar ~
6955 6959 \SpecialChar ~
6956 6960 \SpecialChar ~
6957 6961 \SpecialChar ~
6958 6962 result.append(b)\SpecialChar ~
6959 6963 \SpecialChar ~
6960 6964 \SpecialChar ~
6961 6965 # see below
6962 6966 \newline
6963 6967
6964 6968 \begin_inset ERT
6965 6969 status Collapsed
6966 6970
6967 6971 \layout Standard
6968 6972
6969 6973 \backslash
6970 6974 hspace*{0mm}
6971 6975 \end_inset
6972 6976
6973 6977 \SpecialChar ~
6974 6978 \SpecialChar ~
6975 6979 ...: ...\SpecialChar ~
6976 6980 \SpecialChar ~
6977 6981 \SpecialChar ~
6978 6982 \SpecialChar ~
6979 6983 \SpecialChar ~
6980 6984 \SpecialChar ~
6981 6985 \SpecialChar ~
6982 6986 \SpecialChar ~
6983 6987 a, b = b, a+b
6984 6988 \newline
6985 6989
6986 6990 \begin_inset ERT
6987 6991 status Collapsed
6988 6992
6989 6993 \layout Standard
6990 6994
6991 6995 \backslash
6992 6996 hspace*{0mm}
6993 6997 \end_inset
6994 6998
6995 6999 \SpecialChar ~
6996 7000 \SpecialChar ~
6997 7001 ...: ...\SpecialChar ~
6998 7002 \SpecialChar ~
6999 7003 \SpecialChar ~
7000 7004 \SpecialChar ~
7001 7005 return result
7002 7006 \newline
7003 7007
7004 7008 \begin_inset ERT
7005 7009 status Collapsed
7006 7010
7007 7011 \layout Standard
7008 7012
7009 7013 \backslash
7010 7014 hspace*{0mm}
7011 7015 \end_inset
7012 7016
7013 7017 \SpecialChar ~
7014 7018 \SpecialChar ~
7015 7019 ...:
7016 7020 \newline
7017 7021 \SpecialChar ~
7018 7022
7019 7023 \newline
7020 7024 In [2]: fib2(10)
7021 7025 \newline
7022 7026 Out[2]: [1, 1, 2, 3, 5, 8]
7023 7027 \layout Standard
7024 7028
7025 7029 Note that as currently written, this extension does
7026 7030 \emph on
7027 7031 not
7028 7032 \emph default
7029 7033 recognize IPython's prompts for pasting.
7030 7034 Those are more complicated, since the user can change them very easily,
7031 7035 they involve numbers and can vary in length.
7032 7036 One could however extract all the relevant information from the IPython
7033 7037 instance and build an appropriate regular expression.
7034 7038 This is left as an exercise for the reader.
7035 7039 \layout Subsection
7036 7040
7037 7041 Input of physical quantities with units
7038 7042 \layout Standard
7039 7043
7040 7044 The module
7041 7045 \family typewriter
7042 7046 PhysicalQInput
7043 7047 \family default
7044 7048 allows a simplified form of input for physical quantities with units.
7045 7049 This file is meant to be used in conjunction with the
7046 7050 \family typewriter
7047 7051 PhysicalQInteractive
7048 7052 \family default
7049 7053 module (in the same directory) and
7050 7054 \family typewriter
7051 7055 Physics.PhysicalQuantities
7052 7056 \family default
7053 7057 from Konrad Hinsen's ScientificPython (
7054 7058 \begin_inset LatexCommand \htmlurl{http://dirac.cnrs-orleans.fr/ScientificPython/}
7055 7059
7056 7060 \end_inset
7057 7061
7058 7062 ).
7059 7063 \layout Standard
7060 7064
7061 7065 The
7062 7066 \family typewriter
7063 7067 Physics.PhysicalQuantities
7064 7068 \family default
7065 7069 module defines
7066 7070 \family typewriter
7067 7071 PhysicalQuantity
7068 7072 \family default
7069 7073 objects, but these must be declared as instances of a class.
7070 7074 For example, to define
7071 7075 \family typewriter
7072 7076 v
7073 7077 \family default
7074 7078 as a velocity of 3\SpecialChar ~
7075 7079 m/s, normally you would write:
7076 7080 \family typewriter
7077 7081
7078 7082 \newline
7079 7083 In [1]: v = PhysicalQuantity(3,'m/s')
7080 7084 \layout Standard
7081 7085
7082 7086 Using the
7083 7087 \family typewriter
7084 7088 PhysicalQ_Input
7085 7089 \family default
7086 7090 extension this can be input instead as:
7087 7091 \family typewriter
7088 7092
7089 7093 \newline
7090 7094 In [1]: v = 3 m/s
7091 7095 \family default
7092 7096
7093 7097 \newline
7094 7098 which is much more convenient for interactive use (even though it is blatantly
7095 7099 invalid Python syntax).
7096 7100 \layout Standard
7097 7101
7098 7102 The
7099 7103 \family typewriter
7100 7104 physics
7101 7105 \family default
7102 7106 profile supplied with IPython (enabled via
7103 7107 \family typewriter
7104 7108 'ipython -p physics'
7105 7109 \family default
7106 7110 ) uses these extensions, which you can also activate with:
7107 7111 \layout Standard
7108 7112
7109 7113
7110 7114 \family typewriter
7111 7115 from math import * # math MUST be imported BEFORE PhysicalQInteractive
7112 7116 \newline
7113 7117 from IPython.Extensions.PhysicalQInteractive import *
7114 7118 \newline
7115 7119 import IPython.Extensions.PhysicalQInput
7116 7120 \layout Section
7117 7121
7118 7122
7119 7123 \begin_inset LatexCommand \label{sec:IPython-as-shell}
7120 7124
7121 7125 \end_inset
7122 7126
7123 7127 IPython as a system shell
7124 7128 \layout Standard
7125 7129
7126 7130 IPython ships with a special profile called
7127 7131 \family typewriter
7128 7132 pysh
7129 7133 \family default
7130 7134 , which you can activate at the command line as
7131 7135 \family typewriter
7132 7136 `ipython -p pysh'
7133 7137 \family default
7134 7138 .
7135 7139 This loads
7136 7140 \family typewriter
7137 7141 InterpreterExec
7138 7142 \family default
7139 7143 , along with some additional facilities and a prompt customized for filesystem
7140 7144 navigation.
7141 7145 \layout Standard
7142 7146
7143 7147 Note that this does
7144 7148 \emph on
7145 7149 not
7146 7150 \emph default
7147 7151 make IPython a full-fledged system shell.
7148 7152 In particular, it has no job control, so if you type Ctrl-Z (under Unix),
7149 7153 you'll suspend pysh itself, not the process you just started.
7150 7154
7151 7155 \layout Standard
7152 7156
7153 7157 What the shell profile allows you to do is to use the convenient and powerful
7154 7158 syntax of Python to do quick scripting at the command line.
7155 7159 Below we describe some of its features.
7156 7160 \layout Subsection
7157 7161
7158 7162 Aliases
7159 7163 \layout Standard
7160 7164
7161 7165 All of your
7162 7166 \family typewriter
7163 7167 $PATH
7164 7168 \family default
7165 7169 has been loaded as IPython aliases, so you should be able to type any normal
7166 7170 system command and have it executed.
7167 7171 See
7168 7172 \family typewriter
7169 7173 %alias?
7170 7174 \family default
7171 7175 and
7172 7176 \family typewriter
7173 7177 %unalias?
7174 7178 \family default
7175 7179 for details on the alias facilities.
7176 7180 See also
7177 7181 \family typewriter
7178 7182 %rehash?
7179 7183 \family default
7180 7184 and
7181 7185 \family typewriter
7182 7186 %rehashx?
7183 7187 \family default
7184 7188 for details on the mechanism used to load
7185 7189 \family typewriter
7186 7190 $PATH
7187 7191 \family default
7188 7192 .
7189 7193 \layout Subsection
7190 7194
7191 7195 Special syntax
7192 7196 \layout Standard
7193 7197
7194 7198 Any lines which begin with
7195 7199 \family typewriter
7196 7200 `~'
7197 7201 \family default
7198 7202 ,
7199 7203 \family typewriter
7200 7204 `/'
7201 7205 \family default
7202 7206 and
7203 7207 \family typewriter
7204 7208 `.'
7205 7209 \family default
7206 7210 will be executed as shell commands instead of as Python code.
7207 7211 The special escapes below are also recognized.
7208 7212
7209 7213 \family typewriter
7210 7214 !cmd
7211 7215 \family default
7212 7216 is valid in single or multi-line input, all others are only valid in single-lin
7213 7217 e input:
7214 7218 \layout Description
7215 7219
7216 7220
7217 7221 \family typewriter
7218 7222 !cmd
7219 7223 \family default
7220 7224 pass `cmd' directly to the shell
7221 7225 \layout Description
7222 7226
7223 7227
7224 7228 \family typewriter
7225 7229 !!cmd
7226 7230 \family default
7227 7231 execute `cmd' and return output as a list (split on `
7228 7232 \backslash
7229 7233 n')
7230 7234 \layout Description
7231 7235
7232 7236
7233 7237 \family typewriter
7234 7238 $var=cmd
7235 7239 \family default
7236 7240 capture output of cmd into var, as a string
7237 7241 \layout Description
7238 7242
7239 7243
7240 7244 \family typewriter
7241 7245 $$var=cmd
7242 7246 \family default
7243 7247 capture output of cmd into var, as a list (split on `
7244 7248 \backslash
7245 7249 n')
7246 7250 \layout Standard
7247 7251
7248 7252 The
7249 7253 \family typewriter
7250 7254 $
7251 7255 \family default
7252 7256 /
7253 7257 \family typewriter
7254 7258 $$
7255 7259 \family default
7256 7260 syntaxes make Python variables from system output, which you can later
7257 7261 use for further scripting.
7258 7262 The converse is also possible: when executing an alias or calling to the
7259 7263 system via
7260 7264 \family typewriter
7261 7265 !
7262 7266 \family default
7263 7267 /
7264 7268 \family typewriter
7265 7269 !!
7266 7270 \family default
7267 7271 , you can expand any python variable or expression by prepending it with
7268 7272
7269 7273 \family typewriter
7270 7274 $
7271 7275 \family default
7272 7276 .
7273 7277 Full details of the allowed syntax can be found in Python's PEP 215.
7274 7278 \layout Standard
7275 7279
7276 7280 A few brief examples will illustrate these (note that the indentation below
7277 7281 may be incorrectly displayed):
7278 7282 \layout Standard
7279 7283
7280 7284
7281 7285 \family typewriter
7282 7286 fperez[~/test]|3> !ls *s.py
7283 7287 \newline
7284 7288 scopes.py strings.py
7285 7289 \layout Standard
7286 7290
7287 7291 ls is an internal alias, so there's no need to use
7288 7292 \family typewriter
7289 7293 !
7290 7294 \family default
7291 7295 :
7292 7296 \layout Standard
7293 7297
7294 7298
7295 7299 \family typewriter
7296 7300 fperez[~/test]|4> ls *s.py
7297 7301 \newline
7298 7302 scopes.py* strings.py
7299 7303 \layout Standard
7300 7304
7301 7305 !!ls will return the output into a Python variable:
7302 7306 \layout Standard
7303 7307
7304 7308
7305 7309 \family typewriter
7306 7310 fperez[~/test]|5> !!ls *s.py
7307 7311 \newline
7308 7312
7309 7313 \begin_inset ERT
7310 7314 status Collapsed
7311 7315
7312 7316 \layout Standard
7313 7317
7314 7318 \backslash
7315 7319 hspace*{0mm}
7316 7320 \end_inset
7317 7321
7318 7322 \SpecialChar ~
7319 7323 \SpecialChar ~
7320 7324 \SpecialChar ~
7321 7325 \SpecialChar ~
7322 7326 \SpecialChar ~
7323 7327 \SpecialChar ~
7324 7328 \SpecialChar ~
7325 7329 \SpecialChar ~
7326 7330 \SpecialChar ~
7327 7331 \SpecialChar ~
7328 7332 \SpecialChar ~
7329 7333 \SpecialChar ~
7330 7334 \SpecialChar ~
7331 7335 \SpecialChar ~
7332 7336 <5> ['scopes.py', 'strings.py']
7333 7337 \newline
7334 7338 fperez[~/test]|6> print _5
7335 7339 \newline
7336 7340 ['scopes.py', 'strings.py']
7337 7341 \layout Standard
7338 7342
7339 7343
7340 7344 \family typewriter
7341 7345 $
7342 7346 \family default
7343 7347 and
7344 7348 \family typewriter
7345 7349 $$
7346 7350 \family default
7347 7351 allow direct capture to named variables:
7348 7352 \layout Standard
7349 7353
7350 7354
7351 7355 \family typewriter
7352 7356 fperez[~/test]|7> $astr = ls *s.py
7353 7357 \newline
7354 7358 fperez[~/test]|8> astr
7355 7359 \newline
7356 7360
7357 7361 \begin_inset ERT
7358 7362 status Collapsed
7359 7363
7360 7364 \layout Standard
7361 7365
7362 7366 \backslash
7363 7367 hspace*{0mm}
7364 7368 \end_inset
7365 7369
7366 7370 \SpecialChar ~
7367 7371 \SpecialChar ~
7368 7372 \SpecialChar ~
7369 7373 \SpecialChar ~
7370 7374 \SpecialChar ~
7371 7375 \SpecialChar ~
7372 7376 \SpecialChar ~
7373 7377 \SpecialChar ~
7374 7378 \SpecialChar ~
7375 7379 \SpecialChar ~
7376 7380 \SpecialChar ~
7377 7381 \SpecialChar ~
7378 7382 \SpecialChar ~
7379 7383 \SpecialChar ~
7380 7384 <8> 'scopes.py
7381 7385 \backslash
7382 7386 nstrings.py'
7383 7387 \layout Standard
7384 7388
7385 7389
7386 7390 \family typewriter
7387 7391 fperez[~/test]|9> $$alist = ls *s.py
7388 7392 \newline
7389 7393 fperez[~/test]|10> alist
7390 7394 \newline
7391 7395
7392 7396 \begin_inset ERT
7393 7397 status Collapsed
7394 7398
7395 7399 \layout Standard
7396 7400
7397 7401 \backslash
7398 7402 hspace*{0mm}
7399 7403 \end_inset
7400 7404
7401 7405 \SpecialChar ~
7402 7406 \SpecialChar ~
7403 7407 \SpecialChar ~
7404 7408 \SpecialChar ~
7405 7409 \SpecialChar ~
7406 7410 \SpecialChar ~
7407 7411 \SpecialChar ~
7408 7412 \SpecialChar ~
7409 7413 \SpecialChar ~
7410 7414 \SpecialChar ~
7411 7415 \SpecialChar ~
7412 7416 \SpecialChar ~
7413 7417 \SpecialChar ~
7414 7418 \SpecialChar ~
7415 7419 <10> ['scopes.py', 'strings.py']
7416 7420 \layout Standard
7417 7421
7418 7422 alist is now a normal python list you can loop over.
7419 7423 Using
7420 7424 \family typewriter
7421 7425 $
7422 7426 \family default
7423 7427 will expand back the python values when alias calls are made:
7424 7428 \layout Standard
7425 7429
7426 7430
7427 7431 \family typewriter
7428 7432 fperez[~/test]|11> for f in alist:
7429 7433 \newline
7430 7434
7431 7435 \begin_inset ERT
7432 7436 status Collapsed
7433 7437
7434 7438 \layout Standard
7435 7439
7436 7440 \backslash
7437 7441 hspace*{0mm}
7438 7442 \end_inset
7439 7443
7440 7444 \SpecialChar ~
7441 7445 \SpecialChar ~
7442 7446 \SpecialChar ~
7443 7447 \SpecialChar ~
7444 7448 \SpecialChar ~
7445 7449 \SpecialChar ~
7446 7450 \SpecialChar ~
7447 7451 \SpecialChar ~
7448 7452 \SpecialChar ~
7449 7453 \SpecialChar ~
7450 7454 \SpecialChar ~
7451 7455 \SpecialChar ~
7452 7456 \SpecialChar ~
7453 7457 \SpecialChar ~
7454 7458 |..> \SpecialChar ~
7455 7459 \SpecialChar ~
7456 7460 \SpecialChar ~
7457 7461 \SpecialChar ~
7458 7462 print 'file',f,
7459 7463 \newline
7460 7464
7461 7465 \begin_inset ERT
7462 7466 status Collapsed
7463 7467
7464 7468 \layout Standard
7465 7469
7466 7470 \backslash
7467 7471 hspace*{0mm}
7468 7472 \end_inset
7469 7473
7470 7474 \SpecialChar ~
7471 7475 \SpecialChar ~
7472 7476 \SpecialChar ~
7473 7477 \SpecialChar ~
7474 7478 \SpecialChar ~
7475 7479 \SpecialChar ~
7476 7480 \SpecialChar ~
7477 7481 \SpecialChar ~
7478 7482 \SpecialChar ~
7479 7483 \SpecialChar ~
7480 7484 \SpecialChar ~
7481 7485 \SpecialChar ~
7482 7486 \SpecialChar ~
7483 7487 \SpecialChar ~
7484 7488 |..> \SpecialChar ~
7485 7489 \SpecialChar ~
7486 7490 \SpecialChar ~
7487 7491 \SpecialChar ~
7488 7492 wc -l $f
7489 7493 \newline
7490 7494
7491 7495 \begin_inset ERT
7492 7496 status Collapsed
7493 7497
7494 7498 \layout Standard
7495 7499
7496 7500 \backslash
7497 7501 hspace*{0mm}
7498 7502 \end_inset
7499 7503
7500 7504 \SpecialChar ~
7501 7505 \SpecialChar ~
7502 7506 \SpecialChar ~
7503 7507 \SpecialChar ~
7504 7508 \SpecialChar ~
7505 7509 \SpecialChar ~
7506 7510 \SpecialChar ~
7507 7511 \SpecialChar ~
7508 7512 \SpecialChar ~
7509 7513 \SpecialChar ~
7510 7514 \SpecialChar ~
7511 7515 \SpecialChar ~
7512 7516 \SpecialChar ~
7513 7517 \SpecialChar ~
7514 7518 |..>
7515 7519 \newline
7516 7520 file scopes.py 13 scopes.py
7517 7521 \newline
7518 7522 file strings.py 4 strings.py
7519 7523 \layout Standard
7520 7524
7521 7525 Note that you may need to protect your variables with braces if you want
7522 7526 to append strings to their names.
7523 7527 To copy all files in alist to
7524 7528 \family typewriter
7525 7529 .bak
7526 7530 \family default
7527 7531 extensions, you must use:
7528 7532 \layout Standard
7529 7533
7530 7534
7531 7535 \family typewriter
7532 7536 fperez[~/test]|12> for f in alist:
7533 7537 \newline
7534 7538
7535 7539 \begin_inset ERT
7536 7540 status Collapsed
7537 7541
7538 7542 \layout Standard
7539 7543
7540 7544 \backslash
7541 7545 hspace*{0mm}
7542 7546 \end_inset
7543 7547
7544 7548 \SpecialChar ~
7545 7549 \SpecialChar ~
7546 7550 \SpecialChar ~
7547 7551 \SpecialChar ~
7548 7552 \SpecialChar ~
7549 7553 \SpecialChar ~
7550 7554 \SpecialChar ~
7551 7555 \SpecialChar ~
7552 7556 \SpecialChar ~
7553 7557 \SpecialChar ~
7554 7558 \SpecialChar ~
7555 7559 \SpecialChar ~
7556 7560 \SpecialChar ~
7557 7561 \SpecialChar ~
7558 7562 |..> \SpecialChar ~
7559 7563 \SpecialChar ~
7560 7564 \SpecialChar ~
7561 7565 \SpecialChar ~
7562 7566 cp $f ${f}.bak
7563 7567 \layout Standard
7564 7568
7565 7569 If you try using
7566 7570 \family typewriter
7567 7571 $f.bak
7568 7572 \family default
7569 7573 , you'll get an AttributeError exception saying that your string object
7570 7574 doesn't have a
7571 7575 \family typewriter
7572 7576 .bak
7573 7577 \family default
7574 7578 attribute.
7575 7579 This is because the
7576 7580 \family typewriter
7577 7581 $
7578 7582 \family default
7579 7583 expansion mechanism allows you to expand full Python expressions:
7580 7584 \layout Standard
7581 7585
7582 7586
7583 7587 \family typewriter
7584 7588 fperez[~/test]|13> echo "sys.platform is: $sys.platform"
7585 7589 \newline
7586 7590 sys.platform is: linux2
7587 7591 \layout Standard
7588 7592
7589 7593 IPython's input history handling is still active, which allows you to rerun
7590 7594 a single block of multi-line input by simply using exec:
7591 7595 \newline
7592 7596
7593 7597 \family typewriter
7594 7598 fperez[~/test]|14> $$alist = ls *.eps
7595 7599 \newline
7596 7600 fperez[~/test]|15> exec _i11
7597 7601 \newline
7598 7602 file image2.eps 921 image2.eps
7599 7603 \newline
7600 7604 file image.eps 921 image.eps
7601 7605 \layout Standard
7602 7606
7603 7607 While these are new special-case syntaxes, they are designed to allow very
7604 7608 efficient use of the shell with minimal typing.
7605 7609 At an interactive shell prompt, conciseness of expression wins over readability.
7606 7610 \layout Subsection
7607 7611
7608 7612 Useful functions and modules
7609 7613 \layout Standard
7610 7614
7611 7615 The os, sys and shutil modules from the Python standard library are automaticall
7612 7616 y loaded.
7613 7617 Some additional functions, useful for shell usage, are listed below.
7614 7618 You can request more help about them with `
7615 7619 \family typewriter
7616 7620 ?
7617 7621 \family default
7618 7622 '.
7619 7623 \layout Description
7620 7624
7621 7625
7622 7626 \family typewriter
7623 7627 shell
7624 7628 \family default
7625 7629 - execute a command in the underlying system shell
7626 7630 \layout Description
7627 7631
7628 7632
7629 7633 \family typewriter
7630 7634 system
7631 7635 \family default
7632 7636 - like
7633 7637 \family typewriter
7634 7638 shell()
7635 7639 \family default
7636 7640 , but return the exit status of the command
7637 7641 \layout Description
7638 7642
7639 7643
7640 7644 \family typewriter
7641 7645 sout
7642 7646 \family default
7643 7647 - capture the output of a command as a string
7644 7648 \layout Description
7645 7649
7646 7650
7647 7651 \family typewriter
7648 7652 lout
7649 7653 \family default
7650 7654 - capture the output of a command as a list (split on `
7651 7655 \backslash
7652 7656 n')
7653 7657 \layout Description
7654 7658
7655 7659
7656 7660 \family typewriter
7657 7661 getoutputerror
7658 7662 \family default
7659 7663 - capture (output,error) of a shell commandss
7660 7664 \layout Standard
7661 7665
7662 7666
7663 7667 \family typewriter
7664 7668 sout
7665 7669 \family default
7666 7670 /
7667 7671 \family typewriter
7668 7672 lout
7669 7673 \family default
7670 7674 are the functional equivalents of
7671 7675 \family typewriter
7672 7676 $
7673 7677 \family default
7674 7678 /
7675 7679 \family typewriter
7676 7680 $$
7677 7681 \family default
7678 7682 .
7679 7683 They are provided to allow you to capture system output in the middle of
7680 7684 true python code, function definitions, etc (where
7681 7685 \family typewriter
7682 7686 $
7683 7687 \family default
7684 7688 and
7685 7689 \family typewriter
7686 7690 $$
7687 7691 \family default
7688 7692 are invalid).
7689 7693 \layout Subsection
7690 7694
7691 7695 Directory management
7692 7696 \layout Standard
7693 7697
7694 7698 Since each command passed by pysh to the underlying system is executed in
7695 7699 a subshell which exits immediately, you can NOT use !cd to navigate the
7696 7700 filesystem.
7697 7701 \layout Standard
7698 7702
7699 7703 Pysh provides its own builtin
7700 7704 \family typewriter
7701 7705 `%cd
7702 7706 \family default
7703 7707 ' magic command to move in the filesystem (the
7704 7708 \family typewriter
7705 7709 %
7706 7710 \family default
7707 7711 is not required with automagic on).
7708 7712 It also maintains a list of visited directories (use
7709 7713 \family typewriter
7710 7714 %dhist
7711 7715 \family default
7712 7716 to see it) and allows direct switching to any of them.
7713 7717 Type
7714 7718 \family typewriter
7715 7719 `cd?
7716 7720 \family default
7717 7721 ' for more details.
7718 7722 \layout Standard
7719 7723
7720 7724
7721 7725 \family typewriter
7722 7726 %pushd
7723 7727 \family default
7724 7728 ,
7725 7729 \family typewriter
7726 7730 %popd
7727 7731 \family default
7728 7732 and
7729 7733 \family typewriter
7730 7734 %dirs
7731 7735 \family default
7732 7736 are provided for directory stack handling.
7733 7737 \layout Subsection
7734 7738
7735 7739 Prompt customization
7736 7740 \layout Standard
7737 7741
7738 7742 The supplied
7739 7743 \family typewriter
7740 7744 ipythonrc-pysh
7741 7745 \family default
7742 7746 profile comes with an example of a very colored and detailed prompt, mainly
7743 7747 to serve as an illustration.
7744 7748 The valid escape sequences, besides color names, are:
7745 7749 \layout Description
7746 7750
7747 7751
7748 7752 \backslash
7749 7753 # - Prompt number.
7750 7754 \layout Description
7751 7755
7752 7756
7753 7757 \backslash
7754 7758 D - Dots, as many as there are digits in
7755 7759 \backslash
7756 7760 # (so they align).
7757 7761 \layout Description
7758 7762
7759 7763
7760 7764 \backslash
7761 7765 w - Current working directory (cwd).
7762 7766 \layout Description
7763 7767
7764 7768
7765 7769 \backslash
7766 7770 W - Basename of current working directory.
7767 7771 \layout Description
7768 7772
7769 7773
7770 7774 \backslash
7771 7775 X
7772 7776 \emph on
7773 7777 N
7774 7778 \emph default
7775 7779 - Where
7776 7780 \emph on
7777 7781 N
7778 7782 \emph default
7779 7783 =0..5.
7780 7784 N terms of the cwd, with $HOME written as ~.
7781 7785 \layout Description
7782 7786
7783 7787
7784 7788 \backslash
7785 7789 Y
7786 7790 \emph on
7787 7791 N
7788 7792 \emph default
7789 7793 - Where
7790 7794 \emph on
7791 7795 N
7792 7796 \emph default
7793 7797 =0..5.
7794 7798 Like X
7795 7799 \emph on
7796 7800 N
7797 7801 \emph default
7798 7802 , but if ~ is term
7799 7803 \emph on
7800 7804 N
7801 7805 \emph default
7802 7806 +1 it's also shown.
7803 7807 \layout Description
7804 7808
7805 7809
7806 7810 \backslash
7807 7811 u - Username.
7808 7812 \layout Description
7809 7813
7810 7814
7811 7815 \backslash
7812 7816 H - Full hostname.
7813 7817 \layout Description
7814 7818
7815 7819
7816 7820 \backslash
7817 7821 h - Hostname up to first '.'
7818 7822 \layout Description
7819 7823
7820 7824
7821 7825 \backslash
7822 7826 $ - Root symbol ($ or #).
7823 7827
7824 7828 \layout Description
7825 7829
7826 7830
7827 7831 \backslash
7828 7832 t - Current time, in H:M:S format.
7829 7833 \layout Description
7830 7834
7831 7835
7832 7836 \backslash
7833 7837 v - IPython release version.
7834 7838
7835 7839 \layout Description
7836 7840
7837 7841
7838 7842 \backslash
7839 7843 n - Newline.
7840 7844
7841 7845 \layout Description
7842 7846
7843 7847
7844 7848 \backslash
7845 7849 r - Carriage return.
7846 7850
7847 7851 \layout Description
7848 7852
7849 7853
7850 7854 \backslash
7851 7855
7852 7856 \backslash
7853 7857 - An explicitly escaped '
7854 7858 \backslash
7855 7859 '.
7856 7860 \layout Standard
7857 7861
7858 7862 You can configure your prompt colors using any ANSI color escape.
7859 7863 Each color escape sets the color for any subsequent text, until another
7860 7864 escape comes in and changes things.
7861 7865 The valid color escapes are:
7862 7866 \layout Description
7863 7867
7864 7868
7865 7869 \backslash
7866 7870 C_Black
7867 7871 \layout Description
7868 7872
7869 7873
7870 7874 \backslash
7871 7875 C_Blue
7872 7876 \layout Description
7873 7877
7874 7878
7875 7879 \backslash
7876 7880 C_Brown
7877 7881 \layout Description
7878 7882
7879 7883
7880 7884 \backslash
7881 7885 C_Cyan
7882 7886 \layout Description
7883 7887
7884 7888
7885 7889 \backslash
7886 7890 C_DarkGray
7887 7891 \layout Description
7888 7892
7889 7893
7890 7894 \backslash
7891 7895 C_Green
7892 7896 \layout Description
7893 7897
7894 7898
7895 7899 \backslash
7896 7900 C_LightBlue
7897 7901 \layout Description
7898 7902
7899 7903
7900 7904 \backslash
7901 7905 C_LightCyan
7902 7906 \layout Description
7903 7907
7904 7908
7905 7909 \backslash
7906 7910 C_LightGray
7907 7911 \layout Description
7908 7912
7909 7913
7910 7914 \backslash
7911 7915 C_LightGreen
7912 7916 \layout Description
7913 7917
7914 7918
7915 7919 \backslash
7916 7920 C_LightPurple
7917 7921 \layout Description
7918 7922
7919 7923
7920 7924 \backslash
7921 7925 C_LightRed
7922 7926 \layout Description
7923 7927
7924 7928
7925 7929 \backslash
7926 7930 C_Purple
7927 7931 \layout Description
7928 7932
7929 7933
7930 7934 \backslash
7931 7935 C_Red
7932 7936 \layout Description
7933 7937
7934 7938
7935 7939 \backslash
7936 7940 C_White
7937 7941 \layout Description
7938 7942
7939 7943
7940 7944 \backslash
7941 7945 C_Yellow
7942 7946 \layout Description
7943 7947
7944 7948
7945 7949 \backslash
7946 7950 C_Normal Stop coloring, defaults to your terminal settings.
7947 7951 \layout Section
7948 7952
7949 7953
7950 7954 \begin_inset LatexCommand \label{sec:Threading-support}
7951 7955
7952 7956 \end_inset
7953 7957
7954 7958 Threading support
7955 7959 \layout Standard
7956 7960
7957 7961
7958 7962 \series bold
7959 7963 WARNING:
7960 7964 \series default
7961 7965 The threading support is still somewhat experimental, and it has only seen
7962 7966 reasonable testing under Linux.
7963 7967 Threaded code is particularly tricky to debug, and it tends to show extremely
7964 7968 platform-dependent behavior.
7965 7969 Since I only have access to Linux machines, I will have to rely on user's
7966 7970 experiences and assistance for this area of IPython to improve under other
7967 7971 platforms.
7968 7972 \layout Standard
7969 7973
7970 7974 IPython, via the
7971 7975 \family typewriter
7972 7976 -gthread
7973 7977 \family default
7974 7978 ,
7975 7979 \family typewriter
7976 7980 -qthread
7977 7981 \family default
7978 7982 and
7979 7983 \family typewriter
7980 7984 -wthread
7981 7985 \family default
7982 7986 options (described in Sec.\SpecialChar ~
7983 7987
7984 7988 \begin_inset LatexCommand \ref{sec:threading-opts}
7985 7989
7986 7990 \end_inset
7987 7991
7988 7992 ), can run in multithreaded mode to support pyGTK, Qt and WXPython applications
7989 7993 respectively.
7990 7994 These GUI toolkits need to control the python main loop of execution, so
7991 7995 under a normal Python interpreter, starting a pyGTK, Qt or WXPython application
7992 7996 will immediately freeze the shell.
7993 7997
7994 7998 \layout Standard
7995 7999
7996 8000 IPython, with one of these options (you can only use one at a time), separates
7997 8001 the graphical loop and IPython's code execution run into different threads.
7998 8002 This allows you to test interactively (with
7999 8003 \family typewriter
8000 8004 %run
8001 8005 \family default
8002 8006 , for example) your GUI code without blocking.
8003 8007 \layout Standard
8004 8008
8005 8009 A nice mini-tutorial on using IPython along with the Qt Designer application
8006 8010 is available at the SciPy wiki:
8007 8011 \begin_inset LatexCommand \htmlurl{http://www.scipy.org/wikis/topical_software/QtWithIPythonAndDesigner}
8008 8012
8009 8013 \end_inset
8010 8014
8011 8015 .
8012 8016 \layout Subsection
8013 8017
8014 8018 Tk issues
8015 8019 \layout Standard
8016 8020
8017 8021 As indicated in Sec.\SpecialChar ~
8018 8022
8019 8023 \begin_inset LatexCommand \ref{sec:threading-opts}
8020 8024
8021 8025 \end_inset
8022 8026
8023 8027 , a special
8024 8028 \family typewriter
8025 8029 -tk
8026 8030 \family default
8027 8031 option is provided to try and allow Tk graphical applications to coexist
8028 8032 interactively with WX, Qt or GTK ones.
8029 8033 Whether this works at all, however, is very platform and configuration
8030 8034 dependent.
8031 8035 Please experiment with simple test cases before committing to using this
8032 8036 combination of Tk and GTK/Qt/WX threading in a production environment.
8033 8037 \layout Subsection
8034 8038
8035 8039 Signals and Threads
8036 8040 \layout Standard
8037 8041
8038 8042 When any of the thread systems (GTK, Qt or WX) are active, either directly
8039 8043 or via
8040 8044 \family typewriter
8041 8045 -pylab
8042 8046 \family default
8043 8047 with a threaded backend, it is impossible to interrupt long-running Python
8044 8048 code via
8045 8049 \family typewriter
8046 8050 Ctrl-C
8047 8051 \family default
8048 8052 .
8049 8053 IPython can not pass the KeyboardInterrupt exception (or the underlying
8050 8054
8051 8055 \family typewriter
8052 8056 SIGINT
8053 8057 \family default
8054 8058 ) across threads, so any long-running process started from IPython will
8055 8059 run to completion, or will have to be killed via an external (OS-based)
8056 8060 mechanism.
8057 8061 \layout Standard
8058 8062
8059 8063 To the best of my knowledge, this limitation is imposed by the Python interprete
8060 8064 r itself, and it comes from the difficulty of writing portable signal/threaded
8061 8065 code.
8062 8066 If any user is an expert on this topic and can suggest a better solution,
8063 8067 I would love to hear about it.
8064 8068 In the IPython sources, look at the
8065 8069 \family typewriter
8066 8070 Shell.py
8067 8071 \family default
8068 8072 module, and in particular at the
8069 8073 \family typewriter
8070 8074 runcode()
8071 8075 \family default
8072 8076 method.
8073 8077
8074 8078 \layout Subsection
8075 8079
8076 8080 I/O pitfalls
8077 8081 \layout Standard
8078 8082
8079 8083 Be mindful that the Python interpreter switches between threads every
8080 8084 \begin_inset Formula $N$
8081 8085 \end_inset
8082 8086
8083 8087 bytecodes, where the default value as of Python\SpecialChar ~
8084 8088 2.3 is
8085 8089 \begin_inset Formula $N=100.$
8086 8090 \end_inset
8087 8091
8088 8092 This value can be read by using the
8089 8093 \family typewriter
8090 8094 sys.getcheckinterval()
8091 8095 \family default
8092 8096 function, and it can be reset via
8093 8097 \family typewriter
8094 8098 sys.setcheckinterval(
8095 8099 \emph on
8096 8100 N
8097 8101 \emph default
8098 8102 )
8099 8103 \family default
8100 8104 .
8101 8105 This switching of threads can cause subtly confusing effects if one of
8102 8106 your threads is doing file I/O.
8103 8107 In text mode, most systems only flush file buffers when they encounter
8104 8108 a
8105 8109 \family typewriter
8106 8110 `
8107 8111 \backslash
8108 8112 n'
8109 8113 \family default
8110 8114 .
8111 8115 An instruction as simple as
8112 8116 \family typewriter
8113 8117
8114 8118 \newline
8115 8119 \SpecialChar ~
8116 8120 \SpecialChar ~
8117 8121 print >> filehandle,
8118 8122 \begin_inset Quotes eld
8119 8123 \end_inset
8120 8124
8121 8125 hello world
8122 8126 \begin_inset Quotes erd
8123 8127 \end_inset
8124 8128
8125 8129
8126 8130 \family default
8127 8131
8128 8132 \newline
8129 8133 actually consists of several bytecodes, so it is possible that the newline
8130 8134 does not reach your file before the next thread switch.
8131 8135 Similarly, if you are writing to a file in binary mode, the file won't
8132 8136 be flushed until the buffer fills, and your other thread may see apparently
8133 8137 truncated files.
8134 8138
8135 8139 \layout Standard
8136 8140
8137 8141 For this reason, if you are using IPython's thread support and have (for
8138 8142 example) a GUI application which will read data generated by files written
8139 8143 to from the IPython thread, the safest approach is to open all of your
8140 8144 files in unbuffered mode (the third argument to the
8141 8145 \family typewriter
8142 8146 file/open
8143 8147 \family default
8144 8148 function is the buffering value):
8145 8149 \newline
8146 8150
8147 8151 \family typewriter
8148 8152 \SpecialChar ~
8149 8153 \SpecialChar ~
8150 8154 filehandle = open(filename,mode,0)
8151 8155 \layout Standard
8152 8156
8153 8157 This is obviously a brute force way of avoiding race conditions with the
8154 8158 file buffering.
8155 8159 If you want to do it cleanly, and you have a resource which is being shared
8156 8160 by the interactive IPython loop and your GUI thread, you should really
8157 8161 handle it with thread locking and syncrhonization properties.
8158 8162 The Python documentation discusses these.
8159 8163 \layout Section
8160 8164
8161 8165
8162 8166 \begin_inset LatexCommand \label{sec:interactive-demos}
8163 8167
8164 8168 \end_inset
8165 8169
8166 8170 Interactive demos with IPython
8167 8171 \layout Standard
8168 8172
8169 8173 IPython ships with a basic system for running scripts interactively in sections,
8170 8174 useful when presenting code to audiences.
8171 8175 A few tags embedded in comments (so that the script remains valid Python
8172 8176 code) divide a file into separate blocks, and the demo can be run one block
8173 8177 at a time, with IPython printing (with syntax highlighting) the block before
8174 8178 executing it, and returning to the interactive prompt after each block.
8175 8179 The interactive namespace is updated after each block is run with the contents
8176 8180 of the demo's namespace.
8177 8181 \layout Standard
8178 8182
8179 8183 This allows you to show a piece of code, run it and then execute interactively
8180 8184 commands based on the variables just created.
8181 8185 Once you want to continue, you simply execute the next block of the demo.
8182 8186 The following listing shows the markup necessary for dividing a script
8183 8187 into sections for execution as a demo.
8184 8188 \layout Standard
8185 8189
8186 8190
8187 8191 \begin_inset ERT
8188 8192 status Open
8189 8193
8190 8194 \layout Standard
8191 8195
8192 8196 \backslash
8193 8197 codelist{examples/example-demo.py}
8194 8198 \end_inset
8195 8199
8196 8200
8197 8201 \layout Standard
8198 8202
8199 8203 In order to run a file as a demo, you must first make a
8200 8204 \family typewriter
8201 8205 Demo
8202 8206 \family default
8203 8207 object out of it.
8204 8208 If the file is named
8205 8209 \family typewriter
8206 8210 myscript.py
8207 8211 \family default
8208 8212 , the following code will make a demo:
8209 8213 \layout LyX-Code
8210 8214
8211 8215 from IPython.demo import Demo
8212 8216 \layout LyX-Code
8213 8217
8214 8218 mydemo = Demo('myscript.py')
8215 8219 \layout Standard
8216 8220
8217 8221 This creates the
8218 8222 \family typewriter
8219 8223 mydemo
8220 8224 \family default
8221 8225 object, whose blocks you run one at a time by simply calling the object
8222 8226 with no arguments.
8223 8227 If you have autocall active in IPython (the default), all you need to do
8224 8228 is type
8225 8229 \layout LyX-Code
8226 8230
8227 8231 mydemo
8228 8232 \layout Standard
8229 8233
8230 8234 and IPython will call it, executing each block.
8231 8235 Demo objects can be restarted, you can move forward or back skipping blocks,
8232 8236 re-execute the last block, etc.
8233 8237 Simply use the Tab key on a demo object to see its methods, and call
8234 8238 \family typewriter
8235 8239 `?'
8236 8240 \family default
8237 8241 on them to see their docstrings for more usage details.
8238 8242 In addition, the
8239 8243 \family typewriter
8240 8244 demo
8241 8245 \family default
8242 8246 module itself contains a comprehensive docstring, which you can access
8243 8247 via
8244 8248 \layout LyX-Code
8245 8249
8246 8250 from IPython import demo
8247 8251 \layout LyX-Code
8248 8252
8249 8253 demo?
8250 8254 \layout Standard
8251 8255
8252 8256
8253 8257 \series bold
8254 8258 Limitations:
8255 8259 \series default
8256 8260 It is important to note that these demos are limited to fairly simple uses.
8257 8261 In particular, you can
8258 8262 \emph on
8259 8263 not
8260 8264 \emph default
8261 8265 put division marks in indented code (loops, if statements, function definitions
8262 8266 , etc.) Supporting something like this would basically require tracking the
8263 8267 internal execution state of the Python interpreter, so only top-level divisions
8264 8268 are allowed.
8265 8269 If you want to be able to open an IPython instance at an arbitrary point
8266 8270 in a program, you can use IPython's embedding facilities, described in
8267 8271 detail in Sec\SpecialChar \@.
8268 8272 \SpecialChar ~
8269 8273
8270 8274 \begin_inset LatexCommand \ref{sec:embed}
8271 8275
8272 8276 \end_inset
8273 8277
8274 8278 .
8275 8279 \layout Section
8276 8280
8277 8281
8278 8282 \begin_inset LatexCommand \label{sec:matplotlib-support}
8279 8283
8280 8284 \end_inset
8281 8285
8282 8286 Plotting with
8283 8287 \family typewriter
8284 8288 matplotlib
8285 8289 \family default
8286 8290
8287 8291 \layout Standard
8288 8292
8289 8293 The matplotlib library (
8290 8294 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
8291 8295
8292 8296 \end_inset
8293 8297
8294 8298 ) provides high quality 2D plotting for Python.
8295 8299 Matplotlib can produce plots on screen using a variety of GUI toolkits,
8296 8300 including Tk, GTK and WXPython.
8297 8301 It also provides a number of commands useful for scientific computing,
8298 8302 all with a syntax compatible with that of the popular Matlab program.
8299 8303 \layout Standard
8300 8304
8301 8305 IPython accepts the special option
8302 8306 \family typewriter
8303 8307 -pylab
8304 8308 \family default
8305 8309 (Sec.\SpecialChar ~
8306 8310
8307 8311 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
8308 8312
8309 8313 \end_inset
8310 8314
8311 8315 ).
8312 8316 This configures it to support matplotlib, honoring the settings in the
8313 8317
8314 8318 \family typewriter
8315 8319 .matplotlibrc
8316 8320 \family default
8317 8321 file.
8318 8322 IPython will detect the user's choice of matplotlib GUI backend, and automatica
8319 8323 lly select the proper threading model to prevent blocking.
8320 8324 It also sets matplotlib in interactive mode and modifies
8321 8325 \family typewriter
8322 8326 %run
8323 8327 \family default
8324 8328 slightly, so that any matplotlib-based script can be executed using
8325 8329 \family typewriter
8326 8330 %run
8327 8331 \family default
8328 8332 and the final
8329 8333 \family typewriter
8330 8334 show()
8331 8335 \family default
8332 8336 command does not block the interactive shell.
8333 8337 \layout Standard
8334 8338
8335 8339 The
8336 8340 \family typewriter
8337 8341 -pylab
8338 8342 \family default
8339 8343 option must be given first in order for IPython to configure its threading
8340 8344 mode.
8341 8345 However, you can still issue other options afterwards.
8342 8346 This allows you to have a matplotlib-based environment customized with
8343 8347 additional modules using the standard IPython profile mechanism (Sec.\SpecialChar ~
8344 8348
8345 8349 \begin_inset LatexCommand \ref{sec:profiles}
8346 8350
8347 8351 \end_inset
8348 8352
8349 8353 ): ``
8350 8354 \family typewriter
8351 8355 ipython -pylab -p myprofile
8352 8356 \family default
8353 8357 '' will load the profile defined in
8354 8358 \family typewriter
8355 8359 ipythonrc-myprofile
8356 8360 \family default
8357 8361 after configuring matplotlib.
8358 8362 \layout Section
8359 8363
8360 8364
8361 8365 \begin_inset LatexCommand \label{sec:Gnuplot}
8362 8366
8363 8367 \end_inset
8364 8368
8365 8369 Plotting with
8366 8370 \family typewriter
8367 8371 Gnuplot
8368 8372 \layout Standard
8369 8373
8370 8374 Through the magic extension system described in sec.
8371 8375
8372 8376 \begin_inset LatexCommand \ref{sec:magic}
8373 8377
8374 8378 \end_inset
8375 8379
8376 8380 , IPython incorporates a mechanism for conveniently interfacing with the
8377 8381 Gnuplot system (
8378 8382 \begin_inset LatexCommand \htmlurl{http://www.gnuplot.info}
8379 8383
8380 8384 \end_inset
8381 8385
8382 8386 ).
8383 8387 Gnuplot is a very complete 2D and 3D plotting package available for many
8384 8388 operating systems and commonly included in modern Linux distributions.
8385 8389
8386 8390 \layout Standard
8387 8391
8388 8392 Besides having Gnuplot installed, this functionality requires the
8389 8393 \family typewriter
8390 8394 Gnuplot.py
8391 8395 \family default
8392 8396 module for interfacing python with Gnuplot.
8393 8397 It can be downloaded from:
8394 8398 \begin_inset LatexCommand \htmlurl{http://gnuplot-py.sourceforge.net}
8395 8399
8396 8400 \end_inset
8397 8401
8398 8402 .
8399 8403 \layout Subsection
8400 8404
8401 8405 Proper Gnuplot configuration
8402 8406 \layout Standard
8403 8407
8404 8408 As of version 4.0, Gnuplot has excellent mouse and interactive keyboard support.
8405 8409 However, as of
8406 8410 \family typewriter
8407 8411 Gnuplot.py
8408 8412 \family default
8409 8413 version 1.7, a new option was added to communicate between Python and Gnuplot
8410 8414 via FIFOs (pipes).
8411 8415 This mechanism, while fast, also breaks the mouse system.
8412 8416 You must therefore set the variable
8413 8417 \family typewriter
8414 8418 prefer_fifo_data
8415 8419 \family default
8416 8420 to
8417 8421 \family typewriter
8418 8422 0
8419 8423 \family default
8420 8424 in file
8421 8425 \family typewriter
8422 8426 gp_unix.py
8423 8427 \family default
8424 8428 if you wish to keep the interactive mouse and keyboard features working
8425 8429 properly (
8426 8430 \family typewriter
8427 8431 prefer_inline_data
8428 8432 \family default
8429 8433 also must be
8430 8434 \family typewriter
8431 8435 0
8432 8436 \family default
8433 8437 , but this is the default so unless you've changed it manually you should
8434 8438 be fine).
8435 8439 \layout Standard
8436 8440
8437 8441 'Out of the box', Gnuplot is configured with a rather poor set of size,
8438 8442 color and linewidth choices which make the graphs fairly hard to read on
8439 8443 modern high-resolution displays (although they work fine on old 640x480
8440 8444 ones).
8441 8445 Below is a section of my
8442 8446 \family typewriter
8443 8447 .Xdefaults
8444 8448 \family default
8445 8449 file which I use for having a more convenient Gnuplot setup.
8446 8450 Remember to load it by running
8447 8451 \family typewriter
8448 8452 `xrdb .Xdefaults`
8449 8453 \family default
8450 8454 :
8451 8455 \layout Standard
8452 8456
8453 8457
8454 8458 \family typewriter
8455 8459 !******************************************************************
8456 8460 \newline
8457 8461 ! gnuplot options
8458 8462 \newline
8459 8463 ! modify this for a convenient window size
8460 8464 \newline
8461 8465 gnuplot*geometry: 780x580
8462 8466 \layout Standard
8463 8467
8464 8468
8465 8469 \family typewriter
8466 8470 ! on-screen font (not for PostScript)
8467 8471 \newline
8468 8472 gnuplot*font: -misc-fixed-bold-r-normal--15-120-100-100-c-90-iso8859-1
8469 8473 \layout Standard
8470 8474
8471 8475
8472 8476 \family typewriter
8473 8477 ! color options
8474 8478 \newline
8475 8479 gnuplot*background: black
8476 8480 \newline
8477 8481 gnuplot*textColor: white
8478 8482 \newline
8479 8483 gnuplot*borderColor: white
8480 8484 \newline
8481 8485 gnuplot*axisColor: white
8482 8486 \newline
8483 8487 gnuplot*line1Color: red
8484 8488 \newline
8485 8489 gnuplot*line2Color: green
8486 8490 \newline
8487 8491 gnuplot*line3Color: blue
8488 8492 \newline
8489 8493 gnuplot*line4Color: magenta
8490 8494 \newline
8491 8495 gnuplot*line5Color: cyan
8492 8496 \newline
8493 8497 gnuplot*line6Color: sienna
8494 8498 \newline
8495 8499 gnuplot*line7Color: orange
8496 8500 \newline
8497 8501 gnuplot*line8Color: coral
8498 8502 \layout Standard
8499 8503
8500 8504
8501 8505 \family typewriter
8502 8506 ! multiplicative factor for point styles
8503 8507 \newline
8504 8508 gnuplot*pointsize: 2
8505 8509 \layout Standard
8506 8510
8507 8511
8508 8512 \family typewriter
8509 8513 ! line width options (in pixels)
8510 8514 \newline
8511 8515 gnuplot*borderWidth: 2
8512 8516 \newline
8513 8517 gnuplot*axisWidth: 2
8514 8518 \newline
8515 8519 gnuplot*line1Width: 2
8516 8520 \newline
8517 8521 gnuplot*line2Width: 2
8518 8522 \newline
8519 8523 gnuplot*line3Width: 2
8520 8524 \newline
8521 8525 gnuplot*line4Width: 2
8522 8526 \newline
8523 8527 gnuplot*line5Width: 2
8524 8528 \newline
8525 8529 gnuplot*line6Width: 2
8526 8530 \newline
8527 8531 gnuplot*line7Width: 2
8528 8532 \newline
8529 8533 gnuplot*line8Width: 2
8530 8534 \layout Subsection
8531 8535
8532 8536 The
8533 8537 \family typewriter
8534 8538 IPython.GnuplotRuntime
8535 8539 \family default
8536 8540 module
8537 8541 \layout Standard
8538 8542
8539 8543 IPython includes a module called
8540 8544 \family typewriter
8541 8545 Gnuplot2.py
8542 8546 \family default
8543 8547 which extends and improves the default
8544 8548 \family typewriter
8545 8549 Gnuplot
8546 8550 \family default
8547 8551 .
8548 8552 \family typewriter
8549 8553 py
8550 8554 \family default
8551 8555 (which it still relies upon).
8552 8556 For example, the new
8553 8557 \family typewriter
8554 8558 plot
8555 8559 \family default
8556 8560 function adds several improvements to the original making it more convenient
8557 8561 for interactive use, and
8558 8562 \family typewriter
8559 8563 hardcopy
8560 8564 \family default
8561 8565 fixes a bug in the original which under some circumstances blocks the creation
8562 8566 of PostScript output.
8563 8567 \layout Standard
8564 8568
8565 8569 For scripting use,
8566 8570 \family typewriter
8567 8571 GnuplotRuntime.py
8568 8572 \family default
8569 8573 is provided, which wraps
8570 8574 \family typewriter
8571 8575 Gnuplot2.py
8572 8576 \family default
8573 8577 and creates a series of global aliases.
8574 8578 These make it easy to control Gnuplot plotting jobs through the Python
8575 8579 language.
8576 8580 \layout Standard
8577 8581
8578 8582 Below is some example code which illustrates how to configure Gnuplot inside
8579 8583 your own programs but have it available for further interactive use through
8580 8584 an embedded IPython instance.
8581 8585 Simply run this file at a system prompt.
8582 8586 This file is provided as
8583 8587 \family typewriter
8584 8588 example-gnuplot.py
8585 8589 \family default
8586 8590 in the examples directory:
8587 8591 \layout Standard
8588 8592
8589 8593
8590 8594 \begin_inset ERT
8591 8595 status Open
8592 8596
8593 8597 \layout Standard
8594 8598
8595 8599 \backslash
8596 8600 codelist{examples/example-gnuplot.py}
8597 8601 \end_inset
8598 8602
8599 8603
8600 8604 \layout Subsection
8601 8605
8602 8606 The
8603 8607 \family typewriter
8604 8608 numeric
8605 8609 \family default
8606 8610 profile: a scientific computing environment
8607 8611 \layout Standard
8608 8612
8609 8613 The
8610 8614 \family typewriter
8611 8615 numeric
8612 8616 \family default
8613 8617 IPython profile, which you can activate with
8614 8618 \family typewriter
8615 8619 `ipython -p numeric
8616 8620 \family default
8617 8621 ' will automatically load the IPython Gnuplot extensions (plus Numeric and
8618 8622 other useful things for numerical computing), contained in the
8619 8623 \family typewriter
8620 8624 IPython.GnuplotInteractive
8621 8625 \family default
8622 8626 module.
8623 8627 This will create the globals
8624 8628 \family typewriter
8625 8629 Gnuplot
8626 8630 \family default
8627 8631 (an alias to the improved Gnuplot2 module),
8628 8632 \family typewriter
8629 8633 gp
8630 8634 \family default
8631 8635 (a Gnuplot active instance), the new magic commands
8632 8636 \family typewriter
8633 8637 %gpc
8634 8638 \family default
8635 8639 and
8636 8640 \family typewriter
8637 8641 %gp_set_instance
8638 8642 \family default
8639 8643 and several other convenient globals.
8640 8644 Type
8641 8645 \family typewriter
8642 8646 gphelp()
8643 8647 \family default
8644 8648 for further details.
8645 8649 \layout Standard
8646 8650
8647 8651 This should turn IPython into a convenient environment for numerical computing,
8648 8652 with all the functions in the NumPy library and the Gnuplot facilities
8649 8653 for plotting.
8650 8654 Further improvements can be obtained by loading the SciPy libraries for
8651 8655 scientific computing, available at
8652 8656 \begin_inset LatexCommand \htmlurl{http://scipy.org}
8653 8657
8654 8658 \end_inset
8655 8659
8656 8660 .
8657 8661 \layout Standard
8658 8662
8659 8663 If you are in the middle of a working session with numerical objects and
8660 8664 need to plot them but you didn't start the
8661 8665 \family typewriter
8662 8666 numeric
8663 8667 \family default
8664 8668 profile, you can load these extensions at any time by typing
8665 8669 \newline
8666 8670
8667 8671 \family typewriter
8668 8672 from IPython.GnuplotInteractive import *
8669 8673 \newline
8670 8674
8671 8675 \family default
8672 8676 at the IPython prompt.
8673 8677 This will allow you to keep your objects intact and start using Gnuplot
8674 8678 to view them.
8675 8679 \layout Section
8676 8680
8677 8681 Reporting bugs
8678 8682 \layout Subsection*
8679 8683
8680 8684 Automatic crash reports
8681 8685 \layout Standard
8682 8686
8683 8687 Ideally, IPython itself shouldn't crash.
8684 8688 It will catch exceptions produced by you, but bugs in its internals will
8685 8689 still crash it.
8686 8690 \layout Standard
8687 8691
8688 8692 In such a situation, IPython will leave a file named
8689 8693 \family typewriter
8690 8694 IPython_crash_report.txt
8691 8695 \family default
8692 8696 in your IPYTHONDIR directory (that way if crashes happen several times
8693 8697 it won't litter many directories, the post-mortem file is always located
8694 8698 in the same place and new occurrences just overwrite the previous one).
8695 8699 If you can mail this file to the developers (see sec.
8696 8700
8697 8701 \begin_inset LatexCommand \ref{sec:credits}
8698 8702
8699 8703 \end_inset
8700 8704
8701 8705 for names and addresses), it will help us
8702 8706 \emph on
8703 8707 a lot
8704 8708 \emph default
8705 8709 in understanding the cause of the problem and fixing it sooner.
8706 8710 \layout Subsection*
8707 8711
8708 8712 The bug tracker
8709 8713 \layout Standard
8710 8714
8711 8715 IPython also has an online bug-tracker, located at
8712 8716 \begin_inset LatexCommand \htmlurl{http://projects.scipy.org/ipython/ipython/report/1}
8713 8717
8714 8718 \end_inset
8715 8719
8716 8720 .
8717 8721 In addition to mailing the developers, it would be a good idea to file
8718 8722 a bug report here.
8719 8723 This will ensure that the issue is properly followed to conclusion.
8720 8724 To report new bugs you will have to register first.
8721 8725 \layout Standard
8722 8726
8723 8727 You can also use this bug tracker to file feature requests.
8724 8728 \layout Section
8725 8729
8726 8730 Brief history
8727 8731 \layout Subsection
8728 8732
8729 8733 Origins
8730 8734 \layout Standard
8731 8735
8732 8736 The current IPython system grew out of the following three projects:
8733 8737 \layout List
8734 8738 \labelwidthstring 00.00.0000
8735 8739
8736 8740 ipython by Fernando P
8737 8741 \begin_inset ERT
8738 8742 status Collapsed
8739 8743
8740 8744 \layout Standard
8741 8745
8742 8746 \backslash
8743 8747 '{e}
8744 8748 \end_inset
8745 8749
8746 8750 rez.
8747 8751 I was working on adding Mathematica-type prompts and a flexible configuration
8748 8752 system (something better than
8749 8753 \family typewriter
8750 8754 $PYTHONSTARTUP
8751 8755 \family default
8752 8756 ) to the standard Python interactive interpreter.
8753 8757 \layout List
8754 8758 \labelwidthstring 00.00.0000
8755 8759
8756 8760 IPP by Janko Hauser.
8757 8761 Very well organized, great usability.
8758 8762 Had an old help system.
8759 8763 IPP was used as the `container' code into which I added the functionality
8760 8764 from ipython and LazyPython.
8761 8765 \layout List
8762 8766 \labelwidthstring 00.00.0000
8763 8767
8764 8768 LazyPython by Nathan Gray.
8765 8769 Simple but
8766 8770 \emph on
8767 8771 very
8768 8772 \emph default
8769 8773 powerful.
8770 8774 The quick syntax (auto parens, auto quotes) and verbose/colored tracebacks
8771 8775 were all taken from here.
8772 8776 \layout Standard
8773 8777
8774 8778 When I found out (see sec.
8775 8779
8776 8780 \begin_inset LatexCommand \ref{figgins}
8777 8781
8778 8782 \end_inset
8779 8783
8780 8784 ) about IPP and LazyPython I tried to join all three into a unified system.
8781 8785 I thought this could provide a very nice working environment, both for
8782 8786 regular programming and scientific computing: shell-like features, IDL/Matlab
8783 8787 numerics, Mathematica-type prompt history and great object introspection
8784 8788 and help facilities.
8785 8789 I think it worked reasonably well, though it was a lot more work than I
8786 8790 had initially planned.
8787 8791 \layout Subsection
8788 8792
8789 8793 Current status
8790 8794 \layout Standard
8791 8795
8792 8796 The above listed features work, and quite well for the most part.
8793 8797 But until a major internal restructuring is done (see below), only bug
8794 8798 fixing will be done, no other features will be added (unless very minor
8795 8799 and well localized in the cleaner parts of the code).
8796 8800 \layout Standard
8797 8801
8798 8802 IPython consists of some 18000 lines of pure python code, of which roughly
8799 8803 two thirds is reasonably clean.
8800 8804 The rest is, messy code which needs a massive restructuring before any
8801 8805 further major work is done.
8802 8806 Even the messy code is fairly well documented though, and most of the problems
8803 8807 in the (non-existent) class design are well pointed to by a PyChecker run.
8804 8808 So the rewriting work isn't that bad, it will just be time-consuming.
8805 8809 \layout Subsection
8806 8810
8807 8811 Future
8808 8812 \layout Standard
8809 8813
8810 8814 See the separate
8811 8815 \family typewriter
8812 8816 new_design
8813 8817 \family default
8814 8818 document for details.
8815 8819 Ultimately, I would like to see IPython become part of the standard Python
8816 8820 distribution as a `big brother with batteries' to the standard Python interacti
8817 8821 ve interpreter.
8818 8822 But that will never happen with the current state of the code, so all contribut
8819 8823 ions are welcome.
8820 8824 \layout Section
8821 8825
8822 8826 License
8823 8827 \layout Standard
8824 8828
8825 8829 IPython is released under the terms of the BSD license, whose general form
8826 8830 can be found at:
8827 8831 \begin_inset LatexCommand \htmlurl{http://www.opensource.org/licenses/bsd-license.php}
8828 8832
8829 8833 \end_inset
8830 8834
8831 8835 .
8832 8836 The full text of the IPython license is reproduced below:
8833 8837 \layout Quote
8834 8838
8835 8839
8836 8840 \family typewriter
8837 8841 \size small
8838 8842 IPython is released under a BSD-type license.
8839 8843 \layout Quote
8840 8844
8841 8845
8842 8846 \family typewriter
8843 8847 \size small
8844 8848 Copyright (c) 2001, 2002, 2003, 2004 Fernando Perez <fperez@colorado.edu>.
8845 8849 \layout Quote
8846 8850
8847 8851
8848 8852 \family typewriter
8849 8853 \size small
8850 8854 Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and
8851 8855 \newline
8852 8856 Nathaniel Gray <n8gray@caltech.edu>.
8853 8857 \layout Quote
8854 8858
8855 8859
8856 8860 \family typewriter
8857 8861 \size small
8858 8862 All rights reserved.
8859 8863 \layout Quote
8860 8864
8861 8865
8862 8866 \family typewriter
8863 8867 \size small
8864 8868 Redistribution and use in source and binary forms, with or without modification,
8865 8869 are permitted provided that the following conditions are met:
8866 8870 \layout Quote
8867 8871
8868 8872
8869 8873 \family typewriter
8870 8874 \size small
8871 8875 a.
8872 8876 Redistributions of source code must retain the above copyright notice,
8873 8877 this list of conditions and the following disclaimer.
8874 8878 \layout Quote
8875 8879
8876 8880
8877 8881 \family typewriter
8878 8882 \size small
8879 8883 b.
8880 8884 Redistributions in binary form must reproduce the above copyright notice,
8881 8885 this list of conditions and the following disclaimer in the documentation
8882 8886 and/or other materials provided with the distribution.
8883 8887 \layout Quote
8884 8888
8885 8889
8886 8890 \family typewriter
8887 8891 \size small
8888 8892 c.
8889 8893 Neither the name of the copyright holders nor the names of any contributors
8890 8894 to this software may be used to endorse or promote products derived from
8891 8895 this software without specific prior written permission.
8892 8896 \layout Quote
8893 8897
8894 8898
8895 8899 \family typewriter
8896 8900 \size small
8897 8901 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
8898 8902 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
8899 8903 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
8900 8904 PURPOSE ARE DISCLAIMED.
8901 8905 IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
8902 8906 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
8903 8907 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
8904 8908 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
8905 8909 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8906 8910 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
8907 8911 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8908 8912
8909 8913 \layout Standard
8910 8914
8911 8915 Individual authors are the holders of the copyright for their code and are
8912 8916 listed in each file.
8913 8917 \layout Standard
8914 8918
8915 8919 Some files (
8916 8920 \family typewriter
8917 8921 DPyGetOpt.py
8918 8922 \family default
8919 8923 , for example) may be licensed under different conditions.
8920 8924 Ultimately each file indicates clearly the conditions under which its author/au
8921 8925 thors have decided to publish the code.
8922 8926 \layout Standard
8923 8927
8924 8928 Versions of IPython up to and including 0.6.3 were released under the GNU
8925 8929 Lesser General Public License (LGPL), available at
8926 8930 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/copyleft/lesser.html}
8927 8931
8928 8932 \end_inset
8929 8933
8930 8934 .
8931 8935 \layout Section
8932 8936
8933 8937
8934 8938 \begin_inset LatexCommand \label{sec:credits}
8935 8939
8936 8940 \end_inset
8937 8941
8938 8942 Credits
8939 8943 \layout Standard
8940 8944
8941 8945 IPython is mainly developed by Fernando P
8942 8946 \begin_inset ERT
8943 8947 status Collapsed
8944 8948
8945 8949 \layout Standard
8946 8950
8947 8951 \backslash
8948 8952 '{e}
8949 8953 \end_inset
8950 8954
8951 8955 rez
8952 8956 \family typewriter
8953 8957 <Fernando.Perez@colorado.edu>
8954 8958 \family default
8955 8959 , but the project was born from mixing in Fernando's code with the IPP project
8956 8960 by Janko Hauser
8957 8961 \family typewriter
8958 8962 <jhauser-AT-zscout.de>
8959 8963 \family default
8960 8964 and LazyPython by Nathan Gray
8961 8965 \family typewriter
8962 8966 <n8gray-AT-caltech.edu>
8963 8967 \family default
8964 8968 .
8965 8969 For all IPython-related requests, please contact Fernando.
8966 8970
8967 8971 \layout Standard
8968 8972
8969 8973 As of early 2006, the following developers have joined the core team:
8970 8974 \layout List
8971 8975 \labelwidthstring 00.00.0000
8972 8976
8973 8977 Robert\SpecialChar ~
8974 8978 Kern
8975 8979 \family typewriter
8976 8980 <rkern-AT-enthought.com>
8977 8981 \family default
8978 8982 : co-mentored the 2005 Google Summer of Code project to develop python interacti
8979 8983 ve notebooks (XML documents) and graphical interface.
8980 8984 This project was awarded to the students Tzanko Matev
8981 8985 \family typewriter
8982 8986 <tsanko-AT-gmail.com>
8983 8987 \family default
8984 8988 and Toni Alatalo
8985 8989 \family typewriter
8986 8990 <antont-AT-an.org>
8987 8991 \layout List
8988 8992 \labelwidthstring 00.00.0000
8989 8993
8990 8994 Brian\SpecialChar ~
8991 8995 Granger
8992 8996 \family typewriter
8993 8997 <bgranger-AT-scu.edu>
8994 8998 \family default
8995 8999 : extending IPython to allow support for interactive parallel computing.
8996 9000 \layout List
8997 9001 \labelwidthstring 00.00.0000
8998 9002
8999 9003 Ville\SpecialChar ~
9000 9004 Vainio
9001 9005 \family typewriter
9002 9006 <vivainio-AT-gmail.com>
9003 9007 \family default
9004 9008 : Ville is the new maintainer for the main trunk of IPython after version
9005 9009 0.7.1.
9006 9010 \layout Standard
9007 9011
9008 9012 User or development help should be requested via the IPython mailing lists:
9009 9013 \layout Description
9010 9014
9011 9015 User\SpecialChar ~
9012 9016 list:
9013 9017 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-user}
9014 9018
9015 9019 \end_inset
9016 9020
9017 9021
9018 9022 \layout Description
9019 9023
9020 9024 Developer's\SpecialChar ~
9021 9025 list:
9022 9026 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-dev}
9023 9027
9024 9028 \end_inset
9025 9029
9026 9030
9027 9031 \layout Standard
9028 9032
9029 9033 The IPython project is also very grateful to
9030 9034 \begin_inset Foot
9031 9035 collapsed true
9032 9036
9033 9037 \layout Standard
9034 9038
9035 9039 I've mangled email addresses to reduce spam, since the IPython manuals can
9036 9040 be accessed online.
9037 9041 \end_inset
9038 9042
9039 9043 :
9040 9044 \layout Standard
9041 9045
9042 9046 Bill Bumgarner
9043 9047 \family typewriter
9044 9048 <bbum-AT-friday.com>
9045 9049 \family default
9046 9050 : for providing the DPyGetOpt module which gives very powerful and convenient
9047 9051 handling of command-line options (light years ahead of what Python 2.1.1's
9048 9052 getopt module does).
9049 9053 \layout Standard
9050 9054
9051 9055 Ka-Ping Yee
9052 9056 \family typewriter
9053 9057 <ping-AT-lfw.org>
9054 9058 \family default
9055 9059 : for providing the Itpl module for convenient and powerful string interpolation
9056 9060 with a much nicer syntax than formatting through the '%' operator.
9057 9061 \layout Standard
9058 9062
9059 9063 Arnd Baecker
9060 9064 \family typewriter
9061 9065 <baecker-AT-physik.tu-dresden.de>
9062 9066 \family default
9063 9067 : for his many very useful suggestions and comments, and lots of help with
9064 9068 testing and documentation checking.
9065 9069 Many of IPython's newer features are a result of discussions with him (bugs
9066 9070 are still my fault, not his).
9067 9071 \layout Standard
9068 9072
9069 9073 Obviously Guido van\SpecialChar ~
9070 9074 Rossum and the whole Python development team, that goes
9071 9075 without saying.
9072 9076 \layout Standard
9073 9077
9074 9078 IPython's website is generously hosted at
9075 9079 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
9076 9080
9077 9081 \end_inset
9078 9082
9079 9083 by Enthought (
9080 9084 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
9081 9085
9082 9086 \end_inset
9083 9087
9084 9088 ).
9085 9089 I am very grateful to them and all of the SciPy team for their contribution.
9086 9090 \layout Standard
9087 9091
9088 9092
9089 9093 \begin_inset LatexCommand \label{figgins}
9090 9094
9091 9095 \end_inset
9092 9096
9093 9097 Fernando would also like to thank Stephen Figgins
9094 9098 \family typewriter
9095 9099 <fig-AT-monitor.net>
9096 9100 \family default
9097 9101 , an O'Reilly Python editor.
9098 9102 His Oct/11/2001 article about IPP and LazyPython, was what got this project
9099 9103 started.
9100 9104 You can read it at:
9101 9105 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html}
9102 9106
9103 9107 \end_inset
9104 9108
9105 9109 .
9106 9110 \layout Standard
9107 9111
9108 9112 And last but not least, all the kind IPython users who have emailed new
9109 9113 code, bug reports, fixes, comments and ideas.
9110 9114 A brief list follows, please let me know if I have ommitted your name by
9111 9115 accident:
9112 9116 \layout List
9113 9117 \labelwidthstring 00.00.0000
9114 9118
9115 9119 Jack\SpecialChar ~
9116 9120 Moffit
9117 9121 \family typewriter
9118 9122 <jack-AT-xiph.org>
9119 9123 \family default
9120 9124 Bug fixes, including the infamous color problem.
9121 9125 This bug alone caused many lost hours and frustration, many thanks to him
9122 9126 for the fix.
9123 9127 I've always been a fan of Ogg & friends, now I have one more reason to
9124 9128 like these folks.
9125 9129 \newline
9126 9130 Jack is also contributing with Debian packaging and many other things.
9127 9131 \layout List
9128 9132 \labelwidthstring 00.00.0000
9129 9133
9130 9134 Alexander\SpecialChar ~
9131 9135 Schmolck
9132 9136 \family typewriter
9133 9137 <a.schmolck-AT-gmx.net>
9134 9138 \family default
9135 9139 Emacs work, bug reports, bug fixes, ideas, lots more.
9136 9140 The ipython.el mode for (X)Emacs is Alex's code, providing full support
9137 9141 for IPython under (X)Emacs.
9138 9142 \layout List
9139 9143 \labelwidthstring 00.00.0000
9140 9144
9141 9145 Andrea\SpecialChar ~
9142 9146 Riciputi
9143 9147 \family typewriter
9144 9148 <andrea.riciputi-AT-libero.it>
9145 9149 \family default
9146 9150 Mac OSX information, Fink package management.
9147 9151 \layout List
9148 9152 \labelwidthstring 00.00.0000
9149 9153
9150 9154 Gary\SpecialChar ~
9151 9155 Bishop
9152 9156 \family typewriter
9153 9157 <gb-AT-cs.unc.edu>
9154 9158 \family default
9155 9159 Bug reports, and patches to work around the exception handling idiosyncracies
9156 9160 of WxPython.
9157 9161 Readline and color support for Windows.
9158 9162 \layout List
9159 9163 \labelwidthstring 00.00.0000
9160 9164
9161 9165 Jeffrey\SpecialChar ~
9162 9166 Collins
9163 9167 \family typewriter
9164 9168 <Jeff.Collins-AT-vexcel.com>
9165 9169 \family default
9166 9170 Bug reports.
9167 9171 Much improved readline support, including fixes for Python 2.3.
9168 9172 \layout List
9169 9173 \labelwidthstring 00.00.0000
9170 9174
9171 9175 Dryice\SpecialChar ~
9172 9176 Liu
9173 9177 \family typewriter
9174 9178 <dryice-AT-liu.com.cn>
9175 9179 \family default
9176 9180 FreeBSD port.
9177 9181 \layout List
9178 9182 \labelwidthstring 00.00.0000
9179 9183
9180 9184 Mike\SpecialChar ~
9181 9185 Heeter
9182 9186 \family typewriter
9183 9187 <korora-AT-SDF.LONESTAR.ORG>
9184 9188 \layout List
9185 9189 \labelwidthstring 00.00.0000
9186 9190
9187 9191 Christopher\SpecialChar ~
9188 9192 Hart
9189 9193 \family typewriter
9190 9194 <hart-AT-caltech.edu>
9191 9195 \family default
9192 9196 PDB integration.
9193 9197 \layout List
9194 9198 \labelwidthstring 00.00.0000
9195 9199
9196 9200 Milan\SpecialChar ~
9197 9201 Zamazal
9198 9202 \family typewriter
9199 9203 <pdm-AT-zamazal.org>
9200 9204 \family default
9201 9205 Emacs info.
9202 9206 \layout List
9203 9207 \labelwidthstring 00.00.0000
9204 9208
9205 9209 Philip\SpecialChar ~
9206 9210 Hisley
9207 9211 \family typewriter
9208 9212 <compsys-AT-starpower.net>
9209 9213 \layout List
9210 9214 \labelwidthstring 00.00.0000
9211 9215
9212 9216 Holger\SpecialChar ~
9213 9217 Krekel
9214 9218 \family typewriter
9215 9219 <pyth-AT-devel.trillke.net>
9216 9220 \family default
9217 9221 Tab completion, lots more.
9218 9222 \layout List
9219 9223 \labelwidthstring 00.00.0000
9220 9224
9221 9225 Robin\SpecialChar ~
9222 9226 Siebler
9223 9227 \family typewriter
9224 9228 <robinsiebler-AT-starband.net>
9225 9229 \layout List
9226 9230 \labelwidthstring 00.00.0000
9227 9231
9228 9232 Ralf\SpecialChar ~
9229 9233 Ahlbrink
9230 9234 \family typewriter
9231 9235 <ralf_ahlbrink-AT-web.de>
9232 9236 \layout List
9233 9237 \labelwidthstring 00.00.0000
9234 9238
9235 9239 Thorsten\SpecialChar ~
9236 9240 Kampe
9237 9241 \family typewriter
9238 9242 <thorsten-AT-thorstenkampe.de>
9239 9243 \layout List
9240 9244 \labelwidthstring 00.00.0000
9241 9245
9242 9246 Fredrik\SpecialChar ~
9243 9247 Kant
9244 9248 \family typewriter
9245 9249 <fredrik.kant-AT-front.com>
9246 9250 \family default
9247 9251 Windows setup.
9248 9252 \layout List
9249 9253 \labelwidthstring 00.00.0000
9250 9254
9251 9255 Syver\SpecialChar ~
9252 9256 Enstad
9253 9257 \family typewriter
9254 9258 <syver-en-AT-online.no>
9255 9259 \family default
9256 9260 Windows setup.
9257 9261 \layout List
9258 9262 \labelwidthstring 00.00.0000
9259 9263
9260 9264 Richard
9261 9265 \family typewriter
9262 9266 <rxe-AT-renre-europe.com>
9263 9267 \family default
9264 9268 Global embedding.
9265 9269 \layout List
9266 9270 \labelwidthstring 00.00.0000
9267 9271
9268 9272 Hayden\SpecialChar ~
9269 9273 Callow
9270 9274 \family typewriter
9271 9275 <h.callow-AT-elec.canterbury.ac.nz>
9272 9276 \family default
9273 9277 Gnuplot.py 1.6 compatibility.
9274 9278 \layout List
9275 9279 \labelwidthstring 00.00.0000
9276 9280
9277 9281 Leonardo\SpecialChar ~
9278 9282 Santagada
9279 9283 \family typewriter
9280 9284 <retype-AT-terra.com.br>
9281 9285 \family default
9282 9286 Fixes for Windows installation.
9283 9287 \layout List
9284 9288 \labelwidthstring 00.00.0000
9285 9289
9286 9290 Christopher\SpecialChar ~
9287 9291 Armstrong
9288 9292 \family typewriter
9289 9293 <radix-AT-twistedmatrix.com>
9290 9294 \family default
9291 9295 Bugfixes.
9292 9296 \layout List
9293 9297 \labelwidthstring 00.00.0000
9294 9298
9295 9299 Francois\SpecialChar ~
9296 9300 Pinard
9297 9301 \family typewriter
9298 9302 <pinard-AT-iro.umontreal.ca>
9299 9303 \family default
9300 9304 Code and documentation fixes.
9301 9305 \layout List
9302 9306 \labelwidthstring 00.00.0000
9303 9307
9304 9308 Cory\SpecialChar ~
9305 9309 Dodt
9306 9310 \family typewriter
9307 9311 <cdodt-AT-fcoe.k12.ca.us>
9308 9312 \family default
9309 9313 Bug reports and Windows ideas.
9310 9314 Patches for Windows installer.
9311 9315 \layout List
9312 9316 \labelwidthstring 00.00.0000
9313 9317
9314 9318 Olivier\SpecialChar ~
9315 9319 Aubert
9316 9320 \family typewriter
9317 9321 <oaubert-AT-bat710.univ-lyon1.fr>
9318 9322 \family default
9319 9323 New magics.
9320 9324 \layout List
9321 9325 \labelwidthstring 00.00.0000
9322 9326
9323 9327 King\SpecialChar ~
9324 9328 C.\SpecialChar ~
9325 9329 Shu
9326 9330 \family typewriter
9327 9331 <kingshu-AT-myrealbox.com>
9328 9332 \family default
9329 9333 Autoindent patch.
9330 9334 \layout List
9331 9335 \labelwidthstring 00.00.0000
9332 9336
9333 9337 Chris\SpecialChar ~
9334 9338 Drexler
9335 9339 \family typewriter
9336 9340 <chris-AT-ac-drexler.de>
9337 9341 \family default
9338 9342 Readline packages for Win32/CygWin.
9339 9343 \layout List
9340 9344 \labelwidthstring 00.00.0000
9341 9345
9342 9346 Gustavo\SpecialChar ~
9343 9347 Cordova\SpecialChar ~
9344 9348 Avila
9345 9349 \family typewriter
9346 9350 <gcordova-AT-sismex.com>
9347 9351 \family default
9348 9352 EvalDict code for nice, lightweight string interpolation.
9349 9353 \layout List
9350 9354 \labelwidthstring 00.00.0000
9351 9355
9352 9356 Kasper\SpecialChar ~
9353 9357 Souren
9354 9358 \family typewriter
9355 9359 <Kasper.Souren-AT-ircam.fr>
9356 9360 \family default
9357 9361 Bug reports, ideas.
9358 9362 \layout List
9359 9363 \labelwidthstring 00.00.0000
9360 9364
9361 9365 Gever\SpecialChar ~
9362 9366 Tulley
9363 9367 \family typewriter
9364 9368 <gever-AT-helium.com>
9365 9369 \family default
9366 9370 Code contributions.
9367 9371 \layout List
9368 9372 \labelwidthstring 00.00.0000
9369 9373
9370 9374 Ralf\SpecialChar ~
9371 9375 Schmitt
9372 9376 \family typewriter
9373 9377 <ralf-AT-brainbot.com>
9374 9378 \family default
9375 9379 Bug reports & fixes.
9376 9380 \layout List
9377 9381 \labelwidthstring 00.00.0000
9378 9382
9379 9383 Oliver\SpecialChar ~
9380 9384 Sander
9381 9385 \family typewriter
9382 9386 <osander-AT-gmx.de>
9383 9387 \family default
9384 9388 Bug reports.
9385 9389 \layout List
9386 9390 \labelwidthstring 00.00.0000
9387 9391
9388 9392 Rod\SpecialChar ~
9389 9393 Holland
9390 9394 \family typewriter
9391 9395 <rhh-AT-structurelabs.com>
9392 9396 \family default
9393 9397 Bug reports and fixes to logging module.
9394 9398 \layout List
9395 9399 \labelwidthstring 00.00.0000
9396 9400
9397 9401 Daniel\SpecialChar ~
9398 9402 'Dang'\SpecialChar ~
9399 9403 Griffith
9400 9404 \family typewriter
9401 9405 <pythondev-dang-AT-lazytwinacres.net>
9402 9406 \family default
9403 9407 Fixes, enhancement suggestions for system shell use.
9404 9408 \layout List
9405 9409 \labelwidthstring 00.00.0000
9406 9410
9407 9411 Viktor\SpecialChar ~
9408 9412 Ransmayr
9409 9413 \family typewriter
9410 9414 <viktor.ransmayr-AT-t-online.de>
9411 9415 \family default
9412 9416 Tests and reports on Windows installation issues.
9413 9417 Contributed a true Windows binary installer.
9414 9418 \layout List
9415 9419 \labelwidthstring 00.00.0000
9416 9420
9417 9421 Mike\SpecialChar ~
9418 9422 Salib
9419 9423 \family typewriter
9420 9424 <msalib-AT-mit.edu>
9421 9425 \family default
9422 9426 Help fixing a subtle bug related to traceback printing.
9423 9427 \layout List
9424 9428 \labelwidthstring 00.00.0000
9425 9429
9426 9430 W.J.\SpecialChar ~
9427 9431 van\SpecialChar ~
9428 9432 der\SpecialChar ~
9429 9433 Laan
9430 9434 \family typewriter
9431 9435 <gnufnork-AT-hetdigitalegat.nl>
9432 9436 \family default
9433 9437 Bash-like prompt specials.
9434 9438 \layout List
9435 9439 \labelwidthstring 00.00.0000
9436 9440
9437 9441 Antoon\SpecialChar ~
9438 9442 Pardon
9439 9443 \family typewriter
9440 9444 <Antoon.Pardon-AT-rece.vub.ac.be>
9441 9445 \family default
9442 9446 Critical fix for the multithreaded IPython.
9443 9447 \layout List
9444 9448 \labelwidthstring 00.00.0000
9445 9449
9446 9450 John\SpecialChar ~
9447 9451 Hunter
9448 9452 \family typewriter
9449 9453 <jdhunter-AT-nitace.bsd.uchicago.edu>
9450 9454 \family default
9451 9455 Matplotlib author, helped with all the development of support for matplotlib
9452 9456 in IPyhton, including making necessary changes to matplotlib itself.
9453 9457 \layout List
9454 9458 \labelwidthstring 00.00.0000
9455 9459
9456 9460 Matthew\SpecialChar ~
9457 9461 Arnison
9458 9462 \family typewriter
9459 9463 <maffew-AT-cat.org.au>
9460 9464 \family default
9461 9465 Bug reports, `
9462 9466 \family typewriter
9463 9467 %run -d
9464 9468 \family default
9465 9469 ' idea.
9466 9470 \layout List
9467 9471 \labelwidthstring 00.00.0000
9468 9472
9469 9473 Prabhu\SpecialChar ~
9470 9474 Ramachandran
9471 9475 \family typewriter
9472 9476 <prabhu_r-AT-users.sourceforge.net>
9473 9477 \family default
9474 9478 Help with (X)Emacs support, threading patches, ideas...
9475 9479 \layout List
9476 9480 \labelwidthstring 00.00.0000
9477 9481
9478 9482 Norbert\SpecialChar ~
9479 9483 Tretkowski
9480 9484 \family typewriter
9481 9485 <tretkowski-AT-inittab.de>
9482 9486 \family default
9483 9487 help with Debian packaging and distribution.
9484 9488 \layout List
9485 9489 \labelwidthstring 00.00.0000
9486 9490
9487 9491 George\SpecialChar ~
9488 9492 Sakkis <
9489 9493 \family typewriter
9490 9494 gsakkis-AT-eden.rutgers.edu>
9491 9495 \family default
9492 9496 New matcher for tab-completing named arguments of user-defined functions.
9493 9497 \layout List
9494 9498 \labelwidthstring 00.00.0000
9495 9499
9496 9500 JοΏ½rgen\SpecialChar ~
9497 9501 Stenarson
9498 9502 \family typewriter
9499 9503 <jorgen.stenarson-AT-bostream.nu>
9500 9504 \family default
9501 9505 Wildcard support implementation for searching namespaces.
9502 9506 \layout List
9503 9507 \labelwidthstring 00.00.0000
9504 9508
9505 9509 Vivian\SpecialChar ~
9506 9510 De\SpecialChar ~
9507 9511 Smedt
9508 9512 \family typewriter
9509 9513 <vivian-AT-vdesmedt.com>
9510 9514 \family default
9511 9515 Debugger enhancements, so that when pdb is activated from within IPython,
9512 9516 coloring, tab completion and other features continue to work seamlessly.
9513 9517 \layout List
9514 9518 \labelwidthstring 00.00.0000
9515 9519
9516 9520 Scott\SpecialChar ~
9517 9521 Tsai
9518 9522 \family typewriter
9519 9523 <scottt958-AT-yahoo.com.tw>
9520 9524 \family default
9521 9525 Support for automatic editor invocation on syntax errors (see
9522 9526 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython/issue36}
9523 9527
9524 9528 \end_inset
9525 9529
9526 9530 ).
9527 9531 \layout List
9528 9532 \labelwidthstring 00.00.0000
9529 9533
9530 9534 Alexander\SpecialChar ~
9531 9535 Belchenko
9532 9536 \family typewriter
9533 9537 <bialix-AT-ukr.net>
9534 9538 \family default
9535 9539 Improvements for win32 paging system.
9536 9540 \layout List
9537 9541 \labelwidthstring 00.00.0000
9538 9542
9539 9543 Will\SpecialChar ~
9540 9544 Maier
9541 9545 \family typewriter
9542 9546 <willmaier-AT-ml1.net>
9543 9547 \family default
9544 9548 Official OpenBSD port.
9545 9549 \the_end
General Comments 0
You need to be logged in to leave comments. Login now