##// END OF EJS Templates
Add new winconsole module and fixes to page_dumb() to improve its behavior...
fperez -
Show More
@@ -0,0 +1,43 b''
1 """
2 Set of functions to work with console on Windows.
3
4 Author: Alexander Belchenko (e-mail: bialix AT ukr.net)
5 License: Public domain
6 """
7
8 __author__ = 'Alexander Belchenko (e-mail: bialix AT ukr.net)'
9 __license__ = 'Public domain'
10
11 import struct
12
13 try:
14 import ctypes
15 except ImportError:
16 ctypes = None
17
18 def get_console_size(defaultx=80, defaulty=25):
19 """ Return size of current console.
20
21 This function try to determine actual size of current working
22 console window and return tuple (sizex, sizey) if success,
23 or default size (defaultx, defaulty) otherwise.
24
25 Dependencies: ctypes should be installed.
26 """
27 if ctypes is None:
28 # no ctypes is found
29 return (defaultx, defaulty)
30
31 h = ctypes.windll.kernel32.GetStdHandle(-11)
32 csbi = ctypes.create_string_buffer(22)
33 res = ctypes.windll.kernel32.GetConsoleScreenBufferInfo(h, csbi)
34
35 if res:
36 (bufx, bufy, curx, cury, wattr,
37 left, top, right, bottom, maxx, maxy) = struct.unpack("hhhhHhhhhhh",
38 csbi.raw)
39 sizex = right - left + 1
40 sizey = bottom - top + 1
41 return (sizex, sizey)
42 else:
43 return (defaultx, defaulty)
@@ -1,1645 +1,1680 b''
1 1 # -*- coding: utf-8 -*-
2 2 """
3 3 General purpose utilities.
4 4
5 5 This is a grab-bag of stuff I find useful in most programs I write. Some of
6 6 these things are also convenient when working at the command line.
7 7
8 $Id: genutils.py 967 2005-12-29 09:02:13Z fperez $"""
8 $Id: genutils.py 971 2005-12-29 18:30:45Z fperez $"""
9 9
10 10 #*****************************************************************************
11 11 # Copyright (C) 2001-2004 Fernando Perez. <fperez@colorado.edu>
12 12 #
13 13 # Distributed under the terms of the BSD License. The full license is in
14 14 # the file COPYING, distributed as part of this software.
15 15 #*****************************************************************************
16 16
17 17 from __future__ import generators # 2.2 compatibility
18 18
19 19 from IPython import Release
20 20 __author__ = '%s <%s>' % Release.authors['Fernando']
21 21 __license__ = Release.license
22 22
23 23 #****************************************************************************
24 24 # required modules from the Python standard library
25 25 import __main__
26 26 import commands
27 27 import os
28 28 import re
29 29 import shlex
30 30 import shutil
31 31 import sys
32 32 import tempfile
33 33 import time
34 34 import types
35 35
36 36 # Other IPython utilities
37 37 from IPython.Itpl import Itpl,itpl,printpl
38 38 from IPython import DPyGetOpt
39 39
40 if os.name == "nt":
41 from IPython.winconsole import get_console_size
42
40 43 # Build objects which appeared in Python 2.3 for 2.2, to make ipython
41 44 # 2.2-friendly
42 45 try:
43 46 basestring
44 47 except NameError:
45 48 import types
46 49 basestring = (types.StringType, types.UnicodeType)
47 50 True = 1==1
48 51 False = 1==0
49 52
50 53 def enumerate(obj):
51 54 i = -1
52 55 for item in obj:
53 56 i += 1
54 57 yield i, item
55 58
56 59 # add these to the builtin namespace, so that all modules find them
57 60 import __builtin__
58 61 __builtin__.basestring = basestring
59 62 __builtin__.True = True
60 63 __builtin__.False = False
61 64 __builtin__.enumerate = enumerate
62 65
63 66 # Try to use shlex.split for converting an input string into a sys.argv-type
64 67 # list. This appeared in Python 2.3, so here's a quick backport for 2.2.
65 68 try:
66 69 shlex_split = shlex.split
67 70 except AttributeError:
68 71 _quotesre = re.compile(r'[\'"](.*)[\'"]')
69 72 _wordchars = ('abcdfeghijklmnopqrstuvwxyz'
70 73 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.~*?'
71 74 'ßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ'
72 75 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ%s'
73 76 % os.sep)
74 77
75 78 def shlex_split(s):
76 79 """Simplified backport to Python 2.2 of shlex.split().
77 80
78 81 This is a quick and dirty hack, since the shlex module under 2.2 lacks
79 82 several of the features needed to really match the functionality of
80 83 shlex.split() in 2.3."""
81 84
82 85 lex = shlex.shlex(StringIO(s))
83 86 # Try to get options, extensions and path separators as characters
84 87 lex.wordchars = _wordchars
85 88 lex.commenters = ''
86 89 # Make a list out of the lexer by hand, since in 2.2 it's not an
87 90 # iterator.
88 91 lout = []
89 92 while 1:
90 93 token = lex.get_token()
91 94 if token == '':
92 95 break
93 96 # Try to handle quoted tokens correctly
94 97 quotes = _quotesre.match(token)
95 98 if quotes:
96 99 token = quotes.group(1)
97 100 lout.append(token)
98 101 return lout
99 102
100 103 #****************************************************************************
101 104 # Exceptions
102 105 class Error(Exception):
103 106 """Base class for exceptions in this module."""
104 107 pass
105 108
106 109 #----------------------------------------------------------------------------
107 110 class IOStream:
108 111 def __init__(self,stream,fallback):
109 112 if not hasattr(stream,'write') or not hasattr(stream,'flush'):
110 113 stream = fallback
111 114 self.stream = stream
112 115 self._swrite = stream.write
113 116 self.flush = stream.flush
114 117
115 118 def write(self,data):
116 119 try:
117 120 self._swrite(data)
118 121 except:
119 122 try:
120 123 # print handles some unicode issues which may trip a plain
121 124 # write() call. Attempt to emulate write() by using a
122 125 # trailing comma
123 126 print >> self.stream, data,
124 127 except:
125 128 # if we get here, something is seriously broken.
126 129 print >> sys.stderr, \
127 130 'ERROR - failed to write data to stream:', stream
128 131
129 132 class IOTerm:
130 133 """ Term holds the file or file-like objects for handling I/O operations.
131 134
132 135 These are normally just sys.stdin, sys.stdout and sys.stderr but for
133 136 Windows they can can replaced to allow editing the strings before they are
134 137 displayed."""
135 138
136 139 # In the future, having IPython channel all its I/O operations through
137 140 # this class will make it easier to embed it into other environments which
138 141 # are not a normal terminal (such as a GUI-based shell)
139 142 def __init__(self,cin=None,cout=None,cerr=None):
140 143 self.cin = IOStream(cin,sys.stdin)
141 144 self.cout = IOStream(cout,sys.stdout)
142 145 self.cerr = IOStream(cerr,sys.stderr)
143 146
144 147 # Global variable to be used for all I/O
145 148 Term = IOTerm()
146 149
147 150 # Windows-specific code to load Gary Bishop's readline and configure it
148 151 # automatically for the users
149 152 # Note: os.name on cygwin returns posix, so this should only pick up 'native'
150 153 # windows. Cygwin returns 'cygwin' for sys.platform.
151 154 if os.name == 'nt':
152 155 try:
153 156 import readline
154 157 except ImportError:
155 158 pass
156 159 else:
157 160 try:
158 161 _out = readline.GetOutputFile()
159 162 except AttributeError:
160 163 pass
161 164 else:
162 165 # Remake Term to use the readline i/o facilities
163 166 Term = IOTerm(cout=_out,cerr=_out)
164 167 del _out
165 168
166 169 #****************************************************************************
167 170 # Generic warning/error printer, used by everything else
168 171 def warn(msg,level=2,exit_val=1):
169 172 """Standard warning printer. Gives formatting consistency.
170 173
171 174 Output is sent to Term.cerr (sys.stderr by default).
172 175
173 176 Options:
174 177
175 178 -level(2): allows finer control:
176 179 0 -> Do nothing, dummy function.
177 180 1 -> Print message.
178 181 2 -> Print 'WARNING:' + message. (Default level).
179 182 3 -> Print 'ERROR:' + message.
180 183 4 -> Print 'FATAL ERROR:' + message and trigger a sys.exit(exit_val).
181 184
182 185 -exit_val (1): exit value returned by sys.exit() for a level 4
183 186 warning. Ignored for all other levels."""
184 187
185 188 if level>0:
186 189 header = ['','','WARNING: ','ERROR: ','FATAL ERROR: ']
187 190 print >> Term.cerr, '%s%s' % (header[level],msg)
188 191 if level == 4:
189 192 print >> Term.cerr,'Exiting.\n'
190 193 sys.exit(exit_val)
191 194
192 195 def info(msg):
193 196 """Equivalent to warn(msg,level=1)."""
194 197
195 198 warn(msg,level=1)
196 199
197 200 def error(msg):
198 201 """Equivalent to warn(msg,level=3)."""
199 202
200 203 warn(msg,level=3)
201 204
202 205 def fatal(msg,exit_val=1):
203 206 """Equivalent to warn(msg,exit_val=exit_val,level=4)."""
204 207
205 208 warn(msg,exit_val=exit_val,level=4)
206 209
207 210 #----------------------------------------------------------------------------
208 211 StringTypes = types.StringTypes
209 212
210 213 # Basic timing functionality
211 214
212 215 # If possible (Unix), use the resource module instead of time.clock()
213 216 try:
214 217 import resource
215 218 def clock():
216 219 """clock() -> floating point number
217 220
218 221 Return the CPU time in seconds (user time only, system time is
219 222 ignored) since the start of the process. This is done via a call to
220 223 resource.getrusage, so it avoids the wraparound problems in
221 224 time.clock()."""
222 225
223 226 return resource.getrusage(resource.RUSAGE_SELF)[0]
224 227
225 228 def clock2():
226 229 """clock2() -> (t_user,t_system)
227 230
228 231 Similar to clock(), but return a tuple of user/system times."""
229 232 return resource.getrusage(resource.RUSAGE_SELF)[:2]
230 233
231 234 except ImportError:
232 235 clock = time.clock
233 236 def clock2():
234 237 """Under windows, system CPU time can't be measured.
235 238
236 239 This just returns clock() and zero."""
237 240 return time.clock(),0.0
238 241
239 242 def timings_out(reps,func,*args,**kw):
240 243 """timings_out(reps,func,*args,**kw) -> (t_total,t_per_call,output)
241 244
242 245 Execute a function reps times, return a tuple with the elapsed total
243 246 CPU time in seconds, the time per call and the function's output.
244 247
245 248 Under Unix, the return value is the sum of user+system time consumed by
246 249 the process, computed via the resource module. This prevents problems
247 250 related to the wraparound effect which the time.clock() function has.
248 251
249 252 Under Windows the return value is in wall clock seconds. See the
250 253 documentation for the time module for more details."""
251 254
252 255 reps = int(reps)
253 256 assert reps >=1, 'reps must be >= 1'
254 257 if reps==1:
255 258 start = clock()
256 259 out = func(*args,**kw)
257 260 tot_time = clock()-start
258 261 else:
259 262 rng = xrange(reps-1) # the last time is executed separately to store output
260 263 start = clock()
261 264 for dummy in rng: func(*args,**kw)
262 265 out = func(*args,**kw) # one last time
263 266 tot_time = clock()-start
264 267 av_time = tot_time / reps
265 268 return tot_time,av_time,out
266 269
267 270 def timings(reps,func,*args,**kw):
268 271 """timings(reps,func,*args,**kw) -> (t_total,t_per_call)
269 272
270 273 Execute a function reps times, return a tuple with the elapsed total CPU
271 274 time in seconds and the time per call. These are just the first two values
272 275 in timings_out()."""
273 276
274 277 return timings_out(reps,func,*args,**kw)[0:2]
275 278
276 279 def timing(func,*args,**kw):
277 280 """timing(func,*args,**kw) -> t_total
278 281
279 282 Execute a function once, return the elapsed total CPU time in
280 283 seconds. This is just the first value in timings_out()."""
281 284
282 285 return timings_out(1,func,*args,**kw)[0]
283 286
284 287 #****************************************************************************
285 288 # file and system
286 289
287 290 def system(cmd,verbose=0,debug=0,header=''):
288 291 """Execute a system command, return its exit status.
289 292
290 293 Options:
291 294
292 295 - verbose (0): print the command to be executed.
293 296
294 297 - debug (0): only print, do not actually execute.
295 298
296 299 - header (''): Header to print on screen prior to the executed command (it
297 300 is only prepended to the command, no newlines are added).
298 301
299 302 Note: a stateful version of this function is available through the
300 303 SystemExec class."""
301 304
302 305 stat = 0
303 306 if verbose or debug: print header+cmd
304 307 sys.stdout.flush()
305 308 if not debug: stat = os.system(cmd)
306 309 return stat
307 310
308 311 def shell(cmd,verbose=0,debug=0,header=''):
309 312 """Execute a command in the system shell, always return None.
310 313
311 314 Options:
312 315
313 316 - verbose (0): print the command to be executed.
314 317
315 318 - debug (0): only print, do not actually execute.
316 319
317 320 - header (''): Header to print on screen prior to the executed command (it
318 321 is only prepended to the command, no newlines are added).
319 322
320 323 Note: this is similar to genutils.system(), but it returns None so it can
321 324 be conveniently used in interactive loops without getting the return value
322 325 (typically 0) printed many times."""
323 326
324 327 stat = 0
325 328 if verbose or debug: print header+cmd
326 329 # flush stdout so we don't mangle python's buffering
327 330 sys.stdout.flush()
328 331 if not debug:
329 332 os.system(cmd)
330 333
331 334 def getoutput(cmd,verbose=0,debug=0,header='',split=0):
332 335 """Dummy substitute for perl's backquotes.
333 336
334 337 Executes a command and returns the output.
335 338
336 339 Accepts the same arguments as system(), plus:
337 340
338 341 - split(0): if true, the output is returned as a list split on newlines.
339 342
340 343 Note: a stateful version of this function is available through the
341 344 SystemExec class."""
342 345
343 346 if verbose or debug: print header+cmd
344 347 if not debug:
345 348 output = commands.getoutput(cmd)
346 349 if split:
347 350 return output.split('\n')
348 351 else:
349 352 return output
350 353
351 354 def getoutputerror(cmd,verbose=0,debug=0,header='',split=0):
352 355 """Return (standard output,standard error) of executing cmd in a shell.
353 356
354 357 Accepts the same arguments as system(), plus:
355 358
356 359 - split(0): if true, each of stdout/err is returned as a list split on
357 360 newlines.
358 361
359 362 Note: a stateful version of this function is available through the
360 363 SystemExec class."""
361 364
362 365 if verbose or debug: print header+cmd
363 366 if not cmd:
364 367 if split:
365 368 return [],[]
366 369 else:
367 370 return '',''
368 371 if not debug:
369 372 pin,pout,perr = os.popen3(cmd)
370 373 tout = pout.read().rstrip()
371 374 terr = perr.read().rstrip()
372 375 pin.close()
373 376 pout.close()
374 377 perr.close()
375 378 if split:
376 379 return tout.split('\n'),terr.split('\n')
377 380 else:
378 381 return tout,terr
379 382
380 383 # for compatibility with older naming conventions
381 384 xsys = system
382 385 bq = getoutput
383 386
384 387 class SystemExec:
385 388 """Access the system and getoutput functions through a stateful interface.
386 389
387 390 Note: here we refer to the system and getoutput functions from this
388 391 library, not the ones from the standard python library.
389 392
390 393 This class offers the system and getoutput functions as methods, but the
391 394 verbose, debug and header parameters can be set for the instance (at
392 395 creation time or later) so that they don't need to be specified on each
393 396 call.
394 397
395 398 For efficiency reasons, there's no way to override the parameters on a
396 399 per-call basis other than by setting instance attributes. If you need
397 400 local overrides, it's best to directly call system() or getoutput().
398 401
399 402 The following names are provided as alternate options:
400 403 - xsys: alias to system
401 404 - bq: alias to getoutput
402 405
403 406 An instance can then be created as:
404 407 >>> sysexec = SystemExec(verbose=1,debug=0,header='Calling: ')
405 408
406 409 And used as:
407 410 >>> sysexec.xsys('pwd')
408 411 >>> dirlist = sysexec.bq('ls -l')
409 412 """
410 413
411 414 def __init__(self,verbose=0,debug=0,header='',split=0):
412 415 """Specify the instance's values for verbose, debug and header."""
413 416 setattr_list(self,'verbose debug header split')
414 417
415 418 def system(self,cmd):
416 419 """Stateful interface to system(), with the same keyword parameters."""
417 420
418 421 system(cmd,self.verbose,self.debug,self.header)
419 422
420 423 def shell(self,cmd):
421 424 """Stateful interface to shell(), with the same keyword parameters."""
422 425
423 426 shell(cmd,self.verbose,self.debug,self.header)
424 427
425 428 xsys = system # alias
426 429
427 430 def getoutput(self,cmd):
428 431 """Stateful interface to getoutput()."""
429 432
430 433 return getoutput(cmd,self.verbose,self.debug,self.header,self.split)
431 434
432 435 def getoutputerror(self,cmd):
433 436 """Stateful interface to getoutputerror()."""
434 437
435 438 return getoutputerror(cmd,self.verbose,self.debug,self.header,self.split)
436 439
437 440 bq = getoutput # alias
438 441
439 442 #-----------------------------------------------------------------------------
440 443 def mutex_opts(dict,ex_op):
441 444 """Check for presence of mutually exclusive keys in a dict.
442 445
443 446 Call: mutex_opts(dict,[[op1a,op1b],[op2a,op2b]...]"""
444 447 for op1,op2 in ex_op:
445 448 if op1 in dict and op2 in dict:
446 449 raise ValueError,'\n*** ERROR in Arguments *** '\
447 450 'Options '+op1+' and '+op2+' are mutually exclusive.'
448 451
449 452 #-----------------------------------------------------------------------------
450 453 def get_py_filename(name):
451 454 """Return a valid python filename in the current directory.
452 455
453 456 If the given name is not a file, it adds '.py' and searches again.
454 457 Raises IOError with an informative message if the file isn't found."""
455 458
456 459 name = os.path.expanduser(name)
457 460 if not os.path.isfile(name) and not name.endswith('.py'):
458 461 name += '.py'
459 462 if os.path.isfile(name):
460 463 return name
461 464 else:
462 465 raise IOError,'File `%s` not found.' % name
463 466
464 467 #-----------------------------------------------------------------------------
465 468 def filefind(fname,alt_dirs = None):
466 469 """Return the given filename either in the current directory, if it
467 470 exists, or in a specified list of directories.
468 471
469 472 ~ expansion is done on all file and directory names.
470 473
471 474 Upon an unsuccessful search, raise an IOError exception."""
472 475
473 476 if alt_dirs is None:
474 477 try:
475 478 alt_dirs = get_home_dir()
476 479 except HomeDirError:
477 480 alt_dirs = os.getcwd()
478 481 search = [fname] + list_strings(alt_dirs)
479 482 search = map(os.path.expanduser,search)
480 483 #print 'search list for',fname,'list:',search # dbg
481 484 fname = search[0]
482 485 if os.path.isfile(fname):
483 486 return fname
484 487 for direc in search[1:]:
485 488 testname = os.path.join(direc,fname)
486 489 #print 'testname',testname # dbg
487 490 if os.path.isfile(testname):
488 491 return testname
489 492 raise IOError,'File' + `fname` + \
490 493 ' not found in current or supplied directories:' + `alt_dirs`
491 494
492 495 #----------------------------------------------------------------------------
493 496 def file_read(filename):
494 497 """Read a file and close it. Returns the file source."""
495 498 fobj=open(filename,'r');
496 499 source = fobj.read();
497 500 fobj.close()
498 501 return source
499 502
500 503 #----------------------------------------------------------------------------
501 504 def target_outdated(target,deps):
502 505 """Determine whether a target is out of date.
503 506
504 507 target_outdated(target,deps) -> 1/0
505 508
506 509 deps: list of filenames which MUST exist.
507 510 target: single filename which may or may not exist.
508 511
509 512 If target doesn't exist or is older than any file listed in deps, return
510 513 true, otherwise return false.
511 514 """
512 515 try:
513 516 target_time = os.path.getmtime(target)
514 517 except os.error:
515 518 return 1
516 519 for dep in deps:
517 520 dep_time = os.path.getmtime(dep)
518 521 if dep_time > target_time:
519 522 #print "For target",target,"Dep failed:",dep # dbg
520 523 #print "times (dep,tar):",dep_time,target_time # dbg
521 524 return 1
522 525 return 0
523 526
524 527 #-----------------------------------------------------------------------------
525 528 def target_update(target,deps,cmd):
526 529 """Update a target with a given command given a list of dependencies.
527 530
528 531 target_update(target,deps,cmd) -> runs cmd if target is outdated.
529 532
530 533 This is just a wrapper around target_outdated() which calls the given
531 534 command if target is outdated."""
532 535
533 536 if target_outdated(target,deps):
534 537 xsys(cmd)
535 538
536 539 #----------------------------------------------------------------------------
537 540 def unquote_ends(istr):
538 541 """Remove a single pair of quotes from the endpoints of a string."""
539 542
540 543 if not istr:
541 544 return istr
542 545 if (istr[0]=="'" and istr[-1]=="'") or \
543 546 (istr[0]=='"' and istr[-1]=='"'):
544 547 return istr[1:-1]
545 548 else:
546 549 return istr
547 550
548 551 #----------------------------------------------------------------------------
549 552 def process_cmdline(argv,names=[],defaults={},usage=''):
550 553 """ Process command-line options and arguments.
551 554
552 555 Arguments:
553 556
554 557 - argv: list of arguments, typically sys.argv.
555 558
556 559 - names: list of option names. See DPyGetOpt docs for details on options
557 560 syntax.
558 561
559 562 - defaults: dict of default values.
560 563
561 564 - usage: optional usage notice to print if a wrong argument is passed.
562 565
563 566 Return a dict of options and a list of free arguments."""
564 567
565 568 getopt = DPyGetOpt.DPyGetOpt()
566 569 getopt.setIgnoreCase(0)
567 570 getopt.parseConfiguration(names)
568 571
569 572 try:
570 573 getopt.processArguments(argv)
571 574 except:
572 575 print usage
573 576 warn(`sys.exc_value`,level=4)
574 577
575 578 defaults.update(getopt.optionValues)
576 579 args = getopt.freeValues
577 580
578 581 return defaults,args
579 582
580 583 #----------------------------------------------------------------------------
581 584 def optstr2types(ostr):
582 585 """Convert a string of option names to a dict of type mappings.
583 586
584 587 optstr2types(str) -> {None:'string_opts',int:'int_opts',float:'float_opts'}
585 588
586 589 This is used to get the types of all the options in a string formatted
587 590 with the conventions of DPyGetOpt. The 'type' None is used for options
588 591 which are strings (they need no further conversion). This function's main
589 592 use is to get a typemap for use with read_dict().
590 593 """
591 594
592 595 typeconv = {None:'',int:'',float:''}
593 596 typemap = {'s':None,'i':int,'f':float}
594 597 opt_re = re.compile(r'([\w]*)([^:=]*:?=?)([sif]?)')
595 598
596 599 for w in ostr.split():
597 600 oname,alias,otype = opt_re.match(w).groups()
598 601 if otype == '' or alias == '!': # simple switches are integers too
599 602 otype = 'i'
600 603 typeconv[typemap[otype]] += oname + ' '
601 604 return typeconv
602 605
603 606 #----------------------------------------------------------------------------
604 607 def read_dict(filename,type_conv=None,**opt):
605 608
606 609 """Read a dictionary of key=value pairs from an input file, optionally
607 610 performing conversions on the resulting values.
608 611
609 612 read_dict(filename,type_conv,**opt) -> dict
610 613
611 614 Only one value per line is accepted, the format should be
612 615 # optional comments are ignored
613 616 key value\n
614 617
615 618 Args:
616 619
617 620 - type_conv: A dictionary specifying which keys need to be converted to
618 621 which types. By default all keys are read as strings. This dictionary
619 622 should have as its keys valid conversion functions for strings
620 623 (int,long,float,complex, or your own). The value for each key
621 624 (converter) should be a whitespace separated string containing the names
622 625 of all the entries in the file to be converted using that function. For
623 626 keys to be left alone, use None as the conversion function (only needed
624 627 with purge=1, see below).
625 628
626 629 - opt: dictionary with extra options as below (default in parens)
627 630
628 631 purge(0): if set to 1, all keys *not* listed in type_conv are purged out
629 632 of the dictionary to be returned. If purge is going to be used, the
630 633 set of keys to be left as strings also has to be explicitly specified
631 634 using the (non-existent) conversion function None.
632 635
633 636 fs(None): field separator. This is the key/value separator to be used
634 637 when parsing the file. The None default means any whitespace [behavior
635 638 of string.split()].
636 639
637 640 strip(0): if 1, strip string values of leading/trailinig whitespace.
638 641
639 642 warn(1): warning level if requested keys are not found in file.
640 643 - 0: silently ignore.
641 644 - 1: inform but proceed.
642 645 - 2: raise KeyError exception.
643 646
644 647 no_empty(0): if 1, remove keys with whitespace strings as a value.
645 648
646 649 unique([]): list of keys (or space separated string) which can't be
647 650 repeated. If one such key is found in the file, each new instance
648 651 overwrites the previous one. For keys not listed here, the behavior is
649 652 to make a list of all appearances.
650 653
651 654 Example:
652 655 If the input file test.ini has:
653 656 i 3
654 657 x 4.5
655 658 y 5.5
656 659 s hi ho
657 660 Then:
658 661
659 662 >>> type_conv={int:'i',float:'x',None:'s'}
660 663 >>> read_dict('test.ini')
661 664 {'i': '3', 's': 'hi ho', 'x': '4.5', 'y': '5.5'}
662 665 >>> read_dict('test.ini',type_conv)
663 666 {'i': 3, 's': 'hi ho', 'x': 4.5, 'y': '5.5'}
664 667 >>> read_dict('test.ini',type_conv,purge=1)
665 668 {'i': 3, 's': 'hi ho', 'x': 4.5}
666 669 """
667 670
668 671 # starting config
669 672 opt.setdefault('purge',0)
670 673 opt.setdefault('fs',None) # field sep defaults to any whitespace
671 674 opt.setdefault('strip',0)
672 675 opt.setdefault('warn',1)
673 676 opt.setdefault('no_empty',0)
674 677 opt.setdefault('unique','')
675 678 if type(opt['unique']) in StringTypes:
676 679 unique_keys = qw(opt['unique'])
677 680 elif type(opt['unique']) in (types.TupleType,types.ListType):
678 681 unique_keys = opt['unique']
679 682 else:
680 683 raise ValueError, 'Unique keys must be given as a string, List or Tuple'
681 684
682 685 dict = {}
683 686 # first read in table of values as strings
684 687 file = open(filename,'r')
685 688 for line in file.readlines():
686 689 line = line.strip()
687 690 if len(line) and line[0]=='#': continue
688 691 if len(line)>0:
689 692 lsplit = line.split(opt['fs'],1)
690 693 try:
691 694 key,val = lsplit
692 695 except ValueError:
693 696 key,val = lsplit[0],''
694 697 key = key.strip()
695 698 if opt['strip']: val = val.strip()
696 699 if val == "''" or val == '""': val = ''
697 700 if opt['no_empty'] and (val=='' or val.isspace()):
698 701 continue
699 702 # if a key is found more than once in the file, build a list
700 703 # unless it's in the 'unique' list. In that case, last found in file
701 704 # takes precedence. User beware.
702 705 try:
703 706 if dict[key] and key in unique_keys:
704 707 dict[key] = val
705 708 elif type(dict[key]) is types.ListType:
706 709 dict[key].append(val)
707 710 else:
708 711 dict[key] = [dict[key],val]
709 712 except KeyError:
710 713 dict[key] = val
711 714 # purge if requested
712 715 if opt['purge']:
713 716 accepted_keys = qwflat(type_conv.values())
714 717 for key in dict.keys():
715 718 if key in accepted_keys: continue
716 719 del(dict[key])
717 720 # now convert if requested
718 721 if type_conv==None: return dict
719 722 conversions = type_conv.keys()
720 723 try: conversions.remove(None)
721 724 except: pass
722 725 for convert in conversions:
723 726 for val in qw(type_conv[convert]):
724 727 try:
725 728 dict[val] = convert(dict[val])
726 729 except KeyError,e:
727 730 if opt['warn'] == 0:
728 731 pass
729 732 elif opt['warn'] == 1:
730 733 print >>sys.stderr, 'Warning: key',val,\
731 734 'not found in file',filename
732 735 elif opt['warn'] == 2:
733 736 raise KeyError,e
734 737 else:
735 738 raise ValueError,'Warning level must be 0,1 or 2'
736 739
737 740 return dict
738 741
739 742 #----------------------------------------------------------------------------
740 743 def flag_calls(func):
741 744 """Wrap a function to detect and flag when it gets called.
742 745
743 746 This is a decorator which takes a function and wraps it in a function with
744 747 a 'called' attribute. wrapper.called is initialized to False.
745 748
746 749 The wrapper.called attribute is set to False right before each call to the
747 750 wrapped function, so if the call fails it remains False. After the call
748 751 completes, wrapper.called is set to True and the output is returned.
749 752
750 753 Testing for truth in wrapper.called allows you to determine if a call to
751 754 func() was attempted and succeeded."""
752 755
753 756 def wrapper(*args,**kw):
754 757 wrapper.called = False
755 758 out = func(*args,**kw)
756 759 wrapper.called = True
757 760 return out
758 761
759 762 wrapper.called = False
760 763 wrapper.__doc__ = func.__doc__
761 764 return wrapper
762 765
763 766 #----------------------------------------------------------------------------
764 767 class HomeDirError(Error):
765 768 pass
766 769
767 770 def get_home_dir():
768 771 """Return the closest possible equivalent to a 'home' directory.
769 772
770 773 We first try $HOME. Absent that, on NT it's $HOMEDRIVE\$HOMEPATH.
771 774
772 775 Currently only Posix and NT are implemented, a HomeDirError exception is
773 776 raised for all other OSes. """
774 777
775 778 isdir = os.path.isdir
776 779 env = os.environ
777 780 try:
778 781 homedir = env['HOME']
779 782 if not isdir(homedir):
780 783 # in case a user stuck some string which does NOT resolve to a
781 784 # valid path, it's as good as if we hadn't foud it
782 785 raise KeyError
783 786 return homedir
784 787 except KeyError:
785 788 if os.name == 'posix':
786 789 raise HomeDirError,'undefined $HOME, IPython can not proceed.'
787 790 elif os.name == 'nt':
788 791 # For some strange reason, win9x returns 'nt' for os.name.
789 792 try:
790 793 homedir = os.path.join(env['HOMEDRIVE'],env['HOMEPATH'])
791 794 if not isdir(homedir):
792 795 homedir = os.path.join(env['USERPROFILE'])
793 796 if not isdir(homedir):
794 797 raise HomeDirError
795 798 return homedir
796 799 except:
797 800 try:
798 801 # Use the registry to get the 'My Documents' folder.
799 802 import _winreg as wreg
800 803 key = wreg.OpenKey(wreg.HKEY_CURRENT_USER,
801 804 "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
802 805 homedir = wreg.QueryValueEx(key,'Personal')[0]
803 806 key.Close()
804 807 if not isdir(homedir):
805 808 e = ('Invalid "Personal" folder registry key '
806 809 'typically "My Documents".\n'
807 810 'Value: %s\n'
808 811 'This is not a valid directory on your system.' %
809 812 homedir)
810 813 raise HomeDirError(e)
811 814 return homedir
812 815 except HomeDirError:
813 816 raise
814 817 except:
815 818 return 'C:\\'
816 819 elif os.name == 'dos':
817 820 # Desperate, may do absurd things in classic MacOS. May work under DOS.
818 821 return 'C:\\'
819 822 else:
820 823 raise HomeDirError,'support for your operating system not implemented.'
821 824
822 825 #****************************************************************************
823 826 # strings and text
824 827
825 828 class LSString(str):
826 829 """String derivative with a special access attributes.
827 830
828 831 These are normal strings, but with the special attributes:
829 832
830 833 .l (or .list) : value as list (split on newlines).
831 834 .n (or .nlstr): original value (the string itself).
832 835 .s (or .spstr): value as whitespace-separated string.
833 836
834 837 Any values which require transformations are computed only once and
835 838 cached.
836 839
837 840 Such strings are very useful to efficiently interact with the shell, which
838 841 typically only understands whitespace-separated options for commands."""
839 842
840 843 def get_list(self):
841 844 try:
842 845 return self.__list
843 846 except AttributeError:
844 847 self.__list = self.split('\n')
845 848 return self.__list
846 849
847 850 l = list = property(get_list)
848 851
849 852 def get_spstr(self):
850 853 try:
851 854 return self.__spstr
852 855 except AttributeError:
853 856 self.__spstr = self.replace('\n',' ')
854 857 return self.__spstr
855 858
856 859 s = spstr = property(get_spstr)
857 860
858 861 def get_nlstr(self):
859 862 return self
860 863
861 864 n = nlstr = property(get_nlstr)
862 865
863 866 #----------------------------------------------------------------------------
864 867 class SList(list):
865 868 """List derivative with a special access attributes.
866 869
867 870 These are normal lists, but with the special attributes:
868 871
869 872 .l (or .list) : value as list (the list itself).
870 873 .n (or .nlstr): value as a string, joined on newlines.
871 874 .s (or .spstr): value as a string, joined on spaces.
872 875
873 876 Any values which require transformations are computed only once and
874 877 cached."""
875 878
876 879 def get_list(self):
877 880 return self
878 881
879 882 l = list = property(get_list)
880 883
881 884 def get_spstr(self):
882 885 try:
883 886 return self.__spstr
884 887 except AttributeError:
885 888 self.__spstr = ' '.join(self)
886 889 return self.__spstr
887 890
888 891 s = spstr = property(get_spstr)
889 892
890 893 def get_nlstr(self):
891 894 try:
892 895 return self.__nlstr
893 896 except AttributeError:
894 897 self.__nlstr = '\n'.join(self)
895 898 return self.__nlstr
896 899
897 900 n = nlstr = property(get_nlstr)
898 901
899 902 #----------------------------------------------------------------------------
900 903 # This can be replaced with an isspace() call once we drop 2.2 compatibility
901 904 _isspace_match = re.compile(r'^\s+$').match
902 905 def isspace(s):
903 906 return bool(_isspace_match(s))
904 907
905 908 #----------------------------------------------------------------------------
906 909 def esc_quotes(strng):
907 910 """Return the input string with single and double quotes escaped out"""
908 911
909 912 return strng.replace('"','\\"').replace("'","\\'")
910 913
911 914 #----------------------------------------------------------------------------
912 915 def raw_input_multi(header='', ps1='==> ', ps2='..> ',terminate_str = '.'):
913 916 """Take multiple lines of input.
914 917
915 918 A list with each line of input as a separate element is returned when a
916 919 termination string is entered (defaults to a single '.'). Input can also
917 920 terminate via EOF (^D in Unix, ^Z-RET in Windows).
918 921
919 922 Lines of input which end in \\ are joined into single entries (and a
920 923 secondary continuation prompt is issued as long as the user terminates
921 924 lines with \\). This allows entering very long strings which are still
922 925 meant to be treated as single entities.
923 926 """
924 927
925 928 try:
926 929 if header:
927 930 header += '\n'
928 931 lines = [raw_input(header + ps1)]
929 932 except EOFError:
930 933 return []
931 934 terminate = [terminate_str]
932 935 try:
933 936 while lines[-1:] != terminate:
934 937 new_line = raw_input(ps1)
935 938 while new_line.endswith('\\'):
936 939 new_line = new_line[:-1] + raw_input(ps2)
937 940 lines.append(new_line)
938 941
939 942 return lines[:-1] # don't return the termination command
940 943 except EOFError:
941 944 print
942 945 return lines
943 946
944 947 #----------------------------------------------------------------------------
945 948 def raw_input_ext(prompt='', ps2='... '):
946 949 """Similar to raw_input(), but accepts extended lines if input ends with \\."""
947 950
948 951 line = raw_input(prompt)
949 952 while line.endswith('\\'):
950 953 line = line[:-1] + raw_input(ps2)
951 954 return line
952 955
953 956 #----------------------------------------------------------------------------
954 957 def ask_yes_no(prompt,default=None):
955 958 """Asks a question and returns an integer 1/0 (y/n) answer.
956 959
957 960 If default is given (one of 'y','n'), it is used if the user input is
958 961 empty. Otherwise the question is repeated until an answer is given.
959 962 If EOF occurs 20 times consecutively, the default answer is assumed,
960 963 or if there is no default, an exception is raised to prevent infinite
961 964 loops.
962 965
963 966 Valid answers are: y/yes/n/no (match is not case sensitive)."""
964 967
965 968 answers = {'y':True,'n':False,'yes':True,'no':False}
966 969 ans = None
967 970 eofs, max_eofs = 0, 20
968 971 while ans not in answers.keys():
969 972 try:
970 973 ans = raw_input(prompt+' ').lower()
971 974 if not ans: # response was an empty string
972 975 ans = default
973 976 eofs = 0
974 977 except (EOFError,KeyboardInterrupt):
975 978 eofs = eofs + 1
976 979 if eofs >= max_eofs:
977 980 if default in answers.keys():
978 981 ans = default
979 982 else:
980 983 raise
981 984
982 985 return answers[ans]
983 986
984 987 #----------------------------------------------------------------------------
985 988 def marquee(txt='',width=78,mark='*'):
986 989 """Return the input string centered in a 'marquee'."""
987 990 if not txt:
988 991 return (mark*width)[:width]
989 992 nmark = (width-len(txt)-2)/len(mark)/2
990 993 if nmark < 0: nmark =0
991 994 marks = mark*nmark
992 995 return '%s %s %s' % (marks,txt,marks)
993 996
994 997 #----------------------------------------------------------------------------
995 998 class EvalDict:
996 999 """
997 1000 Emulate a dict which evaluates its contents in the caller's frame.
998 1001
999 1002 Usage:
1000 1003 >>>number = 19
1001 1004 >>>text = "python"
1002 1005 >>>print "%(text.capitalize())s %(number/9.0).1f rules!" % EvalDict()
1003 1006 """
1004 1007
1005 1008 # This version is due to sismex01@hebmex.com on c.l.py, and is basically a
1006 1009 # modified (shorter) version of:
1007 1010 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66018 by
1008 1011 # Skip Montanaro (skip@pobox.com).
1009 1012
1010 1013 def __getitem__(self, name):
1011 1014 frame = sys._getframe(1)
1012 1015 return eval(name, frame.f_globals, frame.f_locals)
1013 1016
1014 1017 EvalString = EvalDict # for backwards compatibility
1015 1018 #----------------------------------------------------------------------------
1016 1019 def qw(words,flat=0,sep=None,maxsplit=-1):
1017 1020 """Similar to Perl's qw() operator, but with some more options.
1018 1021
1019 1022 qw(words,flat=0,sep=' ',maxsplit=-1) -> words.split(sep,maxsplit)
1020 1023
1021 1024 words can also be a list itself, and with flat=1, the output will be
1022 1025 recursively flattened. Examples:
1023 1026
1024 1027 >>> qw('1 2')
1025 1028 ['1', '2']
1026 1029 >>> qw(['a b','1 2',['m n','p q']])
1027 1030 [['a', 'b'], ['1', '2'], [['m', 'n'], ['p', 'q']]]
1028 1031 >>> qw(['a b','1 2',['m n','p q']],flat=1)
1029 1032 ['a', 'b', '1', '2', 'm', 'n', 'p', 'q'] """
1030 1033
1031 1034 if type(words) in StringTypes:
1032 1035 return [word.strip() for word in words.split(sep,maxsplit)
1033 1036 if word and not word.isspace() ]
1034 1037 if flat:
1035 1038 return flatten(map(qw,words,[1]*len(words)))
1036 1039 return map(qw,words)
1037 1040
1038 1041 #----------------------------------------------------------------------------
1039 1042 def qwflat(words,sep=None,maxsplit=-1):
1040 1043 """Calls qw(words) in flat mode. It's just a convenient shorthand."""
1041 1044 return qw(words,1,sep,maxsplit)
1042 1045
1043 1046 #----------------------------------------------------------------------------
1044 1047 def qw_lol(indata):
1045 1048 """qw_lol('a b') -> [['a','b']],
1046 1049 otherwise it's just a call to qw().
1047 1050
1048 1051 We need this to make sure the modules_some keys *always* end up as a
1049 1052 list of lists."""
1050 1053
1051 1054 if type(indata) in StringTypes:
1052 1055 return [qw(indata)]
1053 1056 else:
1054 1057 return qw(indata)
1055 1058
1056 1059 #-----------------------------------------------------------------------------
1057 1060 def list_strings(arg):
1058 1061 """Always return a list of strings, given a string or list of strings
1059 1062 as input."""
1060 1063
1061 1064 if type(arg) in StringTypes: return [arg]
1062 1065 else: return arg
1063 1066
1064 1067 #----------------------------------------------------------------------------
1065 1068 def grep(pat,list,case=1):
1066 1069 """Simple minded grep-like function.
1067 1070 grep(pat,list) returns occurrences of pat in list, None on failure.
1068 1071
1069 1072 It only does simple string matching, with no support for regexps. Use the
1070 1073 option case=0 for case-insensitive matching."""
1071 1074
1072 1075 # This is pretty crude. At least it should implement copying only references
1073 1076 # to the original data in case it's big. Now it copies the data for output.
1074 1077 out=[]
1075 1078 if case:
1076 1079 for term in list:
1077 1080 if term.find(pat)>-1: out.append(term)
1078 1081 else:
1079 1082 lpat=pat.lower()
1080 1083 for term in list:
1081 1084 if term.lower().find(lpat)>-1: out.append(term)
1082 1085
1083 1086 if len(out): return out
1084 1087 else: return None
1085 1088
1086 1089 #----------------------------------------------------------------------------
1087 1090 def dgrep(pat,*opts):
1088 1091 """Return grep() on dir()+dir(__builtins__).
1089 1092
1090 1093 A very common use of grep() when working interactively."""
1091 1094
1092 1095 return grep(pat,dir(__main__)+dir(__main__.__builtins__),*opts)
1093 1096
1094 1097 #----------------------------------------------------------------------------
1095 1098 def idgrep(pat):
1096 1099 """Case-insensitive dgrep()"""
1097 1100
1098 1101 return dgrep(pat,0)
1099 1102
1100 1103 #----------------------------------------------------------------------------
1101 1104 def igrep(pat,list):
1102 1105 """Synonym for case-insensitive grep."""
1103 1106
1104 1107 return grep(pat,list,case=0)
1105 1108
1106 1109 #----------------------------------------------------------------------------
1107 1110 def indent(str,nspaces=4,ntabs=0):
1108 1111 """Indent a string a given number of spaces or tabstops.
1109 1112
1110 1113 indent(str,nspaces=4,ntabs=0) -> indent str by ntabs+nspaces.
1111 1114 """
1112 1115 if str is None:
1113 1116 return
1114 1117 ind = '\t'*ntabs+' '*nspaces
1115 1118 outstr = '%s%s' % (ind,str.replace(os.linesep,os.linesep+ind))
1116 1119 if outstr.endswith(os.linesep+ind):
1117 1120 return outstr[:-len(ind)]
1118 1121 else:
1119 1122 return outstr
1120 1123
1121 1124 #-----------------------------------------------------------------------------
1122 1125 def native_line_ends(filename,backup=1):
1123 1126 """Convert (in-place) a file to line-ends native to the current OS.
1124 1127
1125 1128 If the optional backup argument is given as false, no backup of the
1126 1129 original file is left. """
1127 1130
1128 1131 backup_suffixes = {'posix':'~','dos':'.bak','nt':'.bak','mac':'.bak'}
1129 1132
1130 1133 bak_filename = filename + backup_suffixes[os.name]
1131 1134
1132 1135 original = open(filename).read()
1133 1136 shutil.copy2(filename,bak_filename)
1134 1137 try:
1135 1138 new = open(filename,'wb')
1136 1139 new.write(os.linesep.join(original.splitlines()))
1137 1140 new.write(os.linesep) # ALWAYS put an eol at the end of the file
1138 1141 new.close()
1139 1142 except:
1140 1143 os.rename(bak_filename,filename)
1141 1144 if not backup:
1142 1145 try:
1143 1146 os.remove(bak_filename)
1144 1147 except:
1145 1148 pass
1146 1149
1147 1150 #----------------------------------------------------------------------------
1148 1151 def get_pager_cmd(pager_cmd = None):
1149 1152 """Return a pager command.
1150 1153
1151 1154 Makes some attempts at finding an OS-correct one."""
1152 1155
1153 1156 if os.name == 'posix':
1154 1157 default_pager_cmd = 'less -r' # -r for color control sequences
1155 1158 elif os.name in ['nt','dos']:
1156 1159 default_pager_cmd = 'type'
1157 1160
1158 1161 if pager_cmd is None:
1159 1162 try:
1160 1163 pager_cmd = os.environ['PAGER']
1161 1164 except:
1162 1165 pager_cmd = default_pager_cmd
1163 1166 return pager_cmd
1164 1167
1165 1168 #-----------------------------------------------------------------------------
1166 1169 def get_pager_start(pager,start):
1167 1170 """Return the string for paging files with an offset.
1168 1171
1169 1172 This is the '+N' argument which less and more (under Unix) accept.
1170 1173 """
1171 1174
1172 1175 if pager in ['less','more']:
1173 1176 if start:
1174 1177 start_string = '+' + str(start)
1175 1178 else:
1176 1179 start_string = ''
1177 1180 else:
1178 1181 start_string = ''
1179 1182 return start_string
1180 1183
1181 1184 #----------------------------------------------------------------------------
1185 if os.name == "nt":
1186 import msvcrt
1187 def page_more():
1188 """ Smart pausing between pages
1189
1190 @return: True if need print more lines, False if quit
1191 """
1192 Term.cout.write('---Return to continue, q to quit--- ')
1193 ans = msvcrt.getch()
1194 if ans in ("q", "Q"):
1195 result = False
1196 else:
1197 result = True
1198 Term.cout.write("\b"*37 + " "*37 + "\b"*37)
1199 return result
1200 else:
1201 def page_more():
1202 ans = raw_input('---Return to continue, q to quit--- ')
1203 if ans.lower().startswith('q'):
1204 return False
1205 else:
1206 return True
1207
1208 esc_re = re.compile(r"(\x1b[^m]+m)")
1209
1182 1210 def page_dumb(strng,start=0,screen_lines=25):
1183 1211 """Very dumb 'pager' in Python, for when nothing else works.
1184 1212
1185 1213 Only moves forward, same interface as page(), except for pager_cmd and
1186 1214 mode."""
1187 1215
1188 1216 out_ln = strng.splitlines()[start:]
1189 1217 screens = chop(out_ln,screen_lines-1)
1190 1218 if len(screens) == 1:
1191 1219 print >>Term.cout, os.linesep.join(screens[0])
1192 1220 else:
1221 last_escape = ""
1193 1222 for scr in screens[0:-1]:
1194 print >>Term.cout, os.linesep.join(scr)
1195 ans = raw_input('---Return to continue, q to quit--- ')
1196 if ans.lower().startswith('q'):
1223 hunk = os.linesep.join(scr)
1224 print >>Term.cout, last_escape + hunk
1225 if not page_more():
1197 1226 return
1198 print >>Term.cout, os.linesep.join(screens[-1])
1227 esc_list = esc_re.findall(hunk)
1228 if len(esc_list) > 0:
1229 last_escape = esc_list[-1]
1230 print >>Term.cout, last_escape + os.linesep.join(screens[-1])
1199 1231
1200 1232 #----------------------------------------------------------------------------
1201 1233 def page(strng,start=0,screen_lines=0,pager_cmd = None):
1202 1234 """Print a string, piping through a pager after a certain length.
1203 1235
1204 1236 The screen_lines parameter specifies the number of *usable* lines of your
1205 1237 terminal screen (total lines minus lines you need to reserve to show other
1206 1238 information).
1207 1239
1208 1240 If you set screen_lines to a number <=0, page() will try to auto-determine
1209 1241 your screen size and will only use up to (screen_size+screen_lines) for
1210 1242 printing, paging after that. That is, if you want auto-detection but need
1211 1243 to reserve the bottom 3 lines of the screen, use screen_lines = -3, and for
1212 1244 auto-detection without any lines reserved simply use screen_lines = 0.
1213 1245
1214 1246 If a string won't fit in the allowed lines, it is sent through the
1215 1247 specified pager command. If none given, look for PAGER in the environment,
1216 1248 and ultimately default to less.
1217 1249
1218 1250 If no system pager works, the string is sent through a 'dumb pager'
1219 1251 written in python, very simplistic.
1220 1252 """
1221 1253
1222 1254 # Ugly kludge, but calling curses.initscr() flat out crashes in emacs
1223 1255 TERM = os.environ.get('TERM','dumb')
1224 1256 if TERM in ['dumb','emacs'] and os.name != 'nt':
1225 1257 print strng
1226 1258 return
1227 1259 # chop off the topmost part of the string we don't want to see
1228 1260 str_lines = strng.split(os.linesep)[start:]
1229 1261 str_toprint = os.linesep.join(str_lines)
1230 1262 num_newlines = len(str_lines)
1231 1263 len_str = len(str_toprint)
1232 1264
1233 1265 # Dumb heuristics to guesstimate number of on-screen lines the string
1234 1266 # takes. Very basic, but good enough for docstrings in reasonable
1235 1267 # terminals. If someone later feels like refining it, it's not hard.
1236 1268 numlines = max(num_newlines,int(len_str/80)+1)
1237 1269
1238 screen_lines_def = 25 # default value if we can't auto-determine
1270 if os.name == "nt":
1271 screen_lines_def = get_console_size(defaulty=25)[1]
1272 else:
1273 screen_lines_def = 25 # default value if we can't auto-determine
1239 1274
1240 1275 # auto-determine screen size
1241 1276 if screen_lines <= 0:
1242 1277 if TERM=='xterm':
1243 1278 try:
1244 1279 import curses
1245 1280 if hasattr(curses,'initscr'):
1246 1281 use_curses = 1
1247 1282 else:
1248 1283 use_curses = 0
1249 1284 except ImportError:
1250 1285 use_curses = 0
1251 1286 else:
1252 1287 # curses causes problems on many terminals other than xterm.
1253 1288 use_curses = 0
1254 1289 if use_curses:
1255 1290 scr = curses.initscr()
1256 1291 screen_lines_real,screen_cols = scr.getmaxyx()
1257 1292 curses.endwin()
1258 1293 screen_lines += screen_lines_real
1259 1294 #print '***Screen size:',screen_lines_real,'lines x',\
1260 1295 #screen_cols,'columns.' # dbg
1261 1296 else:
1262 1297 screen_lines += screen_lines_def
1263 1298
1264 1299 #print 'numlines',numlines,'screenlines',screen_lines # dbg
1265 1300 if numlines <= screen_lines :
1266 1301 #print '*** normal print' # dbg
1267 1302 print >>Term.cout, str_toprint
1268 1303 else:
1269 1304 # Try to open pager and default to internal one if that fails.
1270 1305 # All failure modes are tagged as 'retval=1', to match the return
1271 1306 # value of a failed system command. If any intermediate attempt
1272 1307 # sets retval to 1, at the end we resort to our own page_dumb() pager.
1273 1308 pager_cmd = get_pager_cmd(pager_cmd)
1274 1309 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1275 1310 if os.name == 'nt':
1276 1311 if pager_cmd.startswith('type'):
1277 1312 # The default WinXP 'type' command is failing on complex strings.
1278 1313 retval = 1
1279 1314 else:
1280 1315 tmpname = tempfile.mktemp('.txt')
1281 1316 tmpfile = file(tmpname,'wt')
1282 1317 tmpfile.write(strng)
1283 1318 tmpfile.close()
1284 1319 cmd = "%s < %s" % (pager_cmd,tmpname)
1285 1320 if os.system(cmd):
1286 1321 retval = 1
1287 1322 else:
1288 1323 retval = None
1289 1324 os.remove(tmpname)
1290 1325 else:
1291 1326 try:
1292 1327 retval = None
1293 1328 # if I use popen4, things hang. No idea why.
1294 1329 #pager,shell_out = os.popen4(pager_cmd)
1295 1330 pager = os.popen(pager_cmd,'w')
1296 1331 pager.write(strng)
1297 1332 pager.close()
1298 1333 retval = pager.close() # success returns None
1299 1334 except IOError,msg: # broken pipe when user quits
1300 1335 if msg.args == (32,'Broken pipe'):
1301 1336 retval = None
1302 1337 else:
1303 1338 retval = 1
1304 1339 except OSError:
1305 1340 # Other strange problems, sometimes seen in Win2k/cygwin
1306 1341 retval = 1
1307 1342 if retval is not None:
1308 1343 page_dumb(strng,screen_lines=screen_lines)
1309 1344
1310 1345 #----------------------------------------------------------------------------
1311 1346 def page_file(fname,start = 0, pager_cmd = None):
1312 1347 """Page a file, using an optional pager command and starting line.
1313 1348 """
1314 1349
1315 1350 pager_cmd = get_pager_cmd(pager_cmd)
1316 1351 pager_cmd += ' ' + get_pager_start(pager_cmd,start)
1317 1352
1318 1353 try:
1319 1354 if os.environ['TERM'] in ['emacs','dumb']:
1320 1355 raise EnvironmentError
1321 1356 xsys(pager_cmd + ' ' + fname)
1322 1357 except:
1323 1358 try:
1324 1359 if start > 0:
1325 1360 start -= 1
1326 1361 page(open(fname).read(),start)
1327 1362 except:
1328 1363 print 'Unable to show file',`fname`
1329 1364
1330 1365 #----------------------------------------------------------------------------
1331 1366 def snip_print(str,width = 75,print_full = 0,header = ''):
1332 1367 """Print a string snipping the midsection to fit in width.
1333 1368
1334 1369 print_full: mode control:
1335 1370 - 0: only snip long strings
1336 1371 - 1: send to page() directly.
1337 1372 - 2: snip long strings and ask for full length viewing with page()
1338 1373 Return 1 if snipping was necessary, 0 otherwise."""
1339 1374
1340 1375 if print_full == 1:
1341 1376 page(header+str)
1342 1377 return 0
1343 1378
1344 1379 print header,
1345 1380 if len(str) < width:
1346 1381 print str
1347 1382 snip = 0
1348 1383 else:
1349 1384 whalf = int((width -5)/2)
1350 1385 print str[:whalf] + ' <...> ' + str[-whalf:]
1351 1386 snip = 1
1352 1387 if snip and print_full == 2:
1353 1388 if raw_input(header+' Snipped. View (y/n)? [N]').lower() == 'y':
1354 1389 page(str)
1355 1390 return snip
1356 1391
1357 1392 #****************************************************************************
1358 1393 # lists, dicts and structures
1359 1394
1360 1395 def belong(candidates,checklist):
1361 1396 """Check whether a list of items appear in a given list of options.
1362 1397
1363 1398 Returns a list of 1 and 0, one for each candidate given."""
1364 1399
1365 1400 return [x in checklist for x in candidates]
1366 1401
1367 1402 #----------------------------------------------------------------------------
1368 1403 def uniq_stable(elems):
1369 1404 """uniq_stable(elems) -> list
1370 1405
1371 1406 Return from an iterable, a list of all the unique elements in the input,
1372 1407 but maintaining the order in which they first appear.
1373 1408
1374 1409 A naive solution to this problem which just makes a dictionary with the
1375 1410 elements as keys fails to respect the stability condition, since
1376 1411 dictionaries are unsorted by nature.
1377 1412
1378 1413 Note: All elements in the input must be valid dictionary keys for this
1379 1414 routine to work, as it internally uses a dictionary for efficiency
1380 1415 reasons."""
1381 1416
1382 1417 unique = []
1383 1418 unique_dict = {}
1384 1419 for nn in elems:
1385 1420 if nn not in unique_dict:
1386 1421 unique.append(nn)
1387 1422 unique_dict[nn] = None
1388 1423 return unique
1389 1424
1390 1425 #----------------------------------------------------------------------------
1391 1426 class NLprinter:
1392 1427 """Print an arbitrarily nested list, indicating index numbers.
1393 1428
1394 1429 An instance of this class called nlprint is available and callable as a
1395 1430 function.
1396 1431
1397 1432 nlprint(list,indent=' ',sep=': ') -> prints indenting each level by 'indent'
1398 1433 and using 'sep' to separate the index from the value. """
1399 1434
1400 1435 def __init__(self):
1401 1436 self.depth = 0
1402 1437
1403 1438 def __call__(self,lst,pos='',**kw):
1404 1439 """Prints the nested list numbering levels."""
1405 1440 kw.setdefault('indent',' ')
1406 1441 kw.setdefault('sep',': ')
1407 1442 kw.setdefault('start',0)
1408 1443 kw.setdefault('stop',len(lst))
1409 1444 # we need to remove start and stop from kw so they don't propagate
1410 1445 # into a recursive call for a nested list.
1411 1446 start = kw['start']; del kw['start']
1412 1447 stop = kw['stop']; del kw['stop']
1413 1448 if self.depth == 0 and 'header' in kw.keys():
1414 1449 print kw['header']
1415 1450
1416 1451 for idx in range(start,stop):
1417 1452 elem = lst[idx]
1418 1453 if type(elem)==type([]):
1419 1454 self.depth += 1
1420 1455 self.__call__(elem,itpl('$pos$idx,'),**kw)
1421 1456 self.depth -= 1
1422 1457 else:
1423 1458 printpl(kw['indent']*self.depth+'$pos$idx$kw["sep"]$elem')
1424 1459
1425 1460 nlprint = NLprinter()
1426 1461 #----------------------------------------------------------------------------
1427 1462 def all_belong(candidates,checklist):
1428 1463 """Check whether a list of items ALL appear in a given list of options.
1429 1464
1430 1465 Returns a single 1 or 0 value."""
1431 1466
1432 1467 return 1-(0 in [x in checklist for x in candidates])
1433 1468
1434 1469 #----------------------------------------------------------------------------
1435 1470 def sort_compare(lst1,lst2,inplace = 1):
1436 1471 """Sort and compare two lists.
1437 1472
1438 1473 By default it does it in place, thus modifying the lists. Use inplace = 0
1439 1474 to avoid that (at the cost of temporary copy creation)."""
1440 1475 if not inplace:
1441 1476 lst1 = lst1[:]
1442 1477 lst2 = lst2[:]
1443 1478 lst1.sort(); lst2.sort()
1444 1479 return lst1 == lst2
1445 1480
1446 1481 #----------------------------------------------------------------------------
1447 1482 def mkdict(**kwargs):
1448 1483 """Return a dict from a keyword list.
1449 1484
1450 1485 It's just syntactic sugar for making ditcionary creation more convenient:
1451 1486 # the standard way
1452 1487 >>>data = { 'red' : 1, 'green' : 2, 'blue' : 3 }
1453 1488 # a cleaner way
1454 1489 >>>data = dict(red=1, green=2, blue=3)
1455 1490
1456 1491 If you need more than this, look at the Struct() class."""
1457 1492
1458 1493 return kwargs
1459 1494
1460 1495 #----------------------------------------------------------------------------
1461 1496 def list2dict(lst):
1462 1497 """Takes a list of (key,value) pairs and turns it into a dict."""
1463 1498
1464 1499 dic = {}
1465 1500 for k,v in lst: dic[k] = v
1466 1501 return dic
1467 1502
1468 1503 #----------------------------------------------------------------------------
1469 1504 def list2dict2(lst,default=''):
1470 1505 """Takes a list and turns it into a dict.
1471 1506 Much slower than list2dict, but more versatile. This version can take
1472 1507 lists with sublists of arbitrary length (including sclars)."""
1473 1508
1474 1509 dic = {}
1475 1510 for elem in lst:
1476 1511 if type(elem) in (types.ListType,types.TupleType):
1477 1512 size = len(elem)
1478 1513 if size == 0:
1479 1514 pass
1480 1515 elif size == 1:
1481 1516 dic[elem] = default
1482 1517 else:
1483 1518 k,v = elem[0], elem[1:]
1484 1519 if len(v) == 1: v = v[0]
1485 1520 dic[k] = v
1486 1521 else:
1487 1522 dic[elem] = default
1488 1523 return dic
1489 1524
1490 1525 #----------------------------------------------------------------------------
1491 1526 def flatten(seq):
1492 1527 """Flatten a list of lists (NOT recursive, only works for 2d lists)."""
1493 1528
1494 1529 # bug in python??? (YES. Fixed in 2.2, let's leave the kludgy fix in).
1495 1530
1496 1531 # if the x=0 isn't made, a *global* variable x is left over after calling
1497 1532 # this function, with the value of the last element in the return
1498 1533 # list. This does seem like a bug big time to me.
1499 1534
1500 1535 # the problem is fixed with the x=0, which seems to force the creation of
1501 1536 # a local name
1502 1537
1503 1538 x = 0
1504 1539 return [x for subseq in seq for x in subseq]
1505 1540
1506 1541 #----------------------------------------------------------------------------
1507 1542 def get_slice(seq,start=0,stop=None,step=1):
1508 1543 """Get a slice of a sequence with variable step. Specify start,stop,step."""
1509 1544 if stop == None:
1510 1545 stop = len(seq)
1511 1546 item = lambda i: seq[i]
1512 1547 return map(item,xrange(start,stop,step))
1513 1548
1514 1549 #----------------------------------------------------------------------------
1515 1550 def chop(seq,size):
1516 1551 """Chop a sequence into chunks of the given size."""
1517 1552 chunk = lambda i: seq[i:i+size]
1518 1553 return map(chunk,xrange(0,len(seq),size))
1519 1554
1520 1555 #----------------------------------------------------------------------------
1521 1556 def with(object, **args):
1522 1557 """Set multiple attributes for an object, similar to Pascal's with.
1523 1558
1524 1559 Example:
1525 1560 with(jim,
1526 1561 born = 1960,
1527 1562 haircolour = 'Brown',
1528 1563 eyecolour = 'Green')
1529 1564
1530 1565 Credit: Greg Ewing, in
1531 1566 http://mail.python.org/pipermail/python-list/2001-May/040703.html"""
1532 1567
1533 1568 object.__dict__.update(args)
1534 1569
1535 1570 #----------------------------------------------------------------------------
1536 1571 def setattr_list(obj,alist,nspace = None):
1537 1572 """Set a list of attributes for an object taken from a namespace.
1538 1573
1539 1574 setattr_list(obj,alist,nspace) -> sets in obj all the attributes listed in
1540 1575 alist with their values taken from nspace, which must be a dict (something
1541 1576 like locals() will often do) If nspace isn't given, locals() of the
1542 1577 *caller* is used, so in most cases you can omit it.
1543 1578
1544 1579 Note that alist can be given as a string, which will be automatically
1545 1580 split into a list on whitespace. If given as a list, it must be a list of
1546 1581 *strings* (the variable names themselves), not of variables."""
1547 1582
1548 1583 # this grabs the local variables from the *previous* call frame -- that is
1549 1584 # the locals from the function that called setattr_list().
1550 1585 # - snipped from weave.inline()
1551 1586 if nspace is None:
1552 1587 call_frame = sys._getframe().f_back
1553 1588 nspace = call_frame.f_locals
1554 1589
1555 1590 if type(alist) in StringTypes:
1556 1591 alist = alist.split()
1557 1592 for attr in alist:
1558 1593 val = eval(attr,nspace)
1559 1594 setattr(obj,attr,val)
1560 1595
1561 1596 #----------------------------------------------------------------------------
1562 1597 def getattr_list(obj,alist,*args):
1563 1598 """getattr_list(obj,alist[, default]) -> attribute list.
1564 1599
1565 1600 Get a list of named attributes for an object. When a default argument is
1566 1601 given, it is returned when the attribute doesn't exist; without it, an
1567 1602 exception is raised in that case.
1568 1603
1569 1604 Note that alist can be given as a string, which will be automatically
1570 1605 split into a list on whitespace. If given as a list, it must be a list of
1571 1606 *strings* (the variable names themselves), not of variables."""
1572 1607
1573 1608 if type(alist) in StringTypes:
1574 1609 alist = alist.split()
1575 1610 if args:
1576 1611 if len(args)==1:
1577 1612 default = args[0]
1578 1613 return map(lambda attr: getattr(obj,attr,default),alist)
1579 1614 else:
1580 1615 raise ValueError,'getattr_list() takes only one optional argument'
1581 1616 else:
1582 1617 return map(lambda attr: getattr(obj,attr),alist)
1583 1618
1584 1619 #----------------------------------------------------------------------------
1585 1620 def map_method(method,object_list,*argseq,**kw):
1586 1621 """map_method(method,object_list,*args,**kw) -> list
1587 1622
1588 1623 Return a list of the results of applying the methods to the items of the
1589 1624 argument sequence(s). If more than one sequence is given, the method is
1590 1625 called with an argument list consisting of the corresponding item of each
1591 1626 sequence. All sequences must be of the same length.
1592 1627
1593 1628 Keyword arguments are passed verbatim to all objects called.
1594 1629
1595 1630 This is Python code, so it's not nearly as fast as the builtin map()."""
1596 1631
1597 1632 out_list = []
1598 1633 idx = 0
1599 1634 for object in object_list:
1600 1635 try:
1601 1636 handler = getattr(object, method)
1602 1637 except AttributeError:
1603 1638 out_list.append(None)
1604 1639 else:
1605 1640 if argseq:
1606 1641 args = map(lambda lst:lst[idx],argseq)
1607 1642 #print 'ob',object,'hand',handler,'ar',args # dbg
1608 1643 out_list.append(handler(args,**kw))
1609 1644 else:
1610 1645 out_list.append(handler(**kw))
1611 1646 idx += 1
1612 1647 return out_list
1613 1648
1614 1649 #----------------------------------------------------------------------------
1615 1650 def import_fail_info(mod_name,fns=None):
1616 1651 """Inform load failure for a module."""
1617 1652
1618 1653 if fns == None:
1619 1654 warn("Loading of %s failed.\n" % (mod_name,))
1620 1655 else:
1621 1656 warn("Loading of %s from %s failed.\n" % (fns,mod_name))
1622 1657
1623 1658 #----------------------------------------------------------------------------
1624 1659 # Proposed popitem() extension, written as a method
1625 1660
1626 1661 class NotGiven: pass
1627 1662
1628 1663 def popkey(dct,key,default=NotGiven):
1629 1664 """Return dct[key] and delete dct[key].
1630 1665
1631 1666 If default is given, return it if dct[key] doesn't exist, otherwise raise
1632 1667 KeyError. """
1633 1668
1634 1669 try:
1635 1670 val = dct[key]
1636 1671 except KeyError:
1637 1672 if default is NotGiven:
1638 1673 raise
1639 1674 else:
1640 1675 return default
1641 1676 else:
1642 1677 del dct[key]
1643 1678 return val
1644 1679 #*************************** end of file <genutils.py> **********************
1645 1680
@@ -1,4631 +1,4635 b''
1 1 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
2 2
3 * IPython/winconsole.py (get_console_size): add new winconsole
4 module and fixes to page_dumb() to improve its behavior under
5 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
6
3 7 * IPython/Magic.py (Macro): simplified Macro class to just
4 8 subclass list. We've had only 2.2 compatibility for a very long
5 9 time, yet I was still avoiding subclassing the builtin types. No
6 10 more (I'm also starting to use properties, though I won't shift to
7 11 2.3-specific features quite yet).
8 12 (magic_store): added Ville's patch for lightweight variable
9 13 persistence, after a request on the user list by Matt Wilkie
10 <maphew at gmail.com>. The new %store magic's docstring has full
14 <maphew-AT-gmail.com>. The new %store magic's docstring has full
11 15 details.
12 16
13 17 * IPython/iplib.py (InteractiveShell.post_config_initialization):
14 18 changed the default logfile name from 'ipython.log' to
15 19 'ipython_log.py'. These logs are real python files, and now that
16 20 we have much better multiline support, people are more likely to
17 21 want to use them as such. Might as well name them correctly.
18 22
19 23 * IPython/Magic.py: substantial cleanup. While we can't stop
20 24 using magics as mixins, due to the existing customizations 'out
21 25 there' which rely on the mixin naming conventions, at least I
22 26 cleaned out all cross-class name usage. So once we are OK with
23 27 breaking compatibility, the two systems can be separated.
24 28
25 29 * IPython/Logger.py: major cleanup. This one is NOT a mixin
26 30 anymore, and the class is a fair bit less hideous as well. New
27 31 features were also introduced: timestamping of input, and logging
28 32 of output results. These are user-visible with the -t and -o
29 33 options to %logstart. Closes
30 34 http://www.scipy.net/roundup/ipython/issue11 and a request by
31 35 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
32 36
33 37 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
34 38
35 39 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
36 40 better hadnle backslashes in paths. See the thread 'More Windows
37 41 questions part 2 - \/ characters revisited' on the iypthon user
38 42 list:
39 43 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
40 44
41 45 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
42 46
43 47 (InteractiveShell.__init__): change threaded shells to not use the
44 48 ipython crash handler. This was causing more problems than not,
45 49 as exceptions in the main thread (GUI code, typically) would
46 50 always show up as a 'crash', when they really weren't.
47 51
48 52 The colors and exception mode commands (%colors/%xmode) have been
49 53 synchronized to also take this into account, so users can get
50 54 verbose exceptions for their threaded code as well. I also added
51 55 support for activating pdb inside this exception handler as well,
52 56 so now GUI authors can use IPython's enhanced pdb at runtime.
53 57
54 58 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
55 59 true by default, and add it to the shipped ipythonrc file. Since
56 60 this asks the user before proceeding, I think it's OK to make it
57 61 true by default.
58 62
59 63 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
60 64 of the previous special-casing of input in the eval loop. I think
61 65 this is cleaner, as they really are commands and shouldn't have
62 66 a special role in the middle of the core code.
63 67
64 68 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
65 69
66 70 * IPython/iplib.py (edit_syntax_error): added support for
67 71 automatically reopening the editor if the file had a syntax error
68 72 in it. Thanks to scottt who provided the patch at:
69 73 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
70 74 version committed).
71 75
72 76 * IPython/iplib.py (handle_normal): add suport for multi-line
73 77 input with emtpy lines. This fixes
74 78 http://www.scipy.net/roundup/ipython/issue43 and a similar
75 79 discussion on the user list.
76 80
77 81 WARNING: a behavior change is necessarily introduced to support
78 82 blank lines: now a single blank line with whitespace does NOT
79 83 break the input loop, which means that when autoindent is on, by
80 84 default hitting return on the next (indented) line does NOT exit.
81 85
82 86 Instead, to exit a multiline input you can either have:
83 87
84 88 - TWO whitespace lines (just hit return again), or
85 89 - a single whitespace line of a different length than provided
86 90 by the autoindent (add or remove a space).
87 91
88 92 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
89 93 module to better organize all readline-related functionality.
90 94 I've deleted FlexCompleter and put all completion clases here.
91 95
92 96 * IPython/iplib.py (raw_input): improve indentation management.
93 97 It is now possible to paste indented code with autoindent on, and
94 98 the code is interpreted correctly (though it still looks bad on
95 99 screen, due to the line-oriented nature of ipython).
96 100 (MagicCompleter.complete): change behavior so that a TAB key on an
97 101 otherwise empty line actually inserts a tab, instead of completing
98 102 on the entire global namespace. This makes it easier to use the
99 103 TAB key for indentation. After a request by Hans Meine
100 104 <hans_meine-AT-gmx.net>
101 105 (_prefilter): add support so that typing plain 'exit' or 'quit'
102 106 does a sensible thing. Originally I tried to deviate as little as
103 107 possible from the default python behavior, but even that one may
104 108 change in this direction (thread on python-dev to that effect).
105 109 Regardless, ipython should do the right thing even if CPython's
106 110 '>>>' prompt doesn't.
107 111 (InteractiveShell): removed subclassing code.InteractiveConsole
108 112 class. By now we'd overridden just about all of its methods: I've
109 113 copied the remaining two over, and now ipython is a standalone
110 114 class. This will provide a clearer picture for the chainsaw
111 115 branch refactoring.
112 116
113 117 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
114 118
115 119 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
116 120 failures for objects which break when dir() is called on them.
117 121
118 122 * IPython/FlexCompleter.py (Completer.__init__): Added support for
119 123 distinct local and global namespaces in the completer API. This
120 124 change allows us top properly handle completion with distinct
121 125 scopes, including in embedded instances (this had never really
122 126 worked correctly).
123 127
124 128 Note: this introduces a change in the constructor for
125 129 MagicCompleter, as a new global_namespace parameter is now the
126 130 second argument (the others were bumped one position).
127 131
128 132 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
129 133
130 134 * IPython/iplib.py (embed_mainloop): fix tab-completion in
131 135 embedded instances (which can be done now thanks to Vivian's
132 136 frame-handling fixes for pdb).
133 137 (InteractiveShell.__init__): Fix namespace handling problem in
134 138 embedded instances. We were overwriting __main__ unconditionally,
135 139 and this should only be done for 'full' (non-embedded) IPython;
136 140 embedded instances must respect the caller's __main__. Thanks to
137 141 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
138 142
139 143 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
140 144
141 145 * setup.py: added download_url to setup(). This registers the
142 146 download address at PyPI, which is not only useful to humans
143 147 browsing the site, but is also picked up by setuptools (the Eggs
144 148 machinery). Thanks to Ville and R. Kern for the info/discussion
145 149 on this.
146 150
147 151 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
148 152
149 153 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
150 154 This brings a lot of nice functionality to the pdb mode, which now
151 155 has tab-completion, syntax highlighting, and better stack handling
152 156 than before. Many thanks to Vivian De Smedt
153 157 <vivian-AT-vdesmedt.com> for the original patches.
154 158
155 159 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
156 160
157 161 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
158 162 sequence to consistently accept the banner argument. The
159 163 inconsistency was tripping SAGE, thanks to Gary Zablackis
160 164 <gzabl-AT-yahoo.com> for the report.
161 165
162 166 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
163 167
164 168 * IPython/iplib.py (InteractiveShell.post_config_initialization):
165 169 Fix bug where a naked 'alias' call in the ipythonrc file would
166 170 cause a crash. Bug reported by Jorgen Stenarson.
167 171
168 172 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
169 173
170 174 * IPython/ipmaker.py (make_IPython): cleanups which should improve
171 175 startup time.
172 176
173 177 * IPython/iplib.py (runcode): my globals 'fix' for embedded
174 178 instances had introduced a bug with globals in normal code. Now
175 179 it's working in all cases.
176 180
177 181 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
178 182 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
179 183 has been introduced to set the default case sensitivity of the
180 184 searches. Users can still select either mode at runtime on a
181 185 per-search basis.
182 186
183 187 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
184 188
185 189 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
186 190 attributes in wildcard searches for subclasses. Modified version
187 191 of a patch by Jorgen.
188 192
189 193 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
190 194
191 195 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
192 196 embedded instances. I added a user_global_ns attribute to the
193 197 InteractiveShell class to handle this.
194 198
195 199 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
196 200
197 201 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
198 202 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
199 203 (reported under win32, but may happen also in other platforms).
200 204 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
201 205
202 206 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
203 207
204 208 * IPython/Magic.py (magic_psearch): new support for wildcard
205 209 patterns. Now, typing ?a*b will list all names which begin with a
206 210 and end in b, for example. The %psearch magic has full
207 211 docstrings. Many thanks to Jörgen Stenarson
208 212 <jorgen.stenarson-AT-bostream.nu>, author of the patches
209 213 implementing this functionality.
210 214
211 215 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
212 216
213 217 * Manual: fixed long-standing annoyance of double-dashes (as in
214 218 --prefix=~, for example) being stripped in the HTML version. This
215 219 is a latex2html bug, but a workaround was provided. Many thanks
216 220 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
217 221 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
218 222 rolling. This seemingly small issue had tripped a number of users
219 223 when first installing, so I'm glad to see it gone.
220 224
221 225 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
222 226
223 227 * IPython/Extensions/numeric_formats.py: fix missing import,
224 228 reported by Stephen Walton.
225 229
226 230 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
227 231
228 232 * IPython/demo.py: finish demo module, fully documented now.
229 233
230 234 * IPython/genutils.py (file_read): simple little utility to read a
231 235 file and ensure it's closed afterwards.
232 236
233 237 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
234 238
235 239 * IPython/demo.py (Demo.__init__): added support for individually
236 240 tagging blocks for automatic execution.
237 241
238 242 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
239 243 syntax-highlighted python sources, requested by John.
240 244
241 245 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
242 246
243 247 * IPython/demo.py (Demo.again): fix bug where again() blocks after
244 248 finishing.
245 249
246 250 * IPython/genutils.py (shlex_split): moved from Magic to here,
247 251 where all 2.2 compatibility stuff lives. I needed it for demo.py.
248 252
249 253 * IPython/demo.py (Demo.__init__): added support for silent
250 254 blocks, improved marks as regexps, docstrings written.
251 255 (Demo.__init__): better docstring, added support for sys.argv.
252 256
253 257 * IPython/genutils.py (marquee): little utility used by the demo
254 258 code, handy in general.
255 259
256 260 * IPython/demo.py (Demo.__init__): new class for interactive
257 261 demos. Not documented yet, I just wrote it in a hurry for
258 262 scipy'05. Will docstring later.
259 263
260 264 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
261 265
262 266 * IPython/Shell.py (sigint_handler): Drastic simplification which
263 267 also seems to make Ctrl-C work correctly across threads! This is
264 268 so simple, that I can't beleive I'd missed it before. Needs more
265 269 testing, though.
266 270 (KBINT): Never mind, revert changes. I'm sure I'd tried something
267 271 like this before...
268 272
269 273 * IPython/genutils.py (get_home_dir): add protection against
270 274 non-dirs in win32 registry.
271 275
272 276 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
273 277 bug where dict was mutated while iterating (pysh crash).
274 278
275 279 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
276 280
277 281 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
278 282 spurious newlines added by this routine. After a report by
279 283 F. Mantegazza.
280 284
281 285 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
282 286
283 287 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
284 288 calls. These were a leftover from the GTK 1.x days, and can cause
285 289 problems in certain cases (after a report by John Hunter).
286 290
287 291 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
288 292 os.getcwd() fails at init time. Thanks to patch from David Remahl
289 293 <chmod007-AT-mac.com>.
290 294 (InteractiveShell.__init__): prevent certain special magics from
291 295 being shadowed by aliases. Closes
292 296 http://www.scipy.net/roundup/ipython/issue41.
293 297
294 298 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
295 299
296 300 * IPython/iplib.py (InteractiveShell.complete): Added new
297 301 top-level completion method to expose the completion mechanism
298 302 beyond readline-based environments.
299 303
300 304 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
301 305
302 306 * tools/ipsvnc (svnversion): fix svnversion capture.
303 307
304 308 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
305 309 attribute to self, which was missing. Before, it was set by a
306 310 routine which in certain cases wasn't being called, so the
307 311 instance could end up missing the attribute. This caused a crash.
308 312 Closes http://www.scipy.net/roundup/ipython/issue40.
309 313
310 314 2005-08-16 Fernando Perez <fperez@colorado.edu>
311 315
312 316 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
313 317 contains non-string attribute. Closes
314 318 http://www.scipy.net/roundup/ipython/issue38.
315 319
316 320 2005-08-14 Fernando Perez <fperez@colorado.edu>
317 321
318 322 * tools/ipsvnc: Minor improvements, to add changeset info.
319 323
320 324 2005-08-12 Fernando Perez <fperez@colorado.edu>
321 325
322 326 * IPython/iplib.py (runsource): remove self.code_to_run_src
323 327 attribute. I realized this is nothing more than
324 328 '\n'.join(self.buffer), and having the same data in two different
325 329 places is just asking for synchronization bugs. This may impact
326 330 people who have custom exception handlers, so I need to warn
327 331 ipython-dev about it (F. Mantegazza may use them).
328 332
329 333 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
330 334
331 335 * IPython/genutils.py: fix 2.2 compatibility (generators)
332 336
333 337 2005-07-18 Fernando Perez <fperez@colorado.edu>
334 338
335 339 * IPython/genutils.py (get_home_dir): fix to help users with
336 340 invalid $HOME under win32.
337 341
338 342 2005-07-17 Fernando Perez <fperez@colorado.edu>
339 343
340 344 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
341 345 some old hacks and clean up a bit other routines; code should be
342 346 simpler and a bit faster.
343 347
344 348 * IPython/iplib.py (interact): removed some last-resort attempts
345 349 to survive broken stdout/stderr. That code was only making it
346 350 harder to abstract out the i/o (necessary for gui integration),
347 351 and the crashes it could prevent were extremely rare in practice
348 352 (besides being fully user-induced in a pretty violent manner).
349 353
350 354 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
351 355 Nothing major yet, but the code is simpler to read; this should
352 356 make it easier to do more serious modifications in the future.
353 357
354 358 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
355 359 which broke in .15 (thanks to a report by Ville).
356 360
357 361 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
358 362 be quite correct, I know next to nothing about unicode). This
359 363 will allow unicode strings to be used in prompts, amongst other
360 364 cases. It also will prevent ipython from crashing when unicode
361 365 shows up unexpectedly in many places. If ascii encoding fails, we
362 366 assume utf_8. Currently the encoding is not a user-visible
363 367 setting, though it could be made so if there is demand for it.
364 368
365 369 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
366 370
367 371 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
368 372
369 373 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
370 374
371 375 * IPython/genutils.py: Add 2.2 compatibility here, so all other
372 376 code can work transparently for 2.2/2.3.
373 377
374 378 2005-07-16 Fernando Perez <fperez@colorado.edu>
375 379
376 380 * IPython/ultraTB.py (ExceptionColors): Make a global variable
377 381 out of the color scheme table used for coloring exception
378 382 tracebacks. This allows user code to add new schemes at runtime.
379 383 This is a minimally modified version of the patch at
380 384 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
381 385 for the contribution.
382 386
383 387 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
384 388 slightly modified version of the patch in
385 389 http://www.scipy.net/roundup/ipython/issue34, which also allows me
386 390 to remove the previous try/except solution (which was costlier).
387 391 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
388 392
389 393 2005-06-08 Fernando Perez <fperez@colorado.edu>
390 394
391 395 * IPython/iplib.py (write/write_err): Add methods to abstract all
392 396 I/O a bit more.
393 397
394 398 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
395 399 warning, reported by Aric Hagberg, fix by JD Hunter.
396 400
397 401 2005-06-02 *** Released version 0.6.15
398 402
399 403 2005-06-01 Fernando Perez <fperez@colorado.edu>
400 404
401 405 * IPython/iplib.py (MagicCompleter.file_matches): Fix
402 406 tab-completion of filenames within open-quoted strings. Note that
403 407 this requires that in ~/.ipython/ipythonrc, users change the
404 408 readline delimiters configuration to read:
405 409
406 410 readline_remove_delims -/~
407 411
408 412
409 413 2005-05-31 *** Released version 0.6.14
410 414
411 415 2005-05-29 Fernando Perez <fperez@colorado.edu>
412 416
413 417 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
414 418 with files not on the filesystem. Reported by Eliyahu Sandler
415 419 <eli@gondolin.net>
416 420
417 421 2005-05-22 Fernando Perez <fperez@colorado.edu>
418 422
419 423 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
420 424 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
421 425
422 426 2005-05-19 Fernando Perez <fperez@colorado.edu>
423 427
424 428 * IPython/iplib.py (safe_execfile): close a file which could be
425 429 left open (causing problems in win32, which locks open files).
426 430 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
427 431
428 432 2005-05-18 Fernando Perez <fperez@colorado.edu>
429 433
430 434 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
431 435 keyword arguments correctly to safe_execfile().
432 436
433 437 2005-05-13 Fernando Perez <fperez@colorado.edu>
434 438
435 439 * ipython.1: Added info about Qt to manpage, and threads warning
436 440 to usage page (invoked with --help).
437 441
438 442 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
439 443 new matcher (it goes at the end of the priority list) to do
440 444 tab-completion on named function arguments. Submitted by George
441 445 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
442 446 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
443 447 for more details.
444 448
445 449 * IPython/Magic.py (magic_run): Added new -e flag to ignore
446 450 SystemExit exceptions in the script being run. Thanks to a report
447 451 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
448 452 producing very annoying behavior when running unit tests.
449 453
450 454 2005-05-12 Fernando Perez <fperez@colorado.edu>
451 455
452 456 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
453 457 which I'd broken (again) due to a changed regexp. In the process,
454 458 added ';' as an escape to auto-quote the whole line without
455 459 splitting its arguments. Thanks to a report by Jerry McRae
456 460 <qrs0xyc02-AT-sneakemail.com>.
457 461
458 462 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
459 463 possible crashes caused by a TokenError. Reported by Ed Schofield
460 464 <schofield-AT-ftw.at>.
461 465
462 466 2005-05-06 Fernando Perez <fperez@colorado.edu>
463 467
464 468 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
465 469
466 470 2005-04-29 Fernando Perez <fperez@colorado.edu>
467 471
468 472 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
469 473 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
470 474 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
471 475 which provides support for Qt interactive usage (similar to the
472 476 existing one for WX and GTK). This had been often requested.
473 477
474 478 2005-04-14 *** Released version 0.6.13
475 479
476 480 2005-04-08 Fernando Perez <fperez@colorado.edu>
477 481
478 482 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
479 483 from _ofind, which gets called on almost every input line. Now,
480 484 we only try to get docstrings if they are actually going to be
481 485 used (the overhead of fetching unnecessary docstrings can be
482 486 noticeable for certain objects, such as Pyro proxies).
483 487
484 488 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
485 489 for completers. For some reason I had been passing them the state
486 490 variable, which completers never actually need, and was in
487 491 conflict with the rlcompleter API. Custom completers ONLY need to
488 492 take the text parameter.
489 493
490 494 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
491 495 work correctly in pysh. I've also moved all the logic which used
492 496 to be in pysh.py here, which will prevent problems with future
493 497 upgrades. However, this time I must warn users to update their
494 498 pysh profile to include the line
495 499
496 500 import_all IPython.Extensions.InterpreterExec
497 501
498 502 because otherwise things won't work for them. They MUST also
499 503 delete pysh.py and the line
500 504
501 505 execfile pysh.py
502 506
503 507 from their ipythonrc-pysh.
504 508
505 509 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
506 510 robust in the face of objects whose dir() returns non-strings
507 511 (which it shouldn't, but some broken libs like ITK do). Thanks to
508 512 a patch by John Hunter (implemented differently, though). Also
509 513 minor improvements by using .extend instead of + on lists.
510 514
511 515 * pysh.py:
512 516
513 517 2005-04-06 Fernando Perez <fperez@colorado.edu>
514 518
515 519 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
516 520 by default, so that all users benefit from it. Those who don't
517 521 want it can still turn it off.
518 522
519 523 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
520 524 config file, I'd forgotten about this, so users were getting it
521 525 off by default.
522 526
523 527 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
524 528 consistency. Now magics can be called in multiline statements,
525 529 and python variables can be expanded in magic calls via $var.
526 530 This makes the magic system behave just like aliases or !system
527 531 calls.
528 532
529 533 2005-03-28 Fernando Perez <fperez@colorado.edu>
530 534
531 535 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
532 536 expensive string additions for building command. Add support for
533 537 trailing ';' when autocall is used.
534 538
535 539 2005-03-26 Fernando Perez <fperez@colorado.edu>
536 540
537 541 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
538 542 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
539 543 ipython.el robust against prompts with any number of spaces
540 544 (including 0) after the ':' character.
541 545
542 546 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
543 547 continuation prompt, which misled users to think the line was
544 548 already indented. Closes debian Bug#300847, reported to me by
545 549 Norbert Tretkowski <tretkowski-AT-inittab.de>.
546 550
547 551 2005-03-23 Fernando Perez <fperez@colorado.edu>
548 552
549 553 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
550 554 properly aligned if they have embedded newlines.
551 555
552 556 * IPython/iplib.py (runlines): Add a public method to expose
553 557 IPython's code execution machinery, so that users can run strings
554 558 as if they had been typed at the prompt interactively.
555 559 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
556 560 methods which can call the system shell, but with python variable
557 561 expansion. The three such methods are: __IPYTHON__.system,
558 562 .getoutput and .getoutputerror. These need to be documented in a
559 563 'public API' section (to be written) of the manual.
560 564
561 565 2005-03-20 Fernando Perez <fperez@colorado.edu>
562 566
563 567 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
564 568 for custom exception handling. This is quite powerful, and it
565 569 allows for user-installable exception handlers which can trap
566 570 custom exceptions at runtime and treat them separately from
567 571 IPython's default mechanisms. At the request of Frédéric
568 572 Mantegazza <mantegazza-AT-ill.fr>.
569 573 (InteractiveShell.set_custom_completer): public API function to
570 574 add new completers at runtime.
571 575
572 576 2005-03-19 Fernando Perez <fperez@colorado.edu>
573 577
574 578 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
575 579 allow objects which provide their docstrings via non-standard
576 580 mechanisms (like Pyro proxies) to still be inspected by ipython's
577 581 ? system.
578 582
579 583 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
580 584 automatic capture system. I tried quite hard to make it work
581 585 reliably, and simply failed. I tried many combinations with the
582 586 subprocess module, but eventually nothing worked in all needed
583 587 cases (not blocking stdin for the child, duplicating stdout
584 588 without blocking, etc). The new %sc/%sx still do capture to these
585 589 magical list/string objects which make shell use much more
586 590 conveninent, so not all is lost.
587 591
588 592 XXX - FIX MANUAL for the change above!
589 593
590 594 (runsource): I copied code.py's runsource() into ipython to modify
591 595 it a bit. Now the code object and source to be executed are
592 596 stored in ipython. This makes this info accessible to third-party
593 597 tools, like custom exception handlers. After a request by Frédéric
594 598 Mantegazza <mantegazza-AT-ill.fr>.
595 599
596 600 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
597 601 history-search via readline (like C-p/C-n). I'd wanted this for a
598 602 long time, but only recently found out how to do it. For users
599 603 who already have their ipythonrc files made and want this, just
600 604 add:
601 605
602 606 readline_parse_and_bind "\e[A": history-search-backward
603 607 readline_parse_and_bind "\e[B": history-search-forward
604 608
605 609 2005-03-18 Fernando Perez <fperez@colorado.edu>
606 610
607 611 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
608 612 LSString and SList classes which allow transparent conversions
609 613 between list mode and whitespace-separated string.
610 614 (magic_r): Fix recursion problem in %r.
611 615
612 616 * IPython/genutils.py (LSString): New class to be used for
613 617 automatic storage of the results of all alias/system calls in _o
614 618 and _e (stdout/err). These provide a .l/.list attribute which
615 619 does automatic splitting on newlines. This means that for most
616 620 uses, you'll never need to do capturing of output with %sc/%sx
617 621 anymore, since ipython keeps this always done for you. Note that
618 622 only the LAST results are stored, the _o/e variables are
619 623 overwritten on each call. If you need to save their contents
620 624 further, simply bind them to any other name.
621 625
622 626 2005-03-17 Fernando Perez <fperez@colorado.edu>
623 627
624 628 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
625 629 prompt namespace handling.
626 630
627 631 2005-03-16 Fernando Perez <fperez@colorado.edu>
628 632
629 633 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
630 634 classic prompts to be '>>> ' (final space was missing, and it
631 635 trips the emacs python mode).
632 636 (BasePrompt.__str__): Added safe support for dynamic prompt
633 637 strings. Now you can set your prompt string to be '$x', and the
634 638 value of x will be printed from your interactive namespace. The
635 639 interpolation syntax includes the full Itpl support, so
636 640 ${foo()+x+bar()} is a valid prompt string now, and the function
637 641 calls will be made at runtime.
638 642
639 643 2005-03-15 Fernando Perez <fperez@colorado.edu>
640 644
641 645 * IPython/Magic.py (magic_history): renamed %hist to %history, to
642 646 avoid name clashes in pylab. %hist still works, it just forwards
643 647 the call to %history.
644 648
645 649 2005-03-02 *** Released version 0.6.12
646 650
647 651 2005-03-02 Fernando Perez <fperez@colorado.edu>
648 652
649 653 * IPython/iplib.py (handle_magic): log magic calls properly as
650 654 ipmagic() function calls.
651 655
652 656 * IPython/Magic.py (magic_time): Improved %time to support
653 657 statements and provide wall-clock as well as CPU time.
654 658
655 659 2005-02-27 Fernando Perez <fperez@colorado.edu>
656 660
657 661 * IPython/hooks.py: New hooks module, to expose user-modifiable
658 662 IPython functionality in a clean manner. For now only the editor
659 663 hook is actually written, and other thigns which I intend to turn
660 664 into proper hooks aren't yet there. The display and prefilter
661 665 stuff, for example, should be hooks. But at least now the
662 666 framework is in place, and the rest can be moved here with more
663 667 time later. IPython had had a .hooks variable for a long time for
664 668 this purpose, but I'd never actually used it for anything.
665 669
666 670 2005-02-26 Fernando Perez <fperez@colorado.edu>
667 671
668 672 * IPython/ipmaker.py (make_IPython): make the default ipython
669 673 directory be called _ipython under win32, to follow more the
670 674 naming peculiarities of that platform (where buggy software like
671 675 Visual Sourcesafe breaks with .named directories). Reported by
672 676 Ville Vainio.
673 677
674 678 2005-02-23 Fernando Perez <fperez@colorado.edu>
675 679
676 680 * IPython/iplib.py (InteractiveShell.__init__): removed a few
677 681 auto_aliases for win32 which were causing problems. Users can
678 682 define the ones they personally like.
679 683
680 684 2005-02-21 Fernando Perez <fperez@colorado.edu>
681 685
682 686 * IPython/Magic.py (magic_time): new magic to time execution of
683 687 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
684 688
685 689 2005-02-19 Fernando Perez <fperez@colorado.edu>
686 690
687 691 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
688 692 into keys (for prompts, for example).
689 693
690 694 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
691 695 prompts in case users want them. This introduces a small behavior
692 696 change: ipython does not automatically add a space to all prompts
693 697 anymore. To get the old prompts with a space, users should add it
694 698 manually to their ipythonrc file, so for example prompt_in1 should
695 699 now read 'In [\#]: ' instead of 'In [\#]:'.
696 700 (BasePrompt.__init__): New option prompts_pad_left (only in rc
697 701 file) to control left-padding of secondary prompts.
698 702
699 703 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
700 704 the profiler can't be imported. Fix for Debian, which removed
701 705 profile.py because of License issues. I applied a slightly
702 706 modified version of the original Debian patch at
703 707 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
704 708
705 709 2005-02-17 Fernando Perez <fperez@colorado.edu>
706 710
707 711 * IPython/genutils.py (native_line_ends): Fix bug which would
708 712 cause improper line-ends under win32 b/c I was not opening files
709 713 in binary mode. Bug report and fix thanks to Ville.
710 714
711 715 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
712 716 trying to catch spurious foo[1] autocalls. My fix actually broke
713 717 ',/' autoquote/call with explicit escape (bad regexp).
714 718
715 719 2005-02-15 *** Released version 0.6.11
716 720
717 721 2005-02-14 Fernando Perez <fperez@colorado.edu>
718 722
719 723 * IPython/background_jobs.py: New background job management
720 724 subsystem. This is implemented via a new set of classes, and
721 725 IPython now provides a builtin 'jobs' object for background job
722 726 execution. A convenience %bg magic serves as a lightweight
723 727 frontend for starting the more common type of calls. This was
724 728 inspired by discussions with B. Granger and the BackgroundCommand
725 729 class described in the book Python Scripting for Computational
726 730 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
727 731 (although ultimately no code from this text was used, as IPython's
728 732 system is a separate implementation).
729 733
730 734 * IPython/iplib.py (MagicCompleter.python_matches): add new option
731 735 to control the completion of single/double underscore names
732 736 separately. As documented in the example ipytonrc file, the
733 737 readline_omit__names variable can now be set to 2, to omit even
734 738 single underscore names. Thanks to a patch by Brian Wong
735 739 <BrianWong-AT-AirgoNetworks.Com>.
736 740 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
737 741 be autocalled as foo([1]) if foo were callable. A problem for
738 742 things which are both callable and implement __getitem__.
739 743 (init_readline): Fix autoindentation for win32. Thanks to a patch
740 744 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
741 745
742 746 2005-02-12 Fernando Perez <fperez@colorado.edu>
743 747
744 748 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
745 749 which I had written long ago to sort out user error messages which
746 750 may occur during startup. This seemed like a good idea initially,
747 751 but it has proven a disaster in retrospect. I don't want to
748 752 change much code for now, so my fix is to set the internal 'debug'
749 753 flag to true everywhere, whose only job was precisely to control
750 754 this subsystem. This closes issue 28 (as well as avoiding all
751 755 sorts of strange hangups which occur from time to time).
752 756
753 757 2005-02-07 Fernando Perez <fperez@colorado.edu>
754 758
755 759 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
756 760 previous call produced a syntax error.
757 761
758 762 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
759 763 classes without constructor.
760 764
761 765 2005-02-06 Fernando Perez <fperez@colorado.edu>
762 766
763 767 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
764 768 completions with the results of each matcher, so we return results
765 769 to the user from all namespaces. This breaks with ipython
766 770 tradition, but I think it's a nicer behavior. Now you get all
767 771 possible completions listed, from all possible namespaces (python,
768 772 filesystem, magics...) After a request by John Hunter
769 773 <jdhunter-AT-nitace.bsd.uchicago.edu>.
770 774
771 775 2005-02-05 Fernando Perez <fperez@colorado.edu>
772 776
773 777 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
774 778 the call had quote characters in it (the quotes were stripped).
775 779
776 780 2005-01-31 Fernando Perez <fperez@colorado.edu>
777 781
778 782 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
779 783 Itpl.itpl() to make the code more robust against psyco
780 784 optimizations.
781 785
782 786 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
783 787 of causing an exception. Quicker, cleaner.
784 788
785 789 2005-01-28 Fernando Perez <fperez@colorado.edu>
786 790
787 791 * scripts/ipython_win_post_install.py (install): hardcode
788 792 sys.prefix+'python.exe' as the executable path. It turns out that
789 793 during the post-installation run, sys.executable resolves to the
790 794 name of the binary installer! I should report this as a distutils
791 795 bug, I think. I updated the .10 release with this tiny fix, to
792 796 avoid annoying the lists further.
793 797
794 798 2005-01-27 *** Released version 0.6.10
795 799
796 800 2005-01-27 Fernando Perez <fperez@colorado.edu>
797 801
798 802 * IPython/numutils.py (norm): Added 'inf' as optional name for
799 803 L-infinity norm, included references to mathworld.com for vector
800 804 norm definitions.
801 805 (amin/amax): added amin/amax for array min/max. Similar to what
802 806 pylab ships with after the recent reorganization of names.
803 807 (spike/spike_odd): removed deprecated spike/spike_odd functions.
804 808
805 809 * ipython.el: committed Alex's recent fixes and improvements.
806 810 Tested with python-mode from CVS, and it looks excellent. Since
807 811 python-mode hasn't released anything in a while, I'm temporarily
808 812 putting a copy of today's CVS (v 4.70) of python-mode in:
809 813 http://ipython.scipy.org/tmp/python-mode.el
810 814
811 815 * scripts/ipython_win_post_install.py (install): Win32 fix to use
812 816 sys.executable for the executable name, instead of assuming it's
813 817 called 'python.exe' (the post-installer would have produced broken
814 818 setups on systems with a differently named python binary).
815 819
816 820 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
817 821 references to os.linesep, to make the code more
818 822 platform-independent. This is also part of the win32 coloring
819 823 fixes.
820 824
821 825 * IPython/genutils.py (page_dumb): Remove attempts to chop long
822 826 lines, which actually cause coloring bugs because the length of
823 827 the line is very difficult to correctly compute with embedded
824 828 escapes. This was the source of all the coloring problems under
825 829 Win32. I think that _finally_, Win32 users have a properly
826 830 working ipython in all respects. This would never have happened
827 831 if not for Gary Bishop and Viktor Ransmayr's great help and work.
828 832
829 833 2005-01-26 *** Released version 0.6.9
830 834
831 835 2005-01-25 Fernando Perez <fperez@colorado.edu>
832 836
833 837 * setup.py: finally, we have a true Windows installer, thanks to
834 838 the excellent work of Viktor Ransmayr
835 839 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
836 840 Windows users. The setup routine is quite a bit cleaner thanks to
837 841 this, and the post-install script uses the proper functions to
838 842 allow a clean de-installation using the standard Windows Control
839 843 Panel.
840 844
841 845 * IPython/genutils.py (get_home_dir): changed to use the $HOME
842 846 environment variable under all OSes (including win32) if
843 847 available. This will give consistency to win32 users who have set
844 848 this variable for any reason. If os.environ['HOME'] fails, the
845 849 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
846 850
847 851 2005-01-24 Fernando Perez <fperez@colorado.edu>
848 852
849 853 * IPython/numutils.py (empty_like): add empty_like(), similar to
850 854 zeros_like() but taking advantage of the new empty() Numeric routine.
851 855
852 856 2005-01-23 *** Released version 0.6.8
853 857
854 858 2005-01-22 Fernando Perez <fperez@colorado.edu>
855 859
856 860 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
857 861 automatic show() calls. After discussing things with JDH, it
858 862 turns out there are too many corner cases where this can go wrong.
859 863 It's best not to try to be 'too smart', and simply have ipython
860 864 reproduce as much as possible the default behavior of a normal
861 865 python shell.
862 866
863 867 * IPython/iplib.py (InteractiveShell.__init__): Modified the
864 868 line-splitting regexp and _prefilter() to avoid calling getattr()
865 869 on assignments. This closes
866 870 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
867 871 readline uses getattr(), so a simple <TAB> keypress is still
868 872 enough to trigger getattr() calls on an object.
869 873
870 874 2005-01-21 Fernando Perez <fperez@colorado.edu>
871 875
872 876 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
873 877 docstring under pylab so it doesn't mask the original.
874 878
875 879 2005-01-21 *** Released version 0.6.7
876 880
877 881 2005-01-21 Fernando Perez <fperez@colorado.edu>
878 882
879 883 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
880 884 signal handling for win32 users in multithreaded mode.
881 885
882 886 2005-01-17 Fernando Perez <fperez@colorado.edu>
883 887
884 888 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
885 889 instances with no __init__. After a crash report by Norbert Nemec
886 890 <Norbert-AT-nemec-online.de>.
887 891
888 892 2005-01-14 Fernando Perez <fperez@colorado.edu>
889 893
890 894 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
891 895 names for verbose exceptions, when multiple dotted names and the
892 896 'parent' object were present on the same line.
893 897
894 898 2005-01-11 Fernando Perez <fperez@colorado.edu>
895 899
896 900 * IPython/genutils.py (flag_calls): new utility to trap and flag
897 901 calls in functions. I need it to clean up matplotlib support.
898 902 Also removed some deprecated code in genutils.
899 903
900 904 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
901 905 that matplotlib scripts called with %run, which don't call show()
902 906 themselves, still have their plotting windows open.
903 907
904 908 2005-01-05 Fernando Perez <fperez@colorado.edu>
905 909
906 910 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
907 911 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
908 912
909 913 2004-12-19 Fernando Perez <fperez@colorado.edu>
910 914
911 915 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
912 916 parent_runcode, which was an eyesore. The same result can be
913 917 obtained with Python's regular superclass mechanisms.
914 918
915 919 2004-12-17 Fernando Perez <fperez@colorado.edu>
916 920
917 921 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
918 922 reported by Prabhu.
919 923 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
920 924 sys.stderr) instead of explicitly calling sys.stderr. This helps
921 925 maintain our I/O abstractions clean, for future GUI embeddings.
922 926
923 927 * IPython/genutils.py (info): added new utility for sys.stderr
924 928 unified info message handling (thin wrapper around warn()).
925 929
926 930 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
927 931 composite (dotted) names on verbose exceptions.
928 932 (VerboseTB.nullrepr): harden against another kind of errors which
929 933 Python's inspect module can trigger, and which were crashing
930 934 IPython. Thanks to a report by Marco Lombardi
931 935 <mlombard-AT-ma010192.hq.eso.org>.
932 936
933 937 2004-12-13 *** Released version 0.6.6
934 938
935 939 2004-12-12 Fernando Perez <fperez@colorado.edu>
936 940
937 941 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
938 942 generated by pygtk upon initialization if it was built without
939 943 threads (for matplotlib users). After a crash reported by
940 944 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
941 945
942 946 * IPython/ipmaker.py (make_IPython): fix small bug in the
943 947 import_some parameter for multiple imports.
944 948
945 949 * IPython/iplib.py (ipmagic): simplified the interface of
946 950 ipmagic() to take a single string argument, just as it would be
947 951 typed at the IPython cmd line.
948 952 (ipalias): Added new ipalias() with an interface identical to
949 953 ipmagic(). This completes exposing a pure python interface to the
950 954 alias and magic system, which can be used in loops or more complex
951 955 code where IPython's automatic line mangling is not active.
952 956
953 957 * IPython/genutils.py (timing): changed interface of timing to
954 958 simply run code once, which is the most common case. timings()
955 959 remains unchanged, for the cases where you want multiple runs.
956 960
957 961 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
958 962 bug where Python2.2 crashes with exec'ing code which does not end
959 963 in a single newline. Python 2.3 is OK, so I hadn't noticed this
960 964 before.
961 965
962 966 2004-12-10 Fernando Perez <fperez@colorado.edu>
963 967
964 968 * IPython/Magic.py (Magic.magic_prun): changed name of option from
965 969 -t to -T, to accomodate the new -t flag in %run (the %run and
966 970 %prun options are kind of intermixed, and it's not easy to change
967 971 this with the limitations of python's getopt).
968 972
969 973 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
970 974 the execution of scripts. It's not as fine-tuned as timeit.py,
971 975 but it works from inside ipython (and under 2.2, which lacks
972 976 timeit.py). Optionally a number of runs > 1 can be given for
973 977 timing very short-running code.
974 978
975 979 * IPython/genutils.py (uniq_stable): new routine which returns a
976 980 list of unique elements in any iterable, but in stable order of
977 981 appearance. I needed this for the ultraTB fixes, and it's a handy
978 982 utility.
979 983
980 984 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
981 985 dotted names in Verbose exceptions. This had been broken since
982 986 the very start, now x.y will properly be printed in a Verbose
983 987 traceback, instead of x being shown and y appearing always as an
984 988 'undefined global'. Getting this to work was a bit tricky,
985 989 because by default python tokenizers are stateless. Saved by
986 990 python's ability to easily add a bit of state to an arbitrary
987 991 function (without needing to build a full-blown callable object).
988 992
989 993 Also big cleanup of this code, which had horrendous runtime
990 994 lookups of zillions of attributes for colorization. Moved all
991 995 this code into a few templates, which make it cleaner and quicker.
992 996
993 997 Printout quality was also improved for Verbose exceptions: one
994 998 variable per line, and memory addresses are printed (this can be
995 999 quite handy in nasty debugging situations, which is what Verbose
996 1000 is for).
997 1001
998 1002 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
999 1003 the command line as scripts to be loaded by embedded instances.
1000 1004 Doing so has the potential for an infinite recursion if there are
1001 1005 exceptions thrown in the process. This fixes a strange crash
1002 1006 reported by Philippe MULLER <muller-AT-irit.fr>.
1003 1007
1004 1008 2004-12-09 Fernando Perez <fperez@colorado.edu>
1005 1009
1006 1010 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
1007 1011 to reflect new names in matplotlib, which now expose the
1008 1012 matlab-compatible interface via a pylab module instead of the
1009 1013 'matlab' name. The new code is backwards compatible, so users of
1010 1014 all matplotlib versions are OK. Patch by J. Hunter.
1011 1015
1012 1016 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
1013 1017 of __init__ docstrings for instances (class docstrings are already
1014 1018 automatically printed). Instances with customized docstrings
1015 1019 (indep. of the class) are also recognized and all 3 separate
1016 1020 docstrings are printed (instance, class, constructor). After some
1017 1021 comments/suggestions by J. Hunter.
1018 1022
1019 1023 2004-12-05 Fernando Perez <fperez@colorado.edu>
1020 1024
1021 1025 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
1022 1026 warnings when tab-completion fails and triggers an exception.
1023 1027
1024 1028 2004-12-03 Fernando Perez <fperez@colorado.edu>
1025 1029
1026 1030 * IPython/Magic.py (magic_prun): Fix bug where an exception would
1027 1031 be triggered when using 'run -p'. An incorrect option flag was
1028 1032 being set ('d' instead of 'D').
1029 1033 (manpage): fix missing escaped \- sign.
1030 1034
1031 1035 2004-11-30 *** Released version 0.6.5
1032 1036
1033 1037 2004-11-30 Fernando Perez <fperez@colorado.edu>
1034 1038
1035 1039 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1036 1040 setting with -d option.
1037 1041
1038 1042 * setup.py (docfiles): Fix problem where the doc glob I was using
1039 1043 was COMPLETELY BROKEN. It was giving the right files by pure
1040 1044 accident, but failed once I tried to include ipython.el. Note:
1041 1045 glob() does NOT allow you to do exclusion on multiple endings!
1042 1046
1043 1047 2004-11-29 Fernando Perez <fperez@colorado.edu>
1044 1048
1045 1049 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1046 1050 the manpage as the source. Better formatting & consistency.
1047 1051
1048 1052 * IPython/Magic.py (magic_run): Added new -d option, to run
1049 1053 scripts under the control of the python pdb debugger. Note that
1050 1054 this required changing the %prun option -d to -D, to avoid a clash
1051 1055 (since %run must pass options to %prun, and getopt is too dumb to
1052 1056 handle options with string values with embedded spaces). Thanks
1053 1057 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1054 1058 (magic_who_ls): added type matching to %who and %whos, so that one
1055 1059 can filter their output to only include variables of certain
1056 1060 types. Another suggestion by Matthew.
1057 1061 (magic_whos): Added memory summaries in kb and Mb for arrays.
1058 1062 (magic_who): Improve formatting (break lines every 9 vars).
1059 1063
1060 1064 2004-11-28 Fernando Perez <fperez@colorado.edu>
1061 1065
1062 1066 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1063 1067 cache when empty lines were present.
1064 1068
1065 1069 2004-11-24 Fernando Perez <fperez@colorado.edu>
1066 1070
1067 1071 * IPython/usage.py (__doc__): document the re-activated threading
1068 1072 options for WX and GTK.
1069 1073
1070 1074 2004-11-23 Fernando Perez <fperez@colorado.edu>
1071 1075
1072 1076 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1073 1077 the -wthread and -gthread options, along with a new -tk one to try
1074 1078 and coordinate Tk threading with wx/gtk. The tk support is very
1075 1079 platform dependent, since it seems to require Tcl and Tk to be
1076 1080 built with threads (Fedora1/2 appears NOT to have it, but in
1077 1081 Prabhu's Debian boxes it works OK). But even with some Tk
1078 1082 limitations, this is a great improvement.
1079 1083
1080 1084 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1081 1085 info in user prompts. Patch by Prabhu.
1082 1086
1083 1087 2004-11-18 Fernando Perez <fperez@colorado.edu>
1084 1088
1085 1089 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1086 1090 EOFErrors and bail, to avoid infinite loops if a non-terminating
1087 1091 file is fed into ipython. Patch submitted in issue 19 by user,
1088 1092 many thanks.
1089 1093
1090 1094 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1091 1095 autoquote/parens in continuation prompts, which can cause lots of
1092 1096 problems. Closes roundup issue 20.
1093 1097
1094 1098 2004-11-17 Fernando Perez <fperez@colorado.edu>
1095 1099
1096 1100 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1097 1101 reported as debian bug #280505. I'm not sure my local changelog
1098 1102 entry has the proper debian format (Jack?).
1099 1103
1100 1104 2004-11-08 *** Released version 0.6.4
1101 1105
1102 1106 2004-11-08 Fernando Perez <fperez@colorado.edu>
1103 1107
1104 1108 * IPython/iplib.py (init_readline): Fix exit message for Windows
1105 1109 when readline is active. Thanks to a report by Eric Jones
1106 1110 <eric-AT-enthought.com>.
1107 1111
1108 1112 2004-11-07 Fernando Perez <fperez@colorado.edu>
1109 1113
1110 1114 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1111 1115 sometimes seen by win2k/cygwin users.
1112 1116
1113 1117 2004-11-06 Fernando Perez <fperez@colorado.edu>
1114 1118
1115 1119 * IPython/iplib.py (interact): Change the handling of %Exit from
1116 1120 trying to propagate a SystemExit to an internal ipython flag.
1117 1121 This is less elegant than using Python's exception mechanism, but
1118 1122 I can't get that to work reliably with threads, so under -pylab
1119 1123 %Exit was hanging IPython. Cross-thread exception handling is
1120 1124 really a bitch. Thaks to a bug report by Stephen Walton
1121 1125 <stephen.walton-AT-csun.edu>.
1122 1126
1123 1127 2004-11-04 Fernando Perez <fperez@colorado.edu>
1124 1128
1125 1129 * IPython/iplib.py (raw_input_original): store a pointer to the
1126 1130 true raw_input to harden against code which can modify it
1127 1131 (wx.py.PyShell does this and would otherwise crash ipython).
1128 1132 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1129 1133
1130 1134 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1131 1135 Ctrl-C problem, which does not mess up the input line.
1132 1136
1133 1137 2004-11-03 Fernando Perez <fperez@colorado.edu>
1134 1138
1135 1139 * IPython/Release.py: Changed licensing to BSD, in all files.
1136 1140 (name): lowercase name for tarball/RPM release.
1137 1141
1138 1142 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1139 1143 use throughout ipython.
1140 1144
1141 1145 * IPython/Magic.py (Magic._ofind): Switch to using the new
1142 1146 OInspect.getdoc() function.
1143 1147
1144 1148 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1145 1149 of the line currently being canceled via Ctrl-C. It's extremely
1146 1150 ugly, but I don't know how to do it better (the problem is one of
1147 1151 handling cross-thread exceptions).
1148 1152
1149 1153 2004-10-28 Fernando Perez <fperez@colorado.edu>
1150 1154
1151 1155 * IPython/Shell.py (signal_handler): add signal handlers to trap
1152 1156 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1153 1157 report by Francesc Alted.
1154 1158
1155 1159 2004-10-21 Fernando Perez <fperez@colorado.edu>
1156 1160
1157 1161 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1158 1162 to % for pysh syntax extensions.
1159 1163
1160 1164 2004-10-09 Fernando Perez <fperez@colorado.edu>
1161 1165
1162 1166 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1163 1167 arrays to print a more useful summary, without calling str(arr).
1164 1168 This avoids the problem of extremely lengthy computations which
1165 1169 occur if arr is large, and appear to the user as a system lockup
1166 1170 with 100% cpu activity. After a suggestion by Kristian Sandberg
1167 1171 <Kristian.Sandberg@colorado.edu>.
1168 1172 (Magic.__init__): fix bug in global magic escapes not being
1169 1173 correctly set.
1170 1174
1171 1175 2004-10-08 Fernando Perez <fperez@colorado.edu>
1172 1176
1173 1177 * IPython/Magic.py (__license__): change to absolute imports of
1174 1178 ipython's own internal packages, to start adapting to the absolute
1175 1179 import requirement of PEP-328.
1176 1180
1177 1181 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1178 1182 files, and standardize author/license marks through the Release
1179 1183 module instead of having per/file stuff (except for files with
1180 1184 particular licenses, like the MIT/PSF-licensed codes).
1181 1185
1182 1186 * IPython/Debugger.py: remove dead code for python 2.1
1183 1187
1184 1188 2004-10-04 Fernando Perez <fperez@colorado.edu>
1185 1189
1186 1190 * IPython/iplib.py (ipmagic): New function for accessing magics
1187 1191 via a normal python function call.
1188 1192
1189 1193 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1190 1194 from '@' to '%', to accomodate the new @decorator syntax of python
1191 1195 2.4.
1192 1196
1193 1197 2004-09-29 Fernando Perez <fperez@colorado.edu>
1194 1198
1195 1199 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1196 1200 matplotlib.use to prevent running scripts which try to switch
1197 1201 interactive backends from within ipython. This will just crash
1198 1202 the python interpreter, so we can't allow it (but a detailed error
1199 1203 is given to the user).
1200 1204
1201 1205 2004-09-28 Fernando Perez <fperez@colorado.edu>
1202 1206
1203 1207 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1204 1208 matplotlib-related fixes so that using @run with non-matplotlib
1205 1209 scripts doesn't pop up spurious plot windows. This requires
1206 1210 matplotlib >= 0.63, where I had to make some changes as well.
1207 1211
1208 1212 * IPython/ipmaker.py (make_IPython): update version requirement to
1209 1213 python 2.2.
1210 1214
1211 1215 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1212 1216 banner arg for embedded customization.
1213 1217
1214 1218 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1215 1219 explicit uses of __IP as the IPython's instance name. Now things
1216 1220 are properly handled via the shell.name value. The actual code
1217 1221 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1218 1222 is much better than before. I'll clean things completely when the
1219 1223 magic stuff gets a real overhaul.
1220 1224
1221 1225 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1222 1226 minor changes to debian dir.
1223 1227
1224 1228 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1225 1229 pointer to the shell itself in the interactive namespace even when
1226 1230 a user-supplied dict is provided. This is needed for embedding
1227 1231 purposes (found by tests with Michel Sanner).
1228 1232
1229 1233 2004-09-27 Fernando Perez <fperez@colorado.edu>
1230 1234
1231 1235 * IPython/UserConfig/ipythonrc: remove []{} from
1232 1236 readline_remove_delims, so that things like [modname.<TAB> do
1233 1237 proper completion. This disables [].TAB, but that's a less common
1234 1238 case than module names in list comprehensions, for example.
1235 1239 Thanks to a report by Andrea Riciputi.
1236 1240
1237 1241 2004-09-09 Fernando Perez <fperez@colorado.edu>
1238 1242
1239 1243 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1240 1244 blocking problems in win32 and osx. Fix by John.
1241 1245
1242 1246 2004-09-08 Fernando Perez <fperez@colorado.edu>
1243 1247
1244 1248 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1245 1249 for Win32 and OSX. Fix by John Hunter.
1246 1250
1247 1251 2004-08-30 *** Released version 0.6.3
1248 1252
1249 1253 2004-08-30 Fernando Perez <fperez@colorado.edu>
1250 1254
1251 1255 * setup.py (isfile): Add manpages to list of dependent files to be
1252 1256 updated.
1253 1257
1254 1258 2004-08-27 Fernando Perez <fperez@colorado.edu>
1255 1259
1256 1260 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1257 1261 for now. They don't really work with standalone WX/GTK code
1258 1262 (though matplotlib IS working fine with both of those backends).
1259 1263 This will neeed much more testing. I disabled most things with
1260 1264 comments, so turning it back on later should be pretty easy.
1261 1265
1262 1266 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1263 1267 autocalling of expressions like r'foo', by modifying the line
1264 1268 split regexp. Closes
1265 1269 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1266 1270 Riley <ipythonbugs-AT-sabi.net>.
1267 1271 (InteractiveShell.mainloop): honor --nobanner with banner
1268 1272 extensions.
1269 1273
1270 1274 * IPython/Shell.py: Significant refactoring of all classes, so
1271 1275 that we can really support ALL matplotlib backends and threading
1272 1276 models (John spotted a bug with Tk which required this). Now we
1273 1277 should support single-threaded, WX-threads and GTK-threads, both
1274 1278 for generic code and for matplotlib.
1275 1279
1276 1280 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1277 1281 -pylab, to simplify things for users. Will also remove the pylab
1278 1282 profile, since now all of matplotlib configuration is directly
1279 1283 handled here. This also reduces startup time.
1280 1284
1281 1285 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1282 1286 shell wasn't being correctly called. Also in IPShellWX.
1283 1287
1284 1288 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1285 1289 fine-tune banner.
1286 1290
1287 1291 * IPython/numutils.py (spike): Deprecate these spike functions,
1288 1292 delete (long deprecated) gnuplot_exec handler.
1289 1293
1290 1294 2004-08-26 Fernando Perez <fperez@colorado.edu>
1291 1295
1292 1296 * ipython.1: Update for threading options, plus some others which
1293 1297 were missing.
1294 1298
1295 1299 * IPython/ipmaker.py (__call__): Added -wthread option for
1296 1300 wxpython thread handling. Make sure threading options are only
1297 1301 valid at the command line.
1298 1302
1299 1303 * scripts/ipython: moved shell selection into a factory function
1300 1304 in Shell.py, to keep the starter script to a minimum.
1301 1305
1302 1306 2004-08-25 Fernando Perez <fperez@colorado.edu>
1303 1307
1304 1308 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1305 1309 John. Along with some recent changes he made to matplotlib, the
1306 1310 next versions of both systems should work very well together.
1307 1311
1308 1312 2004-08-24 Fernando Perez <fperez@colorado.edu>
1309 1313
1310 1314 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1311 1315 tried to switch the profiling to using hotshot, but I'm getting
1312 1316 strange errors from prof.runctx() there. I may be misreading the
1313 1317 docs, but it looks weird. For now the profiling code will
1314 1318 continue to use the standard profiler.
1315 1319
1316 1320 2004-08-23 Fernando Perez <fperez@colorado.edu>
1317 1321
1318 1322 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1319 1323 threaded shell, by John Hunter. It's not quite ready yet, but
1320 1324 close.
1321 1325
1322 1326 2004-08-22 Fernando Perez <fperez@colorado.edu>
1323 1327
1324 1328 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1325 1329 in Magic and ultraTB.
1326 1330
1327 1331 * ipython.1: document threading options in manpage.
1328 1332
1329 1333 * scripts/ipython: Changed name of -thread option to -gthread,
1330 1334 since this is GTK specific. I want to leave the door open for a
1331 1335 -wthread option for WX, which will most likely be necessary. This
1332 1336 change affects usage and ipmaker as well.
1333 1337
1334 1338 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1335 1339 handle the matplotlib shell issues. Code by John Hunter
1336 1340 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1337 1341 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1338 1342 broken (and disabled for end users) for now, but it puts the
1339 1343 infrastructure in place.
1340 1344
1341 1345 2004-08-21 Fernando Perez <fperez@colorado.edu>
1342 1346
1343 1347 * ipythonrc-pylab: Add matplotlib support.
1344 1348
1345 1349 * matplotlib_config.py: new files for matplotlib support, part of
1346 1350 the pylab profile.
1347 1351
1348 1352 * IPython/usage.py (__doc__): documented the threading options.
1349 1353
1350 1354 2004-08-20 Fernando Perez <fperez@colorado.edu>
1351 1355
1352 1356 * ipython: Modified the main calling routine to handle the -thread
1353 1357 and -mpthread options. This needs to be done as a top-level hack,
1354 1358 because it determines which class to instantiate for IPython
1355 1359 itself.
1356 1360
1357 1361 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1358 1362 classes to support multithreaded GTK operation without blocking,
1359 1363 and matplotlib with all backends. This is a lot of still very
1360 1364 experimental code, and threads are tricky. So it may still have a
1361 1365 few rough edges... This code owes a lot to
1362 1366 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1363 1367 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1364 1368 to John Hunter for all the matplotlib work.
1365 1369
1366 1370 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1367 1371 options for gtk thread and matplotlib support.
1368 1372
1369 1373 2004-08-16 Fernando Perez <fperez@colorado.edu>
1370 1374
1371 1375 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1372 1376 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1373 1377 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1374 1378
1375 1379 2004-08-11 Fernando Perez <fperez@colorado.edu>
1376 1380
1377 1381 * setup.py (isfile): Fix build so documentation gets updated for
1378 1382 rpms (it was only done for .tgz builds).
1379 1383
1380 1384 2004-08-10 Fernando Perez <fperez@colorado.edu>
1381 1385
1382 1386 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1383 1387
1384 1388 * iplib.py : Silence syntax error exceptions in tab-completion.
1385 1389
1386 1390 2004-08-05 Fernando Perez <fperez@colorado.edu>
1387 1391
1388 1392 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1389 1393 'color off' mark for continuation prompts. This was causing long
1390 1394 continuation lines to mis-wrap.
1391 1395
1392 1396 2004-08-01 Fernando Perez <fperez@colorado.edu>
1393 1397
1394 1398 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1395 1399 for building ipython to be a parameter. All this is necessary
1396 1400 right now to have a multithreaded version, but this insane
1397 1401 non-design will be cleaned up soon. For now, it's a hack that
1398 1402 works.
1399 1403
1400 1404 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1401 1405 args in various places. No bugs so far, but it's a dangerous
1402 1406 practice.
1403 1407
1404 1408 2004-07-31 Fernando Perez <fperez@colorado.edu>
1405 1409
1406 1410 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1407 1411 fix completion of files with dots in their names under most
1408 1412 profiles (pysh was OK because the completion order is different).
1409 1413
1410 1414 2004-07-27 Fernando Perez <fperez@colorado.edu>
1411 1415
1412 1416 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1413 1417 keywords manually, b/c the one in keyword.py was removed in python
1414 1418 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1415 1419 This is NOT a bug under python 2.3 and earlier.
1416 1420
1417 1421 2004-07-26 Fernando Perez <fperez@colorado.edu>
1418 1422
1419 1423 * IPython/ultraTB.py (VerboseTB.text): Add another
1420 1424 linecache.checkcache() call to try to prevent inspect.py from
1421 1425 crashing under python 2.3. I think this fixes
1422 1426 http://www.scipy.net/roundup/ipython/issue17.
1423 1427
1424 1428 2004-07-26 *** Released version 0.6.2
1425 1429
1426 1430 2004-07-26 Fernando Perez <fperez@colorado.edu>
1427 1431
1428 1432 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1429 1433 fail for any number.
1430 1434 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1431 1435 empty bookmarks.
1432 1436
1433 1437 2004-07-26 *** Released version 0.6.1
1434 1438
1435 1439 2004-07-26 Fernando Perez <fperez@colorado.edu>
1436 1440
1437 1441 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1438 1442
1439 1443 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1440 1444 escaping '()[]{}' in filenames.
1441 1445
1442 1446 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1443 1447 Python 2.2 users who lack a proper shlex.split.
1444 1448
1445 1449 2004-07-19 Fernando Perez <fperez@colorado.edu>
1446 1450
1447 1451 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1448 1452 for reading readline's init file. I follow the normal chain:
1449 1453 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1450 1454 report by Mike Heeter. This closes
1451 1455 http://www.scipy.net/roundup/ipython/issue16.
1452 1456
1453 1457 2004-07-18 Fernando Perez <fperez@colorado.edu>
1454 1458
1455 1459 * IPython/iplib.py (__init__): Add better handling of '\' under
1456 1460 Win32 for filenames. After a patch by Ville.
1457 1461
1458 1462 2004-07-17 Fernando Perez <fperez@colorado.edu>
1459 1463
1460 1464 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1461 1465 autocalling would be triggered for 'foo is bar' if foo is
1462 1466 callable. I also cleaned up the autocall detection code to use a
1463 1467 regexp, which is faster. Bug reported by Alexander Schmolck.
1464 1468
1465 1469 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1466 1470 '?' in them would confuse the help system. Reported by Alex
1467 1471 Schmolck.
1468 1472
1469 1473 2004-07-16 Fernando Perez <fperez@colorado.edu>
1470 1474
1471 1475 * IPython/GnuplotInteractive.py (__all__): added plot2.
1472 1476
1473 1477 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1474 1478 plotting dictionaries, lists or tuples of 1d arrays.
1475 1479
1476 1480 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1477 1481 optimizations.
1478 1482
1479 1483 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1480 1484 the information which was there from Janko's original IPP code:
1481 1485
1482 1486 03.05.99 20:53 porto.ifm.uni-kiel.de
1483 1487 --Started changelog.
1484 1488 --make clear do what it say it does
1485 1489 --added pretty output of lines from inputcache
1486 1490 --Made Logger a mixin class, simplifies handling of switches
1487 1491 --Added own completer class. .string<TAB> expands to last history
1488 1492 line which starts with string. The new expansion is also present
1489 1493 with Ctrl-r from the readline library. But this shows, who this
1490 1494 can be done for other cases.
1491 1495 --Added convention that all shell functions should accept a
1492 1496 parameter_string This opens the door for different behaviour for
1493 1497 each function. @cd is a good example of this.
1494 1498
1495 1499 04.05.99 12:12 porto.ifm.uni-kiel.de
1496 1500 --added logfile rotation
1497 1501 --added new mainloop method which freezes first the namespace
1498 1502
1499 1503 07.05.99 21:24 porto.ifm.uni-kiel.de
1500 1504 --added the docreader classes. Now there is a help system.
1501 1505 -This is only a first try. Currently it's not easy to put new
1502 1506 stuff in the indices. But this is the way to go. Info would be
1503 1507 better, but HTML is every where and not everybody has an info
1504 1508 system installed and it's not so easy to change html-docs to info.
1505 1509 --added global logfile option
1506 1510 --there is now a hook for object inspection method pinfo needs to
1507 1511 be provided for this. Can be reached by two '??'.
1508 1512
1509 1513 08.05.99 20:51 porto.ifm.uni-kiel.de
1510 1514 --added a README
1511 1515 --bug in rc file. Something has changed so functions in the rc
1512 1516 file need to reference the shell and not self. Not clear if it's a
1513 1517 bug or feature.
1514 1518 --changed rc file for new behavior
1515 1519
1516 1520 2004-07-15 Fernando Perez <fperez@colorado.edu>
1517 1521
1518 1522 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1519 1523 cache was falling out of sync in bizarre manners when multi-line
1520 1524 input was present. Minor optimizations and cleanup.
1521 1525
1522 1526 (Logger): Remove old Changelog info for cleanup. This is the
1523 1527 information which was there from Janko's original code:
1524 1528
1525 1529 Changes to Logger: - made the default log filename a parameter
1526 1530
1527 1531 - put a check for lines beginning with !@? in log(). Needed
1528 1532 (even if the handlers properly log their lines) for mid-session
1529 1533 logging activation to work properly. Without this, lines logged
1530 1534 in mid session, which get read from the cache, would end up
1531 1535 'bare' (with !@? in the open) in the log. Now they are caught
1532 1536 and prepended with a #.
1533 1537
1534 1538 * IPython/iplib.py (InteractiveShell.init_readline): added check
1535 1539 in case MagicCompleter fails to be defined, so we don't crash.
1536 1540
1537 1541 2004-07-13 Fernando Perez <fperez@colorado.edu>
1538 1542
1539 1543 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1540 1544 of EPS if the requested filename ends in '.eps'.
1541 1545
1542 1546 2004-07-04 Fernando Perez <fperez@colorado.edu>
1543 1547
1544 1548 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1545 1549 escaping of quotes when calling the shell.
1546 1550
1547 1551 2004-07-02 Fernando Perez <fperez@colorado.edu>
1548 1552
1549 1553 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1550 1554 gettext not working because we were clobbering '_'. Fixes
1551 1555 http://www.scipy.net/roundup/ipython/issue6.
1552 1556
1553 1557 2004-07-01 Fernando Perez <fperez@colorado.edu>
1554 1558
1555 1559 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1556 1560 into @cd. Patch by Ville.
1557 1561
1558 1562 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1559 1563 new function to store things after ipmaker runs. Patch by Ville.
1560 1564 Eventually this will go away once ipmaker is removed and the class
1561 1565 gets cleaned up, but for now it's ok. Key functionality here is
1562 1566 the addition of the persistent storage mechanism, a dict for
1563 1567 keeping data across sessions (for now just bookmarks, but more can
1564 1568 be implemented later).
1565 1569
1566 1570 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1567 1571 persistent across sections. Patch by Ville, I modified it
1568 1572 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1569 1573 added a '-l' option to list all bookmarks.
1570 1574
1571 1575 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1572 1576 center for cleanup. Registered with atexit.register(). I moved
1573 1577 here the old exit_cleanup(). After a patch by Ville.
1574 1578
1575 1579 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1576 1580 characters in the hacked shlex_split for python 2.2.
1577 1581
1578 1582 * IPython/iplib.py (file_matches): more fixes to filenames with
1579 1583 whitespace in them. It's not perfect, but limitations in python's
1580 1584 readline make it impossible to go further.
1581 1585
1582 1586 2004-06-29 Fernando Perez <fperez@colorado.edu>
1583 1587
1584 1588 * IPython/iplib.py (file_matches): escape whitespace correctly in
1585 1589 filename completions. Bug reported by Ville.
1586 1590
1587 1591 2004-06-28 Fernando Perez <fperez@colorado.edu>
1588 1592
1589 1593 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1590 1594 the history file will be called 'history-PROFNAME' (or just
1591 1595 'history' if no profile is loaded). I was getting annoyed at
1592 1596 getting my Numerical work history clobbered by pysh sessions.
1593 1597
1594 1598 * IPython/iplib.py (InteractiveShell.__init__): Internal
1595 1599 getoutputerror() function so that we can honor the system_verbose
1596 1600 flag for _all_ system calls. I also added escaping of #
1597 1601 characters here to avoid confusing Itpl.
1598 1602
1599 1603 * IPython/Magic.py (shlex_split): removed call to shell in
1600 1604 parse_options and replaced it with shlex.split(). The annoying
1601 1605 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1602 1606 to backport it from 2.3, with several frail hacks (the shlex
1603 1607 module is rather limited in 2.2). Thanks to a suggestion by Ville
1604 1608 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1605 1609 problem.
1606 1610
1607 1611 (Magic.magic_system_verbose): new toggle to print the actual
1608 1612 system calls made by ipython. Mainly for debugging purposes.
1609 1613
1610 1614 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1611 1615 doesn't support persistence. Reported (and fix suggested) by
1612 1616 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1613 1617
1614 1618 2004-06-26 Fernando Perez <fperez@colorado.edu>
1615 1619
1616 1620 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1617 1621 continue prompts.
1618 1622
1619 1623 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1620 1624 function (basically a big docstring) and a few more things here to
1621 1625 speedup startup. pysh.py is now very lightweight. We want because
1622 1626 it gets execfile'd, while InterpreterExec gets imported, so
1623 1627 byte-compilation saves time.
1624 1628
1625 1629 2004-06-25 Fernando Perez <fperez@colorado.edu>
1626 1630
1627 1631 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1628 1632 -NUM', which was recently broken.
1629 1633
1630 1634 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1631 1635 in multi-line input (but not !!, which doesn't make sense there).
1632 1636
1633 1637 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1634 1638 It's just too useful, and people can turn it off in the less
1635 1639 common cases where it's a problem.
1636 1640
1637 1641 2004-06-24 Fernando Perez <fperez@colorado.edu>
1638 1642
1639 1643 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1640 1644 special syntaxes (like alias calling) is now allied in multi-line
1641 1645 input. This is still _very_ experimental, but it's necessary for
1642 1646 efficient shell usage combining python looping syntax with system
1643 1647 calls. For now it's restricted to aliases, I don't think it
1644 1648 really even makes sense to have this for magics.
1645 1649
1646 1650 2004-06-23 Fernando Perez <fperez@colorado.edu>
1647 1651
1648 1652 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1649 1653 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1650 1654
1651 1655 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1652 1656 extensions under Windows (after code sent by Gary Bishop). The
1653 1657 extensions considered 'executable' are stored in IPython's rc
1654 1658 structure as win_exec_ext.
1655 1659
1656 1660 * IPython/genutils.py (shell): new function, like system() but
1657 1661 without return value. Very useful for interactive shell work.
1658 1662
1659 1663 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1660 1664 delete aliases.
1661 1665
1662 1666 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1663 1667 sure that the alias table doesn't contain python keywords.
1664 1668
1665 1669 2004-06-21 Fernando Perez <fperez@colorado.edu>
1666 1670
1667 1671 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1668 1672 non-existent items are found in $PATH. Reported by Thorsten.
1669 1673
1670 1674 2004-06-20 Fernando Perez <fperez@colorado.edu>
1671 1675
1672 1676 * IPython/iplib.py (complete): modified the completer so that the
1673 1677 order of priorities can be easily changed at runtime.
1674 1678
1675 1679 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1676 1680 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1677 1681
1678 1682 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1679 1683 expand Python variables prepended with $ in all system calls. The
1680 1684 same was done to InteractiveShell.handle_shell_escape. Now all
1681 1685 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1682 1686 expansion of python variables and expressions according to the
1683 1687 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1684 1688
1685 1689 Though PEP-215 has been rejected, a similar (but simpler) one
1686 1690 seems like it will go into Python 2.4, PEP-292 -
1687 1691 http://www.python.org/peps/pep-0292.html.
1688 1692
1689 1693 I'll keep the full syntax of PEP-215, since IPython has since the
1690 1694 start used Ka-Ping Yee's reference implementation discussed there
1691 1695 (Itpl), and I actually like the powerful semantics it offers.
1692 1696
1693 1697 In order to access normal shell variables, the $ has to be escaped
1694 1698 via an extra $. For example:
1695 1699
1696 1700 In [7]: PATH='a python variable'
1697 1701
1698 1702 In [8]: !echo $PATH
1699 1703 a python variable
1700 1704
1701 1705 In [9]: !echo $$PATH
1702 1706 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1703 1707
1704 1708 (Magic.parse_options): escape $ so the shell doesn't evaluate
1705 1709 things prematurely.
1706 1710
1707 1711 * IPython/iplib.py (InteractiveShell.call_alias): added the
1708 1712 ability for aliases to expand python variables via $.
1709 1713
1710 1714 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1711 1715 system, now there's a @rehash/@rehashx pair of magics. These work
1712 1716 like the csh rehash command, and can be invoked at any time. They
1713 1717 build a table of aliases to everything in the user's $PATH
1714 1718 (@rehash uses everything, @rehashx is slower but only adds
1715 1719 executable files). With this, the pysh.py-based shell profile can
1716 1720 now simply call rehash upon startup, and full access to all
1717 1721 programs in the user's path is obtained.
1718 1722
1719 1723 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1720 1724 functionality is now fully in place. I removed the old dynamic
1721 1725 code generation based approach, in favor of a much lighter one
1722 1726 based on a simple dict. The advantage is that this allows me to
1723 1727 now have thousands of aliases with negligible cost (unthinkable
1724 1728 with the old system).
1725 1729
1726 1730 2004-06-19 Fernando Perez <fperez@colorado.edu>
1727 1731
1728 1732 * IPython/iplib.py (__init__): extended MagicCompleter class to
1729 1733 also complete (last in priority) on user aliases.
1730 1734
1731 1735 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1732 1736 call to eval.
1733 1737 (ItplNS.__init__): Added a new class which functions like Itpl,
1734 1738 but allows configuring the namespace for the evaluation to occur
1735 1739 in.
1736 1740
1737 1741 2004-06-18 Fernando Perez <fperez@colorado.edu>
1738 1742
1739 1743 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1740 1744 better message when 'exit' or 'quit' are typed (a common newbie
1741 1745 confusion).
1742 1746
1743 1747 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1744 1748 check for Windows users.
1745 1749
1746 1750 * IPython/iplib.py (InteractiveShell.user_setup): removed
1747 1751 disabling of colors for Windows. I'll test at runtime and issue a
1748 1752 warning if Gary's readline isn't found, as to nudge users to
1749 1753 download it.
1750 1754
1751 1755 2004-06-16 Fernando Perez <fperez@colorado.edu>
1752 1756
1753 1757 * IPython/genutils.py (Stream.__init__): changed to print errors
1754 1758 to sys.stderr. I had a circular dependency here. Now it's
1755 1759 possible to run ipython as IDLE's shell (consider this pre-alpha,
1756 1760 since true stdout things end up in the starting terminal instead
1757 1761 of IDLE's out).
1758 1762
1759 1763 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1760 1764 users who haven't # updated their prompt_in2 definitions. Remove
1761 1765 eventually.
1762 1766 (multiple_replace): added credit to original ASPN recipe.
1763 1767
1764 1768 2004-06-15 Fernando Perez <fperez@colorado.edu>
1765 1769
1766 1770 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1767 1771 list of auto-defined aliases.
1768 1772
1769 1773 2004-06-13 Fernando Perez <fperez@colorado.edu>
1770 1774
1771 1775 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1772 1776 install was really requested (so setup.py can be used for other
1773 1777 things under Windows).
1774 1778
1775 1779 2004-06-10 Fernando Perez <fperez@colorado.edu>
1776 1780
1777 1781 * IPython/Logger.py (Logger.create_log): Manually remove any old
1778 1782 backup, since os.remove may fail under Windows. Fixes bug
1779 1783 reported by Thorsten.
1780 1784
1781 1785 2004-06-09 Fernando Perez <fperez@colorado.edu>
1782 1786
1783 1787 * examples/example-embed.py: fixed all references to %n (replaced
1784 1788 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1785 1789 for all examples and the manual as well.
1786 1790
1787 1791 2004-06-08 Fernando Perez <fperez@colorado.edu>
1788 1792
1789 1793 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1790 1794 alignment and color management. All 3 prompt subsystems now
1791 1795 inherit from BasePrompt.
1792 1796
1793 1797 * tools/release: updates for windows installer build and tag rpms
1794 1798 with python version (since paths are fixed).
1795 1799
1796 1800 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1797 1801 which will become eventually obsolete. Also fixed the default
1798 1802 prompt_in2 to use \D, so at least new users start with the correct
1799 1803 defaults.
1800 1804 WARNING: Users with existing ipythonrc files will need to apply
1801 1805 this fix manually!
1802 1806
1803 1807 * setup.py: make windows installer (.exe). This is finally the
1804 1808 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1805 1809 which I hadn't included because it required Python 2.3 (or recent
1806 1810 distutils).
1807 1811
1808 1812 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1809 1813 usage of new '\D' escape.
1810 1814
1811 1815 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
1812 1816 lacks os.getuid())
1813 1817 (CachedOutput.set_colors): Added the ability to turn coloring
1814 1818 on/off with @colors even for manually defined prompt colors. It
1815 1819 uses a nasty global, but it works safely and via the generic color
1816 1820 handling mechanism.
1817 1821 (Prompt2.__init__): Introduced new escape '\D' for continuation
1818 1822 prompts. It represents the counter ('\#') as dots.
1819 1823 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
1820 1824 need to update their ipythonrc files and replace '%n' with '\D' in
1821 1825 their prompt_in2 settings everywhere. Sorry, but there's
1822 1826 otherwise no clean way to get all prompts to properly align. The
1823 1827 ipythonrc shipped with IPython has been updated.
1824 1828
1825 1829 2004-06-07 Fernando Perez <fperez@colorado.edu>
1826 1830
1827 1831 * setup.py (isfile): Pass local_icons option to latex2html, so the
1828 1832 resulting HTML file is self-contained. Thanks to
1829 1833 dryice-AT-liu.com.cn for the tip.
1830 1834
1831 1835 * pysh.py: I created a new profile 'shell', which implements a
1832 1836 _rudimentary_ IPython-based shell. This is in NO WAY a realy
1833 1837 system shell, nor will it become one anytime soon. It's mainly
1834 1838 meant to illustrate the use of the new flexible bash-like prompts.
1835 1839 I guess it could be used by hardy souls for true shell management,
1836 1840 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
1837 1841 profile. This uses the InterpreterExec extension provided by
1838 1842 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
1839 1843
1840 1844 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
1841 1845 auto-align itself with the length of the previous input prompt
1842 1846 (taking into account the invisible color escapes).
1843 1847 (CachedOutput.__init__): Large restructuring of this class. Now
1844 1848 all three prompts (primary1, primary2, output) are proper objects,
1845 1849 managed by the 'parent' CachedOutput class. The code is still a
1846 1850 bit hackish (all prompts share state via a pointer to the cache),
1847 1851 but it's overall far cleaner than before.
1848 1852
1849 1853 * IPython/genutils.py (getoutputerror): modified to add verbose,
1850 1854 debug and header options. This makes the interface of all getout*
1851 1855 functions uniform.
1852 1856 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
1853 1857
1854 1858 * IPython/Magic.py (Magic.default_option): added a function to
1855 1859 allow registering default options for any magic command. This
1856 1860 makes it easy to have profiles which customize the magics globally
1857 1861 for a certain use. The values set through this function are
1858 1862 picked up by the parse_options() method, which all magics should
1859 1863 use to parse their options.
1860 1864
1861 1865 * IPython/genutils.py (warn): modified the warnings framework to
1862 1866 use the Term I/O class. I'm trying to slowly unify all of
1863 1867 IPython's I/O operations to pass through Term.
1864 1868
1865 1869 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
1866 1870 the secondary prompt to correctly match the length of the primary
1867 1871 one for any prompt. Now multi-line code will properly line up
1868 1872 even for path dependent prompts, such as the new ones available
1869 1873 via the prompt_specials.
1870 1874
1871 1875 2004-06-06 Fernando Perez <fperez@colorado.edu>
1872 1876
1873 1877 * IPython/Prompts.py (prompt_specials): Added the ability to have
1874 1878 bash-like special sequences in the prompts, which get
1875 1879 automatically expanded. Things like hostname, current working
1876 1880 directory and username are implemented already, but it's easy to
1877 1881 add more in the future. Thanks to a patch by W.J. van der Laan
1878 1882 <gnufnork-AT-hetdigitalegat.nl>
1879 1883 (prompt_specials): Added color support for prompt strings, so
1880 1884 users can define arbitrary color setups for their prompts.
1881 1885
1882 1886 2004-06-05 Fernando Perez <fperez@colorado.edu>
1883 1887
1884 1888 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
1885 1889 code to load Gary Bishop's readline and configure it
1886 1890 automatically. Thanks to Gary for help on this.
1887 1891
1888 1892 2004-06-01 Fernando Perez <fperez@colorado.edu>
1889 1893
1890 1894 * IPython/Logger.py (Logger.create_log): fix bug for logging
1891 1895 with no filename (previous fix was incomplete).
1892 1896
1893 1897 2004-05-25 Fernando Perez <fperez@colorado.edu>
1894 1898
1895 1899 * IPython/Magic.py (Magic.parse_options): fix bug where naked
1896 1900 parens would get passed to the shell.
1897 1901
1898 1902 2004-05-20 Fernando Perez <fperez@colorado.edu>
1899 1903
1900 1904 * IPython/Magic.py (Magic.magic_prun): changed default profile
1901 1905 sort order to 'time' (the more common profiling need).
1902 1906
1903 1907 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
1904 1908 so that source code shown is guaranteed in sync with the file on
1905 1909 disk (also changed in psource). Similar fix to the one for
1906 1910 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
1907 1911 <yann.ledu-AT-noos.fr>.
1908 1912
1909 1913 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
1910 1914 with a single option would not be correctly parsed. Closes
1911 1915 http://www.scipy.net/roundup/ipython/issue14. This bug had been
1912 1916 introduced in 0.6.0 (on 2004-05-06).
1913 1917
1914 1918 2004-05-13 *** Released version 0.6.0
1915 1919
1916 1920 2004-05-13 Fernando Perez <fperez@colorado.edu>
1917 1921
1918 1922 * debian/: Added debian/ directory to CVS, so that debian support
1919 1923 is publicly accessible. The debian package is maintained by Jack
1920 1924 Moffit <jack-AT-xiph.org>.
1921 1925
1922 1926 * Documentation: included the notes about an ipython-based system
1923 1927 shell (the hypothetical 'pysh') into the new_design.pdf document,
1924 1928 so that these ideas get distributed to users along with the
1925 1929 official documentation.
1926 1930
1927 1931 2004-05-10 Fernando Perez <fperez@colorado.edu>
1928 1932
1929 1933 * IPython/Logger.py (Logger.create_log): fix recently introduced
1930 1934 bug (misindented line) where logstart would fail when not given an
1931 1935 explicit filename.
1932 1936
1933 1937 2004-05-09 Fernando Perez <fperez@colorado.edu>
1934 1938
1935 1939 * IPython/Magic.py (Magic.parse_options): skip system call when
1936 1940 there are no options to look for. Faster, cleaner for the common
1937 1941 case.
1938 1942
1939 1943 * Documentation: many updates to the manual: describing Windows
1940 1944 support better, Gnuplot updates, credits, misc small stuff. Also
1941 1945 updated the new_design doc a bit.
1942 1946
1943 1947 2004-05-06 *** Released version 0.6.0.rc1
1944 1948
1945 1949 2004-05-06 Fernando Perez <fperez@colorado.edu>
1946 1950
1947 1951 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
1948 1952 operations to use the vastly more efficient list/''.join() method.
1949 1953 (FormattedTB.text): Fix
1950 1954 http://www.scipy.net/roundup/ipython/issue12 - exception source
1951 1955 extract not updated after reload. Thanks to Mike Salib
1952 1956 <msalib-AT-mit.edu> for pinning the source of the problem.
1953 1957 Fortunately, the solution works inside ipython and doesn't require
1954 1958 any changes to python proper.
1955 1959
1956 1960 * IPython/Magic.py (Magic.parse_options): Improved to process the
1957 1961 argument list as a true shell would (by actually using the
1958 1962 underlying system shell). This way, all @magics automatically get
1959 1963 shell expansion for variables. Thanks to a comment by Alex
1960 1964 Schmolck.
1961 1965
1962 1966 2004-04-04 Fernando Perez <fperez@colorado.edu>
1963 1967
1964 1968 * IPython/iplib.py (InteractiveShell.interact): Added a special
1965 1969 trap for a debugger quit exception, which is basically impossible
1966 1970 to handle by normal mechanisms, given what pdb does to the stack.
1967 1971 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
1968 1972
1969 1973 2004-04-03 Fernando Perez <fperez@colorado.edu>
1970 1974
1971 1975 * IPython/genutils.py (Term): Standardized the names of the Term
1972 1976 class streams to cin/cout/cerr, following C++ naming conventions
1973 1977 (I can't use in/out/err because 'in' is not a valid attribute
1974 1978 name).
1975 1979
1976 1980 * IPython/iplib.py (InteractiveShell.interact): don't increment
1977 1981 the prompt if there's no user input. By Daniel 'Dang' Griffith
1978 1982 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
1979 1983 Francois Pinard.
1980 1984
1981 1985 2004-04-02 Fernando Perez <fperez@colorado.edu>
1982 1986
1983 1987 * IPython/genutils.py (Stream.__init__): Modified to survive at
1984 1988 least importing in contexts where stdin/out/err aren't true file
1985 1989 objects, such as PyCrust (they lack fileno() and mode). However,
1986 1990 the recovery facilities which rely on these things existing will
1987 1991 not work.
1988 1992
1989 1993 2004-04-01 Fernando Perez <fperez@colorado.edu>
1990 1994
1991 1995 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
1992 1996 use the new getoutputerror() function, so it properly
1993 1997 distinguishes stdout/err.
1994 1998
1995 1999 * IPython/genutils.py (getoutputerror): added a function to
1996 2000 capture separately the standard output and error of a command.
1997 2001 After a comment from dang on the mailing lists. This code is
1998 2002 basically a modified version of commands.getstatusoutput(), from
1999 2003 the standard library.
2000 2004
2001 2005 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
2002 2006 '!!' as a special syntax (shorthand) to access @sx.
2003 2007
2004 2008 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
2005 2009 command and return its output as a list split on '\n'.
2006 2010
2007 2011 2004-03-31 Fernando Perez <fperez@colorado.edu>
2008 2012
2009 2013 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
2010 2014 method to dictionaries used as FakeModule instances if they lack
2011 2015 it. At least pydoc in python2.3 breaks for runtime-defined
2012 2016 functions without this hack. At some point I need to _really_
2013 2017 understand what FakeModule is doing, because it's a gross hack.
2014 2018 But it solves Arnd's problem for now...
2015 2019
2016 2020 2004-02-27 Fernando Perez <fperez@colorado.edu>
2017 2021
2018 2022 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
2019 2023 mode would behave erratically. Also increased the number of
2020 2024 possible logs in rotate mod to 999. Thanks to Rod Holland
2021 2025 <rhh@StructureLABS.com> for the report and fixes.
2022 2026
2023 2027 2004-02-26 Fernando Perez <fperez@colorado.edu>
2024 2028
2025 2029 * IPython/genutils.py (page): Check that the curses module really
2026 2030 has the initscr attribute before trying to use it. For some
2027 2031 reason, the Solaris curses module is missing this. I think this
2028 2032 should be considered a Solaris python bug, but I'm not sure.
2029 2033
2030 2034 2004-01-17 Fernando Perez <fperez@colorado.edu>
2031 2035
2032 2036 * IPython/genutils.py (Stream.__init__): Changes to try to make
2033 2037 ipython robust against stdin/out/err being closed by the user.
2034 2038 This is 'user error' (and blocks a normal python session, at least
2035 2039 the stdout case). However, Ipython should be able to survive such
2036 2040 instances of abuse as gracefully as possible. To simplify the
2037 2041 coding and maintain compatibility with Gary Bishop's Term
2038 2042 contributions, I've made use of classmethods for this. I think
2039 2043 this introduces a dependency on python 2.2.
2040 2044
2041 2045 2004-01-13 Fernando Perez <fperez@colorado.edu>
2042 2046
2043 2047 * IPython/numutils.py (exp_safe): simplified the code a bit and
2044 2048 removed the need for importing the kinds module altogether.
2045 2049
2046 2050 2004-01-06 Fernando Perez <fperez@colorado.edu>
2047 2051
2048 2052 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2049 2053 a magic function instead, after some community feedback. No
2050 2054 special syntax will exist for it, but its name is deliberately
2051 2055 very short.
2052 2056
2053 2057 2003-12-20 Fernando Perez <fperez@colorado.edu>
2054 2058
2055 2059 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2056 2060 new functionality, to automagically assign the result of a shell
2057 2061 command to a variable. I'll solicit some community feedback on
2058 2062 this before making it permanent.
2059 2063
2060 2064 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2061 2065 requested about callables for which inspect couldn't obtain a
2062 2066 proper argspec. Thanks to a crash report sent by Etienne
2063 2067 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2064 2068
2065 2069 2003-12-09 Fernando Perez <fperez@colorado.edu>
2066 2070
2067 2071 * IPython/genutils.py (page): patch for the pager to work across
2068 2072 various versions of Windows. By Gary Bishop.
2069 2073
2070 2074 2003-12-04 Fernando Perez <fperez@colorado.edu>
2071 2075
2072 2076 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2073 2077 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2074 2078 While I tested this and it looks ok, there may still be corner
2075 2079 cases I've missed.
2076 2080
2077 2081 2003-12-01 Fernando Perez <fperez@colorado.edu>
2078 2082
2079 2083 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2080 2084 where a line like 'p,q=1,2' would fail because the automagic
2081 2085 system would be triggered for @p.
2082 2086
2083 2087 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2084 2088 cleanups, code unmodified.
2085 2089
2086 2090 * IPython/genutils.py (Term): added a class for IPython to handle
2087 2091 output. In most cases it will just be a proxy for stdout/err, but
2088 2092 having this allows modifications to be made for some platforms,
2089 2093 such as handling color escapes under Windows. All of this code
2090 2094 was contributed by Gary Bishop, with minor modifications by me.
2091 2095 The actual changes affect many files.
2092 2096
2093 2097 2003-11-30 Fernando Perez <fperez@colorado.edu>
2094 2098
2095 2099 * IPython/iplib.py (file_matches): new completion code, courtesy
2096 2100 of Jeff Collins. This enables filename completion again under
2097 2101 python 2.3, which disabled it at the C level.
2098 2102
2099 2103 2003-11-11 Fernando Perez <fperez@colorado.edu>
2100 2104
2101 2105 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2102 2106 for Numeric.array(map(...)), but often convenient.
2103 2107
2104 2108 2003-11-05 Fernando Perez <fperez@colorado.edu>
2105 2109
2106 2110 * IPython/numutils.py (frange): Changed a call from int() to
2107 2111 int(round()) to prevent a problem reported with arange() in the
2108 2112 numpy list.
2109 2113
2110 2114 2003-10-06 Fernando Perez <fperez@colorado.edu>
2111 2115
2112 2116 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2113 2117 prevent crashes if sys lacks an argv attribute (it happens with
2114 2118 embedded interpreters which build a bare-bones sys module).
2115 2119 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2116 2120
2117 2121 2003-09-24 Fernando Perez <fperez@colorado.edu>
2118 2122
2119 2123 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2120 2124 to protect against poorly written user objects where __getattr__
2121 2125 raises exceptions other than AttributeError. Thanks to a bug
2122 2126 report by Oliver Sander <osander-AT-gmx.de>.
2123 2127
2124 2128 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2125 2129 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2126 2130
2127 2131 2003-09-09 Fernando Perez <fperez@colorado.edu>
2128 2132
2129 2133 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2130 2134 unpacking a list whith a callable as first element would
2131 2135 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2132 2136 Collins.
2133 2137
2134 2138 2003-08-25 *** Released version 0.5.0
2135 2139
2136 2140 2003-08-22 Fernando Perez <fperez@colorado.edu>
2137 2141
2138 2142 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2139 2143 improperly defined user exceptions. Thanks to feedback from Mark
2140 2144 Russell <mrussell-AT-verio.net>.
2141 2145
2142 2146 2003-08-20 Fernando Perez <fperez@colorado.edu>
2143 2147
2144 2148 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2145 2149 printing so that it would print multi-line string forms starting
2146 2150 with a new line. This way the formatting is better respected for
2147 2151 objects which work hard to make nice string forms.
2148 2152
2149 2153 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2150 2154 autocall would overtake data access for objects with both
2151 2155 __getitem__ and __call__.
2152 2156
2153 2157 2003-08-19 *** Released version 0.5.0-rc1
2154 2158
2155 2159 2003-08-19 Fernando Perez <fperez@colorado.edu>
2156 2160
2157 2161 * IPython/deep_reload.py (load_tail): single tiny change here
2158 2162 seems to fix the long-standing bug of dreload() failing to work
2159 2163 for dotted names. But this module is pretty tricky, so I may have
2160 2164 missed some subtlety. Needs more testing!.
2161 2165
2162 2166 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2163 2167 exceptions which have badly implemented __str__ methods.
2164 2168 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2165 2169 which I've been getting reports about from Python 2.3 users. I
2166 2170 wish I had a simple test case to reproduce the problem, so I could
2167 2171 either write a cleaner workaround or file a bug report if
2168 2172 necessary.
2169 2173
2170 2174 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2171 2175 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2172 2176 a bug report by Tjabo Kloppenburg.
2173 2177
2174 2178 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2175 2179 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2176 2180 seems rather unstable. Thanks to a bug report by Tjabo
2177 2181 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2178 2182
2179 2183 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2180 2184 this out soon because of the critical fixes in the inner loop for
2181 2185 generators.
2182 2186
2183 2187 * IPython/Magic.py (Magic.getargspec): removed. This (and
2184 2188 _get_def) have been obsoleted by OInspect for a long time, I
2185 2189 hadn't noticed that they were dead code.
2186 2190 (Magic._ofind): restored _ofind functionality for a few literals
2187 2191 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2188 2192 for things like "hello".capitalize?, since that would require a
2189 2193 potentially dangerous eval() again.
2190 2194
2191 2195 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2192 2196 logic a bit more to clean up the escapes handling and minimize the
2193 2197 use of _ofind to only necessary cases. The interactive 'feel' of
2194 2198 IPython should have improved quite a bit with the changes in
2195 2199 _prefilter and _ofind (besides being far safer than before).
2196 2200
2197 2201 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2198 2202 obscure, never reported). Edit would fail to find the object to
2199 2203 edit under some circumstances.
2200 2204 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2201 2205 which were causing double-calling of generators. Those eval calls
2202 2206 were _very_ dangerous, since code with side effects could be
2203 2207 triggered. As they say, 'eval is evil'... These were the
2204 2208 nastiest evals in IPython. Besides, _ofind is now far simpler,
2205 2209 and it should also be quite a bit faster. Its use of inspect is
2206 2210 also safer, so perhaps some of the inspect-related crashes I've
2207 2211 seen lately with Python 2.3 might be taken care of. That will
2208 2212 need more testing.
2209 2213
2210 2214 2003-08-17 Fernando Perez <fperez@colorado.edu>
2211 2215
2212 2216 * IPython/iplib.py (InteractiveShell._prefilter): significant
2213 2217 simplifications to the logic for handling user escapes. Faster
2214 2218 and simpler code.
2215 2219
2216 2220 2003-08-14 Fernando Perez <fperez@colorado.edu>
2217 2221
2218 2222 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2219 2223 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2220 2224 but it should be quite a bit faster. And the recursive version
2221 2225 generated O(log N) intermediate storage for all rank>1 arrays,
2222 2226 even if they were contiguous.
2223 2227 (l1norm): Added this function.
2224 2228 (norm): Added this function for arbitrary norms (including
2225 2229 l-infinity). l1 and l2 are still special cases for convenience
2226 2230 and speed.
2227 2231
2228 2232 2003-08-03 Fernando Perez <fperez@colorado.edu>
2229 2233
2230 2234 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2231 2235 exceptions, which now raise PendingDeprecationWarnings in Python
2232 2236 2.3. There were some in Magic and some in Gnuplot2.
2233 2237
2234 2238 2003-06-30 Fernando Perez <fperez@colorado.edu>
2235 2239
2236 2240 * IPython/genutils.py (page): modified to call curses only for
2237 2241 terminals where TERM=='xterm'. After problems under many other
2238 2242 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2239 2243
2240 2244 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2241 2245 would be triggered when readline was absent. This was just an old
2242 2246 debugging statement I'd forgotten to take out.
2243 2247
2244 2248 2003-06-20 Fernando Perez <fperez@colorado.edu>
2245 2249
2246 2250 * IPython/genutils.py (clock): modified to return only user time
2247 2251 (not counting system time), after a discussion on scipy. While
2248 2252 system time may be a useful quantity occasionally, it may much
2249 2253 more easily be skewed by occasional swapping or other similar
2250 2254 activity.
2251 2255
2252 2256 2003-06-05 Fernando Perez <fperez@colorado.edu>
2253 2257
2254 2258 * IPython/numutils.py (identity): new function, for building
2255 2259 arbitrary rank Kronecker deltas (mostly backwards compatible with
2256 2260 Numeric.identity)
2257 2261
2258 2262 2003-06-03 Fernando Perez <fperez@colorado.edu>
2259 2263
2260 2264 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2261 2265 arguments passed to magics with spaces, to allow trailing '\' to
2262 2266 work normally (mainly for Windows users).
2263 2267
2264 2268 2003-05-29 Fernando Perez <fperez@colorado.edu>
2265 2269
2266 2270 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2267 2271 instead of pydoc.help. This fixes a bizarre behavior where
2268 2272 printing '%s' % locals() would trigger the help system. Now
2269 2273 ipython behaves like normal python does.
2270 2274
2271 2275 Note that if one does 'from pydoc import help', the bizarre
2272 2276 behavior returns, but this will also happen in normal python, so
2273 2277 it's not an ipython bug anymore (it has to do with how pydoc.help
2274 2278 is implemented).
2275 2279
2276 2280 2003-05-22 Fernando Perez <fperez@colorado.edu>
2277 2281
2278 2282 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2279 2283 return [] instead of None when nothing matches, also match to end
2280 2284 of line. Patch by Gary Bishop.
2281 2285
2282 2286 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2283 2287 protection as before, for files passed on the command line. This
2284 2288 prevents the CrashHandler from kicking in if user files call into
2285 2289 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2286 2290 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2287 2291
2288 2292 2003-05-20 *** Released version 0.4.0
2289 2293
2290 2294 2003-05-20 Fernando Perez <fperez@colorado.edu>
2291 2295
2292 2296 * setup.py: added support for manpages. It's a bit hackish b/c of
2293 2297 a bug in the way the bdist_rpm distutils target handles gzipped
2294 2298 manpages, but it works. After a patch by Jack.
2295 2299
2296 2300 2003-05-19 Fernando Perez <fperez@colorado.edu>
2297 2301
2298 2302 * IPython/numutils.py: added a mockup of the kinds module, since
2299 2303 it was recently removed from Numeric. This way, numutils will
2300 2304 work for all users even if they are missing kinds.
2301 2305
2302 2306 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2303 2307 failure, which can occur with SWIG-wrapped extensions. After a
2304 2308 crash report from Prabhu.
2305 2309
2306 2310 2003-05-16 Fernando Perez <fperez@colorado.edu>
2307 2311
2308 2312 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2309 2313 protect ipython from user code which may call directly
2310 2314 sys.excepthook (this looks like an ipython crash to the user, even
2311 2315 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2312 2316 This is especially important to help users of WxWindows, but may
2313 2317 also be useful in other cases.
2314 2318
2315 2319 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2316 2320 an optional tb_offset to be specified, and to preserve exception
2317 2321 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2318 2322
2319 2323 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2320 2324
2321 2325 2003-05-15 Fernando Perez <fperez@colorado.edu>
2322 2326
2323 2327 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2324 2328 installing for a new user under Windows.
2325 2329
2326 2330 2003-05-12 Fernando Perez <fperez@colorado.edu>
2327 2331
2328 2332 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2329 2333 handler for Emacs comint-based lines. Currently it doesn't do
2330 2334 much (but importantly, it doesn't update the history cache). In
2331 2335 the future it may be expanded if Alex needs more functionality
2332 2336 there.
2333 2337
2334 2338 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2335 2339 info to crash reports.
2336 2340
2337 2341 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2338 2342 just like Python's -c. Also fixed crash with invalid -color
2339 2343 option value at startup. Thanks to Will French
2340 2344 <wfrench-AT-bestweb.net> for the bug report.
2341 2345
2342 2346 2003-05-09 Fernando Perez <fperez@colorado.edu>
2343 2347
2344 2348 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2345 2349 to EvalDict (it's a mapping, after all) and simplified its code
2346 2350 quite a bit, after a nice discussion on c.l.py where Gustavo
2347 2351 Córdova <gcordova-AT-sismex.com> suggested the new version.
2348 2352
2349 2353 2003-04-30 Fernando Perez <fperez@colorado.edu>
2350 2354
2351 2355 * IPython/genutils.py (timings_out): modified it to reduce its
2352 2356 overhead in the common reps==1 case.
2353 2357
2354 2358 2003-04-29 Fernando Perez <fperez@colorado.edu>
2355 2359
2356 2360 * IPython/genutils.py (timings_out): Modified to use the resource
2357 2361 module, which avoids the wraparound problems of time.clock().
2358 2362
2359 2363 2003-04-17 *** Released version 0.2.15pre4
2360 2364
2361 2365 2003-04-17 Fernando Perez <fperez@colorado.edu>
2362 2366
2363 2367 * setup.py (scriptfiles): Split windows-specific stuff over to a
2364 2368 separate file, in an attempt to have a Windows GUI installer.
2365 2369 That didn't work, but part of the groundwork is done.
2366 2370
2367 2371 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2368 2372 indent/unindent with 4 spaces. Particularly useful in combination
2369 2373 with the new auto-indent option.
2370 2374
2371 2375 2003-04-16 Fernando Perez <fperez@colorado.edu>
2372 2376
2373 2377 * IPython/Magic.py: various replacements of self.rc for
2374 2378 self.shell.rc. A lot more remains to be done to fully disentangle
2375 2379 this class from the main Shell class.
2376 2380
2377 2381 * IPython/GnuplotRuntime.py: added checks for mouse support so
2378 2382 that we don't try to enable it if the current gnuplot doesn't
2379 2383 really support it. Also added checks so that we don't try to
2380 2384 enable persist under Windows (where Gnuplot doesn't recognize the
2381 2385 option).
2382 2386
2383 2387 * IPython/iplib.py (InteractiveShell.interact): Added optional
2384 2388 auto-indenting code, after a patch by King C. Shu
2385 2389 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2386 2390 get along well with pasting indented code. If I ever figure out
2387 2391 how to make that part go well, it will become on by default.
2388 2392
2389 2393 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2390 2394 crash ipython if there was an unmatched '%' in the user's prompt
2391 2395 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2392 2396
2393 2397 * IPython/iplib.py (InteractiveShell.interact): removed the
2394 2398 ability to ask the user whether he wants to crash or not at the
2395 2399 'last line' exception handler. Calling functions at that point
2396 2400 changes the stack, and the error reports would have incorrect
2397 2401 tracebacks.
2398 2402
2399 2403 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2400 2404 pass through a peger a pretty-printed form of any object. After a
2401 2405 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2402 2406
2403 2407 2003-04-14 Fernando Perez <fperez@colorado.edu>
2404 2408
2405 2409 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2406 2410 all files in ~ would be modified at first install (instead of
2407 2411 ~/.ipython). This could be potentially disastrous, as the
2408 2412 modification (make line-endings native) could damage binary files.
2409 2413
2410 2414 2003-04-10 Fernando Perez <fperez@colorado.edu>
2411 2415
2412 2416 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2413 2417 handle only lines which are invalid python. This now means that
2414 2418 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2415 2419 for the bug report.
2416 2420
2417 2421 2003-04-01 Fernando Perez <fperez@colorado.edu>
2418 2422
2419 2423 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2420 2424 where failing to set sys.last_traceback would crash pdb.pm().
2421 2425 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2422 2426 report.
2423 2427
2424 2428 2003-03-25 Fernando Perez <fperez@colorado.edu>
2425 2429
2426 2430 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2427 2431 before printing it (it had a lot of spurious blank lines at the
2428 2432 end).
2429 2433
2430 2434 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2431 2435 output would be sent 21 times! Obviously people don't use this
2432 2436 too often, or I would have heard about it.
2433 2437
2434 2438 2003-03-24 Fernando Perez <fperez@colorado.edu>
2435 2439
2436 2440 * setup.py (scriptfiles): renamed the data_files parameter from
2437 2441 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2438 2442 for the patch.
2439 2443
2440 2444 2003-03-20 Fernando Perez <fperez@colorado.edu>
2441 2445
2442 2446 * IPython/genutils.py (error): added error() and fatal()
2443 2447 functions.
2444 2448
2445 2449 2003-03-18 *** Released version 0.2.15pre3
2446 2450
2447 2451 2003-03-18 Fernando Perez <fperez@colorado.edu>
2448 2452
2449 2453 * setupext/install_data_ext.py
2450 2454 (install_data_ext.initialize_options): Class contributed by Jack
2451 2455 Moffit for fixing the old distutils hack. He is sending this to
2452 2456 the distutils folks so in the future we may not need it as a
2453 2457 private fix.
2454 2458
2455 2459 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2456 2460 changes for Debian packaging. See his patch for full details.
2457 2461 The old distutils hack of making the ipythonrc* files carry a
2458 2462 bogus .py extension is gone, at last. Examples were moved to a
2459 2463 separate subdir under doc/, and the separate executable scripts
2460 2464 now live in their own directory. Overall a great cleanup. The
2461 2465 manual was updated to use the new files, and setup.py has been
2462 2466 fixed for this setup.
2463 2467
2464 2468 * IPython/PyColorize.py (Parser.usage): made non-executable and
2465 2469 created a pycolor wrapper around it to be included as a script.
2466 2470
2467 2471 2003-03-12 *** Released version 0.2.15pre2
2468 2472
2469 2473 2003-03-12 Fernando Perez <fperez@colorado.edu>
2470 2474
2471 2475 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2472 2476 long-standing problem with garbage characters in some terminals.
2473 2477 The issue was really that the \001 and \002 escapes must _only_ be
2474 2478 passed to input prompts (which call readline), but _never_ to
2475 2479 normal text to be printed on screen. I changed ColorANSI to have
2476 2480 two classes: TermColors and InputTermColors, each with the
2477 2481 appropriate escapes for input prompts or normal text. The code in
2478 2482 Prompts.py got slightly more complicated, but this very old and
2479 2483 annoying bug is finally fixed.
2480 2484
2481 2485 All the credit for nailing down the real origin of this problem
2482 2486 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2483 2487 *Many* thanks to him for spending quite a bit of effort on this.
2484 2488
2485 2489 2003-03-05 *** Released version 0.2.15pre1
2486 2490
2487 2491 2003-03-03 Fernando Perez <fperez@colorado.edu>
2488 2492
2489 2493 * IPython/FakeModule.py: Moved the former _FakeModule to a
2490 2494 separate file, because it's also needed by Magic (to fix a similar
2491 2495 pickle-related issue in @run).
2492 2496
2493 2497 2003-03-02 Fernando Perez <fperez@colorado.edu>
2494 2498
2495 2499 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2496 2500 the autocall option at runtime.
2497 2501 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2498 2502 across Magic.py to start separating Magic from InteractiveShell.
2499 2503 (Magic._ofind): Fixed to return proper namespace for dotted
2500 2504 names. Before, a dotted name would always return 'not currently
2501 2505 defined', because it would find the 'parent'. s.x would be found,
2502 2506 but since 'x' isn't defined by itself, it would get confused.
2503 2507 (Magic.magic_run): Fixed pickling problems reported by Ralf
2504 2508 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2505 2509 that I'd used when Mike Heeter reported similar issues at the
2506 2510 top-level, but now for @run. It boils down to injecting the
2507 2511 namespace where code is being executed with something that looks
2508 2512 enough like a module to fool pickle.dump(). Since a pickle stores
2509 2513 a named reference to the importing module, we need this for
2510 2514 pickles to save something sensible.
2511 2515
2512 2516 * IPython/ipmaker.py (make_IPython): added an autocall option.
2513 2517
2514 2518 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2515 2519 the auto-eval code. Now autocalling is an option, and the code is
2516 2520 also vastly safer. There is no more eval() involved at all.
2517 2521
2518 2522 2003-03-01 Fernando Perez <fperez@colorado.edu>
2519 2523
2520 2524 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2521 2525 dict with named keys instead of a tuple.
2522 2526
2523 2527 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2524 2528
2525 2529 * setup.py (make_shortcut): Fixed message about directories
2526 2530 created during Windows installation (the directories were ok, just
2527 2531 the printed message was misleading). Thanks to Chris Liechti
2528 2532 <cliechti-AT-gmx.net> for the heads up.
2529 2533
2530 2534 2003-02-21 Fernando Perez <fperez@colorado.edu>
2531 2535
2532 2536 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2533 2537 of ValueError exception when checking for auto-execution. This
2534 2538 one is raised by things like Numeric arrays arr.flat when the
2535 2539 array is non-contiguous.
2536 2540
2537 2541 2003-01-31 Fernando Perez <fperez@colorado.edu>
2538 2542
2539 2543 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2540 2544 not return any value at all (even though the command would get
2541 2545 executed).
2542 2546 (xsys): Flush stdout right after printing the command to ensure
2543 2547 proper ordering of commands and command output in the total
2544 2548 output.
2545 2549 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2546 2550 system/getoutput as defaults. The old ones are kept for
2547 2551 compatibility reasons, so no code which uses this library needs
2548 2552 changing.
2549 2553
2550 2554 2003-01-27 *** Released version 0.2.14
2551 2555
2552 2556 2003-01-25 Fernando Perez <fperez@colorado.edu>
2553 2557
2554 2558 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2555 2559 functions defined in previous edit sessions could not be re-edited
2556 2560 (because the temp files were immediately removed). Now temp files
2557 2561 are removed only at IPython's exit.
2558 2562 (Magic.magic_run): Improved @run to perform shell-like expansions
2559 2563 on its arguments (~users and $VARS). With this, @run becomes more
2560 2564 like a normal command-line.
2561 2565
2562 2566 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2563 2567 bugs related to embedding and cleaned up that code. A fairly
2564 2568 important one was the impossibility to access the global namespace
2565 2569 through the embedded IPython (only local variables were visible).
2566 2570
2567 2571 2003-01-14 Fernando Perez <fperez@colorado.edu>
2568 2572
2569 2573 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2570 2574 auto-calling to be a bit more conservative. Now it doesn't get
2571 2575 triggered if any of '!=()<>' are in the rest of the input line, to
2572 2576 allow comparing callables. Thanks to Alex for the heads up.
2573 2577
2574 2578 2003-01-07 Fernando Perez <fperez@colorado.edu>
2575 2579
2576 2580 * IPython/genutils.py (page): fixed estimation of the number of
2577 2581 lines in a string to be paged to simply count newlines. This
2578 2582 prevents over-guessing due to embedded escape sequences. A better
2579 2583 long-term solution would involve stripping out the control chars
2580 2584 for the count, but it's potentially so expensive I just don't
2581 2585 think it's worth doing.
2582 2586
2583 2587 2002-12-19 *** Released version 0.2.14pre50
2584 2588
2585 2589 2002-12-19 Fernando Perez <fperez@colorado.edu>
2586 2590
2587 2591 * tools/release (version): Changed release scripts to inform
2588 2592 Andrea and build a NEWS file with a list of recent changes.
2589 2593
2590 2594 * IPython/ColorANSI.py (__all__): changed terminal detection
2591 2595 code. Seems to work better for xterms without breaking
2592 2596 konsole. Will need more testing to determine if WinXP and Mac OSX
2593 2597 also work ok.
2594 2598
2595 2599 2002-12-18 *** Released version 0.2.14pre49
2596 2600
2597 2601 2002-12-18 Fernando Perez <fperez@colorado.edu>
2598 2602
2599 2603 * Docs: added new info about Mac OSX, from Andrea.
2600 2604
2601 2605 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2602 2606 allow direct plotting of python strings whose format is the same
2603 2607 of gnuplot data files.
2604 2608
2605 2609 2002-12-16 Fernando Perez <fperez@colorado.edu>
2606 2610
2607 2611 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2608 2612 value of exit question to be acknowledged.
2609 2613
2610 2614 2002-12-03 Fernando Perez <fperez@colorado.edu>
2611 2615
2612 2616 * IPython/ipmaker.py: removed generators, which had been added
2613 2617 by mistake in an earlier debugging run. This was causing trouble
2614 2618 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2615 2619 for pointing this out.
2616 2620
2617 2621 2002-11-17 Fernando Perez <fperez@colorado.edu>
2618 2622
2619 2623 * Manual: updated the Gnuplot section.
2620 2624
2621 2625 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2622 2626 a much better split of what goes in Runtime and what goes in
2623 2627 Interactive.
2624 2628
2625 2629 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2626 2630 being imported from iplib.
2627 2631
2628 2632 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2629 2633 for command-passing. Now the global Gnuplot instance is called
2630 2634 'gp' instead of 'g', which was really a far too fragile and
2631 2635 common name.
2632 2636
2633 2637 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2634 2638 bounding boxes generated by Gnuplot for square plots.
2635 2639
2636 2640 * IPython/genutils.py (popkey): new function added. I should
2637 2641 suggest this on c.l.py as a dict method, it seems useful.
2638 2642
2639 2643 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2640 2644 to transparently handle PostScript generation. MUCH better than
2641 2645 the previous plot_eps/replot_eps (which I removed now). The code
2642 2646 is also fairly clean and well documented now (including
2643 2647 docstrings).
2644 2648
2645 2649 2002-11-13 Fernando Perez <fperez@colorado.edu>
2646 2650
2647 2651 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2648 2652 (inconsistent with options).
2649 2653
2650 2654 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2651 2655 manually disabled, I don't know why. Fixed it.
2652 2656 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2653 2657 eps output.
2654 2658
2655 2659 2002-11-12 Fernando Perez <fperez@colorado.edu>
2656 2660
2657 2661 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2658 2662 don't propagate up to caller. Fixes crash reported by François
2659 2663 Pinard.
2660 2664
2661 2665 2002-11-09 Fernando Perez <fperez@colorado.edu>
2662 2666
2663 2667 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2664 2668 history file for new users.
2665 2669 (make_IPython): fixed bug where initial install would leave the
2666 2670 user running in the .ipython dir.
2667 2671 (make_IPython): fixed bug where config dir .ipython would be
2668 2672 created regardless of the given -ipythondir option. Thanks to Cory
2669 2673 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2670 2674
2671 2675 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2672 2676 type confirmations. Will need to use it in all of IPython's code
2673 2677 consistently.
2674 2678
2675 2679 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2676 2680 context to print 31 lines instead of the default 5. This will make
2677 2681 the crash reports extremely detailed in case the problem is in
2678 2682 libraries I don't have access to.
2679 2683
2680 2684 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2681 2685 line of defense' code to still crash, but giving users fair
2682 2686 warning. I don't want internal errors to go unreported: if there's
2683 2687 an internal problem, IPython should crash and generate a full
2684 2688 report.
2685 2689
2686 2690 2002-11-08 Fernando Perez <fperez@colorado.edu>
2687 2691
2688 2692 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2689 2693 otherwise uncaught exceptions which can appear if people set
2690 2694 sys.stdout to something badly broken. Thanks to a crash report
2691 2695 from henni-AT-mail.brainbot.com.
2692 2696
2693 2697 2002-11-04 Fernando Perez <fperez@colorado.edu>
2694 2698
2695 2699 * IPython/iplib.py (InteractiveShell.interact): added
2696 2700 __IPYTHON__active to the builtins. It's a flag which goes on when
2697 2701 the interaction starts and goes off again when it stops. This
2698 2702 allows embedding code to detect being inside IPython. Before this
2699 2703 was done via __IPYTHON__, but that only shows that an IPython
2700 2704 instance has been created.
2701 2705
2702 2706 * IPython/Magic.py (Magic.magic_env): I realized that in a
2703 2707 UserDict, instance.data holds the data as a normal dict. So I
2704 2708 modified @env to return os.environ.data instead of rebuilding a
2705 2709 dict by hand.
2706 2710
2707 2711 2002-11-02 Fernando Perez <fperez@colorado.edu>
2708 2712
2709 2713 * IPython/genutils.py (warn): changed so that level 1 prints no
2710 2714 header. Level 2 is now the default (with 'WARNING' header, as
2711 2715 before). I think I tracked all places where changes were needed in
2712 2716 IPython, but outside code using the old level numbering may have
2713 2717 broken.
2714 2718
2715 2719 * IPython/iplib.py (InteractiveShell.runcode): added this to
2716 2720 handle the tracebacks in SystemExit traps correctly. The previous
2717 2721 code (through interact) was printing more of the stack than
2718 2722 necessary, showing IPython internal code to the user.
2719 2723
2720 2724 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2721 2725 default. Now that the default at the confirmation prompt is yes,
2722 2726 it's not so intrusive. François' argument that ipython sessions
2723 2727 tend to be complex enough not to lose them from an accidental C-d,
2724 2728 is a valid one.
2725 2729
2726 2730 * IPython/iplib.py (InteractiveShell.interact): added a
2727 2731 showtraceback() call to the SystemExit trap, and modified the exit
2728 2732 confirmation to have yes as the default.
2729 2733
2730 2734 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2731 2735 this file. It's been gone from the code for a long time, this was
2732 2736 simply leftover junk.
2733 2737
2734 2738 2002-11-01 Fernando Perez <fperez@colorado.edu>
2735 2739
2736 2740 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2737 2741 added. If set, IPython now traps EOF and asks for
2738 2742 confirmation. After a request by François Pinard.
2739 2743
2740 2744 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2741 2745 of @abort, and with a new (better) mechanism for handling the
2742 2746 exceptions.
2743 2747
2744 2748 2002-10-27 Fernando Perez <fperez@colorado.edu>
2745 2749
2746 2750 * IPython/usage.py (__doc__): updated the --help information and
2747 2751 the ipythonrc file to indicate that -log generates
2748 2752 ./ipython.log. Also fixed the corresponding info in @logstart.
2749 2753 This and several other fixes in the manuals thanks to reports by
2750 2754 François Pinard <pinard-AT-iro.umontreal.ca>.
2751 2755
2752 2756 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2753 2757 refer to @logstart (instead of @log, which doesn't exist).
2754 2758
2755 2759 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2756 2760 AttributeError crash. Thanks to Christopher Armstrong
2757 2761 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2758 2762 introduced recently (in 0.2.14pre37) with the fix to the eval
2759 2763 problem mentioned below.
2760 2764
2761 2765 2002-10-17 Fernando Perez <fperez@colorado.edu>
2762 2766
2763 2767 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2764 2768 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2765 2769
2766 2770 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2767 2771 this function to fix a problem reported by Alex Schmolck. He saw
2768 2772 it with list comprehensions and generators, which were getting
2769 2773 called twice. The real problem was an 'eval' call in testing for
2770 2774 automagic which was evaluating the input line silently.
2771 2775
2772 2776 This is a potentially very nasty bug, if the input has side
2773 2777 effects which must not be repeated. The code is much cleaner now,
2774 2778 without any blanket 'except' left and with a regexp test for
2775 2779 actual function names.
2776 2780
2777 2781 But an eval remains, which I'm not fully comfortable with. I just
2778 2782 don't know how to find out if an expression could be a callable in
2779 2783 the user's namespace without doing an eval on the string. However
2780 2784 that string is now much more strictly checked so that no code
2781 2785 slips by, so the eval should only happen for things that can
2782 2786 really be only function/method names.
2783 2787
2784 2788 2002-10-15 Fernando Perez <fperez@colorado.edu>
2785 2789
2786 2790 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2787 2791 OSX information to main manual, removed README_Mac_OSX file from
2788 2792 distribution. Also updated credits for recent additions.
2789 2793
2790 2794 2002-10-10 Fernando Perez <fperez@colorado.edu>
2791 2795
2792 2796 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2793 2797 terminal-related issues. Many thanks to Andrea Riciputi
2794 2798 <andrea.riciputi-AT-libero.it> for writing it.
2795 2799
2796 2800 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2797 2801 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2798 2802
2799 2803 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2800 2804 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2801 2805 <syver-en-AT-online.no> who both submitted patches for this problem.
2802 2806
2803 2807 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2804 2808 global embedding to make sure that things don't overwrite user
2805 2809 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2806 2810
2807 2811 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2808 2812 compatibility. Thanks to Hayden Callow
2809 2813 <h.callow-AT-elec.canterbury.ac.nz>
2810 2814
2811 2815 2002-10-04 Fernando Perez <fperez@colorado.edu>
2812 2816
2813 2817 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
2814 2818 Gnuplot.File objects.
2815 2819
2816 2820 2002-07-23 Fernando Perez <fperez@colorado.edu>
2817 2821
2818 2822 * IPython/genutils.py (timing): Added timings() and timing() for
2819 2823 quick access to the most commonly needed data, the execution
2820 2824 times. Old timing() renamed to timings_out().
2821 2825
2822 2826 2002-07-18 Fernando Perez <fperez@colorado.edu>
2823 2827
2824 2828 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
2825 2829 bug with nested instances disrupting the parent's tab completion.
2826 2830
2827 2831 * IPython/iplib.py (all_completions): Added Alex Schmolck's
2828 2832 all_completions code to begin the emacs integration.
2829 2833
2830 2834 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
2831 2835 argument to allow titling individual arrays when plotting.
2832 2836
2833 2837 2002-07-15 Fernando Perez <fperez@colorado.edu>
2834 2838
2835 2839 * setup.py (make_shortcut): changed to retrieve the value of
2836 2840 'Program Files' directory from the registry (this value changes in
2837 2841 non-english versions of Windows). Thanks to Thomas Fanslau
2838 2842 <tfanslau-AT-gmx.de> for the report.
2839 2843
2840 2844 2002-07-10 Fernando Perez <fperez@colorado.edu>
2841 2845
2842 2846 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
2843 2847 a bug in pdb, which crashes if a line with only whitespace is
2844 2848 entered. Bug report submitted to sourceforge.
2845 2849
2846 2850 2002-07-09 Fernando Perez <fperez@colorado.edu>
2847 2851
2848 2852 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
2849 2853 reporting exceptions (it's a bug in inspect.py, I just set a
2850 2854 workaround).
2851 2855
2852 2856 2002-07-08 Fernando Perez <fperez@colorado.edu>
2853 2857
2854 2858 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
2855 2859 __IPYTHON__ in __builtins__ to show up in user_ns.
2856 2860
2857 2861 2002-07-03 Fernando Perez <fperez@colorado.edu>
2858 2862
2859 2863 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
2860 2864 name from @gp_set_instance to @gp_set_default.
2861 2865
2862 2866 * IPython/ipmaker.py (make_IPython): default editor value set to
2863 2867 '0' (a string), to match the rc file. Otherwise will crash when
2864 2868 .strip() is called on it.
2865 2869
2866 2870
2867 2871 2002-06-28 Fernando Perez <fperez@colorado.edu>
2868 2872
2869 2873 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
2870 2874 of files in current directory when a file is executed via
2871 2875 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
2872 2876
2873 2877 * setup.py (manfiles): fix for rpm builds, submitted by RA
2874 2878 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
2875 2879
2876 2880 * IPython/ipmaker.py (make_IPython): fixed lookup of default
2877 2881 editor when set to '0'. Problem was, '0' evaluates to True (it's a
2878 2882 string!). A. Schmolck caught this one.
2879 2883
2880 2884 2002-06-27 Fernando Perez <fperez@colorado.edu>
2881 2885
2882 2886 * IPython/ipmaker.py (make_IPython): fixed bug when running user
2883 2887 defined files at the cmd line. __name__ wasn't being set to
2884 2888 __main__.
2885 2889
2886 2890 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
2887 2891 regular lists and tuples besides Numeric arrays.
2888 2892
2889 2893 * IPython/Prompts.py (CachedOutput.__call__): Added output
2890 2894 supression for input ending with ';'. Similar to Mathematica and
2891 2895 Matlab. The _* vars and Out[] list are still updated, just like
2892 2896 Mathematica behaves.
2893 2897
2894 2898 2002-06-25 Fernando Perez <fperez@colorado.edu>
2895 2899
2896 2900 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
2897 2901 .ini extensions for profiels under Windows.
2898 2902
2899 2903 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
2900 2904 string form. Fix contributed by Alexander Schmolck
2901 2905 <a.schmolck-AT-gmx.net>
2902 2906
2903 2907 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
2904 2908 pre-configured Gnuplot instance.
2905 2909
2906 2910 2002-06-21 Fernando Perez <fperez@colorado.edu>
2907 2911
2908 2912 * IPython/numutils.py (exp_safe): new function, works around the
2909 2913 underflow problems in Numeric.
2910 2914 (log2): New fn. Safe log in base 2: returns exact integer answer
2911 2915 for exact integer powers of 2.
2912 2916
2913 2917 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
2914 2918 properly.
2915 2919
2916 2920 2002-06-20 Fernando Perez <fperez@colorado.edu>
2917 2921
2918 2922 * IPython/genutils.py (timing): new function like
2919 2923 Mathematica's. Similar to time_test, but returns more info.
2920 2924
2921 2925 2002-06-18 Fernando Perez <fperez@colorado.edu>
2922 2926
2923 2927 * IPython/Magic.py (Magic.magic_save): modified @save and @r
2924 2928 according to Mike Heeter's suggestions.
2925 2929
2926 2930 2002-06-16 Fernando Perez <fperez@colorado.edu>
2927 2931
2928 2932 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
2929 2933 system. GnuplotMagic is gone as a user-directory option. New files
2930 2934 make it easier to use all the gnuplot stuff both from external
2931 2935 programs as well as from IPython. Had to rewrite part of
2932 2936 hardcopy() b/c of a strange bug: often the ps files simply don't
2933 2937 get created, and require a repeat of the command (often several
2934 2938 times).
2935 2939
2936 2940 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
2937 2941 resolve output channel at call time, so that if sys.stderr has
2938 2942 been redirected by user this gets honored.
2939 2943
2940 2944 2002-06-13 Fernando Perez <fperez@colorado.edu>
2941 2945
2942 2946 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
2943 2947 IPShell. Kept a copy with the old names to avoid breaking people's
2944 2948 embedded code.
2945 2949
2946 2950 * IPython/ipython: simplified it to the bare minimum after
2947 2951 Holger's suggestions. Added info about how to use it in
2948 2952 PYTHONSTARTUP.
2949 2953
2950 2954 * IPython/Shell.py (IPythonShell): changed the options passing
2951 2955 from a string with funky %s replacements to a straight list. Maybe
2952 2956 a bit more typing, but it follows sys.argv conventions, so there's
2953 2957 less special-casing to remember.
2954 2958
2955 2959 2002-06-12 Fernando Perez <fperez@colorado.edu>
2956 2960
2957 2961 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
2958 2962 command. Thanks to a suggestion by Mike Heeter.
2959 2963 (Magic.magic_pfile): added behavior to look at filenames if given
2960 2964 arg is not a defined object.
2961 2965 (Magic.magic_save): New @save function to save code snippets. Also
2962 2966 a Mike Heeter idea.
2963 2967
2964 2968 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
2965 2969 plot() and replot(). Much more convenient now, especially for
2966 2970 interactive use.
2967 2971
2968 2972 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
2969 2973 filenames.
2970 2974
2971 2975 2002-06-02 Fernando Perez <fperez@colorado.edu>
2972 2976
2973 2977 * IPython/Struct.py (Struct.__init__): modified to admit
2974 2978 initialization via another struct.
2975 2979
2976 2980 * IPython/genutils.py (SystemExec.__init__): New stateful
2977 2981 interface to xsys and bq. Useful for writing system scripts.
2978 2982
2979 2983 2002-05-30 Fernando Perez <fperez@colorado.edu>
2980 2984
2981 2985 * MANIFEST.in: Changed docfile selection to exclude all the lyx
2982 2986 documents. This will make the user download smaller (it's getting
2983 2987 too big).
2984 2988
2985 2989 2002-05-29 Fernando Perez <fperez@colorado.edu>
2986 2990
2987 2991 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
2988 2992 fix problems with shelve and pickle. Seems to work, but I don't
2989 2993 know if corner cases break it. Thanks to Mike Heeter
2990 2994 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
2991 2995
2992 2996 2002-05-24 Fernando Perez <fperez@colorado.edu>
2993 2997
2994 2998 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
2995 2999 macros having broken.
2996 3000
2997 3001 2002-05-21 Fernando Perez <fperez@colorado.edu>
2998 3002
2999 3003 * IPython/Magic.py (Magic.magic_logstart): fixed recently
3000 3004 introduced logging bug: all history before logging started was
3001 3005 being written one character per line! This came from the redesign
3002 3006 of the input history as a special list which slices to strings,
3003 3007 not to lists.
3004 3008
3005 3009 2002-05-20 Fernando Perez <fperez@colorado.edu>
3006 3010
3007 3011 * IPython/Prompts.py (CachedOutput.__init__): made the color table
3008 3012 be an attribute of all classes in this module. The design of these
3009 3013 classes needs some serious overhauling.
3010 3014
3011 3015 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
3012 3016 which was ignoring '_' in option names.
3013 3017
3014 3018 * IPython/ultraTB.py (FormattedTB.__init__): Changed
3015 3019 'Verbose_novars' to 'Context' and made it the new default. It's a
3016 3020 bit more readable and also safer than verbose.
3017 3021
3018 3022 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
3019 3023 triple-quoted strings.
3020 3024
3021 3025 * IPython/OInspect.py (__all__): new module exposing the object
3022 3026 introspection facilities. Now the corresponding magics are dummy
3023 3027 wrappers around this. Having this module will make it much easier
3024 3028 to put these functions into our modified pdb.
3025 3029 This new object inspector system uses the new colorizing module,
3026 3030 so source code and other things are nicely syntax highlighted.
3027 3031
3028 3032 2002-05-18 Fernando Perez <fperez@colorado.edu>
3029 3033
3030 3034 * IPython/ColorANSI.py: Split the coloring tools into a separate
3031 3035 module so I can use them in other code easier (they were part of
3032 3036 ultraTB).
3033 3037
3034 3038 2002-05-17 Fernando Perez <fperez@colorado.edu>
3035 3039
3036 3040 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3037 3041 fixed it to set the global 'g' also to the called instance, as
3038 3042 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3039 3043 user's 'g' variables).
3040 3044
3041 3045 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3042 3046 global variables (aliases to _ih,_oh) so that users which expect
3043 3047 In[5] or Out[7] to work aren't unpleasantly surprised.
3044 3048 (InputList.__getslice__): new class to allow executing slices of
3045 3049 input history directly. Very simple class, complements the use of
3046 3050 macros.
3047 3051
3048 3052 2002-05-16 Fernando Perez <fperez@colorado.edu>
3049 3053
3050 3054 * setup.py (docdirbase): make doc directory be just doc/IPython
3051 3055 without version numbers, it will reduce clutter for users.
3052 3056
3053 3057 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3054 3058 execfile call to prevent possible memory leak. See for details:
3055 3059 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3056 3060
3057 3061 2002-05-15 Fernando Perez <fperez@colorado.edu>
3058 3062
3059 3063 * IPython/Magic.py (Magic.magic_psource): made the object
3060 3064 introspection names be more standard: pdoc, pdef, pfile and
3061 3065 psource. They all print/page their output, and it makes
3062 3066 remembering them easier. Kept old names for compatibility as
3063 3067 aliases.
3064 3068
3065 3069 2002-05-14 Fernando Perez <fperez@colorado.edu>
3066 3070
3067 3071 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3068 3072 what the mouse problem was. The trick is to use gnuplot with temp
3069 3073 files and NOT with pipes (for data communication), because having
3070 3074 both pipes and the mouse on is bad news.
3071 3075
3072 3076 2002-05-13 Fernando Perez <fperez@colorado.edu>
3073 3077
3074 3078 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3075 3079 bug. Information would be reported about builtins even when
3076 3080 user-defined functions overrode them.
3077 3081
3078 3082 2002-05-11 Fernando Perez <fperez@colorado.edu>
3079 3083
3080 3084 * IPython/__init__.py (__all__): removed FlexCompleter from
3081 3085 __all__ so that things don't fail in platforms without readline.
3082 3086
3083 3087 2002-05-10 Fernando Perez <fperez@colorado.edu>
3084 3088
3085 3089 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3086 3090 it requires Numeric, effectively making Numeric a dependency for
3087 3091 IPython.
3088 3092
3089 3093 * Released 0.2.13
3090 3094
3091 3095 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3092 3096 profiler interface. Now all the major options from the profiler
3093 3097 module are directly supported in IPython, both for single
3094 3098 expressions (@prun) and for full programs (@run -p).
3095 3099
3096 3100 2002-05-09 Fernando Perez <fperez@colorado.edu>
3097 3101
3098 3102 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3099 3103 magic properly formatted for screen.
3100 3104
3101 3105 * setup.py (make_shortcut): Changed things to put pdf version in
3102 3106 doc/ instead of doc/manual (had to change lyxport a bit).
3103 3107
3104 3108 * IPython/Magic.py (Profile.string_stats): made profile runs go
3105 3109 through pager (they are long and a pager allows searching, saving,
3106 3110 etc.)
3107 3111
3108 3112 2002-05-08 Fernando Perez <fperez@colorado.edu>
3109 3113
3110 3114 * Released 0.2.12
3111 3115
3112 3116 2002-05-06 Fernando Perez <fperez@colorado.edu>
3113 3117
3114 3118 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3115 3119 introduced); 'hist n1 n2' was broken.
3116 3120 (Magic.magic_pdb): added optional on/off arguments to @pdb
3117 3121 (Magic.magic_run): added option -i to @run, which executes code in
3118 3122 the IPython namespace instead of a clean one. Also added @irun as
3119 3123 an alias to @run -i.
3120 3124
3121 3125 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3122 3126 fixed (it didn't really do anything, the namespaces were wrong).
3123 3127
3124 3128 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3125 3129
3126 3130 * IPython/__init__.py (__all__): Fixed package namespace, now
3127 3131 'import IPython' does give access to IPython.<all> as
3128 3132 expected. Also renamed __release__ to Release.
3129 3133
3130 3134 * IPython/Debugger.py (__license__): created new Pdb class which
3131 3135 functions like a drop-in for the normal pdb.Pdb but does NOT
3132 3136 import readline by default. This way it doesn't muck up IPython's
3133 3137 readline handling, and now tab-completion finally works in the
3134 3138 debugger -- sort of. It completes things globally visible, but the
3135 3139 completer doesn't track the stack as pdb walks it. That's a bit
3136 3140 tricky, and I'll have to implement it later.
3137 3141
3138 3142 2002-05-05 Fernando Perez <fperez@colorado.edu>
3139 3143
3140 3144 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3141 3145 magic docstrings when printed via ? (explicit \'s were being
3142 3146 printed).
3143 3147
3144 3148 * IPython/ipmaker.py (make_IPython): fixed namespace
3145 3149 identification bug. Now variables loaded via logs or command-line
3146 3150 files are recognized in the interactive namespace by @who.
3147 3151
3148 3152 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3149 3153 log replay system stemming from the string form of Structs.
3150 3154
3151 3155 * IPython/Magic.py (Macro.__init__): improved macros to properly
3152 3156 handle magic commands in them.
3153 3157 (Magic.magic_logstart): usernames are now expanded so 'logstart
3154 3158 ~/mylog' now works.
3155 3159
3156 3160 * IPython/iplib.py (complete): fixed bug where paths starting with
3157 3161 '/' would be completed as magic names.
3158 3162
3159 3163 2002-05-04 Fernando Perez <fperez@colorado.edu>
3160 3164
3161 3165 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3162 3166 allow running full programs under the profiler's control.
3163 3167
3164 3168 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3165 3169 mode to report exceptions verbosely but without formatting
3166 3170 variables. This addresses the issue of ipython 'freezing' (it's
3167 3171 not frozen, but caught in an expensive formatting loop) when huge
3168 3172 variables are in the context of an exception.
3169 3173 (VerboseTB.text): Added '--->' markers at line where exception was
3170 3174 triggered. Much clearer to read, especially in NoColor modes.
3171 3175
3172 3176 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3173 3177 implemented in reverse when changing to the new parse_options().
3174 3178
3175 3179 2002-05-03 Fernando Perez <fperez@colorado.edu>
3176 3180
3177 3181 * IPython/Magic.py (Magic.parse_options): new function so that
3178 3182 magics can parse options easier.
3179 3183 (Magic.magic_prun): new function similar to profile.run(),
3180 3184 suggested by Chris Hart.
3181 3185 (Magic.magic_cd): fixed behavior so that it only changes if
3182 3186 directory actually is in history.
3183 3187
3184 3188 * IPython/usage.py (__doc__): added information about potential
3185 3189 slowness of Verbose exception mode when there are huge data
3186 3190 structures to be formatted (thanks to Archie Paulson).
3187 3191
3188 3192 * IPython/ipmaker.py (make_IPython): Changed default logging
3189 3193 (when simply called with -log) to use curr_dir/ipython.log in
3190 3194 rotate mode. Fixed crash which was occuring with -log before
3191 3195 (thanks to Jim Boyle).
3192 3196
3193 3197 2002-05-01 Fernando Perez <fperez@colorado.edu>
3194 3198
3195 3199 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3196 3200 was nasty -- though somewhat of a corner case).
3197 3201
3198 3202 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3199 3203 text (was a bug).
3200 3204
3201 3205 2002-04-30 Fernando Perez <fperez@colorado.edu>
3202 3206
3203 3207 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3204 3208 a print after ^D or ^C from the user so that the In[] prompt
3205 3209 doesn't over-run the gnuplot one.
3206 3210
3207 3211 2002-04-29 Fernando Perez <fperez@colorado.edu>
3208 3212
3209 3213 * Released 0.2.10
3210 3214
3211 3215 * IPython/__release__.py (version): get date dynamically.
3212 3216
3213 3217 * Misc. documentation updates thanks to Arnd's comments. Also ran
3214 3218 a full spellcheck on the manual (hadn't been done in a while).
3215 3219
3216 3220 2002-04-27 Fernando Perez <fperez@colorado.edu>
3217 3221
3218 3222 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3219 3223 starting a log in mid-session would reset the input history list.
3220 3224
3221 3225 2002-04-26 Fernando Perez <fperez@colorado.edu>
3222 3226
3223 3227 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3224 3228 all files were being included in an update. Now anything in
3225 3229 UserConfig that matches [A-Za-z]*.py will go (this excludes
3226 3230 __init__.py)
3227 3231
3228 3232 2002-04-25 Fernando Perez <fperez@colorado.edu>
3229 3233
3230 3234 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3231 3235 to __builtins__ so that any form of embedded or imported code can
3232 3236 test for being inside IPython.
3233 3237
3234 3238 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3235 3239 changed to GnuplotMagic because it's now an importable module,
3236 3240 this makes the name follow that of the standard Gnuplot module.
3237 3241 GnuplotMagic can now be loaded at any time in mid-session.
3238 3242
3239 3243 2002-04-24 Fernando Perez <fperez@colorado.edu>
3240 3244
3241 3245 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3242 3246 the globals (IPython has its own namespace) and the
3243 3247 PhysicalQuantity stuff is much better anyway.
3244 3248
3245 3249 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3246 3250 embedding example to standard user directory for
3247 3251 distribution. Also put it in the manual.
3248 3252
3249 3253 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3250 3254 instance as first argument (so it doesn't rely on some obscure
3251 3255 hidden global).
3252 3256
3253 3257 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3254 3258 delimiters. While it prevents ().TAB from working, it allows
3255 3259 completions in open (... expressions. This is by far a more common
3256 3260 case.
3257 3261
3258 3262 2002-04-23 Fernando Perez <fperez@colorado.edu>
3259 3263
3260 3264 * IPython/Extensions/InterpreterPasteInput.py: new
3261 3265 syntax-processing module for pasting lines with >>> or ... at the
3262 3266 start.
3263 3267
3264 3268 * IPython/Extensions/PhysicalQ_Interactive.py
3265 3269 (PhysicalQuantityInteractive.__int__): fixed to work with either
3266 3270 Numeric or math.
3267 3271
3268 3272 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3269 3273 provided profiles. Now we have:
3270 3274 -math -> math module as * and cmath with its own namespace.
3271 3275 -numeric -> Numeric as *, plus gnuplot & grace
3272 3276 -physics -> same as before
3273 3277
3274 3278 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3275 3279 user-defined magics wouldn't be found by @magic if they were
3276 3280 defined as class methods. Also cleaned up the namespace search
3277 3281 logic and the string building (to use %s instead of many repeated
3278 3282 string adds).
3279 3283
3280 3284 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3281 3285 of user-defined magics to operate with class methods (cleaner, in
3282 3286 line with the gnuplot code).
3283 3287
3284 3288 2002-04-22 Fernando Perez <fperez@colorado.edu>
3285 3289
3286 3290 * setup.py: updated dependency list so that manual is updated when
3287 3291 all included files change.
3288 3292
3289 3293 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3290 3294 the delimiter removal option (the fix is ugly right now).
3291 3295
3292 3296 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3293 3297 all of the math profile (quicker loading, no conflict between
3294 3298 g-9.8 and g-gnuplot).
3295 3299
3296 3300 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3297 3301 name of post-mortem files to IPython_crash_report.txt.
3298 3302
3299 3303 * Cleanup/update of the docs. Added all the new readline info and
3300 3304 formatted all lists as 'real lists'.
3301 3305
3302 3306 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3303 3307 tab-completion options, since the full readline parse_and_bind is
3304 3308 now accessible.
3305 3309
3306 3310 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3307 3311 handling of readline options. Now users can specify any string to
3308 3312 be passed to parse_and_bind(), as well as the delimiters to be
3309 3313 removed.
3310 3314 (InteractiveShell.__init__): Added __name__ to the global
3311 3315 namespace so that things like Itpl which rely on its existence
3312 3316 don't crash.
3313 3317 (InteractiveShell._prefilter): Defined the default with a _ so
3314 3318 that prefilter() is easier to override, while the default one
3315 3319 remains available.
3316 3320
3317 3321 2002-04-18 Fernando Perez <fperez@colorado.edu>
3318 3322
3319 3323 * Added information about pdb in the docs.
3320 3324
3321 3325 2002-04-17 Fernando Perez <fperez@colorado.edu>
3322 3326
3323 3327 * IPython/ipmaker.py (make_IPython): added rc_override option to
3324 3328 allow passing config options at creation time which may override
3325 3329 anything set in the config files or command line. This is
3326 3330 particularly useful for configuring embedded instances.
3327 3331
3328 3332 2002-04-15 Fernando Perez <fperez@colorado.edu>
3329 3333
3330 3334 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3331 3335 crash embedded instances because of the input cache falling out of
3332 3336 sync with the output counter.
3333 3337
3334 3338 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3335 3339 mode which calls pdb after an uncaught exception in IPython itself.
3336 3340
3337 3341 2002-04-14 Fernando Perez <fperez@colorado.edu>
3338 3342
3339 3343 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3340 3344 readline, fix it back after each call.
3341 3345
3342 3346 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3343 3347 method to force all access via __call__(), which guarantees that
3344 3348 traceback references are properly deleted.
3345 3349
3346 3350 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3347 3351 improve printing when pprint is in use.
3348 3352
3349 3353 2002-04-13 Fernando Perez <fperez@colorado.edu>
3350 3354
3351 3355 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3352 3356 exceptions aren't caught anymore. If the user triggers one, he
3353 3357 should know why he's doing it and it should go all the way up,
3354 3358 just like any other exception. So now @abort will fully kill the
3355 3359 embedded interpreter and the embedding code (unless that happens
3356 3360 to catch SystemExit).
3357 3361
3358 3362 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3359 3363 and a debugger() method to invoke the interactive pdb debugger
3360 3364 after printing exception information. Also added the corresponding
3361 3365 -pdb option and @pdb magic to control this feature, and updated
3362 3366 the docs. After a suggestion from Christopher Hart
3363 3367 (hart-AT-caltech.edu).
3364 3368
3365 3369 2002-04-12 Fernando Perez <fperez@colorado.edu>
3366 3370
3367 3371 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3368 3372 the exception handlers defined by the user (not the CrashHandler)
3369 3373 so that user exceptions don't trigger an ipython bug report.
3370 3374
3371 3375 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3372 3376 configurable (it should have always been so).
3373 3377
3374 3378 2002-03-26 Fernando Perez <fperez@colorado.edu>
3375 3379
3376 3380 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3377 3381 and there to fix embedding namespace issues. This should all be
3378 3382 done in a more elegant way.
3379 3383
3380 3384 2002-03-25 Fernando Perez <fperez@colorado.edu>
3381 3385
3382 3386 * IPython/genutils.py (get_home_dir): Try to make it work under
3383 3387 win9x also.
3384 3388
3385 3389 2002-03-20 Fernando Perez <fperez@colorado.edu>
3386 3390
3387 3391 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3388 3392 sys.displayhook untouched upon __init__.
3389 3393
3390 3394 2002-03-19 Fernando Perez <fperez@colorado.edu>
3391 3395
3392 3396 * Released 0.2.9 (for embedding bug, basically).
3393 3397
3394 3398 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3395 3399 exceptions so that enclosing shell's state can be restored.
3396 3400
3397 3401 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3398 3402 naming conventions in the .ipython/ dir.
3399 3403
3400 3404 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3401 3405 from delimiters list so filenames with - in them get expanded.
3402 3406
3403 3407 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3404 3408 sys.displayhook not being properly restored after an embedded call.
3405 3409
3406 3410 2002-03-18 Fernando Perez <fperez@colorado.edu>
3407 3411
3408 3412 * Released 0.2.8
3409 3413
3410 3414 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3411 3415 some files weren't being included in a -upgrade.
3412 3416 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3413 3417 on' so that the first tab completes.
3414 3418 (InteractiveShell.handle_magic): fixed bug with spaces around
3415 3419 quotes breaking many magic commands.
3416 3420
3417 3421 * setup.py: added note about ignoring the syntax error messages at
3418 3422 installation.
3419 3423
3420 3424 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3421 3425 streamlining the gnuplot interface, now there's only one magic @gp.
3422 3426
3423 3427 2002-03-17 Fernando Perez <fperez@colorado.edu>
3424 3428
3425 3429 * IPython/UserConfig/magic_gnuplot.py: new name for the
3426 3430 example-magic_pm.py file. Much enhanced system, now with a shell
3427 3431 for communicating directly with gnuplot, one command at a time.
3428 3432
3429 3433 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3430 3434 setting __name__=='__main__'.
3431 3435
3432 3436 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3433 3437 mini-shell for accessing gnuplot from inside ipython. Should
3434 3438 extend it later for grace access too. Inspired by Arnd's
3435 3439 suggestion.
3436 3440
3437 3441 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3438 3442 calling magic functions with () in their arguments. Thanks to Arnd
3439 3443 Baecker for pointing this to me.
3440 3444
3441 3445 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3442 3446 infinitely for integer or complex arrays (only worked with floats).
3443 3447
3444 3448 2002-03-16 Fernando Perez <fperez@colorado.edu>
3445 3449
3446 3450 * setup.py: Merged setup and setup_windows into a single script
3447 3451 which properly handles things for windows users.
3448 3452
3449 3453 2002-03-15 Fernando Perez <fperez@colorado.edu>
3450 3454
3451 3455 * Big change to the manual: now the magics are all automatically
3452 3456 documented. This information is generated from their docstrings
3453 3457 and put in a latex file included by the manual lyx file. This way
3454 3458 we get always up to date information for the magics. The manual
3455 3459 now also has proper version information, also auto-synced.
3456 3460
3457 3461 For this to work, an undocumented --magic_docstrings option was added.
3458 3462
3459 3463 2002-03-13 Fernando Perez <fperez@colorado.edu>
3460 3464
3461 3465 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3462 3466 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3463 3467
3464 3468 2002-03-12 Fernando Perez <fperez@colorado.edu>
3465 3469
3466 3470 * IPython/ultraTB.py (TermColors): changed color escapes again to
3467 3471 fix the (old, reintroduced) line-wrapping bug. Basically, if
3468 3472 \001..\002 aren't given in the color escapes, lines get wrapped
3469 3473 weirdly. But giving those screws up old xterms and emacs terms. So
3470 3474 I added some logic for emacs terms to be ok, but I can't identify old
3471 3475 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3472 3476
3473 3477 2002-03-10 Fernando Perez <fperez@colorado.edu>
3474 3478
3475 3479 * IPython/usage.py (__doc__): Various documentation cleanups and
3476 3480 updates, both in usage docstrings and in the manual.
3477 3481
3478 3482 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3479 3483 handling of caching. Set minimum acceptabe value for having a
3480 3484 cache at 20 values.
3481 3485
3482 3486 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3483 3487 install_first_time function to a method, renamed it and added an
3484 3488 'upgrade' mode. Now people can update their config directory with
3485 3489 a simple command line switch (-upgrade, also new).
3486 3490
3487 3491 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3488 3492 @file (convenient for automagic users under Python >= 2.2).
3489 3493 Removed @files (it seemed more like a plural than an abbrev. of
3490 3494 'file show').
3491 3495
3492 3496 * IPython/iplib.py (install_first_time): Fixed crash if there were
3493 3497 backup files ('~') in .ipython/ install directory.
3494 3498
3495 3499 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3496 3500 system. Things look fine, but these changes are fairly
3497 3501 intrusive. Test them for a few days.
3498 3502
3499 3503 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3500 3504 the prompts system. Now all in/out prompt strings are user
3501 3505 controllable. This is particularly useful for embedding, as one
3502 3506 can tag embedded instances with particular prompts.
3503 3507
3504 3508 Also removed global use of sys.ps1/2, which now allows nested
3505 3509 embeddings without any problems. Added command-line options for
3506 3510 the prompt strings.
3507 3511
3508 3512 2002-03-08 Fernando Perez <fperez@colorado.edu>
3509 3513
3510 3514 * IPython/UserConfig/example-embed-short.py (ipshell): added
3511 3515 example file with the bare minimum code for embedding.
3512 3516
3513 3517 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3514 3518 functionality for the embeddable shell to be activated/deactivated
3515 3519 either globally or at each call.
3516 3520
3517 3521 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3518 3522 rewriting the prompt with '--->' for auto-inputs with proper
3519 3523 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3520 3524 this is handled by the prompts class itself, as it should.
3521 3525
3522 3526 2002-03-05 Fernando Perez <fperez@colorado.edu>
3523 3527
3524 3528 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3525 3529 @logstart to avoid name clashes with the math log function.
3526 3530
3527 3531 * Big updates to X/Emacs section of the manual.
3528 3532
3529 3533 * Removed ipython_emacs. Milan explained to me how to pass
3530 3534 arguments to ipython through Emacs. Some day I'm going to end up
3531 3535 learning some lisp...
3532 3536
3533 3537 2002-03-04 Fernando Perez <fperez@colorado.edu>
3534 3538
3535 3539 * IPython/ipython_emacs: Created script to be used as the
3536 3540 py-python-command Emacs variable so we can pass IPython
3537 3541 parameters. I can't figure out how to tell Emacs directly to pass
3538 3542 parameters to IPython, so a dummy shell script will do it.
3539 3543
3540 3544 Other enhancements made for things to work better under Emacs'
3541 3545 various types of terminals. Many thanks to Milan Zamazal
3542 3546 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3543 3547
3544 3548 2002-03-01 Fernando Perez <fperez@colorado.edu>
3545 3549
3546 3550 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3547 3551 that loading of readline is now optional. This gives better
3548 3552 control to emacs users.
3549 3553
3550 3554 * IPython/ultraTB.py (__date__): Modified color escape sequences
3551 3555 and now things work fine under xterm and in Emacs' term buffers
3552 3556 (though not shell ones). Well, in emacs you get colors, but all
3553 3557 seem to be 'light' colors (no difference between dark and light
3554 3558 ones). But the garbage chars are gone, and also in xterms. It
3555 3559 seems that now I'm using 'cleaner' ansi sequences.
3556 3560
3557 3561 2002-02-21 Fernando Perez <fperez@colorado.edu>
3558 3562
3559 3563 * Released 0.2.7 (mainly to publish the scoping fix).
3560 3564
3561 3565 * IPython/Logger.py (Logger.logstate): added. A corresponding
3562 3566 @logstate magic was created.
3563 3567
3564 3568 * IPython/Magic.py: fixed nested scoping problem under Python
3565 3569 2.1.x (automagic wasn't working).
3566 3570
3567 3571 2002-02-20 Fernando Perez <fperez@colorado.edu>
3568 3572
3569 3573 * Released 0.2.6.
3570 3574
3571 3575 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3572 3576 option so that logs can come out without any headers at all.
3573 3577
3574 3578 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3575 3579 SciPy.
3576 3580
3577 3581 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3578 3582 that embedded IPython calls don't require vars() to be explicitly
3579 3583 passed. Now they are extracted from the caller's frame (code
3580 3584 snatched from Eric Jones' weave). Added better documentation to
3581 3585 the section on embedding and the example file.
3582 3586
3583 3587 * IPython/genutils.py (page): Changed so that under emacs, it just
3584 3588 prints the string. You can then page up and down in the emacs
3585 3589 buffer itself. This is how the builtin help() works.
3586 3590
3587 3591 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3588 3592 macro scoping: macros need to be executed in the user's namespace
3589 3593 to work as if they had been typed by the user.
3590 3594
3591 3595 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3592 3596 execute automatically (no need to type 'exec...'). They then
3593 3597 behave like 'true macros'. The printing system was also modified
3594 3598 for this to work.
3595 3599
3596 3600 2002-02-19 Fernando Perez <fperez@colorado.edu>
3597 3601
3598 3602 * IPython/genutils.py (page_file): new function for paging files
3599 3603 in an OS-independent way. Also necessary for file viewing to work
3600 3604 well inside Emacs buffers.
3601 3605 (page): Added checks for being in an emacs buffer.
3602 3606 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3603 3607 same bug in iplib.
3604 3608
3605 3609 2002-02-18 Fernando Perez <fperez@colorado.edu>
3606 3610
3607 3611 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3608 3612 of readline so that IPython can work inside an Emacs buffer.
3609 3613
3610 3614 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3611 3615 method signatures (they weren't really bugs, but it looks cleaner
3612 3616 and keeps PyChecker happy).
3613 3617
3614 3618 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3615 3619 for implementing various user-defined hooks. Currently only
3616 3620 display is done.
3617 3621
3618 3622 * IPython/Prompts.py (CachedOutput._display): changed display
3619 3623 functions so that they can be dynamically changed by users easily.
3620 3624
3621 3625 * IPython/Extensions/numeric_formats.py (num_display): added an
3622 3626 extension for printing NumPy arrays in flexible manners. It
3623 3627 doesn't do anything yet, but all the structure is in
3624 3628 place. Ultimately the plan is to implement output format control
3625 3629 like in Octave.
3626 3630
3627 3631 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3628 3632 methods are found at run-time by all the automatic machinery.
3629 3633
3630 3634 2002-02-17 Fernando Perez <fperez@colorado.edu>
3631 3635
3632 3636 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3633 3637 whole file a little.
3634 3638
3635 3639 * ToDo: closed this document. Now there's a new_design.lyx
3636 3640 document for all new ideas. Added making a pdf of it for the
3637 3641 end-user distro.
3638 3642
3639 3643 * IPython/Logger.py (Logger.switch_log): Created this to replace
3640 3644 logon() and logoff(). It also fixes a nasty crash reported by
3641 3645 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3642 3646
3643 3647 * IPython/iplib.py (complete): got auto-completion to work with
3644 3648 automagic (I had wanted this for a long time).
3645 3649
3646 3650 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3647 3651 to @file, since file() is now a builtin and clashes with automagic
3648 3652 for @file.
3649 3653
3650 3654 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3651 3655 of this was previously in iplib, which had grown to more than 2000
3652 3656 lines, way too long. No new functionality, but it makes managing
3653 3657 the code a bit easier.
3654 3658
3655 3659 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3656 3660 information to crash reports.
3657 3661
3658 3662 2002-02-12 Fernando Perez <fperez@colorado.edu>
3659 3663
3660 3664 * Released 0.2.5.
3661 3665
3662 3666 2002-02-11 Fernando Perez <fperez@colorado.edu>
3663 3667
3664 3668 * Wrote a relatively complete Windows installer. It puts
3665 3669 everything in place, creates Start Menu entries and fixes the
3666 3670 color issues. Nothing fancy, but it works.
3667 3671
3668 3672 2002-02-10 Fernando Perez <fperez@colorado.edu>
3669 3673
3670 3674 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3671 3675 os.path.expanduser() call so that we can type @run ~/myfile.py and
3672 3676 have thigs work as expected.
3673 3677
3674 3678 * IPython/genutils.py (page): fixed exception handling so things
3675 3679 work both in Unix and Windows correctly. Quitting a pager triggers
3676 3680 an IOError/broken pipe in Unix, and in windows not finding a pager
3677 3681 is also an IOError, so I had to actually look at the return value
3678 3682 of the exception, not just the exception itself. Should be ok now.
3679 3683
3680 3684 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3681 3685 modified to allow case-insensitive color scheme changes.
3682 3686
3683 3687 2002-02-09 Fernando Perez <fperez@colorado.edu>
3684 3688
3685 3689 * IPython/genutils.py (native_line_ends): new function to leave
3686 3690 user config files with os-native line-endings.
3687 3691
3688 3692 * README and manual updates.
3689 3693
3690 3694 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3691 3695 instead of StringType to catch Unicode strings.
3692 3696
3693 3697 * IPython/genutils.py (filefind): fixed bug for paths with
3694 3698 embedded spaces (very common in Windows).
3695 3699
3696 3700 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3697 3701 files under Windows, so that they get automatically associated
3698 3702 with a text editor. Windows makes it a pain to handle
3699 3703 extension-less files.
3700 3704
3701 3705 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3702 3706 warning about readline only occur for Posix. In Windows there's no
3703 3707 way to get readline, so why bother with the warning.
3704 3708
3705 3709 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3706 3710 for __str__ instead of dir(self), since dir() changed in 2.2.
3707 3711
3708 3712 * Ported to Windows! Tested on XP, I suspect it should work fine
3709 3713 on NT/2000, but I don't think it will work on 98 et al. That
3710 3714 series of Windows is such a piece of junk anyway that I won't try
3711 3715 porting it there. The XP port was straightforward, showed a few
3712 3716 bugs here and there (fixed all), in particular some string
3713 3717 handling stuff which required considering Unicode strings (which
3714 3718 Windows uses). This is good, but hasn't been too tested :) No
3715 3719 fancy installer yet, I'll put a note in the manual so people at
3716 3720 least make manually a shortcut.
3717 3721
3718 3722 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3719 3723 into a single one, "colors". This now controls both prompt and
3720 3724 exception color schemes, and can be changed both at startup
3721 3725 (either via command-line switches or via ipythonrc files) and at
3722 3726 runtime, with @colors.
3723 3727 (Magic.magic_run): renamed @prun to @run and removed the old
3724 3728 @run. The two were too similar to warrant keeping both.
3725 3729
3726 3730 2002-02-03 Fernando Perez <fperez@colorado.edu>
3727 3731
3728 3732 * IPython/iplib.py (install_first_time): Added comment on how to
3729 3733 configure the color options for first-time users. Put a <return>
3730 3734 request at the end so that small-terminal users get a chance to
3731 3735 read the startup info.
3732 3736
3733 3737 2002-01-23 Fernando Perez <fperez@colorado.edu>
3734 3738
3735 3739 * IPython/iplib.py (CachedOutput.update): Changed output memory
3736 3740 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3737 3741 input history we still use _i. Did this b/c these variable are
3738 3742 very commonly used in interactive work, so the less we need to
3739 3743 type the better off we are.
3740 3744 (Magic.magic_prun): updated @prun to better handle the namespaces
3741 3745 the file will run in, including a fix for __name__ not being set
3742 3746 before.
3743 3747
3744 3748 2002-01-20 Fernando Perez <fperez@colorado.edu>
3745 3749
3746 3750 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3747 3751 extra garbage for Python 2.2. Need to look more carefully into
3748 3752 this later.
3749 3753
3750 3754 2002-01-19 Fernando Perez <fperez@colorado.edu>
3751 3755
3752 3756 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3753 3757 display SyntaxError exceptions properly formatted when they occur
3754 3758 (they can be triggered by imported code).
3755 3759
3756 3760 2002-01-18 Fernando Perez <fperez@colorado.edu>
3757 3761
3758 3762 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3759 3763 SyntaxError exceptions are reported nicely formatted, instead of
3760 3764 spitting out only offset information as before.
3761 3765 (Magic.magic_prun): Added the @prun function for executing
3762 3766 programs with command line args inside IPython.
3763 3767
3764 3768 2002-01-16 Fernando Perez <fperez@colorado.edu>
3765 3769
3766 3770 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3767 3771 to *not* include the last item given in a range. This brings their
3768 3772 behavior in line with Python's slicing:
3769 3773 a[n1:n2] -> a[n1]...a[n2-1]
3770 3774 It may be a bit less convenient, but I prefer to stick to Python's
3771 3775 conventions *everywhere*, so users never have to wonder.
3772 3776 (Magic.magic_macro): Added @macro function to ease the creation of
3773 3777 macros.
3774 3778
3775 3779 2002-01-05 Fernando Perez <fperez@colorado.edu>
3776 3780
3777 3781 * Released 0.2.4.
3778 3782
3779 3783 * IPython/iplib.py (Magic.magic_pdef):
3780 3784 (InteractiveShell.safe_execfile): report magic lines and error
3781 3785 lines without line numbers so one can easily copy/paste them for
3782 3786 re-execution.
3783 3787
3784 3788 * Updated manual with recent changes.
3785 3789
3786 3790 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3787 3791 docstring printing when class? is called. Very handy for knowing
3788 3792 how to create class instances (as long as __init__ is well
3789 3793 documented, of course :)
3790 3794 (Magic.magic_doc): print both class and constructor docstrings.
3791 3795 (Magic.magic_pdef): give constructor info if passed a class and
3792 3796 __call__ info for callable object instances.
3793 3797
3794 3798 2002-01-04 Fernando Perez <fperez@colorado.edu>
3795 3799
3796 3800 * Made deep_reload() off by default. It doesn't always work
3797 3801 exactly as intended, so it's probably safer to have it off. It's
3798 3802 still available as dreload() anyway, so nothing is lost.
3799 3803
3800 3804 2002-01-02 Fernando Perez <fperez@colorado.edu>
3801 3805
3802 3806 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3803 3807 so I wanted an updated release).
3804 3808
3805 3809 2001-12-27 Fernando Perez <fperez@colorado.edu>
3806 3810
3807 3811 * IPython/iplib.py (InteractiveShell.interact): Added the original
3808 3812 code from 'code.py' for this module in order to change the
3809 3813 handling of a KeyboardInterrupt. This was necessary b/c otherwise
3810 3814 the history cache would break when the user hit Ctrl-C, and
3811 3815 interact() offers no way to add any hooks to it.
3812 3816
3813 3817 2001-12-23 Fernando Perez <fperez@colorado.edu>
3814 3818
3815 3819 * setup.py: added check for 'MANIFEST' before trying to remove
3816 3820 it. Thanks to Sean Reifschneider.
3817 3821
3818 3822 2001-12-22 Fernando Perez <fperez@colorado.edu>
3819 3823
3820 3824 * Released 0.2.2.
3821 3825
3822 3826 * Finished (reasonably) writing the manual. Later will add the
3823 3827 python-standard navigation stylesheets, but for the time being
3824 3828 it's fairly complete. Distribution will include html and pdf
3825 3829 versions.
3826 3830
3827 3831 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
3828 3832 (MayaVi author).
3829 3833
3830 3834 2001-12-21 Fernando Perez <fperez@colorado.edu>
3831 3835
3832 3836 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
3833 3837 good public release, I think (with the manual and the distutils
3834 3838 installer). The manual can use some work, but that can go
3835 3839 slowly. Otherwise I think it's quite nice for end users. Next
3836 3840 summer, rewrite the guts of it...
3837 3841
3838 3842 * Changed format of ipythonrc files to use whitespace as the
3839 3843 separator instead of an explicit '='. Cleaner.
3840 3844
3841 3845 2001-12-20 Fernando Perez <fperez@colorado.edu>
3842 3846
3843 3847 * Started a manual in LyX. For now it's just a quick merge of the
3844 3848 various internal docstrings and READMEs. Later it may grow into a
3845 3849 nice, full-blown manual.
3846 3850
3847 3851 * Set up a distutils based installer. Installation should now be
3848 3852 trivially simple for end-users.
3849 3853
3850 3854 2001-12-11 Fernando Perez <fperez@colorado.edu>
3851 3855
3852 3856 * Released 0.2.0. First public release, announced it at
3853 3857 comp.lang.python. From now on, just bugfixes...
3854 3858
3855 3859 * Went through all the files, set copyright/license notices and
3856 3860 cleaned up things. Ready for release.
3857 3861
3858 3862 2001-12-10 Fernando Perez <fperez@colorado.edu>
3859 3863
3860 3864 * Changed the first-time installer not to use tarfiles. It's more
3861 3865 robust now and less unix-dependent. Also makes it easier for
3862 3866 people to later upgrade versions.
3863 3867
3864 3868 * Changed @exit to @abort to reflect the fact that it's pretty
3865 3869 brutal (a sys.exit()). The difference between @abort and Ctrl-D
3866 3870 becomes significant only when IPyhton is embedded: in that case,
3867 3871 C-D closes IPython only, but @abort kills the enclosing program
3868 3872 too (unless it had called IPython inside a try catching
3869 3873 SystemExit).
3870 3874
3871 3875 * Created Shell module which exposes the actuall IPython Shell
3872 3876 classes, currently the normal and the embeddable one. This at
3873 3877 least offers a stable interface we won't need to change when
3874 3878 (later) the internals are rewritten. That rewrite will be confined
3875 3879 to iplib and ipmaker, but the Shell interface should remain as is.
3876 3880
3877 3881 * Added embed module which offers an embeddable IPShell object,
3878 3882 useful to fire up IPython *inside* a running program. Great for
3879 3883 debugging or dynamical data analysis.
3880 3884
3881 3885 2001-12-08 Fernando Perez <fperez@colorado.edu>
3882 3886
3883 3887 * Fixed small bug preventing seeing info from methods of defined
3884 3888 objects (incorrect namespace in _ofind()).
3885 3889
3886 3890 * Documentation cleanup. Moved the main usage docstrings to a
3887 3891 separate file, usage.py (cleaner to maintain, and hopefully in the
3888 3892 future some perlpod-like way of producing interactive, man and
3889 3893 html docs out of it will be found).
3890 3894
3891 3895 * Added @profile to see your profile at any time.
3892 3896
3893 3897 * Added @p as an alias for 'print'. It's especially convenient if
3894 3898 using automagic ('p x' prints x).
3895 3899
3896 3900 * Small cleanups and fixes after a pychecker run.
3897 3901
3898 3902 * Changed the @cd command to handle @cd - and @cd -<n> for
3899 3903 visiting any directory in _dh.
3900 3904
3901 3905 * Introduced _dh, a history of visited directories. @dhist prints
3902 3906 it out with numbers.
3903 3907
3904 3908 2001-12-07 Fernando Perez <fperez@colorado.edu>
3905 3909
3906 3910 * Released 0.1.22
3907 3911
3908 3912 * Made initialization a bit more robust against invalid color
3909 3913 options in user input (exit, not traceback-crash).
3910 3914
3911 3915 * Changed the bug crash reporter to write the report only in the
3912 3916 user's .ipython directory. That way IPython won't litter people's
3913 3917 hard disks with crash files all over the place. Also print on
3914 3918 screen the necessary mail command.
3915 3919
3916 3920 * With the new ultraTB, implemented LightBG color scheme for light
3917 3921 background terminals. A lot of people like white backgrounds, so I
3918 3922 guess we should at least give them something readable.
3919 3923
3920 3924 2001-12-06 Fernando Perez <fperez@colorado.edu>
3921 3925
3922 3926 * Modified the structure of ultraTB. Now there's a proper class
3923 3927 for tables of color schemes which allow adding schemes easily and
3924 3928 switching the active scheme without creating a new instance every
3925 3929 time (which was ridiculous). The syntax for creating new schemes
3926 3930 is also cleaner. I think ultraTB is finally done, with a clean
3927 3931 class structure. Names are also much cleaner (now there's proper
3928 3932 color tables, no need for every variable to also have 'color' in
3929 3933 its name).
3930 3934
3931 3935 * Broke down genutils into separate files. Now genutils only
3932 3936 contains utility functions, and classes have been moved to their
3933 3937 own files (they had enough independent functionality to warrant
3934 3938 it): ConfigLoader, OutputTrap, Struct.
3935 3939
3936 3940 2001-12-05 Fernando Perez <fperez@colorado.edu>
3937 3941
3938 3942 * IPython turns 21! Released version 0.1.21, as a candidate for
3939 3943 public consumption. If all goes well, release in a few days.
3940 3944
3941 3945 * Fixed path bug (files in Extensions/ directory wouldn't be found
3942 3946 unless IPython/ was explicitly in sys.path).
3943 3947
3944 3948 * Extended the FlexCompleter class as MagicCompleter to allow
3945 3949 completion of @-starting lines.
3946 3950
3947 3951 * Created __release__.py file as a central repository for release
3948 3952 info that other files can read from.
3949 3953
3950 3954 * Fixed small bug in logging: when logging was turned on in
3951 3955 mid-session, old lines with special meanings (!@?) were being
3952 3956 logged without the prepended comment, which is necessary since
3953 3957 they are not truly valid python syntax. This should make session
3954 3958 restores produce less errors.
3955 3959
3956 3960 * The namespace cleanup forced me to make a FlexCompleter class
3957 3961 which is nothing but a ripoff of rlcompleter, but with selectable
3958 3962 namespace (rlcompleter only works in __main__.__dict__). I'll try
3959 3963 to submit a note to the authors to see if this change can be
3960 3964 incorporated in future rlcompleter releases (Dec.6: done)
3961 3965
3962 3966 * More fixes to namespace handling. It was a mess! Now all
3963 3967 explicit references to __main__.__dict__ are gone (except when
3964 3968 really needed) and everything is handled through the namespace
3965 3969 dicts in the IPython instance. We seem to be getting somewhere
3966 3970 with this, finally...
3967 3971
3968 3972 * Small documentation updates.
3969 3973
3970 3974 * Created the Extensions directory under IPython (with an
3971 3975 __init__.py). Put the PhysicalQ stuff there. This directory should
3972 3976 be used for all special-purpose extensions.
3973 3977
3974 3978 * File renaming:
3975 3979 ipythonlib --> ipmaker
3976 3980 ipplib --> iplib
3977 3981 This makes a bit more sense in terms of what these files actually do.
3978 3982
3979 3983 * Moved all the classes and functions in ipythonlib to ipplib, so
3980 3984 now ipythonlib only has make_IPython(). This will ease up its
3981 3985 splitting in smaller functional chunks later.
3982 3986
3983 3987 * Cleaned up (done, I think) output of @whos. Better column
3984 3988 formatting, and now shows str(var) for as much as it can, which is
3985 3989 typically what one gets with a 'print var'.
3986 3990
3987 3991 2001-12-04 Fernando Perez <fperez@colorado.edu>
3988 3992
3989 3993 * Fixed namespace problems. Now builtin/IPyhton/user names get
3990 3994 properly reported in their namespace. Internal namespace handling
3991 3995 is finally getting decent (not perfect yet, but much better than
3992 3996 the ad-hoc mess we had).
3993 3997
3994 3998 * Removed -exit option. If people just want to run a python
3995 3999 script, that's what the normal interpreter is for. Less
3996 4000 unnecessary options, less chances for bugs.
3997 4001
3998 4002 * Added a crash handler which generates a complete post-mortem if
3999 4003 IPython crashes. This will help a lot in tracking bugs down the
4000 4004 road.
4001 4005
4002 4006 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
4003 4007 which were boud to functions being reassigned would bypass the
4004 4008 logger, breaking the sync of _il with the prompt counter. This
4005 4009 would then crash IPython later when a new line was logged.
4006 4010
4007 4011 2001-12-02 Fernando Perez <fperez@colorado.edu>
4008 4012
4009 4013 * Made IPython a package. This means people don't have to clutter
4010 4014 their sys.path with yet another directory. Changed the INSTALL
4011 4015 file accordingly.
4012 4016
4013 4017 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
4014 4018 sorts its output (so @who shows it sorted) and @whos formats the
4015 4019 table according to the width of the first column. Nicer, easier to
4016 4020 read. Todo: write a generic table_format() which takes a list of
4017 4021 lists and prints it nicely formatted, with optional row/column
4018 4022 separators and proper padding and justification.
4019 4023
4020 4024 * Released 0.1.20
4021 4025
4022 4026 * Fixed bug in @log which would reverse the inputcache list (a
4023 4027 copy operation was missing).
4024 4028
4025 4029 * Code cleanup. @config was changed to use page(). Better, since
4026 4030 its output is always quite long.
4027 4031
4028 4032 * Itpl is back as a dependency. I was having too many problems
4029 4033 getting the parametric aliases to work reliably, and it's just
4030 4034 easier to code weird string operations with it than playing %()s
4031 4035 games. It's only ~6k, so I don't think it's too big a deal.
4032 4036
4033 4037 * Found (and fixed) a very nasty bug with history. !lines weren't
4034 4038 getting cached, and the out of sync caches would crash
4035 4039 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4036 4040 division of labor a bit better. Bug fixed, cleaner structure.
4037 4041
4038 4042 2001-12-01 Fernando Perez <fperez@colorado.edu>
4039 4043
4040 4044 * Released 0.1.19
4041 4045
4042 4046 * Added option -n to @hist to prevent line number printing. Much
4043 4047 easier to copy/paste code this way.
4044 4048
4045 4049 * Created global _il to hold the input list. Allows easy
4046 4050 re-execution of blocks of code by slicing it (inspired by Janko's
4047 4051 comment on 'macros').
4048 4052
4049 4053 * Small fixes and doc updates.
4050 4054
4051 4055 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4052 4056 much too fragile with automagic. Handles properly multi-line
4053 4057 statements and takes parameters.
4054 4058
4055 4059 2001-11-30 Fernando Perez <fperez@colorado.edu>
4056 4060
4057 4061 * Version 0.1.18 released.
4058 4062
4059 4063 * Fixed nasty namespace bug in initial module imports.
4060 4064
4061 4065 * Added copyright/license notes to all code files (except
4062 4066 DPyGetOpt). For the time being, LGPL. That could change.
4063 4067
4064 4068 * Rewrote a much nicer README, updated INSTALL, cleaned up
4065 4069 ipythonrc-* samples.
4066 4070
4067 4071 * Overall code/documentation cleanup. Basically ready for
4068 4072 release. Only remaining thing: licence decision (LGPL?).
4069 4073
4070 4074 * Converted load_config to a class, ConfigLoader. Now recursion
4071 4075 control is better organized. Doesn't include the same file twice.
4072 4076
4073 4077 2001-11-29 Fernando Perez <fperez@colorado.edu>
4074 4078
4075 4079 * Got input history working. Changed output history variables from
4076 4080 _p to _o so that _i is for input and _o for output. Just cleaner
4077 4081 convention.
4078 4082
4079 4083 * Implemented parametric aliases. This pretty much allows the
4080 4084 alias system to offer full-blown shell convenience, I think.
4081 4085
4082 4086 * Version 0.1.17 released, 0.1.18 opened.
4083 4087
4084 4088 * dot_ipython/ipythonrc (alias): added documentation.
4085 4089 (xcolor): Fixed small bug (xcolors -> xcolor)
4086 4090
4087 4091 * Changed the alias system. Now alias is a magic command to define
4088 4092 aliases just like the shell. Rationale: the builtin magics should
4089 4093 be there for things deeply connected to IPython's
4090 4094 architecture. And this is a much lighter system for what I think
4091 4095 is the really important feature: allowing users to define quickly
4092 4096 magics that will do shell things for them, so they can customize
4093 4097 IPython easily to match their work habits. If someone is really
4094 4098 desperate to have another name for a builtin alias, they can
4095 4099 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4096 4100 works.
4097 4101
4098 4102 2001-11-28 Fernando Perez <fperez@colorado.edu>
4099 4103
4100 4104 * Changed @file so that it opens the source file at the proper
4101 4105 line. Since it uses less, if your EDITOR environment is
4102 4106 configured, typing v will immediately open your editor of choice
4103 4107 right at the line where the object is defined. Not as quick as
4104 4108 having a direct @edit command, but for all intents and purposes it
4105 4109 works. And I don't have to worry about writing @edit to deal with
4106 4110 all the editors, less does that.
4107 4111
4108 4112 * Version 0.1.16 released, 0.1.17 opened.
4109 4113
4110 4114 * Fixed some nasty bugs in the page/page_dumb combo that could
4111 4115 crash IPython.
4112 4116
4113 4117 2001-11-27 Fernando Perez <fperez@colorado.edu>
4114 4118
4115 4119 * Version 0.1.15 released, 0.1.16 opened.
4116 4120
4117 4121 * Finally got ? and ?? to work for undefined things: now it's
4118 4122 possible to type {}.get? and get information about the get method
4119 4123 of dicts, or os.path? even if only os is defined (so technically
4120 4124 os.path isn't). Works at any level. For example, after import os,
4121 4125 os?, os.path?, os.path.abspath? all work. This is great, took some
4122 4126 work in _ofind.
4123 4127
4124 4128 * Fixed more bugs with logging. The sanest way to do it was to add
4125 4129 to @log a 'mode' parameter. Killed two in one shot (this mode
4126 4130 option was a request of Janko's). I think it's finally clean
4127 4131 (famous last words).
4128 4132
4129 4133 * Added a page_dumb() pager which does a decent job of paging on
4130 4134 screen, if better things (like less) aren't available. One less
4131 4135 unix dependency (someday maybe somebody will port this to
4132 4136 windows).
4133 4137
4134 4138 * Fixed problem in magic_log: would lock of logging out if log
4135 4139 creation failed (because it would still think it had succeeded).
4136 4140
4137 4141 * Improved the page() function using curses to auto-detect screen
4138 4142 size. Now it can make a much better decision on whether to print
4139 4143 or page a string. Option screen_length was modified: a value 0
4140 4144 means auto-detect, and that's the default now.
4141 4145
4142 4146 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4143 4147 go out. I'll test it for a few days, then talk to Janko about
4144 4148 licences and announce it.
4145 4149
4146 4150 * Fixed the length of the auto-generated ---> prompt which appears
4147 4151 for auto-parens and auto-quotes. Getting this right isn't trivial,
4148 4152 with all the color escapes, different prompt types and optional
4149 4153 separators. But it seems to be working in all the combinations.
4150 4154
4151 4155 2001-11-26 Fernando Perez <fperez@colorado.edu>
4152 4156
4153 4157 * Wrote a regexp filter to get option types from the option names
4154 4158 string. This eliminates the need to manually keep two duplicate
4155 4159 lists.
4156 4160
4157 4161 * Removed the unneeded check_option_names. Now options are handled
4158 4162 in a much saner manner and it's easy to visually check that things
4159 4163 are ok.
4160 4164
4161 4165 * Updated version numbers on all files I modified to carry a
4162 4166 notice so Janko and Nathan have clear version markers.
4163 4167
4164 4168 * Updated docstring for ultraTB with my changes. I should send
4165 4169 this to Nathan.
4166 4170
4167 4171 * Lots of small fixes. Ran everything through pychecker again.
4168 4172
4169 4173 * Made loading of deep_reload an cmd line option. If it's not too
4170 4174 kosher, now people can just disable it. With -nodeep_reload it's
4171 4175 still available as dreload(), it just won't overwrite reload().
4172 4176
4173 4177 * Moved many options to the no| form (-opt and -noopt
4174 4178 accepted). Cleaner.
4175 4179
4176 4180 * Changed magic_log so that if called with no parameters, it uses
4177 4181 'rotate' mode. That way auto-generated logs aren't automatically
4178 4182 over-written. For normal logs, now a backup is made if it exists
4179 4183 (only 1 level of backups). A new 'backup' mode was added to the
4180 4184 Logger class to support this. This was a request by Janko.
4181 4185
4182 4186 * Added @logoff/@logon to stop/restart an active log.
4183 4187
4184 4188 * Fixed a lot of bugs in log saving/replay. It was pretty
4185 4189 broken. Now special lines (!@,/) appear properly in the command
4186 4190 history after a log replay.
4187 4191
4188 4192 * Tried and failed to implement full session saving via pickle. My
4189 4193 idea was to pickle __main__.__dict__, but modules can't be
4190 4194 pickled. This would be a better alternative to replaying logs, but
4191 4195 seems quite tricky to get to work. Changed -session to be called
4192 4196 -logplay, which more accurately reflects what it does. And if we
4193 4197 ever get real session saving working, -session is now available.
4194 4198
4195 4199 * Implemented color schemes for prompts also. As for tracebacks,
4196 4200 currently only NoColor and Linux are supported. But now the
4197 4201 infrastructure is in place, based on a generic ColorScheme
4198 4202 class. So writing and activating new schemes both for the prompts
4199 4203 and the tracebacks should be straightforward.
4200 4204
4201 4205 * Version 0.1.13 released, 0.1.14 opened.
4202 4206
4203 4207 * Changed handling of options for output cache. Now counter is
4204 4208 hardwired starting at 1 and one specifies the maximum number of
4205 4209 entries *in the outcache* (not the max prompt counter). This is
4206 4210 much better, since many statements won't increase the cache
4207 4211 count. It also eliminated some confusing options, now there's only
4208 4212 one: cache_size.
4209 4213
4210 4214 * Added 'alias' magic function and magic_alias option in the
4211 4215 ipythonrc file. Now the user can easily define whatever names he
4212 4216 wants for the magic functions without having to play weird
4213 4217 namespace games. This gives IPython a real shell-like feel.
4214 4218
4215 4219 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4216 4220 @ or not).
4217 4221
4218 4222 This was one of the last remaining 'visible' bugs (that I know
4219 4223 of). I think if I can clean up the session loading so it works
4220 4224 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4221 4225 about licensing).
4222 4226
4223 4227 2001-11-25 Fernando Perez <fperez@colorado.edu>
4224 4228
4225 4229 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4226 4230 there's a cleaner distinction between what ? and ?? show.
4227 4231
4228 4232 * Added screen_length option. Now the user can define his own
4229 4233 screen size for page() operations.
4230 4234
4231 4235 * Implemented magic shell-like functions with automatic code
4232 4236 generation. Now adding another function is just a matter of adding
4233 4237 an entry to a dict, and the function is dynamically generated at
4234 4238 run-time. Python has some really cool features!
4235 4239
4236 4240 * Renamed many options to cleanup conventions a little. Now all
4237 4241 are lowercase, and only underscores where needed. Also in the code
4238 4242 option name tables are clearer.
4239 4243
4240 4244 * Changed prompts a little. Now input is 'In [n]:' instead of
4241 4245 'In[n]:='. This allows it the numbers to be aligned with the
4242 4246 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4243 4247 Python (it was a Mathematica thing). The '...' continuation prompt
4244 4248 was also changed a little to align better.
4245 4249
4246 4250 * Fixed bug when flushing output cache. Not all _p<n> variables
4247 4251 exist, so their deletion needs to be wrapped in a try:
4248 4252
4249 4253 * Figured out how to properly use inspect.formatargspec() (it
4250 4254 requires the args preceded by *). So I removed all the code from
4251 4255 _get_pdef in Magic, which was just replicating that.
4252 4256
4253 4257 * Added test to prefilter to allow redefining magic function names
4254 4258 as variables. This is ok, since the @ form is always available,
4255 4259 but whe should allow the user to define a variable called 'ls' if
4256 4260 he needs it.
4257 4261
4258 4262 * Moved the ToDo information from README into a separate ToDo.
4259 4263
4260 4264 * General code cleanup and small bugfixes. I think it's close to a
4261 4265 state where it can be released, obviously with a big 'beta'
4262 4266 warning on it.
4263 4267
4264 4268 * Got the magic function split to work. Now all magics are defined
4265 4269 in a separate class. It just organizes things a bit, and now
4266 4270 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4267 4271 was too long).
4268 4272
4269 4273 * Changed @clear to @reset to avoid potential confusions with
4270 4274 the shell command clear. Also renamed @cl to @clear, which does
4271 4275 exactly what people expect it to from their shell experience.
4272 4276
4273 4277 Added a check to the @reset command (since it's so
4274 4278 destructive, it's probably a good idea to ask for confirmation).
4275 4279 But now reset only works for full namespace resetting. Since the
4276 4280 del keyword is already there for deleting a few specific
4277 4281 variables, I don't see the point of having a redundant magic
4278 4282 function for the same task.
4279 4283
4280 4284 2001-11-24 Fernando Perez <fperez@colorado.edu>
4281 4285
4282 4286 * Updated the builtin docs (esp. the ? ones).
4283 4287
4284 4288 * Ran all the code through pychecker. Not terribly impressed with
4285 4289 it: lots of spurious warnings and didn't really find anything of
4286 4290 substance (just a few modules being imported and not used).
4287 4291
4288 4292 * Implemented the new ultraTB functionality into IPython. New
4289 4293 option: xcolors. This chooses color scheme. xmode now only selects
4290 4294 between Plain and Verbose. Better orthogonality.
4291 4295
4292 4296 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4293 4297 mode and color scheme for the exception handlers. Now it's
4294 4298 possible to have the verbose traceback with no coloring.
4295 4299
4296 4300 2001-11-23 Fernando Perez <fperez@colorado.edu>
4297 4301
4298 4302 * Version 0.1.12 released, 0.1.13 opened.
4299 4303
4300 4304 * Removed option to set auto-quote and auto-paren escapes by
4301 4305 user. The chances of breaking valid syntax are just too high. If
4302 4306 someone *really* wants, they can always dig into the code.
4303 4307
4304 4308 * Made prompt separators configurable.
4305 4309
4306 4310 2001-11-22 Fernando Perez <fperez@colorado.edu>
4307 4311
4308 4312 * Small bugfixes in many places.
4309 4313
4310 4314 * Removed the MyCompleter class from ipplib. It seemed redundant
4311 4315 with the C-p,C-n history search functionality. Less code to
4312 4316 maintain.
4313 4317
4314 4318 * Moved all the original ipython.py code into ipythonlib.py. Right
4315 4319 now it's just one big dump into a function called make_IPython, so
4316 4320 no real modularity has been gained. But at least it makes the
4317 4321 wrapper script tiny, and since ipythonlib is a module, it gets
4318 4322 compiled and startup is much faster.
4319 4323
4320 4324 This is a reasobably 'deep' change, so we should test it for a
4321 4325 while without messing too much more with the code.
4322 4326
4323 4327 2001-11-21 Fernando Perez <fperez@colorado.edu>
4324 4328
4325 4329 * Version 0.1.11 released, 0.1.12 opened for further work.
4326 4330
4327 4331 * Removed dependency on Itpl. It was only needed in one place. It
4328 4332 would be nice if this became part of python, though. It makes life
4329 4333 *a lot* easier in some cases.
4330 4334
4331 4335 * Simplified the prefilter code a bit. Now all handlers are
4332 4336 expected to explicitly return a value (at least a blank string).
4333 4337
4334 4338 * Heavy edits in ipplib. Removed the help system altogether. Now
4335 4339 obj?/?? is used for inspecting objects, a magic @doc prints
4336 4340 docstrings, and full-blown Python help is accessed via the 'help'
4337 4341 keyword. This cleans up a lot of code (less to maintain) and does
4338 4342 the job. Since 'help' is now a standard Python component, might as
4339 4343 well use it and remove duplicate functionality.
4340 4344
4341 4345 Also removed the option to use ipplib as a standalone program. By
4342 4346 now it's too dependent on other parts of IPython to function alone.
4343 4347
4344 4348 * Fixed bug in genutils.pager. It would crash if the pager was
4345 4349 exited immediately after opening (broken pipe).
4346 4350
4347 4351 * Trimmed down the VerboseTB reporting a little. The header is
4348 4352 much shorter now and the repeated exception arguments at the end
4349 4353 have been removed. For interactive use the old header seemed a bit
4350 4354 excessive.
4351 4355
4352 4356 * Fixed small bug in output of @whos for variables with multi-word
4353 4357 types (only first word was displayed).
4354 4358
4355 4359 2001-11-17 Fernando Perez <fperez@colorado.edu>
4356 4360
4357 4361 * Version 0.1.10 released, 0.1.11 opened for further work.
4358 4362
4359 4363 * Modified dirs and friends. dirs now *returns* the stack (not
4360 4364 prints), so one can manipulate it as a variable. Convenient to
4361 4365 travel along many directories.
4362 4366
4363 4367 * Fixed bug in magic_pdef: would only work with functions with
4364 4368 arguments with default values.
4365 4369
4366 4370 2001-11-14 Fernando Perez <fperez@colorado.edu>
4367 4371
4368 4372 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4369 4373 example with IPython. Various other minor fixes and cleanups.
4370 4374
4371 4375 * Version 0.1.9 released, 0.1.10 opened for further work.
4372 4376
4373 4377 * Added sys.path to the list of directories searched in the
4374 4378 execfile= option. It used to be the current directory and the
4375 4379 user's IPYTHONDIR only.
4376 4380
4377 4381 2001-11-13 Fernando Perez <fperez@colorado.edu>
4378 4382
4379 4383 * Reinstated the raw_input/prefilter separation that Janko had
4380 4384 initially. This gives a more convenient setup for extending the
4381 4385 pre-processor from the outside: raw_input always gets a string,
4382 4386 and prefilter has to process it. We can then redefine prefilter
4383 4387 from the outside and implement extensions for special
4384 4388 purposes.
4385 4389
4386 4390 Today I got one for inputting PhysicalQuantity objects
4387 4391 (from Scientific) without needing any function calls at
4388 4392 all. Extremely convenient, and it's all done as a user-level
4389 4393 extension (no IPython code was touched). Now instead of:
4390 4394 a = PhysicalQuantity(4.2,'m/s**2')
4391 4395 one can simply say
4392 4396 a = 4.2 m/s**2
4393 4397 or even
4394 4398 a = 4.2 m/s^2
4395 4399
4396 4400 I use this, but it's also a proof of concept: IPython really is
4397 4401 fully user-extensible, even at the level of the parsing of the
4398 4402 command line. It's not trivial, but it's perfectly doable.
4399 4403
4400 4404 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4401 4405 the problem of modules being loaded in the inverse order in which
4402 4406 they were defined in
4403 4407
4404 4408 * Version 0.1.8 released, 0.1.9 opened for further work.
4405 4409
4406 4410 * Added magics pdef, source and file. They respectively show the
4407 4411 definition line ('prototype' in C), source code and full python
4408 4412 file for any callable object. The object inspector oinfo uses
4409 4413 these to show the same information.
4410 4414
4411 4415 * Version 0.1.7 released, 0.1.8 opened for further work.
4412 4416
4413 4417 * Separated all the magic functions into a class called Magic. The
4414 4418 InteractiveShell class was becoming too big for Xemacs to handle
4415 4419 (de-indenting a line would lock it up for 10 seconds while it
4416 4420 backtracked on the whole class!)
4417 4421
4418 4422 FIXME: didn't work. It can be done, but right now namespaces are
4419 4423 all messed up. Do it later (reverted it for now, so at least
4420 4424 everything works as before).
4421 4425
4422 4426 * Got the object introspection system (magic_oinfo) working! I
4423 4427 think this is pretty much ready for release to Janko, so he can
4424 4428 test it for a while and then announce it. Pretty much 100% of what
4425 4429 I wanted for the 'phase 1' release is ready. Happy, tired.
4426 4430
4427 4431 2001-11-12 Fernando Perez <fperez@colorado.edu>
4428 4432
4429 4433 * Version 0.1.6 released, 0.1.7 opened for further work.
4430 4434
4431 4435 * Fixed bug in printing: it used to test for truth before
4432 4436 printing, so 0 wouldn't print. Now checks for None.
4433 4437
4434 4438 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4435 4439 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4436 4440 reaches by hand into the outputcache. Think of a better way to do
4437 4441 this later.
4438 4442
4439 4443 * Various small fixes thanks to Nathan's comments.
4440 4444
4441 4445 * Changed magic_pprint to magic_Pprint. This way it doesn't
4442 4446 collide with pprint() and the name is consistent with the command
4443 4447 line option.
4444 4448
4445 4449 * Changed prompt counter behavior to be fully like
4446 4450 Mathematica's. That is, even input that doesn't return a result
4447 4451 raises the prompt counter. The old behavior was kind of confusing
4448 4452 (getting the same prompt number several times if the operation
4449 4453 didn't return a result).
4450 4454
4451 4455 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4452 4456
4453 4457 * Fixed -Classic mode (wasn't working anymore).
4454 4458
4455 4459 * Added colored prompts using Nathan's new code. Colors are
4456 4460 currently hardwired, they can be user-configurable. For
4457 4461 developers, they can be chosen in file ipythonlib.py, at the
4458 4462 beginning of the CachedOutput class def.
4459 4463
4460 4464 2001-11-11 Fernando Perez <fperez@colorado.edu>
4461 4465
4462 4466 * Version 0.1.5 released, 0.1.6 opened for further work.
4463 4467
4464 4468 * Changed magic_env to *return* the environment as a dict (not to
4465 4469 print it). This way it prints, but it can also be processed.
4466 4470
4467 4471 * Added Verbose exception reporting to interactive
4468 4472 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4469 4473 traceback. Had to make some changes to the ultraTB file. This is
4470 4474 probably the last 'big' thing in my mental todo list. This ties
4471 4475 in with the next entry:
4472 4476
4473 4477 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4474 4478 has to specify is Plain, Color or Verbose for all exception
4475 4479 handling.
4476 4480
4477 4481 * Removed ShellServices option. All this can really be done via
4478 4482 the magic system. It's easier to extend, cleaner and has automatic
4479 4483 namespace protection and documentation.
4480 4484
4481 4485 2001-11-09 Fernando Perez <fperez@colorado.edu>
4482 4486
4483 4487 * Fixed bug in output cache flushing (missing parameter to
4484 4488 __init__). Other small bugs fixed (found using pychecker).
4485 4489
4486 4490 * Version 0.1.4 opened for bugfixing.
4487 4491
4488 4492 2001-11-07 Fernando Perez <fperez@colorado.edu>
4489 4493
4490 4494 * Version 0.1.3 released, mainly because of the raw_input bug.
4491 4495
4492 4496 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4493 4497 and when testing for whether things were callable, a call could
4494 4498 actually be made to certain functions. They would get called again
4495 4499 once 'really' executed, with a resulting double call. A disaster
4496 4500 in many cases (list.reverse() would never work!).
4497 4501
4498 4502 * Removed prefilter() function, moved its code to raw_input (which
4499 4503 after all was just a near-empty caller for prefilter). This saves
4500 4504 a function call on every prompt, and simplifies the class a tiny bit.
4501 4505
4502 4506 * Fix _ip to __ip name in magic example file.
4503 4507
4504 4508 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4505 4509 work with non-gnu versions of tar.
4506 4510
4507 4511 2001-11-06 Fernando Perez <fperez@colorado.edu>
4508 4512
4509 4513 * Version 0.1.2. Just to keep track of the recent changes.
4510 4514
4511 4515 * Fixed nasty bug in output prompt routine. It used to check 'if
4512 4516 arg != None...'. Problem is, this fails if arg implements a
4513 4517 special comparison (__cmp__) which disallows comparing to
4514 4518 None. Found it when trying to use the PhysicalQuantity module from
4515 4519 ScientificPython.
4516 4520
4517 4521 2001-11-05 Fernando Perez <fperez@colorado.edu>
4518 4522
4519 4523 * Also added dirs. Now the pushd/popd/dirs family functions
4520 4524 basically like the shell, with the added convenience of going home
4521 4525 when called with no args.
4522 4526
4523 4527 * pushd/popd slightly modified to mimic shell behavior more
4524 4528 closely.
4525 4529
4526 4530 * Added env,pushd,popd from ShellServices as magic functions. I
4527 4531 think the cleanest will be to port all desired functions from
4528 4532 ShellServices as magics and remove ShellServices altogether. This
4529 4533 will provide a single, clean way of adding functionality
4530 4534 (shell-type or otherwise) to IP.
4531 4535
4532 4536 2001-11-04 Fernando Perez <fperez@colorado.edu>
4533 4537
4534 4538 * Added .ipython/ directory to sys.path. This way users can keep
4535 4539 customizations there and access them via import.
4536 4540
4537 4541 2001-11-03 Fernando Perez <fperez@colorado.edu>
4538 4542
4539 4543 * Opened version 0.1.1 for new changes.
4540 4544
4541 4545 * Changed version number to 0.1.0: first 'public' release, sent to
4542 4546 Nathan and Janko.
4543 4547
4544 4548 * Lots of small fixes and tweaks.
4545 4549
4546 4550 * Minor changes to whos format. Now strings are shown, snipped if
4547 4551 too long.
4548 4552
4549 4553 * Changed ShellServices to work on __main__ so they show up in @who
4550 4554
4551 4555 * Help also works with ? at the end of a line:
4552 4556 ?sin and sin?
4553 4557 both produce the same effect. This is nice, as often I use the
4554 4558 tab-complete to find the name of a method, but I used to then have
4555 4559 to go to the beginning of the line to put a ? if I wanted more
4556 4560 info. Now I can just add the ? and hit return. Convenient.
4557 4561
4558 4562 2001-11-02 Fernando Perez <fperez@colorado.edu>
4559 4563
4560 4564 * Python version check (>=2.1) added.
4561 4565
4562 4566 * Added LazyPython documentation. At this point the docs are quite
4563 4567 a mess. A cleanup is in order.
4564 4568
4565 4569 * Auto-installer created. For some bizarre reason, the zipfiles
4566 4570 module isn't working on my system. So I made a tar version
4567 4571 (hopefully the command line options in various systems won't kill
4568 4572 me).
4569 4573
4570 4574 * Fixes to Struct in genutils. Now all dictionary-like methods are
4571 4575 protected (reasonably).
4572 4576
4573 4577 * Added pager function to genutils and changed ? to print usage
4574 4578 note through it (it was too long).
4575 4579
4576 4580 * Added the LazyPython functionality. Works great! I changed the
4577 4581 auto-quote escape to ';', it's on home row and next to '. But
4578 4582 both auto-quote and auto-paren (still /) escapes are command-line
4579 4583 parameters.
4580 4584
4581 4585
4582 4586 2001-11-01 Fernando Perez <fperez@colorado.edu>
4583 4587
4584 4588 * Version changed to 0.0.7. Fairly large change: configuration now
4585 4589 is all stored in a directory, by default .ipython. There, all
4586 4590 config files have normal looking names (not .names)
4587 4591
4588 4592 * Version 0.0.6 Released first to Lucas and Archie as a test
4589 4593 run. Since it's the first 'semi-public' release, change version to
4590 4594 > 0.0.6 for any changes now.
4591 4595
4592 4596 * Stuff I had put in the ipplib.py changelog:
4593 4597
4594 4598 Changes to InteractiveShell:
4595 4599
4596 4600 - Made the usage message a parameter.
4597 4601
4598 4602 - Require the name of the shell variable to be given. It's a bit
4599 4603 of a hack, but allows the name 'shell' not to be hardwire in the
4600 4604 magic (@) handler, which is problematic b/c it requires
4601 4605 polluting the global namespace with 'shell'. This in turn is
4602 4606 fragile: if a user redefines a variable called shell, things
4603 4607 break.
4604 4608
4605 4609 - magic @: all functions available through @ need to be defined
4606 4610 as magic_<name>, even though they can be called simply as
4607 4611 @<name>. This allows the special command @magic to gather
4608 4612 information automatically about all existing magic functions,
4609 4613 even if they are run-time user extensions, by parsing the shell
4610 4614 instance __dict__ looking for special magic_ names.
4611 4615
4612 4616 - mainloop: added *two* local namespace parameters. This allows
4613 4617 the class to differentiate between parameters which were there
4614 4618 before and after command line initialization was processed. This
4615 4619 way, later @who can show things loaded at startup by the
4616 4620 user. This trick was necessary to make session saving/reloading
4617 4621 really work: ideally after saving/exiting/reloading a session,
4618 4622 *everythin* should look the same, including the output of @who. I
4619 4623 was only able to make this work with this double namespace
4620 4624 trick.
4621 4625
4622 4626 - added a header to the logfile which allows (almost) full
4623 4627 session restoring.
4624 4628
4625 4629 - prepend lines beginning with @ or !, with a and log
4626 4630 them. Why? !lines: may be useful to know what you did @lines:
4627 4631 they may affect session state. So when restoring a session, at
4628 4632 least inform the user of their presence. I couldn't quite get
4629 4633 them to properly re-execute, but at least the user is warned.
4630 4634
4631 4635 * Started ChangeLog.
@@ -1,9152 +1,9161 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 10
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 1.1in
62 62 \topmargin 1in
63 63 \rightmargin 1.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 1
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 \layout Standard
91 91
92 92
93 93 \begin_inset ERT
94 94 status Collapsed
95 95
96 96 \layout Standard
97 97
98 98 \backslash
99 99 latex{
100 100 \end_inset
101 101
102 102
103 103 \begin_inset LatexCommand \tableofcontents{}
104 104
105 105 \end_inset
106 106
107 107
108 108 \begin_inset ERT
109 109 status Collapsed
110 110
111 111 \layout Standard
112 112 }
113 113 \end_inset
114 114
115 115
116 116 \layout Standard
117 117
118 118
119 119 \begin_inset ERT
120 120 status Open
121 121
122 122 \layout Standard
123 123
124 124 \backslash
125 125 html{
126 126 \backslash
127 127 bodytext{bgcolor=#ffffff}}
128 128 \end_inset
129 129
130 130
131 131 \layout Section
132 132 \pagebreak_top
133 133 Overview
134 134 \layout Standard
135 135
136 136 One of Python's most useful features is its interactive interpreter.
137 137 This system allows very fast testing of ideas without the overhead of creating
138 138 test files as is typical in most programming languages.
139 139 However, the interpreter supplied with the standard Python distribution
140 140 is somewhat limited for extended interactive use.
141 141 \layout Standard
142 142
143 143 IPython is a free software project (released under the BSD license) which
144 144 tries to:
145 145 \layout Enumerate
146 146
147 147 Provide an interactive shell superior to Python's default.
148 148 IPython has many features for object introspection, system shell access,
149 149 and its own special command system for adding functionality when working
150 150 interactively.
151 151 It tries to be a very efficient environment both for Python code development
152 152 and for exploration of problems using Python objects (in situations like
153 153 data analysis).
154 154 \layout Enumerate
155 155
156 156 Serve as an embeddable, ready to use interpreter for your own programs.
157 157 IPython can be started with a single call from inside another program,
158 158 providing access to the current namespace.
159 159 This can be very useful both for debugging purposes and for situations
160 160 where a blend of batch-processing and interactive exploration are needed.
161 161 \layout Enumerate
162 162
163 163 Offer a flexible framework which can be used as the base environment for
164 164 other systems with Python as the underlying language.
165 165 Specifically scientific environments like Mathematica, IDL and Matlab inspired
166 166 its design, but similar ideas can be useful in many fields.
167 167 \layout Subsection
168 168
169 169 Main features
170 170 \layout Itemize
171 171
172 172 Dynamic object introspection.
173 173 One can access docstrings, function definition prototypes, source code,
174 174 source files and other details of any object accessible to the interpreter
175 175 with a single keystroke (`
176 176 \family typewriter
177 177 ?
178 178 \family default
179 179 ').
180 180 \layout Itemize
181 181
182 182 Completion in the local namespace, by typing TAB at the prompt.
183 183 This works for keywords, methods, variables and files in the current directory.
184 184 This is supported via the readline library, and full access to configuring
185 185 readline's behavior is provided.
186 186 \layout Itemize
187 187
188 188 Numbered input/output prompts with command history (persistent across sessions
189 189 and tied to each profile), full searching in this history and caching of
190 190 all input and output.
191 191 \layout Itemize
192 192
193 193 User-extensible `magic' commands.
194 194 A set of commands prefixed with
195 195 \family typewriter
196 196 %
197 197 \family default
198 198 is available for controlling IPython itself and provides directory control,
199 199 namespace information and many aliases to common system shell commands.
200 200 \layout Itemize
201 201
202 202 Alias facility for defining your own system aliases.
203 203 \layout Itemize
204 204
205 205 Complete system shell access.
206 206 Lines starting with ! are passed directly to the system shell, and using
207 207 !! captures shell output into python variables for further use.
208 208 \layout Itemize
209 209
210 210 All calls to the system (via aliases or via !) have their standard output/error
211 211 automatically stored as strings, and also available as lists.
212 212 \layout Itemize
213 213
214 214 Background execution of Python commands in a separate thread.
215 215 IPython has an internal job manager called
216 216 \family typewriter
217 217 jobs
218 218 \family default
219 219 , and a conveninence backgrounding magic function called
220 220 \family typewriter
221 221 %bg
222 222 \family default
223 223 .
224 224 \layout Itemize
225 225
226 226 The ability to expand python variables when calling the system shell.
227 227 In a shell command, any python variable prefixed with
228 228 \family typewriter
229 229 $
230 230 \family default
231 231 is expanded.
232 232 A double
233 233 \family typewriter
234 234 $$
235 235 \family default
236 236 allows passing a literal
237 237 \family typewriter
238 238 $
239 239 \family default
240 240 to the shell (for access to shell and environment variables like
241 241 \family typewriter
242 242 $PATH
243 243 \family default
244 244 ).
245 245 \layout Itemize
246 246
247 247 Filesystem navigation, via a magic
248 248 \family typewriter
249 249 %cd
250 250 \family default
251 251 command, along with a persistent bookmark system (using
252 252 \family typewriter
253 253 %bookmark
254 254 \family default
255 255 ) for fast access to frequently visited directories.
256 256 \layout Itemize
257 257
258 258 Automatic indentation (optional) of code as you type (through the readline
259 259 library).
260 260 \layout Itemize
261 261
262 262 Macro system for quickly re-executing multiple lines of previous input with
263 263 a single name.
264 264 \layout Itemize
265 265
266 266 Session logging (you can then later use these logs as code in your programs).
267 267 \layout Itemize
268 268
269 269 Session restoring: logs can be replayed to restore a previous session to
270 270 the state where you left it.
271 271 \layout Itemize
272 272
273 273 Verbose and colored exception traceback printouts.
274 274 Easier to parse visually, and in verbose mode they produce a lot of useful
275 275 debugging information (basically a terminal version of the cgitb module).
276 276 \layout Itemize
277 277
278 278 Auto-parentheses: callable objects can be executed without parentheses:
279 279
280 280 \family typewriter
281 281 `sin 3'
282 282 \family default
283 283 is automatically converted to
284 284 \family typewriter
285 285 `sin(3)
286 286 \family default
287 287 '.
288 288 \layout Itemize
289 289
290 290 Auto-quoting: using `
291 291 \family typewriter
292 292 ,
293 293 \family default
294 294 ' or `
295 295 \family typewriter
296 296 ;
297 297 \family default
298 298 ' as the first character forces auto-quoting of the rest of the line:
299 299 \family typewriter
300 300 `,my_function a\SpecialChar ~
301 301 b'
302 302 \family default
303 303 becomes automatically
304 304 \family typewriter
305 305 `my_function("a","b")'
306 306 \family default
307 307 , while
308 308 \family typewriter
309 309 `;my_function a\SpecialChar ~
310 310 b'
311 311 \family default
312 312 becomes
313 313 \family typewriter
314 314 `my_function("a b")'
315 315 \family default
316 316 .
317 317 \layout Itemize
318 318
319 319 Extensible input syntax.
320 320 You can define filters that pre-process user input to simplify input in
321 321 special situations.
322 322 This allows for example pasting multi-line code fragments which start with
323 323
324 324 \family typewriter
325 325 `>>>'
326 326 \family default
327 327 or
328 328 \family typewriter
329 329 `...'
330 330 \family default
331 331 such as those from other python sessions or the standard Python documentation.
332 332 \layout Itemize
333 333
334 334 Flexible configuration system.
335 335 It uses a configuration file which allows permanent setting of all command-line
336 336 options, module loading, code and file execution.
337 337 The system allows recursive file inclusion, so you can have a base file
338 338 with defaults and layers which load other customizations for particular
339 339 projects.
340 340 \layout Itemize
341 341
342 342 Embeddable.
343 343 You can call IPython as a python shell inside your own python programs.
344 344 This can be used both for debugging code or for providing interactive abilities
345 345 to your programs with knowledge about the local namespaces (very useful
346 346 in debugging and data analysis situations).
347 347 \layout Itemize
348 348
349 349 Easy debugger access.
350 350 You can set IPython to call up an enhanced version of the Python debugger
351 351 (
352 352 \family typewriter
353 353 pdb
354 354 \family default
355 355 ) every time there is an uncaught exception.
356 356 This drops you inside the code which triggered the exception with all the
357 357 data live and it is possible to navigate the stack to rapidly isolate the
358 358 source of a bug.
359 359 The
360 360 \family typewriter
361 361 %run
362 362 \family default
363 363 magic command --with the
364 364 \family typewriter
365 365 -d
366 366 \family default
367 367 option-- can run any script under
368 368 \family typewriter
369 369 pdb
370 370 \family default
371 371 's control, automatically setting initial breakpoints for you.
372 372 This version of
373 373 \family typewriter
374 374 pdb
375 375 \family default
376 376 has IPython-specific improvements, including tab-completion and traceback
377 377 coloring support.
378 378 \layout Itemize
379 379
380 380 Profiler support.
381 381 You can run single statements (similar to
382 382 \family typewriter
383 383 profile.run()
384 384 \family default
385 385 ) or complete programs under the profiler's control.
386 386 While this is possible with the standard
387 387 \family typewriter
388 388 profile
389 389 \family default
390 390 module, IPython wraps this functionality with magic commands (see
391 391 \family typewriter
392 392 `%prun'
393 393 \family default
394 394 and
395 395 \family typewriter
396 396 `%run -p
397 397 \family default
398 398 ') convenient for rapid interactive work.
399 399 \layout Subsection
400 400
401 401 Portability and Python requirements
402 402 \layout Standard
403 403
404 404
405 405 \series bold
406 406 Python requirements:
407 407 \series default
408 408 IPython works with Python version 2.2 or newer.
409 409 It has been tested with Python 2.4 and no problems have been reported.
410 410 Support for Python 2.1 hasn't been recently tested, since I don't have access
411 411 to it on any of my systems.
412 412 But I suspect there may be some problems with Python 2.1, because some of
413 413 the newer code may use 2.2 features.
414 414 \layout Standard
415 415
416 416 IPython is developed under
417 417 \series bold
418 418 Linux
419 419 \series default
420 420 , but it should work in any reasonable Unix-type system (tested OK under
421 421 Solaris and the *BSD family, for which a port exists thanks to Dryice Liu).
422 422 \layout Standard
423 423
424 424
425 425 \series bold
426 426 Mac OS X
427 427 \series default
428 428 : it works, apparently without any problems (thanks to Jim Boyle at Lawrence
429 429 Livermore for the information).
430 430 Thanks to Andrea Riciputi, Fink support is available.
431 431 \layout Standard
432 432
433 433
434 434 \series bold
435 435 CygWin
436 436 \series default
437 437 : it works mostly OK, though some users have reported problems with prompt
438 438 coloring.
439 439 No satisfactory solution to this has been found so far, you may want to
440 440 disable colors permanently in the
441 441 \family typewriter
442 442 ipythonrc
443 443 \family default
444 444 configuration file if you experience problems.
445 445 If you have proper color support under cygwin, please post to the IPython
446 446 mailing list so this issue can be resolved for all users.
447 447 \layout Standard
448 448
449 449
450 450 \series bold
451 451 Windows
452 452 \series default
453 453 : it works well under Windows XP/2k, and I suspect NT should behave similarly.
454 454 Section\SpecialChar ~
455 455
456 456 \begin_inset LatexCommand \ref{sub:Under-Windows}
457 457
458 458 \end_inset
459 459
460 460 describes installation details for Windows, including some additional tools
461 461 needed on this platform.
462 462 \layout Standard
463 463
464 464 Windows 9x support is present, and has been reported to work fine (at least
465 465 on WinME).
466 466 \layout Standard
467 467
468 468 Please note, however, that I have very little access to and experience with
469 469 Windows development.
470 470 For this reason, Windows-specific bugs tend to linger far longer than I
471 471 would like, and often I just can't find a satisfactory solution.
472 472 If any Windows user wants to join in with development help, all hands are
473 473 always welcome.
474 474 \layout Subsection
475 475
476 476 Location
477 477 \layout Standard
478 478
479 479 IPython is generously hosted at
480 480 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
481 481
482 482 \end_inset
483 483
484 484 by the SciPy project.
485 485 This site offers downloads, subversion access, mailing lists and a bug
486 486 tracking system.
487 487 I am very grateful to Enthought (
488 488 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
489 489
490 490 \end_inset
491 491
492 492 ) and all of the SciPy team for their contribution.
493 493 \layout Section
494 494
495 495
496 496 \begin_inset LatexCommand \label{sec:install}
497 497
498 498 \end_inset
499 499
500 500 Installation
501 501 \layout Subsection
502 502
503 503 Instant instructions
504 504 \layout Standard
505 505
506 506 If you are of the impatient kind, under Linux/Unix simply untar/unzip the
507 507 download, then install with
508 508 \family typewriter
509 509 `python setup.py install'
510 510 \family default
511 511 .
512 512 Under Windows, double-click on the provided
513 513 \family typewriter
514 514 .exe
515 515 \family default
516 516 binary installer.
517 517 \layout Standard
518 518
519 519 Then, take a look at Sections
520 520 \begin_inset LatexCommand \ref{sec:good_config}
521 521
522 522 \end_inset
523 523
524 524 for configuring things optimally and
525 525 \begin_inset LatexCommand \ref{sec:quick_tips}
526 526
527 527 \end_inset
528 528
529 529 for quick tips on efficient use of IPython.
530 530 You can later refer to the rest of the manual for all the gory details.
531 531 \layout Standard
532 532
533 533 See the notes in sec.
534 534
535 535 \begin_inset LatexCommand \ref{sec:upgrade}
536 536
537 537 \end_inset
538 538
539 539 for upgrading IPython versions.
540 540 \layout Subsection
541 541
542 542 Detailed Unix instructions (Linux, Mac OS X, etc.)
543 543 \layout Standard
544 544
545 545 For RPM based systems, simply install the supplied package in the usual
546 546 manner.
547 547 If you download the tar archive, the process is:
548 548 \layout Enumerate
549 549
550 550 Unzip/untar the
551 551 \family typewriter
552 552 ipython-XXX.tar.gz
553 553 \family default
554 554 file wherever you want (
555 555 \family typewriter
556 556 XXX
557 557 \family default
558 558 is the version number).
559 559 It will make a directory called
560 560 \family typewriter
561 561 ipython-XXX.
562 562
563 563 \family default
564 564 Change into that directory where you will find the files
565 565 \family typewriter
566 566 README
567 567 \family default
568 568 and
569 569 \family typewriter
570 570 setup.py
571 571 \family default
572 572 .
573 573
574 574 \family typewriter
575 575 O
576 576 \family default
577 577 nce you've completed the installation, you can safely remove this directory.
578 578
579 579 \layout Enumerate
580 580
581 581 If you are installing over a previous installation of version 0.2.0 or earlier,
582 582 first remove your
583 583 \family typewriter
584 584 $HOME/.ipython
585 585 \family default
586 586 directory, since the configuration file format has changed somewhat (the
587 587 '=' were removed from all option specifications).
588 588 Or you can call ipython with the
589 589 \family typewriter
590 590 -upgrade
591 591 \family default
592 592 option and it will do this automatically for you.
593 593 \layout Enumerate
594 594
595 595 IPython uses distutils, so you can install it by simply typing at the system
596 596 prompt (don't type the
597 597 \family typewriter
598 598 $
599 599 \family default
600 600 )
601 601 \newline
602 602
603 603 \family typewriter
604 604 $ python setup.py install
605 605 \family default
606 606
607 607 \newline
608 608 Note that this assumes you have root access to your machine.
609 609 If you don't have root access or don't want IPython to go in the default
610 610 python directories, you'll need to use the
611 611 \begin_inset ERT
612 612 status Collapsed
613 613
614 614 \layout Standard
615 615
616 616 \backslash
617 617 verb|--home|
618 618 \end_inset
619 619
620 620 option (or
621 621 \begin_inset ERT
622 622 status Collapsed
623 623
624 624 \layout Standard
625 625
626 626 \backslash
627 627 verb|--prefix|
628 628 \end_inset
629 629
630 630 ).
631 631 For example:
632 632 \newline
633 633
634 634 \begin_inset ERT
635 635 status Collapsed
636 636
637 637 \layout Standard
638 638
639 639 \backslash
640 640 verb|$ python setup.py install --home $HOME/local|
641 641 \end_inset
642 642
643 643
644 644 \newline
645 645 will install IPython into
646 646 \family typewriter
647 647 $HOME/local
648 648 \family default
649 649 and its subdirectories (creating them if necessary).
650 650 \newline
651 651 You can type
652 652 \newline
653 653
654 654 \begin_inset ERT
655 655 status Collapsed
656 656
657 657 \layout Standard
658 658
659 659 \backslash
660 660 verb|$ python setup.py --help|
661 661 \end_inset
662 662
663 663
664 664 \newline
665 665 for more details.
666 666 \newline
667 667 Note that if you change the default location for
668 668 \begin_inset ERT
669 669 status Collapsed
670 670
671 671 \layout Standard
672 672
673 673 \backslash
674 674 verb|--home|
675 675 \end_inset
676 676
677 677 at installation, IPython may end up installed at a location which is not
678 678 part of your
679 679 \family typewriter
680 680 $PYTHONPATH
681 681 \family default
682 682 environment variable.
683 683 In this case, you'll need to configure this variable to include the actual
684 684 directory where the
685 685 \family typewriter
686 686 IPython/
687 687 \family default
688 688 directory ended (typically the value you give to
689 689 \begin_inset ERT
690 690 status Collapsed
691 691
692 692 \layout Standard
693 693
694 694 \backslash
695 695 verb|--home|
696 696 \end_inset
697 697
698 698 plus
699 699 \family typewriter
700 700 /lib/python
701 701 \family default
702 702 ).
703 703 \layout Subsubsection
704 704
705 705 Mac OSX information
706 706 \layout Standard
707 707
708 708 Under OSX, there is a choice you need to make.
709 709 Apple ships its own build of Python, which lives in the core OSX filesystem
710 710 hierarchy.
711 711 You can also manually install a separate Python, either purely by hand
712 712 (typically in
713 713 \family typewriter
714 714 /usr/local
715 715 \family default
716 716 ) or by using Fink, which puts everything under
717 717 \family typewriter
718 718 /sw
719 719 \family default
720 720 .
721 721 Which route to follow is a matter of personal preference, as I've seen
722 722 users who favor each of the approaches.
723 723 Here I will simply list the known installation issues under OSX, along
724 724 with their solutions.
725 725 \layout Standard
726 726
727 727 This page:
728 728 \begin_inset LatexCommand \htmlurl{http://geosci.uchicago.edu/~tobis/pylab.html}
729 729
730 730 \end_inset
731 731
732 732 contains information on this topic, with additional details on how to make
733 733 IPython and matplotlib play nicely under OSX.
734 734 \layout Subsubsection*
735 735
736 736 GUI problems
737 737 \layout Standard
738 738
739 739 The following instructions apply to an install of IPython under OSX from
740 740 unpacking the
741 741 \family typewriter
742 742 .tar.gz
743 743 \family default
744 744 distribution and installing it for the default Python interpreter shipped
745 745 by Apple.
746 746 If you are using a fink install, fink will take care of these details for
747 747 you, by installing IPython against fink's Python.
748 748 \layout Standard
749 749
750 750 IPython offers various forms of support for interacting with graphical applicati
751 751 ons from the command line, from simple Tk apps (which are in principle always
752 752 supported by Python) to interactive control of WX, Qt and GTK apps.
753 753 Under OSX, however, this requires that ipython is installed by calling
754 754 the special
755 755 \family typewriter
756 756 pythonw
757 757 \family default
758 758 script at installation time, which takes care of coordinating things with
759 759 Apple's graphical environment.
760 760 \layout Standard
761 761
762 762 So when installing under OSX, it is best to use the following command:
763 763 \family typewriter
764 764
765 765 \newline
766 766
767 767 \family default
768 768
769 769 \begin_inset ERT
770 770 status Collapsed
771 771
772 772 \layout Standard
773 773
774 774 \backslash
775 775 verb| $ sudo pythonw setup.py install --install-scripts=/usr/local/bin|
776 776 \end_inset
777 777
778 778
779 779 \newline
780 780 or
781 781 \newline
782 782
783 783 \begin_inset ERT
784 784 status Open
785 785
786 786 \layout Standard
787 787
788 788 \backslash
789 789 verb| $ sudo pythonw setup.py install --install-scripts=/usr/bin|
790 790 \end_inset
791 791
792 792
793 793 \newline
794 794 depending on where you like to keep hand-installed executables.
795 795 \layout Standard
796 796
797 797 The resulting script will have an appropriate shebang line (the first line
798 798 in the script whic begins with
799 799 \family typewriter
800 800 #!...
801 801 \family default
802 802 ) such that the ipython interpreter can interact with the OS X GUI.
803 803 If the installed version does not work and has a shebang line that points
804 804 to, for example, just
805 805 \family typewriter
806 806 /usr/bin/python
807 807 \family default
808 808 , then you might have a stale, cached version in your
809 809 \family typewriter
810 810 build/scripts-<python-version>
811 811 \family default
812 812 directory.
813 813 Delete that directory and rerun the
814 814 \family typewriter
815 815 setup.py
816 816 \family default
817 817 .
818 818
819 819 \layout Standard
820 820
821 821 It is also a good idea to use the special flag
822 822 \begin_inset ERT
823 823 status Collapsed
824 824
825 825 \layout Standard
826 826
827 827 \backslash
828 828 verb|--install-scripts|
829 829 \end_inset
830 830
831 831 as indicated above, to ensure that the ipython scripts end up in a location
832 832 which is part of your
833 833 \family typewriter
834 834 $PATH
835 835 \family default
836 836 .
837 837 Otherwise Apple's Python will put the scripts in an internal directory
838 838 not available by default at the command line (if you use
839 839 \family typewriter
840 840 /usr/local/bin
841 841 \family default
842 842 , you need to make sure this is in your
843 843 \family typewriter
844 844 $PATH
845 845 \family default
846 846 , which may not be true by default).
847 847 \layout Subsubsection*
848 848
849 849 Readline problems
850 850 \layout Standard
851 851
852 852 By default, the Python version shipped by Apple does
853 853 \emph on
854 854 not
855 855 \emph default
856 856 include the readline library, so central to IPython's behavior.
857 857 If you install IPython against Apple's Python, you will not have arrow
858 858 keys, tab completion, etc.
859 859 For Mac OSX 10.3 (Panther), you can find a prebuilt readline library here:
860 860 \newline
861 861
862 862 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/readline-5.0-py2.3-macosx10.3.zip}
863 863
864 864 \end_inset
865 865
866 866
867 867 \layout Standard
868 868
869 869 If you are using OSX 10.4 (Tiger), after installing this package you need
870 870 to either:
871 871 \layout Enumerate
872 872
873 873 move
874 874 \family typewriter
875 875 readline.so
876 876 \family default
877 877 from
878 878 \family typewriter
879 879 /Library/Python/2.3
880 880 \family default
881 881 to
882 882 \family typewriter
883 883 /Library/Python/2.3/site-packages
884 884 \family default
885 885 , or
886 886 \layout Enumerate
887 887
888 888 install
889 889 \begin_inset LatexCommand \htmlurl{http://pythonmac.org/packages/TigerPython23Compat.pkg.zip}
890 890
891 891 \end_inset
892 892
893 893
894 894 \layout Standard
895 895
896 896 Users installing against Fink's Python or a properly hand-built one should
897 897 not have this problem.
898 898 \layout Subsubsection*
899 899
900 900 DarwinPorts
901 901 \layout Standard
902 902
903 903 I report here a message from an OSX user, who suggests an alternative means
904 904 of using IPython under this operating system with good results.
905 905 Please let me know of any updates that may be useful for this section.
906 906 His message is reproduced verbatim below:
907 907 \layout Quote
908 908
909 909 From: Markus Banfi
910 910 \family typewriter
911 911 <markus.banfi-AT-mospheira.net>
912 912 \layout Quote
913 913
914 914 As a MacOS X (10.4.2) user I prefer to install software using DawinPorts instead
915 915 of Fink.
916 916 I had no problems installing ipython with DarwinPorts.
917 917 It's just:
918 918 \layout Quote
919 919
920 920
921 921 \family typewriter
922 922 sudo port install py-ipython
923 923 \layout Quote
924 924
925 925 It automatically resolved all dependencies (python24, readline, py-readline).
926 926 So far I did not encounter any problems with the DarwinPorts port of ipython.
927 927
928 928 \layout Subsection
929 929
930 930
931 931 \begin_inset LatexCommand \label{sub:Under-Windows}
932 932
933 933 \end_inset
934 934
935 935 Windows instructions
936 936 \layout Standard
937 937
938 938 Some of IPython's very useful features are:
939 939 \layout Itemize
940 940
941 941 Integrated readline support (Tab-based file, object and attribute completion,
942 942 input history across sessions, editable command line, etc.)
943 943 \layout Itemize
944 944
945 945 Coloring of prompts, code and tracebacks.
946 946 \layout Standard
947 947
948 948 These, by default, are only available under Unix-like operating systems.
949 949 However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit
950 950 from them.
951 951 His readline library implements both GNU readline functionality and color
952 952 support, so that IPython under Windows XP/2k can be as friendly and powerful
953 953 as under Unix-like environments.
954 954 \layout Standard
955 955
956 956 The
957 957 \family typewriter
958 958 readline
959 959 \family default
960 960 extension needs two other libraries to work, so in all you need:
961 961 \layout Enumerate
962 962
963 963
964 964 \family typewriter
965 965 PyWin32
966 966 \family default
967 967 from
968 968 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/mhammond}
969 969
970 970 \end_inset
971 971
972 972 .
973 973 \layout Enumerate
974 974
975 975
976 976 \family typewriter
977 977 CTypes
978 978 \family default
979 979 from
980 980 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/theller/ctypes}
981 981
982 982 \end_inset
983 983
984 984 (you
985 985 \emph on
986 986 must
987 987 \emph default
988 988 use version 0.9.1 or newer).
989 989 \layout Enumerate
990 990
991 991
992 992 \family typewriter
993 993 Readline
994 994 \family default
995 995 for Windows from
996 996 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools}
997 997
998 998 \end_inset
999 999
1000 1000 .
1001 1001 \layout Standard
1002 1002
1003 1003
1004 1004 \series bold
1005 1005 Warning about a broken readline-like library:
1006 1006 \series default
1007 1007 several users have reported problems stemming from using the pseudo-readline
1008 1008 library at
1009 1009 \begin_inset LatexCommand \htmlurl{http://newcenturycomputers.net/projects/readline.html}
1010 1010
1011 1011 \end_inset
1012 1012
1013 1013 .
1014 1014 This is a broken library which, while called readline, only implements
1015 1015 an incomplete subset of the readline API.
1016 1016 Since it is still called readline, it fools IPython's detection mechanisms
1017 1017 and causes unpredictable crashes later.
1018 1018 If you wish to use IPython under Windows, you must NOT use this library,
1019 1019 which for all purposes is (at least as of version 1.6) terminally broken.
1020 1020 \layout Subsubsection
1021 1021
1022 1022 Installation procedure
1023 1023 \layout Standard
1024 1024
1025 1025 Once you have the above installed, from the IPython download directory grab
1026 1026 the
1027 1027 \family typewriter
1028 1028 ipython-XXX.win32.exe
1029 1029 \family default
1030 1030 file, where
1031 1031 \family typewriter
1032 1032 XXX
1033 1033 \family default
1034 1034 represents the version number.
1035 1035 This is a regular windows executable installer, which you can simply double-cli
1036 1036 ck to install.
1037 1037 It will add an entry for IPython to your Start Menu, as well as registering
1038 1038 IPython in the Windows list of applications, so you can later uninstall
1039 1039 it from the Control Panel.
1040 1040
1041 1041 \layout Standard
1042 1042
1043 1043 IPython tries to install the configuration information in a directory named
1044 1044
1045 1045 \family typewriter
1046 1046 .ipython
1047 1047 \family default
1048 1048 (
1049 1049 \family typewriter
1050 1050 _ipython
1051 1051 \family default
1052 1052 under Windows) located in your `home' directory.
1053 1053 IPython sets this directory by looking for a
1054 1054 \family typewriter
1055 1055 HOME
1056 1056 \family default
1057 1057 environment variable; if such a variable does not exist, it uses
1058 1058 \family typewriter
1059 1059 HOMEDRIVE
1060 1060 \backslash
1061 1061 HOMEPATH
1062 1062 \family default
1063 1063 (these are always defined by Windows).
1064 1064 This typically gives something like
1065 1065 \family typewriter
1066 1066 C:
1067 1067 \backslash
1068 1068 Documents and Settings
1069 1069 \backslash
1070 1070 YourUserName
1071 1071 \family default
1072 1072 , but your local details may vary.
1073 1073 In this directory you will find all the files that configure IPython's
1074 1074 defaults, and you can put there your profiles and extensions.
1075 1075 This directory is automatically added by IPython to
1076 1076 \family typewriter
1077 1077 sys.path
1078 1078 \family default
1079 1079 , so anything you place there can be found by
1080 1080 \family typewriter
1081 1081 import
1082 1082 \family default
1083 1083 statements.
1084 1084 \layout Paragraph
1085 1085
1086 1086 Upgrading
1087 1087 \layout Standard
1088 1088
1089 1089 For an IPython upgrade, you should first uninstall the previous version.
1090 1090 This will ensure that all files and directories (such as the documentation)
1091 1091 which carry embedded version strings in their names are properly removed.
1092 1092 \layout Paragraph
1093 1093
1094 1094 Manual installation under Win32
1095 1095 \layout Standard
1096 1096
1097 1097 In case the automatic installer does not work for some reason, you can download
1098 1098 the
1099 1099 \family typewriter
1100 1100 ipython-XXX.tar.gz
1101 1101 \family default
1102 1102 file, which contains the full IPython source distribution (the popular
1103 1103 WinZip can read
1104 1104 \family typewriter
1105 1105 .tar.gz
1106 1106 \family default
1107 1107 files).
1108 1108 After uncompressing the archive, you can install it at a command terminal
1109 1109 just like any other Python module, by using
1110 1110 \family typewriter
1111 1111 `python setup.py install'
1112 1112 \family default
1113 1113 .
1114 1114
1115 1115 \layout Standard
1116 1116
1117 1117 After the installation, run the supplied
1118 1118 \family typewriter
1119 1119 win32_manual_post_install.py
1120 1120 \family default
1121 1121 script, which creates the necessary Start Menu shortcuts for you.
1122 1122 \layout Subsection
1123 1123
1124 1124
1125 1125 \begin_inset LatexCommand \label{sec:upgrade}
1126 1126
1127 1127 \end_inset
1128 1128
1129 1129 Upgrading from a previous version
1130 1130 \layout Standard
1131 1131
1132 1132 If you are upgrading from a previous version of IPython, after doing the
1133 1133 routine installation described above, you should call IPython with the
1134 1134
1135 1135 \family typewriter
1136 1136 -upgrade
1137 1137 \family default
1138 1138 option the first time you run your new copy.
1139 1139 This will automatically update your configuration directory while preserving
1140 1140 copies of your old files.
1141 1141 You can then later merge back any personal customizations you may have
1142 1142 made into the new files.
1143 1143 It is a good idea to do this as there may be new options available in the
1144 1144 new configuration files which you will not have.
1145 1145 \layout Standard
1146 1146
1147 1147 Under Windows, if you don't know how to call python scripts with arguments
1148 1148 from a command line, simply delete the old config directory and IPython
1149 1149 will make a new one.
1150 1150 Win2k and WinXP users will find it in
1151 1151 \family typewriter
1152 1152 C:
1153 1153 \backslash
1154 1154 Documents and Settings
1155 1155 \backslash
1156 1156 YourUserName
1157 1157 \backslash
1158 1158 _ipython
1159 1159 \family default
1160 1160 , and Win 9x users under
1161 1161 \family typewriter
1162 1162 C:
1163 1163 \backslash
1164 1164 Program Files
1165 1165 \backslash
1166 1166 IPython
1167 1167 \backslash
1168 1168 _ipython.
1169 1169 \layout Section
1170 1170
1171 1171
1172 1172 \begin_inset LatexCommand \label{sec:good_config}
1173 1173
1174 1174 \end_inset
1175 1175
1176 1176
1177 1177 \begin_inset OptArg
1178 1178 collapsed true
1179 1179
1180 1180 \layout Standard
1181 1181
1182 1182 Initial configuration
1183 1183 \begin_inset ERT
1184 1184 status Collapsed
1185 1185
1186 1186 \layout Standard
1187 1187
1188 1188 \backslash
1189 1189 ldots
1190 1190 \end_inset
1191 1191
1192 1192
1193 1193 \end_inset
1194 1194
1195 1195 Initial configuration of your environment
1196 1196 \layout Standard
1197 1197
1198 1198 This section will help you set various things in your environment for your
1199 1199 IPython sessions to be as efficient as possible.
1200 1200 All of IPython's configuration information, along with several example
1201 1201 files, is stored in a directory named by default
1202 1202 \family typewriter
1203 1203 $HOME/.ipython
1204 1204 \family default
1205 1205 .
1206 1206 You can change this by defining the environment variable
1207 1207 \family typewriter
1208 1208 IPYTHONDIR
1209 1209 \family default
1210 1210 , or at runtime with the command line option
1211 1211 \family typewriter
1212 1212 -ipythondir
1213 1213 \family default
1214 1214 .
1215 1215 \layout Standard
1216 1216
1217 1217 If all goes well, the first time you run IPython it should automatically
1218 1218 create a user copy of the config directory for you, based on its builtin
1219 1219 defaults.
1220 1220 You can look at the files it creates to learn more about configuring the
1221 1221 system.
1222 1222 The main file you will modify to configure IPython's behavior is called
1223 1223
1224 1224 \family typewriter
1225 1225 ipythonrc
1226 1226 \family default
1227 1227 (with a
1228 1228 \family typewriter
1229 1229 .ini
1230 1230 \family default
1231 1231 extension under Windows), included for reference in Sec.
1232 1232
1233 1233 \begin_inset LatexCommand \ref{sec:ipytonrc-sample}
1234 1234
1235 1235 \end_inset
1236 1236
1237 1237 .
1238 1238 This file is very commented and has many variables you can change to suit
1239 1239 your taste, you can find more details in Sec.
1240 1240
1241 1241 \begin_inset LatexCommand \ref{sec:customization}
1242 1242
1243 1243 \end_inset
1244 1244
1245 1245 .
1246 1246 Here we discuss the basic things you will want to make sure things are
1247 1247 working properly from the beginning.
1248 1248 \layout Subsection
1249 1249
1250 1250
1251 1251 \begin_inset LatexCommand \label{sec:help-access}
1252 1252
1253 1253 \end_inset
1254 1254
1255 1255 Access to the Python help system
1256 1256 \layout Standard
1257 1257
1258 1258 This is true for Python in general (not just for IPython): you should have
1259 1259 an environment variable called
1260 1260 \family typewriter
1261 1261 PYTHONDOCS
1262 1262 \family default
1263 1263 pointing to the directory where your HTML Python documentation lives.
1264 1264 In my system it's
1265 1265 \family typewriter
1266 1266 /usr/share/doc/python-docs-2.3.4/html
1267 1267 \family default
1268 1268 , check your local details or ask your systems administrator.
1269 1269
1270 1270 \layout Standard
1271 1271
1272 1272 This is the directory which holds the HTML version of the Python manuals.
1273 1273 Unfortunately it seems that different Linux distributions package these
1274 1274 files differently, so you may have to look around a bit.
1275 1275 Below I show the contents of this directory on my system for reference:
1276 1276 \layout Standard
1277 1277
1278 1278
1279 1279 \family typewriter
1280 1280 [html]> ls
1281 1281 \newline
1282 1282 about.dat acks.html dist/ ext/ index.html lib/ modindex.html stdabout.dat tut/
1283 1283 about.html api/ doc/ icons/ inst/ mac/ ref/ style.css
1284 1284 \layout Standard
1285 1285
1286 1286 You should really make sure this variable is correctly set so that Python's
1287 1287 pydoc-based help system works.
1288 1288 It is a powerful and convenient system with full access to the Python manuals
1289 1289 and all modules accessible to you.
1290 1290 \layout Standard
1291 1291
1292 1292 Under Windows it seems that pydoc finds the documentation automatically,
1293 1293 so no extra setup appears necessary.
1294 1294 \layout Subsection
1295 1295
1296 1296 Editor
1297 1297 \layout Standard
1298 1298
1299 1299 The
1300 1300 \family typewriter
1301 1301 %edit
1302 1302 \family default
1303 1303 command (and its alias
1304 1304 \family typewriter
1305 1305 %ed
1306 1306 \family default
1307 1307 ) will invoke the editor set in your environment as
1308 1308 \family typewriter
1309 1309 EDITOR
1310 1310 \family default
1311 1311 .
1312 1312 If this variable is not set, it will default to
1313 1313 \family typewriter
1314 1314 vi
1315 1315 \family default
1316 1316 under Linux/Unix and to
1317 1317 \family typewriter
1318 1318 notepad
1319 1319 \family default
1320 1320 under Windows.
1321 1321 You may want to set this variable properly and to a lightweight editor
1322 1322 which doesn't take too long to start (that is, something other than a new
1323 1323 instance of
1324 1324 \family typewriter
1325 1325 Emacs
1326 1326 \family default
1327 1327 ).
1328 1328 This way you can edit multi-line code quickly and with the power of a real
1329 1329 editor right inside IPython.
1330 1330
1331 1331 \layout Standard
1332 1332
1333 1333 If you are a dedicated
1334 1334 \family typewriter
1335 1335 Emacs
1336 1336 \family default
1337 1337 user, you should set up the
1338 1338 \family typewriter
1339 1339 Emacs
1340 1340 \family default
1341 1341 server so that new requests are handled by the original process.
1342 1342 This means that almost no time is spent in handling the request (assuming
1343 1343 an
1344 1344 \family typewriter
1345 1345 Emacs
1346 1346 \family default
1347 1347 process is already running).
1348 1348 For this to work, you need to set your
1349 1349 \family typewriter
1350 1350 EDITOR
1351 1351 \family default
1352 1352 environment variable to
1353 1353 \family typewriter
1354 1354 'emacsclient'
1355 1355 \family default
1356 1356 .
1357 1357
1358 1358 \family typewriter
1359 1359
1360 1360 \family default
1361 1361 The code below, supplied by Francois Pinard, can then be used in your
1362 1362 \family typewriter
1363 1363 .emacs
1364 1364 \family default
1365 1365 file to enable the server:
1366 1366 \layout Standard
1367 1367
1368 1368
1369 1369 \family typewriter
1370 1370 (defvar server-buffer-clients)
1371 1371 \newline
1372 1372 (when (and (fboundp 'server-start) (string-equal (getenv "TERM") 'xterm))
1373 1373 \newline
1374 1374
1375 1375 \begin_inset ERT
1376 1376 status Collapsed
1377 1377
1378 1378 \layout Standard
1379 1379
1380 1380 \backslash
1381 1381 hspace*{0mm}
1382 1382 \end_inset
1383 1383
1384 1384 \SpecialChar ~
1385 1385 \SpecialChar ~
1386 1386 (server-start)
1387 1387 \newline
1388 1388
1389 1389 \begin_inset ERT
1390 1390 status Collapsed
1391 1391
1392 1392 \layout Standard
1393 1393
1394 1394 \backslash
1395 1395 hspace*{0mm}
1396 1396 \end_inset
1397 1397
1398 1398 \SpecialChar ~
1399 1399 \SpecialChar ~
1400 1400 (defun fp-kill-server-with-buffer-routine ()
1401 1401 \newline
1402 1402
1403 1403 \begin_inset ERT
1404 1404 status Collapsed
1405 1405
1406 1406 \layout Standard
1407 1407
1408 1408 \backslash
1409 1409 hspace*{0mm}
1410 1410 \end_inset
1411 1411
1412 1412 \SpecialChar ~
1413 1413 \SpecialChar ~
1414 1414 \SpecialChar ~
1415 1415 \SpecialChar ~
1416 1416 (and server-buffer-clients (server-done)))
1417 1417 \newline
1418 1418
1419 1419 \begin_inset ERT
1420 1420 status Collapsed
1421 1421
1422 1422 \layout Standard
1423 1423
1424 1424 \backslash
1425 1425 hspace*{0mm}
1426 1426 \end_inset
1427 1427
1428 1428 \SpecialChar ~
1429 1429 \SpecialChar ~
1430 1430 (add-hook 'kill-buffer-hook 'fp-kill-server-with-buffer-routine))
1431 1431 \layout Standard
1432 1432
1433 1433 You can also set the value of this editor via the commmand-line option '-
1434 1434 \family typewriter
1435 1435 editor'
1436 1436 \family default
1437 1437 or in your
1438 1438 \family typewriter
1439 1439 ipythonrc
1440 1440 \family default
1441 1441 file.
1442 1442 This is useful if you wish to use specifically for IPython an editor different
1443 1443 from your typical default (and for Windows users who tend to use fewer
1444 1444 environment variables).
1445 1445 \layout Subsection
1446 1446
1447 1447 Color
1448 1448 \layout Standard
1449 1449
1450 1450 The default IPython configuration has most bells and whistles turned on
1451 1451 (they're pretty safe).
1452 1452 But there's one that
1453 1453 \emph on
1454 1454 may
1455 1455 \emph default
1456 1456 cause problems on some systems: the use of color on screen for displaying
1457 1457 information.
1458 1458 This is very useful, since IPython can show prompts and exception tracebacks
1459 1459 with various colors, display syntax-highlighted source code, and in general
1460 1460 make it easier to visually parse information.
1461 1461 \layout Standard
1462 1462
1463 1463 The following terminals seem to handle the color sequences fine:
1464 1464 \layout Itemize
1465 1465
1466 1466 Linux main text console, KDE Konsole, Gnome Terminal, E-term, rxvt, xterm.
1467 1467 \layout Itemize
1468 1468
1469 1469 CDE terminal (tested under Solaris).
1470 1470 This one boldfaces light colors.
1471 1471 \layout Itemize
1472 1472
1473 1473 (X)Emacs buffers.
1474 1474 See sec.
1475 1475 \begin_inset LatexCommand \ref{sec:emacs}
1476 1476
1477 1477 \end_inset
1478 1478
1479 1479 for more details on using IPython with (X)Emacs.
1480 1480 \layout Itemize
1481 1481
1482 1482 A Windows (XP/2k) command prompt
1483 1483 \emph on
1484 1484 with Gary Bishop's support extensions
1485 1485 \emph default
1486 1486 .
1487 1487 Gary's extensions are discussed in Sec.\SpecialChar ~
1488 1488
1489 1489 \begin_inset LatexCommand \ref{sub:Under-Windows}
1490 1490
1491 1491 \end_inset
1492 1492
1493 1493 .
1494 1494 \layout Itemize
1495 1495
1496 1496 A Windows (XP/2k) CygWin shell.
1497 1497 Although some users have reported problems; it is not clear whether there
1498 1498 is an issue for everyone or only under specific configurations.
1499 1499 If you have full color support under cygwin, please post to the IPython
1500 1500 mailing list so this issue can be resolved for all users.
1501 1501 \layout Standard
1502 1502
1503 1503 These have shown problems:
1504 1504 \layout Itemize
1505 1505
1506 1506 Windows command prompt in WinXP/2k logged into a Linux machine via telnet
1507 1507 or ssh.
1508 1508 \layout Itemize
1509 1509
1510 1510 Windows native command prompt in WinXP/2k,
1511 1511 \emph on
1512 1512 without
1513 1513 \emph default
1514 1514 Gary Bishop's extensions.
1515 1515 Once Gary's readline library is installed, the normal WinXP/2k command
1516 1516 prompt works perfectly.
1517 1517 \layout Standard
1518 1518
1519 1519 Currently the following color schemes are available:
1520 1520 \layout Itemize
1521 1521
1522 1522
1523 1523 \family typewriter
1524 1524 NoColor
1525 1525 \family default
1526 1526 : uses no color escapes at all (all escapes are empty
1527 1527 \begin_inset Quotes eld
1528 1528 \end_inset
1529 1529
1530 1530
1531 1531 \begin_inset Quotes eld
1532 1532 \end_inset
1533 1533
1534 1534 strings).
1535 1535 This 'scheme' is thus fully safe to use in any terminal.
1536 1536 \layout Itemize
1537 1537
1538 1538
1539 1539 \family typewriter
1540 1540 Linux
1541 1541 \family default
1542 1542 : works well in Linux console type environments: dark background with light
1543 1543 fonts.
1544 1544 It uses bright colors for information, so it is difficult to read if you
1545 1545 have a light colored background.
1546 1546 \layout Itemize
1547 1547
1548 1548
1549 1549 \family typewriter
1550 1550 LightBG
1551 1551 \family default
1552 1552 : the basic colors are similar to those in the
1553 1553 \family typewriter
1554 1554 Linux
1555 1555 \family default
1556 1556 scheme but darker.
1557 1557 It is easy to read in terminals with light backgrounds.
1558 1558 \layout Standard
1559 1559
1560 1560 IPython uses colors for two main groups of things: prompts and tracebacks
1561 1561 which are directly printed to the terminal, and the object introspection
1562 1562 system which passes large sets of data through a pager.
1563 1563 \layout Subsubsection
1564 1564
1565 1565 Input/Output prompts and exception tracebacks
1566 1566 \layout Standard
1567 1567
1568 1568 You can test whether the colored prompts and tracebacks work on your system
1569 1569 interactively by typing
1570 1570 \family typewriter
1571 1571 '%colors Linux'
1572 1572 \family default
1573 1573 at the prompt (use '
1574 1574 \family typewriter
1575 1575 %colors LightBG'
1576 1576 \family default
1577 1577 if your terminal has a light background).
1578 1578 If the input prompt shows garbage like:
1579 1579 \newline
1580 1580
1581 1581 \family typewriter
1582 1582 [0;32mIn [[1;32m1[0;32m]: [0;00m
1583 1583 \family default
1584 1584
1585 1585 \newline
1586 1586 instead of (in color) something like:
1587 1587 \newline
1588 1588
1589 1589 \family typewriter
1590 1590 In [1]:
1591 1591 \family default
1592 1592
1593 1593 \newline
1594 1594 this means that your terminal doesn't properly handle color escape sequences.
1595 1595 You can go to a 'no color' mode by typing '
1596 1596 \family typewriter
1597 1597 %colors NoColor
1598 1598 \family default
1599 1599 '.
1600 1600
1601 1601 \layout Standard
1602 1602
1603 1603 You can try using a different terminal emulator program.
1604 1604 To permanently set your color preferences, edit the file
1605 1605 \family typewriter
1606 1606 $HOME/.ipython/ipythonrc
1607 1607 \family default
1608 1608 and set the
1609 1609 \family typewriter
1610 1610 colors
1611 1611 \family default
1612 1612 option to the desired value.
1613 1613 \layout Subsubsection
1614 1614
1615 1615 Object details (types, docstrings, source code, etc.)
1616 1616 \layout Standard
1617 1617
1618 1618 IPython has a set of special functions for studying the objects you are
1619 1619 working with, discussed in detail in Sec.
1620 1620
1621 1621 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1622 1622
1623 1623 \end_inset
1624 1624
1625 1625 .
1626 1626 But this system relies on passing information which is longer than your
1627 1627 screen through a data pager, such as the common Unix
1628 1628 \family typewriter
1629 1629 less
1630 1630 \family default
1631 1631 and
1632 1632 \family typewriter
1633 1633 more
1634 1634 \family default
1635 1635 programs.
1636 1636 In order to be able to see this information in color, your pager needs
1637 1637 to be properly configured.
1638 1638 I strongly recommend using
1639 1639 \family typewriter
1640 1640 less
1641 1641 \family default
1642 1642 instead of
1643 1643 \family typewriter
1644 1644 more
1645 1645 \family default
1646 1646 , as it seems that
1647 1647 \family typewriter
1648 1648 more
1649 1649 \family default
1650 1650 simply can not understand colored text correctly.
1651 1651 \layout Standard
1652 1652
1653 1653 In order to configure
1654 1654 \family typewriter
1655 1655 less
1656 1656 \family default
1657 1657 as your default pager, do the following:
1658 1658 \layout Enumerate
1659 1659
1660 1660 Set the environment
1661 1661 \family typewriter
1662 1662 PAGER
1663 1663 \family default
1664 1664 variable to
1665 1665 \family typewriter
1666 1666 less
1667 1667 \family default
1668 1668 .
1669 1669 \layout Enumerate
1670 1670
1671 1671 Set the environment
1672 1672 \family typewriter
1673 1673 LESS
1674 1674 \family default
1675 1675 variable to
1676 1676 \family typewriter
1677 1677 -r
1678 1678 \family default
1679 1679 (plus any other options you always want to pass to
1680 1680 \family typewriter
1681 1681 less
1682 1682 \family default
1683 1683 by default).
1684 1684 This tells
1685 1685 \family typewriter
1686 1686 less
1687 1687 \family default
1688 1688 to properly interpret control sequences, which is how color information
1689 1689 is given to your terminal.
1690 1690 \layout Standard
1691 1691
1692 1692 For the
1693 1693 \family typewriter
1694 1694 csh
1695 1695 \family default
1696 1696 or
1697 1697 \family typewriter
1698 1698 tcsh
1699 1699 \family default
1700 1700 shells, add to your
1701 1701 \family typewriter
1702 1702 ~/.cshrc
1703 1703 \family default
1704 1704 file the lines:
1705 1705 \layout Standard
1706 1706
1707 1707
1708 1708 \family typewriter
1709 1709 setenv PAGER less
1710 1710 \newline
1711 1711 setenv LESS -r
1712 1712 \layout Standard
1713 1713
1714 1714 There is similar syntax for other Unix shells, look at your system documentation
1715 1715 for details.
1716 1716 \layout Standard
1717 1717
1718 1718 If you are on a system which lacks proper data pagers (such as Windows),
1719 1719 IPython will use a very limited builtin pager.
1720 1720 \layout Subsection
1721 1721
1722 1722
1723 1723 \begin_inset LatexCommand \label{sec:emacs}
1724 1724
1725 1725 \end_inset
1726 1726
1727 1727 (X)Emacs configuration
1728 1728 \layout Standard
1729 1729
1730 1730 Thanks to the work of Alexander Schmolck and Prabhu Ramachandran, currently
1731 1731 (X)Emacs and IPython get along very well.
1732 1732
1733 1733 \layout Standard
1734 1734
1735 1735
1736 1736 \series bold
1737 1737 Important note:
1738 1738 \series default
1739 1739 You will need to use a recent enough version of
1740 1740 \family typewriter
1741 1741 python-mode.el
1742 1742 \family default
1743 1743 , along with the file
1744 1744 \family typewriter
1745 1745 ipython.el
1746 1746 \family default
1747 1747 .
1748 1748 You can check that the version you have of
1749 1749 \family typewriter
1750 1750 python-mode.el
1751 1751 \family default
1752 1752 is new enough by either looking at the revision number in the file itself,
1753 1753 or asking for it in (X)Emacs via
1754 1754 \family typewriter
1755 1755 M-x py-version
1756 1756 \family default
1757 1757 .
1758 1758 Versions 4.68 and newer contain the necessary fixes for proper IPython support.
1759 1759 \layout Standard
1760 1760
1761 1761 The file
1762 1762 \family typewriter
1763 1763 ipython.el
1764 1764 \family default
1765 1765 is included with the IPython distribution, in the documentation directory
1766 1766 (where this manual resides in PDF and HTML formats).
1767 1767 \layout Standard
1768 1768
1769 1769 Once you put these files in your Emacs path, all you need in your
1770 1770 \family typewriter
1771 1771 .emacs
1772 1772 \family default
1773 1773 file is:
1774 1774 \layout Standard
1775 1775
1776 1776
1777 1777 \family typewriter
1778 1778 (require 'ipython)
1779 1779 \layout Standard
1780 1780
1781 1781 This should give you full support for executing code snippets via IPython,
1782 1782 opening IPython as your Python shell via
1783 1783 \family typewriter
1784 1784 C-c\SpecialChar ~
1785 1785 !
1786 1786 \family default
1787 1787 , etc.
1788 1788
1789 1789 \layout Subsubsection*
1790 1790
1791 1791 Notes
1792 1792 \layout Itemize
1793 1793
1794 1794 There is one caveat you should be aware of: you must start the IPython shell
1795 1795
1796 1796 \emph on
1797 1797 before
1798 1798 \emph default
1799 1799 attempting to execute any code regions via
1800 1800 \family typewriter
1801 1801 C-c\SpecialChar ~
1802 1802 |
1803 1803 \family default
1804 1804 .
1805 1805 Simply type
1806 1806 \family typewriter
1807 1807 C-c\SpecialChar ~
1808 1808 !
1809 1809 \family default
1810 1810 to start IPython before passing any code regions to the interpreter, and
1811 1811 you shouldn't experience any problems.
1812 1812 \newline
1813 1813 This is due to a bug in Python itself, which has been fixed for Python 2.3,
1814 1814 but exists as of Python 2.2.2 (reported as SF bug [ 737947 ]).
1815 1815 \layout Itemize
1816 1816
1817 1817 The (X)Emacs support is maintained by Alexander Schmolck, so all comments/reques
1818 1818 ts should be directed to him through the IPython mailing lists.
1819 1819
1820 1820 \layout Itemize
1821 1821
1822 1822 This code is still somewhat experimental so it's a bit rough around the
1823 1823 edges (although in practice, it works quite well).
1824 1824 \layout Itemize
1825 1825
1826 1826 Be aware that if you customize
1827 1827 \family typewriter
1828 1828 py-python-command
1829 1829 \family default
1830 1830 previously, this value will override what
1831 1831 \family typewriter
1832 1832 ipython.el
1833 1833 \family default
1834 1834 does (because loading the customization variables comes later).
1835 1835 \layout Section
1836 1836
1837 1837
1838 1838 \begin_inset LatexCommand \label{sec:quick_tips}
1839 1839
1840 1840 \end_inset
1841 1841
1842 1842 Quick tips
1843 1843 \layout Standard
1844 1844
1845 1845 IPython can be used as an improved replacement for the Python prompt, and
1846 1846 for that you don't really need to read any more of this manual.
1847 1847 But in this section we'll try to summarize a few tips on how to make the
1848 1848 most effective use of it for everyday Python development, highlighting
1849 1849 things you might miss in the rest of the manual (which is getting long).
1850 1850 We'll give references to parts in the manual which provide more detail
1851 1851 when appropriate.
1852 1852 \layout Standard
1853 1853
1854 1854 The following article by Jeremy Jones provides an introductory tutorial
1855 1855 about IPython:
1856 1856 \newline
1857 1857
1858 1858 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2005/01/27/ipython.html}
1859 1859
1860 1860 \end_inset
1861 1861
1862 1862
1863 1863 \layout Itemize
1864 1864
1865 1865 The TAB key.
1866 1866 TAB-completion, especially for attributes, is a convenient way to explore
1867 1867 the structure of any object you're dealing with.
1868 1868 Simply type
1869 1869 \family typewriter
1870 1870 object_name.<TAB>
1871 1871 \family default
1872 1872 and a list of the object's attributes will be printed (see sec.
1873 1873
1874 1874 \begin_inset LatexCommand \ref{sec:readline}
1875 1875
1876 1876 \end_inset
1877 1877
1878 1878 for more).
1879 1879 Tab completion also works on file and directory names, which combined with
1880 1880 IPython's alias system allows you to do from within IPython many of the
1881 1881 things you normally would need the system shell for.
1882 1882
1883 1883 \layout Itemize
1884 1884
1885 1885 Explore your objects.
1886 1886 Typing
1887 1887 \family typewriter
1888 1888 object_name?
1889 1889 \family default
1890 1890 will print all sorts of details about any object, including docstrings,
1891 1891 function definition lines (for call arguments) and constructor details
1892 1892 for classes.
1893 1893 The magic commands
1894 1894 \family typewriter
1895 1895 %pdoc
1896 1896 \family default
1897 1897 ,
1898 1898 \family typewriter
1899 1899 %pdef
1900 1900 \family default
1901 1901 ,
1902 1902 \family typewriter
1903 1903 %psource
1904 1904 \family default
1905 1905 and
1906 1906 \family typewriter
1907 1907 %pfile
1908 1908 \family default
1909 1909 will respectively print the docstring, function definition line, full source
1910 1910 code and the complete file for any object (when they can be found).
1911 1911 If automagic is on (it is by default), you don't need to type the '
1912 1912 \family typewriter
1913 1913 %
1914 1914 \family default
1915 1915 ' explicitly.
1916 1916 See sec.
1917 1917
1918 1918 \begin_inset LatexCommand \ref{sec:dyn-object-info}
1919 1919
1920 1920 \end_inset
1921 1921
1922 1922 for more.
1923 1923 \layout Itemize
1924 1924
1925 1925 The
1926 1926 \family typewriter
1927 1927 %run
1928 1928 \family default
1929 1929 magic command allows you to run any python script and load all of its data
1930 1930 directly into the interactive namespace.
1931 1931 Since the file is re-read from disk each time, changes you make to it are
1932 1932 reflected immediately (in contrast to the behavior of
1933 1933 \family typewriter
1934 1934 import
1935 1935 \family default
1936 1936 ).
1937 1937 I rarely use
1938 1938 \family typewriter
1939 1939 import
1940 1940 \family default
1941 1941 for code I am testing, relying on
1942 1942 \family typewriter
1943 1943 %run
1944 1944 \family default
1945 1945 instead.
1946 1946 See sec.
1947 1947
1948 1948 \begin_inset LatexCommand \ref{sec:magic}
1949 1949
1950 1950 \end_inset
1951 1951
1952 1952 for more on this and other magic commands, or type the name of any magic
1953 1953 command and ? to get details on it.
1954 1954 See also sec.
1955 1955
1956 1956 \begin_inset LatexCommand \ref{sec:dreload}
1957 1957
1958 1958 \end_inset
1959 1959
1960 1960 for a recursive reload command.
1961 1961 \newline
1962 1962
1963 1963 \family typewriter
1964 1964 %run
1965 1965 \family default
1966 1966 also has special flags for timing the execution of your scripts (
1967 1967 \family typewriter
1968 1968 -t
1969 1969 \family default
1970 1970 ) and for executing them under the control of either Python's
1971 1971 \family typewriter
1972 1972 pdb
1973 1973 \family default
1974 1974 debugger (
1975 1975 \family typewriter
1976 1976 -d
1977 1977 \family default
1978 1978 ) or profiler (
1979 1979 \family typewriter
1980 1980 -p
1981 1981 \family default
1982 1982 ).
1983 1983 With all of these,
1984 1984 \family typewriter
1985 1985 %run
1986 1986 \family default
1987 1987 can be used as the main tool for efficient interactive development of code
1988 1988 which you write in your editor of choice.
1989 1989 \layout Itemize
1990 1990
1991 1991 Use the Python debugger,
1992 1992 \family typewriter
1993 1993 pdb
1994 1994 \family default
1995 1995
1996 1996 \begin_inset Foot
1997 1997 collapsed true
1998 1998
1999 1999 \layout Standard
2000 2000
2001 2001 Thanks to Christian Hart and Matthew Arnison for the suggestions leading
2002 2002 to IPython's improved debugger and profiler support.
2003 2003 \end_inset
2004 2004
2005 2005 .
2006 2006 The
2007 2007 \family typewriter
2008 2008 %pdb
2009 2009 \family default
2010 2010 command allows you to toggle on and off the automatic invocation of an
2011 2011 IPython-enhanced
2012 2012 \family typewriter
2013 2013 pdb
2014 2014 \family default
2015 2015 debugger (with coloring, tab completion and more) at any uncaught exception.
2016 2016 The advantage of this is that
2017 2017 \family typewriter
2018 2018 pdb
2019 2019 \family default
2020 2020 starts
2021 2021 \emph on
2022 2022 inside
2023 2023 \emph default
2024 2024 the function where the exception occurred, with all data still available.
2025 2025 You can print variables, see code, execute statements and even walk up
2026 2026 and down the call stack to track down the true source of the problem (which
2027 2027 often is many layers in the stack above where the exception gets triggered).
2028 2028 \newline
2029 2029 Running programs with
2030 2030 \family typewriter
2031 2031 %run
2032 2032 \family default
2033 2033 and pdb active can be an efficient to develop and debug code, in many cases
2034 2034 eliminating the need for
2035 2035 \family typewriter
2036 2036 print
2037 2037 \family default
2038 2038 statements or external debugging tools.
2039 2039 I often simply put a
2040 2040 \family typewriter
2041 2041 1/0
2042 2042 \family default
2043 2043 in a place where I want to take a look so that pdb gets called, quickly
2044 2044 view whatever variables I need to or test various pieces of code and then
2045 2045 remove the
2046 2046 \family typewriter
2047 2047 1/0
2048 2048 \family default
2049 2049 .
2050 2050 \newline
2051 2051 Note also that `
2052 2052 \family typewriter
2053 2053 %run -d
2054 2054 \family default
2055 2055 ' activates
2056 2056 \family typewriter
2057 2057 pdb
2058 2058 \family default
2059 2059 and automatically sets initial breakpoints for you to step through your
2060 2060 code, watch variables, etc.
2061 2061 See Sec.\SpecialChar ~
2062 2062
2063 2063 \begin_inset LatexCommand \ref{sec:cache_output}
2064 2064
2065 2065 \end_inset
2066 2066
2067 2067 for details.
2068 2068 \layout Itemize
2069 2069
2070 2070 Use the output cache.
2071 2071 All output results are automatically stored in a global dictionary named
2072 2072
2073 2073 \family typewriter
2074 2074 Out
2075 2075 \family default
2076 2076 and variables named
2077 2077 \family typewriter
2078 2078 _1
2079 2079 \family default
2080 2080 ,
2081 2081 \family typewriter
2082 2082 _2
2083 2083 \family default
2084 2084 , etc.
2085 2085 alias them.
2086 2086 For example, the result of input line 4 is available either as
2087 2087 \family typewriter
2088 2088 Out[4]
2089 2089 \family default
2090 2090 or as
2091 2091 \family typewriter
2092 2092 _4
2093 2093 \family default
2094 2094 .
2095 2095 Additionally, three variables named
2096 2096 \family typewriter
2097 2097 _
2098 2098 \family default
2099 2099 ,
2100 2100 \family typewriter
2101 2101 __
2102 2102 \family default
2103 2103 and
2104 2104 \family typewriter
2105 2105 ___
2106 2106 \family default
2107 2107 are always kept updated with the for the last three results.
2108 2108 This allows you to recall any previous result and further use it for new
2109 2109 calculations.
2110 2110 See Sec.\SpecialChar ~
2111 2111
2112 2112 \begin_inset LatexCommand \ref{sec:cache_output}
2113 2113
2114 2114 \end_inset
2115 2115
2116 2116 for more.
2117 2117 \layout Itemize
2118 2118
2119 2119 Put a '
2120 2120 \family typewriter
2121 2121 ;
2122 2122 \family default
2123 2123 ' at the end of a line to supress the printing of output.
2124 2124 This is useful when doing calculations which generate long output you are
2125 2125 not interested in seeing.
2126 2126 The
2127 2127 \family typewriter
2128 2128 _*
2129 2129 \family default
2130 2130 variables and the
2131 2131 \family typewriter
2132 2132 Out[]
2133 2133 \family default
2134 2134 list do get updated with the contents of the output, even if it is not
2135 2135 printed.
2136 2136 You can thus still access the generated results this way for further processing.
2137 2137 \layout Itemize
2138 2138
2139 2139 A similar system exists for caching input.
2140 2140 All input is stored in a global list called
2141 2141 \family typewriter
2142 2142 In
2143 2143 \family default
2144 2144 , so you can re-execute lines 22 through 28 plus line 34 by typing
2145 2145 \family typewriter
2146 2146 'exec In[22:29]+In[34]'
2147 2147 \family default
2148 2148 (using Python slicing notation).
2149 2149 If you need to execute the same set of lines often, you can assign them
2150 2150 to a macro with the
2151 2151 \family typewriter
2152 2152 %macro
2153 2153 \family default
2154 2154
2155 2155 \family typewriter
2156 2156 function.
2157 2157
2158 2158 \family default
2159 2159 See sec.
2160 2160
2161 2161 \begin_inset LatexCommand \ref{sec:cache_input}
2162 2162
2163 2163 \end_inset
2164 2164
2165 2165 for more.
2166 2166 \layout Itemize
2167 2167
2168 2168 Use your input history.
2169 2169 The
2170 2170 \family typewriter
2171 2171 %hist
2172 2172 \family default
2173 2173 command can show you all previous input, without line numbers if desired
2174 2174 (option
2175 2175 \family typewriter
2176 2176 -n
2177 2177 \family default
2178 2178 ) so you can directly copy and paste code either back in IPython or in a
2179 2179 text editor.
2180 2180 You can also save all your history by turning on logging via
2181 2181 \family typewriter
2182 2182 %logstart
2183 2183 \family default
2184 2184 ; these logs can later be either reloaded as IPython sessions or used as
2185 2185 code for your programs.
2186 2186 \layout Itemize
2187 2187
2188 2188 Define your own macros with
2189 2189 \family typewriter
2190 2190 %macro
2191 2191 \family default
2192 2192 .
2193 2193 This can be useful for automating sequences of expressions when working
2194 2194 interactively.
2195 2195 \layout Itemize
2196 2196
2197 2197 Define your own system aliases.
2198 2198 Even though IPython gives you access to your system shell via the
2199 2199 \family typewriter
2200 2200 !
2201 2201 \family default
2202 2202 prefix, it is convenient to have aliases to the system commands you use
2203 2203 most often.
2204 2204 This allows you to work seamlessly from inside IPython with the same commands
2205 2205 you are used to in your system shell.
2206 2206 \newline
2207 2207 IPython comes with some pre-defined aliases and a complete system for changing
2208 2208 directories, both via a stack (see
2209 2209 \family typewriter
2210 2210 %pushd
2211 2211 \family default
2212 2212 ,
2213 2213 \family typewriter
2214 2214 %popd
2215 2215 \family default
2216 2216 and
2217 2217 \family typewriter
2218 2218 %ds
2219 2219 \family default
2220 2220 ) and via direct
2221 2221 \family typewriter
2222 2222 %cd
2223 2223 \family default
2224 2224 .
2225 2225 The latter keeps a history of visited directories and allows you to go
2226 2226 to any previously visited one.
2227 2227 \layout Itemize
2228 2228
2229 2229 Use Python to manipulate the results of system commands.
2230 2230 The `
2231 2231 \family typewriter
2232 2232 !!
2233 2233 \family default
2234 2234 ' special syntax, and the
2235 2235 \family typewriter
2236 2236 %sc
2237 2237 \family default
2238 2238 and
2239 2239 \family typewriter
2240 2240 %sx
2241 2241 \family default
2242 2242 magic commands allow you to capture system output into Python variables.
2243 2243 \layout Itemize
2244 2244
2245 2245 Expand python variables when calling the shell (either via
2246 2246 \family typewriter
2247 2247 `!'
2248 2248 \family default
2249 2249 and
2250 2250 \family typewriter
2251 2251 `!!'
2252 2252 \family default
2253 2253 or via aliases) by prepending a
2254 2254 \family typewriter
2255 2255 $
2256 2256 \family default
2257 2257 in front of them.
2258 2258 You can also expand complete python expressions.
2259 2259 See sec.\SpecialChar ~
2260 2260
2261 2261 \begin_inset LatexCommand \ref{sub:System-shell-access}
2262 2262
2263 2263 \end_inset
2264 2264
2265 2265 for more.
2266 2266 \layout Itemize
2267 2267
2268 2268 Use profiles to maintain different configurations (modules to load, function
2269 2269 definitions, option settings) for particular tasks.
2270 2270 You can then have customized versions of IPython for specific purposes.
2271 2271 See sec.\SpecialChar ~
2272 2272
2273 2273 \begin_inset LatexCommand \ref{sec:profiles}
2274 2274
2275 2275 \end_inset
2276 2276
2277 2277 for more.
2278 2278 \layout Itemize
2279 2279
2280 2280 Embed IPython in your programs.
2281 2281 A few lines of code are enough to load a complete IPython inside your own
2282 2282 programs, giving you the ability to work with your data interactively after
2283 2283 automatic processing has been completed.
2284 2284 See sec.\SpecialChar ~
2285 2285
2286 2286 \begin_inset LatexCommand \ref{sec:embed}
2287 2287
2288 2288 \end_inset
2289 2289
2290 2290 for more.
2291 2291 \layout Itemize
2292 2292
2293 2293 Use the Python profiler.
2294 2294 When dealing with performance issues, the
2295 2295 \family typewriter
2296 2296 %run
2297 2297 \family default
2298 2298 command with a
2299 2299 \family typewriter
2300 2300 -p
2301 2301 \family default
2302 2302 option allows you to run complete programs under the control of the Python
2303 2303 profiler.
2304 2304 The
2305 2305 \family typewriter
2306 2306 %prun
2307 2307 \family default
2308 2308 command does a similar job for single Python expressions (like function
2309 2309 calls).
2310 2310 \layout Itemize
2311 2311
2312 2312 Use
2313 2313 \family typewriter
2314 2314 %edit
2315 2315 \family default
2316 2316 to have almost multiline editing.
2317 2317 While IPython doesn't support true multiline editing, this command allows
2318 2318 you to call an editor on the spot, and IPython will execute the code you
2319 2319 type in there as if it were typed interactively.
2320 2320 \layout Itemize
2321 2321
2322 2322 Use the IPython.demo.Demo class to load any Python script as an interactive
2323 2323 demo.
2324 2324 With a minimal amount of simple markup, you can control the execution of
2325 2325 the script, stopping as needed.
2326 2326 See sec.\SpecialChar ~
2327 2327
2328 2328 \begin_inset LatexCommand \ref{sec:interactive-demos}
2329 2329
2330 2330 \end_inset
2331 2331
2332 2332 for more.
2333 2333 \layout Standard
2334 2334
2335 2335
2336 2336 \series bold
2337 2337 Effective logging:
2338 2338 \series default
2339 2339 a very useful suggestion sent in by Robert Kern follows
2340 2340 \layout Standard
2341 2341
2342 2342 I recently happened on a nifty way to keep tidy per-project log files.
2343 2343 I made a profile for my project (which is called "parkfield").
2344 2344 \layout LyX-Code
2345 2345
2346 2346 include ipythonrc
2347 2347 \layout LyX-Code
2348 2348
2349 2349 logfile '' # cancel earlier logfile invocation
2350 2350 \layout LyX-Code
2351 2351
2352 2352 execute import time
2353 2353 \layout LyX-Code
2354 2354
2355 2355 execute __cmd = '/Users/kern/research/logfiles/parkfield-%s.log rotate'
2356 2356 \layout LyX-Code
2357 2357
2358 2358 execute __IP.magic_logstart(__cmd % time.strftime('%Y-%m-%d'))
2359 2359 \layout Standard
2360 2360
2361 2361 I also added a shell alias for convenience:
2362 2362 \layout LyX-Code
2363 2363
2364 2364 alias parkfield="ipython -pylab -profile parkfield"
2365 2365 \layout Standard
2366 2366
2367 2367 Now I have a nice little directory with everything I ever type in, organized
2368 2368 by project and date.
2369 2369 \layout Standard
2370 2370
2371 2371
2372 2372 \series bold
2373 2373 Contribute your own:
2374 2374 \series default
2375 2375 If you have your own favorite tip on using IPython efficiently for a certain
2376 2376 task (especially things which can't be done in the normal Python interpreter),
2377 2377 don't hesitate to send it!
2378 2378 \layout Section
2379 2379
2380 2380 Command-line use
2381 2381 \layout Standard
2382 2382
2383 2383 You start IPython with the command:
2384 2384 \layout Standard
2385 2385
2386 2386
2387 2387 \family typewriter
2388 2388 $ ipython [options] files
2389 2389 \layout Standard
2390 2390
2391 2391 If invoked with no options, it executes all the files listed in sequence
2392 2392 and drops you into the interpreter while still acknowledging any options
2393 2393 you may have set in your ipythonrc file.
2394 2394 This behavior is different from standard Python, which when called as
2395 2395 \family typewriter
2396 2396 python -i
2397 2397 \family default
2398 2398 will only execute one file and ignore your configuration setup.
2399 2399 \layout Standard
2400 2400
2401 2401 Please note that some of the configuration options are not available at
2402 2402 the command line, simply because they are not practical here.
2403 2403 Look into your ipythonrc configuration file for details on those.
2404 2404 This file typically installed in the
2405 2405 \family typewriter
2406 2406 $HOME/.ipython
2407 2407 \family default
2408 2408 directory.
2409 2409 For Windows users,
2410 2410 \family typewriter
2411 2411 $HOME
2412 2412 \family default
2413 2413 resolves to
2414 2414 \family typewriter
2415 2415 C:
2416 2416 \backslash
2417 2417
2418 2418 \backslash
2419 2419 Documents and Settings
2420 2420 \backslash
2421 2421
2422 2422 \backslash
2423 2423 YourUserName
2424 2424 \family default
2425 2425 in most instances.
2426 2426 In the rest of this text, we will refer to this directory as
2427 2427 \family typewriter
2428 2428 IPYTHONDIR
2429 2429 \family default
2430 2430 .
2431 2431 \layout Subsection
2432 2432
2433 2433
2434 2434 \begin_inset LatexCommand \label{sec:threading-opts}
2435 2435
2436 2436 \end_inset
2437 2437
2438 2438 Special Threading Options
2439 2439 \layout Standard
2440 2440
2441 2441 The following special options are ONLY valid at the beginning of the command
2442 2442 line, and not later.
2443 2443 This is because they control the initial- ization of ipython itself, before
2444 2444 the normal option-handling mechanism is active.
2445 2445 \layout List
2446 2446 \labelwidthstring 00.00.0000
2447 2447
2448 2448
2449 2449 \family typewriter
2450 2450 \series bold
2451 2451 -gthread,\SpecialChar ~
2452 2452 -qthread,\SpecialChar ~
2453 2453 -wthread,\SpecialChar ~
2454 2454 -pylab:
2455 2455 \family default
2456 2456 \series default
2457 2457 Only
2458 2458 \emph on
2459 2459 one
2460 2460 \emph default
2461 2461 of these can be given, and it can only be given as the first option passed
2462 2462 to IPython (it will have no effect in any other position).
2463 2463 They provide threading support for the GTK Qt and WXPython toolkits, and
2464 2464 for the matplotlib library.
2465 2465 \layout List
2466 2466 \labelwidthstring 00.00.0000
2467 2467
2468 2468 \SpecialChar ~
2469 2469 With any of the first three options, IPython starts running a separate
2470 2470 thread for the graphical toolkit's operation, so that you can open and
2471 2471 control graphical elements from within an IPython command line, without
2472 2472 blocking.
2473 2473 All three provide essentially the same functionality, respectively for
2474 2474 GTK, QT and WXWidgets (via their Python interfaces).
2475 2475 \layout List
2476 2476 \labelwidthstring 00.00.0000
2477 2477
2478 2478 \SpecialChar ~
2479 2479 If
2480 2480 \family typewriter
2481 2481 -pylab
2482 2482 \family default
2483 2483 is given, IPython loads special support for the mat plotlib library (
2484 2484 \begin_inset LatexCommand \htmlurl{http://matplotlib.sourceforge.net}
2485 2485
2486 2486 \end_inset
2487 2487
2488 2488 ), allowing interactive usage of any of its backends as defined in the user's
2489 2489
2490 2490 \family typewriter
2491 2491 ~/.matplotlib/matplotlibrc
2492 2492 \family default
2493 2493 file.
2494 2494 It automatically activates GTK, Qt or WX threading for IPyhton if the choice
2495 2495 of matplotlib backend requires it.
2496 2496 It also modifies the
2497 2497 \family typewriter
2498 2498 %run
2499 2499 \family default
2500 2500 command to correctly execute (without blocking) any matplotlib-based script
2501 2501 which calls
2502 2502 \family typewriter
2503 2503 show()
2504 2504 \family default
2505 2505 at the end.
2506 2506
2507 2507 \layout List
2508 2508 \labelwidthstring 00.00.0000
2509 2509
2510 2510
2511 2511 \family typewriter
2512 2512 \series bold
2513 2513 -tk
2514 2514 \family default
2515 2515 \series default
2516 2516 The
2517 2517 \family typewriter
2518 2518 -g/q/wthread
2519 2519 \family default
2520 2520 options, and
2521 2521 \family typewriter
2522 2522 -pylab
2523 2523 \family default
2524 2524 (if matplotlib is configured to use GTK, Qt or WX), will normally block
2525 2525 Tk graphical interfaces.
2526 2526 This means that when either GTK, Qt or WX threading is active, any attempt
2527 2527 to open a Tk GUI will result in a dead window, and possibly cause the Python
2528 2528 interpreter to crash.
2529 2529 An extra option,
2530 2530 \family typewriter
2531 2531 -tk
2532 2532 \family default
2533 2533 , is available to address this issue.
2534 2534 It can
2535 2535 \emph on
2536 2536 only
2537 2537 \emph default
2538 2538 be given as a
2539 2539 \emph on
2540 2540 second
2541 2541 \emph default
2542 2542 option after any of the above (
2543 2543 \family typewriter
2544 2544 -gthread
2545 2545 \family default
2546 2546 ,
2547 2547 \family typewriter
2548 2548 -wthread
2549 2549 \family default
2550 2550 or
2551 2551 \family typewriter
2552 2552 -pylab
2553 2553 \family default
2554 2554 ).
2555 2555 \layout List
2556 2556 \labelwidthstring 00.00.0000
2557 2557
2558 2558 \SpecialChar ~
2559 2559 If
2560 2560 \family typewriter
2561 2561 -tk
2562 2562 \family default
2563 2563 is given, IPython will try to coordinate Tk threading with GTK, Qt or WX.
2564 2564 This is however potentially unreliable, and you will have to test on your
2565 2565 platform and Python configuration to determine whether it works for you.
2566 2566 Debian users have reported success, apparently due to the fact that Debian
2567 2567 builds all of Tcl, Tk, Tkinter and Python with pthreads support.
2568 2568 Under other Linux environments (such as Fedora Core 2/3), this option has
2569 2569 caused random crashes and lockups of the Python interpreter.
2570 2570 Under other operating systems (Mac OSX and Windows), you'll need to try
2571 2571 it to find out, since currently no user reports are available.
2572 2572 \layout List
2573 2573 \labelwidthstring 00.00.0000
2574 2574
2575 2575 \SpecialChar ~
2576 2576 There is unfortunately no way for IPython to determine at run time whether
2577 2577
2578 2578 \family typewriter
2579 2579 -tk
2580 2580 \family default
2581 2581 will work reliably or not, so you will need to do some experiments before
2582 2582 relying on it for regular work.
2583 2583
2584 2584 \layout Subsection
2585 2585
2586 2586
2587 2587 \begin_inset LatexCommand \label{sec:cmd-line-opts}
2588 2588
2589 2589 \end_inset
2590 2590
2591 2591 Regular Options
2592 2592 \layout Standard
2593 2593
2594 2594 After the above threading options have been given, regular options can follow
2595 2595 in any order.
2596 2596 All options can be abbreviated to their shortest non-ambiguous form and
2597 2597 are case-sensitive.
2598 2598 One or two dashes can be used.
2599 2599 Some options have an alternate short form, indicated after a
2600 2600 \family typewriter
2601 2601 |
2602 2602 \family default
2603 2603 .
2604 2604 \layout Standard
2605 2605
2606 2606 Most options can also be set from your ipythonrc configuration file.
2607 2607 See the provided example for more details on what the options do.
2608 2608 Options given at the command line override the values set in the ipythonrc
2609 2609 file.
2610 2610 \layout Standard
2611 2611
2612 2612 All options with a
2613 2613 \family typewriter
2614 2614 [no]
2615 2615 \family default
2616 2616 prepended can be specified in negated form (
2617 2617 \family typewriter
2618 2618 -nooption
2619 2619 \family default
2620 2620 instead of
2621 2621 \family typewriter
2622 2622 -option
2623 2623 \family default
2624 2624 ) to turn the feature off.
2625 2625 \layout List
2626 2626 \labelwidthstring 00.00.0000
2627 2627
2628 2628
2629 2629 \family typewriter
2630 2630 \series bold
2631 2631 -help
2632 2632 \family default
2633 2633 \series default
2634 2634 : print a help message and exit.
2635 2635 \layout List
2636 2636 \labelwidthstring 00.00.0000
2637 2637
2638 2638
2639 2639 \family typewriter
2640 2640 \series bold
2641 2641 -pylab:
2642 2642 \family default
2643 2643 \series default
2644 2644 this can
2645 2645 \emph on
2646 2646 only
2647 2647 \emph default
2648 2648 be given as the
2649 2649 \emph on
2650 2650 first
2651 2651 \emph default
2652 2652 option passed to IPython (it will have no effect in any other position).
2653 2653 It adds special support for the matplotlib library (
2654 2654 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
2655 2655
2656 2656 \end_inset
2657 2657
2658 2658 ), allowing interactive usage of any of its backends as defined in the user's
2659 2659
2660 2660 \family typewriter
2661 2661 .matplotlibrc
2662 2662 \family default
2663 2663 file.
2664 2664 It automatically activates GTK or WX threading for IPyhton if the choice
2665 2665 of matplotlib backend requires it.
2666 2666 It also modifies the
2667 2667 \family typewriter
2668 2668 %run
2669 2669 \family default
2670 2670 command to correctly execute (without blocking) any matplotlib-based script
2671 2671 which calls
2672 2672 \family typewriter
2673 2673 show()
2674 2674 \family default
2675 2675 at the end.
2676 2676 See Sec.\SpecialChar ~
2677 2677
2678 2678 \begin_inset LatexCommand \ref{sec:matplotlib-support}
2679 2679
2680 2680 \end_inset
2681 2681
2682 2682 for more details.
2683 2683 \layout List
2684 2684 \labelwidthstring 00.00.0000
2685 2685
2686 2686
2687 2687 \family typewriter
2688 2688 \series bold
2689 2689 -[no]autocall:
2690 2690 \family default
2691 2691 \series default
2692 2692 Make IPython automatically call any callable object even if you didn't
2693 2693 type explicit parentheses.
2694 2694 For example, `str 43' becomes `str(43)' automatically.
2695 2695 \layout List
2696 2696 \labelwidthstring 00.00.0000
2697 2697
2698 2698
2699 2699 \family typewriter
2700 2700 \series bold
2701 2701 -[no]autoindent:
2702 2702 \family default
2703 2703 \series default
2704 2704 Turn automatic indentation on/off.
2705 2705 \layout List
2706 2706 \labelwidthstring 00.00.0000
2707 2707
2708 2708
2709 2709 \family typewriter
2710 2710 \series bold
2711 2711 -[no]automagic
2712 2712 \series default
2713 2713 :
2714 2714 \family default
2715 2715 make magic commands automatic (without needing their first character to
2716 2716 be
2717 2717 \family typewriter
2718 2718 %
2719 2719 \family default
2720 2720 ).
2721 2721 Type
2722 2722 \family typewriter
2723 2723 %magic
2724 2724 \family default
2725 2725 at the IPython prompt for more information.
2726 2726 \layout List
2727 2727 \labelwidthstring 00.00.0000
2728 2728
2729 2729
2730 2730 \family typewriter
2731 2731 \series bold
2732 2732 -[no]autoedit_syntax:
2733 2733 \family default
2734 2734 \series default
2735 2735 When a syntax error occurs after editing a file, automatically open the
2736 2736 file to the trouble causing line for convenient fixing.
2737 2737
2738 2738 \layout List
2739 2739 \labelwidthstring 00.00.0000
2740 2740
2741 2741
2742 2742 \family typewriter
2743 2743 \series bold
2744 2744 -[no]banner
2745 2745 \series default
2746 2746 :
2747 2747 \family default
2748 2748 Print the initial information banner (default on).
2749 2749 \layout List
2750 2750 \labelwidthstring 00.00.0000
2751 2751
2752 2752
2753 2753 \family typewriter
2754 2754 \series bold
2755 2755 -c\SpecialChar ~
2756 2756 <command>:
2757 2757 \family default
2758 2758 \series default
2759 2759 execute the given command string, and set sys.argv to
2760 2760 \family typewriter
2761 2761 ['c']
2762 2762 \family default
2763 2763 .
2764 2764 This is similar to the
2765 2765 \family typewriter
2766 2766 -c
2767 2767 \family default
2768 2768 option in the normal Python interpreter.
2769 2769
2770 2770 \layout List
2771 2771 \labelwidthstring 00.00.0000
2772 2772
2773 2773
2774 2774 \family typewriter
2775 2775 \series bold
2776 2776 -cache_size|cs\SpecialChar ~
2777 2777 <n>
2778 2778 \series default
2779 2779 :
2780 2780 \family default
2781 2781 size of the output cache (maximum number of entries to hold in memory).
2782 2782 The default is 1000, you can change it permanently in your config file.
2783 2783 Setting it to 0 completely disables the caching system, and the minimum
2784 2784 value accepted is 20 (if you provide a value less than 20, it is reset
2785 2785 to 0 and a warning is issued) This limit is defined because otherwise you'll
2786 2786 spend more time re-flushing a too small cache than working.
2787 2787 \layout List
2788 2788 \labelwidthstring 00.00.0000
2789 2789
2790 2790
2791 2791 \family typewriter
2792 2792 \series bold
2793 2793 -classic|cl
2794 2794 \series default
2795 2795 :
2796 2796 \family default
2797 2797 Gives IPython a similar feel to the classic Python prompt.
2798 2798 \layout List
2799 2799 \labelwidthstring 00.00.0000
2800 2800
2801 2801
2802 2802 \family typewriter
2803 2803 \series bold
2804 2804 -colors\SpecialChar ~
2805 2805 <scheme>:
2806 2806 \family default
2807 2807 \series default
2808 2808 Color scheme for prompts and exception reporting.
2809 2809 Currently implemented: NoColor, Linux and LightBG.
2810 2810 \layout List
2811 2811 \labelwidthstring 00.00.0000
2812 2812
2813 2813
2814 2814 \family typewriter
2815 2815 \series bold
2816 2816 -[no]color_info:
2817 2817 \family default
2818 2818 \series default
2819 2819 IPython can display information about objects via a set of functions, and
2820 2820 optionally can use colors for this, syntax highlighting source code and
2821 2821 various other elements.
2822 2822 However, because this information is passed through a pager (like 'less')
2823 2823 and many pagers get confused with color codes, this option is off by default.
2824 2824 You can test it and turn it on permanently in your ipythonrc file if it
2825 2825 works for you.
2826 2826 As a reference, the 'less' pager supplied with Mandrake 8.2 works ok, but
2827 2827 that in RedHat 7.2 doesn't.
2828 2828 \layout List
2829 2829 \labelwidthstring 00.00.0000
2830 2830
2831 2831 \SpecialChar ~
2832 2832 Test it and turn it on permanently if it works with your system.
2833 2833 The magic function
2834 2834 \family typewriter
2835 2835 %color_info
2836 2836 \family default
2837 2837 allows you to toggle this interactively for testing.
2838 2838 \layout List
2839 2839 \labelwidthstring 00.00.0000
2840 2840
2841 2841
2842 2842 \family typewriter
2843 2843 \series bold
2844 2844 -[no]debug
2845 2845 \family default
2846 2846 \series default
2847 2847 : Show information about the loading process.
2848 2848 Very useful to pin down problems with your configuration files or to get
2849 2849 details about session restores.
2850 2850 \layout List
2851 2851 \labelwidthstring 00.00.0000
2852 2852
2853 2853
2854 2854 \family typewriter
2855 2855 \series bold
2856 2856 -[no]deep_reload
2857 2857 \series default
2858 2858 :
2859 2859 \family default
2860 2860 IPython can use the
2861 2861 \family typewriter
2862 2862 deep_reload
2863 2863 \family default
2864 2864 module which reloads changes in modules recursively (it replaces the
2865 2865 \family typewriter
2866 2866 reload()
2867 2867 \family default
2868 2868 function, so you don't need to change anything to use it).
2869 2869
2870 2870 \family typewriter
2871 2871 deep_reload()
2872 2872 \family default
2873 2873 forces a full reload of modules whose code may have changed, which the
2874 2874 default
2875 2875 \family typewriter
2876 2876 reload()
2877 2877 \family default
2878 2878 function does not.
2879 2879 \layout List
2880 2880 \labelwidthstring 00.00.0000
2881 2881
2882 2882 \SpecialChar ~
2883 2883 When deep_reload is off, IPython will use the normal
2884 2884 \family typewriter
2885 2885 reload()
2886 2886 \family default
2887 2887 , but deep_reload will still be available as
2888 2888 \family typewriter
2889 2889 dreload()
2890 2890 \family default
2891 2891 .
2892 2892 This feature is off by default [which means that you have both normal
2893 2893 \family typewriter
2894 2894 reload()
2895 2895 \family default
2896 2896 and
2897 2897 \family typewriter
2898 2898 dreload()
2899 2899 \family default
2900 2900 ].
2901 2901 \layout List
2902 2902 \labelwidthstring 00.00.0000
2903 2903
2904 2904
2905 2905 \family typewriter
2906 2906 \series bold
2907 2907 -editor\SpecialChar ~
2908 2908 <name>
2909 2909 \family default
2910 2910 \series default
2911 2911 : Which editor to use with the
2912 2912 \family typewriter
2913 2913 %edit
2914 2914 \family default
2915 2915 command.
2916 2916 By default, IPython will honor your
2917 2917 \family typewriter
2918 2918 EDITOR
2919 2919 \family default
2920 2920 environment variable (if not set, vi is the Unix default and notepad the
2921 2921 Windows one).
2922 2922 Since this editor is invoked on the fly by IPython and is meant for editing
2923 2923 small code snippets, you may want to use a small, lightweight editor here
2924 2924 (in case your default
2925 2925 \family typewriter
2926 2926 EDITOR
2927 2927 \family default
2928 2928 is something like Emacs).
2929 2929 \layout List
2930 2930 \labelwidthstring 00.00.0000
2931 2931
2932 2932
2933 2933 \family typewriter
2934 2934 \series bold
2935 2935 -ipythondir\SpecialChar ~
2936 2936 <name>
2937 2937 \series default
2938 2938 :
2939 2939 \family default
2940 2940 name of your IPython configuration directory
2941 2941 \family typewriter
2942 2942 IPYTHONDIR
2943 2943 \family default
2944 2944 .
2945 2945 This can also be specified through the environment variable
2946 2946 \family typewriter
2947 2947 IPYTHONDIR
2948 2948 \family default
2949 2949 .
2950 2950 \layout List
2951 2951 \labelwidthstring 00.00.0000
2952 2952
2953 2953
2954 2954 \family typewriter
2955 2955 \series bold
2956 2956 -log|l
2957 2957 \family default
2958 2958 \series default
2959 2959 : generate a log file of all input.
2960 2960 The file is named
2961 2961 \family typewriter
2962 2962 ipython_log.py
2963 2963 \family default
2964 2964 in your current directory (which prevents logs from multiple IPython sessions
2965 2965 from trampling each other).
2966 2966 You can use this to later restore a session by loading your logfile as
2967 2967 a file to be executed with option
2968 2968 \family typewriter
2969 2969 -logplay
2970 2970 \family default
2971 2971 (see below).
2972 2972 \layout List
2973 2973 \labelwidthstring 00.00.0000
2974 2974
2975 2975
2976 2976 \family typewriter
2977 2977 \series bold
2978 2978 -logfile|lf\SpecialChar ~
2979 2979 <name>
2980 2980 \series default
2981 2981 :
2982 2982 \family default
2983 2983 specify the name of your logfile.
2984 2984 \layout List
2985 2985 \labelwidthstring 00.00.0000
2986 2986
2987 2987
2988 2988 \family typewriter
2989 2989 \series bold
2990 2990 -logplay|lp\SpecialChar ~
2991 2991 <name>
2992 2992 \series default
2993 2993 :
2994 2994 \family default
2995 2995 you can replay a previous log.
2996 2996 For restoring a session as close as possible to the state you left it in,
2997 2997 use this option (don't just run the logfile).
2998 2998 With
2999 2999 \family typewriter
3000 3000 -logplay
3001 3001 \family default
3002 3002 , IPython will try to reconstruct the previous working environment in full,
3003 3003 not just execute the commands in the logfile.
3004 3004 \layout List
3005 3005 \labelwidthstring 00.00.0000
3006 3006
3007 3007 \SpecialChar ~
3008 3008 When a session is restored, logging is automatically turned on again with
3009 3009 the name of the logfile it was invoked with (it is read from the log header).
3010 3010 So once you've turned logging on for a session, you can quit IPython and
3011 3011 reload it as many times as you want and it will continue to log its history
3012 3012 and restore from the beginning every time.
3013 3013 \layout List
3014 3014 \labelwidthstring 00.00.0000
3015 3015
3016 3016 \SpecialChar ~
3017 3017 Caveats: there are limitations in this option.
3018 3018 The history variables
3019 3019 \family typewriter
3020 3020 _i*
3021 3021 \family default
3022 3022 ,
3023 3023 \family typewriter
3024 3024 _*
3025 3025 \family default
3026 3026 and
3027 3027 \family typewriter
3028 3028 _dh
3029 3029 \family default
3030 3030 don't get restored properly.
3031 3031 In the future we will try to implement full session saving by writing and
3032 3032 retrieving a 'snapshot' of the memory state of IPython.
3033 3033 But our first attempts failed because of inherent limitations of Python's
3034 3034 Pickle module, so this may have to wait.
3035 3035 \layout List
3036 3036 \labelwidthstring 00.00.0000
3037 3037
3038 3038
3039 3039 \family typewriter
3040 3040 \series bold
3041 3041 -[no]messages
3042 3042 \series default
3043 3043 :
3044 3044 \family default
3045 3045 Print messages which IPython collects about its startup process (default
3046 3046 on).
3047 3047 \layout List
3048 3048 \labelwidthstring 00.00.0000
3049 3049
3050 3050
3051 3051 \family typewriter
3052 3052 \series bold
3053 3053 -[no]pdb
3054 3054 \family default
3055 3055 \series default
3056 3056 : Automatically call the pdb debugger after every uncaught exception.
3057 3057 If you are used to debugging using pdb, this puts you automatically inside
3058 3058 of it after any call (either in IPython or in code called by it) which
3059 3059 triggers an exception which goes uncaught.
3060 3060 \layout List
3061 3061 \labelwidthstring 00.00.0000
3062 3062
3063 3063
3064 3064 \family typewriter
3065 3065 \series bold
3066 3066 -[no]pprint
3067 3067 \series default
3068 3068 :
3069 3069 \family default
3070 3070 ipython can optionally use the pprint (pretty printer) module for displaying
3071 3071 results.
3072 3072 pprint tends to give a nicer display of nested data structures.
3073 3073 If you like it, you can turn it on permanently in your config file (default
3074 3074 off).
3075 3075 \layout List
3076 3076 \labelwidthstring 00.00.0000
3077 3077
3078 3078
3079 3079 \family typewriter
3080 3080 \series bold
3081 3081 -profile|p <name>
3082 3082 \series default
3083 3083 :
3084 3084 \family default
3085 3085 assume that your config file is
3086 3086 \family typewriter
3087 3087 ipythonrc-<name>
3088 3088 \family default
3089 3089 (looks in current dir first, then in
3090 3090 \family typewriter
3091 3091 IPYTHONDIR
3092 3092 \family default
3093 3093 ).
3094 3094 This is a quick way to keep and load multiple config files for different
3095 3095 tasks, especially if you use the include option of config files.
3096 3096 You can keep a basic
3097 3097 \family typewriter
3098 3098 IPYTHONDIR/ipythonrc
3099 3099 \family default
3100 3100 file and then have other 'profiles' which include this one and load extra
3101 3101 things for particular tasks.
3102 3102 For example:
3103 3103 \layout List
3104 3104 \labelwidthstring 00.00.0000
3105 3105
3106 3106
3107 3107 \family typewriter
3108 3108 \SpecialChar ~
3109 3109
3110 3110 \family default
3111 3111 1.
3112 3112
3113 3113 \family typewriter
3114 3114 $HOME/.ipython/ipythonrc
3115 3115 \family default
3116 3116 : load basic things you always want.
3117 3117 \layout List
3118 3118 \labelwidthstring 00.00.0000
3119 3119
3120 3120
3121 3121 \family typewriter
3122 3122 \SpecialChar ~
3123 3123
3124 3124 \family default
3125 3125 2.
3126 3126
3127 3127 \family typewriter
3128 3128 $HOME/.ipython/ipythonrc-math
3129 3129 \family default
3130 3130 : load (1) and basic math-related modules.
3131 3131
3132 3132 \layout List
3133 3133 \labelwidthstring 00.00.0000
3134 3134
3135 3135
3136 3136 \family typewriter
3137 3137 \SpecialChar ~
3138 3138
3139 3139 \family default
3140 3140 3.
3141 3141
3142 3142 \family typewriter
3143 3143 $HOME/.ipython/ipythonrc-numeric
3144 3144 \family default
3145 3145 : load (1) and Numeric and plotting modules.
3146 3146 \layout List
3147 3147 \labelwidthstring 00.00.0000
3148 3148
3149 3149 \SpecialChar ~
3150 3150 Since it is possible to create an endless loop by having circular file
3151 3151 inclusions, IPython will stop if it reaches 15 recursive inclusions.
3152 3152 \layout List
3153 3153 \labelwidthstring 00.00.0000
3154 3154
3155 3155
3156 3156 \family typewriter
3157 3157 \series bold
3158 3158 -prompt_in1|pi1\SpecialChar ~
3159 3159 <string>:
3160 3160 \family default
3161 3161 \series default
3162 3162 Specify the string used for input prompts.
3163 3163 Note that if you are using numbered prompts, the number is represented
3164 3164 with a '
3165 3165 \backslash
3166 3166 #' in the string.
3167 3167 Don't forget to quote strings with spaces embedded in them.
3168 3168 Default: '
3169 3169 \family typewriter
3170 3170 In\SpecialChar ~
3171 3171 [
3172 3172 \backslash
3173 3173 #]:
3174 3174 \family default
3175 3175 '.
3176 3176 Sec.\SpecialChar ~
3177 3177
3178 3178 \begin_inset LatexCommand \ref{sec:prompts}
3179 3179
3180 3180 \end_inset
3181 3181
3182 3182 discusses in detail all the available escapes to customize your prompts.
3183 3183 \layout List
3184 3184 \labelwidthstring 00.00.0000
3185 3185
3186 3186
3187 3187 \family typewriter
3188 3188 \series bold
3189 3189 -prompt_in2|pi2\SpecialChar ~
3190 3190 <string>:
3191 3191 \family default
3192 3192 \series default
3193 3193 Similar to the previous option, but used for the continuation prompts.
3194 3194 The special sequence '
3195 3195 \family typewriter
3196 3196
3197 3197 \backslash
3198 3198 D
3199 3199 \family default
3200 3200 ' is similar to '
3201 3201 \family typewriter
3202 3202
3203 3203 \backslash
3204 3204 #
3205 3205 \family default
3206 3206 ', but with all digits replaced dots (so you can have your continuation
3207 3207 prompt aligned with your input prompt).
3208 3208 Default: '
3209 3209 \family typewriter
3210 3210 \SpecialChar ~
3211 3211 \SpecialChar ~
3212 3212 \SpecialChar ~
3213 3213 .
3214 3214 \backslash
3215 3215 D.:
3216 3216 \family default
3217 3217 ' (note three spaces at the start for alignment with '
3218 3218 \family typewriter
3219 3219 In\SpecialChar ~
3220 3220 [
3221 3221 \backslash
3222 3222 #]
3223 3223 \family default
3224 3224 ').
3225 3225 \layout List
3226 3226 \labelwidthstring 00.00.0000
3227 3227
3228 3228
3229 3229 \family typewriter
3230 3230 \series bold
3231 3231 -prompt_out|po\SpecialChar ~
3232 3232 <string>:
3233 3233 \family default
3234 3234 \series default
3235 3235 String used for output prompts, also uses numbers like
3236 3236 \family typewriter
3237 3237 prompt_in1
3238 3238 \family default
3239 3239 .
3240 3240 Default: '
3241 3241 \family typewriter
3242 3242 Out[
3243 3243 \backslash
3244 3244 #]:
3245 3245 \family default
3246 3246 '
3247 3247 \layout List
3248 3248 \labelwidthstring 00.00.0000
3249 3249
3250 3250
3251 3251 \family typewriter
3252 3252 \series bold
3253 3253 -quick
3254 3254 \family default
3255 3255 \series default
3256 3256 : start in bare bones mode (no config file loaded).
3257 3257 \layout List
3258 3258 \labelwidthstring 00.00.0000
3259 3259
3260 3260
3261 3261 \family typewriter
3262 3262 \series bold
3263 3263 -rcfile\SpecialChar ~
3264 3264 <name>
3265 3265 \series default
3266 3266 :
3267 3267 \family default
3268 3268 name of your IPython resource configuration file.
3269 3269 Normally IPython loads ipythonrc (from current directory) or
3270 3270 \family typewriter
3271 3271 IPYTHONDIR/ipythonrc
3272 3272 \family default
3273 3273 .
3274 3274 \layout List
3275 3275 \labelwidthstring 00.00.0000
3276 3276
3277 3277 \SpecialChar ~
3278 3278 If the loading of your config file fails, IPython starts with a bare bones
3279 3279 configuration (no modules loaded at all).
3280 3280 \layout List
3281 3281 \labelwidthstring 00.00.0000
3282 3282
3283 3283
3284 3284 \family typewriter
3285 3285 \series bold
3286 3286 -[no]readline
3287 3287 \family default
3288 3288 \series default
3289 3289 : use the readline library, which is needed to support name completion and
3290 3290 command history, among other things.
3291 3291 It is enabled by default, but may cause problems for users of X/Emacs in
3292 3292 Python comint or shell buffers.
3293 3293 \layout List
3294 3294 \labelwidthstring 00.00.0000
3295 3295
3296 3296 \SpecialChar ~
3297 3297 Note that X/Emacs 'eterm' buffers (opened with
3298 3298 \family typewriter
3299 3299 M-x\SpecialChar ~
3300 3300 term
3301 3301 \family default
3302 3302 ) support IPython's readline and syntax coloring fine, only 'emacs' (
3303 3303 \family typewriter
3304 3304 M-x\SpecialChar ~
3305 3305 shell
3306 3306 \family default
3307 3307 and
3308 3308 \family typewriter
3309 3309 C-c\SpecialChar ~
3310 3310 !
3311 3311 \family default
3312 3312 ) buffers do not.
3313 3313 \layout List
3314 3314 \labelwidthstring 00.00.0000
3315 3315
3316 3316
3317 3317 \family typewriter
3318 3318 \series bold
3319 3319 -screen_length|sl\SpecialChar ~
3320 3320 <n>
3321 3321 \series default
3322 3322 :
3323 3323 \family default
3324 3324 number of lines of your screen.
3325 3325 This is used to control printing of very long strings.
3326 3326 Strings longer than this number of lines will be sent through a pager instead
3327 3327 of directly printed.
3328 3328 \layout List
3329 3329 \labelwidthstring 00.00.0000
3330 3330
3331 3331 \SpecialChar ~
3332 3332 The default value for this is 0, which means IPython will auto-detect your
3333 3333 screen size every time it needs to print certain potentially long strings
3334 3334 (this doesn't change the behavior of the 'print' keyword, it's only triggered
3335 3335 internally).
3336 3336 If for some reason this isn't working well (it needs curses support), specify
3337 3337 it yourself.
3338 3338 Otherwise don't change the default.
3339 3339 \layout List
3340 3340 \labelwidthstring 00.00.0000
3341 3341
3342 3342
3343 3343 \family typewriter
3344 3344 \series bold
3345 3345 -separate_in|si\SpecialChar ~
3346 3346 <string>
3347 3347 \series default
3348 3348 :
3349 3349 \family default
3350 3350 separator before input prompts.
3351 3351 Default: '
3352 3352 \family typewriter
3353 3353
3354 3354 \backslash
3355 3355 n
3356 3356 \family default
3357 3357 '
3358 3358 \layout List
3359 3359 \labelwidthstring 00.00.0000
3360 3360
3361 3361
3362 3362 \family typewriter
3363 3363 \series bold
3364 3364 -separate_out|so\SpecialChar ~
3365 3365 <string>
3366 3366 \family default
3367 3367 \series default
3368 3368 : separator before output prompts.
3369 3369 Default: nothing.
3370 3370 \layout List
3371 3371 \labelwidthstring 00.00.0000
3372 3372
3373 3373
3374 3374 \family typewriter
3375 3375 \series bold
3376 3376 -separate_out2|so2\SpecialChar ~
3377 3377 <string>
3378 3378 \series default
3379 3379 :
3380 3380 \family default
3381 3381 separator after output prompts.
3382 3382 Default: nothing.
3383 3383 \layout List
3384 3384 \labelwidthstring 00.00.0000
3385 3385
3386 3386 \SpecialChar ~
3387 3387 For these three options, use the value 0 to specify no separator.
3388 3388 \layout List
3389 3389 \labelwidthstring 00.00.0000
3390 3390
3391 3391
3392 3392 \family typewriter
3393 3393 \series bold
3394 3394 -nosep
3395 3395 \series default
3396 3396 :
3397 3397 \family default
3398 3398 shorthand for
3399 3399 \family typewriter
3400 3400 '-SeparateIn 0 -SeparateOut 0 -SeparateOut2 0'
3401 3401 \family default
3402 3402 .
3403 3403 Simply removes all input/output separators.
3404 3404 \layout List
3405 3405 \labelwidthstring 00.00.0000
3406 3406
3407 3407
3408 3408 \family typewriter
3409 3409 \series bold
3410 3410 -upgrade
3411 3411 \family default
3412 3412 \series default
3413 3413 : allows you to upgrade your
3414 3414 \family typewriter
3415 3415 IPYTHONDIR
3416 3416 \family default
3417 3417 configuration when you install a new version of IPython.
3418 3418 Since new versions may include new command line options or example files,
3419 3419 this copies updated ipythonrc-type files.
3420 3420 However, it backs up (with a
3421 3421 \family typewriter
3422 3422 .old
3423 3423 \family default
3424 3424 extension) all files which it overwrites so that you can merge back any
3425 3425 customizations you might have in your personal files.
3426 3426 \layout List
3427 3427 \labelwidthstring 00.00.0000
3428 3428
3429 3429
3430 3430 \family typewriter
3431 3431 \series bold
3432 3432 -Version
3433 3433 \series default
3434 3434 :
3435 3435 \family default
3436 3436 print version information and exit.
3437 3437 \layout List
3438 3438 \labelwidthstring 00.00.0000
3439 3439
3440 3440
3441 3441 \family typewriter
3442 3442 \series bold
3443 3443 -xmode <modename>
3444 3444 \series default
3445 3445 :
3446 3446 \family default
3447 3447 Mode for exception reporting.
3448 3448 \layout List
3449 3449 \labelwidthstring 00.00.0000
3450 3450
3451 3451 \SpecialChar ~
3452 3452 Valid modes: Plain, Context and Verbose.
3453 3453 \layout List
3454 3454 \labelwidthstring 00.00.0000
3455 3455
3456 3456 \SpecialChar ~
3457 3457 Plain: similar to python's normal traceback printing.
3458 3458 \layout List
3459 3459 \labelwidthstring 00.00.0000
3460 3460
3461 3461 \SpecialChar ~
3462 3462 Context: prints 5 lines of context source code around each line in the
3463 3463 traceback.
3464 3464 \layout List
3465 3465 \labelwidthstring 00.00.0000
3466 3466
3467 3467 \SpecialChar ~
3468 3468 Verbose: similar to Context, but additionally prints the variables currently
3469 3469 visible where the exception happened (shortening their strings if too long).
3470 3470 This can potentially be very slow, if you happen to have a huge data structure
3471 3471 whose string representation is complex to compute.
3472 3472 Your computer may appear to freeze for a while with cpu usage at 100%.
3473 3473 If this occurs, you can cancel the traceback with Ctrl-C (maybe hitting
3474 3474 it more than once).
3475 3475 \layout Section
3476 3476
3477 3477 Interactive use
3478 3478 \layout Standard
3479 3479
3480 3480
3481 3481 \series bold
3482 3482 Warning
3483 3483 \series default
3484 3484 : IPython relies on the existence of a global variable called
3485 3485 \family typewriter
3486 3486 __IP
3487 3487 \family default
3488 3488 which controls the shell itself.
3489 3489 If you redefine
3490 3490 \family typewriter
3491 3491 __IP
3492 3492 \family default
3493 3493 to anything, bizarre behavior will quickly occur.
3494 3494 \layout Standard
3495 3495
3496 3496 Other than the above warning, IPython is meant to work as a drop-in replacement
3497 3497 for the standard interactive interpreter.
3498 3498 As such, any code which is valid python should execute normally under IPython
3499 3499 (cases where this is not true should be reported as bugs).
3500 3500 It does, however, offer many features which are not available at a standard
3501 3501 python prompt.
3502 3502 What follows is a list of these.
3503 3503 \layout Subsection
3504 3504
3505 3505 Caution for Windows users
3506 3506 \layout Standard
3507 3507
3508 3508 Windows, unfortunately, uses the `
3509 3509 \family typewriter
3510 3510
3511 3511 \backslash
3512 3512
3513 3513 \family default
3514 3514 ' character as a path separator.
3515 3515 This is a terrible choice, because `
3516 3516 \family typewriter
3517 3517
3518 3518 \backslash
3519 3519
3520 3520 \family default
3521 3521 ' also represents the escape character in most modern programming languages,
3522 3522 including Python.
3523 3523 For this reason, issuing many of the commands discussed below (especially
3524 3524 magics which affect the filesystem) with `
3525 3525 \family typewriter
3526 3526
3527 3527 \backslash
3528 3528
3529 3529 \family default
3530 3530 ' in them will cause strange errors.
3531 3531 \layout Standard
3532 3532
3533 3533 A partial solution is to use instead the `
3534 3534 \family typewriter
3535 3535 /
3536 3536 \family default
3537 3537 ' character as a path separator, which Windows recognizes in
3538 3538 \emph on
3539 3539 most
3540 3540 \emph default
3541 3541 situations.
3542 3542 However, in Windows commands `
3543 3543 \family typewriter
3544 3544 /
3545 3545 \family default
3546 3546 ' flags options, so you can not use it for the root directory.
3547 3547 This means that paths beginning at the root must be typed in a contrived
3548 3548 manner like:
3549 3549 \newline
3550 3550
3551 3551 \family typewriter
3552 3552 %copy
3553 3553 \backslash
3554 3554 opt/foo/bar.txt
3555 3555 \backslash
3556 3556 tmp
3557 3557 \layout Standard
3558 3558
3559 3559 There is no sensible thing IPython can do to truly work around this flaw
3560 3560 in Windows
3561 3561 \begin_inset Foot
3562 3562 collapsed true
3563 3563
3564 3564 \layout Standard
3565 3565
3566 3566 If anyone comes up with a
3567 3567 \emph on
3568 3568 clean
3569 3569 \emph default
3570 3570 solution which works consistently and does not negatively impact other
3571 3571 platforms at all, I'll gladly accept a patch.
3572 3572 \end_inset
3573 3573
3574 3574 .
3575 3575 \layout Subsection
3576 3576
3577 3577
3578 3578 \begin_inset LatexCommand \label{sec:magic}
3579 3579
3580 3580 \end_inset
3581 3581
3582 3582 Magic command system
3583 3583 \layout Standard
3584 3584
3585 3585 IPython will treat any line whose first character is a
3586 3586 \family typewriter
3587 3587 %
3588 3588 \family default
3589 3589 as a special call to a 'magic' function.
3590 3590 These allow you to control the behavior of IPython itself, plus a lot of
3591 3591 system-type features.
3592 3592 They are all prefixed with a
3593 3593 \family typewriter
3594 3594 %
3595 3595 \family default
3596 3596 character, but parameters are given without parentheses or quotes.
3597 3597 \layout Standard
3598 3598
3599 3599 Example: typing
3600 3600 \family typewriter
3601 3601 '%cd mydir'
3602 3602 \family default
3603 3603 (without the quotes) changes you working directory to
3604 3604 \family typewriter
3605 3605 'mydir'
3606 3606 \family default
3607 3607 , if it exists.
3608 3608 \layout Standard
3609 3609
3610 3610 If you have 'automagic' enabled (in your
3611 3611 \family typewriter
3612 3612 ipythonrc
3613 3613 \family default
3614 3614 file, via the command line option
3615 3615 \family typewriter
3616 3616 -automagic
3617 3617 \family default
3618 3618 or with the
3619 3619 \family typewriter
3620 3620 %automagic
3621 3621 \family default
3622 3622 function), you don't need to type in the
3623 3623 \family typewriter
3624 3624 %
3625 3625 \family default
3626 3626 explicitly.
3627 3627 IPython will scan its internal list of magic functions and call one if
3628 3628 it exists.
3629 3629 With automagic on you can then just type '
3630 3630 \family typewriter
3631 3631 cd mydir
3632 3632 \family default
3633 3633 ' to go to directory '
3634 3634 \family typewriter
3635 3635 mydir
3636 3636 \family default
3637 3637 '.
3638 3638 The automagic system has the lowest possible precedence in name searches,
3639 3639 so defining an identifier with the same name as an existing magic function
3640 3640 will shadow it for automagic use.
3641 3641 You can still access the shadowed magic function by explicitly using the
3642 3642
3643 3643 \family typewriter
3644 3644 %
3645 3645 \family default
3646 3646 character at the beginning of the line.
3647 3647 \layout Standard
3648 3648
3649 3649 An example (with automagic on) should clarify all this:
3650 3650 \layout LyX-Code
3651 3651
3652 3652 In [1]: cd ipython # %cd is called by automagic
3653 3653 \layout LyX-Code
3654 3654
3655 3655 /home/fperez/ipython
3656 3656 \layout LyX-Code
3657 3657
3658 3658 In [2]: cd=1 # now cd is just a variable
3659 3659 \layout LyX-Code
3660 3660
3661 3661 In [3]: cd ..
3662 3662 # and doesn't work as a function anymore
3663 3663 \layout LyX-Code
3664 3664
3665 3665 ------------------------------------------------------------
3666 3666 \layout LyX-Code
3667 3667
3668 3668 File "<console>", line 1
3669 3669 \layout LyX-Code
3670 3670
3671 3671 cd ..
3672 3672 \layout LyX-Code
3673 3673
3674 3674 ^
3675 3675 \layout LyX-Code
3676 3676
3677 3677 SyntaxError: invalid syntax
3678 3678 \layout LyX-Code
3679 3679
3680 3680 \layout LyX-Code
3681 3681
3682 3682 In [4]: %cd ..
3683 3683 # but %cd always works
3684 3684 \layout LyX-Code
3685 3685
3686 3686 /home/fperez
3687 3687 \layout LyX-Code
3688 3688
3689 3689 In [5]: del cd # if you remove the cd variable
3690 3690 \layout LyX-Code
3691 3691
3692 3692 In [6]: cd ipython # automagic can work again
3693 3693 \layout LyX-Code
3694 3694
3695 3695 /home/fperez/ipython
3696 3696 \layout Standard
3697 3697
3698 3698 You can define your own magic functions to extend the system.
3699 3699 The following is a snippet of code which shows how to do it.
3700 3700 It is provided as file
3701 3701 \family typewriter
3702 3702 example-magic.py
3703 3703 \family default
3704 3704 in the examples directory:
3705 3705 \layout Standard
3706 3706
3707 3707
3708 3708 \begin_inset ERT
3709 3709 status Open
3710 3710
3711 3711 \layout Standard
3712 3712
3713 3713 \backslash
3714 3714 codelist{examples/example-magic.py}
3715 3715 \end_inset
3716 3716
3717 3717
3718 3718 \layout Standard
3719 3719
3720 3720 You can also define your own aliased names for magic functions.
3721 3721 In your
3722 3722 \family typewriter
3723 3723 ipythonrc
3724 3724 \family default
3725 3725 file, placing a line like:
3726 3726 \layout Standard
3727 3727
3728 3728
3729 3729 \family typewriter
3730 3730 execute __IP.magic_cl = __IP.magic_clear
3731 3731 \layout Standard
3732 3732
3733 3733 will define
3734 3734 \family typewriter
3735 3735 %cl
3736 3736 \family default
3737 3737 as a new name for
3738 3738 \family typewriter
3739 3739 %clear
3740 3740 \family default
3741 3741 .
3742 3742 \layout Standard
3743 3743
3744 3744 Type
3745 3745 \family typewriter
3746 3746 %magic
3747 3747 \family default
3748 3748 for more information, including a list of all available magic functions
3749 3749 at any time and their docstrings.
3750 3750 You can also type
3751 3751 \family typewriter
3752 3752 %magic_function_name?
3753 3753 \family default
3754 3754 (see sec.
3755 3755
3756 3756 \begin_inset LatexCommand \ref{sec:dyn-object-info}
3757 3757
3758 3758 \end_inset
3759 3759
3760 3760 for information on the
3761 3761 \family typewriter
3762 3762 '?'
3763 3763 \family default
3764 3764 system) to get information about any particular magic function you are
3765 3765 interested in.
3766 3766 \layout Subsubsection
3767 3767
3768 3768 Magic commands
3769 3769 \layout Standard
3770 3770
3771 3771 The rest of this section is automatically generated for each release from
3772 3772 the docstrings in the IPython code.
3773 3773 Therefore the formatting is somewhat minimal, but this method has the advantage
3774 3774 of having information always in sync with the code.
3775 3775 \layout Standard
3776 3776
3777 3777 A list of all the magic commands available in IPython's
3778 3778 \emph on
3779 3779 default
3780 3780 \emph default
3781 3781 installation follows.
3782 3782 This is similar to what you'll see by simply typing
3783 3783 \family typewriter
3784 3784 %magic
3785 3785 \family default
3786 3786 at the prompt, but that will also give you information about magic commands
3787 3787 you may have added as part of your personal customizations.
3788 3788 \layout Standard
3789 3789
3790 3790
3791 3791 \begin_inset Include \input{magic.tex}
3792 3792 preview false
3793 3793
3794 3794 \end_inset
3795 3795
3796 3796
3797 3797 \layout Subsection
3798 3798
3799 3799 Access to the standard Python help
3800 3800 \layout Standard
3801 3801
3802 3802 As of Python 2.1, a help system is available with access to object docstrings
3803 3803 and the Python manuals.
3804 3804 Simply type
3805 3805 \family typewriter
3806 3806 'help'
3807 3807 \family default
3808 3808 (no quotes) to access it.
3809 3809 You can also type
3810 3810 \family typewriter
3811 3811 help(object)
3812 3812 \family default
3813 3813 to obtain information about a given object, and
3814 3814 \family typewriter
3815 3815 help('keyword')
3816 3816 \family default
3817 3817 for information on a keyword.
3818 3818 As noted in sec.
3819 3819
3820 3820 \begin_inset LatexCommand \ref{sec:help-access}
3821 3821
3822 3822 \end_inset
3823 3823
3824 3824 , you need to properly configure your environment variable
3825 3825 \family typewriter
3826 3826 PYTHONDOCS
3827 3827 \family default
3828 3828 for this feature to work correctly.
3829 3829 \layout Subsection
3830 3830
3831 3831
3832 3832 \begin_inset LatexCommand \label{sec:dyn-object-info}
3833 3833
3834 3834 \end_inset
3835 3835
3836 3836 Dynamic object information
3837 3837 \layout Standard
3838 3838
3839 3839 Typing
3840 3840 \family typewriter
3841 3841 ?word
3842 3842 \family default
3843 3843 or
3844 3844 \family typewriter
3845 3845 word?
3846 3846 \family default
3847 3847 prints detailed information about an object.
3848 3848 If certain strings in the object are too long (docstrings, code, etc.) they
3849 3849 get snipped in the center for brevity.
3850 3850 This system gives access variable types and values, full source code for
3851 3851 any object (if available), function prototypes and other useful information.
3852 3852 \layout Standard
3853 3853
3854 3854 Typing
3855 3855 \family typewriter
3856 3856 ??word
3857 3857 \family default
3858 3858 or
3859 3859 \family typewriter
3860 3860 word??
3861 3861 \family default
3862 3862 gives access to the full information without snipping long strings.
3863 3863 Long strings are sent to the screen through the
3864 3864 \family typewriter
3865 3865 less
3866 3866 \family default
3867 3867 pager if longer than the screen and printed otherwise.
3868 3868 On systems lacking the
3869 3869 \family typewriter
3870 3870 less
3871 3871 \family default
3872 3872 command, IPython uses a very basic internal pager.
3873 3873 \layout Standard
3874 3874
3875 3875 The following magic functions are particularly useful for gathering information
3876 3876 about your working environment.
3877 3877 You can get more details by typing
3878 3878 \family typewriter
3879 3879 %magic
3880 3880 \family default
3881 3881 or querying them individually (use
3882 3882 \family typewriter
3883 3883 %function_name?
3884 3884 \family default
3885 3885 with or without the
3886 3886 \family typewriter
3887 3887 %
3888 3888 \family default
3889 3889 ), this is just a summary:
3890 3890 \layout List
3891 3891 \labelwidthstring 00.00.0000
3892 3892
3893 3893
3894 3894 \family typewriter
3895 3895 \series bold
3896 3896 %pdoc\SpecialChar ~
3897 3897 <object>
3898 3898 \family default
3899 3899 \series default
3900 3900 : Print (or run through a pager if too long) the docstring for an object.
3901 3901 If the given object is a class, it will print both the class and the constructo
3902 3902 r docstrings.
3903 3903 \layout List
3904 3904 \labelwidthstring 00.00.0000
3905 3905
3906 3906
3907 3907 \family typewriter
3908 3908 \series bold
3909 3909 %pdef\SpecialChar ~
3910 3910 <object>
3911 3911 \family default
3912 3912 \series default
3913 3913 : Print the definition header for any callable object.
3914 3914 If the object is a class, print the constructor information.
3915 3915 \layout List
3916 3916 \labelwidthstring 00.00.0000
3917 3917
3918 3918
3919 3919 \family typewriter
3920 3920 \series bold
3921 3921 %psource\SpecialChar ~
3922 3922 <object>
3923 3923 \family default
3924 3924 \series default
3925 3925 : Print (or run through a pager if too long) the source code for an object.
3926 3926 \layout List
3927 3927 \labelwidthstring 00.00.0000
3928 3928
3929 3929
3930 3930 \family typewriter
3931 3931 \series bold
3932 3932 %pfile\SpecialChar ~
3933 3933 <object>
3934 3934 \family default
3935 3935 \series default
3936 3936 : Show the entire source file where an object was defined via a pager, opening
3937 3937 it at the line where the object definition begins.
3938 3938 \layout List
3939 3939 \labelwidthstring 00.00.0000
3940 3940
3941 3941
3942 3942 \family typewriter
3943 3943 \series bold
3944 3944 %who/%whos
3945 3945 \family default
3946 3946 \series default
3947 3947 : These functions give information about identifiers you have defined interactiv
3948 3948 ely (not things you loaded or defined in your configuration files).
3949 3949
3950 3950 \family typewriter
3951 3951 %who
3952 3952 \family default
3953 3953 just prints a list of identifiers and
3954 3954 \family typewriter
3955 3955 %whos
3956 3956 \family default
3957 3957 prints a table with some basic details about each identifier.
3958 3958 \layout Standard
3959 3959
3960 3960 Note that the dynamic object information functions (
3961 3961 \family typewriter
3962 3962 ?/??, %pdoc, %pfile, %pdef, %psource
3963 3963 \family default
3964 3964 ) give you access to documentation even on things which are not really defined
3965 3965 as separate identifiers.
3966 3966 Try for example typing
3967 3967 \family typewriter
3968 3968 {}.get?
3969 3969 \family default
3970 3970 or after doing
3971 3971 \family typewriter
3972 3972 import os
3973 3973 \family default
3974 3974 , type
3975 3975 \family typewriter
3976 3976 os.path.abspath??
3977 3977 \family default
3978 3978 .
3979 3979 \layout Subsection
3980 3980
3981 3981
3982 3982 \begin_inset LatexCommand \label{sec:readline}
3983 3983
3984 3984 \end_inset
3985 3985
3986 3986 Readline-based features
3987 3987 \layout Standard
3988 3988
3989 3989 These features require the GNU readline library, so they won't work if your
3990 3990 Python installation lacks readline support.
3991 3991 We will first describe the default behavior IPython uses, and then how
3992 3992 to change it to suit your preferences.
3993 3993 \layout Subsubsection
3994 3994
3995 3995 Command line completion
3996 3996 \layout Standard
3997 3997
3998 3998 At any time, hitting TAB will complete any available python commands or
3999 3999 variable names, and show you a list of the possible completions if there's
4000 4000 no unambiguous one.
4001 4001 It will also complete filenames in the current directory if no python names
4002 4002 match what you've typed so far.
4003 4003 \layout Subsubsection
4004 4004
4005 4005 Search command history
4006 4006 \layout Standard
4007 4007
4008 4008 IPython provides two ways for searching through previous input and thus
4009 4009 reduce the need for repetitive typing:
4010 4010 \layout Enumerate
4011 4011
4012 4012 Start typing, and then use
4013 4013 \family typewriter
4014 4014 Ctrl-p
4015 4015 \family default
4016 4016 (previous,up) and
4017 4017 \family typewriter
4018 4018 Ctrl-n
4019 4019 \family default
4020 4020 (next,down) to search through only the history items that match what you've
4021 4021 typed so far.
4022 4022 If you use
4023 4023 \family typewriter
4024 4024 Ctrl-p/Ctrl-n
4025 4025 \family default
4026 4026 at a blank prompt, they just behave like normal arrow keys.
4027 4027 \layout Enumerate
4028 4028
4029 4029 Hit
4030 4030 \family typewriter
4031 4031 Ctrl-r
4032 4032 \family default
4033 4033 : opens a search prompt.
4034 4034 Begin typing and the system searches your history for lines that contain
4035 4035 what you've typed so far, completing as much as it can.
4036 4036 \layout Subsubsection
4037 4037
4038 4038 Persistent command history across sessions
4039 4039 \layout Standard
4040 4040
4041 4041 IPython will save your input history when it leaves and reload it next time
4042 4042 you restart it.
4043 4043 By default, the history file is named
4044 4044 \family typewriter
4045 4045 $IPYTHONDIR/history
4046 4046 \family default
4047 4047 , but if you've loaded a named profile, '
4048 4048 \family typewriter
4049 4049 -PROFILE_NAME
4050 4050 \family default
4051 4051 ' is appended to the name.
4052 4052 This allows you to keep separate histories related to various tasks: commands
4053 4053 related to numerical work will not be clobbered by a system shell history,
4054 4054 for example.
4055 4055 \layout Subsubsection
4056 4056
4057 4057 Autoindent
4058 4058 \layout Standard
4059 4059
4060 4060 IPython can recognize lines ending in ':' and indent the next line, while
4061 4061 also un-indenting automatically after 'raise' or 'return'.
4062 4062
4063 4063 \layout Standard
4064 4064
4065 4065 This feature uses the readline library, so it will honor your
4066 4066 \family typewriter
4067 4067 ~/.inputrc
4068 4068 \family default
4069 4069 configuration (or whatever file your
4070 4070 \family typewriter
4071 4071 INPUTRC
4072 4072 \family default
4073 4073 variable points to).
4074 4074 Adding the following lines to your
4075 4075 \family typewriter
4076 4076 .inputrc
4077 4077 \family default
4078 4078 file can make indenting/unindenting more convenient (
4079 4079 \family typewriter
4080 4080 M-i
4081 4081 \family default
4082 4082 indents,
4083 4083 \family typewriter
4084 4084 M-u
4085 4085 \family default
4086 4086 unindents):
4087 4087 \layout Standard
4088 4088
4089 4089
4090 4090 \family typewriter
4091 4091 $if Python
4092 4092 \newline
4093 4093 "
4094 4094 \backslash
4095 4095 M-i": "\SpecialChar ~
4096 4096 \SpecialChar ~
4097 4097 \SpecialChar ~
4098 4098 \SpecialChar ~
4099 4099 "
4100 4100 \newline
4101 4101 "
4102 4102 \backslash
4103 4103 M-u": "
4104 4104 \backslash
4105 4105 d
4106 4106 \backslash
4107 4107 d
4108 4108 \backslash
4109 4109 d
4110 4110 \backslash
4111 4111 d"
4112 4112 \newline
4113 4113 $endif
4114 4114 \layout Standard
4115 4115
4116 4116 Note that there are 4 spaces between the quote marks after
4117 4117 \family typewriter
4118 4118 "M-i"
4119 4119 \family default
4120 4120 above.
4121 4121 \layout Standard
4122 4122
4123 4123
4124 4124 \series bold
4125 4125 Warning:
4126 4126 \series default
4127 4127 this feature is ON by default, but it can cause problems with the pasting
4128 4128 of multi-line indented code (the pasted code gets re-indented on each line).
4129 4129 A magic function
4130 4130 \family typewriter
4131 4131 %autoindent
4132 4132 \family default
4133 4133 allows you to toggle it on/off at runtime.
4134 4134 You can also disable it permanently on in your
4135 4135 \family typewriter
4136 4136 ipythonrc
4137 4137 \family default
4138 4138 file (set
4139 4139 \family typewriter
4140 4140 autoindent 0
4141 4141 \family default
4142 4142 ).
4143 4143 \layout Subsubsection
4144 4144
4145 4145 Customizing readline behavior
4146 4146 \layout Standard
4147 4147
4148 4148 All these features are based on the GNU readline library, which has an extremely
4149 4149 customizable interface.
4150 4150 Normally, readline is configured via a file which defines the behavior
4151 4151 of the library; the details of the syntax for this can be found in the
4152 4152 readline documentation available with your system or on the Internet.
4153 4153 IPython doesn't read this file (if it exists) directly, but it does support
4154 4154 passing to readline valid options via a simple interface.
4155 4155 In brief, you can customize readline by setting the following options in
4156 4156 your
4157 4157 \family typewriter
4158 4158 ipythonrc
4159 4159 \family default
4160 4160 configuration file (note that these options can
4161 4161 \emph on
4162 4162 not
4163 4163 \emph default
4164 4164 be specified at the command line):
4165 4165 \layout List
4166 4166 \labelwidthstring 00.00.0000
4167 4167
4168 4168
4169 4169 \family typewriter
4170 4170 \series bold
4171 4171 readline_parse_and_bind:
4172 4172 \family default
4173 4173 \series default
4174 4174 this option can appear as many times as you want, each time defining a
4175 4175 string to be executed via a
4176 4176 \family typewriter
4177 4177 readline.parse_and_bind()
4178 4178 \family default
4179 4179 command.
4180 4180 The syntax for valid commands of this kind can be found by reading the
4181 4181 documentation for the GNU readline library, as these commands are of the
4182 4182 kind which readline accepts in its configuration file.
4183 4183 \layout List
4184 4184 \labelwidthstring 00.00.0000
4185 4185
4186 4186
4187 4187 \family typewriter
4188 4188 \series bold
4189 4189 readline_remove_delims:
4190 4190 \family default
4191 4191 \series default
4192 4192 a string of characters to be removed from the default word-delimiters list
4193 4193 used by readline, so that completions may be performed on strings which
4194 4194 contain them.
4195 4195 Do not change the default value unless you know what you're doing.
4196 4196 \layout List
4197 4197 \labelwidthstring 00.00.0000
4198 4198
4199 4199
4200 4200 \family typewriter
4201 4201 \series bold
4202 4202 readline_omit__names
4203 4203 \family default
4204 4204 \series default
4205 4205 : when tab-completion is enabled, hitting
4206 4206 \family typewriter
4207 4207 <tab>
4208 4208 \family default
4209 4209 after a '
4210 4210 \family typewriter
4211 4211 .
4212 4212 \family default
4213 4213 ' in a name will complete all attributes of an object, including all the
4214 4214 special methods whose names include double underscores (like
4215 4215 \family typewriter
4216 4216 __getitem__
4217 4217 \family default
4218 4218 or
4219 4219 \family typewriter
4220 4220 __class__
4221 4221 \family default
4222 4222 ).
4223 4223 If you'd rather not see these names by default, you can set this option
4224 4224 to 1.
4225 4225 Note that even when this option is set, you can still see those names by
4226 4226 explicitly typing a
4227 4227 \family typewriter
4228 4228 _
4229 4229 \family default
4230 4230 after the period and hitting
4231 4231 \family typewriter
4232 4232 <tab>
4233 4233 \family default
4234 4234 : '
4235 4235 \family typewriter
4236 4236 name._<tab>
4237 4237 \family default
4238 4238 ' will always complete attribute names starting with '
4239 4239 \family typewriter
4240 4240 _
4241 4241 \family default
4242 4242 '.
4243 4243 \layout List
4244 4244 \labelwidthstring 00.00.0000
4245 4245
4246 4246 \SpecialChar ~
4247 4247 This option is off by default so that new users see all attributes of any
4248 4248 objects they are dealing with.
4249 4249 \layout Standard
4250 4250
4251 4251 You will find the default values along with a corresponding detailed explanation
4252 4252 in your
4253 4253 \family typewriter
4254 4254 ipythonrc
4255 4255 \family default
4256 4256 file.
4257 4257 \layout Subsection
4258 4258
4259 4259 Session logging and restoring
4260 4260 \layout Standard
4261 4261
4262 4262 You can log all input from a session either by starting IPython with the
4263 4263 command line switches
4264 4264 \family typewriter
4265 4265 -log
4266 4266 \family default
4267 4267 or
4268 4268 \family typewriter
4269 4269 -logfile
4270 4270 \family default
4271 4271 (see sec.
4272 4272
4273 4273 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
4274 4274
4275 4275 \end_inset
4276 4276
4277 4277 )or by activating the logging at any moment with the magic function
4278 4278 \family typewriter
4279 4279 %logstart
4280 4280 \family default
4281 4281 .
4282 4282
4283 4283 \layout Standard
4284 4284
4285 4285 Log files can later be reloaded with the
4286 4286 \family typewriter
4287 4287 -logplay
4288 4288 \family default
4289 4289 option and IPython will attempt to 'replay' the log by executing all the
4290 4290 lines in it, thus restoring the state of a previous session.
4291 4291 This feature is not quite perfect, but can still be useful in many cases.
4292 4292 \layout Standard
4293 4293
4294 4294 The log files can also be used as a way to have a permanent record of any
4295 4295 code you wrote while experimenting.
4296 4296 Log files are regular text files which you can later open in your favorite
4297 4297 text editor to extract code or to 'clean them up' before using them to
4298 4298 replay a session.
4299 4299 \layout Standard
4300 4300
4301 4301 The
4302 4302 \family typewriter
4303 4303 %logstart
4304 4304 \family default
4305 4305 function for activating logging in mid-session is used as follows:
4306 4306 \layout Standard
4307 4307
4308 4308
4309 4309 \family typewriter
4310 4310 %logstart [log_name [log_mode]]
4311 4311 \layout Standard
4312 4312
4313 4313 If no name is given, it defaults to a file named
4314 4314 \family typewriter
4315 4315 'log'
4316 4316 \family default
4317 4317 in your IPYTHONDIR directory, in
4318 4318 \family typewriter
4319 4319 'rotate'
4320 4320 \family default
4321 4321 mode (see below).
4322 4322 \layout Standard
4323 4323
4324 4324 '
4325 4325 \family typewriter
4326 4326 %logstart name
4327 4327 \family default
4328 4328 ' saves to file
4329 4329 \family typewriter
4330 4330 'name'
4331 4331 \family default
4332 4332 in
4333 4333 \family typewriter
4334 4334 'backup'
4335 4335 \family default
4336 4336 mode.
4337 4337 It saves your history up to that point and then continues logging.
4338 4338 \layout Standard
4339 4339
4340 4340
4341 4341 \family typewriter
4342 4342 %logstart
4343 4343 \family default
4344 4344 takes a second optional parameter: logging mode.
4345 4345 This can be one of (note that the modes are given unquoted):
4346 4346 \layout List
4347 4347 \labelwidthstring 00.00.0000
4348 4348
4349 4349
4350 4350 \family typewriter
4351 4351 over
4352 4352 \family default
4353 4353 : overwrite existing
4354 4354 \family typewriter
4355 4355 log_name
4356 4356 \family default
4357 4357 .
4358 4358 \layout List
4359 4359 \labelwidthstring 00.00.0000
4360 4360
4361 4361
4362 4362 \family typewriter
4363 4363 backup
4364 4364 \family default
4365 4365 : rename (if exists) to
4366 4366 \family typewriter
4367 4367 log_name~
4368 4368 \family default
4369 4369 and start
4370 4370 \family typewriter
4371 4371 log_name
4372 4372 \family default
4373 4373 .
4374 4374 \layout List
4375 4375 \labelwidthstring 00.00.0000
4376 4376
4377 4377
4378 4378 \family typewriter
4379 4379 append
4380 4380 \family default
4381 4381 : well, that says it.
4382 4382 \layout List
4383 4383 \labelwidthstring 00.00.0000
4384 4384
4385 4385
4386 4386 \family typewriter
4387 4387 rotate
4388 4388 \family default
4389 4389 : create rotating logs
4390 4390 \family typewriter
4391 4391 log_name
4392 4392 \family default
4393 4393 .
4394 4394 \family typewriter
4395 4395 1~
4396 4396 \family default
4397 4397 ,
4398 4398 \family typewriter
4399 4399 log_name.2~
4400 4400 \family default
4401 4401 , etc.
4402 4402 \layout Standard
4403 4403
4404 4404 The
4405 4405 \family typewriter
4406 4406 %logoff
4407 4407 \family default
4408 4408 and
4409 4409 \family typewriter
4410 4410 %logon
4411 4411 \family default
4412 4412 functions allow you to temporarily stop and resume logging to a file which
4413 4413 had previously been started with
4414 4414 \family typewriter
4415 4415 %logstart
4416 4416 \family default
4417 4417 .
4418 4418 They will fail (with an explanation) if you try to use them before logging
4419 4419 has been started.
4420 4420 \layout Subsection
4421 4421
4422 4422
4423 4423 \begin_inset LatexCommand \label{sub:System-shell-access}
4424 4424
4425 4425 \end_inset
4426 4426
4427 4427 System shell access
4428 4428 \layout Standard
4429 4429
4430 4430 Any input line beginning with a
4431 4431 \family typewriter
4432 4432 !
4433 4433 \family default
4434 4434 character is passed verbatim (minus the
4435 4435 \family typewriter
4436 4436 !
4437 4437 \family default
4438 4438 , of course) to the underlying operating system.
4439 4439 For example, typing
4440 4440 \family typewriter
4441 4441 !ls
4442 4442 \family default
4443 4443 will run
4444 4444 \family typewriter
4445 4445 'ls'
4446 4446 \family default
4447 4447 in the current directory.
4448 4448 \layout Subsubsection
4449 4449
4450 4450 Manual capture of command output
4451 4451 \layout Standard
4452 4452
4453 4453 If the input line begins with
4454 4454 \emph on
4455 4455 two
4456 4456 \emph default
4457 4457 exclamation marks,
4458 4458 \family typewriter
4459 4459 !!
4460 4460 \family default
4461 4461 , the command is executed but its output is captured and returned as a python
4462 4462 list, split on newlines.
4463 4463 Any output sent by the subprocess to standard error is printed separately,
4464 4464 so that the resulting list only captures standard output.
4465 4465 The
4466 4466 \family typewriter
4467 4467 !!
4468 4468 \family default
4469 4469 syntax is a shorthand for the
4470 4470 \family typewriter
4471 4471 %sx
4472 4472 \family default
4473 4473 magic command.
4474 4474 \layout Standard
4475 4475
4476 4476 Finally, the
4477 4477 \family typewriter
4478 4478 %sc
4479 4479 \family default
4480 4480 magic (short for `shell capture') is similar to
4481 4481 \family typewriter
4482 4482 %sx
4483 4483 \family default
4484 4484 , but allowing more fine-grained control of the capture details, and storing
4485 4485 the result directly into a named variable.
4486 4486 \layout Standard
4487 4487
4488 4488 See Sec.\SpecialChar ~
4489 4489
4490 4490 \begin_inset LatexCommand \ref{sec:magic}
4491 4491
4492 4492 \end_inset
4493 4493
4494 4494 for details on the magics
4495 4495 \family typewriter
4496 4496 %sc
4497 4497 \family default
4498 4498 and
4499 4499 \family typewriter
4500 4500 %sx
4501 4501 \family default
4502 4502 , or use IPython's own help (
4503 4503 \family typewriter
4504 4504 sc?
4505 4505 \family default
4506 4506 and
4507 4507 \family typewriter
4508 4508 sx?
4509 4509 \family default
4510 4510 ) for further details.
4511 4511 \layout Standard
4512 4512
4513 4513 IPython also allows you to expand the value of python variables when making
4514 4514 system calls.
4515 4515 Any python variable or expression which you prepend with
4516 4516 \family typewriter
4517 4517 $
4518 4518 \family default
4519 4519 will get expanded before the system call is made.
4520 4520
4521 4521 \layout Standard
4522 4522
4523 4523
4524 4524 \family typewriter
4525 4525 In [1]: pyvar='Hello world'
4526 4526 \newline
4527 4527 In [2]: !echo "A python variable: $pyvar"
4528 4528 \newline
4529 4529 A python variable: Hello world
4530 4530 \layout Standard
4531 4531
4532 4532 If you want the shell to actually see a literal
4533 4533 \family typewriter
4534 4534 $
4535 4535 \family default
4536 4536 , you need to type it twice:
4537 4537 \layout Standard
4538 4538
4539 4539
4540 4540 \family typewriter
4541 4541 In [3]: !echo "A system variable: $$HOME"
4542 4542 \newline
4543 4543 A system variable: /home/fperez
4544 4544 \layout Standard
4545 4545
4546 4546 You can pass arbitrary expressions, though you'll need to delimit them with
4547 4547
4548 4548 \family typewriter
4549 4549 {}
4550 4550 \family default
4551 4551 if there is ambiguity as to the extent of the expression:
4552 4552 \layout Standard
4553 4553
4554 4554
4555 4555 \family typewriter
4556 4556 In [5]: x=10
4557 4557 \newline
4558 4558 In [6]: y=20
4559 4559 \newline
4560 4560 In [13]: !echo $x+y
4561 4561 \newline
4562 4562 10+y
4563 4563 \newline
4564 4564 In [7]: !echo ${x+y}
4565 4565 \newline
4566 4566 30
4567 4567 \layout Standard
4568 4568
4569 4569 Even object attributes can be expanded:
4570 4570 \layout Standard
4571 4571
4572 4572
4573 4573 \family typewriter
4574 4574 In [12]: !echo $sys.argv
4575 4575 \newline
4576 4576 [/home/fperez/usr/bin/ipython]
4577 4577 \layout Subsection
4578 4578
4579 4579 System command aliases
4580 4580 \layout Standard
4581 4581
4582 4582 The
4583 4583 \family typewriter
4584 4584 %alias
4585 4585 \family default
4586 4586 magic function and the
4587 4587 \family typewriter
4588 4588 alias
4589 4589 \family default
4590 4590 option in the
4591 4591 \family typewriter
4592 4592 ipythonrc
4593 4593 \family default
4594 4594 configuration file allow you to define magic functions which are in fact
4595 4595 system shell commands.
4596 4596 These aliases can have parameters.
4597 4597
4598 4598 \layout Standard
4599 4599
4600 4600 '
4601 4601 \family typewriter
4602 4602 %alias alias_name cmd
4603 4603 \family default
4604 4604 ' defines '
4605 4605 \family typewriter
4606 4606 alias_name
4607 4607 \family default
4608 4608 ' as an alias for '
4609 4609 \family typewriter
4610 4610 cmd
4611 4611 \family default
4612 4612 '
4613 4613 \layout Standard
4614 4614
4615 4615 Then, typing '
4616 4616 \family typewriter
4617 4617 %alias_name params
4618 4618 \family default
4619 4619 ' will execute the system command '
4620 4620 \family typewriter
4621 4621 cmd params
4622 4622 \family default
4623 4623 ' (from your underlying operating system).
4624 4624
4625 4625 \layout Standard
4626 4626
4627 4627 You can also define aliases with parameters using
4628 4628 \family typewriter
4629 4629 %s
4630 4630 \family default
4631 4631 specifiers (one per parameter).
4632 4632 The following example defines the
4633 4633 \family typewriter
4634 4634 %parts
4635 4635 \family default
4636 4636 function as an alias to the command '
4637 4637 \family typewriter
4638 4638 echo first %s second %s
4639 4639 \family default
4640 4640 ' where each
4641 4641 \family typewriter
4642 4642 %s
4643 4643 \family default
4644 4644 will be replaced by a positional parameter to the call to
4645 4645 \family typewriter
4646 4646 %parts:
4647 4647 \layout Standard
4648 4648
4649 4649
4650 4650 \family typewriter
4651 4651 In [1]: alias parts echo first %s second %s
4652 4652 \newline
4653 4653 In [2]: %parts A B
4654 4654 \newline
4655 4655 first A second B
4656 4656 \newline
4657 4657 In [3]: %parts A
4658 4658 \newline
4659 4659 Incorrect number of arguments: 2 expected.
4660 4660
4661 4661 \newline
4662 4662 parts is an alias to: 'echo first %s second %s'
4663 4663 \layout Standard
4664 4664
4665 4665 If called with no parameters,
4666 4666 \family typewriter
4667 4667 %alias
4668 4668 \family default
4669 4669 prints the table of currently defined aliases.
4670 4670 \layout Standard
4671 4671
4672 4672 The
4673 4673 \family typewriter
4674 4674 %rehash/rehashx
4675 4675 \family default
4676 4676 magics allow you to load your entire
4677 4677 \family typewriter
4678 4678 $PATH
4679 4679 \family default
4680 4680 as ipython aliases.
4681 4681 See their respective docstrings (or sec.\SpecialChar ~
4682 4682
4683 4683 \begin_inset LatexCommand \ref{sec:magic}
4684 4684
4685 4685 \end_inset
4686 4686
4687 4687 for further details).
4688 4688 \layout Subsection
4689 4689
4690 4690
4691 4691 \begin_inset LatexCommand \label{sec:dreload}
4692 4692
4693 4693 \end_inset
4694 4694
4695 4695 Recursive reload
4696 4696 \layout Standard
4697 4697
4698 4698 The
4699 4699 \family typewriter
4700 4700 %dreload
4701 4701 \family default
4702 4702 command does a recursive reload of a module: changes made to the module
4703 4703 since you imported will actually be available without having to exit.
4704 4704 \layout Subsection
4705 4705
4706 4706 Verbose and colored exception traceback printouts
4707 4707 \layout Standard
4708 4708
4709 4709 IPython provides the option to see very detailed exception tracebacks, which
4710 4710 can be especially useful when debugging large programs.
4711 4711 You can run any Python file with the
4712 4712 \family typewriter
4713 4713 %run
4714 4714 \family default
4715 4715 function to benefit from these detailed tracebacks.
4716 4716 Furthermore, both normal and verbose tracebacks can be colored (if your
4717 4717 terminal supports it) which makes them much easier to parse visually.
4718 4718 \layout Standard
4719 4719
4720 4720 See the magic
4721 4721 \family typewriter
4722 4722 xmode
4723 4723 \family default
4724 4724 and
4725 4725 \family typewriter
4726 4726 colors
4727 4727 \family default
4728 4728 functions for details (just type
4729 4729 \family typewriter
4730 4730 %magic
4731 4731 \family default
4732 4732 ).
4733 4733 \layout Standard
4734 4734
4735 4735 These features are basically a terminal version of Ka-Ping Yee's
4736 4736 \family typewriter
4737 4737 cgitb
4738 4738 \family default
4739 4739 module, now part of the standard Python library.
4740 4740 \layout Subsection
4741 4741
4742 4742
4743 4743 \begin_inset LatexCommand \label{sec:cache_input}
4744 4744
4745 4745 \end_inset
4746 4746
4747 4747 Input caching system
4748 4748 \layout Standard
4749 4749
4750 4750 IPython offers numbered prompts (In/Out) with input and output caching.
4751 4751 All input is saved and can be retrieved as variables (besides the usual
4752 4752 arrow key recall).
4753 4753 \layout Standard
4754 4754
4755 4755 The following GLOBAL variables always exist (so don't overwrite them!):
4756 4756
4757 4757 \family typewriter
4758 4758 _i
4759 4759 \family default
4760 4760 : stores previous input.
4761 4761
4762 4762 \family typewriter
4763 4763 _ii
4764 4764 \family default
4765 4765 : next previous.
4766 4766
4767 4767 \family typewriter
4768 4768 _iii
4769 4769 \family default
4770 4770 : next-next previous.
4771 4771
4772 4772 \family typewriter
4773 4773 _ih
4774 4774 \family default
4775 4775 : a list of all input
4776 4776 \family typewriter
4777 4777 _ih[n]
4778 4778 \family default
4779 4779 is the input from line
4780 4780 \family typewriter
4781 4781 n
4782 4782 \family default
4783 4783 and this list is aliased to the global variable
4784 4784 \family typewriter
4785 4785 In
4786 4786 \family default
4787 4787 .
4788 4788 If you overwrite
4789 4789 \family typewriter
4790 4790 In
4791 4791 \family default
4792 4792 with a variable of your own, you can remake the assignment to the internal
4793 4793 list with a simple
4794 4794 \family typewriter
4795 4795 'In=_ih'
4796 4796 \family default
4797 4797 .
4798 4798 \layout Standard
4799 4799
4800 4800 Additionally, global variables named
4801 4801 \family typewriter
4802 4802 _i<n>
4803 4803 \family default
4804 4804 are dynamically created (
4805 4805 \family typewriter
4806 4806 <n>
4807 4807 \family default
4808 4808 being the prompt counter), such that
4809 4809 \newline
4810 4810
4811 4811 \family typewriter
4812 4812 _i<n> == _ih[<n>] == In[<n>].
4813 4813 \layout Standard
4814 4814
4815 4815 For example, what you typed at prompt 14 is available as
4816 4816 \family typewriter
4817 4817 _i14,
4818 4818 \family default
4819 4819
4820 4820 \family typewriter
4821 4821 _ih[14]
4822 4822 \family default
4823 4823 and
4824 4824 \family typewriter
4825 4825 In[14]
4826 4826 \family default
4827 4827 .
4828 4828 \layout Standard
4829 4829
4830 4830 This allows you to easily cut and paste multi line interactive prompts by
4831 4831 printing them out: they print like a clean string, without prompt characters.
4832 4832 You can also manipulate them like regular variables (they are strings),
4833 4833 modify or exec them (typing
4834 4834 \family typewriter
4835 4835 'exec _i9'
4836 4836 \family default
4837 4837 will re-execute the contents of input prompt 9, '
4838 4838 \family typewriter
4839 4839 exec In[9:14]+In[18]
4840 4840 \family default
4841 4841 ' will re-execute lines 9 through 13 and line 18).
4842 4842 \layout Standard
4843 4843
4844 4844 You can also re-execute multiple lines of input easily by using the magic
4845 4845
4846 4846 \family typewriter
4847 4847 %macro
4848 4848 \family default
4849 4849 function (which automates the process and allows re-execution without having
4850 4850 to type '
4851 4851 \family typewriter
4852 4852 exec
4853 4853 \family default
4854 4854 ' every time).
4855 4855 The macro system also allows you to re-execute previous lines which include
4856 4856 magic function calls (which require special processing).
4857 4857 Type
4858 4858 \family typewriter
4859 4859 %macro?
4860 4860 \family default
4861 4861 or see sec.
4862 4862
4863 4863 \begin_inset LatexCommand \ref{sec:magic}
4864 4864
4865 4865 \end_inset
4866 4866
4867 4867 for more details on the macro system.
4868 4868 \layout Standard
4869 4869
4870 4870 A history function
4871 4871 \family typewriter
4872 4872 %hist
4873 4873 \family default
4874 4874 allows you to see any part of your input history by printing a range of
4875 4875 the
4876 4876 \family typewriter
4877 4877 _i
4878 4878 \family default
4879 4879 variables.
4880 4880 \layout Subsection
4881 4881
4882 4882
4883 4883 \begin_inset LatexCommand \label{sec:cache_output}
4884 4884
4885 4885 \end_inset
4886 4886
4887 4887 Output caching system
4888 4888 \layout Standard
4889 4889
4890 4890 For output that is returned from actions, a system similar to the input
4891 4891 cache exists but using
4892 4892 \family typewriter
4893 4893 _
4894 4894 \family default
4895 4895 instead of
4896 4896 \family typewriter
4897 4897 _i
4898 4898 \family default
4899 4899 .
4900 4900 Only actions that produce a result (NOT assignments, for example) are cached.
4901 4901 If you are familiar with Mathematica, IPython's
4902 4902 \family typewriter
4903 4903 _
4904 4904 \family default
4905 4905 variables behave exactly like Mathematica's
4906 4906 \family typewriter
4907 4907 %
4908 4908 \family default
4909 4909 variables.
4910 4910 \layout Standard
4911 4911
4912 4912 The following GLOBAL variables always exist (so don't overwrite them!):
4913 4913
4914 4914 \layout List
4915 4915 \labelwidthstring 00.00.0000
4916 4916
4917 4917
4918 4918 \family typewriter
4919 4919 \series bold
4920 4920 _
4921 4921 \family default
4922 4922 \series default
4923 4923 (a
4924 4924 \emph on
4925 4925 single
4926 4926 \emph default
4927 4927 underscore) : stores previous output, like Python's default interpreter.
4928 4928 \layout List
4929 4929 \labelwidthstring 00.00.0000
4930 4930
4931 4931
4932 4932 \family typewriter
4933 4933 \series bold
4934 4934 __
4935 4935 \family default
4936 4936 \series default
4937 4937 (two underscores): next previous.
4938 4938 \layout List
4939 4939 \labelwidthstring 00.00.0000
4940 4940
4941 4941
4942 4942 \family typewriter
4943 4943 \series bold
4944 4944 ___
4945 4945 \family default
4946 4946 \series default
4947 4947 (three underscores): next-next previous.
4948 4948 \layout Standard
4949 4949
4950 4950 Additionally, global variables named
4951 4951 \family typewriter
4952 4952 _<n>
4953 4953 \family default
4954 4954 are dynamically created (
4955 4955 \family typewriter
4956 4956 <n>
4957 4957 \family default
4958 4958 being the prompt counter), such that the result of output
4959 4959 \family typewriter
4960 4960 <n>
4961 4961 \family default
4962 4962 is always available as
4963 4963 \family typewriter
4964 4964 _<n>
4965 4965 \family default
4966 4966 (don't use the angle brackets, just the number, e.g.
4967 4967
4968 4968 \family typewriter
4969 4969 _21
4970 4970 \family default
4971 4971 ).
4972 4972 \layout Standard
4973 4973
4974 4974 These global variables are all stored in a global dictionary (not a list,
4975 4975 since it only has entries for lines which returned a result) available
4976 4976 under the names
4977 4977 \family typewriter
4978 4978 _oh
4979 4979 \family default
4980 4980 and
4981 4981 \family typewriter
4982 4982 Out
4983 4983 \family default
4984 4984 (similar to
4985 4985 \family typewriter
4986 4986 _ih
4987 4987 \family default
4988 4988 and
4989 4989 \family typewriter
4990 4990 In
4991 4991 \family default
4992 4992 ).
4993 4993 So the output from line 12 can be obtained as
4994 4994 \family typewriter
4995 4995 _12
4996 4996 \family default
4997 4997 ,
4998 4998 \family typewriter
4999 4999 Out[12]
5000 5000 \family default
5001 5001 or
5002 5002 \family typewriter
5003 5003 _oh[12]
5004 5004 \family default
5005 5005 .
5006 5006 If you accidentally overwrite the
5007 5007 \family typewriter
5008 5008 Out
5009 5009 \family default
5010 5010 variable you can recover it by typing
5011 5011 \family typewriter
5012 5012 'Out=_oh
5013 5013 \family default
5014 5014 ' at the prompt.
5015 5015 \layout Standard
5016 5016
5017 5017 This system obviously can potentially put heavy memory demands on your system,
5018 5018 since it prevents Python's garbage collector from removing any previously
5019 5019 computed results.
5020 5020 You can control how many results are kept in memory with the option (at
5021 5021 the command line or in your
5022 5022 \family typewriter
5023 5023 ipythonrc
5024 5024 \family default
5025 5025 file)
5026 5026 \family typewriter
5027 5027 cache_size
5028 5028 \family default
5029 5029 .
5030 5030 If you set it to 0, the whole system is completely disabled and the prompts
5031 5031 revert to the classic
5032 5032 \family typewriter
5033 5033 '>>>'
5034 5034 \family default
5035 5035 of normal Python.
5036 5036 \layout Subsection
5037 5037
5038 5038 Directory history
5039 5039 \layout Standard
5040 5040
5041 5041 Your history of visited directories is kept in the global list
5042 5042 \family typewriter
5043 5043 _dh
5044 5044 \family default
5045 5045 , and the magic
5046 5046 \family typewriter
5047 5047 %cd
5048 5048 \family default
5049 5049 command can be used to go to any entry in that list.
5050 5050 The
5051 5051 \family typewriter
5052 5052 %dhist
5053 5053 \family default
5054 5054 command allows you to view this history.
5055 5055 \layout Subsection
5056 5056
5057 5057 Automatic parentheses and quotes
5058 5058 \layout Standard
5059 5059
5060 5060 These features were adapted from Nathan Gray's LazyPython.
5061 5061 They are meant to allow less typing for common situations.
5062 5062 \layout Subsubsection
5063 5063
5064 5064 Automatic parentheses
5065 5065 \layout Standard
5066 5066
5067 5067 Callable objects (i.e.
5068 5068 functions, methods, etc) can be invoked like this (notice the commas between
5069 5069 the arguments):
5070 5070 \layout Standard
5071 5071
5072 5072
5073 5073 \family typewriter
5074 5074 >>> callable_ob arg1, arg2, arg3
5075 5075 \layout Standard
5076 5076
5077 5077 and the input will be translated to this:
5078 5078 \layout Standard
5079 5079
5080 5080
5081 5081 \family typewriter
5082 5082 --> callable_ob(arg1, arg2, arg3)
5083 5083 \layout Standard
5084 5084
5085 5085 You can force automatic parentheses by using '/' as the first character
5086 5086 of a line.
5087 5087 For example:
5088 5088 \layout Standard
5089 5089
5090 5090
5091 5091 \family typewriter
5092 5092 >>> /globals # becomes 'globals()'
5093 5093 \layout Standard
5094 5094
5095 5095 Note that the '/' MUST be the first character on the line! This won't work:
5096 5096
5097 5097 \layout Standard
5098 5098
5099 5099
5100 5100 \family typewriter
5101 5101 >>> print /globals # syntax error
5102 5102 \layout Standard
5103 5103
5104 5104 In most cases the automatic algorithm should work, so you should rarely
5105 5105 need to explicitly invoke /.
5106 5106 One notable exception is if you are trying to call a function with a list
5107 5107 of tuples as arguments (the parenthesis will confuse IPython):
5108 5108 \layout Standard
5109 5109
5110 5110
5111 5111 \family typewriter
5112 5112 In [1]: zip (1,2,3),(4,5,6) # won't work
5113 5113 \layout Standard
5114 5114
5115 5115 but this will work:
5116 5116 \layout Standard
5117 5117
5118 5118
5119 5119 \family typewriter
5120 5120 In [2]: /zip (1,2,3),(4,5,6)
5121 5121 \newline
5122 5122 ------> zip ((1,2,3),(4,5,6))
5123 5123 \newline
5124 5124 Out[2]= [(1, 4), (2, 5), (3, 6)]
5125 5125 \layout Standard
5126 5126
5127 5127 IPython tells you that it has altered your command line by displaying the
5128 5128 new command line preceded by
5129 5129 \family typewriter
5130 5130 -->
5131 5131 \family default
5132 5132 .
5133 5133 e.g.:
5134 5134 \layout Standard
5135 5135
5136 5136
5137 5137 \family typewriter
5138 5138 In [18]: callable list
5139 5139 \newline
5140 5140 -------> callable (list)
5141 5141 \layout Subsubsection
5142 5142
5143 5143 Automatic quoting
5144 5144 \layout Standard
5145 5145
5146 5146 You can force automatic quoting of a function's arguments by using
5147 5147 \family typewriter
5148 5148 `,'
5149 5149 \family default
5150 5150 or
5151 5151 \family typewriter
5152 5152 `;'
5153 5153 \family default
5154 5154 as the first character of a line.
5155 5155 For example:
5156 5156 \layout Standard
5157 5157
5158 5158
5159 5159 \family typewriter
5160 5160 >>> ,my_function /home/me # becomes my_function("/home/me")
5161 5161 \layout Standard
5162 5162
5163 5163 If you use
5164 5164 \family typewriter
5165 5165 `;'
5166 5166 \family default
5167 5167 instead, the whole argument is quoted as a single string (while
5168 5168 \family typewriter
5169 5169 `,'
5170 5170 \family default
5171 5171 splits on whitespace):
5172 5172 \layout Standard
5173 5173
5174 5174
5175 5175 \family typewriter
5176 5176 >>> ,my_function a b c # becomes my_function("a","b","c")
5177 5177 \layout Standard
5178 5178
5179 5179
5180 5180 \family typewriter
5181 5181 >>> ;my_function a b c # becomes my_function("a b c")
5182 5182 \layout Standard
5183 5183
5184 5184 Note that the `
5185 5185 \family typewriter
5186 5186 ,
5187 5187 \family default
5188 5188 ' or `
5189 5189 \family typewriter
5190 5190 ;
5191 5191 \family default
5192 5192 ' MUST be the first character on the line! This won't work:
5193 5193 \layout Standard
5194 5194
5195 5195
5196 5196 \family typewriter
5197 5197 >>> x = ,my_function /home/me # syntax error
5198 5198 \layout Section
5199 5199
5200 5200
5201 5201 \begin_inset LatexCommand \label{sec:customization}
5202 5202
5203 5203 \end_inset
5204 5204
5205 5205 Customization
5206 5206 \layout Standard
5207 5207
5208 5208 As we've already mentioned, IPython reads a configuration file which can
5209 5209 be specified at the command line (
5210 5210 \family typewriter
5211 5211 -rcfile
5212 5212 \family default
5213 5213 ) or which by default is assumed to be called
5214 5214 \family typewriter
5215 5215 ipythonrc
5216 5216 \family default
5217 5217 .
5218 5218 Such a file is looked for in the current directory where IPython is started
5219 5219 and then in your
5220 5220 \family typewriter
5221 5221 IPYTHONDIR
5222 5222 \family default
5223 5223 , which allows you to have local configuration files for specific projects.
5224 5224 In this section we will call these types of configuration files simply
5225 5225 rcfiles (short for resource configuration file).
5226 5226 \layout Standard
5227 5227
5228 5228 The syntax of an rcfile is one of key-value pairs separated by whitespace,
5229 5229 one per line.
5230 5230 Lines beginning with a
5231 5231 \family typewriter
5232 5232 #
5233 5233 \family default
5234 5234 are ignored as comments, but comments can
5235 5235 \series bold
5236 5236 not
5237 5237 \series default
5238 5238 be put on lines with data (the parser is fairly primitive).
5239 5239 Note that these are not python files, and this is deliberate, because it
5240 5240 allows us to do some things which would be quite tricky to implement if
5241 5241 they were normal python files.
5242 5242 \layout Standard
5243 5243
5244 5244 First, an rcfile can contain permanent default values for almost all command
5245 5245 line options (except things like
5246 5246 \family typewriter
5247 5247 -help
5248 5248 \family default
5249 5249 or
5250 5250 \family typewriter
5251 5251 -Version
5252 5252 \family default
5253 5253 ).
5254 5254 Sec\SpecialChar ~
5255 5255
5256 5256 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5257 5257
5258 5258 \end_inset
5259 5259
5260 5260 contains a description of all command-line options.
5261 5261 However, values you explicitly specify at the command line override the
5262 5262 values defined in the rcfile.
5263 5263 \layout Standard
5264 5264
5265 5265 Besides command line option values, the rcfile can specify values for certain
5266 5266 extra special options which are not available at the command line.
5267 5267 These options are briefly described below.
5268 5268
5269 5269 \layout Standard
5270 5270
5271 5271 Each of these options may appear as many times as you need it in the file.
5272 5272 \layout List
5273 5273 \labelwidthstring 00.00.0000
5274 5274
5275 5275
5276 5276 \family typewriter
5277 5277 \series bold
5278 5278 include\SpecialChar ~
5279 5279 <file1>\SpecialChar ~
5280 5280 <file2>\SpecialChar ~
5281 5281 ...
5282 5282 \family default
5283 5283 \series default
5284 5284 : you can name
5285 5285 \emph on
5286 5286 other
5287 5287 \emph default
5288 5288 rcfiles you want to recursively load up to 15 levels (don't use the
5289 5289 \family typewriter
5290 5290 <>
5291 5291 \family default
5292 5292 brackets in your names!).
5293 5293 This feature allows you to define a 'base' rcfile with general options
5294 5294 and special-purpose files which can be loaded only when needed with particular
5295 5295 configuration options.
5296 5296 To make this more convenient, IPython accepts the
5297 5297 \family typewriter
5298 5298 -profile <name>
5299 5299 \family default
5300 5300 option (abbreviates to
5301 5301 \family typewriter
5302 5302 -p <name
5303 5303 \family default
5304 5304 >)
5305 5305 \family typewriter
5306 5306 which
5307 5307 \family default
5308 5308 tells it to look for an rcfile named
5309 5309 \family typewriter
5310 5310 ipythonrc-<name>
5311 5311 \family default
5312 5312 .
5313 5313
5314 5314 \layout List
5315 5315 \labelwidthstring 00.00.0000
5316 5316
5317 5317
5318 5318 \family typewriter
5319 5319 \series bold
5320 5320 import_mod\SpecialChar ~
5321 5321 <mod1>\SpecialChar ~
5322 5322 <mod2>\SpecialChar ~
5323 5323 ...
5324 5324 \family default
5325 5325 \series default
5326 5326 : import modules with '
5327 5327 \family typewriter
5328 5328 import
5329 5329 \family default
5330 5330
5331 5331 \family typewriter
5332 5332 <mod1>,<mod2>,...
5333 5333 \family default
5334 5334 '
5335 5335 \layout List
5336 5336 \labelwidthstring 00.00.0000
5337 5337
5338 5338
5339 5339 \family typewriter
5340 5340 \series bold
5341 5341 import_some\SpecialChar ~
5342 5342 <mod>\SpecialChar ~
5343 5343 <f1>\SpecialChar ~
5344 5344 <f2>\SpecialChar ~
5345 5345 ...
5346 5346 \family default
5347 5347 \series default
5348 5348 : import functions with '
5349 5349 \family typewriter
5350 5350 from <mod> import
5351 5351 \family default
5352 5352
5353 5353 \family typewriter
5354 5354 <f1>,<f2>,...
5355 5355 \family default
5356 5356 '
5357 5357 \layout List
5358 5358 \labelwidthstring 00.00.0000
5359 5359
5360 5360
5361 5361 \family typewriter
5362 5362 \series bold
5363 5363 import_all\SpecialChar ~
5364 5364 <mod1>\SpecialChar ~
5365 5365 <mod2>\SpecialChar ~
5366 5366 ...
5367 5367 \family default
5368 5368 \series default
5369 5369 : for each module listed import functions with '
5370 5370 \family typewriter
5371 5371 from <mod> import *
5372 5372 \family default
5373 5373 '
5374 5374 \layout List
5375 5375 \labelwidthstring 00.00.0000
5376 5376
5377 5377
5378 5378 \family typewriter
5379 5379 \series bold
5380 5380 execute\SpecialChar ~
5381 5381 <python\SpecialChar ~
5382 5382 code>
5383 5383 \family default
5384 5384 \series default
5385 5385 : give any single-line python code to be executed.
5386 5386 \layout List
5387 5387 \labelwidthstring 00.00.0000
5388 5388
5389 5389
5390 5390 \family typewriter
5391 5391 \series bold
5392 5392 execfile\SpecialChar ~
5393 5393 <filename>
5394 5394 \family default
5395 5395 \series default
5396 5396 : execute the python file given with an '
5397 5397 \family typewriter
5398 5398 execfile(filename)
5399 5399 \family default
5400 5400 ' command.
5401 5401 Username expansion is performed on the given names.
5402 5402 So if you need any amount of extra fancy customization that won't fit in
5403 5403 any of the above 'canned' options, you can just put it in a separate python
5404 5404 file and execute it.
5405 5405 \layout List
5406 5406 \labelwidthstring 00.00.0000
5407 5407
5408 5408
5409 5409 \family typewriter
5410 5410 \series bold
5411 5411 alias\SpecialChar ~
5412 5412 <alias_def>
5413 5413 \family default
5414 5414 \series default
5415 5415 : this is equivalent to calling '
5416 5416 \family typewriter
5417 5417 %alias\SpecialChar ~
5418 5418 <alias_def>
5419 5419 \family default
5420 5420 ' at the IPython command line.
5421 5421 This way, from within IPython you can do common system tasks without having
5422 5422 to exit it or use the
5423 5423 \family typewriter
5424 5424 !
5425 5425 \family default
5426 5426 escape.
5427 5427 IPython isn't meant to be a shell replacement, but it is often very useful
5428 5428 to be able to do things with files while testing code.
5429 5429 This gives you the flexibility to have within IPython any aliases you may
5430 5430 be used to under your normal system shell.
5431 5431 \layout Subsection
5432 5432
5433 5433
5434 5434 \begin_inset LatexCommand \label{sec:ipytonrc-sample}
5435 5435
5436 5436 \end_inset
5437 5437
5438 5438 Sample
5439 5439 \family typewriter
5440 5440 ipythonrc
5441 5441 \family default
5442 5442 file
5443 5443 \layout Standard
5444 5444
5445 5445 The default rcfile, called
5446 5446 \family typewriter
5447 5447 ipythonrc
5448 5448 \family default
5449 5449 and supplied in your
5450 5450 \family typewriter
5451 5451 IPYTHONDIR
5452 5452 \family default
5453 5453 directory contains lots of comments on all of these options.
5454 5454 We reproduce it here for reference:
5455 5455 \layout Standard
5456 5456
5457 5457
5458 5458 \begin_inset ERT
5459 5459 status Open
5460 5460
5461 5461 \layout Standard
5462 5462
5463 5463 \backslash
5464 5464 codelist{../IPython/UserConfig/ipythonrc}
5465 5465 \end_inset
5466 5466
5467 5467
5468 5468 \layout Subsection
5469 5469
5470 5470
5471 5471 \begin_inset LatexCommand \label{sec:prompts}
5472 5472
5473 5473 \end_inset
5474 5474
5475 5475 Fine-tuning your prompt
5476 5476 \layout Standard
5477 5477
5478 5478 IPython's prompts can be customized using a syntax similar to that of the
5479 5479
5480 5480 \family typewriter
5481 5481 bash
5482 5482 \family default
5483 5483 shell.
5484 5484 Many of
5485 5485 \family typewriter
5486 5486 bash
5487 5487 \family default
5488 5488 's escapes are supported, as well as a few additional ones.
5489 5489 We list them below:
5490 5490 \layout Description
5491 5491
5492 5492
5493 5493 \backslash
5494 5494 # the prompt/history count number
5495 5495 \layout Description
5496 5496
5497 5497
5498 5498 \backslash
5499 5499 D the prompt/history count, with the actual digits replaced by dots.
5500 5500 Used mainly in continuation prompts (prompt_in2)
5501 5501 \layout Description
5502 5502
5503 5503
5504 5504 \backslash
5505 5505 w the current working directory
5506 5506 \layout Description
5507 5507
5508 5508
5509 5509 \backslash
5510 5510 W the basename of current working directory
5511 5511 \layout Description
5512 5512
5513 5513
5514 5514 \backslash
5515 5515 X
5516 5516 \emph on
5517 5517 n
5518 5518 \emph default
5519 5519 where
5520 5520 \begin_inset Formula $n=0\ldots5.$
5521 5521 \end_inset
5522 5522
5523 5523 The current working directory, with
5524 5524 \family typewriter
5525 5525 $HOME
5526 5526 \family default
5527 5527 replaced by
5528 5528 \family typewriter
5529 5529 ~
5530 5530 \family default
5531 5531 , and filtered out to contain only
5532 5532 \begin_inset Formula $n$
5533 5533 \end_inset
5534 5534
5535 5535 path elements
5536 5536 \layout Description
5537 5537
5538 5538
5539 5539 \backslash
5540 5540 Y
5541 5541 \emph on
5542 5542 n
5543 5543 \emph default
5544 5544 Similar to
5545 5545 \backslash
5546 5546 X
5547 5547 \emph on
5548 5548 n
5549 5549 \emph default
5550 5550 , but with the
5551 5551 \begin_inset Formula $n+1$
5552 5552 \end_inset
5553 5553
5554 5554 element included if it is
5555 5555 \family typewriter
5556 5556 ~
5557 5557 \family default
5558 5558 (this is similar to the behavior of the %c
5559 5559 \emph on
5560 5560 n
5561 5561 \emph default
5562 5562 escapes in
5563 5563 \family typewriter
5564 5564 tcsh
5565 5565 \family default
5566 5566 )
5567 5567 \layout Description
5568 5568
5569 5569
5570 5570 \backslash
5571 5571 u the username of the current user
5572 5572 \layout Description
5573 5573
5574 5574
5575 5575 \backslash
5576 5576 $ if the effective UID is 0, a #, otherwise a $
5577 5577 \layout Description
5578 5578
5579 5579
5580 5580 \backslash
5581 5581 h the hostname up to the first `.'
5582 5582 \layout Description
5583 5583
5584 5584
5585 5585 \backslash
5586 5586 H the hostname
5587 5587 \layout Description
5588 5588
5589 5589
5590 5590 \backslash
5591 5591 n a newline
5592 5592 \layout Description
5593 5593
5594 5594
5595 5595 \backslash
5596 5596 r a carriage return
5597 5597 \layout Description
5598 5598
5599 5599
5600 5600 \backslash
5601 5601 v IPython version string
5602 5602 \layout Standard
5603 5603
5604 5604 In addition to these, ANSI color escapes can be insterted into the prompts,
5605 5605 as
5606 5606 \family typewriter
5607 5607
5608 5608 \backslash
5609 5609 C_
5610 5610 \emph on
5611 5611 ColorName
5612 5612 \family default
5613 5613 \emph default
5614 5614 .
5615 5615 The list of valid color names is: Black, Blue, Brown, Cyan, DarkGray, Green,
5616 5616 LightBlue, LightCyan, LightGray, LightGreen, LightPurple, LightRed, NoColor,
5617 5617 Normal, Purple, Red, White, Yellow.
5618 5618 \layout Standard
5619 5619
5620 5620 Finally, IPython supports the evaluation of arbitrary expressions in your
5621 5621 prompt string.
5622 5622 The prompt strings are evaluated through the syntax of PEP 215, but basically
5623 5623 you can use
5624 5624 \family typewriter
5625 5625 $x.y
5626 5626 \family default
5627 5627 to expand the value of
5628 5628 \family typewriter
5629 5629 x.y
5630 5630 \family default
5631 5631 , and for more complicated expressions you can use braces:
5632 5632 \family typewriter
5633 5633 ${foo()+x}
5634 5634 \family default
5635 5635 will call function
5636 5636 \family typewriter
5637 5637 foo
5638 5638 \family default
5639 5639 and add to it the value of
5640 5640 \family typewriter
5641 5641 x
5642 5642 \family default
5643 5643 , before putting the result into your prompt.
5644 5644 For example, using
5645 5645 \newline
5646 5646
5647 5647 \family typewriter
5648 5648 prompt_in1 '${commands.getoutput("uptime")}
5649 5649 \backslash
5650 5650 nIn [
5651 5651 \backslash
5652 5652 #]: '
5653 5653 \newline
5654 5654
5655 5655 \family default
5656 5656 will print the result of the uptime command on each prompt (assuming the
5657 5657
5658 5658 \family typewriter
5659 5659 commands
5660 5660 \family default
5661 5661 module has been imported in your
5662 5662 \family typewriter
5663 5663 ipythonrc
5664 5664 \family default
5665 5665 file).
5666 5666 \layout Subsubsection
5667 5667
5668 5668 Prompt examples
5669 5669 \layout Standard
5670 5670
5671 5671 The following options in an ipythonrc file will give you IPython's default
5672 5672 prompts:
5673 5673 \layout Standard
5674 5674
5675 5675
5676 5676 \family typewriter
5677 5677 prompt_in1 'In [
5678 5678 \backslash
5679 5679 #]:'
5680 5680 \newline
5681 5681 prompt_in2 '\SpecialChar ~
5682 5682 \SpecialChar ~
5683 5683 \SpecialChar ~
5684 5684 .
5685 5685 \backslash
5686 5686 D.:'
5687 5687 \newline
5688 5688 prompt_out 'Out[
5689 5689 \backslash
5690 5690 #]:'
5691 5691 \layout Standard
5692 5692
5693 5693 which look like this:
5694 5694 \layout Standard
5695 5695
5696 5696
5697 5697 \family typewriter
5698 5698 In [1]: 1+2
5699 5699 \newline
5700 5700 Out[1]: 3
5701 5701 \layout Standard
5702 5702
5703 5703
5704 5704 \family typewriter
5705 5705 In [2]: for i in (1,2,3):
5706 5706 \newline
5707 5707
5708 5708 \begin_inset ERT
5709 5709 status Collapsed
5710 5710
5711 5711 \layout Standard
5712 5712
5713 5713 \backslash
5714 5714 hspace*{0mm}
5715 5715 \end_inset
5716 5716
5717 5717 \SpecialChar ~
5718 5718 \SpecialChar ~
5719 5719 \SpecialChar ~
5720 5720 ...: \SpecialChar ~
5721 5721 \SpecialChar ~
5722 5722 \SpecialChar ~
5723 5723 \SpecialChar ~
5724 5724 print i,
5725 5725 \newline
5726 5726
5727 5727 \begin_inset ERT
5728 5728 status Collapsed
5729 5729
5730 5730 \layout Standard
5731 5731
5732 5732 \backslash
5733 5733 hspace*{0mm}
5734 5734 \end_inset
5735 5735
5736 5736 \SpecialChar ~
5737 5737 \SpecialChar ~
5738 5738 \SpecialChar ~
5739 5739 ...:
5740 5740 \newline
5741 5741 1 2 3
5742 5742 \layout Standard
5743 5743
5744 5744 These will give you a very colorful prompt with path information:
5745 5745 \layout Standard
5746 5746
5747 5747
5748 5748 \family typewriter
5749 5749 #prompt_in1 '
5750 5750 \backslash
5751 5751 C_Red
5752 5752 \backslash
5753 5753 u
5754 5754 \backslash
5755 5755 C_Blue[
5756 5756 \backslash
5757 5757 C_Cyan
5758 5758 \backslash
5759 5759 Y1
5760 5760 \backslash
5761 5761 C_Blue]
5762 5762 \backslash
5763 5763 C_LightGreen
5764 5764 \backslash
5765 5765 #>'
5766 5766 \newline
5767 5767 prompt_in2 ' ..
5768 5768 \backslash
5769 5769 D>'
5770 5770 \newline
5771 5771 prompt_out '<
5772 5772 \backslash
5773 5773 #>'
5774 5774 \layout Standard
5775 5775
5776 5776 which look like this:
5777 5777 \layout Standard
5778 5778
5779 5779
5780 5780 \family typewriter
5781 5781 \color red
5782 5782 fperez
5783 5783 \color blue
5784 5784 [
5785 5785 \color cyan
5786 5786 ~/ipython
5787 5787 \color blue
5788 5788 ]
5789 5789 \color green
5790 5790 1>
5791 5791 \color default
5792 5792 1+2
5793 5793 \newline
5794 5794
5795 5795 \begin_inset ERT
5796 5796 status Collapsed
5797 5797
5798 5798 \layout Standard
5799 5799
5800 5800 \backslash
5801 5801 hspace*{0mm}
5802 5802 \end_inset
5803 5803
5804 5804 \SpecialChar ~
5805 5805 \SpecialChar ~
5806 5806 \SpecialChar ~
5807 5807 \SpecialChar ~
5808 5808 \SpecialChar ~
5809 5809 \SpecialChar ~
5810 5810 \SpecialChar ~
5811 5811 \SpecialChar ~
5812 5812 \SpecialChar ~
5813 5813 \SpecialChar ~
5814 5814 \SpecialChar ~
5815 5815 \SpecialChar ~
5816 5816 \SpecialChar ~
5817 5817 \SpecialChar ~
5818 5818 \SpecialChar ~
5819 5819 \SpecialChar ~
5820 5820
5821 5821 \color red
5822 5822 <1>
5823 5823 \color default
5824 5824 3
5825 5825 \newline
5826 5826
5827 5827 \color red
5828 5828 fperez
5829 5829 \color blue
5830 5830 [
5831 5831 \color cyan
5832 5832 ~/ipython
5833 5833 \color blue
5834 5834 ]
5835 5835 \color green
5836 5836 2>
5837 5837 \color default
5838 5838 for i in (1,2,3):
5839 5839 \newline
5840 5840
5841 5841 \begin_inset ERT
5842 5842 status Collapsed
5843 5843
5844 5844 \layout Standard
5845 5845
5846 5846 \backslash
5847 5847 hspace*{0mm}
5848 5848 \end_inset
5849 5849
5850 5850 \SpecialChar ~
5851 5851 \SpecialChar ~
5852 5852 \SpecialChar ~
5853 5853 \SpecialChar ~
5854 5854 \SpecialChar ~
5855 5855 \SpecialChar ~
5856 5856 \SpecialChar ~
5857 5857 \SpecialChar ~
5858 5858 \SpecialChar ~
5859 5859 \SpecialChar ~
5860 5860 \SpecialChar ~
5861 5861 \SpecialChar ~
5862 5862 \SpecialChar ~
5863 5863 \SpecialChar ~
5864 5864 \SpecialChar ~
5865 5865
5866 5866 \color green
5867 5867 ...>
5868 5868 \color default
5869 5869 \SpecialChar ~
5870 5870 \SpecialChar ~
5871 5871 \SpecialChar ~
5872 5872 \SpecialChar ~
5873 5873 print i,
5874 5874 \newline
5875 5875
5876 5876 \begin_inset ERT
5877 5877 status Collapsed
5878 5878
5879 5879 \layout Standard
5880 5880
5881 5881 \backslash
5882 5882 hspace*{0mm}
5883 5883 \end_inset
5884 5884
5885 5885 \SpecialChar ~
5886 5886 \SpecialChar ~
5887 5887 \SpecialChar ~
5888 5888 \SpecialChar ~
5889 5889 \SpecialChar ~
5890 5890 \SpecialChar ~
5891 5891 \SpecialChar ~
5892 5892 \SpecialChar ~
5893 5893 \SpecialChar ~
5894 5894 \SpecialChar ~
5895 5895 \SpecialChar ~
5896 5896 \SpecialChar ~
5897 5897 \SpecialChar ~
5898 5898 \SpecialChar ~
5899 5899 \SpecialChar ~
5900 5900
5901 5901 \color green
5902 5902 ...>
5903 5903 \color default
5904 5904
5905 5905 \newline
5906 5906 1 2 3
5907 5907 \layout Standard
5908 5908
5909 5909 The following shows the usage of dynamic expression evaluation:
5910 5910 \layout Subsection
5911 5911
5912 5912
5913 5913 \begin_inset LatexCommand \label{sec:profiles}
5914 5914
5915 5915 \end_inset
5916 5916
5917 5917 IPython profiles
5918 5918 \layout Standard
5919 5919
5920 5920 As we already mentioned, IPython supports the
5921 5921 \family typewriter
5922 5922 -profile
5923 5923 \family default
5924 5924 command-line option (see sec.
5925 5925
5926 5926 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
5927 5927
5928 5928 \end_inset
5929 5929
5930 5930 ).
5931 5931 A profile is nothing more than a particular configuration file like your
5932 5932 basic
5933 5933 \family typewriter
5934 5934 ipythonrc
5935 5935 \family default
5936 5936 one, but with particular customizations for a specific purpose.
5937 5937 When you start IPython with '
5938 5938 \family typewriter
5939 5939 ipython -profile <name>
5940 5940 \family default
5941 5941 ', it assumes that in your
5942 5942 \family typewriter
5943 5943 IPYTHONDIR
5944 5944 \family default
5945 5945 there is a file called
5946 5946 \family typewriter
5947 5947 ipythonrc-<name>
5948 5948 \family default
5949 5949 , and loads it instead of the normal
5950 5950 \family typewriter
5951 5951 ipythonrc
5952 5952 \family default
5953 5953 .
5954 5954 \layout Standard
5955 5955
5956 5956 This system allows you to maintain multiple configurations which load modules,
5957 5957 set options, define functions, etc.
5958 5958 suitable for different tasks and activate them in a very simple manner.
5959 5959 In order to avoid having to repeat all of your basic options (common things
5960 5960 that don't change such as your color preferences, for example), any profile
5961 5961 can include another configuration file.
5962 5962 The most common way to use profiles is then to have each one include your
5963 5963 basic
5964 5964 \family typewriter
5965 5965 ipythonrc
5966 5966 \family default
5967 5967 file as a starting point, and then add further customizations.
5968 5968 \layout Standard
5969 5969
5970 5970 In sections
5971 5971 \begin_inset LatexCommand \ref{sec:syntax-extensions}
5972 5972
5973 5973 \end_inset
5974 5974
5975 5975 and
5976 5976 \begin_inset LatexCommand \ref{sec:Gnuplot}
5977 5977
5978 5978 \end_inset
5979 5979
5980 5980 we discuss some particular profiles which come as part of the standard
5981 5981 IPython distribution.
5982 5982 You may also look in your
5983 5983 \family typewriter
5984 5984 IPYTHONDIR
5985 5985 \family default
5986 5986 directory, any file whose name begins with
5987 5987 \family typewriter
5988 5988 ipythonrc-
5989 5989 \family default
5990 5990 is a profile.
5991 5991 You can use those as examples for further customizations to suit your own
5992 5992 needs.
5993 5993 \layout Section
5994 5994
5995 5995
5996 5996 \begin_inset OptArg
5997 5997 collapsed false
5998 5998
5999 5999 \layout Standard
6000 6000
6001 6001 IPython as default...
6002 6002 \end_inset
6003 6003
6004 6004 IPython as your default Python environment
6005 6005 \layout Standard
6006 6006
6007 6007 Python honors the environment variable
6008 6008 \family typewriter
6009 6009 PYTHONSTARTUP
6010 6010 \family default
6011 6011 and will execute at startup the file referenced by this variable.
6012 6012 If you put at the end of this file the following two lines of code:
6013 6013 \layout Standard
6014 6014
6015 6015
6016 6016 \family typewriter
6017 6017 import IPython
6018 6018 \newline
6019 6019 IPython.Shell.IPShell().mainloop(sys_exit=1)
6020 6020 \layout Standard
6021 6021
6022 6022 then IPython will be your working environment anytime you start Python.
6023 6023 The
6024 6024 \family typewriter
6025 6025 sys_exit=1
6026 6026 \family default
6027 6027 is needed to have IPython issue a call to
6028 6028 \family typewriter
6029 6029 sys.exit()
6030 6030 \family default
6031 6031 when it finishes, otherwise you'll be back at the normal Python '
6032 6032 \family typewriter
6033 6033 >>>
6034 6034 \family default
6035 6035 ' prompt
6036 6036 \begin_inset Foot
6037 6037 collapsed true
6038 6038
6039 6039 \layout Standard
6040 6040
6041 6041 Based on an idea by Holger Krekel.
6042 6042 \end_inset
6043 6043
6044 6044 .
6045 6045 \layout Standard
6046 6046
6047 6047 This is probably useful to developers who manage multiple Python versions
6048 6048 and don't want to have correspondingly multiple IPython versions.
6049 6049 Note that in this mode, there is no way to pass IPython any command-line
6050 6050 options, as those are trapped first by Python itself.
6051 6051 \layout Section
6052 6052
6053 6053
6054 6054 \begin_inset LatexCommand \label{sec:embed}
6055 6055
6056 6056 \end_inset
6057 6057
6058 6058 Embedding IPython
6059 6059 \layout Standard
6060 6060
6061 6061 It is possible to start an IPython instance
6062 6062 \emph on
6063 6063 inside
6064 6064 \emph default
6065 6065 your own Python programs.
6066 6066 This allows you to evaluate dynamically the state of your code, operate
6067 6067 with your variables, analyze them, etc.
6068 6068 Note however that any changes you make to values while in the shell do
6069 6069
6070 6070 \emph on
6071 6071 not
6072 6072 \emph default
6073 6073 propagate back to the running code, so it is safe to modify your values
6074 6074 because you won't break your code in bizarre ways by doing so.
6075 6075 \layout Standard
6076 6076
6077 6077 This feature allows you to easily have a fully functional python environment
6078 6078 for doing object introspection anywhere in your code with a simple function
6079 6079 call.
6080 6080 In some cases a simple print statement is enough, but if you need to do
6081 6081 more detailed analysis of a code fragment this feature can be very valuable.
6082 6082 \layout Standard
6083 6083
6084 6084 It can also be useful in scientific computing situations where it is common
6085 6085 to need to do some automatic, computationally intensive part and then stop
6086 6086 to look at data, plots, etc
6087 6087 \begin_inset Foot
6088 6088 collapsed true
6089 6089
6090 6090 \layout Standard
6091 6091
6092 6092 This functionality was inspired by IDL's combination of the
6093 6093 \family typewriter
6094 6094 stop
6095 6095 \family default
6096 6096 keyword and the
6097 6097 \family typewriter
6098 6098 .continue
6099 6099 \family default
6100 6100 executive command, which I have found very useful in the past, and by a
6101 6101 posting on comp.lang.python by cmkl <cmkleffner-AT-gmx.de> on Dec.
6102 6102 06/01 concerning similar uses of pyrepl.
6103 6103 \end_inset
6104 6104
6105 6105 .
6106 6106 Opening an IPython instance will give you full access to your data and
6107 6107 functions, and you can resume program execution once you are done with
6108 6108 the interactive part (perhaps to stop again later, as many times as needed).
6109 6109 \layout Standard
6110 6110
6111 6111 The following code snippet is the bare minimum you need to include in your
6112 6112 Python programs for this to work (detailed examples follow later):
6113 6113 \layout LyX-Code
6114 6114
6115 6115 from IPython.Shell import IPShellEmbed
6116 6116 \layout LyX-Code
6117 6117
6118 6118 ipshell = IPShellEmbed()
6119 6119 \layout LyX-Code
6120 6120
6121 6121 ipshell() # this call anywhere in your program will start IPython
6122 6122 \layout Standard
6123 6123
6124 6124 You can run embedded instances even in code which is itself being run at
6125 6125 the IPython interactive prompt with '
6126 6126 \family typewriter
6127 6127 %run\SpecialChar ~
6128 6128 <filename>
6129 6129 \family default
6130 6130 '.
6131 6131 Since it's easy to get lost as to where you are (in your top-level IPython
6132 6132 or in your embedded one), it's a good idea in such cases to set the in/out
6133 6133 prompts to something different for the embedded instances.
6134 6134 The code examples below illustrate this.
6135 6135 \layout Standard
6136 6136
6137 6137 You can also have multiple IPython instances in your program and open them
6138 6138 separately, for example with different options for data presentation.
6139 6139 If you close and open the same instance multiple times, its prompt counters
6140 6140 simply continue from each execution to the next.
6141 6141 \layout Standard
6142 6142
6143 6143 Please look at the docstrings in the
6144 6144 \family typewriter
6145 6145 Shell.py
6146 6146 \family default
6147 6147 module for more details on the use of this system.
6148 6148 \layout Standard
6149 6149
6150 6150 The following sample file illustrating how to use the embedding functionality
6151 6151 is provided in the examples directory as
6152 6152 \family typewriter
6153 6153 example-embed.py
6154 6154 \family default
6155 6155 .
6156 6156 It should be fairly self-explanatory:
6157 6157 \layout Standard
6158 6158
6159 6159
6160 6160 \begin_inset ERT
6161 6161 status Open
6162 6162
6163 6163 \layout Standard
6164 6164
6165 6165 \backslash
6166 6166 codelist{examples/example-embed.py}
6167 6167 \end_inset
6168 6168
6169 6169
6170 6170 \layout Standard
6171 6171
6172 6172 Once you understand how the system functions, you can use the following
6173 6173 code fragments in your programs which are ready for cut and paste:
6174 6174 \layout Standard
6175 6175
6176 6176
6177 6177 \begin_inset ERT
6178 6178 status Open
6179 6179
6180 6180 \layout Standard
6181 6181
6182 6182 \backslash
6183 6183 codelist{examples/example-embed-short.py}
6184 6184 \end_inset
6185 6185
6186 6186
6187 6187 \layout Section
6188 6188
6189 6189
6190 6190 \begin_inset LatexCommand \label{sec:using-pdb}
6191 6191
6192 6192 \end_inset
6193 6193
6194 6194 Using the Python debugger (
6195 6195 \family typewriter
6196 6196 pdb
6197 6197 \family default
6198 6198 )
6199 6199 \layout Subsection
6200 6200
6201 6201 Running entire programs via
6202 6202 \family typewriter
6203 6203 pdb
6204 6204 \layout Standard
6205 6205
6206 6206
6207 6207 \family typewriter
6208 6208 pdb
6209 6209 \family default
6210 6210 , the Python debugger, is a powerful interactive debugger which allows you
6211 6211 to step through code, set breakpoints, watch variables, etc.
6212 6212 IPython makes it very easy to start any script under the control of
6213 6213 \family typewriter
6214 6214 pdb
6215 6215 \family default
6216 6216 , regardless of whether you have wrapped it into a
6217 6217 \family typewriter
6218 6218 `main()'
6219 6219 \family default
6220 6220 function or not.
6221 6221 For this, simply type
6222 6222 \family typewriter
6223 6223 `%run -d myscript'
6224 6224 \family default
6225 6225 at an IPython prompt.
6226 6226 See the
6227 6227 \family typewriter
6228 6228 %run
6229 6229 \family default
6230 6230 command's documentation (via
6231 6231 \family typewriter
6232 6232 `%run?'
6233 6233 \family default
6234 6234 or in Sec.\SpecialChar ~
6235 6235
6236 6236 \begin_inset LatexCommand \ref{sec:magic}
6237 6237
6238 6238 \end_inset
6239 6239
6240 6240 ) for more details, including how to control where
6241 6241 \family typewriter
6242 6242 pdb
6243 6243 \family default
6244 6244 will stop execution first.
6245 6245 \layout Standard
6246 6246
6247 6247 For more information on the use of the
6248 6248 \family typewriter
6249 6249 pdb
6250 6250 \family default
6251 6251 debugger, read the included
6252 6252 \family typewriter
6253 6253 pdb.doc
6254 6254 \family default
6255 6255 file (part of the standard Python distribution).
6256 6256 On a stock Linux system it is located at
6257 6257 \family typewriter
6258 6258 /usr/lib/python2.3/pdb.doc
6259 6259 \family default
6260 6260 , but the easiest way to read it is by using the
6261 6261 \family typewriter
6262 6262 help()
6263 6263 \family default
6264 6264 function of the
6265 6265 \family typewriter
6266 6266 pdb
6267 6267 \family default
6268 6268 module as follows (in an IPython prompt):
6269 6269 \layout Standard
6270 6270
6271 6271
6272 6272 \family typewriter
6273 6273 In [1]: import pdb
6274 6274 \newline
6275 6275 In [2]: pdb.help()
6276 6276 \layout Standard
6277 6277
6278 6278 This will load the
6279 6279 \family typewriter
6280 6280 pdb.doc
6281 6281 \family default
6282 6282 document in a file viewer for you automatically.
6283 6283 \layout Subsection
6284 6284
6285 6285 Automatic invocation of
6286 6286 \family typewriter
6287 6287 pdb
6288 6288 \family default
6289 6289 on exceptions
6290 6290 \layout Standard
6291 6291
6292 6292 IPython, if started with the
6293 6293 \family typewriter
6294 6294 -pdb
6295 6295 \family default
6296 6296 option (or if the option is set in your rc file) can call the Python
6297 6297 \family typewriter
6298 6298 pdb
6299 6299 \family default
6300 6300 debugger every time your code triggers an uncaught exception
6301 6301 \begin_inset Foot
6302 6302 collapsed true
6303 6303
6304 6304 \layout Standard
6305 6305
6306 6306 Many thanks to Christopher Hart for the request which prompted adding this
6307 6307 feature to IPython.
6308 6308 \end_inset
6309 6309
6310 6310 .
6311 6311 This feature can also be toggled at any time with the
6312 6312 \family typewriter
6313 6313 %pdb
6314 6314 \family default
6315 6315 magic command.
6316 6316 This can be extremely useful in order to find the origin of subtle bugs,
6317 6317 because
6318 6318 \family typewriter
6319 6319 pdb
6320 6320 \family default
6321 6321 opens up at the point in your code which triggered the exception, and while
6322 6322 your program is at this point `dead', all the data is still available and
6323 6323 you can walk up and down the stack frame and understand the origin of the
6324 6324 problem.
6325 6325 \layout Standard
6326 6326
6327 6327 Furthermore, you can use these debugging facilities both with the embedded
6328 6328 IPython mode and without IPython at all.
6329 6329 For an embedded shell (see sec.
6330 6330
6331 6331 \begin_inset LatexCommand \ref{sec:embed}
6332 6332
6333 6333 \end_inset
6334 6334
6335 6335 ), simply call the constructor with
6336 6336 \family typewriter
6337 6337 `-pdb'
6338 6338 \family default
6339 6339 in the argument string and automatically
6340 6340 \family typewriter
6341 6341 pdb
6342 6342 \family default
6343 6343 will be called if an uncaught exception is triggered by your code.
6344 6344
6345 6345 \layout Standard
6346 6346
6347 6347 For stand-alone use of the feature in your programs which do not use IPython
6348 6348 at all, put the following lines toward the top of your `main' routine:
6349 6349 \layout Standard
6350 6350 \align left
6351 6351
6352 6352 \family typewriter
6353 6353 import sys,IPython.ultraTB
6354 6354 \newline
6355 6355 sys.excepthook = IPython.ultraTB.FormattedTB(mode=`Verbose', color_scheme=`Linux',
6356 6356 call_pdb=1)
6357 6357 \layout Standard
6358 6358
6359 6359 The
6360 6360 \family typewriter
6361 6361 mode
6362 6362 \family default
6363 6363 keyword can be either
6364 6364 \family typewriter
6365 6365 `Verbose'
6366 6366 \family default
6367 6367 or
6368 6368 \family typewriter
6369 6369 `Plain'
6370 6370 \family default
6371 6371 , giving either very detailed or normal tracebacks respectively.
6372 6372 The
6373 6373 \family typewriter
6374 6374 color_scheme
6375 6375 \family default
6376 6376 keyword can be one of
6377 6377 \family typewriter
6378 6378 `NoColor'
6379 6379 \family default
6380 6380 ,
6381 6381 \family typewriter
6382 6382 `Linux'
6383 6383 \family default
6384 6384 (default) or
6385 6385 \family typewriter
6386 6386 `LightBG'
6387 6387 \family default
6388 6388 .
6389 6389 These are the same options which can be set in IPython with
6390 6390 \family typewriter
6391 6391 -colors
6392 6392 \family default
6393 6393 and
6394 6394 \family typewriter
6395 6395 -xmode
6396 6396 \family default
6397 6397 .
6398 6398 \layout Standard
6399 6399
6400 6400 This will give any of your programs detailed, colored tracebacks with automatic
6401 6401 invocation of
6402 6402 \family typewriter
6403 6403 pdb
6404 6404 \family default
6405 6405 .
6406 6406 \layout Section
6407 6407
6408 6408
6409 6409 \begin_inset LatexCommand \label{sec:syntax-extensions}
6410 6410
6411 6411 \end_inset
6412 6412
6413 6413 Extensions for syntax processing
6414 6414 \layout Standard
6415 6415
6416 6416 This isn't for the faint of heart, because the potential for breaking things
6417 6417 is quite high.
6418 6418 But it can be a very powerful and useful feature.
6419 6419 In a nutshell, you can redefine the way IPython processes the user input
6420 6420 line to accept new, special extensions to the syntax without needing to
6421 6421 change any of IPython's own code.
6422 6422 \layout Standard
6423 6423
6424 6424 In the
6425 6425 \family typewriter
6426 6426 IPython/Extensions
6427 6427 \family default
6428 6428 directory you will find some examples supplied, which we will briefly describe
6429 6429 now.
6430 6430 These can be used `as is' (and both provide very useful functionality),
6431 6431 or you can use them as a starting point for writing your own extensions.
6432 6432 \layout Subsection
6433 6433
6434 6434 Pasting of code starting with
6435 6435 \family typewriter
6436 6436 `>>>
6437 6437 \family default
6438 6438 ' or
6439 6439 \family typewriter
6440 6440 `...
6441 6441
6442 6442 \family default
6443 6443 '
6444 6444 \layout Standard
6445 6445
6446 6446 In the python tutorial it is common to find code examples which have been
6447 6447 taken from real python sessions.
6448 6448 The problem with those is that all the lines begin with either
6449 6449 \family typewriter
6450 6450 `>>>
6451 6451 \family default
6452 6452 ' or
6453 6453 \family typewriter
6454 6454 `...
6455 6455
6456 6456 \family default
6457 6457 ', which makes it impossible to paste them all at once.
6458 6458 One must instead do a line by line manual copying, carefully removing the
6459 6459 leading extraneous characters.
6460 6460 \layout Standard
6461 6461
6462 6462 This extension identifies those starting characters and removes them from
6463 6463 the input automatically, so that one can paste multi-line examples directly
6464 6464 into IPython, saving a lot of time.
6465 6465 Please look at the file
6466 6466 \family typewriter
6467 6467 InterpreterPasteInput.py
6468 6468 \family default
6469 6469 in the
6470 6470 \family typewriter
6471 6471 IPython/Extensions
6472 6472 \family default
6473 6473 directory for details on how this is done.
6474 6474 \layout Standard
6475 6475
6476 6476 IPython comes with a special profile enabling this feature, called
6477 6477 \family typewriter
6478 6478 tutorial
6479 6479 \family default
6480 6480 \emph on
6481 6481 .
6482 6482
6483 6483 \emph default
6484 6484 Simply start IPython via
6485 6485 \family typewriter
6486 6486 `ipython\SpecialChar ~
6487 6487 -p\SpecialChar ~
6488 6488 tutorial'
6489 6489 \family default
6490 6490 and the feature will be available.
6491 6491 In a normal IPython session you can activate the feature by importing the
6492 6492 corresponding module with:
6493 6493 \newline
6494 6494
6495 6495 \family typewriter
6496 6496 In [1]: import IPython.Extensions.InterpreterPasteInput
6497 6497 \layout Standard
6498 6498
6499 6499 The following is a 'screenshot' of how things work when this extension is
6500 6500 on, copying an example from the standard tutorial:
6501 6501 \layout Standard
6502 6502
6503 6503
6504 6504 \family typewriter
6505 6505 IPython profile: tutorial
6506 6506 \newline
6507 6507 \SpecialChar ~
6508 6508
6509 6509 \newline
6510 6510 *** Pasting of code with ">>>" or "..." has been enabled.
6511 6511 \newline
6512 6512 \SpecialChar ~
6513 6513
6514 6514 \newline
6515 6515 In [1]: >>> def fib2(n): # return Fibonacci series up to n
6516 6516 \newline
6517 6517
6518 6518 \begin_inset ERT
6519 6519 status Collapsed
6520 6520
6521 6521 \layout Standard
6522 6522
6523 6523 \backslash
6524 6524 hspace*{0mm}
6525 6525 \end_inset
6526 6526
6527 6527 \SpecialChar ~
6528 6528 \SpecialChar ~
6529 6529 ...: ...\SpecialChar ~
6530 6530 \SpecialChar ~
6531 6531 \SpecialChar ~
6532 6532 \SpecialChar ~
6533 6533 """Return a list containing the Fibonacci series up to n."""
6534 6534 \newline
6535 6535
6536 6536 \begin_inset ERT
6537 6537 status Collapsed
6538 6538
6539 6539 \layout Standard
6540 6540
6541 6541 \backslash
6542 6542 hspace*{0mm}
6543 6543 \end_inset
6544 6544
6545 6545 \SpecialChar ~
6546 6546 \SpecialChar ~
6547 6547 ...: ...\SpecialChar ~
6548 6548 \SpecialChar ~
6549 6549 \SpecialChar ~
6550 6550 \SpecialChar ~
6551 6551 result = []
6552 6552 \newline
6553 6553
6554 6554 \begin_inset ERT
6555 6555 status Collapsed
6556 6556
6557 6557 \layout Standard
6558 6558
6559 6559 \backslash
6560 6560 hspace*{0mm}
6561 6561 \end_inset
6562 6562
6563 6563 \SpecialChar ~
6564 6564 \SpecialChar ~
6565 6565 ...: ...\SpecialChar ~
6566 6566 \SpecialChar ~
6567 6567 \SpecialChar ~
6568 6568 \SpecialChar ~
6569 6569 a, b = 0, 1
6570 6570 \newline
6571 6571
6572 6572 \begin_inset ERT
6573 6573 status Collapsed
6574 6574
6575 6575 \layout Standard
6576 6576
6577 6577 \backslash
6578 6578 hspace*{0mm}
6579 6579 \end_inset
6580 6580
6581 6581 \SpecialChar ~
6582 6582 \SpecialChar ~
6583 6583 ...: ...\SpecialChar ~
6584 6584 \SpecialChar ~
6585 6585 \SpecialChar ~
6586 6586 \SpecialChar ~
6587 6587 while b < n:
6588 6588 \newline
6589 6589
6590 6590 \begin_inset ERT
6591 6591 status Collapsed
6592 6592
6593 6593 \layout Standard
6594 6594
6595 6595 \backslash
6596 6596 hspace*{0mm}
6597 6597 \end_inset
6598 6598
6599 6599 \SpecialChar ~
6600 6600 \SpecialChar ~
6601 6601 ...: ...\SpecialChar ~
6602 6602 \SpecialChar ~
6603 6603 \SpecialChar ~
6604 6604 \SpecialChar ~
6605 6605 \SpecialChar ~
6606 6606 \SpecialChar ~
6607 6607 \SpecialChar ~
6608 6608 \SpecialChar ~
6609 6609 result.append(b)\SpecialChar ~
6610 6610 \SpecialChar ~
6611 6611 \SpecialChar ~
6612 6612 # see below
6613 6613 \newline
6614 6614
6615 6615 \begin_inset ERT
6616 6616 status Collapsed
6617 6617
6618 6618 \layout Standard
6619 6619
6620 6620 \backslash
6621 6621 hspace*{0mm}
6622 6622 \end_inset
6623 6623
6624 6624 \SpecialChar ~
6625 6625 \SpecialChar ~
6626 6626 ...: ...\SpecialChar ~
6627 6627 \SpecialChar ~
6628 6628 \SpecialChar ~
6629 6629 \SpecialChar ~
6630 6630 \SpecialChar ~
6631 6631 \SpecialChar ~
6632 6632 \SpecialChar ~
6633 6633 \SpecialChar ~
6634 6634 a, b = b, a+b
6635 6635 \newline
6636 6636
6637 6637 \begin_inset ERT
6638 6638 status Collapsed
6639 6639
6640 6640 \layout Standard
6641 6641
6642 6642 \backslash
6643 6643 hspace*{0mm}
6644 6644 \end_inset
6645 6645
6646 6646 \SpecialChar ~
6647 6647 \SpecialChar ~
6648 6648 ...: ...\SpecialChar ~
6649 6649 \SpecialChar ~
6650 6650 \SpecialChar ~
6651 6651 \SpecialChar ~
6652 6652 return result
6653 6653 \newline
6654 6654
6655 6655 \begin_inset ERT
6656 6656 status Collapsed
6657 6657
6658 6658 \layout Standard
6659 6659
6660 6660 \backslash
6661 6661 hspace*{0mm}
6662 6662 \end_inset
6663 6663
6664 6664 \SpecialChar ~
6665 6665 \SpecialChar ~
6666 6666 ...:
6667 6667 \newline
6668 6668 \SpecialChar ~
6669 6669
6670 6670 \newline
6671 6671 In [2]: fib2(10)
6672 6672 \newline
6673 6673 Out[2]: [1, 1, 2, 3, 5, 8]
6674 6674 \layout Standard
6675 6675
6676 6676 Note that as currently written, this extension does
6677 6677 \emph on
6678 6678 not
6679 6679 \emph default
6680 6680 recognize IPython's prompts for pasting.
6681 6681 Those are more complicated, since the user can change them very easily,
6682 6682 they involve numbers and can vary in length.
6683 6683 One could however extract all the relevant information from the IPython
6684 6684 instance and build an appropriate regular expression.
6685 6685 This is left as an exercise for the reader.
6686 6686 \layout Subsection
6687 6687
6688 6688 Input of physical quantities with units
6689 6689 \layout Standard
6690 6690
6691 6691 The module
6692 6692 \family typewriter
6693 6693 PhysicalQInput
6694 6694 \family default
6695 6695 allows a simplified form of input for physical quantities with units.
6696 6696 This file is meant to be used in conjunction with the
6697 6697 \family typewriter
6698 6698 PhysicalQInteractive
6699 6699 \family default
6700 6700 module (in the same directory) and
6701 6701 \family typewriter
6702 6702 Physics.PhysicalQuantities
6703 6703 \family default
6704 6704 from Konrad Hinsen's ScientificPython (
6705 6705 \begin_inset LatexCommand \htmlurl{http://starship.python.net/crew/hinsen/scientific.html}
6706 6706
6707 6707 \end_inset
6708 6708
6709 6709 ).
6710 6710 \layout Standard
6711 6711
6712 6712 The
6713 6713 \family typewriter
6714 6714 Physics.PhysicalQuantities
6715 6715 \family default
6716 6716 module defines
6717 6717 \family typewriter
6718 6718 PhysicalQuantity
6719 6719 \family default
6720 6720 objects, but these must be declared as instances of a class.
6721 6721 For example, to define
6722 6722 \family typewriter
6723 6723 v
6724 6724 \family default
6725 6725 as a velocity of 3\SpecialChar ~
6726 6726 m/s, normally you would write:
6727 6727 \family typewriter
6728 6728
6729 6729 \newline
6730 6730 In [1]: v = PhysicalQuantity(3,'m/s')
6731 6731 \layout Standard
6732 6732
6733 6733 Using the
6734 6734 \family typewriter
6735 6735 PhysicalQ_Input
6736 6736 \family default
6737 6737 extension this can be input instead as:
6738 6738 \family typewriter
6739 6739
6740 6740 \newline
6741 6741 In [1]: v = 3 m/s
6742 6742 \family default
6743 6743
6744 6744 \newline
6745 6745 which is much more convenient for interactive use (even though it is blatantly
6746 6746 invalid Python syntax).
6747 6747 \layout Standard
6748 6748
6749 6749 The
6750 6750 \family typewriter
6751 6751 physics
6752 6752 \family default
6753 6753 profile supplied with IPython (enabled via
6754 6754 \family typewriter
6755 6755 'ipython -p physics'
6756 6756 \family default
6757 6757 ) uses these extensions, which you can also activate with:
6758 6758 \layout Standard
6759 6759
6760 6760
6761 6761 \family typewriter
6762 6762 from math import * # math MUST be imported BEFORE PhysicalQInteractive
6763 6763 \newline
6764 6764 from IPython.Extensions.PhysicalQInteractive import *
6765 6765 \newline
6766 6766 import IPython.Extensions.PhysicalQInput
6767 6767 \layout Section
6768 6768
6769 6769 IPython as a system shell
6770 6770 \layout Standard
6771 6771
6772 6772 IPython ships with a special profile called
6773 6773 \family typewriter
6774 6774 pysh
6775 6775 \family default
6776 6776 , which you can activate at the command line as
6777 6777 \family typewriter
6778 6778 `ipython -p pysh'
6779 6779 \family default
6780 6780 .
6781 6781 This loads
6782 6782 \family typewriter
6783 6783 InterpreterExec
6784 6784 \family default
6785 6785 , along with some additional facilities and a prompt customized for filesystem
6786 6786 navigation.
6787 6787 \layout Standard
6788 6788
6789 6789 Note that this does
6790 6790 \emph on
6791 6791 not
6792 6792 \emph default
6793 6793 make IPython a full-fledged system shell.
6794 6794 In particular, it has no job control, so if you type Ctrl-Z (under Unix),
6795 6795 you'll suspend pysh itself, not the process you just started.
6796 6796
6797 6797 \layout Standard
6798 6798
6799 6799 What the shell profile allows you to do is to use the convenient and powerful
6800 6800 syntax of Python to do quick scripting at the command line.
6801 6801 Below we describe some of its features.
6802 6802 \layout Subsection
6803 6803
6804 6804 Aliases
6805 6805 \layout Standard
6806 6806
6807 6807 All of your
6808 6808 \family typewriter
6809 6809 $PATH
6810 6810 \family default
6811 6811 has been loaded as IPython aliases, so you should be able to type any normal
6812 6812 system command and have it executed.
6813 6813 See
6814 6814 \family typewriter
6815 6815 %alias?
6816 6816 \family default
6817 6817 and
6818 6818 \family typewriter
6819 6819 %unalias?
6820 6820 \family default
6821 6821 for details on the alias facilities.
6822 6822 See also
6823 6823 \family typewriter
6824 6824 %rehash?
6825 6825 \family default
6826 6826 and
6827 6827 \family typewriter
6828 6828 %rehashx?
6829 6829 \family default
6830 6830 for details on the mechanism used to load
6831 6831 \family typewriter
6832 6832 $PATH
6833 6833 \family default
6834 6834 .
6835 6835 \layout Subsection
6836 6836
6837 6837 Special syntax
6838 6838 \layout Standard
6839 6839
6840 6840 Any lines which begin with
6841 6841 \family typewriter
6842 6842 `~'
6843 6843 \family default
6844 6844 ,
6845 6845 \family typewriter
6846 6846 `/'
6847 6847 \family default
6848 6848 and
6849 6849 \family typewriter
6850 6850 `.'
6851 6851 \family default
6852 6852 will be executed as shell commands instead of as Python code.
6853 6853 The special escapes below are also recognized.
6854 6854
6855 6855 \family typewriter
6856 6856 !cmd
6857 6857 \family default
6858 6858 is valid in single or multi-line input, all others are only valid in single-lin
6859 6859 e input:
6860 6860 \layout Description
6861 6861
6862 6862
6863 6863 \family typewriter
6864 6864 !cmd
6865 6865 \family default
6866 6866 pass `cmd' directly to the shell
6867 6867 \layout Description
6868 6868
6869 6869
6870 6870 \family typewriter
6871 6871 !!cmd
6872 6872 \family default
6873 6873 execute `cmd' and return output as a list (split on `
6874 6874 \backslash
6875 6875 n')
6876 6876 \layout Description
6877 6877
6878 6878
6879 6879 \family typewriter
6880 6880 $var=cmd
6881 6881 \family default
6882 6882 capture output of cmd into var, as a string
6883 6883 \layout Description
6884 6884
6885 6885
6886 6886 \family typewriter
6887 6887 $$var=cmd
6888 6888 \family default
6889 6889 capture output of cmd into var, as a list (split on `
6890 6890 \backslash
6891 6891 n')
6892 6892 \layout Standard
6893 6893
6894 6894 The
6895 6895 \family typewriter
6896 6896 $
6897 6897 \family default
6898 6898 /
6899 6899 \family typewriter
6900 6900 $$
6901 6901 \family default
6902 6902 syntaxes make Python variables from system output, which you can later
6903 6903 use for further scripting.
6904 6904 The converse is also possible: when executing an alias or calling to the
6905 6905 system via
6906 6906 \family typewriter
6907 6907 !
6908 6908 \family default
6909 6909 /
6910 6910 \family typewriter
6911 6911 !!
6912 6912 \family default
6913 6913 , you can expand any python variable or expression by prepending it with
6914 6914
6915 6915 \family typewriter
6916 6916 $
6917 6917 \family default
6918 6918 .
6919 6919 Full details of the allowed syntax can be found in Python's PEP 215.
6920 6920 \layout Standard
6921 6921
6922 6922 A few brief examples will illustrate these (note that the indentation below
6923 6923 may be incorrectly displayed):
6924 6924 \layout Standard
6925 6925
6926 6926
6927 6927 \family typewriter
6928 6928 fperez[~/test]|3> !ls *s.py
6929 6929 \newline
6930 6930 scopes.py strings.py
6931 6931 \layout Standard
6932 6932
6933 6933 ls is an internal alias, so there's no need to use
6934 6934 \family typewriter
6935 6935 !
6936 6936 \family default
6937 6937 :
6938 6938 \layout Standard
6939 6939
6940 6940
6941 6941 \family typewriter
6942 6942 fperez[~/test]|4> ls *s.py
6943 6943 \newline
6944 6944 scopes.py* strings.py
6945 6945 \layout Standard
6946 6946
6947 6947 !!ls will return the output into a Python variable:
6948 6948 \layout Standard
6949 6949
6950 6950
6951 6951 \family typewriter
6952 6952 fperez[~/test]|5> !!ls *s.py
6953 6953 \newline
6954 6954
6955 6955 \begin_inset ERT
6956 6956 status Collapsed
6957 6957
6958 6958 \layout Standard
6959 6959
6960 6960 \backslash
6961 6961 hspace*{0mm}
6962 6962 \end_inset
6963 6963
6964 6964 \SpecialChar ~
6965 6965 \SpecialChar ~
6966 6966 \SpecialChar ~
6967 6967 \SpecialChar ~
6968 6968 \SpecialChar ~
6969 6969 \SpecialChar ~
6970 6970 \SpecialChar ~
6971 6971 \SpecialChar ~
6972 6972 \SpecialChar ~
6973 6973 \SpecialChar ~
6974 6974 \SpecialChar ~
6975 6975 \SpecialChar ~
6976 6976 \SpecialChar ~
6977 6977 \SpecialChar ~
6978 6978 <5> ['scopes.py', 'strings.py']
6979 6979 \newline
6980 6980 fperez[~/test]|6> print _5
6981 6981 \newline
6982 6982 ['scopes.py', 'strings.py']
6983 6983 \layout Standard
6984 6984
6985 6985
6986 6986 \family typewriter
6987 6987 $
6988 6988 \family default
6989 6989 and
6990 6990 \family typewriter
6991 6991 $$
6992 6992 \family default
6993 6993 allow direct capture to named variables:
6994 6994 \layout Standard
6995 6995
6996 6996
6997 6997 \family typewriter
6998 6998 fperez[~/test]|7> $astr = ls *s.py
6999 6999 \newline
7000 7000 fperez[~/test]|8> astr
7001 7001 \newline
7002 7002
7003 7003 \begin_inset ERT
7004 7004 status Collapsed
7005 7005
7006 7006 \layout Standard
7007 7007
7008 7008 \backslash
7009 7009 hspace*{0mm}
7010 7010 \end_inset
7011 7011
7012 7012 \SpecialChar ~
7013 7013 \SpecialChar ~
7014 7014 \SpecialChar ~
7015 7015 \SpecialChar ~
7016 7016 \SpecialChar ~
7017 7017 \SpecialChar ~
7018 7018 \SpecialChar ~
7019 7019 \SpecialChar ~
7020 7020 \SpecialChar ~
7021 7021 \SpecialChar ~
7022 7022 \SpecialChar ~
7023 7023 \SpecialChar ~
7024 7024 \SpecialChar ~
7025 7025 \SpecialChar ~
7026 7026 <8> 'scopes.py
7027 7027 \backslash
7028 7028 nstrings.py'
7029 7029 \layout Standard
7030 7030
7031 7031
7032 7032 \family typewriter
7033 7033 fperez[~/test]|9> $$alist = ls *s.py
7034 7034 \newline
7035 7035 fperez[~/test]|10> alist
7036 7036 \newline
7037 7037
7038 7038 \begin_inset ERT
7039 7039 status Collapsed
7040 7040
7041 7041 \layout Standard
7042 7042
7043 7043 \backslash
7044 7044 hspace*{0mm}
7045 7045 \end_inset
7046 7046
7047 7047 \SpecialChar ~
7048 7048 \SpecialChar ~
7049 7049 \SpecialChar ~
7050 7050 \SpecialChar ~
7051 7051 \SpecialChar ~
7052 7052 \SpecialChar ~
7053 7053 \SpecialChar ~
7054 7054 \SpecialChar ~
7055 7055 \SpecialChar ~
7056 7056 \SpecialChar ~
7057 7057 \SpecialChar ~
7058 7058 \SpecialChar ~
7059 7059 \SpecialChar ~
7060 7060 \SpecialChar ~
7061 7061 <10> ['scopes.py', 'strings.py']
7062 7062 \layout Standard
7063 7063
7064 7064 alist is now a normal python list you can loop over.
7065 7065 Using
7066 7066 \family typewriter
7067 7067 $
7068 7068 \family default
7069 7069 will expand back the python values when alias calls are made:
7070 7070 \layout Standard
7071 7071
7072 7072
7073 7073 \family typewriter
7074 7074 fperez[~/test]|11> for f in alist:
7075 7075 \newline
7076 7076
7077 7077 \begin_inset ERT
7078 7078 status Collapsed
7079 7079
7080 7080 \layout Standard
7081 7081
7082 7082 \backslash
7083 7083 hspace*{0mm}
7084 7084 \end_inset
7085 7085
7086 7086 \SpecialChar ~
7087 7087 \SpecialChar ~
7088 7088 \SpecialChar ~
7089 7089 \SpecialChar ~
7090 7090 \SpecialChar ~
7091 7091 \SpecialChar ~
7092 7092 \SpecialChar ~
7093 7093 \SpecialChar ~
7094 7094 \SpecialChar ~
7095 7095 \SpecialChar ~
7096 7096 \SpecialChar ~
7097 7097 \SpecialChar ~
7098 7098 \SpecialChar ~
7099 7099 \SpecialChar ~
7100 7100 |..> \SpecialChar ~
7101 7101 \SpecialChar ~
7102 7102 \SpecialChar ~
7103 7103 \SpecialChar ~
7104 7104 print 'file',f,
7105 7105 \newline
7106 7106
7107 7107 \begin_inset ERT
7108 7108 status Collapsed
7109 7109
7110 7110 \layout Standard
7111 7111
7112 7112 \backslash
7113 7113 hspace*{0mm}
7114 7114 \end_inset
7115 7115
7116 7116 \SpecialChar ~
7117 7117 \SpecialChar ~
7118 7118 \SpecialChar ~
7119 7119 \SpecialChar ~
7120 7120 \SpecialChar ~
7121 7121 \SpecialChar ~
7122 7122 \SpecialChar ~
7123 7123 \SpecialChar ~
7124 7124 \SpecialChar ~
7125 7125 \SpecialChar ~
7126 7126 \SpecialChar ~
7127 7127 \SpecialChar ~
7128 7128 \SpecialChar ~
7129 7129 \SpecialChar ~
7130 7130 |..> \SpecialChar ~
7131 7131 \SpecialChar ~
7132 7132 \SpecialChar ~
7133 7133 \SpecialChar ~
7134 7134 wc -l $f
7135 7135 \newline
7136 7136
7137 7137 \begin_inset ERT
7138 7138 status Collapsed
7139 7139
7140 7140 \layout Standard
7141 7141
7142 7142 \backslash
7143 7143 hspace*{0mm}
7144 7144 \end_inset
7145 7145
7146 7146 \SpecialChar ~
7147 7147 \SpecialChar ~
7148 7148 \SpecialChar ~
7149 7149 \SpecialChar ~
7150 7150 \SpecialChar ~
7151 7151 \SpecialChar ~
7152 7152 \SpecialChar ~
7153 7153 \SpecialChar ~
7154 7154 \SpecialChar ~
7155 7155 \SpecialChar ~
7156 7156 \SpecialChar ~
7157 7157 \SpecialChar ~
7158 7158 \SpecialChar ~
7159 7159 \SpecialChar ~
7160 7160 |..>
7161 7161 \newline
7162 7162 file scopes.py 13 scopes.py
7163 7163 \newline
7164 7164 file strings.py 4 strings.py
7165 7165 \layout Standard
7166 7166
7167 7167 Note that you may need to protect your variables with braces if you want
7168 7168 to append strings to their names.
7169 7169 To copy all files in alist to
7170 7170 \family typewriter
7171 7171 .bak
7172 7172 \family default
7173 7173 extensions, you must use:
7174 7174 \layout Standard
7175 7175
7176 7176
7177 7177 \family typewriter
7178 7178 fperez[~/test]|12> for f in alist:
7179 7179 \newline
7180 7180
7181 7181 \begin_inset ERT
7182 7182 status Collapsed
7183 7183
7184 7184 \layout Standard
7185 7185
7186 7186 \backslash
7187 7187 hspace*{0mm}
7188 7188 \end_inset
7189 7189
7190 7190 \SpecialChar ~
7191 7191 \SpecialChar ~
7192 7192 \SpecialChar ~
7193 7193 \SpecialChar ~
7194 7194 \SpecialChar ~
7195 7195 \SpecialChar ~
7196 7196 \SpecialChar ~
7197 7197 \SpecialChar ~
7198 7198 \SpecialChar ~
7199 7199 \SpecialChar ~
7200 7200 \SpecialChar ~
7201 7201 \SpecialChar ~
7202 7202 \SpecialChar ~
7203 7203 \SpecialChar ~
7204 7204 |..> \SpecialChar ~
7205 7205 \SpecialChar ~
7206 7206 \SpecialChar ~
7207 7207 \SpecialChar ~
7208 7208 cp $f ${f}.bak
7209 7209 \layout Standard
7210 7210
7211 7211 If you try using
7212 7212 \family typewriter
7213 7213 $f.bak
7214 7214 \family default
7215 7215 , you'll get an AttributeError exception saying that your string object
7216 7216 doesn't have a
7217 7217 \family typewriter
7218 7218 .bak
7219 7219 \family default
7220 7220 attribute.
7221 7221 This is because the
7222 7222 \family typewriter
7223 7223 $
7224 7224 \family default
7225 7225 expansion mechanism allows you to expand full Python expressions:
7226 7226 \layout Standard
7227 7227
7228 7228
7229 7229 \family typewriter
7230 7230 fperez[~/test]|13> echo "sys.platform is: $sys.platform"
7231 7231 \newline
7232 7232 sys.platform is: linux2
7233 7233 \layout Standard
7234 7234
7235 7235 IPython's input history handling is still active, which allows you to rerun
7236 7236 a single block of multi-line input by simply using exec:
7237 7237 \newline
7238 7238
7239 7239 \family typewriter
7240 7240 fperez[~/test]|14> $$alist = ls *.eps
7241 7241 \newline
7242 7242 fperez[~/test]|15> exec _i11
7243 7243 \newline
7244 7244 file image2.eps 921 image2.eps
7245 7245 \newline
7246 7246 file image.eps 921 image.eps
7247 7247 \layout Standard
7248 7248
7249 7249 While these are new special-case syntaxes, they are designed to allow very
7250 7250 efficient use of the shell with minimal typing.
7251 7251 At an interactive shell prompt, conciseness of expression wins over readability.
7252 7252 \layout Subsection
7253 7253
7254 7254 Useful functions and modules
7255 7255 \layout Standard
7256 7256
7257 7257 The os, sys and shutil modules from the Python standard library are automaticall
7258 7258 y loaded.
7259 7259 Some additional functions, useful for shell usage, are listed below.
7260 7260 You can request more help about them with `
7261 7261 \family typewriter
7262 7262 ?
7263 7263 \family default
7264 7264 '.
7265 7265 \layout Description
7266 7266
7267 7267
7268 7268 \family typewriter
7269 7269 shell
7270 7270 \family default
7271 7271 - execute a command in the underlying system shell
7272 7272 \layout Description
7273 7273
7274 7274
7275 7275 \family typewriter
7276 7276 system
7277 7277 \family default
7278 7278 - like
7279 7279 \family typewriter
7280 7280 shell()
7281 7281 \family default
7282 7282 , but return the exit status of the command
7283 7283 \layout Description
7284 7284
7285 7285
7286 7286 \family typewriter
7287 7287 sout
7288 7288 \family default
7289 7289 - capture the output of a command as a string
7290 7290 \layout Description
7291 7291
7292 7292
7293 7293 \family typewriter
7294 7294 lout
7295 7295 \family default
7296 7296 - capture the output of a command as a list (split on `
7297 7297 \backslash
7298 7298 n')
7299 7299 \layout Description
7300 7300
7301 7301
7302 7302 \family typewriter
7303 7303 getoutputerror
7304 7304 \family default
7305 7305 - capture (output,error) of a shell commandss
7306 7306 \layout Standard
7307 7307
7308 7308
7309 7309 \family typewriter
7310 7310 sout
7311 7311 \family default
7312 7312 /
7313 7313 \family typewriter
7314 7314 lout
7315 7315 \family default
7316 7316 are the functional equivalents of
7317 7317 \family typewriter
7318 7318 $
7319 7319 \family default
7320 7320 /
7321 7321 \family typewriter
7322 7322 $$
7323 7323 \family default
7324 7324 .
7325 7325 They are provided to allow you to capture system output in the middle of
7326 7326 true python code, function definitions, etc (where
7327 7327 \family typewriter
7328 7328 $
7329 7329 \family default
7330 7330 and
7331 7331 \family typewriter
7332 7332 $$
7333 7333 \family default
7334 7334 are invalid).
7335 7335 \layout Subsection
7336 7336
7337 7337 Directory management
7338 7338 \layout Standard
7339 7339
7340 7340 Since each command passed by pysh to the underlying system is executed in
7341 7341 a subshell which exits immediately, you can NOT use !cd to navigate the
7342 7342 filesystem.
7343 7343 \layout Standard
7344 7344
7345 7345 Pysh provides its own builtin
7346 7346 \family typewriter
7347 7347 `%cd
7348 7348 \family default
7349 7349 ' magic command to move in the filesystem (the
7350 7350 \family typewriter
7351 7351 %
7352 7352 \family default
7353 7353 is not required with automagic on).
7354 7354 It also maintains a list of visited directories (use
7355 7355 \family typewriter
7356 7356 %dhist
7357 7357 \family default
7358 7358 to see it) and allows direct switching to any of them.
7359 7359 Type
7360 7360 \family typewriter
7361 7361 `cd?
7362 7362 \family default
7363 7363 ' for more details.
7364 7364 \layout Standard
7365 7365
7366 7366
7367 7367 \family typewriter
7368 7368 %pushd
7369 7369 \family default
7370 7370 ,
7371 7371 \family typewriter
7372 7372 %popd
7373 7373 \family default
7374 7374 and
7375 7375 \family typewriter
7376 7376 %dirs
7377 7377 \family default
7378 7378 are provided for directory stack handling.
7379 7379 \layout Subsection
7380 7380
7381 7381 Prompt customization
7382 7382 \layout Standard
7383 7383
7384 7384 The supplied
7385 7385 \family typewriter
7386 7386 ipythonrc-pysh
7387 7387 \family default
7388 7388 profile comes with an example of a very colored and detailed prompt, mainly
7389 7389 to serve as an illustration.
7390 7390 The valid escape sequences, besides color names, are:
7391 7391 \layout Description
7392 7392
7393 7393
7394 7394 \backslash
7395 7395 # - Prompt number.
7396 7396 \layout Description
7397 7397
7398 7398
7399 7399 \backslash
7400 7400 D - Dots, as many as there are digits in
7401 7401 \backslash
7402 7402 # (so they align).
7403 7403 \layout Description
7404 7404
7405 7405
7406 7406 \backslash
7407 7407 w - Current working directory (cwd).
7408 7408 \layout Description
7409 7409
7410 7410
7411 7411 \backslash
7412 7412 W - Basename of current working directory.
7413 7413 \layout Description
7414 7414
7415 7415
7416 7416 \backslash
7417 7417 X
7418 7418 \emph on
7419 7419 N
7420 7420 \emph default
7421 7421 - Where
7422 7422 \emph on
7423 7423 N
7424 7424 \emph default
7425 7425 =0..5.
7426 7426 N terms of the cwd, with $HOME written as ~.
7427 7427 \layout Description
7428 7428
7429 7429
7430 7430 \backslash
7431 7431 Y
7432 7432 \emph on
7433 7433 N
7434 7434 \emph default
7435 7435 - Where
7436 7436 \emph on
7437 7437 N
7438 7438 \emph default
7439 7439 =0..5.
7440 7440 Like X
7441 7441 \emph on
7442 7442 N
7443 7443 \emph default
7444 7444 , but if ~ is term
7445 7445 \emph on
7446 7446 N
7447 7447 \emph default
7448 7448 +1 it's also shown.
7449 7449 \layout Description
7450 7450
7451 7451
7452 7452 \backslash
7453 7453 u - Username.
7454 7454 \layout Description
7455 7455
7456 7456
7457 7457 \backslash
7458 7458 H - Full hostname.
7459 7459 \layout Description
7460 7460
7461 7461
7462 7462 \backslash
7463 7463 h - Hostname up to first '.'
7464 7464 \layout Description
7465 7465
7466 7466
7467 7467 \backslash
7468 7468 $ - Root symbol ($ or #).
7469 7469
7470 7470 \layout Description
7471 7471
7472 7472
7473 7473 \backslash
7474 7474 t - Current time, in H:M:S format.
7475 7475 \layout Description
7476 7476
7477 7477
7478 7478 \backslash
7479 7479 v - IPython release version.
7480 7480
7481 7481 \layout Description
7482 7482
7483 7483
7484 7484 \backslash
7485 7485 n - Newline.
7486 7486
7487 7487 \layout Description
7488 7488
7489 7489
7490 7490 \backslash
7491 7491 r - Carriage return.
7492 7492
7493 7493 \layout Description
7494 7494
7495 7495
7496 7496 \backslash
7497 7497
7498 7498 \backslash
7499 7499 - An explicitly escaped '
7500 7500 \backslash
7501 7501 '.
7502 7502 \layout Standard
7503 7503
7504 7504 You can configure your prompt colors using any ANSI color escape.
7505 7505 Each color escape sets the color for any subsequent text, until another
7506 7506 escape comes in and changes things.
7507 7507 The valid color escapes are:
7508 7508 \layout Description
7509 7509
7510 7510
7511 7511 \backslash
7512 7512 C_Black
7513 7513 \layout Description
7514 7514
7515 7515
7516 7516 \backslash
7517 7517 C_Blue
7518 7518 \layout Description
7519 7519
7520 7520
7521 7521 \backslash
7522 7522 C_Brown
7523 7523 \layout Description
7524 7524
7525 7525
7526 7526 \backslash
7527 7527 C_Cyan
7528 7528 \layout Description
7529 7529
7530 7530
7531 7531 \backslash
7532 7532 C_DarkGray
7533 7533 \layout Description
7534 7534
7535 7535
7536 7536 \backslash
7537 7537 C_Green
7538 7538 \layout Description
7539 7539
7540 7540
7541 7541 \backslash
7542 7542 C_LightBlue
7543 7543 \layout Description
7544 7544
7545 7545
7546 7546 \backslash
7547 7547 C_LightCyan
7548 7548 \layout Description
7549 7549
7550 7550
7551 7551 \backslash
7552 7552 C_LightGray
7553 7553 \layout Description
7554 7554
7555 7555
7556 7556 \backslash
7557 7557 C_LightGreen
7558 7558 \layout Description
7559 7559
7560 7560
7561 7561 \backslash
7562 7562 C_LightPurple
7563 7563 \layout Description
7564 7564
7565 7565
7566 7566 \backslash
7567 7567 C_LightRed
7568 7568 \layout Description
7569 7569
7570 7570
7571 7571 \backslash
7572 7572 C_Purple
7573 7573 \layout Description
7574 7574
7575 7575
7576 7576 \backslash
7577 7577 C_Red
7578 7578 \layout Description
7579 7579
7580 7580
7581 7581 \backslash
7582 7582 C_White
7583 7583 \layout Description
7584 7584
7585 7585
7586 7586 \backslash
7587 7587 C_Yellow
7588 7588 \layout Description
7589 7589
7590 7590
7591 7591 \backslash
7592 7592 C_Normal Stop coloring, defaults to your terminal settings.
7593 7593 \layout Section
7594 7594
7595 7595
7596 7596 \begin_inset LatexCommand \label{sec:Threading-support}
7597 7597
7598 7598 \end_inset
7599 7599
7600 7600 Threading support
7601 7601 \layout Standard
7602 7602
7603 7603
7604 7604 \series bold
7605 7605 WARNING:
7606 7606 \series default
7607 7607 The threading support is still somewhat experimental, and it has only seen
7608 7608 reasonable testing under Linux.
7609 7609 Threaded code is particularly tricky to debug, and it tends to show extremely
7610 7610 platform-dependent behavior.
7611 7611 Since I only have access to Linux machines, I will have to rely on user's
7612 7612 experiences and assistance for this area of IPython to improve under other
7613 7613 platforms.
7614 7614 \layout Standard
7615 7615
7616 7616 IPython, via the
7617 7617 \family typewriter
7618 7618 -gthread
7619 7619 \family default
7620 7620 ,
7621 7621 \family typewriter
7622 7622 -qthread
7623 7623 \family default
7624 7624 and
7625 7625 \family typewriter
7626 7626 -wthread
7627 7627 \family default
7628 7628 options (described in Sec.\SpecialChar ~
7629 7629
7630 7630 \begin_inset LatexCommand \ref{sec:threading-opts}
7631 7631
7632 7632 \end_inset
7633 7633
7634 7634 ), can run in multithreaded mode to support pyGTK, Qt and WXPython applications
7635 7635 respectively.
7636 7636 These GUI toolkits need to control the python main loop of execution, so
7637 7637 under a normal Python interpreter, starting a pyGTK, Qt or WXPython application
7638 7638 will immediately freeze the shell.
7639 7639
7640 7640 \layout Standard
7641 7641
7642 7642 IPython, with one of these options (you can only use one at a time), separates
7643 7643 the graphical loop and IPython's code execution run into different threads.
7644 7644 This allows you to test interactively (with
7645 7645 \family typewriter
7646 7646 %run
7647 7647 \family default
7648 7648 , for example) your GUI code without blocking.
7649 7649 \layout Standard
7650 7650
7651 7651 A nice mini-tutorial on using IPython along with the Qt Designer application
7652 7652 is available at the SciPy wiki:
7653 7653 \begin_inset LatexCommand \htmlurl{http://www.scipy.org/wikis/topical_software/QtWithIPythonAndDesigner}
7654 7654
7655 7655 \end_inset
7656 7656
7657 7657 .
7658 7658 \layout Subsection
7659 7659
7660 7660 Tk issues
7661 7661 \layout Standard
7662 7662
7663 7663 As indicated in Sec.\SpecialChar ~
7664 7664
7665 7665 \begin_inset LatexCommand \ref{sec:threading-opts}
7666 7666
7667 7667 \end_inset
7668 7668
7669 7669 , a special
7670 7670 \family typewriter
7671 7671 -tk
7672 7672 \family default
7673 7673 option is provided to try and allow Tk graphical applications to coexist
7674 7674 interactively with WX, Qt or GTK ones.
7675 7675 Whether this works at all, however, is very platform and configuration
7676 7676 dependent.
7677 7677 Please experiment with simple test cases before committing to using this
7678 7678 combination of Tk and GTK/Qt/WX threading in a production environment.
7679 7679 \layout Subsection
7680 7680
7681 7681 Signals and Threads
7682 7682 \layout Standard
7683 7683
7684 7684 When any of the thread systems (GTK, Qt or WX) are active, either directly
7685 7685 or via
7686 7686 \family typewriter
7687 7687 -pylab
7688 7688 \family default
7689 7689 with a threaded backend, it is impossible to interrupt long-running Python
7690 7690 code via
7691 7691 \family typewriter
7692 7692 Ctrl-C
7693 7693 \family default
7694 7694 .
7695 7695 IPython can not pass the KeyboardInterrupt exception (or the underlying
7696 7696
7697 7697 \family typewriter
7698 7698 SIGINT
7699 7699 \family default
7700 7700 ) across threads, so any long-running process started from IPython will
7701 7701 run to completion, or will have to be killed via an external (OS-based)
7702 7702 mechanism.
7703 7703 \layout Standard
7704 7704
7705 7705 To the best of my knowledge, this limitation is imposed by the Python interprete
7706 7706 r itself, and it comes from the difficulty of writing portable signal/threaded
7707 7707 code.
7708 7708 If any user is an expert on this topic and can suggest a better solution,
7709 7709 I would love to hear about it.
7710 7710 In the IPython sources, look at the
7711 7711 \family typewriter
7712 7712 Shell.py
7713 7713 \family default
7714 7714 module, and in particular at the
7715 7715 \family typewriter
7716 7716 runcode()
7717 7717 \family default
7718 7718 method.
7719 7719
7720 7720 \layout Subsection
7721 7721
7722 7722 I/O pitfalls
7723 7723 \layout Standard
7724 7724
7725 7725 Be mindful that the Python interpreter switches between threads every
7726 7726 \begin_inset Formula $N$
7727 7727 \end_inset
7728 7728
7729 7729 bytecodes, where the default value as of Python\SpecialChar ~
7730 7730 2.3 is
7731 7731 \begin_inset Formula $N=100.$
7732 7732 \end_inset
7733 7733
7734 7734 This value can be read by using the
7735 7735 \family typewriter
7736 7736 sys.getcheckinterval()
7737 7737 \family default
7738 7738 function, and it can be reset via
7739 7739 \family typewriter
7740 7740 sys.setcheckinterval(
7741 7741 \emph on
7742 7742 N
7743 7743 \emph default
7744 7744 )
7745 7745 \family default
7746 7746 .
7747 7747 This switching of threads can cause subtly confusing effects if one of
7748 7748 your threads is doing file I/O.
7749 7749 In text mode, most systems only flush file buffers when they encounter
7750 7750 a
7751 7751 \family typewriter
7752 7752 `
7753 7753 \backslash
7754 7754 n'
7755 7755 \family default
7756 7756 .
7757 7757 An instruction as simple as
7758 7758 \family typewriter
7759 7759
7760 7760 \newline
7761 7761 \SpecialChar ~
7762 7762 \SpecialChar ~
7763 7763 print >> filehandle,
7764 7764 \begin_inset Quotes eld
7765 7765 \end_inset
7766 7766
7767 7767 hello world
7768 7768 \begin_inset Quotes erd
7769 7769 \end_inset
7770 7770
7771 7771
7772 7772 \family default
7773 7773
7774 7774 \newline
7775 7775 actually consists of several bytecodes, so it is possible that the newline
7776 7776 does not reach your file before the next thread switch.
7777 7777 Similarly, if you are writing to a file in binary mode, the file won't
7778 7778 be flushed until the buffer fills, and your other thread may see apparently
7779 7779 truncated files.
7780 7780
7781 7781 \layout Standard
7782 7782
7783 7783 For this reason, if you are using IPython's thread support and have (for
7784 7784 example) a GUI application which will read data generated by files written
7785 7785 to from the IPython thread, the safest approach is to open all of your
7786 7786 files in unbuffered mode (the third argument to the
7787 7787 \family typewriter
7788 7788 file/open
7789 7789 \family default
7790 7790 function is the buffering value):
7791 7791 \newline
7792 7792
7793 7793 \family typewriter
7794 7794 \SpecialChar ~
7795 7795 \SpecialChar ~
7796 7796 filehandle = open(filename,mode,0)
7797 7797 \layout Standard
7798 7798
7799 7799 This is obviously a brute force way of avoiding race conditions with the
7800 7800 file buffering.
7801 7801 If you want to do it cleanly, and you have a resource which is being shared
7802 7802 by the interactive IPython loop and your GUI thread, you should really
7803 7803 handle it with thread locking and syncrhonization properties.
7804 7804 The Python documentation discusses these.
7805 7805 \layout Section
7806 7806
7807 7807
7808 7808 \begin_inset LatexCommand \label{sec:interactive-demos}
7809 7809
7810 7810 \end_inset
7811 7811
7812 7812 Interactive demos with IPython
7813 7813 \layout Standard
7814 7814
7815 7815 IPython ships with a basic system for running scripts interactively in sections,
7816 7816 useful when presenting code to audiences.
7817 7817 A few tags embedded in comments (so that the script remains valid Python
7818 7818 code) divide a file into separate blocks, and the demo can be run one block
7819 7819 at a time, with IPython printing (with syntax highlighting) the block before
7820 7820 executing it, and returning to the interactive prompt after each block.
7821 7821 The interactive namespace is updated after each block is run with the contents
7822 7822 of the demo's namespace.
7823 7823 \layout Standard
7824 7824
7825 7825 This allows you to show a piece of code, run it and then execute interactively
7826 7826 commands based on the variables just created.
7827 7827 Once you want to continue, you simply execute the next block of the demo.
7828 7828 The following listing shows the markup necessary for dividing a script
7829 7829 into sections for execution as a demo.
7830 7830 \layout Standard
7831 7831
7832 7832
7833 7833 \begin_inset ERT
7834 7834 status Open
7835 7835
7836 7836 \layout Standard
7837 7837
7838 7838 \backslash
7839 7839 codelist{examples/example-demo.py}
7840 7840 \end_inset
7841 7841
7842 7842
7843 7843 \layout Standard
7844 7844
7845 7845 In order to run a file as a demo, you must first make a
7846 7846 \family typewriter
7847 7847 Demo
7848 7848 \family default
7849 7849 object out of it.
7850 7850 If the file is named
7851 7851 \family typewriter
7852 7852 myscript.py
7853 7853 \family default
7854 7854 , the following code will make a demo:
7855 7855 \layout LyX-Code
7856 7856
7857 7857 from IPython.demo import Demo
7858 7858 \layout LyX-Code
7859 7859
7860 7860 mydemo = Demo('myscript.py')
7861 7861 \layout Standard
7862 7862
7863 7863 This creates the
7864 7864 \family typewriter
7865 7865 mydemo
7866 7866 \family default
7867 7867 object, whose blocks you run one at a time by simply calling the object
7868 7868 with no arguments.
7869 7869 If you have autocall active in IPython (the default), all you need to do
7870 7870 is type
7871 7871 \layout LyX-Code
7872 7872
7873 7873 mydemo
7874 7874 \layout Standard
7875 7875
7876 7876 and IPython will call it, executing each block.
7877 7877 Demo objects can be restarted, you can move forward or back skipping blocks,
7878 7878 re-execute the last block, etc.
7879 7879 Simply use the Tab key on a demo object to see its methods, and call
7880 7880 \family typewriter
7881 7881 `?'
7882 7882 \family default
7883 7883 on them to see their docstrings for more usage details.
7884 7884 In addition, the
7885 7885 \family typewriter
7886 7886 demo
7887 7887 \family default
7888 7888 module itself contains a comprehensive docstring, which you can access
7889 7889 via
7890 7890 \layout LyX-Code
7891 7891
7892 7892 from IPython import demo
7893 7893 \layout LyX-Code
7894 7894
7895 7895 demo?
7896 7896 \layout Standard
7897 7897
7898 7898
7899 7899 \series bold
7900 7900 Limitations:
7901 7901 \series default
7902 7902 It is important to note that these demos are limited to fairly simple uses.
7903 7903 In particular, you can
7904 7904 \emph on
7905 7905 not
7906 7906 \emph default
7907 7907 put division marks in indented code (loops, if statements, function definitions
7908 7908 , etc.) Supporting something like this would basically require tracking the
7909 7909 internal execution state of the Python interpreter, so only top-level divisions
7910 7910 are allowed.
7911 7911 If you want to be able to open an IPython instance at an arbitrary point
7912 7912 in a program, you can use IPython's embedding facilities, described in
7913 7913 detail in Sec\SpecialChar \@.
7914 7914 \SpecialChar ~
7915 7915
7916 7916 \begin_inset LatexCommand \ref{sec:embed}
7917 7917
7918 7918 \end_inset
7919 7919
7920 7920 .
7921 7921 \layout Section
7922 7922
7923 7923
7924 7924 \begin_inset LatexCommand \label{sec:matplotlib-support}
7925 7925
7926 7926 \end_inset
7927 7927
7928 7928 Plotting with
7929 7929 \family typewriter
7930 7930 matplotlib
7931 7931 \family default
7932 7932
7933 7933 \layout Standard
7934 7934
7935 7935 The matplotlib library (
7936 7936 \begin_inset LatexCommand \htmlurl[http://matplotlib.sourceforge.net]{http://matplotlib.sourceforge.net}
7937 7937
7938 7938 \end_inset
7939 7939
7940 7940 ) provides high quality 2D plotting for Python.
7941 7941 Matplotlib can produce plots on screen using a variety of GUI toolkits,
7942 7942 including Tk, GTK and WXPython.
7943 7943 It also provides a number of commands useful for scientific computing,
7944 7944 all with a syntax compatible with that of the popular Matlab program.
7945 7945 \layout Standard
7946 7946
7947 7947 IPython accepts the special option
7948 7948 \family typewriter
7949 7949 -pylab
7950 7950 \family default
7951 7951 (Sec.\SpecialChar ~
7952 7952
7953 7953 \begin_inset LatexCommand \ref{sec:cmd-line-opts}
7954 7954
7955 7955 \end_inset
7956 7956
7957 7957 ).
7958 7958 This configures it to support matplotlib, honoring the settings in the
7959 7959
7960 7960 \family typewriter
7961 7961 .matplotlibrc
7962 7962 \family default
7963 7963 file.
7964 7964 IPython will detect the user's choice of matplotlib GUI backend, and automatica
7965 7965 lly select the proper threading model to prevent blocking.
7966 7966 It also sets matplotlib in interactive mode and modifies
7967 7967 \family typewriter
7968 7968 %run
7969 7969 \family default
7970 7970 slightly, so that any matplotlib-based script can be executed using
7971 7971 \family typewriter
7972 7972 %run
7973 7973 \family default
7974 7974 and the final
7975 7975 \family typewriter
7976 7976 show()
7977 7977 \family default
7978 7978 command does not block the interactive shell.
7979 7979 \layout Standard
7980 7980
7981 7981 The
7982 7982 \family typewriter
7983 7983 -pylab
7984 7984 \family default
7985 7985 option must be given first in order for IPython to configure its threading
7986 7986 mode.
7987 7987 However, you can still issue other options afterwards.
7988 7988 This allows you to have a matplotlib-based environment customized with
7989 7989 additional modules using the standard IPython profile mechanism (Sec.\SpecialChar ~
7990 7990
7991 7991 \begin_inset LatexCommand \ref{sec:profiles}
7992 7992
7993 7993 \end_inset
7994 7994
7995 7995 ): ``
7996 7996 \family typewriter
7997 7997 ipython -pylab -p myprofile
7998 7998 \family default
7999 7999 '' will load the profile defined in
8000 8000 \family typewriter
8001 8001 ipythonrc-myprofile
8002 8002 \family default
8003 8003 after configuring matplotlib.
8004 8004 \layout Section
8005 8005
8006 8006
8007 8007 \begin_inset LatexCommand \label{sec:Gnuplot}
8008 8008
8009 8009 \end_inset
8010 8010
8011 8011 Plotting with
8012 8012 \family typewriter
8013 8013 Gnuplot
8014 8014 \layout Standard
8015 8015
8016 8016 Through the magic extension system described in sec.
8017 8017
8018 8018 \begin_inset LatexCommand \ref{sec:magic}
8019 8019
8020 8020 \end_inset
8021 8021
8022 8022 , IPython incorporates a mechanism for conveniently interfacing with the
8023 8023 Gnuplot system (
8024 8024 \begin_inset LatexCommand \htmlurl{http://www.gnuplot.info}
8025 8025
8026 8026 \end_inset
8027 8027
8028 8028 ).
8029 8029 Gnuplot is a very complete 2D and 3D plotting package available for many
8030 8030 operating systems and commonly included in modern Linux distributions.
8031 8031
8032 8032 \layout Standard
8033 8033
8034 8034 Besides having Gnuplot installed, this functionality requires the
8035 8035 \family typewriter
8036 8036 Gnuplot.py
8037 8037 \family default
8038 8038 module for interfacing python with Gnuplot.
8039 8039 It can be downloaded from:
8040 8040 \begin_inset LatexCommand \htmlurl{http://gnuplot-py.sourceforge.net}
8041 8041
8042 8042 \end_inset
8043 8043
8044 8044 .
8045 8045 \layout Subsection
8046 8046
8047 8047 Proper Gnuplot configuration
8048 8048 \layout Standard
8049 8049
8050 8050 As of version 4.0, Gnuplot has excellent mouse and interactive keyboard support.
8051 8051 However, as of
8052 8052 \family typewriter
8053 8053 Gnuplot.py
8054 8054 \family default
8055 8055 version 1.7, a new option was added to communicate between Python and Gnuplot
8056 8056 via FIFOs (pipes).
8057 8057 This mechanism, while fast, also breaks the mouse system.
8058 8058 You must therefore set the variable
8059 8059 \family typewriter
8060 8060 prefer_fifo_data
8061 8061 \family default
8062 8062 to
8063 8063 \family typewriter
8064 8064 0
8065 8065 \family default
8066 8066 in file
8067 8067 \family typewriter
8068 8068 gp_unix.py
8069 8069 \family default
8070 8070 if you wish to keep the interactive mouse and keyboard features working
8071 8071 properly (
8072 8072 \family typewriter
8073 8073 prefer_inline_data
8074 8074 \family default
8075 8075 also must be
8076 8076 \family typewriter
8077 8077 0
8078 8078 \family default
8079 8079 , but this is the default so unless you've changed it manually you should
8080 8080 be fine).
8081 8081 \layout Standard
8082 8082
8083 8083 'Out of the box', Gnuplot is configured with a rather poor set of size,
8084 8084 color and linewidth choices which make the graphs fairly hard to read on
8085 8085 modern high-resolution displays (although they work fine on old 640x480
8086 8086 ones).
8087 8087 Below is a section of my
8088 8088 \family typewriter
8089 8089 .Xdefaults
8090 8090 \family default
8091 8091 file which I use for having a more convenient Gnuplot setup.
8092 8092 Remember to load it by running
8093 8093 \family typewriter
8094 8094 `xrdb .Xdefaults`
8095 8095 \family default
8096 8096 :
8097 8097 \layout Standard
8098 8098
8099 8099
8100 8100 \family typewriter
8101 8101 !******************************************************************
8102 8102 \newline
8103 8103 ! gnuplot options
8104 8104 \newline
8105 8105 ! modify this for a convenient window size
8106 8106 \newline
8107 8107 gnuplot*geometry: 780x580
8108 8108 \layout Standard
8109 8109
8110 8110
8111 8111 \family typewriter
8112 8112 ! on-screen font (not for PostScript)
8113 8113 \newline
8114 8114 gnuplot*font: -misc-fixed-bold-r-normal--15-120-100-100-c-90-iso8859-1
8115 8115 \layout Standard
8116 8116
8117 8117
8118 8118 \family typewriter
8119 8119 ! color options
8120 8120 \newline
8121 8121 gnuplot*background: black
8122 8122 \newline
8123 8123 gnuplot*textColor: white
8124 8124 \newline
8125 8125 gnuplot*borderColor: white
8126 8126 \newline
8127 8127 gnuplot*axisColor: white
8128 8128 \newline
8129 8129 gnuplot*line1Color: red
8130 8130 \newline
8131 8131 gnuplot*line2Color: green
8132 8132 \newline
8133 8133 gnuplot*line3Color: blue
8134 8134 \newline
8135 8135 gnuplot*line4Color: magenta
8136 8136 \newline
8137 8137 gnuplot*line5Color: cyan
8138 8138 \newline
8139 8139 gnuplot*line6Color: sienna
8140 8140 \newline
8141 8141 gnuplot*line7Color: orange
8142 8142 \newline
8143 8143 gnuplot*line8Color: coral
8144 8144 \layout Standard
8145 8145
8146 8146
8147 8147 \family typewriter
8148 8148 ! multiplicative factor for point styles
8149 8149 \newline
8150 8150 gnuplot*pointsize: 2
8151 8151 \layout Standard
8152 8152
8153 8153
8154 8154 \family typewriter
8155 8155 ! line width options (in pixels)
8156 8156 \newline
8157 8157 gnuplot*borderWidth: 2
8158 8158 \newline
8159 8159 gnuplot*axisWidth: 2
8160 8160 \newline
8161 8161 gnuplot*line1Width: 2
8162 8162 \newline
8163 8163 gnuplot*line2Width: 2
8164 8164 \newline
8165 8165 gnuplot*line3Width: 2
8166 8166 \newline
8167 8167 gnuplot*line4Width: 2
8168 8168 \newline
8169 8169 gnuplot*line5Width: 2
8170 8170 \newline
8171 8171 gnuplot*line6Width: 2
8172 8172 \newline
8173 8173 gnuplot*line7Width: 2
8174 8174 \newline
8175 8175 gnuplot*line8Width: 2
8176 8176 \layout Subsection
8177 8177
8178 8178 The
8179 8179 \family typewriter
8180 8180 IPython.GnuplotRuntime
8181 8181 \family default
8182 8182 module
8183 8183 \layout Standard
8184 8184
8185 8185 IPython includes a module called
8186 8186 \family typewriter
8187 8187 Gnuplot2.py
8188 8188 \family default
8189 8189 which extends and improves the default
8190 8190 \family typewriter
8191 8191 Gnuplot
8192 8192 \family default
8193 8193 .
8194 8194 \family typewriter
8195 8195 py
8196 8196 \family default
8197 8197 (which it still relies upon).
8198 8198 For example, the new
8199 8199 \family typewriter
8200 8200 plot
8201 8201 \family default
8202 8202 function adds several improvements to the original making it more convenient
8203 8203 for interactive use, and
8204 8204 \family typewriter
8205 8205 hardcopy
8206 8206 \family default
8207 8207 fixes a bug in the original which under some circumstances blocks the creation
8208 8208 of PostScript output.
8209 8209 \layout Standard
8210 8210
8211 8211 For scripting use,
8212 8212 \family typewriter
8213 8213 GnuplotRuntime.py
8214 8214 \family default
8215 8215 is provided, which wraps
8216 8216 \family typewriter
8217 8217 Gnuplot2.py
8218 8218 \family default
8219 8219 and creates a series of global aliases.
8220 8220 These make it easy to control Gnuplot plotting jobs through the Python
8221 8221 language.
8222 8222 \layout Standard
8223 8223
8224 8224 Below is some example code which illustrates how to configure Gnuplot inside
8225 8225 your own programs but have it available for further interactive use through
8226 8226 an embedded IPython instance.
8227 8227 Simply run this file at a system prompt.
8228 8228 This file is provided as
8229 8229 \family typewriter
8230 8230 example-gnuplot.py
8231 8231 \family default
8232 8232 in the examples directory:
8233 8233 \layout Standard
8234 8234
8235 8235
8236 8236 \begin_inset ERT
8237 8237 status Open
8238 8238
8239 8239 \layout Standard
8240 8240
8241 8241 \backslash
8242 8242 codelist{examples/example-gnuplot.py}
8243 8243 \end_inset
8244 8244
8245 8245
8246 8246 \layout Subsection
8247 8247
8248 8248 The
8249 8249 \family typewriter
8250 8250 numeric
8251 8251 \family default
8252 8252 profile: a scientific computing environment
8253 8253 \layout Standard
8254 8254
8255 8255 The
8256 8256 \family typewriter
8257 8257 numeric
8258 8258 \family default
8259 8259 IPython profile, which you can activate with
8260 8260 \family typewriter
8261 8261 `ipython -p numeric
8262 8262 \family default
8263 8263 ' will automatically load the IPython Gnuplot extensions (plus Numeric and
8264 8264 other useful things for numerical computing), contained in the
8265 8265 \family typewriter
8266 8266 IPython.GnuplotInteractive
8267 8267 \family default
8268 8268 module.
8269 8269 This will create the globals
8270 8270 \family typewriter
8271 8271 Gnuplot
8272 8272 \family default
8273 8273 (an alias to the improved Gnuplot2 module),
8274 8274 \family typewriter
8275 8275 gp
8276 8276 \family default
8277 8277 (a Gnuplot active instance), the new magic commands
8278 8278 \family typewriter
8279 8279 %gpc
8280 8280 \family default
8281 8281 and
8282 8282 \family typewriter
8283 8283 %gp_set_instance
8284 8284 \family default
8285 8285 and several other convenient globals.
8286 8286 Type
8287 8287 \family typewriter
8288 8288 gphelp()
8289 8289 \family default
8290 8290 for further details.
8291 8291 \layout Standard
8292 8292
8293 8293 This should turn IPython into a convenient environment for numerical computing,
8294 8294 with all the functions in the NumPy library and the Gnuplot facilities
8295 8295 for plotting.
8296 8296 Further improvements can be obtained by loading the SciPy libraries for
8297 8297 scientific computing, available at
8298 8298 \begin_inset LatexCommand \htmlurl{http://scipy.org}
8299 8299
8300 8300 \end_inset
8301 8301
8302 8302 .
8303 8303 \layout Standard
8304 8304
8305 8305 If you are in the middle of a working session with numerical objects and
8306 8306 need to plot them but you didn't start the
8307 8307 \family typewriter
8308 8308 numeric
8309 8309 \family default
8310 8310 profile, you can load these extensions at any time by typing
8311 8311 \newline
8312 8312
8313 8313 \family typewriter
8314 8314 from IPython.GnuplotInteractive import *
8315 8315 \newline
8316 8316
8317 8317 \family default
8318 8318 at the IPython prompt.
8319 8319 This will allow you to keep your objects intact and start using Gnuplot
8320 8320 to view them.
8321 8321 \layout Section
8322 8322
8323 8323 Reporting bugs
8324 8324 \layout Subsection*
8325 8325
8326 8326 Automatic crash reports
8327 8327 \layout Standard
8328 8328
8329 8329 Ideally, IPython itself shouldn't crash.
8330 8330 It will catch exceptions produced by you, but bugs in its internals will
8331 8331 still crash it.
8332 8332 \layout Standard
8333 8333
8334 8334 In such a situation, IPython will leave a file named
8335 8335 \family typewriter
8336 8336 IPython_crash_report.txt
8337 8337 \family default
8338 8338 in your IPYTHONDIR directory (that way if crashes happen several times
8339 8339 it won't litter many directories, the post-mortem file is always located
8340 8340 in the same place and new occurrences just overwrite the previous one).
8341 8341 If you can mail this file to the developers (see sec.
8342 8342
8343 8343 \begin_inset LatexCommand \ref{sec:credits}
8344 8344
8345 8345 \end_inset
8346 8346
8347 8347 for names and addresses), it will help us
8348 8348 \emph on
8349 8349 a lot
8350 8350 \emph default
8351 8351 in understanding the cause of the problem and fixing it sooner.
8352 8352 \layout Subsection*
8353 8353
8354 8354 The bug tracker
8355 8355 \layout Standard
8356 8356
8357 8357 IPython also has an online bug-tracker, located at
8358 8358 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython}
8359 8359
8360 8360 \end_inset
8361 8361
8362 8362 .
8363 8363 In addition to mailing the developers, it would be a good idea to file
8364 8364 a bug report here.
8365 8365 This will ensure that the issue is properly followed to conclusion.
8366 8366 \layout Standard
8367 8367
8368 8368 You can also use this bug tracker to file feature requests.
8369 8369 \layout Section
8370 8370
8371 8371 Brief history
8372 8372 \layout Subsection
8373 8373
8374 8374 Origins
8375 8375 \layout Standard
8376 8376
8377 8377 The current IPython system grew out of the following three projects:
8378 8378 \layout List
8379 8379 \labelwidthstring 00.00.0000
8380 8380
8381 8381 ipython by Fernando Pérez.
8382 8382 I was working on adding Mathematica-type prompts and a flexible configuration
8383 8383 system (something better than
8384 8384 \family typewriter
8385 8385 $PYTHONSTARTUP
8386 8386 \family default
8387 8387 ) to the standard Python interactive interpreter.
8388 8388 \layout List
8389 8389 \labelwidthstring 00.00.0000
8390 8390
8391 8391 IPP by Janko Hauser.
8392 8392 Very well organized, great usability.
8393 8393 Had an old help system.
8394 8394 IPP was used as the `container' code into which I added the functionality
8395 8395 from ipython and LazyPython.
8396 8396 \layout List
8397 8397 \labelwidthstring 00.00.0000
8398 8398
8399 8399 LazyPython by Nathan Gray.
8400 8400 Simple but
8401 8401 \emph on
8402 8402 very
8403 8403 \emph default
8404 8404 powerful.
8405 8405 The quick syntax (auto parens, auto quotes) and verbose/colored tracebacks
8406 8406 were all taken from here.
8407 8407 \layout Standard
8408 8408
8409 8409 When I found out (see sec.
8410 8410
8411 8411 \begin_inset LatexCommand \ref{figgins}
8412 8412
8413 8413 \end_inset
8414 8414
8415 8415 ) about IPP and LazyPython I tried to join all three into a unified system.
8416 8416 I thought this could provide a very nice working environment, both for
8417 8417 regular programming and scientific computing: shell-like features, IDL/Matlab
8418 8418 numerics, Mathematica-type prompt history and great object introspection
8419 8419 and help facilities.
8420 8420 I think it worked reasonably well, though it was a lot more work than I
8421 8421 had initially planned.
8422 8422 \layout Subsection
8423 8423
8424 8424 Current status
8425 8425 \layout Standard
8426 8426
8427 8427 The above listed features work, and quite well for the most part.
8428 8428 But until a major internal restructuring is done (see below), only bug
8429 8429 fixing will be done, no other features will be added (unless very minor
8430 8430 and well localized in the cleaner parts of the code).
8431 8431 \layout Standard
8432 8432
8433 8433 IPython consists of some 12000 lines of pure python code, of which roughly
8434 8434 50% are fairly clean.
8435 8435 The other 50% are fragile, messy code which needs a massive restructuring
8436 8436 before any further major work is done.
8437 8437 Even the messy code is fairly well documented though, and most of the problems
8438 8438 in the (non-existent) class design are well pointed to by a PyChecker run.
8439 8439 So the rewriting work isn't that bad, it will just be time-consuming.
8440 8440 \layout Subsection
8441 8441
8442 8442 Future
8443 8443 \layout Standard
8444 8444
8445 8445 See the separate
8446 8446 \family typewriter
8447 8447 new_design
8448 8448 \family default
8449 8449 document for details.
8450 8450 Ultimately, I would like to see IPython become part of the standard Python
8451 8451 distribution as a `big brother with batteries' to the standard Python interacti
8452 8452 ve interpreter.
8453 8453 But that will never happen with the current state of the code, so all contribut
8454 8454 ions are welcome.
8455 8455 \layout Section
8456 8456
8457 8457 License
8458 8458 \layout Standard
8459 8459
8460 8460 IPython is released under the terms of the BSD license, whose general form
8461 8461 can be found at:
8462 8462 \begin_inset LatexCommand \htmlurl{http://www.opensource.org/licenses/bsd-license.php}
8463 8463
8464 8464 \end_inset
8465 8465
8466 8466 .
8467 8467 The full text of the IPython license is reproduced below:
8468 8468 \layout Quote
8469 8469
8470 8470
8471 8471 \family typewriter
8472 8472 \size small
8473 8473 IPython is released under a BSD-type license.
8474 8474 \layout Quote
8475 8475
8476 8476
8477 8477 \family typewriter
8478 8478 \size small
8479 8479 Copyright (c) 2001, 2002, 2003, 2004 Fernando Perez <fperez@colorado.edu>.
8480 8480 \layout Quote
8481 8481
8482 8482
8483 8483 \family typewriter
8484 8484 \size small
8485 8485 Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and
8486 8486 \newline
8487 8487 Nathaniel Gray <n8gray@caltech.edu>.
8488 8488 \layout Quote
8489 8489
8490 8490
8491 8491 \family typewriter
8492 8492 \size small
8493 8493 All rights reserved.
8494 8494 \layout Quote
8495 8495
8496 8496
8497 8497 \family typewriter
8498 8498 \size small
8499 8499 Redistribution and use in source and binary forms, with or without modification,
8500 8500 are permitted provided that the following conditions are met:
8501 8501 \layout Quote
8502 8502
8503 8503
8504 8504 \family typewriter
8505 8505 \size small
8506 8506 a.
8507 8507 Redistributions of source code must retain the above copyright notice,
8508 8508 this list of conditions and the following disclaimer.
8509 8509 \layout Quote
8510 8510
8511 8511
8512 8512 \family typewriter
8513 8513 \size small
8514 8514 b.
8515 8515 Redistributions in binary form must reproduce the above copyright notice,
8516 8516 this list of conditions and the following disclaimer in the documentation
8517 8517 and/or other materials provided with the distribution.
8518 8518 \layout Quote
8519 8519
8520 8520
8521 8521 \family typewriter
8522 8522 \size small
8523 8523 c.
8524 8524 Neither the name of the copyright holders nor the names of any contributors
8525 8525 to this software may be used to endorse or promote products derived from
8526 8526 this software without specific prior written permission.
8527 8527 \layout Quote
8528 8528
8529 8529
8530 8530 \family typewriter
8531 8531 \size small
8532 8532 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
8533 8533 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
8534 8534 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
8535 8535 PURPOSE ARE DISCLAIMED.
8536 8536 IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
8537 8537 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
8538 8538 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
8539 8539 USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
8540 8540 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
8541 8541 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
8542 8542 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8543 8543
8544 8544 \layout Standard
8545 8545
8546 8546 Individual authors are the holders of the copyright for their code and are
8547 8547 listed in each file.
8548 8548 \layout Standard
8549 8549
8550 8550 Some files (
8551 8551 \family typewriter
8552 8552 DPyGetOpt.py
8553 8553 \family default
8554 8554 , for example) may be licensed under different conditions.
8555 8555 Ultimately each file indicates clearly the conditions under which its author/au
8556 8556 thors have decided to publish the code.
8557 8557 \layout Standard
8558 8558
8559 8559 Versions of IPython up to and including 0.6.3 were released under the GNU
8560 8560 Lesser General Public License (LGPL), available at
8561 8561 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/copyleft/lesser.html}
8562 8562
8563 8563 \end_inset
8564 8564
8565 8565 .
8566 8566 \layout Section
8567 8567
8568 8568
8569 8569 \begin_inset LatexCommand \label{sec:credits}
8570 8570
8571 8571 \end_inset
8572 8572
8573 8573 Credits
8574 8574 \layout Standard
8575 8575
8576 8576 IPython is mainly developed by Fernando Pérez
8577 8577 \family typewriter
8578 8578 <fperez@colorado.edu>
8579 8579 \family default
8580 8580 , but the project was born from mixing in Fernando's code with the IPP project
8581 8581 by Janko Hauser
8582 8582 \family typewriter
8583 8583 <jhauser-AT-zscout.de>
8584 8584 \family default
8585 8585 and LazyPython by Nathan Gray
8586 8586 \family typewriter
8587 8587 <n8gray-AT-caltech.edu>
8588 8588 \family default
8589 8589 .
8590 8590 For all IPython-related requests, please contact Fernando.
8591 8591
8592 8592 \layout Standard
8593 8593
8594 8594 As of late 2005, the following developers have joined the core team:
8595 8595 \layout List
8596 8596 \labelwidthstring 00.00.0000
8597 8597
8598 8598 Robert\SpecialChar ~
8599 8599 Kern
8600 8600 \family typewriter
8601 8601 <rkern-AT-enthought.com>
8602 8602 \family default
8603 8603 : co-mentored the 2005 Google Summer of Code project to develop python interacti
8604 8604 ve notebooks (XML documents) and graphical interface.
8605 8605 This project was awarded to the students Tzanko Matev
8606 8606 \family typewriter
8607 8607 <tsanko-AT-gmail.com>
8608 8608 \family default
8609 8609 and Toni Alatalo
8610 8610 \family typewriter
8611 8611 <antont-AT-an.org>
8612 8612 \layout List
8613 8613 \labelwidthstring 00.00.0000
8614 8614
8615 8615 Brian\SpecialChar ~
8616 8616 Granger
8617 8617 \family typewriter
8618 8618 <bgranger-AT-scu.edu>
8619 8619 \family default
8620 8620 : extending IPython to allow support for interactive parallel computing.
8621 8621 \layout Standard
8622 8622
8623 8623 User or development help should be requested via the IPython mailing lists:
8624 8624 \layout Description
8625 8625
8626 8626 User\SpecialChar ~
8627 8627 list:
8628 8628 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-user}
8629 8629
8630 8630 \end_inset
8631 8631
8632 8632
8633 8633 \layout Description
8634 8634
8635 8635 Developer's\SpecialChar ~
8636 8636 list:
8637 8637 \begin_inset LatexCommand \htmlurl{http://scipy.net/mailman/listinfo/ipython-dev}
8638 8638
8639 8639 \end_inset
8640 8640
8641 8641
8642 8642 \layout Standard
8643 8643
8644 8644 The IPython project is also very grateful to
8645 8645 \begin_inset Foot
8646 8646 collapsed true
8647 8647
8648 8648 \layout Standard
8649 8649
8650 8650 I've mangled email addresses to reduce spam, since the IPython manuals can
8651 8651 be accessed online.
8652 8652 \end_inset
8653 8653
8654 8654 :
8655 8655 \layout Standard
8656 8656
8657 8657 Bill Bumgarner
8658 8658 \family typewriter
8659 8659 <bbum-AT-friday.com>
8660 8660 \family default
8661 8661 : for providing the DPyGetOpt module which gives very powerful and convenient
8662 8662 handling of command-line options (light years ahead of what Python 2.1.1's
8663 8663 getopt module does).
8664 8664 \layout Standard
8665 8665
8666 8666 Ka-Ping Yee
8667 8667 \family typewriter
8668 8668 <ping-AT-lfw.org>
8669 8669 \family default
8670 8670 : for providing the Itpl module for convenient and powerful string interpolation
8671 8671 with a much nicer syntax than formatting through the '%' operator.
8672 8672 \layout Standard
8673 8673
8674 8674 Arnd Bäcker
8675 8675 \family typewriter
8676 8676 <baecker-AT-physik.tu-dresden.de>
8677 8677 \family default
8678 8678 : for his many very useful suggestions and comments, and lots of help with
8679 8679 testing and documentation checking.
8680 8680 Many of IPython's newer features are a result of discussions with him (bugs
8681 8681 are still my fault, not his).
8682 8682 \layout Standard
8683 8683
8684 8684 Obviously Guido van\SpecialChar ~
8685 8685 Rossum and the whole Python development team, that goes
8686 8686 without saying.
8687 8687 \layout Standard
8688 8688
8689 8689 IPython's website is generously hosted at
8690 8690 \begin_inset LatexCommand \htmlurl{http://ipython.scipy.org}
8691 8691
8692 8692 \end_inset
8693 8693
8694 8694 by Enthought (
8695 8695 \begin_inset LatexCommand \htmlurl{http://www.enthought.com}
8696 8696
8697 8697 \end_inset
8698 8698
8699 8699 ).
8700 8700 I am very grateful to them and all of the SciPy team for their contribution.
8701 8701 \layout Standard
8702 8702
8703 8703
8704 8704 \begin_inset LatexCommand \label{figgins}
8705 8705
8706 8706 \end_inset
8707 8707
8708 8708 Fernando would also like to thank Stephen Figgins
8709 8709 \family typewriter
8710 8710 <fig-AT-monitor.net>
8711 8711 \family default
8712 8712 , an O'Reilly Python editor.
8713 8713 His Oct/11/2001 article about IPP and LazyPython, was what got this project
8714 8714 started.
8715 8715 You can read it at:
8716 8716 \begin_inset LatexCommand \htmlurl{http://www.onlamp.com/pub/a/python/2001/10/11/pythonnews.html}
8717 8717
8718 8718 \end_inset
8719 8719
8720 8720 .
8721 8721 \layout Standard
8722 8722
8723 8723 And last but not least, all the kind IPython users who have emailed new
8724 8724 code, bug reports, fixes, comments and ideas.
8725 8725 A brief list follows, please let me know if I have ommitted your name by
8726 8726 accident:
8727 8727 \layout List
8728 8728 \labelwidthstring 00.00.0000
8729 8729
8730 8730 Jack\SpecialChar ~
8731 8731 Moffit
8732 8732 \family typewriter
8733 8733 <jack-AT-xiph.org>
8734 8734 \family default
8735 8735 Bug fixes, including the infamous color problem.
8736 8736 This bug alone caused many lost hours and frustration, many thanks to him
8737 8737 for the fix.
8738 8738 I've always been a fan of Ogg & friends, now I have one more reason to
8739 8739 like these folks.
8740 8740 \newline
8741 8741 Jack is also contributing with Debian packaging and many other things.
8742 8742 \layout List
8743 8743 \labelwidthstring 00.00.0000
8744 8744
8745 8745 Alexander\SpecialChar ~
8746 8746 Schmolck
8747 8747 \family typewriter
8748 8748 <a.schmolck-AT-gmx.net>
8749 8749 \family default
8750 8750 Emacs work, bug reports, bug fixes, ideas, lots more.
8751 8751 The ipython.el mode for (X)Emacs is Alex's code, providing full support
8752 8752 for IPython under (X)Emacs.
8753 8753 \layout List
8754 8754 \labelwidthstring 00.00.0000
8755 8755
8756 8756 Andrea\SpecialChar ~
8757 8757 Riciputi
8758 8758 \family typewriter
8759 8759 <andrea.riciputi-AT-libero.it>
8760 8760 \family default
8761 8761 Mac OSX information, Fink package management.
8762 8762 \layout List
8763 8763 \labelwidthstring 00.00.0000
8764 8764
8765 8765 Gary\SpecialChar ~
8766 8766 Bishop
8767 8767 \family typewriter
8768 8768 <gb-AT-cs.unc.edu>
8769 8769 \family default
8770 8770 Bug reports, and patches to work around the exception handling idiosyncracies
8771 8771 of WxPython.
8772 8772 Readline and color support for Windows.
8773 8773 \layout List
8774 8774 \labelwidthstring 00.00.0000
8775 8775
8776 8776 Jeffrey\SpecialChar ~
8777 8777 Collins
8778 8778 \family typewriter
8779 8779 <Jeff.Collins-AT-vexcel.com>
8780 8780 \family default
8781 8781 Bug reports.
8782 8782 Much improved readline support, including fixes for Python 2.3.
8783 8783 \layout List
8784 8784 \labelwidthstring 00.00.0000
8785 8785
8786 8786 Dryice\SpecialChar ~
8787 8787 Liu
8788 8788 \family typewriter
8789 8789 <dryice-AT-liu.com.cn>
8790 8790 \family default
8791 8791 FreeBSD port.
8792 8792 \layout List
8793 8793 \labelwidthstring 00.00.0000
8794 8794
8795 8795 Mike\SpecialChar ~
8796 8796 Heeter
8797 8797 \family typewriter
8798 8798 <korora-AT-SDF.LONESTAR.ORG>
8799 8799 \layout List
8800 8800 \labelwidthstring 00.00.0000
8801 8801
8802 8802 Christopher\SpecialChar ~
8803 8803 Hart
8804 8804 \family typewriter
8805 8805 <hart-AT-caltech.edu>
8806 8806 \family default
8807 8807 PDB integration.
8808 8808 \layout List
8809 8809 \labelwidthstring 00.00.0000
8810 8810
8811 8811 Milan\SpecialChar ~
8812 8812 Zamazal
8813 8813 \family typewriter
8814 8814 <pdm-AT-zamazal.org>
8815 8815 \family default
8816 8816 Emacs info.
8817 8817 \layout List
8818 8818 \labelwidthstring 00.00.0000
8819 8819
8820 8820 Philip\SpecialChar ~
8821 8821 Hisley
8822 8822 \family typewriter
8823 8823 <compsys-AT-starpower.net>
8824 8824 \layout List
8825 8825 \labelwidthstring 00.00.0000
8826 8826
8827 8827 Holger\SpecialChar ~
8828 8828 Krekel
8829 8829 \family typewriter
8830 8830 <pyth-AT-devel.trillke.net>
8831 8831 \family default
8832 8832 Tab completion, lots more.
8833 8833 \layout List
8834 8834 \labelwidthstring 00.00.0000
8835 8835
8836 8836 Robin\SpecialChar ~
8837 8837 Siebler
8838 8838 \family typewriter
8839 8839 <robinsiebler-AT-starband.net>
8840 8840 \layout List
8841 8841 \labelwidthstring 00.00.0000
8842 8842
8843 8843 Ralf\SpecialChar ~
8844 8844 Ahlbrink
8845 8845 \family typewriter
8846 8846 <ralf_ahlbrink-AT-web.de>
8847 8847 \layout List
8848 8848 \labelwidthstring 00.00.0000
8849 8849
8850 8850 Thorsten\SpecialChar ~
8851 8851 Kampe
8852 8852 \family typewriter
8853 8853 <thorsten-AT-thorstenkampe.de>
8854 8854 \layout List
8855 8855 \labelwidthstring 00.00.0000
8856 8856
8857 8857 Fredrik\SpecialChar ~
8858 8858 Kant
8859 8859 \family typewriter
8860 8860 <fredrik.kant-AT-front.com>
8861 8861 \family default
8862 8862 Windows setup.
8863 8863 \layout List
8864 8864 \labelwidthstring 00.00.0000
8865 8865
8866 8866 Syver\SpecialChar ~
8867 8867 Enstad
8868 8868 \family typewriter
8869 8869 <syver-en-AT-online.no>
8870 8870 \family default
8871 8871 Windows setup.
8872 8872 \layout List
8873 8873 \labelwidthstring 00.00.0000
8874 8874
8875 8875 Richard
8876 8876 \family typewriter
8877 8877 <rxe-AT-renre-europe.com>
8878 8878 \family default
8879 8879 Global embedding.
8880 8880 \layout List
8881 8881 \labelwidthstring 00.00.0000
8882 8882
8883 8883 Hayden\SpecialChar ~
8884 8884 Callow
8885 8885 \family typewriter
8886 8886 <h.callow-AT-elec.canterbury.ac.nz>
8887 8887 \family default
8888 8888 Gnuplot.py 1.6 compatibility.
8889 8889 \layout List
8890 8890 \labelwidthstring 00.00.0000
8891 8891
8892 8892 Leonardo\SpecialChar ~
8893 8893 Santagada
8894 8894 \family typewriter
8895 8895 <retype-AT-terra.com.br>
8896 8896 \family default
8897 8897 Fixes for Windows installation.
8898 8898 \layout List
8899 8899 \labelwidthstring 00.00.0000
8900 8900
8901 8901 Christopher\SpecialChar ~
8902 8902 Armstrong
8903 8903 \family typewriter
8904 8904 <radix-AT-twistedmatrix.com>
8905 8905 \family default
8906 8906 Bugfixes.
8907 8907 \layout List
8908 8908 \labelwidthstring 00.00.0000
8909 8909
8910 8910 Francois\SpecialChar ~
8911 8911 Pinard
8912 8912 \family typewriter
8913 8913 <pinard-AT-iro.umontreal.ca>
8914 8914 \family default
8915 8915 Code and documentation fixes.
8916 8916 \layout List
8917 8917 \labelwidthstring 00.00.0000
8918 8918
8919 8919 Cory\SpecialChar ~
8920 8920 Dodt
8921 8921 \family typewriter
8922 8922 <cdodt-AT-fcoe.k12.ca.us>
8923 8923 \family default
8924 8924 Bug reports and Windows ideas.
8925 8925 Patches for Windows installer.
8926 8926 \layout List
8927 8927 \labelwidthstring 00.00.0000
8928 8928
8929 8929 Olivier\SpecialChar ~
8930 8930 Aubert
8931 8931 \family typewriter
8932 8932 <oaubert-AT-bat710.univ-lyon1.fr>
8933 8933 \family default
8934 8934 New magics.
8935 8935 \layout List
8936 8936 \labelwidthstring 00.00.0000
8937 8937
8938 8938 King\SpecialChar ~
8939 8939 C.\SpecialChar ~
8940 8940 Shu
8941 8941 \family typewriter
8942 8942 <kingshu-AT-myrealbox.com>
8943 8943 \family default
8944 8944 Autoindent patch.
8945 8945 \layout List
8946 8946 \labelwidthstring 00.00.0000
8947 8947
8948 8948 Chris\SpecialChar ~
8949 8949 Drexler
8950 8950 \family typewriter
8951 8951 <chris-AT-ac-drexler.de>
8952 8952 \family default
8953 8953 Readline packages for Win32/CygWin.
8954 8954 \layout List
8955 8955 \labelwidthstring 00.00.0000
8956 8956
8957 8957 Gustavo\SpecialChar ~
8958 8958 Córdova\SpecialChar ~
8959 8959 Avila
8960 8960 \family typewriter
8961 8961 <gcordova-AT-sismex.com>
8962 8962 \family default
8963 8963 EvalDict code for nice, lightweight string interpolation.
8964 8964 \layout List
8965 8965 \labelwidthstring 00.00.0000
8966 8966
8967 8967 Kasper\SpecialChar ~
8968 8968 Souren
8969 8969 \family typewriter
8970 8970 <Kasper.Souren-AT-ircam.fr>
8971 8971 \family default
8972 8972 Bug reports, ideas.
8973 8973 \layout List
8974 8974 \labelwidthstring 00.00.0000
8975 8975
8976 8976 Gever\SpecialChar ~
8977 8977 Tulley
8978 8978 \family typewriter
8979 8979 <gever-AT-helium.com>
8980 8980 \family default
8981 8981 Code contributions.
8982 8982 \layout List
8983 8983 \labelwidthstring 00.00.0000
8984 8984
8985 8985 Ralf\SpecialChar ~
8986 8986 Schmitt
8987 8987 \family typewriter
8988 8988 <ralf-AT-brainbot.com>
8989 8989 \family default
8990 8990 Bug reports & fixes.
8991 8991 \layout List
8992 8992 \labelwidthstring 00.00.0000
8993 8993
8994 8994 Oliver\SpecialChar ~
8995 8995 Sander
8996 8996 \family typewriter
8997 8997 <osander-AT-gmx.de>
8998 8998 \family default
8999 8999 Bug reports.
9000 9000 \layout List
9001 9001 \labelwidthstring 00.00.0000
9002 9002
9003 9003 Rod\SpecialChar ~
9004 9004 Holland
9005 9005 \family typewriter
9006 9006 <rhh-AT-structurelabs.com>
9007 9007 \family default
9008 9008 Bug reports and fixes to logging module.
9009 9009 \layout List
9010 9010 \labelwidthstring 00.00.0000
9011 9011
9012 9012 Daniel\SpecialChar ~
9013 9013 'Dang'\SpecialChar ~
9014 9014 Griffith
9015 9015 \family typewriter
9016 9016 <pythondev-dang-AT-lazytwinacres.net>
9017 9017 \family default
9018 9018 Fixes, enhancement suggestions for system shell use.
9019 9019 \layout List
9020 9020 \labelwidthstring 00.00.0000
9021 9021
9022 9022 Viktor\SpecialChar ~
9023 9023 Ransmayr
9024 9024 \family typewriter
9025 9025 <viktor.ransmayr-AT-t-online.de>
9026 9026 \family default
9027 9027 Tests and reports on Windows installation issues.
9028 9028 Contributed a true Windows binary installer.
9029 9029 \layout List
9030 9030 \labelwidthstring 00.00.0000
9031 9031
9032 9032 Mike\SpecialChar ~
9033 9033 Salib
9034 9034 \family typewriter
9035 9035 <msalib-AT-mit.edu>
9036 9036 \family default
9037 9037 Help fixing a subtle bug related to traceback printing.
9038 9038 \layout List
9039 9039 \labelwidthstring 00.00.0000
9040 9040
9041 9041 W.J.\SpecialChar ~
9042 9042 van\SpecialChar ~
9043 9043 der\SpecialChar ~
9044 9044 Laan
9045 9045 \family typewriter
9046 9046 <gnufnork-AT-hetdigitalegat.nl>
9047 9047 \family default
9048 9048 Bash-like prompt specials.
9049 9049 \layout List
9050 9050 \labelwidthstring 00.00.0000
9051 9051
9052 9052 Ville\SpecialChar ~
9053 9053 Vainio
9054 9054 \family typewriter
9055 9055 <vivainio-AT-kolumbus.fi>
9056 9056 \family default
9057 9057 Bugfixes and suggestions.
9058 9058 Excellent patches for many new features.
9059 9059 \layout List
9060 9060 \labelwidthstring 00.00.0000
9061 9061
9062 9062 Antoon\SpecialChar ~
9063 9063 Pardon
9064 9064 \family typewriter
9065 9065 <Antoon.Pardon-AT-rece.vub.ac.be>
9066 9066 \family default
9067 9067 Critical fix for the multithreaded IPython.
9068 9068 \layout List
9069 9069 \labelwidthstring 00.00.0000
9070 9070
9071 9071 John\SpecialChar ~
9072 9072 Hunter
9073 9073 \family typewriter
9074 9074 <jdhunter-AT-nitace.bsd.uchicago.edu>
9075 9075 \family default
9076 9076 Matplotlib author, helped with all the development of support for matplotlib
9077 9077 in IPyhton, including making necessary changes to matplotlib itself.
9078 9078 \layout List
9079 9079 \labelwidthstring 00.00.0000
9080 9080
9081 9081 Matthew\SpecialChar ~
9082 9082 Arnison
9083 9083 \family typewriter
9084 9084 <maffew-AT-cat.org.au>
9085 9085 \family default
9086 9086 Bug reports, `
9087 9087 \family typewriter
9088 9088 %run -d
9089 9089 \family default
9090 9090 ' idea.
9091 9091 \layout List
9092 9092 \labelwidthstring 00.00.0000
9093 9093
9094 9094 Prabhu\SpecialChar ~
9095 9095 Ramachandran
9096 9096 \family typewriter
9097 9097 <prabhu_r-AT-users.sourceforge.net>
9098 9098 \family default
9099 9099 Help with (X)Emacs support, threading patches, ideas...
9100 9100 \layout List
9101 9101 \labelwidthstring 00.00.0000
9102 9102
9103 9103 Norbert\SpecialChar ~
9104 9104 Tretkowski
9105 9105 \family typewriter
9106 9106 <tretkowski-AT-inittab.de>
9107 9107 \family default
9108 9108 help with Debian packaging and distribution.
9109 9109 \layout List
9110 9110 \labelwidthstring 00.00.0000
9111 9111
9112 9112 George\SpecialChar ~
9113 9113 Sakkis <
9114 9114 \family typewriter
9115 9115 gsakkis-AT-eden.rutgers.edu>
9116 9116 \family default
9117 9117 New matcher for tab-completing named arguments of user-defined functions.
9118 9118 \layout List
9119 9119 \labelwidthstring 00.00.0000
9120 9120
9121 9121 J�rgen\SpecialChar ~
9122 9122 Stenarson
9123 9123 \family typewriter
9124 9124 <jorgen.stenarson-AT-bostream.nu>
9125 9125 \family default
9126 9126 Wildcard support implementation for searching namespaces.
9127 9127 \layout List
9128 9128 \labelwidthstring 00.00.0000
9129 9129
9130 9130 Vivian\SpecialChar ~
9131 9131 De\SpecialChar ~
9132 9132 Smedt
9133 9133 \family typewriter
9134 9134 <vivian-AT-vdesmedt.com>
9135 9135 \family default
9136 9136 Debugger enhancements, so that when pdb is activated from within IPython,
9137 9137 coloring, tab completion and other features continue to work seamlessly.
9138 9138 \layout List
9139 9139 \labelwidthstring 00.00.0000
9140 9140
9141 9141 Scott\SpecialChar ~
9142 9142 Tsai
9143 9143 \family typewriter
9144 9144 <scottt958-AT-yahoo.com.tw>
9145 9145 \family default
9146 9146 Support for automatic editor invocation on syntax errors (see
9147 9147 \begin_inset LatexCommand \htmlurl{http://www.scipy.net/roundup/ipython/issue36}
9148 9148
9149 9149 \end_inset
9150 9150
9151 9151 ).
9152 \layout List
9153 \labelwidthstring 00.00.0000
9154
9155 Alexander\SpecialChar ~
9156 Belchenko
9157 \family typewriter
9158 <bialix-AT-ukr.net>
9159 \family default
9160 Improvements for win32 paging system.
9152 9161 \the_end
General Comments 0
You need to be logged in to leave comments. Login now