##// END OF EJS Templates
%cpaste now strips > from the beginning of lines, after a patch by ...
vivainio -
Show More
@@ -1,2988 +1,2990 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Magic functions for InteractiveShell.
3 3
4 $Id: Magic.py 1380 2006-06-27 11:34:39Z vivainio $"""
4 $Id: Magic.py 1386 2006-07-08 09:32:30Z vivainio $"""
5 5
6 6 #*****************************************************************************
7 7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
8 8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
9 9 #
10 10 # Distributed under the terms of the BSD License. The full license is in
11 11 # the file COPYING, distributed as part of this software.
12 12 #*****************************************************************************
13 13
14 14 #****************************************************************************
15 15 # Modules and globals
16 16
17 17 from IPython import Release
18 18 __author__ = '%s <%s>\n%s <%s>' % \
19 19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
20 20 __license__ = Release.license
21 21
22 22 # Python standard modules
23 23 import __builtin__
24 24 import bdb
25 25 import inspect
26 26 import os
27 27 import pdb
28 28 import pydoc
29 29 import shlex
30 30 import sys
31 31 import re
32 32 import tempfile
33 33 import time
34 34 import cPickle as pickle
35 35 import textwrap
36 36 from cStringIO import StringIO
37 37 from getopt import getopt,GetoptError
38 38 from pprint import pprint, pformat
39 39
40 40 # profile isn't bundled by default in Debian for license reasons
41 41 try:
42 42 import profile,pstats
43 43 except ImportError:
44 44 profile = pstats = None
45 45
46 46 # Homebrewed
47 47 import IPython
48 48 from IPython import Debugger, OInspect, wildcard
49 49 from IPython.FakeModule import FakeModule
50 50 from IPython.Itpl import Itpl, itpl, printpl,itplns
51 51 from IPython.PyColorize import Parser
52 52 from IPython.ipstruct import Struct
53 53 from IPython.macro import Macro
54 54 from IPython.genutils import *
55 55 from IPython import platutils
56 56
57 57 #***************************************************************************
58 58 # Utility functions
59 59 def on_off(tag):
60 60 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
61 61 return ['OFF','ON'][tag]
62 62
63 63 class Bunch: pass
64 64
65 65 #***************************************************************************
66 66 # Main class implementing Magic functionality
67 67 class Magic:
68 68 """Magic functions for InteractiveShell.
69 69
70 70 Shell functions which can be reached as %function_name. All magic
71 71 functions should accept a string, which they can parse for their own
72 72 needs. This can make some functions easier to type, eg `%cd ../`
73 73 vs. `%cd("../")`
74 74
75 75 ALL definitions MUST begin with the prefix magic_. The user won't need it
76 76 at the command line, but it is is needed in the definition. """
77 77
78 78 # class globals
79 79 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
80 80 'Automagic is ON, % prefix NOT needed for magic functions.']
81 81
82 82 #......................................................................
83 83 # some utility functions
84 84
85 85 def __init__(self,shell):
86 86
87 87 self.options_table = {}
88 88 if profile is None:
89 89 self.magic_prun = self.profile_missing_notice
90 90 self.shell = shell
91 91
92 92 # namespace for holding state we may need
93 93 self._magic_state = Bunch()
94 94
95 95 def profile_missing_notice(self, *args, **kwargs):
96 96 error("""\
97 97 The profile module could not be found. If you are a Debian user,
98 98 it has been removed from the standard Debian package because of its non-free
99 99 license. To use profiling, please install"python2.3-profiler" from non-free.""")
100 100
101 101 def default_option(self,fn,optstr):
102 102 """Make an entry in the options_table for fn, with value optstr"""
103 103
104 104 if fn not in self.lsmagic():
105 105 error("%s is not a magic function" % fn)
106 106 self.options_table[fn] = optstr
107 107
108 108 def lsmagic(self):
109 109 """Return a list of currently available magic functions.
110 110
111 111 Gives a list of the bare names after mangling (['ls','cd', ...], not
112 112 ['magic_ls','magic_cd',...]"""
113 113
114 114 # FIXME. This needs a cleanup, in the way the magics list is built.
115 115
116 116 # magics in class definition
117 117 class_magic = lambda fn: fn.startswith('magic_') and \
118 118 callable(Magic.__dict__[fn])
119 119 # in instance namespace (run-time user additions)
120 120 inst_magic = lambda fn: fn.startswith('magic_') and \
121 121 callable(self.__dict__[fn])
122 122 # and bound magics by user (so they can access self):
123 123 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
124 124 callable(self.__class__.__dict__[fn])
125 125 magics = filter(class_magic,Magic.__dict__.keys()) + \
126 126 filter(inst_magic,self.__dict__.keys()) + \
127 127 filter(inst_bound_magic,self.__class__.__dict__.keys())
128 128 out = []
129 129 for fn in magics:
130 130 out.append(fn.replace('magic_','',1))
131 131 out.sort()
132 132 return out
133 133
134 134 def extract_input_slices(self,slices,raw=False):
135 135 """Return as a string a set of input history slices.
136 136
137 137 Inputs:
138 138
139 139 - slices: the set of slices is given as a list of strings (like
140 140 ['1','4:8','9'], since this function is for use by magic functions
141 141 which get their arguments as strings.
142 142
143 143 Optional inputs:
144 144
145 145 - raw(False): by default, the processed input is used. If this is
146 146 true, the raw input history is used instead.
147 147
148 148 Note that slices can be called with two notations:
149 149
150 150 N:M -> standard python form, means including items N...(M-1).
151 151
152 152 N-M -> include items N..M (closed endpoint)."""
153 153
154 154 if raw:
155 155 hist = self.shell.input_hist_raw
156 156 else:
157 157 hist = self.shell.input_hist
158 158
159 159 cmds = []
160 160 for chunk in slices:
161 161 if ':' in chunk:
162 162 ini,fin = map(int,chunk.split(':'))
163 163 elif '-' in chunk:
164 164 ini,fin = map(int,chunk.split('-'))
165 165 fin += 1
166 166 else:
167 167 ini = int(chunk)
168 168 fin = ini+1
169 169 cmds.append(hist[ini:fin])
170 170 return cmds
171 171
172 172 def _ofind(self,oname):
173 173 """Find an object in the available namespaces.
174 174
175 175 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
176 176
177 177 Has special code to detect magic functions.
178 178 """
179 179
180 180 oname = oname.strip()
181 181
182 182 # Namespaces to search in:
183 183 user_ns = self.shell.user_ns
184 184 internal_ns = self.shell.internal_ns
185 185 builtin_ns = __builtin__.__dict__
186 186 alias_ns = self.shell.alias_table
187 187
188 188 # Put them in a list. The order is important so that we find things in
189 189 # the same order that Python finds them.
190 190 namespaces = [ ('Interactive',user_ns),
191 191 ('IPython internal',internal_ns),
192 192 ('Python builtin',builtin_ns),
193 193 ('Alias',alias_ns),
194 194 ]
195 195
196 196 # initialize results to 'null'
197 197 found = 0; obj = None; ospace = None; ds = None;
198 198 ismagic = 0; isalias = 0; parent = None
199 199
200 200 # Look for the given name by splitting it in parts. If the head is
201 201 # found, then we look for all the remaining parts as members, and only
202 202 # declare success if we can find them all.
203 203 oname_parts = oname.split('.')
204 204 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
205 205 for nsname,ns in namespaces:
206 206 try:
207 207 obj = ns[oname_head]
208 208 except KeyError:
209 209 continue
210 210 else:
211 211 for part in oname_rest:
212 212 try:
213 213 parent = obj
214 214 obj = getattr(obj,part)
215 215 except:
216 216 # Blanket except b/c some badly implemented objects
217 217 # allow __getattr__ to raise exceptions other than
218 218 # AttributeError, which then crashes IPython.
219 219 break
220 220 else:
221 221 # If we finish the for loop (no break), we got all members
222 222 found = 1
223 223 ospace = nsname
224 224 if ns == alias_ns:
225 225 isalias = 1
226 226 break # namespace loop
227 227
228 228 # Try to see if it's magic
229 229 if not found:
230 230 if oname.startswith(self.shell.ESC_MAGIC):
231 231 oname = oname[1:]
232 232 obj = getattr(self,'magic_'+oname,None)
233 233 if obj is not None:
234 234 found = 1
235 235 ospace = 'IPython internal'
236 236 ismagic = 1
237 237
238 238 # Last try: special-case some literals like '', [], {}, etc:
239 239 if not found and oname_head in ["''",'""','[]','{}','()']:
240 240 obj = eval(oname_head)
241 241 found = 1
242 242 ospace = 'Interactive'
243 243
244 244 return {'found':found, 'obj':obj, 'namespace':ospace,
245 245 'ismagic':ismagic, 'isalias':isalias, 'parent':parent}
246 246
247 247 def arg_err(self,func):
248 248 """Print docstring if incorrect arguments were passed"""
249 249 print 'Error in arguments:'
250 250 print OInspect.getdoc(func)
251 251
252 252 def format_latex(self,strng):
253 253 """Format a string for latex inclusion."""
254 254
255 255 # Characters that need to be escaped for latex:
256 256 escape_re = re.compile(r'(%|_|\$|#|&)',re.MULTILINE)
257 257 # Magic command names as headers:
258 258 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
259 259 re.MULTILINE)
260 260 # Magic commands
261 261 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
262 262 re.MULTILINE)
263 263 # Paragraph continue
264 264 par_re = re.compile(r'\\$',re.MULTILINE)
265 265
266 266 # The "\n" symbol
267 267 newline_re = re.compile(r'\\n')
268 268
269 269 # Now build the string for output:
270 270 #strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng)
271 271 strng = cmd_name_re.sub(r'\n\\bigskip\n\\texttt{\\textbf{ \1}}:',
272 272 strng)
273 273 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
274 274 strng = par_re.sub(r'\\\\',strng)
275 275 strng = escape_re.sub(r'\\\1',strng)
276 276 strng = newline_re.sub(r'\\textbackslash{}n',strng)
277 277 return strng
278 278
279 279 def format_screen(self,strng):
280 280 """Format a string for screen printing.
281 281
282 282 This removes some latex-type format codes."""
283 283 # Paragraph continue
284 284 par_re = re.compile(r'\\$',re.MULTILINE)
285 285 strng = par_re.sub('',strng)
286 286 return strng
287 287
288 288 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
289 289 """Parse options passed to an argument string.
290 290
291 291 The interface is similar to that of getopt(), but it returns back a
292 292 Struct with the options as keys and the stripped argument string still
293 293 as a string.
294 294
295 295 arg_str is quoted as a true sys.argv vector by using shlex.split.
296 296 This allows us to easily expand variables, glob files, quote
297 297 arguments, etc.
298 298
299 299 Options:
300 300 -mode: default 'string'. If given as 'list', the argument string is
301 301 returned as a list (split on whitespace) instead of a string.
302 302
303 303 -list_all: put all option values in lists. Normally only options
304 304 appearing more than once are put in a list."""
305 305
306 306 # inject default options at the beginning of the input line
307 307 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
308 308 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
309 309
310 310 mode = kw.get('mode','string')
311 311 if mode not in ['string','list']:
312 312 raise ValueError,'incorrect mode given: %s' % mode
313 313 # Get options
314 314 list_all = kw.get('list_all',0)
315 315
316 316 # Check if we have more than one argument to warrant extra processing:
317 317 odict = {} # Dictionary with options
318 318 args = arg_str.split()
319 319 if len(args) >= 1:
320 320 # If the list of inputs only has 0 or 1 thing in it, there's no
321 321 # need to look for options
322 322 argv = shlex.split(arg_str)
323 323 # Do regular option processing
324 324 try:
325 325 opts,args = getopt(argv,opt_str,*long_opts)
326 326 except GetoptError,e:
327 327 raise GetoptError('%s ( allowed: "%s" %s)' % (e.msg,opt_str,
328 328 " ".join(long_opts)))
329 329 for o,a in opts:
330 330 if o.startswith('--'):
331 331 o = o[2:]
332 332 else:
333 333 o = o[1:]
334 334 try:
335 335 odict[o].append(a)
336 336 except AttributeError:
337 337 odict[o] = [odict[o],a]
338 338 except KeyError:
339 339 if list_all:
340 340 odict[o] = [a]
341 341 else:
342 342 odict[o] = a
343 343
344 344 # Prepare opts,args for return
345 345 opts = Struct(odict)
346 346 if mode == 'string':
347 347 args = ' '.join(args)
348 348
349 349 return opts,args
350 350
351 351 #......................................................................
352 352 # And now the actual magic functions
353 353
354 354 # Functions for IPython shell work (vars,funcs, config, etc)
355 355 def magic_lsmagic(self, parameter_s = ''):
356 356 """List currently available magic functions."""
357 357 mesc = self.shell.ESC_MAGIC
358 358 print 'Available magic functions:\n'+mesc+\
359 359 (' '+mesc).join(self.lsmagic())
360 360 print '\n' + Magic.auto_status[self.shell.rc.automagic]
361 361 return None
362 362
363 363 def magic_magic(self, parameter_s = ''):
364 364 """Print information about the magic function system."""
365 365
366 366 mode = ''
367 367 try:
368 368 if parameter_s.split()[0] == '-latex':
369 369 mode = 'latex'
370 370 if parameter_s.split()[0] == '-brief':
371 371 mode = 'brief'
372 372 except:
373 373 pass
374 374
375 375 magic_docs = []
376 376 for fname in self.lsmagic():
377 377 mname = 'magic_' + fname
378 378 for space in (Magic,self,self.__class__):
379 379 try:
380 380 fn = space.__dict__[mname]
381 381 except KeyError:
382 382 pass
383 383 else:
384 384 break
385 385 if mode == 'brief':
386 386 # only first line
387 387 fndoc = fn.__doc__.split('\n',1)[0]
388 388 else:
389 389 fndoc = fn.__doc__
390 390
391 391 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
392 392 fname,fndoc))
393 393 magic_docs = ''.join(magic_docs)
394 394
395 395 if mode == 'latex':
396 396 print self.format_latex(magic_docs)
397 397 return
398 398 else:
399 399 magic_docs = self.format_screen(magic_docs)
400 400 if mode == 'brief':
401 401 return magic_docs
402 402
403 403 outmsg = """
404 404 IPython's 'magic' functions
405 405 ===========================
406 406
407 407 The magic function system provides a series of functions which allow you to
408 408 control the behavior of IPython itself, plus a lot of system-type
409 409 features. All these functions are prefixed with a % character, but parameters
410 410 are given without parentheses or quotes.
411 411
412 412 NOTE: If you have 'automagic' enabled (via the command line option or with the
413 413 %automagic function), you don't need to type in the % explicitly. By default,
414 414 IPython ships with automagic on, so you should only rarely need the % escape.
415 415
416 416 Example: typing '%cd mydir' (without the quotes) changes you working directory
417 417 to 'mydir', if it exists.
418 418
419 419 You can define your own magic functions to extend the system. See the supplied
420 420 ipythonrc and example-magic.py files for details (in your ipython
421 421 configuration directory, typically $HOME/.ipython/).
422 422
423 423 You can also define your own aliased names for magic functions. In your
424 424 ipythonrc file, placing a line like:
425 425
426 426 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
427 427
428 428 will define %pf as a new name for %profile.
429 429
430 430 You can also call magics in code using the ipmagic() function, which IPython
431 431 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
432 432
433 433 For a list of the available magic functions, use %lsmagic. For a description
434 434 of any of them, type %magic_name?, e.g. '%cd?'.
435 435
436 436 Currently the magic system has the following functions:\n"""
437 437
438 438 mesc = self.shell.ESC_MAGIC
439 439 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
440 440 "\n\n%s%s\n\n%s" % (outmsg,
441 441 magic_docs,mesc,mesc,
442 442 (' '+mesc).join(self.lsmagic()),
443 443 Magic.auto_status[self.shell.rc.automagic] ) )
444 444
445 445 page(outmsg,screen_lines=self.shell.rc.screen_length)
446 446
447 447 def magic_automagic(self, parameter_s = ''):
448 448 """Make magic functions callable without having to type the initial %.
449 449
450 450 Toggles on/off (when off, you must call it as %automagic, of
451 451 course). Note that magic functions have lowest priority, so if there's
452 452 a variable whose name collides with that of a magic fn, automagic
453 453 won't work for that function (you get the variable instead). However,
454 454 if you delete the variable (del var), the previously shadowed magic
455 455 function becomes visible to automagic again."""
456 456
457 457 rc = self.shell.rc
458 458 rc.automagic = not rc.automagic
459 459 print '\n' + Magic.auto_status[rc.automagic]
460 460
461 461 def magic_autocall(self, parameter_s = ''):
462 462 """Make functions callable without having to type parentheses.
463 463
464 464 Usage:
465 465
466 466 %autocall [mode]
467 467
468 468 The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the
469 469 value is toggled on and off (remembering the previous state)."""
470 470
471 471 rc = self.shell.rc
472 472
473 473 if parameter_s:
474 474 arg = int(parameter_s)
475 475 else:
476 476 arg = 'toggle'
477 477
478 478 if not arg in (0,1,2,'toggle'):
479 479 error('Valid modes: (0->Off, 1->Smart, 2->Full')
480 480 return
481 481
482 482 if arg in (0,1,2):
483 483 rc.autocall = arg
484 484 else: # toggle
485 485 if rc.autocall:
486 486 self._magic_state.autocall_save = rc.autocall
487 487 rc.autocall = 0
488 488 else:
489 489 try:
490 490 rc.autocall = self._magic_state.autocall_save
491 491 except AttributeError:
492 492 rc.autocall = self._magic_state.autocall_save = 1
493 493
494 494 print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall]
495 495
496 496 def magic_autoindent(self, parameter_s = ''):
497 497 """Toggle autoindent on/off (if available)."""
498 498
499 499 self.shell.set_autoindent()
500 500 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
501 501
502 502 def magic_system_verbose(self, parameter_s = ''):
503 503 """Toggle verbose printing of system calls on/off."""
504 504
505 505 self.shell.rc_set_toggle('system_verbose')
506 506 print "System verbose printing is:",\
507 507 ['OFF','ON'][self.shell.rc.system_verbose]
508 508
509 509 def magic_history(self, parameter_s = ''):
510 510 """Print input history (_i<n> variables), with most recent last.
511 511
512 512 %history -> print at most 40 inputs (some may be multi-line)\\
513 513 %history n -> print at most n inputs\\
514 514 %history n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
515 515
516 516 Each input's number <n> is shown, and is accessible as the
517 517 automatically generated variable _i<n>. Multi-line statements are
518 518 printed starting at a new line for easy copy/paste.
519 519
520 520
521 521 Options:
522 522
523 523 -n: do NOT print line numbers. This is useful if you want to get a
524 524 printout of many lines which can be directly pasted into a text
525 525 editor.
526 526
527 527 This feature is only available if numbered prompts are in use.
528 528
529 529 -r: print the 'raw' history. IPython filters your input and
530 530 converts it all into valid Python source before executing it (things
531 531 like magics or aliases are turned into function calls, for
532 532 example). With this option, you'll see the unfiltered history
533 533 instead of the filtered version: '%cd /' will be seen as '%cd /'
534 534 instead of '_ip.magic("%cd /")'.
535 535 """
536 536
537 537 shell = self.shell
538 538 if not shell.outputcache.do_full_cache:
539 539 print 'This feature is only available if numbered prompts are in use.'
540 540 return
541 541 opts,args = self.parse_options(parameter_s,'nr',mode='list')
542 542
543 543 if opts.has_key('r'):
544 544 input_hist = shell.input_hist_raw
545 545 else:
546 546 input_hist = shell.input_hist
547 547
548 548 default_length = 40
549 549 if len(args) == 0:
550 550 final = len(input_hist)
551 551 init = max(1,final-default_length)
552 552 elif len(args) == 1:
553 553 final = len(input_hist)
554 554 init = max(1,final-int(args[0]))
555 555 elif len(args) == 2:
556 556 init,final = map(int,args)
557 557 else:
558 558 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
559 559 print self.magic_hist.__doc__
560 560 return
561 561 width = len(str(final))
562 562 line_sep = ['','\n']
563 563 print_nums = not opts.has_key('n')
564 564 for in_num in range(init,final):
565 565 inline = input_hist[in_num]
566 566 multiline = int(inline.count('\n') > 1)
567 567 if print_nums:
568 568 print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]),
569 569 print inline,
570 570
571 571 def magic_hist(self, parameter_s=''):
572 572 """Alternate name for %history."""
573 573 return self.magic_history(parameter_s)
574 574
575 575 def magic_p(self, parameter_s=''):
576 576 """Just a short alias for Python's 'print'."""
577 577 exec 'print ' + parameter_s in self.shell.user_ns
578 578
579 579 def magic_r(self, parameter_s=''):
580 580 """Repeat previous input.
581 581
582 582 If given an argument, repeats the previous command which starts with
583 583 the same string, otherwise it just repeats the previous input.
584 584
585 585 Shell escaped commands (with ! as first character) are not recognized
586 586 by this system, only pure python code and magic commands.
587 587 """
588 588
589 589 start = parameter_s.strip()
590 590 esc_magic = self.shell.ESC_MAGIC
591 591 # Identify magic commands even if automagic is on (which means
592 592 # the in-memory version is different from that typed by the user).
593 593 if self.shell.rc.automagic:
594 594 start_magic = esc_magic+start
595 595 else:
596 596 start_magic = start
597 597 # Look through the input history in reverse
598 598 for n in range(len(self.shell.input_hist)-2,0,-1):
599 599 input = self.shell.input_hist[n]
600 600 # skip plain 'r' lines so we don't recurse to infinity
601 601 if input != '_ip.magic("r")\n' and \
602 602 (input.startswith(start) or input.startswith(start_magic)):
603 603 #print 'match',`input` # dbg
604 604 print 'Executing:',input,
605 605 self.shell.runlines(input)
606 606 return
607 607 print 'No previous input matching `%s` found.' % start
608 608
609 609 def magic_page(self, parameter_s=''):
610 610 """Pretty print the object and display it through a pager.
611 611
612 612 If no parameter is given, use _ (last output)."""
613 613 # After a function contributed by Olivier Aubert, slightly modified.
614 614
615 615 oname = parameter_s and parameter_s or '_'
616 616 info = self._ofind(oname)
617 617 if info['found']:
618 618 page(pformat(info['obj']))
619 619 else:
620 620 print 'Object `%s` not found' % oname
621 621
622 622 def magic_profile(self, parameter_s=''):
623 623 """Print your currently active IPyhton profile."""
624 624 if self.shell.rc.profile:
625 625 printpl('Current IPython profile: $self.shell.rc.profile.')
626 626 else:
627 627 print 'No profile active.'
628 628
629 629 def _inspect(self,meth,oname,**kw):
630 630 """Generic interface to the inspector system.
631 631
632 632 This function is meant to be called by pdef, pdoc & friends."""
633 633
634 634 oname = oname.strip()
635 635 info = Struct(self._ofind(oname))
636 636
637 637 if info.found:
638 638 # Get the docstring of the class property if it exists.
639 639 path = oname.split('.')
640 640 root = '.'.join(path[:-1])
641 641 if info.parent is not None:
642 642 try:
643 643 target = getattr(info.parent, '__class__')
644 644 # The object belongs to a class instance.
645 645 try:
646 646 target = getattr(target, path[-1])
647 647 # The class defines the object.
648 648 if isinstance(target, property):
649 649 oname = root + '.__class__.' + path[-1]
650 650 info = Struct(self._ofind(oname))
651 651 except AttributeError: pass
652 652 except AttributeError: pass
653 653
654 654 pmethod = getattr(self.shell.inspector,meth)
655 655 formatter = info.ismagic and self.format_screen or None
656 656 if meth == 'pdoc':
657 657 pmethod(info.obj,oname,formatter)
658 658 elif meth == 'pinfo':
659 659 pmethod(info.obj,oname,formatter,info,**kw)
660 660 else:
661 661 pmethod(info.obj,oname)
662 662 else:
663 663 print 'Object `%s` not found.' % oname
664 664 return 'not found' # so callers can take other action
665 665
666 666 def magic_pdef(self, parameter_s=''):
667 667 """Print the definition header for any callable object.
668 668
669 669 If the object is a class, print the constructor information."""
670 670 self._inspect('pdef',parameter_s)
671 671
672 672 def magic_pdoc(self, parameter_s=''):
673 673 """Print the docstring for an object.
674 674
675 675 If the given object is a class, it will print both the class and the
676 676 constructor docstrings."""
677 677 self._inspect('pdoc',parameter_s)
678 678
679 679 def magic_psource(self, parameter_s=''):
680 680 """Print (or run through pager) the source code for an object."""
681 681 self._inspect('psource',parameter_s)
682 682
683 683 def magic_pfile(self, parameter_s=''):
684 684 """Print (or run through pager) the file where an object is defined.
685 685
686 686 The file opens at the line where the object definition begins. IPython
687 687 will honor the environment variable PAGER if set, and otherwise will
688 688 do its best to print the file in a convenient form.
689 689
690 690 If the given argument is not an object currently defined, IPython will
691 691 try to interpret it as a filename (automatically adding a .py extension
692 692 if needed). You can thus use %pfile as a syntax highlighting code
693 693 viewer."""
694 694
695 695 # first interpret argument as an object name
696 696 out = self._inspect('pfile',parameter_s)
697 697 # if not, try the input as a filename
698 698 if out == 'not found':
699 699 try:
700 700 filename = get_py_filename(parameter_s)
701 701 except IOError,msg:
702 702 print msg
703 703 return
704 704 page(self.shell.inspector.format(file(filename).read()))
705 705
706 706 def magic_pinfo(self, parameter_s=''):
707 707 """Provide detailed information about an object.
708 708
709 709 '%pinfo object' is just a synonym for object? or ?object."""
710 710
711 711 #print 'pinfo par: <%s>' % parameter_s # dbg
712 712
713 713 # detail_level: 0 -> obj? , 1 -> obj??
714 714 detail_level = 0
715 715 # We need to detect if we got called as 'pinfo pinfo foo', which can
716 716 # happen if the user types 'pinfo foo?' at the cmd line.
717 717 pinfo,qmark1,oname,qmark2 = \
718 718 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
719 719 if pinfo or qmark1 or qmark2:
720 720 detail_level = 1
721 721 if "*" in oname:
722 722 self.magic_psearch(oname)
723 723 else:
724 724 self._inspect('pinfo',oname,detail_level=detail_level)
725 725
726 726 def magic_psearch(self, parameter_s=''):
727 727 """Search for object in namespaces by wildcard.
728 728
729 729 %psearch [options] PATTERN [OBJECT TYPE]
730 730
731 731 Note: ? can be used as a synonym for %psearch, at the beginning or at
732 732 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
733 733 rest of the command line must be unchanged (options come first), so
734 734 for example the following forms are equivalent
735 735
736 736 %psearch -i a* function
737 737 -i a* function?
738 738 ?-i a* function
739 739
740 740 Arguments:
741 741
742 742 PATTERN
743 743
744 744 where PATTERN is a string containing * as a wildcard similar to its
745 745 use in a shell. The pattern is matched in all namespaces on the
746 746 search path. By default objects starting with a single _ are not
747 747 matched, many IPython generated objects have a single
748 748 underscore. The default is case insensitive matching. Matching is
749 749 also done on the attributes of objects and not only on the objects
750 750 in a module.
751 751
752 752 [OBJECT TYPE]
753 753
754 754 Is the name of a python type from the types module. The name is
755 755 given in lowercase without the ending type, ex. StringType is
756 756 written string. By adding a type here only objects matching the
757 757 given type are matched. Using all here makes the pattern match all
758 758 types (this is the default).
759 759
760 760 Options:
761 761
762 762 -a: makes the pattern match even objects whose names start with a
763 763 single underscore. These names are normally ommitted from the
764 764 search.
765 765
766 766 -i/-c: make the pattern case insensitive/sensitive. If neither of
767 767 these options is given, the default is read from your ipythonrc
768 768 file. The option name which sets this value is
769 769 'wildcards_case_sensitive'. If this option is not specified in your
770 770 ipythonrc file, IPython's internal default is to do a case sensitive
771 771 search.
772 772
773 773 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
774 774 specifiy can be searched in any of the following namespaces:
775 775 'builtin', 'user', 'user_global','internal', 'alias', where
776 776 'builtin' and 'user' are the search defaults. Note that you should
777 777 not use quotes when specifying namespaces.
778 778
779 779 'Builtin' contains the python module builtin, 'user' contains all
780 780 user data, 'alias' only contain the shell aliases and no python
781 781 objects, 'internal' contains objects used by IPython. The
782 782 'user_global' namespace is only used by embedded IPython instances,
783 783 and it contains module-level globals. You can add namespaces to the
784 784 search with -s or exclude them with -e (these options can be given
785 785 more than once).
786 786
787 787 Examples:
788 788
789 789 %psearch a* -> objects beginning with an a
790 790 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
791 791 %psearch a* function -> all functions beginning with an a
792 792 %psearch re.e* -> objects beginning with an e in module re
793 793 %psearch r*.e* -> objects that start with e in modules starting in r
794 794 %psearch r*.* string -> all strings in modules beginning with r
795 795
796 796 Case sensitve search:
797 797
798 798 %psearch -c a* list all object beginning with lower case a
799 799
800 800 Show objects beginning with a single _:
801 801
802 802 %psearch -a _* list objects beginning with a single underscore"""
803 803
804 804 # default namespaces to be searched
805 805 def_search = ['user','builtin']
806 806
807 807 # Process options/args
808 808 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
809 809 opt = opts.get
810 810 shell = self.shell
811 811 psearch = shell.inspector.psearch
812 812
813 813 # select case options
814 814 if opts.has_key('i'):
815 815 ignore_case = True
816 816 elif opts.has_key('c'):
817 817 ignore_case = False
818 818 else:
819 819 ignore_case = not shell.rc.wildcards_case_sensitive
820 820
821 821 # Build list of namespaces to search from user options
822 822 def_search.extend(opt('s',[]))
823 823 ns_exclude = ns_exclude=opt('e',[])
824 824 ns_search = [nm for nm in def_search if nm not in ns_exclude]
825 825
826 826 # Call the actual search
827 827 try:
828 828 psearch(args,shell.ns_table,ns_search,
829 829 show_all=opt('a'),ignore_case=ignore_case)
830 830 except:
831 831 shell.showtraceback()
832 832
833 833 def magic_who_ls(self, parameter_s=''):
834 834 """Return a sorted list of all interactive variables.
835 835
836 836 If arguments are given, only variables of types matching these
837 837 arguments are returned."""
838 838
839 839 user_ns = self.shell.user_ns
840 840 internal_ns = self.shell.internal_ns
841 841 user_config_ns = self.shell.user_config_ns
842 842 out = []
843 843 typelist = parameter_s.split()
844 844
845 845 for i in user_ns:
846 846 if not (i.startswith('_') or i.startswith('_i')) \
847 847 and not (i in internal_ns or i in user_config_ns):
848 848 if typelist:
849 849 if type(user_ns[i]).__name__ in typelist:
850 850 out.append(i)
851 851 else:
852 852 out.append(i)
853 853 out.sort()
854 854 return out
855 855
856 856 def magic_who(self, parameter_s=''):
857 857 """Print all interactive variables, with some minimal formatting.
858 858
859 859 If any arguments are given, only variables whose type matches one of
860 860 these are printed. For example:
861 861
862 862 %who function str
863 863
864 864 will only list functions and strings, excluding all other types of
865 865 variables. To find the proper type names, simply use type(var) at a
866 866 command line to see how python prints type names. For example:
867 867
868 868 In [1]: type('hello')\\
869 869 Out[1]: <type 'str'>
870 870
871 871 indicates that the type name for strings is 'str'.
872 872
873 873 %who always excludes executed names loaded through your configuration
874 874 file and things which are internal to IPython.
875 875
876 876 This is deliberate, as typically you may load many modules and the
877 877 purpose of %who is to show you only what you've manually defined."""
878 878
879 879 varlist = self.magic_who_ls(parameter_s)
880 880 if not varlist:
881 881 print 'Interactive namespace is empty.'
882 882 return
883 883
884 884 # if we have variables, move on...
885 885
886 886 # stupid flushing problem: when prompts have no separators, stdout is
887 887 # getting lost. I'm starting to think this is a python bug. I'm having
888 888 # to force a flush with a print because even a sys.stdout.flush
889 889 # doesn't seem to do anything!
890 890
891 891 count = 0
892 892 for i in varlist:
893 893 print i+'\t',
894 894 count += 1
895 895 if count > 8:
896 896 count = 0
897 897 print
898 898 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
899 899
900 900 print # well, this does force a flush at the expense of an extra \n
901 901
902 902 def magic_whos(self, parameter_s=''):
903 903 """Like %who, but gives some extra information about each variable.
904 904
905 905 The same type filtering of %who can be applied here.
906 906
907 907 For all variables, the type is printed. Additionally it prints:
908 908
909 909 - For {},[],(): their length.
910 910
911 911 - For Numeric arrays, a summary with shape, number of elements,
912 912 typecode and size in memory.
913 913
914 914 - Everything else: a string representation, snipping their middle if
915 915 too long."""
916 916
917 917 varnames = self.magic_who_ls(parameter_s)
918 918 if not varnames:
919 919 print 'Interactive namespace is empty.'
920 920 return
921 921
922 922 # if we have variables, move on...
923 923
924 924 # for these types, show len() instead of data:
925 925 seq_types = [types.DictType,types.ListType,types.TupleType]
926 926
927 927 # for Numeric arrays, display summary info
928 928 try:
929 929 import Numeric
930 930 except ImportError:
931 931 array_type = None
932 932 else:
933 933 array_type = Numeric.ArrayType.__name__
934 934
935 935 # Find all variable names and types so we can figure out column sizes
936 936 get_vars = lambda i: self.shell.user_ns[i]
937 937 type_name = lambda v: type(v).__name__
938 938 varlist = map(get_vars,varnames)
939 939
940 940 typelist = []
941 941 for vv in varlist:
942 942 tt = type_name(vv)
943 943 if tt=='instance':
944 944 typelist.append(str(vv.__class__))
945 945 else:
946 946 typelist.append(tt)
947 947
948 948 # column labels and # of spaces as separator
949 949 varlabel = 'Variable'
950 950 typelabel = 'Type'
951 951 datalabel = 'Data/Info'
952 952 colsep = 3
953 953 # variable format strings
954 954 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
955 955 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
956 956 aformat = "%s: %s elems, type `%s`, %s bytes"
957 957 # find the size of the columns to format the output nicely
958 958 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
959 959 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
960 960 # table header
961 961 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
962 962 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
963 963 # and the table itself
964 964 kb = 1024
965 965 Mb = 1048576 # kb**2
966 966 for vname,var,vtype in zip(varnames,varlist,typelist):
967 967 print itpl(vformat),
968 968 if vtype in seq_types:
969 969 print len(var)
970 970 elif vtype==array_type:
971 971 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
972 972 vsize = Numeric.size(var)
973 973 vbytes = vsize*var.itemsize()
974 974 if vbytes < 100000:
975 975 print aformat % (vshape,vsize,var.typecode(),vbytes)
976 976 else:
977 977 print aformat % (vshape,vsize,var.typecode(),vbytes),
978 978 if vbytes < Mb:
979 979 print '(%s kb)' % (vbytes/kb,)
980 980 else:
981 981 print '(%s Mb)' % (vbytes/Mb,)
982 982 else:
983 983 vstr = str(var).replace('\n','\\n')
984 984 if len(vstr) < 50:
985 985 print vstr
986 986 else:
987 987 printpl(vfmt_short)
988 988
989 989 def magic_reset(self, parameter_s=''):
990 990 """Resets the namespace by removing all names defined by the user.
991 991
992 992 Input/Output history are left around in case you need them."""
993 993
994 994 ans = self.shell.ask_yes_no(
995 995 "Once deleted, variables cannot be recovered. Proceed (y/[n])? ")
996 996 if not ans:
997 997 print 'Nothing done.'
998 998 return
999 999 user_ns = self.shell.user_ns
1000 1000 for i in self.magic_who_ls():
1001 1001 del(user_ns[i])
1002 1002
1003 1003 def magic_config(self,parameter_s=''):
1004 1004 """Show IPython's internal configuration."""
1005 1005
1006 1006 page('Current configuration structure:\n'+
1007 1007 pformat(self.shell.rc.dict()))
1008 1008
1009 1009 def magic_logstart(self,parameter_s=''):
1010 1010 """Start logging anywhere in a session.
1011 1011
1012 1012 %logstart [-o|-r|-t] [log_name [log_mode]]
1013 1013
1014 1014 If no name is given, it defaults to a file named 'ipython_log.py' in your
1015 1015 current directory, in 'rotate' mode (see below).
1016 1016
1017 1017 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
1018 1018 history up to that point and then continues logging.
1019 1019
1020 1020 %logstart takes a second optional parameter: logging mode. This can be one
1021 1021 of (note that the modes are given unquoted):\\
1022 1022 append: well, that says it.\\
1023 1023 backup: rename (if exists) to name~ and start name.\\
1024 1024 global: single logfile in your home dir, appended to.\\
1025 1025 over : overwrite existing log.\\
1026 1026 rotate: create rotating logs name.1~, name.2~, etc.
1027 1027
1028 1028 Options:
1029 1029
1030 1030 -o: log also IPython's output. In this mode, all commands which
1031 1031 generate an Out[NN] prompt are recorded to the logfile, right after
1032 1032 their corresponding input line. The output lines are always
1033 1033 prepended with a '#[Out]# ' marker, so that the log remains valid
1034 1034 Python code.
1035 1035
1036 1036 Since this marker is always the same, filtering only the output from
1037 1037 a log is very easy, using for example a simple awk call:
1038 1038
1039 1039 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
1040 1040
1041 1041 -r: log 'raw' input. Normally, IPython's logs contain the processed
1042 1042 input, so that user lines are logged in their final form, converted
1043 1043 into valid Python. For example, %Exit is logged as
1044 1044 '_ip.magic("Exit"). If the -r flag is given, all input is logged
1045 1045 exactly as typed, with no transformations applied.
1046 1046
1047 1047 -t: put timestamps before each input line logged (these are put in
1048 1048 comments)."""
1049 1049
1050 1050 opts,par = self.parse_options(parameter_s,'ort')
1051 1051 log_output = 'o' in opts
1052 1052 log_raw_input = 'r' in opts
1053 1053 timestamp = 't' in opts
1054 1054
1055 1055 rc = self.shell.rc
1056 1056 logger = self.shell.logger
1057 1057
1058 1058 # if no args are given, the defaults set in the logger constructor by
1059 1059 # ipytohn remain valid
1060 1060 if par:
1061 1061 try:
1062 1062 logfname,logmode = par.split()
1063 1063 except:
1064 1064 logfname = par
1065 1065 logmode = 'backup'
1066 1066 else:
1067 1067 logfname = logger.logfname
1068 1068 logmode = logger.logmode
1069 1069 # put logfname into rc struct as if it had been called on the command
1070 1070 # line, so it ends up saved in the log header Save it in case we need
1071 1071 # to restore it...
1072 1072 old_logfile = rc.opts.get('logfile','')
1073 1073 if logfname:
1074 1074 logfname = os.path.expanduser(logfname)
1075 1075 rc.opts.logfile = logfname
1076 1076 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
1077 1077 try:
1078 1078 started = logger.logstart(logfname,loghead,logmode,
1079 1079 log_output,timestamp,log_raw_input)
1080 1080 except:
1081 1081 rc.opts.logfile = old_logfile
1082 1082 warn("Couldn't start log: %s" % sys.exc_info()[1])
1083 1083 else:
1084 1084 # log input history up to this point, optionally interleaving
1085 1085 # output if requested
1086 1086
1087 1087 if timestamp:
1088 1088 # disable timestamping for the previous history, since we've
1089 1089 # lost those already (no time machine here).
1090 1090 logger.timestamp = False
1091 1091
1092 1092 if log_raw_input:
1093 1093 input_hist = self.shell.input_hist_raw
1094 1094 else:
1095 1095 input_hist = self.shell.input_hist
1096 1096
1097 1097 if log_output:
1098 1098 log_write = logger.log_write
1099 1099 output_hist = self.shell.output_hist
1100 1100 for n in range(1,len(input_hist)-1):
1101 1101 log_write(input_hist[n].rstrip())
1102 1102 if n in output_hist:
1103 1103 log_write(repr(output_hist[n]),'output')
1104 1104 else:
1105 1105 logger.log_write(input_hist[1:])
1106 1106 if timestamp:
1107 1107 # re-enable timestamping
1108 1108 logger.timestamp = True
1109 1109
1110 1110 print ('Activating auto-logging. '
1111 1111 'Current session state plus future input saved.')
1112 1112 logger.logstate()
1113 1113
1114 1114 def magic_logoff(self,parameter_s=''):
1115 1115 """Temporarily stop logging.
1116 1116
1117 1117 You must have previously started logging."""
1118 1118 self.shell.logger.switch_log(0)
1119 1119
1120 1120 def magic_logon(self,parameter_s=''):
1121 1121 """Restart logging.
1122 1122
1123 1123 This function is for restarting logging which you've temporarily
1124 1124 stopped with %logoff. For starting logging for the first time, you
1125 1125 must use the %logstart function, which allows you to specify an
1126 1126 optional log filename."""
1127 1127
1128 1128 self.shell.logger.switch_log(1)
1129 1129
1130 1130 def magic_logstate(self,parameter_s=''):
1131 1131 """Print the status of the logging system."""
1132 1132
1133 1133 self.shell.logger.logstate()
1134 1134
1135 1135 def magic_pdb(self, parameter_s=''):
1136 1136 """Control the calling of the pdb interactive debugger.
1137 1137
1138 1138 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1139 1139 argument it works as a toggle.
1140 1140
1141 1141 When an exception is triggered, IPython can optionally call the
1142 1142 interactive pdb debugger after the traceback printout. %pdb toggles
1143 1143 this feature on and off."""
1144 1144
1145 1145 par = parameter_s.strip().lower()
1146 1146
1147 1147 if par:
1148 1148 try:
1149 1149 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1150 1150 except KeyError:
1151 1151 print ('Incorrect argument. Use on/1, off/0, '
1152 1152 'or nothing for a toggle.')
1153 1153 return
1154 1154 else:
1155 1155 # toggle
1156 1156 new_pdb = not self.shell.InteractiveTB.call_pdb
1157 1157
1158 1158 # set on the shell
1159 1159 self.shell.call_pdb = new_pdb
1160 1160 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1161 1161
1162 1162 def magic_prun(self, parameter_s ='',user_mode=1,
1163 1163 opts=None,arg_lst=None,prog_ns=None):
1164 1164
1165 1165 """Run a statement through the python code profiler.
1166 1166
1167 1167 Usage:\\
1168 1168 %prun [options] statement
1169 1169
1170 1170 The given statement (which doesn't require quote marks) is run via the
1171 1171 python profiler in a manner similar to the profile.run() function.
1172 1172 Namespaces are internally managed to work correctly; profile.run
1173 1173 cannot be used in IPython because it makes certain assumptions about
1174 1174 namespaces which do not hold under IPython.
1175 1175
1176 1176 Options:
1177 1177
1178 1178 -l <limit>: you can place restrictions on what or how much of the
1179 1179 profile gets printed. The limit value can be:
1180 1180
1181 1181 * A string: only information for function names containing this string
1182 1182 is printed.
1183 1183
1184 1184 * An integer: only these many lines are printed.
1185 1185
1186 1186 * A float (between 0 and 1): this fraction of the report is printed
1187 1187 (for example, use a limit of 0.4 to see the topmost 40% only).
1188 1188
1189 1189 You can combine several limits with repeated use of the option. For
1190 1190 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1191 1191 information about class constructors.
1192 1192
1193 1193 -r: return the pstats.Stats object generated by the profiling. This
1194 1194 object has all the information about the profile in it, and you can
1195 1195 later use it for further analysis or in other functions.
1196 1196
1197 1197 Since magic functions have a particular form of calling which prevents
1198 1198 you from writing something like:\\
1199 1199 In [1]: p = %prun -r print 4 # invalid!\\
1200 1200 you must instead use IPython's automatic variables to assign this:\\
1201 1201 In [1]: %prun -r print 4 \\
1202 1202 Out[1]: <pstats.Stats instance at 0x8222cec>\\
1203 1203 In [2]: stats = _
1204 1204
1205 1205 If you really need to assign this value via an explicit function call,
1206 1206 you can always tap directly into the true name of the magic function
1207 1207 by using the _ip.magic function:\\
1208 1208 In [3]: stats = _ip.magic('prun','-r print 4')
1209 1209
1210 1210 You can type _ip.magic? for more details.
1211 1211
1212 1212 -s <key>: sort profile by given key. You can provide more than one key
1213 1213 by using the option several times: '-s key1 -s key2 -s key3...'. The
1214 1214 default sorting key is 'time'.
1215 1215
1216 1216 The following is copied verbatim from the profile documentation
1217 1217 referenced below:
1218 1218
1219 1219 When more than one key is provided, additional keys are used as
1220 1220 secondary criteria when the there is equality in all keys selected
1221 1221 before them.
1222 1222
1223 1223 Abbreviations can be used for any key names, as long as the
1224 1224 abbreviation is unambiguous. The following are the keys currently
1225 1225 defined:
1226 1226
1227 1227 Valid Arg Meaning\\
1228 1228 "calls" call count\\
1229 1229 "cumulative" cumulative time\\
1230 1230 "file" file name\\
1231 1231 "module" file name\\
1232 1232 "pcalls" primitive call count\\
1233 1233 "line" line number\\
1234 1234 "name" function name\\
1235 1235 "nfl" name/file/line\\
1236 1236 "stdname" standard name\\
1237 1237 "time" internal time
1238 1238
1239 1239 Note that all sorts on statistics are in descending order (placing
1240 1240 most time consuming items first), where as name, file, and line number
1241 1241 searches are in ascending order (i.e., alphabetical). The subtle
1242 1242 distinction between "nfl" and "stdname" is that the standard name is a
1243 1243 sort of the name as printed, which means that the embedded line
1244 1244 numbers get compared in an odd way. For example, lines 3, 20, and 40
1245 1245 would (if the file names were the same) appear in the string order
1246 1246 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1247 1247 line numbers. In fact, sort_stats("nfl") is the same as
1248 1248 sort_stats("name", "file", "line").
1249 1249
1250 1250 -T <filename>: save profile results as shown on screen to a text
1251 1251 file. The profile is still shown on screen.
1252 1252
1253 1253 -D <filename>: save (via dump_stats) profile statistics to given
1254 1254 filename. This data is in a format understod by the pstats module, and
1255 1255 is generated by a call to the dump_stats() method of profile
1256 1256 objects. The profile is still shown on screen.
1257 1257
1258 1258 If you want to run complete programs under the profiler's control, use
1259 1259 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1260 1260 contains profiler specific options as described here.
1261 1261
1262 1262 You can read the complete documentation for the profile module with:\\
1263 1263 In [1]: import profile; profile.help() """
1264 1264
1265 1265 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1266 1266 # protect user quote marks
1267 1267 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1268 1268
1269 1269 if user_mode: # regular user call
1270 1270 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1271 1271 list_all=1)
1272 1272 namespace = self.shell.user_ns
1273 1273 else: # called to run a program by %run -p
1274 1274 try:
1275 1275 filename = get_py_filename(arg_lst[0])
1276 1276 except IOError,msg:
1277 1277 error(msg)
1278 1278 return
1279 1279
1280 1280 arg_str = 'execfile(filename,prog_ns)'
1281 1281 namespace = locals()
1282 1282
1283 1283 opts.merge(opts_def)
1284 1284
1285 1285 prof = profile.Profile()
1286 1286 try:
1287 1287 prof = prof.runctx(arg_str,namespace,namespace)
1288 1288 sys_exit = ''
1289 1289 except SystemExit:
1290 1290 sys_exit = """*** SystemExit exception caught in code being profiled."""
1291 1291
1292 1292 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1293 1293
1294 1294 lims = opts.l
1295 1295 if lims:
1296 1296 lims = [] # rebuild lims with ints/floats/strings
1297 1297 for lim in opts.l:
1298 1298 try:
1299 1299 lims.append(int(lim))
1300 1300 except ValueError:
1301 1301 try:
1302 1302 lims.append(float(lim))
1303 1303 except ValueError:
1304 1304 lims.append(lim)
1305 1305
1306 1306 # trap output
1307 1307 sys_stdout = sys.stdout
1308 1308 stdout_trap = StringIO()
1309 1309 try:
1310 1310 sys.stdout = stdout_trap
1311 1311 stats.print_stats(*lims)
1312 1312 finally:
1313 1313 sys.stdout = sys_stdout
1314 1314 output = stdout_trap.getvalue()
1315 1315 output = output.rstrip()
1316 1316
1317 1317 page(output,screen_lines=self.shell.rc.screen_length)
1318 1318 print sys_exit,
1319 1319
1320 1320 dump_file = opts.D[0]
1321 1321 text_file = opts.T[0]
1322 1322 if dump_file:
1323 1323 prof.dump_stats(dump_file)
1324 1324 print '\n*** Profile stats marshalled to file',\
1325 1325 `dump_file`+'.',sys_exit
1326 1326 if text_file:
1327 1327 file(text_file,'w').write(output)
1328 1328 print '\n*** Profile printout saved to text file',\
1329 1329 `text_file`+'.',sys_exit
1330 1330
1331 1331 if opts.has_key('r'):
1332 1332 return stats
1333 1333 else:
1334 1334 return None
1335 1335
1336 1336 def magic_run(self, parameter_s ='',runner=None):
1337 1337 """Run the named file inside IPython as a program.
1338 1338
1339 1339 Usage:\\
1340 1340 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1341 1341
1342 1342 Parameters after the filename are passed as command-line arguments to
1343 1343 the program (put in sys.argv). Then, control returns to IPython's
1344 1344 prompt.
1345 1345
1346 1346 This is similar to running at a system prompt:\\
1347 1347 $ python file args\\
1348 1348 but with the advantage of giving you IPython's tracebacks, and of
1349 1349 loading all variables into your interactive namespace for further use
1350 1350 (unless -p is used, see below).
1351 1351
1352 1352 The file is executed in a namespace initially consisting only of
1353 1353 __name__=='__main__' and sys.argv constructed as indicated. It thus
1354 1354 sees its environment as if it were being run as a stand-alone
1355 1355 program. But after execution, the IPython interactive namespace gets
1356 1356 updated with all variables defined in the program (except for __name__
1357 1357 and sys.argv). This allows for very convenient loading of code for
1358 1358 interactive work, while giving each program a 'clean sheet' to run in.
1359 1359
1360 1360 Options:
1361 1361
1362 1362 -n: __name__ is NOT set to '__main__', but to the running file's name
1363 1363 without extension (as python does under import). This allows running
1364 1364 scripts and reloading the definitions in them without calling code
1365 1365 protected by an ' if __name__ == "__main__" ' clause.
1366 1366
1367 1367 -i: run the file in IPython's namespace instead of an empty one. This
1368 1368 is useful if you are experimenting with code written in a text editor
1369 1369 which depends on variables defined interactively.
1370 1370
1371 1371 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1372 1372 being run. This is particularly useful if IPython is being used to
1373 1373 run unittests, which always exit with a sys.exit() call. In such
1374 1374 cases you are interested in the output of the test results, not in
1375 1375 seeing a traceback of the unittest module.
1376 1376
1377 1377 -t: print timing information at the end of the run. IPython will give
1378 1378 you an estimated CPU time consumption for your script, which under
1379 1379 Unix uses the resource module to avoid the wraparound problems of
1380 1380 time.clock(). Under Unix, an estimate of time spent on system tasks
1381 1381 is also given (for Windows platforms this is reported as 0.0).
1382 1382
1383 1383 If -t is given, an additional -N<N> option can be given, where <N>
1384 1384 must be an integer indicating how many times you want the script to
1385 1385 run. The final timing report will include total and per run results.
1386 1386
1387 1387 For example (testing the script uniq_stable.py):
1388 1388
1389 1389 In [1]: run -t uniq_stable
1390 1390
1391 1391 IPython CPU timings (estimated):\\
1392 1392 User : 0.19597 s.\\
1393 1393 System: 0.0 s.\\
1394 1394
1395 1395 In [2]: run -t -N5 uniq_stable
1396 1396
1397 1397 IPython CPU timings (estimated):\\
1398 1398 Total runs performed: 5\\
1399 1399 Times : Total Per run\\
1400 1400 User : 0.910862 s, 0.1821724 s.\\
1401 1401 System: 0.0 s, 0.0 s.
1402 1402
1403 1403 -d: run your program under the control of pdb, the Python debugger.
1404 1404 This allows you to execute your program step by step, watch variables,
1405 1405 etc. Internally, what IPython does is similar to calling:
1406 1406
1407 1407 pdb.run('execfile("YOURFILENAME")')
1408 1408
1409 1409 with a breakpoint set on line 1 of your file. You can change the line
1410 1410 number for this automatic breakpoint to be <N> by using the -bN option
1411 1411 (where N must be an integer). For example:
1412 1412
1413 1413 %run -d -b40 myscript
1414 1414
1415 1415 will set the first breakpoint at line 40 in myscript.py. Note that
1416 1416 the first breakpoint must be set on a line which actually does
1417 1417 something (not a comment or docstring) for it to stop execution.
1418 1418
1419 1419 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1420 1420 first enter 'c' (without qoutes) to start execution up to the first
1421 1421 breakpoint.
1422 1422
1423 1423 Entering 'help' gives information about the use of the debugger. You
1424 1424 can easily see pdb's full documentation with "import pdb;pdb.help()"
1425 1425 at a prompt.
1426 1426
1427 1427 -p: run program under the control of the Python profiler module (which
1428 1428 prints a detailed report of execution times, function calls, etc).
1429 1429
1430 1430 You can pass other options after -p which affect the behavior of the
1431 1431 profiler itself. See the docs for %prun for details.
1432 1432
1433 1433 In this mode, the program's variables do NOT propagate back to the
1434 1434 IPython interactive namespace (because they remain in the namespace
1435 1435 where the profiler executes them).
1436 1436
1437 1437 Internally this triggers a call to %prun, see its documentation for
1438 1438 details on the options available specifically for profiling."""
1439 1439
1440 1440 # get arguments and set sys.argv for program to be run.
1441 1441 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1442 1442 mode='list',list_all=1)
1443 1443
1444 1444 try:
1445 1445 filename = get_py_filename(arg_lst[0])
1446 1446 except IndexError:
1447 1447 warn('you must provide at least a filename.')
1448 1448 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1449 1449 return
1450 1450 except IOError,msg:
1451 1451 error(msg)
1452 1452 return
1453 1453
1454 1454 # Control the response to exit() calls made by the script being run
1455 1455 exit_ignore = opts.has_key('e')
1456 1456
1457 1457 # Make sure that the running script gets a proper sys.argv as if it
1458 1458 # were run from a system shell.
1459 1459 save_argv = sys.argv # save it for later restoring
1460 1460 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1461 1461
1462 1462 if opts.has_key('i'):
1463 1463 prog_ns = self.shell.user_ns
1464 1464 __name__save = self.shell.user_ns['__name__']
1465 1465 prog_ns['__name__'] = '__main__'
1466 1466 else:
1467 1467 if opts.has_key('n'):
1468 1468 name = os.path.splitext(os.path.basename(filename))[0]
1469 1469 else:
1470 1470 name = '__main__'
1471 1471 prog_ns = {'__name__':name}
1472 1472
1473 1473 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
1474 1474 # set the __file__ global in the script's namespace
1475 1475 prog_ns['__file__'] = filename
1476 1476
1477 1477 # pickle fix. See iplib for an explanation. But we need to make sure
1478 1478 # that, if we overwrite __main__, we replace it at the end
1479 1479 if prog_ns['__name__'] == '__main__':
1480 1480 restore_main = sys.modules['__main__']
1481 1481 else:
1482 1482 restore_main = False
1483 1483
1484 1484 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1485 1485
1486 1486 stats = None
1487 1487 try:
1488 1488 if opts.has_key('p'):
1489 1489 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1490 1490 else:
1491 1491 if opts.has_key('d'):
1492 1492 deb = Debugger.Pdb(self.shell.rc.colors)
1493 1493 # reset Breakpoint state, which is moronically kept
1494 1494 # in a class
1495 1495 bdb.Breakpoint.next = 1
1496 1496 bdb.Breakpoint.bplist = {}
1497 1497 bdb.Breakpoint.bpbynumber = [None]
1498 1498 # Set an initial breakpoint to stop execution
1499 1499 maxtries = 10
1500 1500 bp = int(opts.get('b',[1])[0])
1501 1501 checkline = deb.checkline(filename,bp)
1502 1502 if not checkline:
1503 1503 for bp in range(bp+1,bp+maxtries+1):
1504 1504 if deb.checkline(filename,bp):
1505 1505 break
1506 1506 else:
1507 1507 msg = ("\nI failed to find a valid line to set "
1508 1508 "a breakpoint\n"
1509 1509 "after trying up to line: %s.\n"
1510 1510 "Please set a valid breakpoint manually "
1511 1511 "with the -b option." % bp)
1512 1512 error(msg)
1513 1513 return
1514 1514 # if we find a good linenumber, set the breakpoint
1515 1515 deb.do_break('%s:%s' % (filename,bp))
1516 1516 # Start file run
1517 1517 print "NOTE: Enter 'c' at the",
1518 1518 print "ipdb> prompt to start your script."
1519 1519 try:
1520 1520 deb.run('execfile("%s")' % filename,prog_ns)
1521 1521 except:
1522 1522 etype, value, tb = sys.exc_info()
1523 1523 # Skip three frames in the traceback: the %run one,
1524 1524 # one inside bdb.py, and the command-line typed by the
1525 1525 # user (run by exec in pdb itself).
1526 1526 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1527 1527 else:
1528 1528 if runner is None:
1529 1529 runner = self.shell.safe_execfile
1530 1530 if opts.has_key('t'):
1531 1531 try:
1532 1532 nruns = int(opts['N'][0])
1533 1533 if nruns < 1:
1534 1534 error('Number of runs must be >=1')
1535 1535 return
1536 1536 except (KeyError):
1537 1537 nruns = 1
1538 1538 if nruns == 1:
1539 1539 t0 = clock2()
1540 1540 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1541 1541 t1 = clock2()
1542 1542 t_usr = t1[0]-t0[0]
1543 1543 t_sys = t1[1]-t1[1]
1544 1544 print "\nIPython CPU timings (estimated):"
1545 1545 print " User : %10s s." % t_usr
1546 1546 print " System: %10s s." % t_sys
1547 1547 else:
1548 1548 runs = range(nruns)
1549 1549 t0 = clock2()
1550 1550 for nr in runs:
1551 1551 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1552 1552 t1 = clock2()
1553 1553 t_usr = t1[0]-t0[0]
1554 1554 t_sys = t1[1]-t1[1]
1555 1555 print "\nIPython CPU timings (estimated):"
1556 1556 print "Total runs performed:",nruns
1557 1557 print " Times : %10s %10s" % ('Total','Per run')
1558 1558 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1559 1559 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1560 1560
1561 1561 else:
1562 1562 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1563 1563 if opts.has_key('i'):
1564 1564 self.shell.user_ns['__name__'] = __name__save
1565 1565 else:
1566 1566 # update IPython interactive namespace
1567 1567 del prog_ns['__name__']
1568 1568 self.shell.user_ns.update(prog_ns)
1569 1569 finally:
1570 1570 sys.argv = save_argv
1571 1571 if restore_main:
1572 1572 sys.modules['__main__'] = restore_main
1573 1573 return stats
1574 1574
1575 1575 def magic_runlog(self, parameter_s =''):
1576 1576 """Run files as logs.
1577 1577
1578 1578 Usage:\\
1579 1579 %runlog file1 file2 ...
1580 1580
1581 1581 Run the named files (treating them as log files) in sequence inside
1582 1582 the interpreter, and return to the prompt. This is much slower than
1583 1583 %run because each line is executed in a try/except block, but it
1584 1584 allows running files with syntax errors in them.
1585 1585
1586 1586 Normally IPython will guess when a file is one of its own logfiles, so
1587 1587 you can typically use %run even for logs. This shorthand allows you to
1588 1588 force any file to be treated as a log file."""
1589 1589
1590 1590 for f in parameter_s.split():
1591 1591 self.shell.safe_execfile(f,self.shell.user_ns,
1592 1592 self.shell.user_ns,islog=1)
1593 1593
1594 1594 def magic_timeit(self, parameter_s =''):
1595 1595 """Time execution of a Python statement or expression
1596 1596
1597 1597 Usage:\\
1598 1598 %timeit [-n<N> -r<R> [-t|-c]] statement
1599 1599
1600 1600 Time execution of a Python statement or expression using the timeit
1601 1601 module.
1602 1602
1603 1603 Options:
1604 1604 -n<N>: execute the given statement <N> times in a loop. If this value
1605 1605 is not given, a fitting value is chosen.
1606 1606
1607 1607 -r<R>: repeat the loop iteration <R> times and take the best result.
1608 1608 Default: 3
1609 1609
1610 1610 -t: use time.time to measure the time, which is the default on Unix.
1611 1611 This function measures wall time.
1612 1612
1613 1613 -c: use time.clock to measure the time, which is the default on
1614 1614 Windows and measures wall time. On Unix, resource.getrusage is used
1615 1615 instead and returns the CPU user time.
1616 1616
1617 1617 -p<P>: use a precision of <P> digits to display the timing result.
1618 1618 Default: 3
1619 1619
1620 1620
1621 1621 Examples:\\
1622 1622 In [1]: %timeit pass
1623 1623 10000000 loops, best of 3: 53.3 ns per loop
1624 1624
1625 1625 In [2]: u = None
1626 1626
1627 1627 In [3]: %timeit u is None
1628 1628 10000000 loops, best of 3: 184 ns per loop
1629 1629
1630 1630 In [4]: %timeit -r 4 u == None
1631 1631 1000000 loops, best of 4: 242 ns per loop
1632 1632
1633 1633 In [5]: import time
1634 1634
1635 1635 In [6]: %timeit -n1 time.sleep(2)
1636 1636 1 loops, best of 3: 2 s per loop
1637 1637
1638 1638
1639 1639 The times reported by %timeit will be slightly higher than those reported
1640 1640 by the timeit.py script when variables are accessed. This is due to the
1641 1641 fact that %timeit executes the statement in the namespace of the shell,
1642 1642 compared with timeit.py, which uses a single setup statement to import
1643 1643 function or create variables. Generally, the bias does not matter as long
1644 1644 as results from timeit.py are not mixed with those from %timeit."""
1645 1645 import timeit
1646 1646 import math
1647 1647
1648 1648 units = ["s", "ms", "\xc2\xb5s", "ns"]
1649 1649 scaling = [1, 1e3, 1e6, 1e9]
1650 1650
1651 1651 opts, stmt = self.parse_options(parameter_s,'n:r:tcp:')
1652 1652 if stmt == "":
1653 1653 return
1654 1654 timefunc = timeit.default_timer
1655 1655 number = int(getattr(opts, "n", 0))
1656 1656 repeat = int(getattr(opts, "r", timeit.default_repeat))
1657 1657 precision = int(getattr(opts, "p", 3))
1658 1658 if hasattr(opts, "t"):
1659 1659 timefunc = time.time
1660 1660 if hasattr(opts, "c"):
1661 1661 timefunc = clock
1662 1662
1663 1663 timer = timeit.Timer(timer=timefunc)
1664 1664 # this code has tight coupling to the inner workings of timeit.Timer,
1665 1665 # but is there a better way to achieve that the code stmt has access
1666 1666 # to the shell namespace?
1667 1667
1668 1668 src = timeit.template % {'stmt': timeit.reindent(stmt, 8), 'setup': "pass"}
1669 1669 code = compile(src, "<magic-timeit>", "exec")
1670 1670 ns = {}
1671 1671 exec code in self.shell.user_ns, ns
1672 1672 timer.inner = ns["inner"]
1673 1673
1674 1674 if number == 0:
1675 1675 # determine number so that 0.2 <= total time < 2.0
1676 1676 number = 1
1677 1677 for i in range(1, 10):
1678 1678 number *= 10
1679 1679 if timer.timeit(number) >= 0.2:
1680 1680 break
1681 1681
1682 1682 best = min(timer.repeat(repeat, number)) / number
1683 1683
1684 1684 if best > 0.0:
1685 1685 order = min(-int(math.floor(math.log10(best)) // 3), 3)
1686 1686 else:
1687 1687 order = 3
1688 1688 print "%d loops, best of %d: %.*g %s per loop" % (number, repeat,
1689 1689 precision,
1690 1690 best * scaling[order],
1691 1691 units[order])
1692 1692
1693 1693 def magic_time(self,parameter_s = ''):
1694 1694 """Time execution of a Python statement or expression.
1695 1695
1696 1696 The CPU and wall clock times are printed, and the value of the
1697 1697 expression (if any) is returned. Note that under Win32, system time
1698 1698 is always reported as 0, since it can not be measured.
1699 1699
1700 1700 This function provides very basic timing functionality. In Python
1701 1701 2.3, the timeit module offers more control and sophistication, so this
1702 1702 could be rewritten to use it (patches welcome).
1703 1703
1704 1704 Some examples:
1705 1705
1706 1706 In [1]: time 2**128
1707 1707 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1708 1708 Wall time: 0.00
1709 1709 Out[1]: 340282366920938463463374607431768211456L
1710 1710
1711 1711 In [2]: n = 1000000
1712 1712
1713 1713 In [3]: time sum(range(n))
1714 1714 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1715 1715 Wall time: 1.37
1716 1716 Out[3]: 499999500000L
1717 1717
1718 1718 In [4]: time print 'hello world'
1719 1719 hello world
1720 1720 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1721 1721 Wall time: 0.00
1722 1722 """
1723 1723
1724 1724 # fail immediately if the given expression can't be compiled
1725 1725 try:
1726 1726 mode = 'eval'
1727 1727 code = compile(parameter_s,'<timed eval>',mode)
1728 1728 except SyntaxError:
1729 1729 mode = 'exec'
1730 1730 code = compile(parameter_s,'<timed exec>',mode)
1731 1731 # skew measurement as little as possible
1732 1732 glob = self.shell.user_ns
1733 1733 clk = clock2
1734 1734 wtime = time.time
1735 1735 # time execution
1736 1736 wall_st = wtime()
1737 1737 if mode=='eval':
1738 1738 st = clk()
1739 1739 out = eval(code,glob)
1740 1740 end = clk()
1741 1741 else:
1742 1742 st = clk()
1743 1743 exec code in glob
1744 1744 end = clk()
1745 1745 out = None
1746 1746 wall_end = wtime()
1747 1747 # Compute actual times and report
1748 1748 wall_time = wall_end-wall_st
1749 1749 cpu_user = end[0]-st[0]
1750 1750 cpu_sys = end[1]-st[1]
1751 1751 cpu_tot = cpu_user+cpu_sys
1752 1752 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1753 1753 (cpu_user,cpu_sys,cpu_tot)
1754 1754 print "Wall time: %.2f" % wall_time
1755 1755 return out
1756 1756
1757 1757 def magic_macro(self,parameter_s = ''):
1758 1758 """Define a set of input lines as a macro for future re-execution.
1759 1759
1760 1760 Usage:\\
1761 1761 %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...
1762 1762
1763 1763 Options:
1764 1764
1765 1765 -r: use 'raw' input. By default, the 'processed' history is used,
1766 1766 so that magics are loaded in their transformed version to valid
1767 1767 Python. If this option is given, the raw input as typed as the
1768 1768 command line is used instead.
1769 1769
1770 1770 This will define a global variable called `name` which is a string
1771 1771 made of joining the slices and lines you specify (n1,n2,... numbers
1772 1772 above) from your input history into a single string. This variable
1773 1773 acts like an automatic function which re-executes those lines as if
1774 1774 you had typed them. You just type 'name' at the prompt and the code
1775 1775 executes.
1776 1776
1777 1777 The notation for indicating number ranges is: n1-n2 means 'use line
1778 1778 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1779 1779 using the lines numbered 5,6 and 7.
1780 1780
1781 1781 Note: as a 'hidden' feature, you can also use traditional python slice
1782 1782 notation, where N:M means numbers N through M-1.
1783 1783
1784 1784 For example, if your history contains (%hist prints it):
1785 1785
1786 1786 44: x=1\\
1787 1787 45: y=3\\
1788 1788 46: z=x+y\\
1789 1789 47: print x\\
1790 1790 48: a=5\\
1791 1791 49: print 'x',x,'y',y\\
1792 1792
1793 1793 you can create a macro with lines 44 through 47 (included) and line 49
1794 1794 called my_macro with:
1795 1795
1796 1796 In [51]: %macro my_macro 44-47 49
1797 1797
1798 1798 Now, typing `my_macro` (without quotes) will re-execute all this code
1799 1799 in one pass.
1800 1800
1801 1801 You don't need to give the line-numbers in order, and any given line
1802 1802 number can appear multiple times. You can assemble macros with any
1803 1803 lines from your input history in any order.
1804 1804
1805 1805 The macro is a simple object which holds its value in an attribute,
1806 1806 but IPython's display system checks for macros and executes them as
1807 1807 code instead of printing them when you type their name.
1808 1808
1809 1809 You can view a macro's contents by explicitly printing it with:
1810 1810
1811 1811 'print macro_name'.
1812 1812
1813 1813 For one-off cases which DON'T contain magic function calls in them you
1814 1814 can obtain similar results by explicitly executing slices from your
1815 1815 input history with:
1816 1816
1817 1817 In [60]: exec In[44:48]+In[49]"""
1818 1818
1819 1819 opts,args = self.parse_options(parameter_s,'r',mode='list')
1820 1820 name,ranges = args[0], args[1:]
1821 1821 #print 'rng',ranges # dbg
1822 1822 lines = self.extract_input_slices(ranges,opts.has_key('r'))
1823 1823 macro = Macro(lines)
1824 1824 self.shell.user_ns.update({name:macro})
1825 1825 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1826 1826 print 'Macro contents:'
1827 1827 print macro,
1828 1828
1829 1829 def magic_save(self,parameter_s = ''):
1830 1830 """Save a set of lines to a given filename.
1831 1831
1832 1832 Usage:\\
1833 1833 %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...
1834 1834
1835 1835 Options:
1836 1836
1837 1837 -r: use 'raw' input. By default, the 'processed' history is used,
1838 1838 so that magics are loaded in their transformed version to valid
1839 1839 Python. If this option is given, the raw input as typed as the
1840 1840 command line is used instead.
1841 1841
1842 1842 This function uses the same syntax as %macro for line extraction, but
1843 1843 instead of creating a macro it saves the resulting string to the
1844 1844 filename you specify.
1845 1845
1846 1846 It adds a '.py' extension to the file if you don't do so yourself, and
1847 1847 it asks for confirmation before overwriting existing files."""
1848 1848
1849 1849 opts,args = self.parse_options(parameter_s,'r',mode='list')
1850 1850 fname,ranges = args[0], args[1:]
1851 1851 if not fname.endswith('.py'):
1852 1852 fname += '.py'
1853 1853 if os.path.isfile(fname):
1854 1854 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1855 1855 if ans.lower() not in ['y','yes']:
1856 1856 print 'Operation cancelled.'
1857 1857 return
1858 1858 cmds = ''.join(self.extract_input_slices(ranges,opts.has_key('r')))
1859 1859 f = file(fname,'w')
1860 1860 f.write(cmds)
1861 1861 f.close()
1862 1862 print 'The following commands were written to file `%s`:' % fname
1863 1863 print cmds
1864 1864
1865 1865 def _edit_macro(self,mname,macro):
1866 1866 """open an editor with the macro data in a file"""
1867 1867 filename = self.shell.mktempfile(macro.value)
1868 1868 self.shell.hooks.editor(filename)
1869 1869
1870 1870 # and make a new macro object, to replace the old one
1871 1871 mfile = open(filename)
1872 1872 mvalue = mfile.read()
1873 1873 mfile.close()
1874 1874 self.shell.user_ns[mname] = Macro(mvalue)
1875 1875
1876 1876 def magic_ed(self,parameter_s=''):
1877 1877 """Alias to %edit."""
1878 1878 return self.magic_edit(parameter_s)
1879 1879
1880 1880 def magic_edit(self,parameter_s='',last_call=['','']):
1881 1881 """Bring up an editor and execute the resulting code.
1882 1882
1883 1883 Usage:
1884 1884 %edit [options] [args]
1885 1885
1886 1886 %edit runs IPython's editor hook. The default version of this hook is
1887 1887 set to call the __IPYTHON__.rc.editor command. This is read from your
1888 1888 environment variable $EDITOR. If this isn't found, it will default to
1889 1889 vi under Linux/Unix and to notepad under Windows. See the end of this
1890 1890 docstring for how to change the editor hook.
1891 1891
1892 1892 You can also set the value of this editor via the command line option
1893 1893 '-editor' or in your ipythonrc file. This is useful if you wish to use
1894 1894 specifically for IPython an editor different from your typical default
1895 1895 (and for Windows users who typically don't set environment variables).
1896 1896
1897 1897 This command allows you to conveniently edit multi-line code right in
1898 1898 your IPython session.
1899 1899
1900 1900 If called without arguments, %edit opens up an empty editor with a
1901 1901 temporary file and will execute the contents of this file when you
1902 1902 close it (don't forget to save it!).
1903 1903
1904 1904
1905 1905 Options:
1906 1906
1907 1907 -n <number>: open the editor at a specified line number. By default,
1908 1908 the IPython editor hook uses the unix syntax 'editor +N filename', but
1909 1909 you can configure this by providing your own modified hook if your
1910 1910 favorite editor supports line-number specifications with a different
1911 1911 syntax.
1912 1912
1913 1913 -p: this will call the editor with the same data as the previous time
1914 1914 it was used, regardless of how long ago (in your current session) it
1915 1915 was.
1916 1916
1917 1917 -r: use 'raw' input. This option only applies to input taken from the
1918 1918 user's history. By default, the 'processed' history is used, so that
1919 1919 magics are loaded in their transformed version to valid Python. If
1920 1920 this option is given, the raw input as typed as the command line is
1921 1921 used instead. When you exit the editor, it will be executed by
1922 1922 IPython's own processor.
1923 1923
1924 1924 -x: do not execute the edited code immediately upon exit. This is
1925 1925 mainly useful if you are editing programs which need to be called with
1926 1926 command line arguments, which you can then do using %run.
1927 1927
1928 1928
1929 1929 Arguments:
1930 1930
1931 1931 If arguments are given, the following possibilites exist:
1932 1932
1933 1933 - The arguments are numbers or pairs of colon-separated numbers (like
1934 1934 1 4:8 9). These are interpreted as lines of previous input to be
1935 1935 loaded into the editor. The syntax is the same of the %macro command.
1936 1936
1937 1937 - If the argument doesn't start with a number, it is evaluated as a
1938 1938 variable and its contents loaded into the editor. You can thus edit
1939 1939 any string which contains python code (including the result of
1940 1940 previous edits).
1941 1941
1942 1942 - If the argument is the name of an object (other than a string),
1943 1943 IPython will try to locate the file where it was defined and open the
1944 1944 editor at the point where it is defined. You can use `%edit function`
1945 1945 to load an editor exactly at the point where 'function' is defined,
1946 1946 edit it and have the file be executed automatically.
1947 1947
1948 1948 If the object is a macro (see %macro for details), this opens up your
1949 1949 specified editor with a temporary file containing the macro's data.
1950 1950 Upon exit, the macro is reloaded with the contents of the file.
1951 1951
1952 1952 Note: opening at an exact line is only supported under Unix, and some
1953 1953 editors (like kedit and gedit up to Gnome 2.8) do not understand the
1954 1954 '+NUMBER' parameter necessary for this feature. Good editors like
1955 1955 (X)Emacs, vi, jed, pico and joe all do.
1956 1956
1957 1957 - If the argument is not found as a variable, IPython will look for a
1958 1958 file with that name (adding .py if necessary) and load it into the
1959 1959 editor. It will execute its contents with execfile() when you exit,
1960 1960 loading any code in the file into your interactive namespace.
1961 1961
1962 1962 After executing your code, %edit will return as output the code you
1963 1963 typed in the editor (except when it was an existing file). This way
1964 1964 you can reload the code in further invocations of %edit as a variable,
1965 1965 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
1966 1966 the output.
1967 1967
1968 1968 Note that %edit is also available through the alias %ed.
1969 1969
1970 1970 This is an example of creating a simple function inside the editor and
1971 1971 then modifying it. First, start up the editor:
1972 1972
1973 1973 In [1]: ed\\
1974 1974 Editing... done. Executing edited code...\\
1975 1975 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
1976 1976
1977 1977 We can then call the function foo():
1978 1978
1979 1979 In [2]: foo()\\
1980 1980 foo() was defined in an editing session
1981 1981
1982 1982 Now we edit foo. IPython automatically loads the editor with the
1983 1983 (temporary) file where foo() was previously defined:
1984 1984
1985 1985 In [3]: ed foo\\
1986 1986 Editing... done. Executing edited code...
1987 1987
1988 1988 And if we call foo() again we get the modified version:
1989 1989
1990 1990 In [4]: foo()\\
1991 1991 foo() has now been changed!
1992 1992
1993 1993 Here is an example of how to edit a code snippet successive
1994 1994 times. First we call the editor:
1995 1995
1996 1996 In [8]: ed\\
1997 1997 Editing... done. Executing edited code...\\
1998 1998 hello\\
1999 1999 Out[8]: "print 'hello'\\n"
2000 2000
2001 2001 Now we call it again with the previous output (stored in _):
2002 2002
2003 2003 In [9]: ed _\\
2004 2004 Editing... done. Executing edited code...\\
2005 2005 hello world\\
2006 2006 Out[9]: "print 'hello world'\\n"
2007 2007
2008 2008 Now we call it with the output #8 (stored in _8, also as Out[8]):
2009 2009
2010 2010 In [10]: ed _8\\
2011 2011 Editing... done. Executing edited code...\\
2012 2012 hello again\\
2013 2013 Out[10]: "print 'hello again'\\n"
2014 2014
2015 2015
2016 2016 Changing the default editor hook:
2017 2017
2018 2018 If you wish to write your own editor hook, you can put it in a
2019 2019 configuration file which you load at startup time. The default hook
2020 2020 is defined in the IPython.hooks module, and you can use that as a
2021 2021 starting example for further modifications. That file also has
2022 2022 general instructions on how to set a new hook for use once you've
2023 2023 defined it."""
2024 2024
2025 2025 # FIXME: This function has become a convoluted mess. It needs a
2026 2026 # ground-up rewrite with clean, simple logic.
2027 2027
2028 2028 def make_filename(arg):
2029 2029 "Make a filename from the given args"
2030 2030 try:
2031 2031 filename = get_py_filename(arg)
2032 2032 except IOError:
2033 2033 if args.endswith('.py'):
2034 2034 filename = arg
2035 2035 else:
2036 2036 filename = None
2037 2037 return filename
2038 2038
2039 2039 # custom exceptions
2040 2040 class DataIsObject(Exception): pass
2041 2041
2042 2042 opts,args = self.parse_options(parameter_s,'prxn:')
2043 2043 # Set a few locals from the options for convenience:
2044 2044 opts_p = opts.has_key('p')
2045 2045 opts_r = opts.has_key('r')
2046 2046
2047 2047 # Default line number value
2048 2048 lineno = opts.get('n',None)
2049 2049
2050 2050 if opts_p:
2051 2051 args = '_%s' % last_call[0]
2052 2052 if not self.shell.user_ns.has_key(args):
2053 2053 args = last_call[1]
2054 2054
2055 2055 # use last_call to remember the state of the previous call, but don't
2056 2056 # let it be clobbered by successive '-p' calls.
2057 2057 try:
2058 2058 last_call[0] = self.shell.outputcache.prompt_count
2059 2059 if not opts_p:
2060 2060 last_call[1] = parameter_s
2061 2061 except:
2062 2062 pass
2063 2063
2064 2064 # by default this is done with temp files, except when the given
2065 2065 # arg is a filename
2066 2066 use_temp = 1
2067 2067
2068 2068 if re.match(r'\d',args):
2069 2069 # Mode where user specifies ranges of lines, like in %macro.
2070 2070 # This means that you can't edit files whose names begin with
2071 2071 # numbers this way. Tough.
2072 2072 ranges = args.split()
2073 2073 data = ''.join(self.extract_input_slices(ranges,opts_r))
2074 2074 elif args.endswith('.py'):
2075 2075 filename = make_filename(args)
2076 2076 data = ''
2077 2077 use_temp = 0
2078 2078 elif args:
2079 2079 try:
2080 2080 # Load the parameter given as a variable. If not a string,
2081 2081 # process it as an object instead (below)
2082 2082
2083 2083 #print '*** args',args,'type',type(args) # dbg
2084 2084 data = eval(args,self.shell.user_ns)
2085 2085 if not type(data) in StringTypes:
2086 2086 raise DataIsObject
2087 2087
2088 2088 except (NameError,SyntaxError):
2089 2089 # given argument is not a variable, try as a filename
2090 2090 filename = make_filename(args)
2091 2091 if filename is None:
2092 2092 warn("Argument given (%s) can't be found as a variable "
2093 2093 "or as a filename." % args)
2094 2094 return
2095 2095
2096 2096 data = ''
2097 2097 use_temp = 0
2098 2098 except DataIsObject:
2099 2099
2100 2100 # macros have a special edit function
2101 2101 if isinstance(data,Macro):
2102 2102 self._edit_macro(args,data)
2103 2103 return
2104 2104
2105 2105 # For objects, try to edit the file where they are defined
2106 2106 try:
2107 2107 filename = inspect.getabsfile(data)
2108 2108 datafile = 1
2109 2109 except TypeError:
2110 2110 filename = make_filename(args)
2111 2111 datafile = 1
2112 2112 warn('Could not find file where `%s` is defined.\n'
2113 2113 'Opening a file named `%s`' % (args,filename))
2114 2114 # Now, make sure we can actually read the source (if it was in
2115 2115 # a temp file it's gone by now).
2116 2116 if datafile:
2117 2117 try:
2118 2118 if lineno is None:
2119 2119 lineno = inspect.getsourcelines(data)[1]
2120 2120 except IOError:
2121 2121 filename = make_filename(args)
2122 2122 if filename is None:
2123 2123 warn('The file `%s` where `%s` was defined cannot '
2124 2124 'be read.' % (filename,data))
2125 2125 return
2126 2126 use_temp = 0
2127 2127 else:
2128 2128 data = ''
2129 2129
2130 2130 if use_temp:
2131 2131 filename = self.shell.mktempfile(data)
2132 2132 print 'IPython will make a temporary file named:',filename
2133 2133
2134 2134 # do actual editing here
2135 2135 print 'Editing...',
2136 2136 sys.stdout.flush()
2137 2137 self.shell.hooks.editor(filename,lineno)
2138 2138 if opts.has_key('x'): # -x prevents actual execution
2139 2139 print
2140 2140 else:
2141 2141 print 'done. Executing edited code...'
2142 2142 if opts_r:
2143 2143 self.shell.runlines(file_read(filename))
2144 2144 else:
2145 2145 self.shell.safe_execfile(filename,self.shell.user_ns)
2146 2146 if use_temp:
2147 2147 try:
2148 2148 return open(filename).read()
2149 2149 except IOError,msg:
2150 2150 if msg.filename == filename:
2151 2151 warn('File not found. Did you forget to save?')
2152 2152 return
2153 2153 else:
2154 2154 self.shell.showtraceback()
2155 2155
2156 2156 def magic_xmode(self,parameter_s = ''):
2157 2157 """Switch modes for the exception handlers.
2158 2158
2159 2159 Valid modes: Plain, Context and Verbose.
2160 2160
2161 2161 If called without arguments, acts as a toggle."""
2162 2162
2163 2163 def xmode_switch_err(name):
2164 2164 warn('Error changing %s exception modes.\n%s' %
2165 2165 (name,sys.exc_info()[1]))
2166 2166
2167 2167 shell = self.shell
2168 2168 new_mode = parameter_s.strip().capitalize()
2169 2169 try:
2170 2170 shell.InteractiveTB.set_mode(mode=new_mode)
2171 2171 print 'Exception reporting mode:',shell.InteractiveTB.mode
2172 2172 except:
2173 2173 xmode_switch_err('user')
2174 2174
2175 2175 # threaded shells use a special handler in sys.excepthook
2176 2176 if shell.isthreaded:
2177 2177 try:
2178 2178 shell.sys_excepthook.set_mode(mode=new_mode)
2179 2179 except:
2180 2180 xmode_switch_err('threaded')
2181 2181
2182 2182 def magic_colors(self,parameter_s = ''):
2183 2183 """Switch color scheme for prompts, info system and exception handlers.
2184 2184
2185 2185 Currently implemented schemes: NoColor, Linux, LightBG.
2186 2186
2187 2187 Color scheme names are not case-sensitive."""
2188 2188
2189 2189 def color_switch_err(name):
2190 2190 warn('Error changing %s color schemes.\n%s' %
2191 2191 (name,sys.exc_info()[1]))
2192 2192
2193 2193
2194 2194 new_scheme = parameter_s.strip()
2195 2195 if not new_scheme:
2196 2196 print 'You must specify a color scheme.'
2197 2197 return
2198 2198 import IPython.rlineimpl as readline
2199 2199 if not readline.have_readline:
2200 2200 msg = """\
2201 2201 Proper color support under MS Windows requires Gary Bishop's readline library.
2202 2202 You can find it at:
2203 2203 http://sourceforge.net/projects/uncpythontools
2204 2204 Gary's readline needs the ctypes module, from:
2205 2205 http://starship.python.net/crew/theller/ctypes
2206 2206
2207 2207 Defaulting color scheme to 'NoColor'"""
2208 2208 new_scheme = 'NoColor'
2209 2209 warn(msg)
2210 2210 # local shortcut
2211 2211 shell = self.shell
2212 2212
2213 2213 # Set prompt colors
2214 2214 try:
2215 2215 shell.outputcache.set_colors(new_scheme)
2216 2216 except:
2217 2217 color_switch_err('prompt')
2218 2218 else:
2219 2219 shell.rc.colors = \
2220 2220 shell.outputcache.color_table.active_scheme_name
2221 2221 # Set exception colors
2222 2222 try:
2223 2223 shell.InteractiveTB.set_colors(scheme = new_scheme)
2224 2224 shell.SyntaxTB.set_colors(scheme = new_scheme)
2225 2225 except:
2226 2226 color_switch_err('exception')
2227 2227
2228 2228 # threaded shells use a verbose traceback in sys.excepthook
2229 2229 if shell.isthreaded:
2230 2230 try:
2231 2231 shell.sys_excepthook.set_colors(scheme=new_scheme)
2232 2232 except:
2233 2233 color_switch_err('system exception handler')
2234 2234
2235 2235 # Set info (for 'object?') colors
2236 2236 if shell.rc.color_info:
2237 2237 try:
2238 2238 shell.inspector.set_active_scheme(new_scheme)
2239 2239 except:
2240 2240 color_switch_err('object inspector')
2241 2241 else:
2242 2242 shell.inspector.set_active_scheme('NoColor')
2243 2243
2244 2244 def magic_color_info(self,parameter_s = ''):
2245 2245 """Toggle color_info.
2246 2246
2247 2247 The color_info configuration parameter controls whether colors are
2248 2248 used for displaying object details (by things like %psource, %pfile or
2249 2249 the '?' system). This function toggles this value with each call.
2250 2250
2251 2251 Note that unless you have a fairly recent pager (less works better
2252 2252 than more) in your system, using colored object information displays
2253 2253 will not work properly. Test it and see."""
2254 2254
2255 2255 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2256 2256 self.magic_colors(self.shell.rc.colors)
2257 2257 print 'Object introspection functions have now coloring:',
2258 2258 print ['OFF','ON'][self.shell.rc.color_info]
2259 2259
2260 2260 def magic_Pprint(self, parameter_s=''):
2261 2261 """Toggle pretty printing on/off."""
2262 2262
2263 2263 self.shell.rc.pprint = 1 - self.shell.rc.pprint
2264 2264 print 'Pretty printing has been turned', \
2265 2265 ['OFF','ON'][self.shell.rc.pprint]
2266 2266
2267 2267 def magic_exit(self, parameter_s=''):
2268 2268 """Exit IPython, confirming if configured to do so.
2269 2269
2270 2270 You can configure whether IPython asks for confirmation upon exit by
2271 2271 setting the confirm_exit flag in the ipythonrc file."""
2272 2272
2273 2273 self.shell.exit()
2274 2274
2275 2275 def magic_quit(self, parameter_s=''):
2276 2276 """Exit IPython, confirming if configured to do so (like %exit)"""
2277 2277
2278 2278 self.shell.exit()
2279 2279
2280 2280 def magic_Exit(self, parameter_s=''):
2281 2281 """Exit IPython without confirmation."""
2282 2282
2283 2283 self.shell.exit_now = True
2284 2284
2285 2285 def magic_Quit(self, parameter_s=''):
2286 2286 """Exit IPython without confirmation (like %Exit)."""
2287 2287
2288 2288 self.shell.exit_now = True
2289 2289
2290 2290 #......................................................................
2291 2291 # Functions to implement unix shell-type things
2292 2292
2293 2293 def magic_alias(self, parameter_s = ''):
2294 2294 """Define an alias for a system command.
2295 2295
2296 2296 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2297 2297
2298 2298 Then, typing 'alias_name params' will execute the system command 'cmd
2299 2299 params' (from your underlying operating system).
2300 2300
2301 2301 Aliases have lower precedence than magic functions and Python normal
2302 2302 variables, so if 'foo' is both a Python variable and an alias, the
2303 2303 alias can not be executed until 'del foo' removes the Python variable.
2304 2304
2305 2305 You can use the %l specifier in an alias definition to represent the
2306 2306 whole line when the alias is called. For example:
2307 2307
2308 2308 In [2]: alias all echo "Input in brackets: <%l>"\\
2309 2309 In [3]: all hello world\\
2310 2310 Input in brackets: <hello world>
2311 2311
2312 2312 You can also define aliases with parameters using %s specifiers (one
2313 2313 per parameter):
2314 2314
2315 2315 In [1]: alias parts echo first %s second %s\\
2316 2316 In [2]: %parts A B\\
2317 2317 first A second B\\
2318 2318 In [3]: %parts A\\
2319 2319 Incorrect number of arguments: 2 expected.\\
2320 2320 parts is an alias to: 'echo first %s second %s'
2321 2321
2322 2322 Note that %l and %s are mutually exclusive. You can only use one or
2323 2323 the other in your aliases.
2324 2324
2325 2325 Aliases expand Python variables just like system calls using ! or !!
2326 2326 do: all expressions prefixed with '$' get expanded. For details of
2327 2327 the semantic rules, see PEP-215:
2328 2328 http://www.python.org/peps/pep-0215.html. This is the library used by
2329 2329 IPython for variable expansion. If you want to access a true shell
2330 2330 variable, an extra $ is necessary to prevent its expansion by IPython:
2331 2331
2332 2332 In [6]: alias show echo\\
2333 2333 In [7]: PATH='A Python string'\\
2334 2334 In [8]: show $PATH\\
2335 2335 A Python string\\
2336 2336 In [9]: show $$PATH\\
2337 2337 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2338 2338
2339 2339 You can use the alias facility to acess all of $PATH. See the %rehash
2340 2340 and %rehashx functions, which automatically create aliases for the
2341 2341 contents of your $PATH.
2342 2342
2343 2343 If called with no parameters, %alias prints the current alias table."""
2344 2344
2345 2345 par = parameter_s.strip()
2346 2346 if not par:
2347 2347 if self.shell.rc.automagic:
2348 2348 prechar = ''
2349 2349 else:
2350 2350 prechar = self.shell.ESC_MAGIC
2351 2351 #print 'Alias\t\tSystem Command\n'+'-'*30
2352 2352 atab = self.shell.alias_table
2353 2353 aliases = atab.keys()
2354 2354 aliases.sort()
2355 2355 res = []
2356 2356 for alias in aliases:
2357 2357 res.append((alias, atab[alias][1]))
2358 2358 print "Total number of aliases:",len(aliases)
2359 2359 return res
2360 2360 try:
2361 2361 alias,cmd = par.split(None,1)
2362 2362 except:
2363 2363 print OInspect.getdoc(self.magic_alias)
2364 2364 else:
2365 2365 nargs = cmd.count('%s')
2366 2366 if nargs>0 and cmd.find('%l')>=0:
2367 2367 error('The %s and %l specifiers are mutually exclusive '
2368 2368 'in alias definitions.')
2369 2369 else: # all looks OK
2370 2370 self.shell.alias_table[alias] = (nargs,cmd)
2371 2371 self.shell.alias_table_validate(verbose=0)
2372 2372 # end magic_alias
2373 2373
2374 2374 def magic_unalias(self, parameter_s = ''):
2375 2375 """Remove an alias"""
2376 2376
2377 2377 aname = parameter_s.strip()
2378 2378 if aname in self.shell.alias_table:
2379 2379 del self.shell.alias_table[aname]
2380 2380
2381 2381 def magic_rehash(self, parameter_s = ''):
2382 2382 """Update the alias table with all entries in $PATH.
2383 2383
2384 2384 This version does no checks on execute permissions or whether the
2385 2385 contents of $PATH are truly files (instead of directories or something
2386 2386 else). For such a safer (but slower) version, use %rehashx."""
2387 2387
2388 2388 # This function (and rehashx) manipulate the alias_table directly
2389 2389 # rather than calling magic_alias, for speed reasons. A rehash on a
2390 2390 # typical Linux box involves several thousand entries, so efficiency
2391 2391 # here is a top concern.
2392 2392
2393 2393 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2394 2394 alias_table = self.shell.alias_table
2395 2395 for pdir in path:
2396 2396 for ff in os.listdir(pdir):
2397 2397 # each entry in the alias table must be (N,name), where
2398 2398 # N is the number of positional arguments of the alias.
2399 2399 alias_table[ff] = (0,ff)
2400 2400 # Make sure the alias table doesn't contain keywords or builtins
2401 2401 self.shell.alias_table_validate()
2402 2402 # Call again init_auto_alias() so we get 'rm -i' and other modified
2403 2403 # aliases since %rehash will probably clobber them
2404 2404 self.shell.init_auto_alias()
2405 2405
2406 2406 def magic_rehashx(self, parameter_s = ''):
2407 2407 """Update the alias table with all executable files in $PATH.
2408 2408
2409 2409 This version explicitly checks that every entry in $PATH is a file
2410 2410 with execute access (os.X_OK), so it is much slower than %rehash.
2411 2411
2412 2412 Under Windows, it checks executability as a match agains a
2413 2413 '|'-separated string of extensions, stored in the IPython config
2414 2414 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2415 2415
2416 2416 path = [os.path.abspath(os.path.expanduser(p)) for p in
2417 2417 os.environ['PATH'].split(os.pathsep)]
2418 2418 path = filter(os.path.isdir,path)
2419 2419
2420 2420 alias_table = self.shell.alias_table
2421 2421 syscmdlist = []
2422 2422 if os.name == 'posix':
2423 2423 isexec = lambda fname:os.path.isfile(fname) and \
2424 2424 os.access(fname,os.X_OK)
2425 2425 else:
2426 2426
2427 2427 try:
2428 2428 winext = os.environ['pathext'].replace(';','|').replace('.','')
2429 2429 except KeyError:
2430 2430 winext = 'exe|com|bat'
2431 2431
2432 2432 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2433 2433 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2434 2434 savedir = os.getcwd()
2435 2435 try:
2436 2436 # write the whole loop for posix/Windows so we don't have an if in
2437 2437 # the innermost part
2438 2438 if os.name == 'posix':
2439 2439 for pdir in path:
2440 2440 os.chdir(pdir)
2441 2441 for ff in os.listdir(pdir):
2442 2442 if isexec(ff) and ff not in self.shell.no_alias:
2443 2443 # each entry in the alias table must be (N,name),
2444 2444 # where N is the number of positional arguments of the
2445 2445 # alias.
2446 2446 alias_table[ff] = (0,ff)
2447 2447 syscmdlist.append(ff)
2448 2448 else:
2449 2449 for pdir in path:
2450 2450 os.chdir(pdir)
2451 2451 for ff in os.listdir(pdir):
2452 2452 if isexec(ff) and os.path.splitext(ff)[0] not in self.shell.no_alias:
2453 2453 alias_table[execre.sub(r'\1',ff)] = (0,ff)
2454 2454 syscmdlist.append(ff)
2455 2455 # Make sure the alias table doesn't contain keywords or builtins
2456 2456 self.shell.alias_table_validate()
2457 2457 # Call again init_auto_alias() so we get 'rm -i' and other
2458 2458 # modified aliases since %rehashx will probably clobber them
2459 2459 self.shell.init_auto_alias()
2460 2460 db = self.getapi().db
2461 2461 db['syscmdlist'] = syscmdlist
2462 2462 finally:
2463 2463 os.chdir(savedir)
2464 2464
2465 2465 def magic_pwd(self, parameter_s = ''):
2466 2466 """Return the current working directory path."""
2467 2467 return os.getcwd()
2468 2468
2469 2469 def magic_cd(self, parameter_s=''):
2470 2470 """Change the current working directory.
2471 2471
2472 2472 This command automatically maintains an internal list of directories
2473 2473 you visit during your IPython session, in the variable _dh. The
2474 2474 command %dhist shows this history nicely formatted.
2475 2475
2476 2476 Usage:
2477 2477
2478 2478 cd 'dir': changes to directory 'dir'.
2479 2479
2480 2480 cd -: changes to the last visited directory.
2481 2481
2482 2482 cd -<n>: changes to the n-th directory in the directory history.
2483 2483
2484 2484 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2485 2485 (note: cd <bookmark_name> is enough if there is no
2486 2486 directory <bookmark_name>, but a bookmark with the name exists.)
2487 2487
2488 2488 Options:
2489 2489
2490 2490 -q: quiet. Do not print the working directory after the cd command is
2491 2491 executed. By default IPython's cd command does print this directory,
2492 2492 since the default prompts do not display path information.
2493 2493
2494 2494 Note that !cd doesn't work for this purpose because the shell where
2495 2495 !command runs is immediately discarded after executing 'command'."""
2496 2496
2497 2497 parameter_s = parameter_s.strip()
2498 2498 #bkms = self.shell.persist.get("bookmarks",{})
2499 2499
2500 2500 numcd = re.match(r'(-)(\d+)$',parameter_s)
2501 2501 # jump in directory history by number
2502 2502 if numcd:
2503 2503 nn = int(numcd.group(2))
2504 2504 try:
2505 2505 ps = self.shell.user_ns['_dh'][nn]
2506 2506 except IndexError:
2507 2507 print 'The requested directory does not exist in history.'
2508 2508 return
2509 2509 else:
2510 2510 opts = {}
2511 2511 else:
2512 2512 #turn all non-space-escaping backslashes to slashes,
2513 2513 # for c:\windows\directory\names\
2514 2514 parameter_s = re.sub(r'\\(?! )','/', parameter_s)
2515 2515 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2516 2516 # jump to previous
2517 2517 if ps == '-':
2518 2518 try:
2519 2519 ps = self.shell.user_ns['_dh'][-2]
2520 2520 except IndexError:
2521 2521 print 'No previous directory to change to.'
2522 2522 return
2523 2523 # jump to bookmark if needed
2524 2524 else:
2525 2525 if not os.path.isdir(ps) or opts.has_key('b'):
2526 2526 bkms = self.db.get('bookmarks', {})
2527 2527
2528 2528 if bkms.has_key(ps):
2529 2529 target = bkms[ps]
2530 2530 print '(bookmark:%s) -> %s' % (ps,target)
2531 2531 ps = target
2532 2532 else:
2533 2533 if opts.has_key('b'):
2534 2534 error("Bookmark '%s' not found. "
2535 2535 "Use '%%bookmark -l' to see your bookmarks." % ps)
2536 2536 return
2537 2537
2538 2538 # at this point ps should point to the target dir
2539 2539 if ps:
2540 2540 try:
2541 2541 os.chdir(os.path.expanduser(ps))
2542 2542 ttitle = ("IPy:" + (
2543 2543 os.getcwd() == '/' and '/' or os.path.basename(os.getcwd())))
2544 2544 platutils.set_term_title(ttitle)
2545 2545 except OSError:
2546 2546 print sys.exc_info()[1]
2547 2547 else:
2548 2548 self.shell.user_ns['_dh'].append(os.getcwd())
2549 2549 else:
2550 2550 os.chdir(self.shell.home_dir)
2551 2551 platutils.set_term_title("IPy:~")
2552 2552 self.shell.user_ns['_dh'].append(os.getcwd())
2553 2553 if not 'q' in opts:
2554 2554 print self.shell.user_ns['_dh'][-1]
2555 2555
2556 2556 def magic_dhist(self, parameter_s=''):
2557 2557 """Print your history of visited directories.
2558 2558
2559 2559 %dhist -> print full history\\
2560 2560 %dhist n -> print last n entries only\\
2561 2561 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2562 2562
2563 2563 This history is automatically maintained by the %cd command, and
2564 2564 always available as the global list variable _dh. You can use %cd -<n>
2565 2565 to go to directory number <n>."""
2566 2566
2567 2567 dh = self.shell.user_ns['_dh']
2568 2568 if parameter_s:
2569 2569 try:
2570 2570 args = map(int,parameter_s.split())
2571 2571 except:
2572 2572 self.arg_err(Magic.magic_dhist)
2573 2573 return
2574 2574 if len(args) == 1:
2575 2575 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2576 2576 elif len(args) == 2:
2577 2577 ini,fin = args
2578 2578 else:
2579 2579 self.arg_err(Magic.magic_dhist)
2580 2580 return
2581 2581 else:
2582 2582 ini,fin = 0,len(dh)
2583 2583 nlprint(dh,
2584 2584 header = 'Directory history (kept in _dh)',
2585 2585 start=ini,stop=fin)
2586 2586
2587 2587 def magic_env(self, parameter_s=''):
2588 2588 """List environment variables."""
2589 2589
2590 2590 return os.environ.data
2591 2591
2592 2592 def magic_pushd(self, parameter_s=''):
2593 2593 """Place the current dir on stack and change directory.
2594 2594
2595 2595 Usage:\\
2596 2596 %pushd ['dirname']
2597 2597
2598 2598 %pushd with no arguments does a %pushd to your home directory.
2599 2599 """
2600 2600 if parameter_s == '': parameter_s = '~'
2601 2601 dir_s = self.shell.dir_stack
2602 2602 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2603 2603 os.path.expanduser(self.shell.dir_stack[0]):
2604 2604 try:
2605 2605 self.magic_cd(parameter_s)
2606 2606 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2607 2607 self.magic_dirs()
2608 2608 except:
2609 2609 print 'Invalid directory'
2610 2610 else:
2611 2611 print 'You are already there!'
2612 2612
2613 2613 def magic_popd(self, parameter_s=''):
2614 2614 """Change to directory popped off the top of the stack.
2615 2615 """
2616 2616 if len (self.shell.dir_stack) > 1:
2617 2617 self.shell.dir_stack.pop(0)
2618 2618 self.magic_cd(self.shell.dir_stack[0])
2619 2619 print self.shell.dir_stack[0]
2620 2620 else:
2621 2621 print "You can't remove the starting directory from the stack:",\
2622 2622 self.shell.dir_stack
2623 2623
2624 2624 def magic_dirs(self, parameter_s=''):
2625 2625 """Return the current directory stack."""
2626 2626
2627 2627 return self.shell.dir_stack[:]
2628 2628
2629 2629 def magic_sc(self, parameter_s=''):
2630 2630 """Shell capture - execute a shell command and capture its output.
2631 2631
2632 2632 DEPRECATED. Suboptimal, retained for backwards compatibility.
2633 2633
2634 2634 You should use the form 'var = !command' instead. Example:
2635 2635
2636 2636 "%sc -l myfiles = ls ~" should now be written as
2637 2637
2638 2638 "myfiles = !ls ~"
2639 2639
2640 2640 myfiles.s, myfiles.l and myfiles.n still apply as documented
2641 2641 below.
2642 2642
2643 2643 --
2644 2644 %sc [options] varname=command
2645 2645
2646 2646 IPython will run the given command using commands.getoutput(), and
2647 2647 will then update the user's interactive namespace with a variable
2648 2648 called varname, containing the value of the call. Your command can
2649 2649 contain shell wildcards, pipes, etc.
2650 2650
2651 2651 The '=' sign in the syntax is mandatory, and the variable name you
2652 2652 supply must follow Python's standard conventions for valid names.
2653 2653
2654 2654 (A special format without variable name exists for internal use)
2655 2655
2656 2656 Options:
2657 2657
2658 2658 -l: list output. Split the output on newlines into a list before
2659 2659 assigning it to the given variable. By default the output is stored
2660 2660 as a single string.
2661 2661
2662 2662 -v: verbose. Print the contents of the variable.
2663 2663
2664 2664 In most cases you should not need to split as a list, because the
2665 2665 returned value is a special type of string which can automatically
2666 2666 provide its contents either as a list (split on newlines) or as a
2667 2667 space-separated string. These are convenient, respectively, either
2668 2668 for sequential processing or to be passed to a shell command.
2669 2669
2670 2670 For example:
2671 2671
2672 2672 # Capture into variable a
2673 2673 In [9]: sc a=ls *py
2674 2674
2675 2675 # a is a string with embedded newlines
2676 2676 In [10]: a
2677 2677 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2678 2678
2679 2679 # which can be seen as a list:
2680 2680 In [11]: a.l
2681 2681 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2682 2682
2683 2683 # or as a whitespace-separated string:
2684 2684 In [12]: a.s
2685 2685 Out[12]: 'setup.py win32_manual_post_install.py'
2686 2686
2687 2687 # a.s is useful to pass as a single command line:
2688 2688 In [13]: !wc -l $a.s
2689 2689 146 setup.py
2690 2690 130 win32_manual_post_install.py
2691 2691 276 total
2692 2692
2693 2693 # while the list form is useful to loop over:
2694 2694 In [14]: for f in a.l:
2695 2695 ....: !wc -l $f
2696 2696 ....:
2697 2697 146 setup.py
2698 2698 130 win32_manual_post_install.py
2699 2699
2700 2700 Similiarly, the lists returned by the -l option are also special, in
2701 2701 the sense that you can equally invoke the .s attribute on them to
2702 2702 automatically get a whitespace-separated string from their contents:
2703 2703
2704 2704 In [1]: sc -l b=ls *py
2705 2705
2706 2706 In [2]: b
2707 2707 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2708 2708
2709 2709 In [3]: b.s
2710 2710 Out[3]: 'setup.py win32_manual_post_install.py'
2711 2711
2712 2712 In summary, both the lists and strings used for ouptut capture have
2713 2713 the following special attributes:
2714 2714
2715 2715 .l (or .list) : value as list.
2716 2716 .n (or .nlstr): value as newline-separated string.
2717 2717 .s (or .spstr): value as space-separated string.
2718 2718 """
2719 2719
2720 2720 opts,args = self.parse_options(parameter_s,'lv')
2721 2721 # Try to get a variable name and command to run
2722 2722 try:
2723 2723 # the variable name must be obtained from the parse_options
2724 2724 # output, which uses shlex.split to strip options out.
2725 2725 var,_ = args.split('=',1)
2726 2726 var = var.strip()
2727 2727 # But the the command has to be extracted from the original input
2728 2728 # parameter_s, not on what parse_options returns, to avoid the
2729 2729 # quote stripping which shlex.split performs on it.
2730 2730 _,cmd = parameter_s.split('=',1)
2731 2731 except ValueError:
2732 2732 var,cmd = '',''
2733 2733 # If all looks ok, proceed
2734 2734 out,err = self.shell.getoutputerror(cmd)
2735 2735 if err:
2736 2736 print >> Term.cerr,err
2737 2737 if opts.has_key('l'):
2738 2738 out = SList(out.split('\n'))
2739 2739 else:
2740 2740 out = LSString(out)
2741 2741 if opts.has_key('v'):
2742 2742 print '%s ==\n%s' % (var,pformat(out))
2743 2743 if var:
2744 2744 self.shell.user_ns.update({var:out})
2745 2745 else:
2746 2746 return out
2747 2747
2748 2748 def magic_sx(self, parameter_s=''):
2749 2749 """Shell execute - run a shell command and capture its output.
2750 2750
2751 2751 %sx command
2752 2752
2753 2753 IPython will run the given command using commands.getoutput(), and
2754 2754 return the result formatted as a list (split on '\\n'). Since the
2755 2755 output is _returned_, it will be stored in ipython's regular output
2756 2756 cache Out[N] and in the '_N' automatic variables.
2757 2757
2758 2758 Notes:
2759 2759
2760 2760 1) If an input line begins with '!!', then %sx is automatically
2761 2761 invoked. That is, while:
2762 2762 !ls
2763 2763 causes ipython to simply issue system('ls'), typing
2764 2764 !!ls
2765 2765 is a shorthand equivalent to:
2766 2766 %sx ls
2767 2767
2768 2768 2) %sx differs from %sc in that %sx automatically splits into a list,
2769 2769 like '%sc -l'. The reason for this is to make it as easy as possible
2770 2770 to process line-oriented shell output via further python commands.
2771 2771 %sc is meant to provide much finer control, but requires more
2772 2772 typing.
2773 2773
2774 2774 3) Just like %sc -l, this is a list with special attributes:
2775 2775
2776 2776 .l (or .list) : value as list.
2777 2777 .n (or .nlstr): value as newline-separated string.
2778 2778 .s (or .spstr): value as whitespace-separated string.
2779 2779
2780 2780 This is very useful when trying to use such lists as arguments to
2781 2781 system commands."""
2782 2782
2783 2783 if parameter_s:
2784 2784 out,err = self.shell.getoutputerror(parameter_s)
2785 2785 if err:
2786 2786 print >> Term.cerr,err
2787 2787 return SList(out.split('\n'))
2788 2788
2789 2789 def magic_bg(self, parameter_s=''):
2790 2790 """Run a job in the background, in a separate thread.
2791 2791
2792 2792 For example,
2793 2793
2794 2794 %bg myfunc(x,y,z=1)
2795 2795
2796 2796 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2797 2797 execution starts, a message will be printed indicating the job
2798 2798 number. If your job number is 5, you can use
2799 2799
2800 2800 myvar = jobs.result(5) or myvar = jobs[5].result
2801 2801
2802 2802 to assign this result to variable 'myvar'.
2803 2803
2804 2804 IPython has a job manager, accessible via the 'jobs' object. You can
2805 2805 type jobs? to get more information about it, and use jobs.<TAB> to see
2806 2806 its attributes. All attributes not starting with an underscore are
2807 2807 meant for public use.
2808 2808
2809 2809 In particular, look at the jobs.new() method, which is used to create
2810 2810 new jobs. This magic %bg function is just a convenience wrapper
2811 2811 around jobs.new(), for expression-based jobs. If you want to create a
2812 2812 new job with an explicit function object and arguments, you must call
2813 2813 jobs.new() directly.
2814 2814
2815 2815 The jobs.new docstring also describes in detail several important
2816 2816 caveats associated with a thread-based model for background job
2817 2817 execution. Type jobs.new? for details.
2818 2818
2819 2819 You can check the status of all jobs with jobs.status().
2820 2820
2821 2821 The jobs variable is set by IPython into the Python builtin namespace.
2822 2822 If you ever declare a variable named 'jobs', you will shadow this
2823 2823 name. You can either delete your global jobs variable to regain
2824 2824 access to the job manager, or make a new name and assign it manually
2825 2825 to the manager (stored in IPython's namespace). For example, to
2826 2826 assign the job manager to the Jobs name, use:
2827 2827
2828 2828 Jobs = __builtins__.jobs"""
2829 2829
2830 2830 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2831 2831
2832 2832
2833 2833 def magic_bookmark(self, parameter_s=''):
2834 2834 """Manage IPython's bookmark system.
2835 2835
2836 2836 %bookmark <name> - set bookmark to current dir
2837 2837 %bookmark <name> <dir> - set bookmark to <dir>
2838 2838 %bookmark -l - list all bookmarks
2839 2839 %bookmark -d <name> - remove bookmark
2840 2840 %bookmark -r - remove all bookmarks
2841 2841
2842 2842 You can later on access a bookmarked folder with:
2843 2843 %cd -b <name>
2844 2844 or simply '%cd <name>' if there is no directory called <name> AND
2845 2845 there is such a bookmark defined.
2846 2846
2847 2847 Your bookmarks persist through IPython sessions, but they are
2848 2848 associated with each profile."""
2849 2849
2850 2850 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2851 2851 if len(args) > 2:
2852 2852 error('You can only give at most two arguments')
2853 2853 return
2854 2854
2855 2855 bkms = self.db.get('bookmarks',{})
2856 2856
2857 2857 if opts.has_key('d'):
2858 2858 try:
2859 2859 todel = args[0]
2860 2860 except IndexError:
2861 2861 error('You must provide a bookmark to delete')
2862 2862 else:
2863 2863 try:
2864 2864 del bkms[todel]
2865 2865 except:
2866 2866 error("Can't delete bookmark '%s'" % todel)
2867 2867 elif opts.has_key('r'):
2868 2868 bkms = {}
2869 2869 elif opts.has_key('l'):
2870 2870 bks = bkms.keys()
2871 2871 bks.sort()
2872 2872 if bks:
2873 2873 size = max(map(len,bks))
2874 2874 else:
2875 2875 size = 0
2876 2876 fmt = '%-'+str(size)+'s -> %s'
2877 2877 print 'Current bookmarks:'
2878 2878 for bk in bks:
2879 2879 print fmt % (bk,bkms[bk])
2880 2880 else:
2881 2881 if not args:
2882 2882 error("You must specify the bookmark name")
2883 2883 elif len(args)==1:
2884 2884 bkms[args[0]] = os.getcwd()
2885 2885 elif len(args)==2:
2886 2886 bkms[args[0]] = args[1]
2887 2887 self.db['bookmarks'] = bkms
2888 2888
2889 2889 def magic_pycat(self, parameter_s=''):
2890 2890 """Show a syntax-highlighted file through a pager.
2891 2891
2892 2892 This magic is similar to the cat utility, but it will assume the file
2893 2893 to be Python source and will show it with syntax highlighting. """
2894 2894
2895 2895 try:
2896 2896 filename = get_py_filename(parameter_s)
2897 2897 cont = file_read(filename)
2898 2898 except IOError:
2899 2899 try:
2900 2900 cont = eval(parameter_s,self.user_ns)
2901 2901 except NameError:
2902 2902 cont = None
2903 2903 if cont is None:
2904 2904 print "Error: no such file or variable"
2905 2905 return
2906 2906
2907 2907 page(self.shell.pycolorize(cont),
2908 2908 screen_lines=self.shell.rc.screen_length)
2909 2909
2910 2910 def magic_cpaste(self, parameter_s=''):
2911 2911 """Allows you to paste & execute a pre-formatted code block from clipboard
2912 2912
2913 2913 You must terminate the block with '--' (two minus-signs) alone on the
2914 2914 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
2915 2915 is the new sentinel for this operation)
2916 2916
2917 2917 The block is dedented prior to execution to enable execution of
2918 method definitions. The executed block is also assigned to variable
2919 named 'pasted_block' for later editing with '%edit pasted_block'.
2918 method definitions. '>' characters at the beginning of a line is
2919 ignored, to allow pasting directly from e-mails. The executed block
2920 is also assigned to variable named 'pasted_block' for later editing
2921 with '%edit pasted_block'.
2920 2922
2921 2923 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
2922 2924 This assigns the pasted block to variable 'foo' as string, without
2923 2925 dedenting or executing it.
2924 2926
2925 2927 Do not be alarmed by garbled output on Windows (it's a readline bug).
2926 2928 Just press enter and type -- (and press enter again) and the block
2927 2929 will be what was just pasted.
2928 2930
2929 2931 IPython statements (magics, shell escapes) are not supported (yet).
2930 2932 """
2931 2933 opts,args = self.parse_options(parameter_s,'s:',mode='string')
2932 2934 par = args.strip()
2933 2935 sentinel = opts.get('s','--')
2934 2936
2935 2937 from IPython import iplib
2936 2938 lines = []
2937 2939 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
2938 2940 while 1:
2939 2941 l = iplib.raw_input_original(':')
2940 2942 if l ==sentinel:
2941 2943 break
2942 lines.append(l)
2944 lines.append(l.lstrip('>'))
2943 2945 block = "\n".join(lines) + '\n'
2944 2946 #print "block:\n",block
2945 2947 if not par:
2946 2948 b = textwrap.dedent(block)
2947 2949 exec b in self.user_ns
2948 2950 self.user_ns['pasted_block'] = b
2949 2951 else:
2950 2952 self.user_ns[par] = block
2951 2953 print "Block assigned to '%s'" % par
2952 2954
2953 2955 def magic_quickref(self,arg):
2954 2956 """ Show a quick reference sheet """
2955 2957 import IPython.usage
2956 2958 qr = IPython.usage.quick_reference + self.magic_magic('-brief')
2957 2959
2958 2960 page(qr)
2959 2961
2960 2962 def magic_upgrade(self,arg):
2961 2963 """ Upgrade your IPython installation
2962 2964
2963 2965 This will copy the config files that don't yet exist in your
2964 2966 ipython dir from the system config dir. Use this after upgrading
2965 2967 IPython if you don't wish to delete your .ipython dir.
2966 2968
2967 2969 Call with -nolegacy to get rid of ipythonrc* files (recommended for
2968 2970 new users)
2969 2971
2970 2972 """
2971 2973 ip = self.getapi()
2972 2974 ipinstallation = path(IPython.__file__).dirname()
2973 2975 upgrade_script = '%s "%s"' % (sys.executable,ipinstallation / 'upgrade_dir.py')
2974 2976 src_config = ipinstallation / 'UserConfig'
2975 2977 userdir = path(ip.options.ipythondir)
2976 2978 cmd = '%s "%s" "%s"' % (upgrade_script, src_config, userdir)
2977 2979 print ">",cmd
2978 2980 shell(cmd)
2979 2981 if arg == '-nolegacy':
2980 2982 legacy = userdir.files('ipythonrc*')
2981 2983 print "Nuking legacy files:",legacy
2982 2984
2983 2985 [p.remove() for p in legacy]
2984 2986 suffix = (sys.platform == 'win32' and '.ini' or '')
2985 2987 (userdir / ('ipythonrc' + suffix)).write_text('# Empty, see ipy_user_conf.py\n')
2986 2988
2987 2989
2988 2990 # end Magic
@@ -1,5636 +1,5642 b''
1 2006-07-08 Ville Vainio <vivainio@gmail.com>
2
3 * Magic.py: %cpaste now strips > from the beginning of lines
4 to ease pasting quoted code from emails. Contributed by
5 Stefan van der Walt.
6
1 7 2006-06-29 Ville Vainio <vivainio@gmail.com>
2 8
3 9 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
4 10 mode, patch contributed by Darren Dale. NEEDS TESTING!
5 11
6 12 2006-06-28 Walter Doerwald <walter@livinglogic.de>
7 13
8 14 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
9 15 a blue background. Fix fetching new display rows when the browser
10 16 scrolls more than a screenful (e.g. by using the goto command).
11 17
12 18 2006-06-27 Ville Vainio <vivainio@gmail.com>
13 19
14 20 * Magic.py (_inspect, _ofind) Apply David Huard's
15 21 patch for displaying the correct docstring for 'property'
16 22 attributes.
17 23
18 24 2006-06-23 Walter Doerwald <walter@livinglogic.de>
19 25
20 26 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
21 27 commands into the methods implementing them.
22 28
23 29 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
24 30
25 31 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
26 32 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
27 33 autoindent support was authored by Jin Liu.
28 34
29 35 2006-06-22 Walter Doerwald <walter@livinglogic.de>
30 36
31 37 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
32 38 for keymaps with a custom class that simplifies handling.
33 39
34 40 2006-06-19 Walter Doerwald <walter@livinglogic.de>
35 41
36 42 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
37 43 resizing. This requires Python 2.5 to work.
38 44
39 45 2006-06-16 Walter Doerwald <walter@livinglogic.de>
40 46
41 47 * IPython/Extensions/ibrowse.py: Add two new commands to
42 48 ibrowse: "hideattr" (mapped to "h") hides the attribute under
43 49 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
44 50 attributes again. Remapped the help command to "?". Display
45 51 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
46 52 as keys for the "home" and "end" commands. Add three new commands
47 53 to the input mode for "find" and friends: "delend" (CTRL-K)
48 54 deletes to the end of line. "incsearchup" searches upwards in the
49 55 command history for an input that starts with the text before the cursor.
50 56 "incsearchdown" does the same downwards. Removed a bogus mapping of
51 57 the x key to "delete".
52 58
53 59 2006-06-15 Ville Vainio <vivainio@gmail.com>
54 60
55 61 * iplib.py, hooks.py: Added new generate_prompt hook that can be
56 62 used to create prompts dynamically, instead of the "old" way of
57 63 assigning "magic" strings to prompt_in1 and prompt_in2. The old
58 64 way still works (it's invoked by the default hook), of course.
59 65
60 66 * Prompts.py: added generate_output_prompt hook for altering output
61 67 prompt
62 68
63 69 * Release.py: Changed version string to 0.7.3.svn.
64 70
65 71 2006-06-15 Walter Doerwald <walter@livinglogic.de>
66 72
67 73 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
68 74 the call to fetch() always tries to fetch enough data for at least one
69 75 full screen. This makes it possible to simply call moveto(0,0,True) in
70 76 the constructor. Fix typos and removed the obsolete goto attribute.
71 77
72 78 2006-06-12 Ville Vainio <vivainio@gmail.com>
73 79
74 80 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
75 81 allowing $variable interpolation within multiline statements,
76 82 though so far only with "sh" profile for a testing period.
77 83 The patch also enables splitting long commands with \ but it
78 84 doesn't work properly yet.
79 85
80 86 2006-06-12 Walter Doerwald <walter@livinglogic.de>
81 87
82 88 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
83 89 input history and the position of the cursor in the input history for
84 90 the find, findbackwards and goto command.
85 91
86 92 2006-06-10 Walter Doerwald <walter@livinglogic.de>
87 93
88 94 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
89 95 implements the basic functionality of browser commands that require
90 96 input. Reimplement the goto, find and findbackwards commands as
91 97 subclasses of _CommandInput. Add an input history and keymaps to those
92 98 commands. Add "\r" as a keyboard shortcut for the enterdefault and
93 99 execute commands.
94 100
95 101 2006-06-07 Ville Vainio <vivainio@gmail.com>
96 102
97 103 * iplib.py: ipython mybatch.ipy exits ipython immediately after
98 104 running the batch files instead of leaving the session open.
99 105
100 106 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
101 107
102 108 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
103 109 the original fix was incomplete. Patch submitted by W. Maier.
104 110
105 111 2006-06-07 Ville Vainio <vivainio@gmail.com>
106 112
107 113 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
108 114 Confirmation prompts can be supressed by 'quiet' option.
109 115 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
110 116
111 117 2006-06-06 *** Released version 0.7.2
112 118
113 119 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
114 120
115 121 * IPython/Release.py (version): Made 0.7.2 final for release.
116 122 Repo tagged and release cut.
117 123
118 124 2006-06-05 Ville Vainio <vivainio@gmail.com>
119 125
120 126 * Magic.py (magic_rehashx): Honor no_alias list earlier in
121 127 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
122 128
123 129 * upgrade_dir.py: try import 'path' module a bit harder
124 130 (for %upgrade)
125 131
126 132 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
127 133
128 134 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
129 135 instead of looping 20 times.
130 136
131 137 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
132 138 correctly at initialization time. Bug reported by Krishna Mohan
133 139 Gundu <gkmohan-AT-gmail.com> on the user list.
134 140
135 141 * IPython/Release.py (version): Mark 0.7.2 version to start
136 142 testing for release on 06/06.
137 143
138 144 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
139 145
140 146 * scripts/irunner: thin script interface so users don't have to
141 147 find the module and call it as an executable, since modules rarely
142 148 live in people's PATH.
143 149
144 150 * IPython/irunner.py (InteractiveRunner.__init__): added
145 151 delaybeforesend attribute to control delays with newer versions of
146 152 pexpect. Thanks to detailed help from pexpect's author, Noah
147 153 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
148 154 correctly (it works in NoColor mode).
149 155
150 156 * IPython/iplib.py (handle_normal): fix nasty crash reported on
151 157 SAGE list, from improper log() calls.
152 158
153 159 2006-05-31 Ville Vainio <vivainio@gmail.com>
154 160
155 161 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
156 162 with args in parens to work correctly with dirs that have spaces.
157 163
158 164 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
159 165
160 166 * IPython/Logger.py (Logger.logstart): add option to log raw input
161 167 instead of the processed one. A -r flag was added to the
162 168 %logstart magic used for controlling logging.
163 169
164 170 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
165 171
166 172 * IPython/iplib.py (InteractiveShell.__init__): add check for the
167 173 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
168 174 recognize the option. After a bug report by Will Maier. This
169 175 closes #64 (will do it after confirmation from W. Maier).
170 176
171 177 * IPython/irunner.py: New module to run scripts as if manually
172 178 typed into an interactive environment, based on pexpect. After a
173 179 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
174 180 ipython-user list. Simple unittests in the tests/ directory.
175 181
176 182 * tools/release: add Will Maier, OpenBSD port maintainer, to
177 183 recepients list. We are now officially part of the OpenBSD ports:
178 184 http://www.openbsd.org/ports.html ! Many thanks to Will for the
179 185 work.
180 186
181 187 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
182 188
183 189 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
184 190 so that it doesn't break tkinter apps.
185 191
186 192 * IPython/iplib.py (_prefilter): fix bug where aliases would
187 193 shadow variables when autocall was fully off. Reported by SAGE
188 194 author William Stein.
189 195
190 196 * IPython/OInspect.py (Inspector.__init__): add a flag to control
191 197 at what detail level strings are computed when foo? is requested.
192 198 This allows users to ask for example that the string form of an
193 199 object is only computed when foo?? is called, or even never, by
194 200 setting the object_info_string_level >= 2 in the configuration
195 201 file. This new option has been added and documented. After a
196 202 request by SAGE to be able to control the printing of very large
197 203 objects more easily.
198 204
199 205 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
200 206
201 207 * IPython/ipmaker.py (make_IPython): remove the ipython call path
202 208 from sys.argv, to be 100% consistent with how Python itself works
203 209 (as seen for example with python -i file.py). After a bug report
204 210 by Jeffrey Collins.
205 211
206 212 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
207 213 nasty bug which was preventing custom namespaces with -pylab,
208 214 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
209 215 compatibility (long gone from mpl).
210 216
211 217 * IPython/ipapi.py (make_session): name change: create->make. We
212 218 use make in other places (ipmaker,...), it's shorter and easier to
213 219 type and say, etc. I'm trying to clean things before 0.7.2 so
214 220 that I can keep things stable wrt to ipapi in the chainsaw branch.
215 221
216 222 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
217 223 python-mode recognizes our debugger mode. Add support for
218 224 autoindent inside (X)emacs. After a patch sent in by Jin Liu
219 225 <m.liu.jin-AT-gmail.com> originally written by
220 226 doxgen-AT-newsmth.net (with minor modifications for xemacs
221 227 compatibility)
222 228
223 229 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
224 230 tracebacks when walking the stack so that the stack tracking system
225 231 in emacs' python-mode can identify the frames correctly.
226 232
227 233 * IPython/ipmaker.py (make_IPython): make the internal (and
228 234 default config) autoedit_syntax value false by default. Too many
229 235 users have complained to me (both on and off-list) about problems
230 236 with this option being on by default, so I'm making it default to
231 237 off. It can still be enabled by anyone via the usual mechanisms.
232 238
233 239 * IPython/completer.py (Completer.attr_matches): add support for
234 240 PyCrust-style _getAttributeNames magic method. Patch contributed
235 241 by <mscott-AT-goldenspud.com>. Closes #50.
236 242
237 243 * IPython/iplib.py (InteractiveShell.__init__): remove the
238 244 deletion of exit/quit from __builtin__, which can break
239 245 third-party tools like the Zope debugging console. The
240 246 %exit/%quit magics remain. In general, it's probably a good idea
241 247 not to delete anything from __builtin__, since we never know what
242 248 that will break. In any case, python now (for 2.5) will support
243 249 'real' exit/quit, so this issue is moot. Closes #55.
244 250
245 251 * IPython/genutils.py (with_obj): rename the 'with' function to
246 252 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
247 253 becomes a language keyword. Closes #53.
248 254
249 255 * IPython/FakeModule.py (FakeModule.__init__): add a proper
250 256 __file__ attribute to this so it fools more things into thinking
251 257 it is a real module. Closes #59.
252 258
253 259 * IPython/Magic.py (magic_edit): add -n option to open the editor
254 260 at a specific line number. After a patch by Stefan van der Walt.
255 261
256 262 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
257 263
258 264 * IPython/iplib.py (edit_syntax_error): fix crash when for some
259 265 reason the file could not be opened. After automatic crash
260 266 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
261 267 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
262 268 (_should_recompile): Don't fire editor if using %bg, since there
263 269 is no file in the first place. From the same report as above.
264 270 (raw_input): protect against faulty third-party prefilters. After
265 271 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
266 272 while running under SAGE.
267 273
268 274 2006-05-23 Ville Vainio <vivainio@gmail.com>
269 275
270 276 * ipapi.py: Stripped down ip.to_user_ns() to work only as
271 277 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
272 278 now returns None (again), unless dummy is specifically allowed by
273 279 ipapi.get(allow_dummy=True).
274 280
275 281 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
276 282
277 283 * IPython: remove all 2.2-compatibility objects and hacks from
278 284 everywhere, since we only support 2.3 at this point. Docs
279 285 updated.
280 286
281 287 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
282 288 Anything requiring extra validation can be turned into a Python
283 289 property in the future. I used a property for the db one b/c
284 290 there was a nasty circularity problem with the initialization
285 291 order, which right now I don't have time to clean up.
286 292
287 293 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
288 294 another locking bug reported by Jorgen. I'm not 100% sure though,
289 295 so more testing is needed...
290 296
291 297 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
292 298
293 299 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
294 300 local variables from any routine in user code (typically executed
295 301 with %run) directly into the interactive namespace. Very useful
296 302 when doing complex debugging.
297 303 (IPythonNotRunning): Changed the default None object to a dummy
298 304 whose attributes can be queried as well as called without
299 305 exploding, to ease writing code which works transparently both in
300 306 and out of ipython and uses some of this API.
301 307
302 308 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
303 309
304 310 * IPython/hooks.py (result_display): Fix the fact that our display
305 311 hook was using str() instead of repr(), as the default python
306 312 console does. This had gone unnoticed b/c it only happened if
307 313 %Pprint was off, but the inconsistency was there.
308 314
309 315 2006-05-15 Ville Vainio <vivainio@gmail.com>
310 316
311 317 * Oinspect.py: Only show docstring for nonexisting/binary files
312 318 when doing object??, closing ticket #62
313 319
314 320 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
315 321
316 322 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
317 323 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
318 324 was being released in a routine which hadn't checked if it had
319 325 been the one to acquire it.
320 326
321 327 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
322 328
323 329 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
324 330
325 331 2006-04-11 Ville Vainio <vivainio@gmail.com>
326 332
327 333 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
328 334 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
329 335 prefilters, allowing stuff like magics and aliases in the file.
330 336
331 337 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
332 338 added. Supported now are "%clear in" and "%clear out" (clear input and
333 339 output history, respectively). Also fixed CachedOutput.flush to
334 340 properly flush the output cache.
335 341
336 342 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
337 343 half-success (and fail explicitly).
338 344
339 345 2006-03-28 Ville Vainio <vivainio@gmail.com>
340 346
341 347 * iplib.py: Fix quoting of aliases so that only argless ones
342 348 are quoted
343 349
344 350 2006-03-28 Ville Vainio <vivainio@gmail.com>
345 351
346 352 * iplib.py: Quote aliases with spaces in the name.
347 353 "c:\program files\blah\bin" is now legal alias target.
348 354
349 355 * ext_rehashdir.py: Space no longer allowed as arg
350 356 separator, since space is legal in path names.
351 357
352 358 2006-03-16 Ville Vainio <vivainio@gmail.com>
353 359
354 360 * upgrade_dir.py: Take path.py from Extensions, correcting
355 361 %upgrade magic
356 362
357 363 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
358 364
359 365 * hooks.py: Only enclose editor binary in quotes if legal and
360 366 necessary (space in the name, and is an existing file). Fixes a bug
361 367 reported by Zachary Pincus.
362 368
363 369 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
364 370
365 371 * Manual: thanks to a tip on proper color handling for Emacs, by
366 372 Eric J Haywiser <ejh1-AT-MIT.EDU>.
367 373
368 374 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
369 375 by applying the provided patch. Thanks to Liu Jin
370 376 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
371 377 XEmacs/Linux, I'm trusting the submitter that it actually helps
372 378 under win32/GNU Emacs. Will revisit if any problems are reported.
373 379
374 380 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
375 381
376 382 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
377 383 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
378 384
379 385 2006-03-12 Ville Vainio <vivainio@gmail.com>
380 386
381 387 * Magic.py (magic_timeit): Added %timeit magic, contributed by
382 388 Torsten Marek.
383 389
384 390 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
385 391
386 392 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
387 393 line ranges works again.
388 394
389 395 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
390 396
391 397 * IPython/iplib.py (showtraceback): add back sys.last_traceback
392 398 and friends, after a discussion with Zach Pincus on ipython-user.
393 399 I'm not 100% sure, but after thinking about it quite a bit, it may
394 400 be OK. Testing with the multithreaded shells didn't reveal any
395 401 problems, but let's keep an eye out.
396 402
397 403 In the process, I fixed a few things which were calling
398 404 self.InteractiveTB() directly (like safe_execfile), which is a
399 405 mistake: ALL exception reporting should be done by calling
400 406 self.showtraceback(), which handles state and tab-completion and
401 407 more.
402 408
403 409 2006-03-01 Ville Vainio <vivainio@gmail.com>
404 410
405 411 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
406 412 To use, do "from ipipe import *".
407 413
408 414 2006-02-24 Ville Vainio <vivainio@gmail.com>
409 415
410 416 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
411 417 "cleanly" and safely than the older upgrade mechanism.
412 418
413 419 2006-02-21 Ville Vainio <vivainio@gmail.com>
414 420
415 421 * Magic.py: %save works again.
416 422
417 423 2006-02-15 Ville Vainio <vivainio@gmail.com>
418 424
419 425 * Magic.py: %Pprint works again
420 426
421 427 * Extensions/ipy_sane_defaults.py: Provide everything provided
422 428 in default ipythonrc, to make it possible to have a completely empty
423 429 ipythonrc (and thus completely rc-file free configuration)
424 430
425 431 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
426 432
427 433 * IPython/hooks.py (editor): quote the call to the editor command,
428 434 to allow commands with spaces in them. Problem noted by watching
429 435 Ian Oswald's video about textpad under win32 at
430 436 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
431 437
432 438 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
433 439 describing magics (we haven't used @ for a loong time).
434 440
435 441 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
436 442 contributed by marienz to close
437 443 http://www.scipy.net/roundup/ipython/issue53.
438 444
439 445 2006-02-10 Ville Vainio <vivainio@gmail.com>
440 446
441 447 * genutils.py: getoutput now works in win32 too
442 448
443 449 * completer.py: alias and magic completion only invoked
444 450 at the first "item" in the line, to avoid "cd %store"
445 451 nonsense.
446 452
447 453 2006-02-09 Ville Vainio <vivainio@gmail.com>
448 454
449 455 * test/*: Added a unit testing framework (finally).
450 456 '%run runtests.py' to run test_*.
451 457
452 458 * ipapi.py: Exposed runlines and set_custom_exc
453 459
454 460 2006-02-07 Ville Vainio <vivainio@gmail.com>
455 461
456 462 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
457 463 instead use "f(1 2)" as before.
458 464
459 465 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
460 466
461 467 * IPython/demo.py (IPythonDemo): Add new classes to the demo
462 468 facilities, for demos processed by the IPython input filter
463 469 (IPythonDemo), and for running a script one-line-at-a-time as a
464 470 demo, both for pure Python (LineDemo) and for IPython-processed
465 471 input (IPythonLineDemo). After a request by Dave Kohel, from the
466 472 SAGE team.
467 473 (Demo.edit): added an edit() method to the demo objects, to edit
468 474 the in-memory copy of the last executed block.
469 475
470 476 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
471 477 processing to %edit, %macro and %save. These commands can now be
472 478 invoked on the unprocessed input as it was typed by the user
473 479 (without any prefilters applied). After requests by the SAGE team
474 480 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
475 481
476 482 2006-02-01 Ville Vainio <vivainio@gmail.com>
477 483
478 484 * setup.py, eggsetup.py: easy_install ipython==dev works
479 485 correctly now (on Linux)
480 486
481 487 * ipy_user_conf,ipmaker: user config changes, removed spurious
482 488 warnings
483 489
484 490 * iplib: if rc.banner is string, use it as is.
485 491
486 492 * Magic: %pycat accepts a string argument and pages it's contents.
487 493
488 494
489 495 2006-01-30 Ville Vainio <vivainio@gmail.com>
490 496
491 497 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
492 498 Now %store and bookmarks work through PickleShare, meaning that
493 499 concurrent access is possible and all ipython sessions see the
494 500 same database situation all the time, instead of snapshot of
495 501 the situation when the session was started. Hence, %bookmark
496 502 results are immediately accessible from othes sessions. The database
497 503 is also available for use by user extensions. See:
498 504 http://www.python.org/pypi/pickleshare
499 505
500 506 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
501 507
502 508 * aliases can now be %store'd
503 509
504 510 * path.py moved to Extensions so that pickleshare does not need
505 511 IPython-specific import. Extensions added to pythonpath right
506 512 at __init__.
507 513
508 514 * iplib.py: ipalias deprecated/redundant; aliases are converted and
509 515 called with _ip.system and the pre-transformed command string.
510 516
511 517 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
512 518
513 519 * IPython/iplib.py (interact): Fix that we were not catching
514 520 KeyboardInterrupt exceptions properly. I'm not quite sure why the
515 521 logic here had to change, but it's fixed now.
516 522
517 523 2006-01-29 Ville Vainio <vivainio@gmail.com>
518 524
519 525 * iplib.py: Try to import pyreadline on Windows.
520 526
521 527 2006-01-27 Ville Vainio <vivainio@gmail.com>
522 528
523 529 * iplib.py: Expose ipapi as _ip in builtin namespace.
524 530 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
525 531 and ip_set_hook (-> _ip.set_hook) redundant. % and !
526 532 syntax now produce _ip.* variant of the commands.
527 533
528 534 * "_ip.options().autoedit_syntax = 2" automatically throws
529 535 user to editor for syntax error correction without prompting.
530 536
531 537 2006-01-27 Ville Vainio <vivainio@gmail.com>
532 538
533 539 * ipmaker.py: Give "realistic" sys.argv for scripts (without
534 540 'ipython' at argv[0]) executed through command line.
535 541 NOTE: this DEPRECATES calling ipython with multiple scripts
536 542 ("ipython a.py b.py c.py")
537 543
538 544 * iplib.py, hooks.py: Added configurable input prefilter,
539 545 named 'input_prefilter'. See ext_rescapture.py for example
540 546 usage.
541 547
542 548 * ext_rescapture.py, Magic.py: Better system command output capture
543 549 through 'var = !ls' (deprecates user-visible %sc). Same notation
544 550 applies for magics, 'var = %alias' assigns alias list to var.
545 551
546 552 * ipapi.py: added meta() for accessing extension-usable data store.
547 553
548 554 * iplib.py: added InteractiveShell.getapi(). New magics should be
549 555 written doing self.getapi() instead of using the shell directly.
550 556
551 557 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
552 558 %store foo >> ~/myfoo.txt to store variables to files (in clean
553 559 textual form, not a restorable pickle).
554 560
555 561 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
556 562
557 563 * usage.py, Magic.py: added %quickref
558 564
559 565 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
560 566
561 567 * GetoptErrors when invoking magics etc. with wrong args
562 568 are now more helpful:
563 569 GetoptError: option -l not recognized (allowed: "qb" )
564 570
565 571 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
566 572
567 573 * IPython/demo.py (Demo.show): Flush stdout after each block, so
568 574 computationally intensive blocks don't appear to stall the demo.
569 575
570 576 2006-01-24 Ville Vainio <vivainio@gmail.com>
571 577
572 578 * iplib.py, hooks.py: 'result_display' hook can return a non-None
573 579 value to manipulate resulting history entry.
574 580
575 581 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
576 582 to instance methods of IPApi class, to make extending an embedded
577 583 IPython feasible. See ext_rehashdir.py for example usage.
578 584
579 585 * Merged 1071-1076 from branches/0.7.1
580 586
581 587
582 588 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
583 589
584 590 * tools/release (daystamp): Fix build tools to use the new
585 591 eggsetup.py script to build lightweight eggs.
586 592
587 593 * Applied changesets 1062 and 1064 before 0.7.1 release.
588 594
589 595 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
590 596 see the raw input history (without conversions like %ls ->
591 597 ipmagic("ls")). After a request from W. Stein, SAGE
592 598 (http://modular.ucsd.edu/sage) developer. This information is
593 599 stored in the input_hist_raw attribute of the IPython instance, so
594 600 developers can access it if needed (it's an InputList instance).
595 601
596 602 * Versionstring = 0.7.2.svn
597 603
598 604 * eggsetup.py: A separate script for constructing eggs, creates
599 605 proper launch scripts even on Windows (an .exe file in
600 606 \python24\scripts).
601 607
602 608 * ipapi.py: launch_new_instance, launch entry point needed for the
603 609 egg.
604 610
605 611 2006-01-23 Ville Vainio <vivainio@gmail.com>
606 612
607 613 * Added %cpaste magic for pasting python code
608 614
609 615 2006-01-22 Ville Vainio <vivainio@gmail.com>
610 616
611 617 * Merge from branches/0.7.1 into trunk, revs 1052-1057
612 618
613 619 * Versionstring = 0.7.2.svn
614 620
615 621 * eggsetup.py: A separate script for constructing eggs, creates
616 622 proper launch scripts even on Windows (an .exe file in
617 623 \python24\scripts).
618 624
619 625 * ipapi.py: launch_new_instance, launch entry point needed for the
620 626 egg.
621 627
622 628 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
623 629
624 630 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
625 631 %pfile foo would print the file for foo even if it was a binary.
626 632 Now, extensions '.so' and '.dll' are skipped.
627 633
628 634 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
629 635 bug, where macros would fail in all threaded modes. I'm not 100%
630 636 sure, so I'm going to put out an rc instead of making a release
631 637 today, and wait for feedback for at least a few days.
632 638
633 639 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
634 640 it...) the handling of pasting external code with autoindent on.
635 641 To get out of a multiline input, the rule will appear for most
636 642 users unchanged: two blank lines or change the indent level
637 643 proposed by IPython. But there is a twist now: you can
638 644 add/subtract only *one or two spaces*. If you add/subtract three
639 645 or more (unless you completely delete the line), IPython will
640 646 accept that line, and you'll need to enter a second one of pure
641 647 whitespace. I know it sounds complicated, but I can't find a
642 648 different solution that covers all the cases, with the right
643 649 heuristics. Hopefully in actual use, nobody will really notice
644 650 all these strange rules and things will 'just work'.
645 651
646 652 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
647 653
648 654 * IPython/iplib.py (interact): catch exceptions which can be
649 655 triggered asynchronously by signal handlers. Thanks to an
650 656 automatic crash report, submitted by Colin Kingsley
651 657 <tercel-AT-gentoo.org>.
652 658
653 659 2006-01-20 Ville Vainio <vivainio@gmail.com>
654 660
655 661 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
656 662 (%rehashdir, very useful, try it out) of how to extend ipython
657 663 with new magics. Also added Extensions dir to pythonpath to make
658 664 importing extensions easy.
659 665
660 666 * %store now complains when trying to store interactively declared
661 667 classes / instances of those classes.
662 668
663 669 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
664 670 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
665 671 if they exist, and ipy_user_conf.py with some defaults is created for
666 672 the user.
667 673
668 674 * Startup rehashing done by the config file, not InterpreterExec.
669 675 This means system commands are available even without selecting the
670 676 pysh profile. It's the sensible default after all.
671 677
672 678 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
673 679
674 680 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
675 681 multiline code with autoindent on working. But I am really not
676 682 sure, so this needs more testing. Will commit a debug-enabled
677 683 version for now, while I test it some more, so that Ville and
678 684 others may also catch any problems. Also made
679 685 self.indent_current_str() a method, to ensure that there's no
680 686 chance of the indent space count and the corresponding string
681 687 falling out of sync. All code needing the string should just call
682 688 the method.
683 689
684 690 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
685 691
686 692 * IPython/Magic.py (magic_edit): fix check for when users don't
687 693 save their output files, the try/except was in the wrong section.
688 694
689 695 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
690 696
691 697 * IPython/Magic.py (magic_run): fix __file__ global missing from
692 698 script's namespace when executed via %run. After a report by
693 699 Vivian.
694 700
695 701 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
696 702 when using python 2.4. The parent constructor changed in 2.4, and
697 703 we need to track it directly (we can't call it, as it messes up
698 704 readline and tab-completion inside our pdb would stop working).
699 705 After a bug report by R. Bernstein <rocky-AT-panix.com>.
700 706
701 707 2006-01-16 Ville Vainio <vivainio@gmail.com>
702 708
703 709 * Ipython/magic.py: Reverted back to old %edit functionality
704 710 that returns file contents on exit.
705 711
706 712 * IPython/path.py: Added Jason Orendorff's "path" module to
707 713 IPython tree, http://www.jorendorff.com/articles/python/path/.
708 714 You can get path objects conveniently through %sc, and !!, e.g.:
709 715 sc files=ls
710 716 for p in files.paths: # or files.p
711 717 print p,p.mtime
712 718
713 719 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
714 720 now work again without considering the exclusion regexp -
715 721 hence, things like ',foo my/path' turn to 'foo("my/path")'
716 722 instead of syntax error.
717 723
718 724
719 725 2006-01-14 Ville Vainio <vivainio@gmail.com>
720 726
721 727 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
722 728 ipapi decorators for python 2.4 users, options() provides access to rc
723 729 data.
724 730
725 731 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
726 732 as path separators (even on Linux ;-). Space character after
727 733 backslash (as yielded by tab completer) is still space;
728 734 "%cd long\ name" works as expected.
729 735
730 736 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
731 737 as "chain of command", with priority. API stays the same,
732 738 TryNext exception raised by a hook function signals that
733 739 current hook failed and next hook should try handling it, as
734 740 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
735 741 requested configurable display hook, which is now implemented.
736 742
737 743 2006-01-13 Ville Vainio <vivainio@gmail.com>
738 744
739 745 * IPython/platutils*.py: platform specific utility functions,
740 746 so far only set_term_title is implemented (change terminal
741 747 label in windowing systems). %cd now changes the title to
742 748 current dir.
743 749
744 750 * IPython/Release.py: Added myself to "authors" list,
745 751 had to create new files.
746 752
747 753 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
748 754 shell escape; not a known bug but had potential to be one in the
749 755 future.
750 756
751 757 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
752 758 extension API for IPython! See the module for usage example. Fix
753 759 OInspect for docstring-less magic functions.
754 760
755 761
756 762 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
757 763
758 764 * IPython/iplib.py (raw_input): temporarily deactivate all
759 765 attempts at allowing pasting of code with autoindent on. It
760 766 introduced bugs (reported by Prabhu) and I can't seem to find a
761 767 robust combination which works in all cases. Will have to revisit
762 768 later.
763 769
764 770 * IPython/genutils.py: remove isspace() function. We've dropped
765 771 2.2 compatibility, so it's OK to use the string method.
766 772
767 773 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
768 774
769 775 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
770 776 matching what NOT to autocall on, to include all python binary
771 777 operators (including things like 'and', 'or', 'is' and 'in').
772 778 Prompted by a bug report on 'foo & bar', but I realized we had
773 779 many more potential bug cases with other operators. The regexp is
774 780 self.re_exclude_auto, it's fairly commented.
775 781
776 782 2006-01-12 Ville Vainio <vivainio@gmail.com>
777 783
778 784 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
779 785 Prettified and hardened string/backslash quoting with ipsystem(),
780 786 ipalias() and ipmagic(). Now even \ characters are passed to
781 787 %magics, !shell escapes and aliases exactly as they are in the
782 788 ipython command line. Should improve backslash experience,
783 789 particularly in Windows (path delimiter for some commands that
784 790 won't understand '/'), but Unix benefits as well (regexps). %cd
785 791 magic still doesn't support backslash path delimiters, though. Also
786 792 deleted all pretense of supporting multiline command strings in
787 793 !system or %magic commands. Thanks to Jerry McRae for suggestions.
788 794
789 795 * doc/build_doc_instructions.txt added. Documentation on how to
790 796 use doc/update_manual.py, added yesterday. Both files contributed
791 797 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
792 798 doc/*.sh for deprecation at a later date.
793 799
794 800 * /ipython.py Added ipython.py to root directory for
795 801 zero-installation (tar xzvf ipython.tgz; cd ipython; python
796 802 ipython.py) and development convenience (no need to keep doing
797 803 "setup.py install" between changes).
798 804
799 805 * Made ! and !! shell escapes work (again) in multiline expressions:
800 806 if 1:
801 807 !ls
802 808 !!ls
803 809
804 810 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
805 811
806 812 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
807 813 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
808 814 module in case-insensitive installation. Was causing crashes
809 815 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
810 816
811 817 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
812 818 <marienz-AT-gentoo.org>, closes
813 819 http://www.scipy.net/roundup/ipython/issue51.
814 820
815 821 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
816 822
817 823 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
818 824 problem of excessive CPU usage under *nix and keyboard lag under
819 825 win32.
820 826
821 827 2006-01-10 *** Released version 0.7.0
822 828
823 829 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
824 830
825 831 * IPython/Release.py (revision): tag version number to 0.7.0,
826 832 ready for release.
827 833
828 834 * IPython/Magic.py (magic_edit): Add print statement to %edit so
829 835 it informs the user of the name of the temp. file used. This can
830 836 help if you decide later to reuse that same file, so you know
831 837 where to copy the info from.
832 838
833 839 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
834 840
835 841 * setup_bdist_egg.py: little script to build an egg. Added
836 842 support in the release tools as well.
837 843
838 844 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
839 845
840 846 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
841 847 version selection (new -wxversion command line and ipythonrc
842 848 parameter). Patch contributed by Arnd Baecker
843 849 <arnd.baecker-AT-web.de>.
844 850
845 851 * IPython/iplib.py (embed_mainloop): fix tab-completion in
846 852 embedded instances, for variables defined at the interactive
847 853 prompt of the embedded ipython. Reported by Arnd.
848 854
849 855 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
850 856 it can be used as a (stateful) toggle, or with a direct parameter.
851 857
852 858 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
853 859 could be triggered in certain cases and cause the traceback
854 860 printer not to work.
855 861
856 862 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
857 863
858 864 * IPython/iplib.py (_should_recompile): Small fix, closes
859 865 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
860 866
861 867 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
862 868
863 869 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
864 870 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
865 871 Moad for help with tracking it down.
866 872
867 873 * IPython/iplib.py (handle_auto): fix autocall handling for
868 874 objects which support BOTH __getitem__ and __call__ (so that f [x]
869 875 is left alone, instead of becoming f([x]) automatically).
870 876
871 877 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
872 878 Ville's patch.
873 879
874 880 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
875 881
876 882 * IPython/iplib.py (handle_auto): changed autocall semantics to
877 883 include 'smart' mode, where the autocall transformation is NOT
878 884 applied if there are no arguments on the line. This allows you to
879 885 just type 'foo' if foo is a callable to see its internal form,
880 886 instead of having it called with no arguments (typically a
881 887 mistake). The old 'full' autocall still exists: for that, you
882 888 need to set the 'autocall' parameter to 2 in your ipythonrc file.
883 889
884 890 * IPython/completer.py (Completer.attr_matches): add
885 891 tab-completion support for Enthoughts' traits. After a report by
886 892 Arnd and a patch by Prabhu.
887 893
888 894 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
889 895
890 896 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
891 897 Schmolck's patch to fix inspect.getinnerframes().
892 898
893 899 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
894 900 for embedded instances, regarding handling of namespaces and items
895 901 added to the __builtin__ one. Multiple embedded instances and
896 902 recursive embeddings should work better now (though I'm not sure
897 903 I've got all the corner cases fixed, that code is a bit of a brain
898 904 twister).
899 905
900 906 * IPython/Magic.py (magic_edit): added support to edit in-memory
901 907 macros (automatically creates the necessary temp files). %edit
902 908 also doesn't return the file contents anymore, it's just noise.
903 909
904 910 * IPython/completer.py (Completer.attr_matches): revert change to
905 911 complete only on attributes listed in __all__. I realized it
906 912 cripples the tab-completion system as a tool for exploring the
907 913 internals of unknown libraries (it renders any non-__all__
908 914 attribute off-limits). I got bit by this when trying to see
909 915 something inside the dis module.
910 916
911 917 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
912 918
913 919 * IPython/iplib.py (InteractiveShell.__init__): add .meta
914 920 namespace for users and extension writers to hold data in. This
915 921 follows the discussion in
916 922 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
917 923
918 924 * IPython/completer.py (IPCompleter.complete): small patch to help
919 925 tab-completion under Emacs, after a suggestion by John Barnard
920 926 <barnarj-AT-ccf.org>.
921 927
922 928 * IPython/Magic.py (Magic.extract_input_slices): added support for
923 929 the slice notation in magics to use N-M to represent numbers N...M
924 930 (closed endpoints). This is used by %macro and %save.
925 931
926 932 * IPython/completer.py (Completer.attr_matches): for modules which
927 933 define __all__, complete only on those. After a patch by Jeffrey
928 934 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
929 935 speed up this routine.
930 936
931 937 * IPython/Logger.py (Logger.log): fix a history handling bug. I
932 938 don't know if this is the end of it, but the behavior now is
933 939 certainly much more correct. Note that coupled with macros,
934 940 slightly surprising (at first) behavior may occur: a macro will in
935 941 general expand to multiple lines of input, so upon exiting, the
936 942 in/out counters will both be bumped by the corresponding amount
937 943 (as if the macro's contents had been typed interactively). Typing
938 944 %hist will reveal the intermediate (silently processed) lines.
939 945
940 946 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
941 947 pickle to fail (%run was overwriting __main__ and not restoring
942 948 it, but pickle relies on __main__ to operate).
943 949
944 950 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
945 951 using properties, but forgot to make the main InteractiveShell
946 952 class a new-style class. Properties fail silently, and
947 953 mysteriously, with old-style class (getters work, but
948 954 setters don't do anything).
949 955
950 956 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
951 957
952 958 * IPython/Magic.py (magic_history): fix history reporting bug (I
953 959 know some nasties are still there, I just can't seem to find a
954 960 reproducible test case to track them down; the input history is
955 961 falling out of sync...)
956 962
957 963 * IPython/iplib.py (handle_shell_escape): fix bug where both
958 964 aliases and system accesses where broken for indented code (such
959 965 as loops).
960 966
961 967 * IPython/genutils.py (shell): fix small but critical bug for
962 968 win32 system access.
963 969
964 970 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
965 971
966 972 * IPython/iplib.py (showtraceback): remove use of the
967 973 sys.last_{type/value/traceback} structures, which are non
968 974 thread-safe.
969 975 (_prefilter): change control flow to ensure that we NEVER
970 976 introspect objects when autocall is off. This will guarantee that
971 977 having an input line of the form 'x.y', where access to attribute
972 978 'y' has side effects, doesn't trigger the side effect TWICE. It
973 979 is important to note that, with autocall on, these side effects
974 980 can still happen.
975 981 (ipsystem): new builtin, to complete the ip{magic/alias/system}
976 982 trio. IPython offers these three kinds of special calls which are
977 983 not python code, and it's a good thing to have their call method
978 984 be accessible as pure python functions (not just special syntax at
979 985 the command line). It gives us a better internal implementation
980 986 structure, as well as exposing these for user scripting more
981 987 cleanly.
982 988
983 989 * IPython/macro.py (Macro.__init__): moved macros to a standalone
984 990 file. Now that they'll be more likely to be used with the
985 991 persistance system (%store), I want to make sure their module path
986 992 doesn't change in the future, so that we don't break things for
987 993 users' persisted data.
988 994
989 995 * IPython/iplib.py (autoindent_update): move indentation
990 996 management into the _text_ processing loop, not the keyboard
991 997 interactive one. This is necessary to correctly process non-typed
992 998 multiline input (such as macros).
993 999
994 1000 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
995 1001 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
996 1002 which was producing problems in the resulting manual.
997 1003 (magic_whos): improve reporting of instances (show their class,
998 1004 instead of simply printing 'instance' which isn't terribly
999 1005 informative).
1000 1006
1001 1007 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
1002 1008 (minor mods) to support network shares under win32.
1003 1009
1004 1010 * IPython/winconsole.py (get_console_size): add new winconsole
1005 1011 module and fixes to page_dumb() to improve its behavior under
1006 1012 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
1007 1013
1008 1014 * IPython/Magic.py (Macro): simplified Macro class to just
1009 1015 subclass list. We've had only 2.2 compatibility for a very long
1010 1016 time, yet I was still avoiding subclassing the builtin types. No
1011 1017 more (I'm also starting to use properties, though I won't shift to
1012 1018 2.3-specific features quite yet).
1013 1019 (magic_store): added Ville's patch for lightweight variable
1014 1020 persistence, after a request on the user list by Matt Wilkie
1015 1021 <maphew-AT-gmail.com>. The new %store magic's docstring has full
1016 1022 details.
1017 1023
1018 1024 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1019 1025 changed the default logfile name from 'ipython.log' to
1020 1026 'ipython_log.py'. These logs are real python files, and now that
1021 1027 we have much better multiline support, people are more likely to
1022 1028 want to use them as such. Might as well name them correctly.
1023 1029
1024 1030 * IPython/Magic.py: substantial cleanup. While we can't stop
1025 1031 using magics as mixins, due to the existing customizations 'out
1026 1032 there' which rely on the mixin naming conventions, at least I
1027 1033 cleaned out all cross-class name usage. So once we are OK with
1028 1034 breaking compatibility, the two systems can be separated.
1029 1035
1030 1036 * IPython/Logger.py: major cleanup. This one is NOT a mixin
1031 1037 anymore, and the class is a fair bit less hideous as well. New
1032 1038 features were also introduced: timestamping of input, and logging
1033 1039 of output results. These are user-visible with the -t and -o
1034 1040 options to %logstart. Closes
1035 1041 http://www.scipy.net/roundup/ipython/issue11 and a request by
1036 1042 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
1037 1043
1038 1044 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
1039 1045
1040 1046 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
1041 1047 better handle backslashes in paths. See the thread 'More Windows
1042 1048 questions part 2 - \/ characters revisited' on the iypthon user
1043 1049 list:
1044 1050 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
1045 1051
1046 1052 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
1047 1053
1048 1054 (InteractiveShell.__init__): change threaded shells to not use the
1049 1055 ipython crash handler. This was causing more problems than not,
1050 1056 as exceptions in the main thread (GUI code, typically) would
1051 1057 always show up as a 'crash', when they really weren't.
1052 1058
1053 1059 The colors and exception mode commands (%colors/%xmode) have been
1054 1060 synchronized to also take this into account, so users can get
1055 1061 verbose exceptions for their threaded code as well. I also added
1056 1062 support for activating pdb inside this exception handler as well,
1057 1063 so now GUI authors can use IPython's enhanced pdb at runtime.
1058 1064
1059 1065 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
1060 1066 true by default, and add it to the shipped ipythonrc file. Since
1061 1067 this asks the user before proceeding, I think it's OK to make it
1062 1068 true by default.
1063 1069
1064 1070 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
1065 1071 of the previous special-casing of input in the eval loop. I think
1066 1072 this is cleaner, as they really are commands and shouldn't have
1067 1073 a special role in the middle of the core code.
1068 1074
1069 1075 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
1070 1076
1071 1077 * IPython/iplib.py (edit_syntax_error): added support for
1072 1078 automatically reopening the editor if the file had a syntax error
1073 1079 in it. Thanks to scottt who provided the patch at:
1074 1080 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
1075 1081 version committed).
1076 1082
1077 1083 * IPython/iplib.py (handle_normal): add suport for multi-line
1078 1084 input with emtpy lines. This fixes
1079 1085 http://www.scipy.net/roundup/ipython/issue43 and a similar
1080 1086 discussion on the user list.
1081 1087
1082 1088 WARNING: a behavior change is necessarily introduced to support
1083 1089 blank lines: now a single blank line with whitespace does NOT
1084 1090 break the input loop, which means that when autoindent is on, by
1085 1091 default hitting return on the next (indented) line does NOT exit.
1086 1092
1087 1093 Instead, to exit a multiline input you can either have:
1088 1094
1089 1095 - TWO whitespace lines (just hit return again), or
1090 1096 - a single whitespace line of a different length than provided
1091 1097 by the autoindent (add or remove a space).
1092 1098
1093 1099 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
1094 1100 module to better organize all readline-related functionality.
1095 1101 I've deleted FlexCompleter and put all completion clases here.
1096 1102
1097 1103 * IPython/iplib.py (raw_input): improve indentation management.
1098 1104 It is now possible to paste indented code with autoindent on, and
1099 1105 the code is interpreted correctly (though it still looks bad on
1100 1106 screen, due to the line-oriented nature of ipython).
1101 1107 (MagicCompleter.complete): change behavior so that a TAB key on an
1102 1108 otherwise empty line actually inserts a tab, instead of completing
1103 1109 on the entire global namespace. This makes it easier to use the
1104 1110 TAB key for indentation. After a request by Hans Meine
1105 1111 <hans_meine-AT-gmx.net>
1106 1112 (_prefilter): add support so that typing plain 'exit' or 'quit'
1107 1113 does a sensible thing. Originally I tried to deviate as little as
1108 1114 possible from the default python behavior, but even that one may
1109 1115 change in this direction (thread on python-dev to that effect).
1110 1116 Regardless, ipython should do the right thing even if CPython's
1111 1117 '>>>' prompt doesn't.
1112 1118 (InteractiveShell): removed subclassing code.InteractiveConsole
1113 1119 class. By now we'd overridden just about all of its methods: I've
1114 1120 copied the remaining two over, and now ipython is a standalone
1115 1121 class. This will provide a clearer picture for the chainsaw
1116 1122 branch refactoring.
1117 1123
1118 1124 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
1119 1125
1120 1126 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
1121 1127 failures for objects which break when dir() is called on them.
1122 1128
1123 1129 * IPython/FlexCompleter.py (Completer.__init__): Added support for
1124 1130 distinct local and global namespaces in the completer API. This
1125 1131 change allows us to properly handle completion with distinct
1126 1132 scopes, including in embedded instances (this had never really
1127 1133 worked correctly).
1128 1134
1129 1135 Note: this introduces a change in the constructor for
1130 1136 MagicCompleter, as a new global_namespace parameter is now the
1131 1137 second argument (the others were bumped one position).
1132 1138
1133 1139 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
1134 1140
1135 1141 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1136 1142 embedded instances (which can be done now thanks to Vivian's
1137 1143 frame-handling fixes for pdb).
1138 1144 (InteractiveShell.__init__): Fix namespace handling problem in
1139 1145 embedded instances. We were overwriting __main__ unconditionally,
1140 1146 and this should only be done for 'full' (non-embedded) IPython;
1141 1147 embedded instances must respect the caller's __main__. Thanks to
1142 1148 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
1143 1149
1144 1150 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
1145 1151
1146 1152 * setup.py: added download_url to setup(). This registers the
1147 1153 download address at PyPI, which is not only useful to humans
1148 1154 browsing the site, but is also picked up by setuptools (the Eggs
1149 1155 machinery). Thanks to Ville and R. Kern for the info/discussion
1150 1156 on this.
1151 1157
1152 1158 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
1153 1159
1154 1160 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
1155 1161 This brings a lot of nice functionality to the pdb mode, which now
1156 1162 has tab-completion, syntax highlighting, and better stack handling
1157 1163 than before. Many thanks to Vivian De Smedt
1158 1164 <vivian-AT-vdesmedt.com> for the original patches.
1159 1165
1160 1166 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
1161 1167
1162 1168 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
1163 1169 sequence to consistently accept the banner argument. The
1164 1170 inconsistency was tripping SAGE, thanks to Gary Zablackis
1165 1171 <gzabl-AT-yahoo.com> for the report.
1166 1172
1167 1173 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1168 1174
1169 1175 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1170 1176 Fix bug where a naked 'alias' call in the ipythonrc file would
1171 1177 cause a crash. Bug reported by Jorgen Stenarson.
1172 1178
1173 1179 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1174 1180
1175 1181 * IPython/ipmaker.py (make_IPython): cleanups which should improve
1176 1182 startup time.
1177 1183
1178 1184 * IPython/iplib.py (runcode): my globals 'fix' for embedded
1179 1185 instances had introduced a bug with globals in normal code. Now
1180 1186 it's working in all cases.
1181 1187
1182 1188 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
1183 1189 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
1184 1190 has been introduced to set the default case sensitivity of the
1185 1191 searches. Users can still select either mode at runtime on a
1186 1192 per-search basis.
1187 1193
1188 1194 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
1189 1195
1190 1196 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
1191 1197 attributes in wildcard searches for subclasses. Modified version
1192 1198 of a patch by Jorgen.
1193 1199
1194 1200 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
1195 1201
1196 1202 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
1197 1203 embedded instances. I added a user_global_ns attribute to the
1198 1204 InteractiveShell class to handle this.
1199 1205
1200 1206 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
1201 1207
1202 1208 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
1203 1209 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
1204 1210 (reported under win32, but may happen also in other platforms).
1205 1211 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
1206 1212
1207 1213 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
1208 1214
1209 1215 * IPython/Magic.py (magic_psearch): new support for wildcard
1210 1216 patterns. Now, typing ?a*b will list all names which begin with a
1211 1217 and end in b, for example. The %psearch magic has full
1212 1218 docstrings. Many thanks to JΓΆrgen Stenarson
1213 1219 <jorgen.stenarson-AT-bostream.nu>, author of the patches
1214 1220 implementing this functionality.
1215 1221
1216 1222 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1217 1223
1218 1224 * Manual: fixed long-standing annoyance of double-dashes (as in
1219 1225 --prefix=~, for example) being stripped in the HTML version. This
1220 1226 is a latex2html bug, but a workaround was provided. Many thanks
1221 1227 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
1222 1228 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
1223 1229 rolling. This seemingly small issue had tripped a number of users
1224 1230 when first installing, so I'm glad to see it gone.
1225 1231
1226 1232 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1227 1233
1228 1234 * IPython/Extensions/numeric_formats.py: fix missing import,
1229 1235 reported by Stephen Walton.
1230 1236
1231 1237 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
1232 1238
1233 1239 * IPython/demo.py: finish demo module, fully documented now.
1234 1240
1235 1241 * IPython/genutils.py (file_read): simple little utility to read a
1236 1242 file and ensure it's closed afterwards.
1237 1243
1238 1244 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
1239 1245
1240 1246 * IPython/demo.py (Demo.__init__): added support for individually
1241 1247 tagging blocks for automatic execution.
1242 1248
1243 1249 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
1244 1250 syntax-highlighted python sources, requested by John.
1245 1251
1246 1252 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
1247 1253
1248 1254 * IPython/demo.py (Demo.again): fix bug where again() blocks after
1249 1255 finishing.
1250 1256
1251 1257 * IPython/genutils.py (shlex_split): moved from Magic to here,
1252 1258 where all 2.2 compatibility stuff lives. I needed it for demo.py.
1253 1259
1254 1260 * IPython/demo.py (Demo.__init__): added support for silent
1255 1261 blocks, improved marks as regexps, docstrings written.
1256 1262 (Demo.__init__): better docstring, added support for sys.argv.
1257 1263
1258 1264 * IPython/genutils.py (marquee): little utility used by the demo
1259 1265 code, handy in general.
1260 1266
1261 1267 * IPython/demo.py (Demo.__init__): new class for interactive
1262 1268 demos. Not documented yet, I just wrote it in a hurry for
1263 1269 scipy'05. Will docstring later.
1264 1270
1265 1271 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
1266 1272
1267 1273 * IPython/Shell.py (sigint_handler): Drastic simplification which
1268 1274 also seems to make Ctrl-C work correctly across threads! This is
1269 1275 so simple, that I can't beleive I'd missed it before. Needs more
1270 1276 testing, though.
1271 1277 (KBINT): Never mind, revert changes. I'm sure I'd tried something
1272 1278 like this before...
1273 1279
1274 1280 * IPython/genutils.py (get_home_dir): add protection against
1275 1281 non-dirs in win32 registry.
1276 1282
1277 1283 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
1278 1284 bug where dict was mutated while iterating (pysh crash).
1279 1285
1280 1286 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
1281 1287
1282 1288 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
1283 1289 spurious newlines added by this routine. After a report by
1284 1290 F. Mantegazza.
1285 1291
1286 1292 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
1287 1293
1288 1294 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
1289 1295 calls. These were a leftover from the GTK 1.x days, and can cause
1290 1296 problems in certain cases (after a report by John Hunter).
1291 1297
1292 1298 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
1293 1299 os.getcwd() fails at init time. Thanks to patch from David Remahl
1294 1300 <chmod007-AT-mac.com>.
1295 1301 (InteractiveShell.__init__): prevent certain special magics from
1296 1302 being shadowed by aliases. Closes
1297 1303 http://www.scipy.net/roundup/ipython/issue41.
1298 1304
1299 1305 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
1300 1306
1301 1307 * IPython/iplib.py (InteractiveShell.complete): Added new
1302 1308 top-level completion method to expose the completion mechanism
1303 1309 beyond readline-based environments.
1304 1310
1305 1311 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
1306 1312
1307 1313 * tools/ipsvnc (svnversion): fix svnversion capture.
1308 1314
1309 1315 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
1310 1316 attribute to self, which was missing. Before, it was set by a
1311 1317 routine which in certain cases wasn't being called, so the
1312 1318 instance could end up missing the attribute. This caused a crash.
1313 1319 Closes http://www.scipy.net/roundup/ipython/issue40.
1314 1320
1315 1321 2005-08-16 Fernando Perez <fperez@colorado.edu>
1316 1322
1317 1323 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
1318 1324 contains non-string attribute. Closes
1319 1325 http://www.scipy.net/roundup/ipython/issue38.
1320 1326
1321 1327 2005-08-14 Fernando Perez <fperez@colorado.edu>
1322 1328
1323 1329 * tools/ipsvnc: Minor improvements, to add changeset info.
1324 1330
1325 1331 2005-08-12 Fernando Perez <fperez@colorado.edu>
1326 1332
1327 1333 * IPython/iplib.py (runsource): remove self.code_to_run_src
1328 1334 attribute. I realized this is nothing more than
1329 1335 '\n'.join(self.buffer), and having the same data in two different
1330 1336 places is just asking for synchronization bugs. This may impact
1331 1337 people who have custom exception handlers, so I need to warn
1332 1338 ipython-dev about it (F. Mantegazza may use them).
1333 1339
1334 1340 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
1335 1341
1336 1342 * IPython/genutils.py: fix 2.2 compatibility (generators)
1337 1343
1338 1344 2005-07-18 Fernando Perez <fperez@colorado.edu>
1339 1345
1340 1346 * IPython/genutils.py (get_home_dir): fix to help users with
1341 1347 invalid $HOME under win32.
1342 1348
1343 1349 2005-07-17 Fernando Perez <fperez@colorado.edu>
1344 1350
1345 1351 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
1346 1352 some old hacks and clean up a bit other routines; code should be
1347 1353 simpler and a bit faster.
1348 1354
1349 1355 * IPython/iplib.py (interact): removed some last-resort attempts
1350 1356 to survive broken stdout/stderr. That code was only making it
1351 1357 harder to abstract out the i/o (necessary for gui integration),
1352 1358 and the crashes it could prevent were extremely rare in practice
1353 1359 (besides being fully user-induced in a pretty violent manner).
1354 1360
1355 1361 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
1356 1362 Nothing major yet, but the code is simpler to read; this should
1357 1363 make it easier to do more serious modifications in the future.
1358 1364
1359 1365 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
1360 1366 which broke in .15 (thanks to a report by Ville).
1361 1367
1362 1368 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
1363 1369 be quite correct, I know next to nothing about unicode). This
1364 1370 will allow unicode strings to be used in prompts, amongst other
1365 1371 cases. It also will prevent ipython from crashing when unicode
1366 1372 shows up unexpectedly in many places. If ascii encoding fails, we
1367 1373 assume utf_8. Currently the encoding is not a user-visible
1368 1374 setting, though it could be made so if there is demand for it.
1369 1375
1370 1376 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
1371 1377
1372 1378 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
1373 1379
1374 1380 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
1375 1381
1376 1382 * IPython/genutils.py: Add 2.2 compatibility here, so all other
1377 1383 code can work transparently for 2.2/2.3.
1378 1384
1379 1385 2005-07-16 Fernando Perez <fperez@colorado.edu>
1380 1386
1381 1387 * IPython/ultraTB.py (ExceptionColors): Make a global variable
1382 1388 out of the color scheme table used for coloring exception
1383 1389 tracebacks. This allows user code to add new schemes at runtime.
1384 1390 This is a minimally modified version of the patch at
1385 1391 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
1386 1392 for the contribution.
1387 1393
1388 1394 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
1389 1395 slightly modified version of the patch in
1390 1396 http://www.scipy.net/roundup/ipython/issue34, which also allows me
1391 1397 to remove the previous try/except solution (which was costlier).
1392 1398 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
1393 1399
1394 1400 2005-06-08 Fernando Perez <fperez@colorado.edu>
1395 1401
1396 1402 * IPython/iplib.py (write/write_err): Add methods to abstract all
1397 1403 I/O a bit more.
1398 1404
1399 1405 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
1400 1406 warning, reported by Aric Hagberg, fix by JD Hunter.
1401 1407
1402 1408 2005-06-02 *** Released version 0.6.15
1403 1409
1404 1410 2005-06-01 Fernando Perez <fperez@colorado.edu>
1405 1411
1406 1412 * IPython/iplib.py (MagicCompleter.file_matches): Fix
1407 1413 tab-completion of filenames within open-quoted strings. Note that
1408 1414 this requires that in ~/.ipython/ipythonrc, users change the
1409 1415 readline delimiters configuration to read:
1410 1416
1411 1417 readline_remove_delims -/~
1412 1418
1413 1419
1414 1420 2005-05-31 *** Released version 0.6.14
1415 1421
1416 1422 2005-05-29 Fernando Perez <fperez@colorado.edu>
1417 1423
1418 1424 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
1419 1425 with files not on the filesystem. Reported by Eliyahu Sandler
1420 1426 <eli@gondolin.net>
1421 1427
1422 1428 2005-05-22 Fernando Perez <fperez@colorado.edu>
1423 1429
1424 1430 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
1425 1431 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
1426 1432
1427 1433 2005-05-19 Fernando Perez <fperez@colorado.edu>
1428 1434
1429 1435 * IPython/iplib.py (safe_execfile): close a file which could be
1430 1436 left open (causing problems in win32, which locks open files).
1431 1437 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
1432 1438
1433 1439 2005-05-18 Fernando Perez <fperez@colorado.edu>
1434 1440
1435 1441 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
1436 1442 keyword arguments correctly to safe_execfile().
1437 1443
1438 1444 2005-05-13 Fernando Perez <fperez@colorado.edu>
1439 1445
1440 1446 * ipython.1: Added info about Qt to manpage, and threads warning
1441 1447 to usage page (invoked with --help).
1442 1448
1443 1449 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
1444 1450 new matcher (it goes at the end of the priority list) to do
1445 1451 tab-completion on named function arguments. Submitted by George
1446 1452 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
1447 1453 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
1448 1454 for more details.
1449 1455
1450 1456 * IPython/Magic.py (magic_run): Added new -e flag to ignore
1451 1457 SystemExit exceptions in the script being run. Thanks to a report
1452 1458 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
1453 1459 producing very annoying behavior when running unit tests.
1454 1460
1455 1461 2005-05-12 Fernando Perez <fperez@colorado.edu>
1456 1462
1457 1463 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
1458 1464 which I'd broken (again) due to a changed regexp. In the process,
1459 1465 added ';' as an escape to auto-quote the whole line without
1460 1466 splitting its arguments. Thanks to a report by Jerry McRae
1461 1467 <qrs0xyc02-AT-sneakemail.com>.
1462 1468
1463 1469 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
1464 1470 possible crashes caused by a TokenError. Reported by Ed Schofield
1465 1471 <schofield-AT-ftw.at>.
1466 1472
1467 1473 2005-05-06 Fernando Perez <fperez@colorado.edu>
1468 1474
1469 1475 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
1470 1476
1471 1477 2005-04-29 Fernando Perez <fperez@colorado.edu>
1472 1478
1473 1479 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
1474 1480 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
1475 1481 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
1476 1482 which provides support for Qt interactive usage (similar to the
1477 1483 existing one for WX and GTK). This had been often requested.
1478 1484
1479 1485 2005-04-14 *** Released version 0.6.13
1480 1486
1481 1487 2005-04-08 Fernando Perez <fperez@colorado.edu>
1482 1488
1483 1489 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
1484 1490 from _ofind, which gets called on almost every input line. Now,
1485 1491 we only try to get docstrings if they are actually going to be
1486 1492 used (the overhead of fetching unnecessary docstrings can be
1487 1493 noticeable for certain objects, such as Pyro proxies).
1488 1494
1489 1495 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
1490 1496 for completers. For some reason I had been passing them the state
1491 1497 variable, which completers never actually need, and was in
1492 1498 conflict with the rlcompleter API. Custom completers ONLY need to
1493 1499 take the text parameter.
1494 1500
1495 1501 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
1496 1502 work correctly in pysh. I've also moved all the logic which used
1497 1503 to be in pysh.py here, which will prevent problems with future
1498 1504 upgrades. However, this time I must warn users to update their
1499 1505 pysh profile to include the line
1500 1506
1501 1507 import_all IPython.Extensions.InterpreterExec
1502 1508
1503 1509 because otherwise things won't work for them. They MUST also
1504 1510 delete pysh.py and the line
1505 1511
1506 1512 execfile pysh.py
1507 1513
1508 1514 from their ipythonrc-pysh.
1509 1515
1510 1516 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
1511 1517 robust in the face of objects whose dir() returns non-strings
1512 1518 (which it shouldn't, but some broken libs like ITK do). Thanks to
1513 1519 a patch by John Hunter (implemented differently, though). Also
1514 1520 minor improvements by using .extend instead of + on lists.
1515 1521
1516 1522 * pysh.py:
1517 1523
1518 1524 2005-04-06 Fernando Perez <fperez@colorado.edu>
1519 1525
1520 1526 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
1521 1527 by default, so that all users benefit from it. Those who don't
1522 1528 want it can still turn it off.
1523 1529
1524 1530 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
1525 1531 config file, I'd forgotten about this, so users were getting it
1526 1532 off by default.
1527 1533
1528 1534 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
1529 1535 consistency. Now magics can be called in multiline statements,
1530 1536 and python variables can be expanded in magic calls via $var.
1531 1537 This makes the magic system behave just like aliases or !system
1532 1538 calls.
1533 1539
1534 1540 2005-03-28 Fernando Perez <fperez@colorado.edu>
1535 1541
1536 1542 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
1537 1543 expensive string additions for building command. Add support for
1538 1544 trailing ';' when autocall is used.
1539 1545
1540 1546 2005-03-26 Fernando Perez <fperez@colorado.edu>
1541 1547
1542 1548 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
1543 1549 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
1544 1550 ipython.el robust against prompts with any number of spaces
1545 1551 (including 0) after the ':' character.
1546 1552
1547 1553 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
1548 1554 continuation prompt, which misled users to think the line was
1549 1555 already indented. Closes debian Bug#300847, reported to me by
1550 1556 Norbert Tretkowski <tretkowski-AT-inittab.de>.
1551 1557
1552 1558 2005-03-23 Fernando Perez <fperez@colorado.edu>
1553 1559
1554 1560 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
1555 1561 properly aligned if they have embedded newlines.
1556 1562
1557 1563 * IPython/iplib.py (runlines): Add a public method to expose
1558 1564 IPython's code execution machinery, so that users can run strings
1559 1565 as if they had been typed at the prompt interactively.
1560 1566 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
1561 1567 methods which can call the system shell, but with python variable
1562 1568 expansion. The three such methods are: __IPYTHON__.system,
1563 1569 .getoutput and .getoutputerror. These need to be documented in a
1564 1570 'public API' section (to be written) of the manual.
1565 1571
1566 1572 2005-03-20 Fernando Perez <fperez@colorado.edu>
1567 1573
1568 1574 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
1569 1575 for custom exception handling. This is quite powerful, and it
1570 1576 allows for user-installable exception handlers which can trap
1571 1577 custom exceptions at runtime and treat them separately from
1572 1578 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
1573 1579 Mantegazza <mantegazza-AT-ill.fr>.
1574 1580 (InteractiveShell.set_custom_completer): public API function to
1575 1581 add new completers at runtime.
1576 1582
1577 1583 2005-03-19 Fernando Perez <fperez@colorado.edu>
1578 1584
1579 1585 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
1580 1586 allow objects which provide their docstrings via non-standard
1581 1587 mechanisms (like Pyro proxies) to still be inspected by ipython's
1582 1588 ? system.
1583 1589
1584 1590 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
1585 1591 automatic capture system. I tried quite hard to make it work
1586 1592 reliably, and simply failed. I tried many combinations with the
1587 1593 subprocess module, but eventually nothing worked in all needed
1588 1594 cases (not blocking stdin for the child, duplicating stdout
1589 1595 without blocking, etc). The new %sc/%sx still do capture to these
1590 1596 magical list/string objects which make shell use much more
1591 1597 conveninent, so not all is lost.
1592 1598
1593 1599 XXX - FIX MANUAL for the change above!
1594 1600
1595 1601 (runsource): I copied code.py's runsource() into ipython to modify
1596 1602 it a bit. Now the code object and source to be executed are
1597 1603 stored in ipython. This makes this info accessible to third-party
1598 1604 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
1599 1605 Mantegazza <mantegazza-AT-ill.fr>.
1600 1606
1601 1607 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
1602 1608 history-search via readline (like C-p/C-n). I'd wanted this for a
1603 1609 long time, but only recently found out how to do it. For users
1604 1610 who already have their ipythonrc files made and want this, just
1605 1611 add:
1606 1612
1607 1613 readline_parse_and_bind "\e[A": history-search-backward
1608 1614 readline_parse_and_bind "\e[B": history-search-forward
1609 1615
1610 1616 2005-03-18 Fernando Perez <fperez@colorado.edu>
1611 1617
1612 1618 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
1613 1619 LSString and SList classes which allow transparent conversions
1614 1620 between list mode and whitespace-separated string.
1615 1621 (magic_r): Fix recursion problem in %r.
1616 1622
1617 1623 * IPython/genutils.py (LSString): New class to be used for
1618 1624 automatic storage of the results of all alias/system calls in _o
1619 1625 and _e (stdout/err). These provide a .l/.list attribute which
1620 1626 does automatic splitting on newlines. This means that for most
1621 1627 uses, you'll never need to do capturing of output with %sc/%sx
1622 1628 anymore, since ipython keeps this always done for you. Note that
1623 1629 only the LAST results are stored, the _o/e variables are
1624 1630 overwritten on each call. If you need to save their contents
1625 1631 further, simply bind them to any other name.
1626 1632
1627 1633 2005-03-17 Fernando Perez <fperez@colorado.edu>
1628 1634
1629 1635 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
1630 1636 prompt namespace handling.
1631 1637
1632 1638 2005-03-16 Fernando Perez <fperez@colorado.edu>
1633 1639
1634 1640 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
1635 1641 classic prompts to be '>>> ' (final space was missing, and it
1636 1642 trips the emacs python mode).
1637 1643 (BasePrompt.__str__): Added safe support for dynamic prompt
1638 1644 strings. Now you can set your prompt string to be '$x', and the
1639 1645 value of x will be printed from your interactive namespace. The
1640 1646 interpolation syntax includes the full Itpl support, so
1641 1647 ${foo()+x+bar()} is a valid prompt string now, and the function
1642 1648 calls will be made at runtime.
1643 1649
1644 1650 2005-03-15 Fernando Perez <fperez@colorado.edu>
1645 1651
1646 1652 * IPython/Magic.py (magic_history): renamed %hist to %history, to
1647 1653 avoid name clashes in pylab. %hist still works, it just forwards
1648 1654 the call to %history.
1649 1655
1650 1656 2005-03-02 *** Released version 0.6.12
1651 1657
1652 1658 2005-03-02 Fernando Perez <fperez@colorado.edu>
1653 1659
1654 1660 * IPython/iplib.py (handle_magic): log magic calls properly as
1655 1661 ipmagic() function calls.
1656 1662
1657 1663 * IPython/Magic.py (magic_time): Improved %time to support
1658 1664 statements and provide wall-clock as well as CPU time.
1659 1665
1660 1666 2005-02-27 Fernando Perez <fperez@colorado.edu>
1661 1667
1662 1668 * IPython/hooks.py: New hooks module, to expose user-modifiable
1663 1669 IPython functionality in a clean manner. For now only the editor
1664 1670 hook is actually written, and other thigns which I intend to turn
1665 1671 into proper hooks aren't yet there. The display and prefilter
1666 1672 stuff, for example, should be hooks. But at least now the
1667 1673 framework is in place, and the rest can be moved here with more
1668 1674 time later. IPython had had a .hooks variable for a long time for
1669 1675 this purpose, but I'd never actually used it for anything.
1670 1676
1671 1677 2005-02-26 Fernando Perez <fperez@colorado.edu>
1672 1678
1673 1679 * IPython/ipmaker.py (make_IPython): make the default ipython
1674 1680 directory be called _ipython under win32, to follow more the
1675 1681 naming peculiarities of that platform (where buggy software like
1676 1682 Visual Sourcesafe breaks with .named directories). Reported by
1677 1683 Ville Vainio.
1678 1684
1679 1685 2005-02-23 Fernando Perez <fperez@colorado.edu>
1680 1686
1681 1687 * IPython/iplib.py (InteractiveShell.__init__): removed a few
1682 1688 auto_aliases for win32 which were causing problems. Users can
1683 1689 define the ones they personally like.
1684 1690
1685 1691 2005-02-21 Fernando Perez <fperez@colorado.edu>
1686 1692
1687 1693 * IPython/Magic.py (magic_time): new magic to time execution of
1688 1694 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
1689 1695
1690 1696 2005-02-19 Fernando Perez <fperez@colorado.edu>
1691 1697
1692 1698 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
1693 1699 into keys (for prompts, for example).
1694 1700
1695 1701 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
1696 1702 prompts in case users want them. This introduces a small behavior
1697 1703 change: ipython does not automatically add a space to all prompts
1698 1704 anymore. To get the old prompts with a space, users should add it
1699 1705 manually to their ipythonrc file, so for example prompt_in1 should
1700 1706 now read 'In [\#]: ' instead of 'In [\#]:'.
1701 1707 (BasePrompt.__init__): New option prompts_pad_left (only in rc
1702 1708 file) to control left-padding of secondary prompts.
1703 1709
1704 1710 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
1705 1711 the profiler can't be imported. Fix for Debian, which removed
1706 1712 profile.py because of License issues. I applied a slightly
1707 1713 modified version of the original Debian patch at
1708 1714 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
1709 1715
1710 1716 2005-02-17 Fernando Perez <fperez@colorado.edu>
1711 1717
1712 1718 * IPython/genutils.py (native_line_ends): Fix bug which would
1713 1719 cause improper line-ends under win32 b/c I was not opening files
1714 1720 in binary mode. Bug report and fix thanks to Ville.
1715 1721
1716 1722 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
1717 1723 trying to catch spurious foo[1] autocalls. My fix actually broke
1718 1724 ',/' autoquote/call with explicit escape (bad regexp).
1719 1725
1720 1726 2005-02-15 *** Released version 0.6.11
1721 1727
1722 1728 2005-02-14 Fernando Perez <fperez@colorado.edu>
1723 1729
1724 1730 * IPython/background_jobs.py: New background job management
1725 1731 subsystem. This is implemented via a new set of classes, and
1726 1732 IPython now provides a builtin 'jobs' object for background job
1727 1733 execution. A convenience %bg magic serves as a lightweight
1728 1734 frontend for starting the more common type of calls. This was
1729 1735 inspired by discussions with B. Granger and the BackgroundCommand
1730 1736 class described in the book Python Scripting for Computational
1731 1737 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
1732 1738 (although ultimately no code from this text was used, as IPython's
1733 1739 system is a separate implementation).
1734 1740
1735 1741 * IPython/iplib.py (MagicCompleter.python_matches): add new option
1736 1742 to control the completion of single/double underscore names
1737 1743 separately. As documented in the example ipytonrc file, the
1738 1744 readline_omit__names variable can now be set to 2, to omit even
1739 1745 single underscore names. Thanks to a patch by Brian Wong
1740 1746 <BrianWong-AT-AirgoNetworks.Com>.
1741 1747 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
1742 1748 be autocalled as foo([1]) if foo were callable. A problem for
1743 1749 things which are both callable and implement __getitem__.
1744 1750 (init_readline): Fix autoindentation for win32. Thanks to a patch
1745 1751 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
1746 1752
1747 1753 2005-02-12 Fernando Perez <fperez@colorado.edu>
1748 1754
1749 1755 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
1750 1756 which I had written long ago to sort out user error messages which
1751 1757 may occur during startup. This seemed like a good idea initially,
1752 1758 but it has proven a disaster in retrospect. I don't want to
1753 1759 change much code for now, so my fix is to set the internal 'debug'
1754 1760 flag to true everywhere, whose only job was precisely to control
1755 1761 this subsystem. This closes issue 28 (as well as avoiding all
1756 1762 sorts of strange hangups which occur from time to time).
1757 1763
1758 1764 2005-02-07 Fernando Perez <fperez@colorado.edu>
1759 1765
1760 1766 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
1761 1767 previous call produced a syntax error.
1762 1768
1763 1769 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1764 1770 classes without constructor.
1765 1771
1766 1772 2005-02-06 Fernando Perez <fperez@colorado.edu>
1767 1773
1768 1774 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
1769 1775 completions with the results of each matcher, so we return results
1770 1776 to the user from all namespaces. This breaks with ipython
1771 1777 tradition, but I think it's a nicer behavior. Now you get all
1772 1778 possible completions listed, from all possible namespaces (python,
1773 1779 filesystem, magics...) After a request by John Hunter
1774 1780 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1775 1781
1776 1782 2005-02-05 Fernando Perez <fperez@colorado.edu>
1777 1783
1778 1784 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
1779 1785 the call had quote characters in it (the quotes were stripped).
1780 1786
1781 1787 2005-01-31 Fernando Perez <fperez@colorado.edu>
1782 1788
1783 1789 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
1784 1790 Itpl.itpl() to make the code more robust against psyco
1785 1791 optimizations.
1786 1792
1787 1793 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
1788 1794 of causing an exception. Quicker, cleaner.
1789 1795
1790 1796 2005-01-28 Fernando Perez <fperez@colorado.edu>
1791 1797
1792 1798 * scripts/ipython_win_post_install.py (install): hardcode
1793 1799 sys.prefix+'python.exe' as the executable path. It turns out that
1794 1800 during the post-installation run, sys.executable resolves to the
1795 1801 name of the binary installer! I should report this as a distutils
1796 1802 bug, I think. I updated the .10 release with this tiny fix, to
1797 1803 avoid annoying the lists further.
1798 1804
1799 1805 2005-01-27 *** Released version 0.6.10
1800 1806
1801 1807 2005-01-27 Fernando Perez <fperez@colorado.edu>
1802 1808
1803 1809 * IPython/numutils.py (norm): Added 'inf' as optional name for
1804 1810 L-infinity norm, included references to mathworld.com for vector
1805 1811 norm definitions.
1806 1812 (amin/amax): added amin/amax for array min/max. Similar to what
1807 1813 pylab ships with after the recent reorganization of names.
1808 1814 (spike/spike_odd): removed deprecated spike/spike_odd functions.
1809 1815
1810 1816 * ipython.el: committed Alex's recent fixes and improvements.
1811 1817 Tested with python-mode from CVS, and it looks excellent. Since
1812 1818 python-mode hasn't released anything in a while, I'm temporarily
1813 1819 putting a copy of today's CVS (v 4.70) of python-mode in:
1814 1820 http://ipython.scipy.org/tmp/python-mode.el
1815 1821
1816 1822 * scripts/ipython_win_post_install.py (install): Win32 fix to use
1817 1823 sys.executable for the executable name, instead of assuming it's
1818 1824 called 'python.exe' (the post-installer would have produced broken
1819 1825 setups on systems with a differently named python binary).
1820 1826
1821 1827 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
1822 1828 references to os.linesep, to make the code more
1823 1829 platform-independent. This is also part of the win32 coloring
1824 1830 fixes.
1825 1831
1826 1832 * IPython/genutils.py (page_dumb): Remove attempts to chop long
1827 1833 lines, which actually cause coloring bugs because the length of
1828 1834 the line is very difficult to correctly compute with embedded
1829 1835 escapes. This was the source of all the coloring problems under
1830 1836 Win32. I think that _finally_, Win32 users have a properly
1831 1837 working ipython in all respects. This would never have happened
1832 1838 if not for Gary Bishop and Viktor Ransmayr's great help and work.
1833 1839
1834 1840 2005-01-26 *** Released version 0.6.9
1835 1841
1836 1842 2005-01-25 Fernando Perez <fperez@colorado.edu>
1837 1843
1838 1844 * setup.py: finally, we have a true Windows installer, thanks to
1839 1845 the excellent work of Viktor Ransmayr
1840 1846 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
1841 1847 Windows users. The setup routine is quite a bit cleaner thanks to
1842 1848 this, and the post-install script uses the proper functions to
1843 1849 allow a clean de-installation using the standard Windows Control
1844 1850 Panel.
1845 1851
1846 1852 * IPython/genutils.py (get_home_dir): changed to use the $HOME
1847 1853 environment variable under all OSes (including win32) if
1848 1854 available. This will give consistency to win32 users who have set
1849 1855 this variable for any reason. If os.environ['HOME'] fails, the
1850 1856 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
1851 1857
1852 1858 2005-01-24 Fernando Perez <fperez@colorado.edu>
1853 1859
1854 1860 * IPython/numutils.py (empty_like): add empty_like(), similar to
1855 1861 zeros_like() but taking advantage of the new empty() Numeric routine.
1856 1862
1857 1863 2005-01-23 *** Released version 0.6.8
1858 1864
1859 1865 2005-01-22 Fernando Perez <fperez@colorado.edu>
1860 1866
1861 1867 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
1862 1868 automatic show() calls. After discussing things with JDH, it
1863 1869 turns out there are too many corner cases where this can go wrong.
1864 1870 It's best not to try to be 'too smart', and simply have ipython
1865 1871 reproduce as much as possible the default behavior of a normal
1866 1872 python shell.
1867 1873
1868 1874 * IPython/iplib.py (InteractiveShell.__init__): Modified the
1869 1875 line-splitting regexp and _prefilter() to avoid calling getattr()
1870 1876 on assignments. This closes
1871 1877 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
1872 1878 readline uses getattr(), so a simple <TAB> keypress is still
1873 1879 enough to trigger getattr() calls on an object.
1874 1880
1875 1881 2005-01-21 Fernando Perez <fperez@colorado.edu>
1876 1882
1877 1883 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
1878 1884 docstring under pylab so it doesn't mask the original.
1879 1885
1880 1886 2005-01-21 *** Released version 0.6.7
1881 1887
1882 1888 2005-01-21 Fernando Perez <fperez@colorado.edu>
1883 1889
1884 1890 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
1885 1891 signal handling for win32 users in multithreaded mode.
1886 1892
1887 1893 2005-01-17 Fernando Perez <fperez@colorado.edu>
1888 1894
1889 1895 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
1890 1896 instances with no __init__. After a crash report by Norbert Nemec
1891 1897 <Norbert-AT-nemec-online.de>.
1892 1898
1893 1899 2005-01-14 Fernando Perez <fperez@colorado.edu>
1894 1900
1895 1901 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
1896 1902 names for verbose exceptions, when multiple dotted names and the
1897 1903 'parent' object were present on the same line.
1898 1904
1899 1905 2005-01-11 Fernando Perez <fperez@colorado.edu>
1900 1906
1901 1907 * IPython/genutils.py (flag_calls): new utility to trap and flag
1902 1908 calls in functions. I need it to clean up matplotlib support.
1903 1909 Also removed some deprecated code in genutils.
1904 1910
1905 1911 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
1906 1912 that matplotlib scripts called with %run, which don't call show()
1907 1913 themselves, still have their plotting windows open.
1908 1914
1909 1915 2005-01-05 Fernando Perez <fperez@colorado.edu>
1910 1916
1911 1917 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
1912 1918 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
1913 1919
1914 1920 2004-12-19 Fernando Perez <fperez@colorado.edu>
1915 1921
1916 1922 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
1917 1923 parent_runcode, which was an eyesore. The same result can be
1918 1924 obtained with Python's regular superclass mechanisms.
1919 1925
1920 1926 2004-12-17 Fernando Perez <fperez@colorado.edu>
1921 1927
1922 1928 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
1923 1929 reported by Prabhu.
1924 1930 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
1925 1931 sys.stderr) instead of explicitly calling sys.stderr. This helps
1926 1932 maintain our I/O abstractions clean, for future GUI embeddings.
1927 1933
1928 1934 * IPython/genutils.py (info): added new utility for sys.stderr
1929 1935 unified info message handling (thin wrapper around warn()).
1930 1936
1931 1937 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
1932 1938 composite (dotted) names on verbose exceptions.
1933 1939 (VerboseTB.nullrepr): harden against another kind of errors which
1934 1940 Python's inspect module can trigger, and which were crashing
1935 1941 IPython. Thanks to a report by Marco Lombardi
1936 1942 <mlombard-AT-ma010192.hq.eso.org>.
1937 1943
1938 1944 2004-12-13 *** Released version 0.6.6
1939 1945
1940 1946 2004-12-12 Fernando Perez <fperez@colorado.edu>
1941 1947
1942 1948 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
1943 1949 generated by pygtk upon initialization if it was built without
1944 1950 threads (for matplotlib users). After a crash reported by
1945 1951 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
1946 1952
1947 1953 * IPython/ipmaker.py (make_IPython): fix small bug in the
1948 1954 import_some parameter for multiple imports.
1949 1955
1950 1956 * IPython/iplib.py (ipmagic): simplified the interface of
1951 1957 ipmagic() to take a single string argument, just as it would be
1952 1958 typed at the IPython cmd line.
1953 1959 (ipalias): Added new ipalias() with an interface identical to
1954 1960 ipmagic(). This completes exposing a pure python interface to the
1955 1961 alias and magic system, which can be used in loops or more complex
1956 1962 code where IPython's automatic line mangling is not active.
1957 1963
1958 1964 * IPython/genutils.py (timing): changed interface of timing to
1959 1965 simply run code once, which is the most common case. timings()
1960 1966 remains unchanged, for the cases where you want multiple runs.
1961 1967
1962 1968 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
1963 1969 bug where Python2.2 crashes with exec'ing code which does not end
1964 1970 in a single newline. Python 2.3 is OK, so I hadn't noticed this
1965 1971 before.
1966 1972
1967 1973 2004-12-10 Fernando Perez <fperez@colorado.edu>
1968 1974
1969 1975 * IPython/Magic.py (Magic.magic_prun): changed name of option from
1970 1976 -t to -T, to accomodate the new -t flag in %run (the %run and
1971 1977 %prun options are kind of intermixed, and it's not easy to change
1972 1978 this with the limitations of python's getopt).
1973 1979
1974 1980 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
1975 1981 the execution of scripts. It's not as fine-tuned as timeit.py,
1976 1982 but it works from inside ipython (and under 2.2, which lacks
1977 1983 timeit.py). Optionally a number of runs > 1 can be given for
1978 1984 timing very short-running code.
1979 1985
1980 1986 * IPython/genutils.py (uniq_stable): new routine which returns a
1981 1987 list of unique elements in any iterable, but in stable order of
1982 1988 appearance. I needed this for the ultraTB fixes, and it's a handy
1983 1989 utility.
1984 1990
1985 1991 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
1986 1992 dotted names in Verbose exceptions. This had been broken since
1987 1993 the very start, now x.y will properly be printed in a Verbose
1988 1994 traceback, instead of x being shown and y appearing always as an
1989 1995 'undefined global'. Getting this to work was a bit tricky,
1990 1996 because by default python tokenizers are stateless. Saved by
1991 1997 python's ability to easily add a bit of state to an arbitrary
1992 1998 function (without needing to build a full-blown callable object).
1993 1999
1994 2000 Also big cleanup of this code, which had horrendous runtime
1995 2001 lookups of zillions of attributes for colorization. Moved all
1996 2002 this code into a few templates, which make it cleaner and quicker.
1997 2003
1998 2004 Printout quality was also improved for Verbose exceptions: one
1999 2005 variable per line, and memory addresses are printed (this can be
2000 2006 quite handy in nasty debugging situations, which is what Verbose
2001 2007 is for).
2002 2008
2003 2009 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
2004 2010 the command line as scripts to be loaded by embedded instances.
2005 2011 Doing so has the potential for an infinite recursion if there are
2006 2012 exceptions thrown in the process. This fixes a strange crash
2007 2013 reported by Philippe MULLER <muller-AT-irit.fr>.
2008 2014
2009 2015 2004-12-09 Fernando Perez <fperez@colorado.edu>
2010 2016
2011 2017 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
2012 2018 to reflect new names in matplotlib, which now expose the
2013 2019 matlab-compatible interface via a pylab module instead of the
2014 2020 'matlab' name. The new code is backwards compatible, so users of
2015 2021 all matplotlib versions are OK. Patch by J. Hunter.
2016 2022
2017 2023 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
2018 2024 of __init__ docstrings for instances (class docstrings are already
2019 2025 automatically printed). Instances with customized docstrings
2020 2026 (indep. of the class) are also recognized and all 3 separate
2021 2027 docstrings are printed (instance, class, constructor). After some
2022 2028 comments/suggestions by J. Hunter.
2023 2029
2024 2030 2004-12-05 Fernando Perez <fperez@colorado.edu>
2025 2031
2026 2032 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
2027 2033 warnings when tab-completion fails and triggers an exception.
2028 2034
2029 2035 2004-12-03 Fernando Perez <fperez@colorado.edu>
2030 2036
2031 2037 * IPython/Magic.py (magic_prun): Fix bug where an exception would
2032 2038 be triggered when using 'run -p'. An incorrect option flag was
2033 2039 being set ('d' instead of 'D').
2034 2040 (manpage): fix missing escaped \- sign.
2035 2041
2036 2042 2004-11-30 *** Released version 0.6.5
2037 2043
2038 2044 2004-11-30 Fernando Perez <fperez@colorado.edu>
2039 2045
2040 2046 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
2041 2047 setting with -d option.
2042 2048
2043 2049 * setup.py (docfiles): Fix problem where the doc glob I was using
2044 2050 was COMPLETELY BROKEN. It was giving the right files by pure
2045 2051 accident, but failed once I tried to include ipython.el. Note:
2046 2052 glob() does NOT allow you to do exclusion on multiple endings!
2047 2053
2048 2054 2004-11-29 Fernando Perez <fperez@colorado.edu>
2049 2055
2050 2056 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
2051 2057 the manpage as the source. Better formatting & consistency.
2052 2058
2053 2059 * IPython/Magic.py (magic_run): Added new -d option, to run
2054 2060 scripts under the control of the python pdb debugger. Note that
2055 2061 this required changing the %prun option -d to -D, to avoid a clash
2056 2062 (since %run must pass options to %prun, and getopt is too dumb to
2057 2063 handle options with string values with embedded spaces). Thanks
2058 2064 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
2059 2065 (magic_who_ls): added type matching to %who and %whos, so that one
2060 2066 can filter their output to only include variables of certain
2061 2067 types. Another suggestion by Matthew.
2062 2068 (magic_whos): Added memory summaries in kb and Mb for arrays.
2063 2069 (magic_who): Improve formatting (break lines every 9 vars).
2064 2070
2065 2071 2004-11-28 Fernando Perez <fperez@colorado.edu>
2066 2072
2067 2073 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
2068 2074 cache when empty lines were present.
2069 2075
2070 2076 2004-11-24 Fernando Perez <fperez@colorado.edu>
2071 2077
2072 2078 * IPython/usage.py (__doc__): document the re-activated threading
2073 2079 options for WX and GTK.
2074 2080
2075 2081 2004-11-23 Fernando Perez <fperez@colorado.edu>
2076 2082
2077 2083 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
2078 2084 the -wthread and -gthread options, along with a new -tk one to try
2079 2085 and coordinate Tk threading with wx/gtk. The tk support is very
2080 2086 platform dependent, since it seems to require Tcl and Tk to be
2081 2087 built with threads (Fedora1/2 appears NOT to have it, but in
2082 2088 Prabhu's Debian boxes it works OK). But even with some Tk
2083 2089 limitations, this is a great improvement.
2084 2090
2085 2091 * IPython/Prompts.py (prompt_specials_color): Added \t for time
2086 2092 info in user prompts. Patch by Prabhu.
2087 2093
2088 2094 2004-11-18 Fernando Perez <fperez@colorado.edu>
2089 2095
2090 2096 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
2091 2097 EOFErrors and bail, to avoid infinite loops if a non-terminating
2092 2098 file is fed into ipython. Patch submitted in issue 19 by user,
2093 2099 many thanks.
2094 2100
2095 2101 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
2096 2102 autoquote/parens in continuation prompts, which can cause lots of
2097 2103 problems. Closes roundup issue 20.
2098 2104
2099 2105 2004-11-17 Fernando Perez <fperez@colorado.edu>
2100 2106
2101 2107 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
2102 2108 reported as debian bug #280505. I'm not sure my local changelog
2103 2109 entry has the proper debian format (Jack?).
2104 2110
2105 2111 2004-11-08 *** Released version 0.6.4
2106 2112
2107 2113 2004-11-08 Fernando Perez <fperez@colorado.edu>
2108 2114
2109 2115 * IPython/iplib.py (init_readline): Fix exit message for Windows
2110 2116 when readline is active. Thanks to a report by Eric Jones
2111 2117 <eric-AT-enthought.com>.
2112 2118
2113 2119 2004-11-07 Fernando Perez <fperez@colorado.edu>
2114 2120
2115 2121 * IPython/genutils.py (page): Add a trap for OSError exceptions,
2116 2122 sometimes seen by win2k/cygwin users.
2117 2123
2118 2124 2004-11-06 Fernando Perez <fperez@colorado.edu>
2119 2125
2120 2126 * IPython/iplib.py (interact): Change the handling of %Exit from
2121 2127 trying to propagate a SystemExit to an internal ipython flag.
2122 2128 This is less elegant than using Python's exception mechanism, but
2123 2129 I can't get that to work reliably with threads, so under -pylab
2124 2130 %Exit was hanging IPython. Cross-thread exception handling is
2125 2131 really a bitch. Thaks to a bug report by Stephen Walton
2126 2132 <stephen.walton-AT-csun.edu>.
2127 2133
2128 2134 2004-11-04 Fernando Perez <fperez@colorado.edu>
2129 2135
2130 2136 * IPython/iplib.py (raw_input_original): store a pointer to the
2131 2137 true raw_input to harden against code which can modify it
2132 2138 (wx.py.PyShell does this and would otherwise crash ipython).
2133 2139 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
2134 2140
2135 2141 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
2136 2142 Ctrl-C problem, which does not mess up the input line.
2137 2143
2138 2144 2004-11-03 Fernando Perez <fperez@colorado.edu>
2139 2145
2140 2146 * IPython/Release.py: Changed licensing to BSD, in all files.
2141 2147 (name): lowercase name for tarball/RPM release.
2142 2148
2143 2149 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
2144 2150 use throughout ipython.
2145 2151
2146 2152 * IPython/Magic.py (Magic._ofind): Switch to using the new
2147 2153 OInspect.getdoc() function.
2148 2154
2149 2155 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
2150 2156 of the line currently being canceled via Ctrl-C. It's extremely
2151 2157 ugly, but I don't know how to do it better (the problem is one of
2152 2158 handling cross-thread exceptions).
2153 2159
2154 2160 2004-10-28 Fernando Perez <fperez@colorado.edu>
2155 2161
2156 2162 * IPython/Shell.py (signal_handler): add signal handlers to trap
2157 2163 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
2158 2164 report by Francesc Alted.
2159 2165
2160 2166 2004-10-21 Fernando Perez <fperez@colorado.edu>
2161 2167
2162 2168 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
2163 2169 to % for pysh syntax extensions.
2164 2170
2165 2171 2004-10-09 Fernando Perez <fperez@colorado.edu>
2166 2172
2167 2173 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
2168 2174 arrays to print a more useful summary, without calling str(arr).
2169 2175 This avoids the problem of extremely lengthy computations which
2170 2176 occur if arr is large, and appear to the user as a system lockup
2171 2177 with 100% cpu activity. After a suggestion by Kristian Sandberg
2172 2178 <Kristian.Sandberg@colorado.edu>.
2173 2179 (Magic.__init__): fix bug in global magic escapes not being
2174 2180 correctly set.
2175 2181
2176 2182 2004-10-08 Fernando Perez <fperez@colorado.edu>
2177 2183
2178 2184 * IPython/Magic.py (__license__): change to absolute imports of
2179 2185 ipython's own internal packages, to start adapting to the absolute
2180 2186 import requirement of PEP-328.
2181 2187
2182 2188 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
2183 2189 files, and standardize author/license marks through the Release
2184 2190 module instead of having per/file stuff (except for files with
2185 2191 particular licenses, like the MIT/PSF-licensed codes).
2186 2192
2187 2193 * IPython/Debugger.py: remove dead code for python 2.1
2188 2194
2189 2195 2004-10-04 Fernando Perez <fperez@colorado.edu>
2190 2196
2191 2197 * IPython/iplib.py (ipmagic): New function for accessing magics
2192 2198 via a normal python function call.
2193 2199
2194 2200 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
2195 2201 from '@' to '%', to accomodate the new @decorator syntax of python
2196 2202 2.4.
2197 2203
2198 2204 2004-09-29 Fernando Perez <fperez@colorado.edu>
2199 2205
2200 2206 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
2201 2207 matplotlib.use to prevent running scripts which try to switch
2202 2208 interactive backends from within ipython. This will just crash
2203 2209 the python interpreter, so we can't allow it (but a detailed error
2204 2210 is given to the user).
2205 2211
2206 2212 2004-09-28 Fernando Perez <fperez@colorado.edu>
2207 2213
2208 2214 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
2209 2215 matplotlib-related fixes so that using @run with non-matplotlib
2210 2216 scripts doesn't pop up spurious plot windows. This requires
2211 2217 matplotlib >= 0.63, where I had to make some changes as well.
2212 2218
2213 2219 * IPython/ipmaker.py (make_IPython): update version requirement to
2214 2220 python 2.2.
2215 2221
2216 2222 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
2217 2223 banner arg for embedded customization.
2218 2224
2219 2225 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
2220 2226 explicit uses of __IP as the IPython's instance name. Now things
2221 2227 are properly handled via the shell.name value. The actual code
2222 2228 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
2223 2229 is much better than before. I'll clean things completely when the
2224 2230 magic stuff gets a real overhaul.
2225 2231
2226 2232 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
2227 2233 minor changes to debian dir.
2228 2234
2229 2235 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
2230 2236 pointer to the shell itself in the interactive namespace even when
2231 2237 a user-supplied dict is provided. This is needed for embedding
2232 2238 purposes (found by tests with Michel Sanner).
2233 2239
2234 2240 2004-09-27 Fernando Perez <fperez@colorado.edu>
2235 2241
2236 2242 * IPython/UserConfig/ipythonrc: remove []{} from
2237 2243 readline_remove_delims, so that things like [modname.<TAB> do
2238 2244 proper completion. This disables [].TAB, but that's a less common
2239 2245 case than module names in list comprehensions, for example.
2240 2246 Thanks to a report by Andrea Riciputi.
2241 2247
2242 2248 2004-09-09 Fernando Perez <fperez@colorado.edu>
2243 2249
2244 2250 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
2245 2251 blocking problems in win32 and osx. Fix by John.
2246 2252
2247 2253 2004-09-08 Fernando Perez <fperez@colorado.edu>
2248 2254
2249 2255 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
2250 2256 for Win32 and OSX. Fix by John Hunter.
2251 2257
2252 2258 2004-08-30 *** Released version 0.6.3
2253 2259
2254 2260 2004-08-30 Fernando Perez <fperez@colorado.edu>
2255 2261
2256 2262 * setup.py (isfile): Add manpages to list of dependent files to be
2257 2263 updated.
2258 2264
2259 2265 2004-08-27 Fernando Perez <fperez@colorado.edu>
2260 2266
2261 2267 * IPython/Shell.py (start): I've disabled -wthread and -gthread
2262 2268 for now. They don't really work with standalone WX/GTK code
2263 2269 (though matplotlib IS working fine with both of those backends).
2264 2270 This will neeed much more testing. I disabled most things with
2265 2271 comments, so turning it back on later should be pretty easy.
2266 2272
2267 2273 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
2268 2274 autocalling of expressions like r'foo', by modifying the line
2269 2275 split regexp. Closes
2270 2276 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
2271 2277 Riley <ipythonbugs-AT-sabi.net>.
2272 2278 (InteractiveShell.mainloop): honor --nobanner with banner
2273 2279 extensions.
2274 2280
2275 2281 * IPython/Shell.py: Significant refactoring of all classes, so
2276 2282 that we can really support ALL matplotlib backends and threading
2277 2283 models (John spotted a bug with Tk which required this). Now we
2278 2284 should support single-threaded, WX-threads and GTK-threads, both
2279 2285 for generic code and for matplotlib.
2280 2286
2281 2287 * IPython/ipmaker.py (__call__): Changed -mpthread option to
2282 2288 -pylab, to simplify things for users. Will also remove the pylab
2283 2289 profile, since now all of matplotlib configuration is directly
2284 2290 handled here. This also reduces startup time.
2285 2291
2286 2292 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
2287 2293 shell wasn't being correctly called. Also in IPShellWX.
2288 2294
2289 2295 * IPython/iplib.py (InteractiveShell.__init__): Added option to
2290 2296 fine-tune banner.
2291 2297
2292 2298 * IPython/numutils.py (spike): Deprecate these spike functions,
2293 2299 delete (long deprecated) gnuplot_exec handler.
2294 2300
2295 2301 2004-08-26 Fernando Perez <fperez@colorado.edu>
2296 2302
2297 2303 * ipython.1: Update for threading options, plus some others which
2298 2304 were missing.
2299 2305
2300 2306 * IPython/ipmaker.py (__call__): Added -wthread option for
2301 2307 wxpython thread handling. Make sure threading options are only
2302 2308 valid at the command line.
2303 2309
2304 2310 * scripts/ipython: moved shell selection into a factory function
2305 2311 in Shell.py, to keep the starter script to a minimum.
2306 2312
2307 2313 2004-08-25 Fernando Perez <fperez@colorado.edu>
2308 2314
2309 2315 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
2310 2316 John. Along with some recent changes he made to matplotlib, the
2311 2317 next versions of both systems should work very well together.
2312 2318
2313 2319 2004-08-24 Fernando Perez <fperez@colorado.edu>
2314 2320
2315 2321 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
2316 2322 tried to switch the profiling to using hotshot, but I'm getting
2317 2323 strange errors from prof.runctx() there. I may be misreading the
2318 2324 docs, but it looks weird. For now the profiling code will
2319 2325 continue to use the standard profiler.
2320 2326
2321 2327 2004-08-23 Fernando Perez <fperez@colorado.edu>
2322 2328
2323 2329 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
2324 2330 threaded shell, by John Hunter. It's not quite ready yet, but
2325 2331 close.
2326 2332
2327 2333 2004-08-22 Fernando Perez <fperez@colorado.edu>
2328 2334
2329 2335 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
2330 2336 in Magic and ultraTB.
2331 2337
2332 2338 * ipython.1: document threading options in manpage.
2333 2339
2334 2340 * scripts/ipython: Changed name of -thread option to -gthread,
2335 2341 since this is GTK specific. I want to leave the door open for a
2336 2342 -wthread option for WX, which will most likely be necessary. This
2337 2343 change affects usage and ipmaker as well.
2338 2344
2339 2345 * IPython/Shell.py (matplotlib_shell): Add a factory function to
2340 2346 handle the matplotlib shell issues. Code by John Hunter
2341 2347 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2342 2348 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
2343 2349 broken (and disabled for end users) for now, but it puts the
2344 2350 infrastructure in place.
2345 2351
2346 2352 2004-08-21 Fernando Perez <fperez@colorado.edu>
2347 2353
2348 2354 * ipythonrc-pylab: Add matplotlib support.
2349 2355
2350 2356 * matplotlib_config.py: new files for matplotlib support, part of
2351 2357 the pylab profile.
2352 2358
2353 2359 * IPython/usage.py (__doc__): documented the threading options.
2354 2360
2355 2361 2004-08-20 Fernando Perez <fperez@colorado.edu>
2356 2362
2357 2363 * ipython: Modified the main calling routine to handle the -thread
2358 2364 and -mpthread options. This needs to be done as a top-level hack,
2359 2365 because it determines which class to instantiate for IPython
2360 2366 itself.
2361 2367
2362 2368 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
2363 2369 classes to support multithreaded GTK operation without blocking,
2364 2370 and matplotlib with all backends. This is a lot of still very
2365 2371 experimental code, and threads are tricky. So it may still have a
2366 2372 few rough edges... This code owes a lot to
2367 2373 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
2368 2374 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
2369 2375 to John Hunter for all the matplotlib work.
2370 2376
2371 2377 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
2372 2378 options for gtk thread and matplotlib support.
2373 2379
2374 2380 2004-08-16 Fernando Perez <fperez@colorado.edu>
2375 2381
2376 2382 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
2377 2383 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
2378 2384 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
2379 2385
2380 2386 2004-08-11 Fernando Perez <fperez@colorado.edu>
2381 2387
2382 2388 * setup.py (isfile): Fix build so documentation gets updated for
2383 2389 rpms (it was only done for .tgz builds).
2384 2390
2385 2391 2004-08-10 Fernando Perez <fperez@colorado.edu>
2386 2392
2387 2393 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
2388 2394
2389 2395 * iplib.py : Silence syntax error exceptions in tab-completion.
2390 2396
2391 2397 2004-08-05 Fernando Perez <fperez@colorado.edu>
2392 2398
2393 2399 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
2394 2400 'color off' mark for continuation prompts. This was causing long
2395 2401 continuation lines to mis-wrap.
2396 2402
2397 2403 2004-08-01 Fernando Perez <fperez@colorado.edu>
2398 2404
2399 2405 * IPython/ipmaker.py (make_IPython): Allow the shell class used
2400 2406 for building ipython to be a parameter. All this is necessary
2401 2407 right now to have a multithreaded version, but this insane
2402 2408 non-design will be cleaned up soon. For now, it's a hack that
2403 2409 works.
2404 2410
2405 2411 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
2406 2412 args in various places. No bugs so far, but it's a dangerous
2407 2413 practice.
2408 2414
2409 2415 2004-07-31 Fernando Perez <fperez@colorado.edu>
2410 2416
2411 2417 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
2412 2418 fix completion of files with dots in their names under most
2413 2419 profiles (pysh was OK because the completion order is different).
2414 2420
2415 2421 2004-07-27 Fernando Perez <fperez@colorado.edu>
2416 2422
2417 2423 * IPython/iplib.py (InteractiveShell.__init__): build dict of
2418 2424 keywords manually, b/c the one in keyword.py was removed in python
2419 2425 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
2420 2426 This is NOT a bug under python 2.3 and earlier.
2421 2427
2422 2428 2004-07-26 Fernando Perez <fperez@colorado.edu>
2423 2429
2424 2430 * IPython/ultraTB.py (VerboseTB.text): Add another
2425 2431 linecache.checkcache() call to try to prevent inspect.py from
2426 2432 crashing under python 2.3. I think this fixes
2427 2433 http://www.scipy.net/roundup/ipython/issue17.
2428 2434
2429 2435 2004-07-26 *** Released version 0.6.2
2430 2436
2431 2437 2004-07-26 Fernando Perez <fperez@colorado.edu>
2432 2438
2433 2439 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
2434 2440 fail for any number.
2435 2441 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
2436 2442 empty bookmarks.
2437 2443
2438 2444 2004-07-26 *** Released version 0.6.1
2439 2445
2440 2446 2004-07-26 Fernando Perez <fperez@colorado.edu>
2441 2447
2442 2448 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
2443 2449
2444 2450 * IPython/iplib.py (protect_filename): Applied Ville's patch for
2445 2451 escaping '()[]{}' in filenames.
2446 2452
2447 2453 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
2448 2454 Python 2.2 users who lack a proper shlex.split.
2449 2455
2450 2456 2004-07-19 Fernando Perez <fperez@colorado.edu>
2451 2457
2452 2458 * IPython/iplib.py (InteractiveShell.init_readline): Add support
2453 2459 for reading readline's init file. I follow the normal chain:
2454 2460 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
2455 2461 report by Mike Heeter. This closes
2456 2462 http://www.scipy.net/roundup/ipython/issue16.
2457 2463
2458 2464 2004-07-18 Fernando Perez <fperez@colorado.edu>
2459 2465
2460 2466 * IPython/iplib.py (__init__): Add better handling of '\' under
2461 2467 Win32 for filenames. After a patch by Ville.
2462 2468
2463 2469 2004-07-17 Fernando Perez <fperez@colorado.edu>
2464 2470
2465 2471 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2466 2472 autocalling would be triggered for 'foo is bar' if foo is
2467 2473 callable. I also cleaned up the autocall detection code to use a
2468 2474 regexp, which is faster. Bug reported by Alexander Schmolck.
2469 2475
2470 2476 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
2471 2477 '?' in them would confuse the help system. Reported by Alex
2472 2478 Schmolck.
2473 2479
2474 2480 2004-07-16 Fernando Perez <fperez@colorado.edu>
2475 2481
2476 2482 * IPython/GnuplotInteractive.py (__all__): added plot2.
2477 2483
2478 2484 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
2479 2485 plotting dictionaries, lists or tuples of 1d arrays.
2480 2486
2481 2487 * IPython/Magic.py (Magic.magic_hist): small clenaups and
2482 2488 optimizations.
2483 2489
2484 2490 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
2485 2491 the information which was there from Janko's original IPP code:
2486 2492
2487 2493 03.05.99 20:53 porto.ifm.uni-kiel.de
2488 2494 --Started changelog.
2489 2495 --make clear do what it say it does
2490 2496 --added pretty output of lines from inputcache
2491 2497 --Made Logger a mixin class, simplifies handling of switches
2492 2498 --Added own completer class. .string<TAB> expands to last history
2493 2499 line which starts with string. The new expansion is also present
2494 2500 with Ctrl-r from the readline library. But this shows, who this
2495 2501 can be done for other cases.
2496 2502 --Added convention that all shell functions should accept a
2497 2503 parameter_string This opens the door for different behaviour for
2498 2504 each function. @cd is a good example of this.
2499 2505
2500 2506 04.05.99 12:12 porto.ifm.uni-kiel.de
2501 2507 --added logfile rotation
2502 2508 --added new mainloop method which freezes first the namespace
2503 2509
2504 2510 07.05.99 21:24 porto.ifm.uni-kiel.de
2505 2511 --added the docreader classes. Now there is a help system.
2506 2512 -This is only a first try. Currently it's not easy to put new
2507 2513 stuff in the indices. But this is the way to go. Info would be
2508 2514 better, but HTML is every where and not everybody has an info
2509 2515 system installed and it's not so easy to change html-docs to info.
2510 2516 --added global logfile option
2511 2517 --there is now a hook for object inspection method pinfo needs to
2512 2518 be provided for this. Can be reached by two '??'.
2513 2519
2514 2520 08.05.99 20:51 porto.ifm.uni-kiel.de
2515 2521 --added a README
2516 2522 --bug in rc file. Something has changed so functions in the rc
2517 2523 file need to reference the shell and not self. Not clear if it's a
2518 2524 bug or feature.
2519 2525 --changed rc file for new behavior
2520 2526
2521 2527 2004-07-15 Fernando Perez <fperez@colorado.edu>
2522 2528
2523 2529 * IPython/Logger.py (Logger.log): fixed recent bug where the input
2524 2530 cache was falling out of sync in bizarre manners when multi-line
2525 2531 input was present. Minor optimizations and cleanup.
2526 2532
2527 2533 (Logger): Remove old Changelog info for cleanup. This is the
2528 2534 information which was there from Janko's original code:
2529 2535
2530 2536 Changes to Logger: - made the default log filename a parameter
2531 2537
2532 2538 - put a check for lines beginning with !@? in log(). Needed
2533 2539 (even if the handlers properly log their lines) for mid-session
2534 2540 logging activation to work properly. Without this, lines logged
2535 2541 in mid session, which get read from the cache, would end up
2536 2542 'bare' (with !@? in the open) in the log. Now they are caught
2537 2543 and prepended with a #.
2538 2544
2539 2545 * IPython/iplib.py (InteractiveShell.init_readline): added check
2540 2546 in case MagicCompleter fails to be defined, so we don't crash.
2541 2547
2542 2548 2004-07-13 Fernando Perez <fperez@colorado.edu>
2543 2549
2544 2550 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
2545 2551 of EPS if the requested filename ends in '.eps'.
2546 2552
2547 2553 2004-07-04 Fernando Perez <fperez@colorado.edu>
2548 2554
2549 2555 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
2550 2556 escaping of quotes when calling the shell.
2551 2557
2552 2558 2004-07-02 Fernando Perez <fperez@colorado.edu>
2553 2559
2554 2560 * IPython/Prompts.py (CachedOutput.update): Fix problem with
2555 2561 gettext not working because we were clobbering '_'. Fixes
2556 2562 http://www.scipy.net/roundup/ipython/issue6.
2557 2563
2558 2564 2004-07-01 Fernando Perez <fperez@colorado.edu>
2559 2565
2560 2566 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
2561 2567 into @cd. Patch by Ville.
2562 2568
2563 2569 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2564 2570 new function to store things after ipmaker runs. Patch by Ville.
2565 2571 Eventually this will go away once ipmaker is removed and the class
2566 2572 gets cleaned up, but for now it's ok. Key functionality here is
2567 2573 the addition of the persistent storage mechanism, a dict for
2568 2574 keeping data across sessions (for now just bookmarks, but more can
2569 2575 be implemented later).
2570 2576
2571 2577 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
2572 2578 persistent across sections. Patch by Ville, I modified it
2573 2579 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
2574 2580 added a '-l' option to list all bookmarks.
2575 2581
2576 2582 * IPython/iplib.py (InteractiveShell.atexit_operations): new
2577 2583 center for cleanup. Registered with atexit.register(). I moved
2578 2584 here the old exit_cleanup(). After a patch by Ville.
2579 2585
2580 2586 * IPython/Magic.py (get_py_filename): added '~' to the accepted
2581 2587 characters in the hacked shlex_split for python 2.2.
2582 2588
2583 2589 * IPython/iplib.py (file_matches): more fixes to filenames with
2584 2590 whitespace in them. It's not perfect, but limitations in python's
2585 2591 readline make it impossible to go further.
2586 2592
2587 2593 2004-06-29 Fernando Perez <fperez@colorado.edu>
2588 2594
2589 2595 * IPython/iplib.py (file_matches): escape whitespace correctly in
2590 2596 filename completions. Bug reported by Ville.
2591 2597
2592 2598 2004-06-28 Fernando Perez <fperez@colorado.edu>
2593 2599
2594 2600 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
2595 2601 the history file will be called 'history-PROFNAME' (or just
2596 2602 'history' if no profile is loaded). I was getting annoyed at
2597 2603 getting my Numerical work history clobbered by pysh sessions.
2598 2604
2599 2605 * IPython/iplib.py (InteractiveShell.__init__): Internal
2600 2606 getoutputerror() function so that we can honor the system_verbose
2601 2607 flag for _all_ system calls. I also added escaping of #
2602 2608 characters here to avoid confusing Itpl.
2603 2609
2604 2610 * IPython/Magic.py (shlex_split): removed call to shell in
2605 2611 parse_options and replaced it with shlex.split(). The annoying
2606 2612 part was that in Python 2.2, shlex.split() doesn't exist, so I had
2607 2613 to backport it from 2.3, with several frail hacks (the shlex
2608 2614 module is rather limited in 2.2). Thanks to a suggestion by Ville
2609 2615 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
2610 2616 problem.
2611 2617
2612 2618 (Magic.magic_system_verbose): new toggle to print the actual
2613 2619 system calls made by ipython. Mainly for debugging purposes.
2614 2620
2615 2621 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
2616 2622 doesn't support persistence. Reported (and fix suggested) by
2617 2623 Travis Caldwell <travis_caldwell2000@yahoo.com>.
2618 2624
2619 2625 2004-06-26 Fernando Perez <fperez@colorado.edu>
2620 2626
2621 2627 * IPython/Logger.py (Logger.log): fix to handle correctly empty
2622 2628 continue prompts.
2623 2629
2624 2630 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
2625 2631 function (basically a big docstring) and a few more things here to
2626 2632 speedup startup. pysh.py is now very lightweight. We want because
2627 2633 it gets execfile'd, while InterpreterExec gets imported, so
2628 2634 byte-compilation saves time.
2629 2635
2630 2636 2004-06-25 Fernando Perez <fperez@colorado.edu>
2631 2637
2632 2638 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
2633 2639 -NUM', which was recently broken.
2634 2640
2635 2641 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
2636 2642 in multi-line input (but not !!, which doesn't make sense there).
2637 2643
2638 2644 * IPython/UserConfig/ipythonrc: made autoindent on by default.
2639 2645 It's just too useful, and people can turn it off in the less
2640 2646 common cases where it's a problem.
2641 2647
2642 2648 2004-06-24 Fernando Perez <fperez@colorado.edu>
2643 2649
2644 2650 * IPython/iplib.py (InteractiveShell._prefilter): big change -
2645 2651 special syntaxes (like alias calling) is now allied in multi-line
2646 2652 input. This is still _very_ experimental, but it's necessary for
2647 2653 efficient shell usage combining python looping syntax with system
2648 2654 calls. For now it's restricted to aliases, I don't think it
2649 2655 really even makes sense to have this for magics.
2650 2656
2651 2657 2004-06-23 Fernando Perez <fperez@colorado.edu>
2652 2658
2653 2659 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
2654 2660 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
2655 2661
2656 2662 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
2657 2663 extensions under Windows (after code sent by Gary Bishop). The
2658 2664 extensions considered 'executable' are stored in IPython's rc
2659 2665 structure as win_exec_ext.
2660 2666
2661 2667 * IPython/genutils.py (shell): new function, like system() but
2662 2668 without return value. Very useful for interactive shell work.
2663 2669
2664 2670 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
2665 2671 delete aliases.
2666 2672
2667 2673 * IPython/iplib.py (InteractiveShell.alias_table_update): make
2668 2674 sure that the alias table doesn't contain python keywords.
2669 2675
2670 2676 2004-06-21 Fernando Perez <fperez@colorado.edu>
2671 2677
2672 2678 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
2673 2679 non-existent items are found in $PATH. Reported by Thorsten.
2674 2680
2675 2681 2004-06-20 Fernando Perez <fperez@colorado.edu>
2676 2682
2677 2683 * IPython/iplib.py (complete): modified the completer so that the
2678 2684 order of priorities can be easily changed at runtime.
2679 2685
2680 2686 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
2681 2687 Modified to auto-execute all lines beginning with '~', '/' or '.'.
2682 2688
2683 2689 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
2684 2690 expand Python variables prepended with $ in all system calls. The
2685 2691 same was done to InteractiveShell.handle_shell_escape. Now all
2686 2692 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
2687 2693 expansion of python variables and expressions according to the
2688 2694 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
2689 2695
2690 2696 Though PEP-215 has been rejected, a similar (but simpler) one
2691 2697 seems like it will go into Python 2.4, PEP-292 -
2692 2698 http://www.python.org/peps/pep-0292.html.
2693 2699
2694 2700 I'll keep the full syntax of PEP-215, since IPython has since the
2695 2701 start used Ka-Ping Yee's reference implementation discussed there
2696 2702 (Itpl), and I actually like the powerful semantics it offers.
2697 2703
2698 2704 In order to access normal shell variables, the $ has to be escaped
2699 2705 via an extra $. For example:
2700 2706
2701 2707 In [7]: PATH='a python variable'
2702 2708
2703 2709 In [8]: !echo $PATH
2704 2710 a python variable
2705 2711
2706 2712 In [9]: !echo $$PATH
2707 2713 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2708 2714
2709 2715 (Magic.parse_options): escape $ so the shell doesn't evaluate
2710 2716 things prematurely.
2711 2717
2712 2718 * IPython/iplib.py (InteractiveShell.call_alias): added the
2713 2719 ability for aliases to expand python variables via $.
2714 2720
2715 2721 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
2716 2722 system, now there's a @rehash/@rehashx pair of magics. These work
2717 2723 like the csh rehash command, and can be invoked at any time. They
2718 2724 build a table of aliases to everything in the user's $PATH
2719 2725 (@rehash uses everything, @rehashx is slower but only adds
2720 2726 executable files). With this, the pysh.py-based shell profile can
2721 2727 now simply call rehash upon startup, and full access to all
2722 2728 programs in the user's path is obtained.
2723 2729
2724 2730 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
2725 2731 functionality is now fully in place. I removed the old dynamic
2726 2732 code generation based approach, in favor of a much lighter one
2727 2733 based on a simple dict. The advantage is that this allows me to
2728 2734 now have thousands of aliases with negligible cost (unthinkable
2729 2735 with the old system).
2730 2736
2731 2737 2004-06-19 Fernando Perez <fperez@colorado.edu>
2732 2738
2733 2739 * IPython/iplib.py (__init__): extended MagicCompleter class to
2734 2740 also complete (last in priority) on user aliases.
2735 2741
2736 2742 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
2737 2743 call to eval.
2738 2744 (ItplNS.__init__): Added a new class which functions like Itpl,
2739 2745 but allows configuring the namespace for the evaluation to occur
2740 2746 in.
2741 2747
2742 2748 2004-06-18 Fernando Perez <fperez@colorado.edu>
2743 2749
2744 2750 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
2745 2751 better message when 'exit' or 'quit' are typed (a common newbie
2746 2752 confusion).
2747 2753
2748 2754 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
2749 2755 check for Windows users.
2750 2756
2751 2757 * IPython/iplib.py (InteractiveShell.user_setup): removed
2752 2758 disabling of colors for Windows. I'll test at runtime and issue a
2753 2759 warning if Gary's readline isn't found, as to nudge users to
2754 2760 download it.
2755 2761
2756 2762 2004-06-16 Fernando Perez <fperez@colorado.edu>
2757 2763
2758 2764 * IPython/genutils.py (Stream.__init__): changed to print errors
2759 2765 to sys.stderr. I had a circular dependency here. Now it's
2760 2766 possible to run ipython as IDLE's shell (consider this pre-alpha,
2761 2767 since true stdout things end up in the starting terminal instead
2762 2768 of IDLE's out).
2763 2769
2764 2770 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
2765 2771 users who haven't # updated their prompt_in2 definitions. Remove
2766 2772 eventually.
2767 2773 (multiple_replace): added credit to original ASPN recipe.
2768 2774
2769 2775 2004-06-15 Fernando Perez <fperez@colorado.edu>
2770 2776
2771 2777 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
2772 2778 list of auto-defined aliases.
2773 2779
2774 2780 2004-06-13 Fernando Perez <fperez@colorado.edu>
2775 2781
2776 2782 * setup.py (scriptfiles): Don't trigger win_post_install unless an
2777 2783 install was really requested (so setup.py can be used for other
2778 2784 things under Windows).
2779 2785
2780 2786 2004-06-10 Fernando Perez <fperez@colorado.edu>
2781 2787
2782 2788 * IPython/Logger.py (Logger.create_log): Manually remove any old
2783 2789 backup, since os.remove may fail under Windows. Fixes bug
2784 2790 reported by Thorsten.
2785 2791
2786 2792 2004-06-09 Fernando Perez <fperez@colorado.edu>
2787 2793
2788 2794 * examples/example-embed.py: fixed all references to %n (replaced
2789 2795 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
2790 2796 for all examples and the manual as well.
2791 2797
2792 2798 2004-06-08 Fernando Perez <fperez@colorado.edu>
2793 2799
2794 2800 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
2795 2801 alignment and color management. All 3 prompt subsystems now
2796 2802 inherit from BasePrompt.
2797 2803
2798 2804 * tools/release: updates for windows installer build and tag rpms
2799 2805 with python version (since paths are fixed).
2800 2806
2801 2807 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
2802 2808 which will become eventually obsolete. Also fixed the default
2803 2809 prompt_in2 to use \D, so at least new users start with the correct
2804 2810 defaults.
2805 2811 WARNING: Users with existing ipythonrc files will need to apply
2806 2812 this fix manually!
2807 2813
2808 2814 * setup.py: make windows installer (.exe). This is finally the
2809 2815 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
2810 2816 which I hadn't included because it required Python 2.3 (or recent
2811 2817 distutils).
2812 2818
2813 2819 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
2814 2820 usage of new '\D' escape.
2815 2821
2816 2822 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
2817 2823 lacks os.getuid())
2818 2824 (CachedOutput.set_colors): Added the ability to turn coloring
2819 2825 on/off with @colors even for manually defined prompt colors. It
2820 2826 uses a nasty global, but it works safely and via the generic color
2821 2827 handling mechanism.
2822 2828 (Prompt2.__init__): Introduced new escape '\D' for continuation
2823 2829 prompts. It represents the counter ('\#') as dots.
2824 2830 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
2825 2831 need to update their ipythonrc files and replace '%n' with '\D' in
2826 2832 their prompt_in2 settings everywhere. Sorry, but there's
2827 2833 otherwise no clean way to get all prompts to properly align. The
2828 2834 ipythonrc shipped with IPython has been updated.
2829 2835
2830 2836 2004-06-07 Fernando Perez <fperez@colorado.edu>
2831 2837
2832 2838 * setup.py (isfile): Pass local_icons option to latex2html, so the
2833 2839 resulting HTML file is self-contained. Thanks to
2834 2840 dryice-AT-liu.com.cn for the tip.
2835 2841
2836 2842 * pysh.py: I created a new profile 'shell', which implements a
2837 2843 _rudimentary_ IPython-based shell. This is in NO WAY a realy
2838 2844 system shell, nor will it become one anytime soon. It's mainly
2839 2845 meant to illustrate the use of the new flexible bash-like prompts.
2840 2846 I guess it could be used by hardy souls for true shell management,
2841 2847 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
2842 2848 profile. This uses the InterpreterExec extension provided by
2843 2849 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
2844 2850
2845 2851 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
2846 2852 auto-align itself with the length of the previous input prompt
2847 2853 (taking into account the invisible color escapes).
2848 2854 (CachedOutput.__init__): Large restructuring of this class. Now
2849 2855 all three prompts (primary1, primary2, output) are proper objects,
2850 2856 managed by the 'parent' CachedOutput class. The code is still a
2851 2857 bit hackish (all prompts share state via a pointer to the cache),
2852 2858 but it's overall far cleaner than before.
2853 2859
2854 2860 * IPython/genutils.py (getoutputerror): modified to add verbose,
2855 2861 debug and header options. This makes the interface of all getout*
2856 2862 functions uniform.
2857 2863 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
2858 2864
2859 2865 * IPython/Magic.py (Magic.default_option): added a function to
2860 2866 allow registering default options for any magic command. This
2861 2867 makes it easy to have profiles which customize the magics globally
2862 2868 for a certain use. The values set through this function are
2863 2869 picked up by the parse_options() method, which all magics should
2864 2870 use to parse their options.
2865 2871
2866 2872 * IPython/genutils.py (warn): modified the warnings framework to
2867 2873 use the Term I/O class. I'm trying to slowly unify all of
2868 2874 IPython's I/O operations to pass through Term.
2869 2875
2870 2876 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
2871 2877 the secondary prompt to correctly match the length of the primary
2872 2878 one for any prompt. Now multi-line code will properly line up
2873 2879 even for path dependent prompts, such as the new ones available
2874 2880 via the prompt_specials.
2875 2881
2876 2882 2004-06-06 Fernando Perez <fperez@colorado.edu>
2877 2883
2878 2884 * IPython/Prompts.py (prompt_specials): Added the ability to have
2879 2885 bash-like special sequences in the prompts, which get
2880 2886 automatically expanded. Things like hostname, current working
2881 2887 directory and username are implemented already, but it's easy to
2882 2888 add more in the future. Thanks to a patch by W.J. van der Laan
2883 2889 <gnufnork-AT-hetdigitalegat.nl>
2884 2890 (prompt_specials): Added color support for prompt strings, so
2885 2891 users can define arbitrary color setups for their prompts.
2886 2892
2887 2893 2004-06-05 Fernando Perez <fperez@colorado.edu>
2888 2894
2889 2895 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
2890 2896 code to load Gary Bishop's readline and configure it
2891 2897 automatically. Thanks to Gary for help on this.
2892 2898
2893 2899 2004-06-01 Fernando Perez <fperez@colorado.edu>
2894 2900
2895 2901 * IPython/Logger.py (Logger.create_log): fix bug for logging
2896 2902 with no filename (previous fix was incomplete).
2897 2903
2898 2904 2004-05-25 Fernando Perez <fperez@colorado.edu>
2899 2905
2900 2906 * IPython/Magic.py (Magic.parse_options): fix bug where naked
2901 2907 parens would get passed to the shell.
2902 2908
2903 2909 2004-05-20 Fernando Perez <fperez@colorado.edu>
2904 2910
2905 2911 * IPython/Magic.py (Magic.magic_prun): changed default profile
2906 2912 sort order to 'time' (the more common profiling need).
2907 2913
2908 2914 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
2909 2915 so that source code shown is guaranteed in sync with the file on
2910 2916 disk (also changed in psource). Similar fix to the one for
2911 2917 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
2912 2918 <yann.ledu-AT-noos.fr>.
2913 2919
2914 2920 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
2915 2921 with a single option would not be correctly parsed. Closes
2916 2922 http://www.scipy.net/roundup/ipython/issue14. This bug had been
2917 2923 introduced in 0.6.0 (on 2004-05-06).
2918 2924
2919 2925 2004-05-13 *** Released version 0.6.0
2920 2926
2921 2927 2004-05-13 Fernando Perez <fperez@colorado.edu>
2922 2928
2923 2929 * debian/: Added debian/ directory to CVS, so that debian support
2924 2930 is publicly accessible. The debian package is maintained by Jack
2925 2931 Moffit <jack-AT-xiph.org>.
2926 2932
2927 2933 * Documentation: included the notes about an ipython-based system
2928 2934 shell (the hypothetical 'pysh') into the new_design.pdf document,
2929 2935 so that these ideas get distributed to users along with the
2930 2936 official documentation.
2931 2937
2932 2938 2004-05-10 Fernando Perez <fperez@colorado.edu>
2933 2939
2934 2940 * IPython/Logger.py (Logger.create_log): fix recently introduced
2935 2941 bug (misindented line) where logstart would fail when not given an
2936 2942 explicit filename.
2937 2943
2938 2944 2004-05-09 Fernando Perez <fperez@colorado.edu>
2939 2945
2940 2946 * IPython/Magic.py (Magic.parse_options): skip system call when
2941 2947 there are no options to look for. Faster, cleaner for the common
2942 2948 case.
2943 2949
2944 2950 * Documentation: many updates to the manual: describing Windows
2945 2951 support better, Gnuplot updates, credits, misc small stuff. Also
2946 2952 updated the new_design doc a bit.
2947 2953
2948 2954 2004-05-06 *** Released version 0.6.0.rc1
2949 2955
2950 2956 2004-05-06 Fernando Perez <fperez@colorado.edu>
2951 2957
2952 2958 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
2953 2959 operations to use the vastly more efficient list/''.join() method.
2954 2960 (FormattedTB.text): Fix
2955 2961 http://www.scipy.net/roundup/ipython/issue12 - exception source
2956 2962 extract not updated after reload. Thanks to Mike Salib
2957 2963 <msalib-AT-mit.edu> for pinning the source of the problem.
2958 2964 Fortunately, the solution works inside ipython and doesn't require
2959 2965 any changes to python proper.
2960 2966
2961 2967 * IPython/Magic.py (Magic.parse_options): Improved to process the
2962 2968 argument list as a true shell would (by actually using the
2963 2969 underlying system shell). This way, all @magics automatically get
2964 2970 shell expansion for variables. Thanks to a comment by Alex
2965 2971 Schmolck.
2966 2972
2967 2973 2004-04-04 Fernando Perez <fperez@colorado.edu>
2968 2974
2969 2975 * IPython/iplib.py (InteractiveShell.interact): Added a special
2970 2976 trap for a debugger quit exception, which is basically impossible
2971 2977 to handle by normal mechanisms, given what pdb does to the stack.
2972 2978 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
2973 2979
2974 2980 2004-04-03 Fernando Perez <fperez@colorado.edu>
2975 2981
2976 2982 * IPython/genutils.py (Term): Standardized the names of the Term
2977 2983 class streams to cin/cout/cerr, following C++ naming conventions
2978 2984 (I can't use in/out/err because 'in' is not a valid attribute
2979 2985 name).
2980 2986
2981 2987 * IPython/iplib.py (InteractiveShell.interact): don't increment
2982 2988 the prompt if there's no user input. By Daniel 'Dang' Griffith
2983 2989 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
2984 2990 Francois Pinard.
2985 2991
2986 2992 2004-04-02 Fernando Perez <fperez@colorado.edu>
2987 2993
2988 2994 * IPython/genutils.py (Stream.__init__): Modified to survive at
2989 2995 least importing in contexts where stdin/out/err aren't true file
2990 2996 objects, such as PyCrust (they lack fileno() and mode). However,
2991 2997 the recovery facilities which rely on these things existing will
2992 2998 not work.
2993 2999
2994 3000 2004-04-01 Fernando Perez <fperez@colorado.edu>
2995 3001
2996 3002 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
2997 3003 use the new getoutputerror() function, so it properly
2998 3004 distinguishes stdout/err.
2999 3005
3000 3006 * IPython/genutils.py (getoutputerror): added a function to
3001 3007 capture separately the standard output and error of a command.
3002 3008 After a comment from dang on the mailing lists. This code is
3003 3009 basically a modified version of commands.getstatusoutput(), from
3004 3010 the standard library.
3005 3011
3006 3012 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
3007 3013 '!!' as a special syntax (shorthand) to access @sx.
3008 3014
3009 3015 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
3010 3016 command and return its output as a list split on '\n'.
3011 3017
3012 3018 2004-03-31 Fernando Perez <fperez@colorado.edu>
3013 3019
3014 3020 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
3015 3021 method to dictionaries used as FakeModule instances if they lack
3016 3022 it. At least pydoc in python2.3 breaks for runtime-defined
3017 3023 functions without this hack. At some point I need to _really_
3018 3024 understand what FakeModule is doing, because it's a gross hack.
3019 3025 But it solves Arnd's problem for now...
3020 3026
3021 3027 2004-02-27 Fernando Perez <fperez@colorado.edu>
3022 3028
3023 3029 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
3024 3030 mode would behave erratically. Also increased the number of
3025 3031 possible logs in rotate mod to 999. Thanks to Rod Holland
3026 3032 <rhh@StructureLABS.com> for the report and fixes.
3027 3033
3028 3034 2004-02-26 Fernando Perez <fperez@colorado.edu>
3029 3035
3030 3036 * IPython/genutils.py (page): Check that the curses module really
3031 3037 has the initscr attribute before trying to use it. For some
3032 3038 reason, the Solaris curses module is missing this. I think this
3033 3039 should be considered a Solaris python bug, but I'm not sure.
3034 3040
3035 3041 2004-01-17 Fernando Perez <fperez@colorado.edu>
3036 3042
3037 3043 * IPython/genutils.py (Stream.__init__): Changes to try to make
3038 3044 ipython robust against stdin/out/err being closed by the user.
3039 3045 This is 'user error' (and blocks a normal python session, at least
3040 3046 the stdout case). However, Ipython should be able to survive such
3041 3047 instances of abuse as gracefully as possible. To simplify the
3042 3048 coding and maintain compatibility with Gary Bishop's Term
3043 3049 contributions, I've made use of classmethods for this. I think
3044 3050 this introduces a dependency on python 2.2.
3045 3051
3046 3052 2004-01-13 Fernando Perez <fperez@colorado.edu>
3047 3053
3048 3054 * IPython/numutils.py (exp_safe): simplified the code a bit and
3049 3055 removed the need for importing the kinds module altogether.
3050 3056
3051 3057 2004-01-06 Fernando Perez <fperez@colorado.edu>
3052 3058
3053 3059 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
3054 3060 a magic function instead, after some community feedback. No
3055 3061 special syntax will exist for it, but its name is deliberately
3056 3062 very short.
3057 3063
3058 3064 2003-12-20 Fernando Perez <fperez@colorado.edu>
3059 3065
3060 3066 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
3061 3067 new functionality, to automagically assign the result of a shell
3062 3068 command to a variable. I'll solicit some community feedback on
3063 3069 this before making it permanent.
3064 3070
3065 3071 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
3066 3072 requested about callables for which inspect couldn't obtain a
3067 3073 proper argspec. Thanks to a crash report sent by Etienne
3068 3074 Posthumus <etienne-AT-apple01.cs.vu.nl>.
3069 3075
3070 3076 2003-12-09 Fernando Perez <fperez@colorado.edu>
3071 3077
3072 3078 * IPython/genutils.py (page): patch for the pager to work across
3073 3079 various versions of Windows. By Gary Bishop.
3074 3080
3075 3081 2003-12-04 Fernando Perez <fperez@colorado.edu>
3076 3082
3077 3083 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
3078 3084 Gnuplot.py version 1.7, whose internal names changed quite a bit.
3079 3085 While I tested this and it looks ok, there may still be corner
3080 3086 cases I've missed.
3081 3087
3082 3088 2003-12-01 Fernando Perez <fperez@colorado.edu>
3083 3089
3084 3090 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
3085 3091 where a line like 'p,q=1,2' would fail because the automagic
3086 3092 system would be triggered for @p.
3087 3093
3088 3094 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
3089 3095 cleanups, code unmodified.
3090 3096
3091 3097 * IPython/genutils.py (Term): added a class for IPython to handle
3092 3098 output. In most cases it will just be a proxy for stdout/err, but
3093 3099 having this allows modifications to be made for some platforms,
3094 3100 such as handling color escapes under Windows. All of this code
3095 3101 was contributed by Gary Bishop, with minor modifications by me.
3096 3102 The actual changes affect many files.
3097 3103
3098 3104 2003-11-30 Fernando Perez <fperez@colorado.edu>
3099 3105
3100 3106 * IPython/iplib.py (file_matches): new completion code, courtesy
3101 3107 of Jeff Collins. This enables filename completion again under
3102 3108 python 2.3, which disabled it at the C level.
3103 3109
3104 3110 2003-11-11 Fernando Perez <fperez@colorado.edu>
3105 3111
3106 3112 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
3107 3113 for Numeric.array(map(...)), but often convenient.
3108 3114
3109 3115 2003-11-05 Fernando Perez <fperez@colorado.edu>
3110 3116
3111 3117 * IPython/numutils.py (frange): Changed a call from int() to
3112 3118 int(round()) to prevent a problem reported with arange() in the
3113 3119 numpy list.
3114 3120
3115 3121 2003-10-06 Fernando Perez <fperez@colorado.edu>
3116 3122
3117 3123 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
3118 3124 prevent crashes if sys lacks an argv attribute (it happens with
3119 3125 embedded interpreters which build a bare-bones sys module).
3120 3126 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
3121 3127
3122 3128 2003-09-24 Fernando Perez <fperez@colorado.edu>
3123 3129
3124 3130 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
3125 3131 to protect against poorly written user objects where __getattr__
3126 3132 raises exceptions other than AttributeError. Thanks to a bug
3127 3133 report by Oliver Sander <osander-AT-gmx.de>.
3128 3134
3129 3135 * IPython/FakeModule.py (FakeModule.__repr__): this method was
3130 3136 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
3131 3137
3132 3138 2003-09-09 Fernando Perez <fperez@colorado.edu>
3133 3139
3134 3140 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3135 3141 unpacking a list whith a callable as first element would
3136 3142 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
3137 3143 Collins.
3138 3144
3139 3145 2003-08-25 *** Released version 0.5.0
3140 3146
3141 3147 2003-08-22 Fernando Perez <fperez@colorado.edu>
3142 3148
3143 3149 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
3144 3150 improperly defined user exceptions. Thanks to feedback from Mark
3145 3151 Russell <mrussell-AT-verio.net>.
3146 3152
3147 3153 2003-08-20 Fernando Perez <fperez@colorado.edu>
3148 3154
3149 3155 * IPython/OInspect.py (Inspector.pinfo): changed String Form
3150 3156 printing so that it would print multi-line string forms starting
3151 3157 with a new line. This way the formatting is better respected for
3152 3158 objects which work hard to make nice string forms.
3153 3159
3154 3160 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
3155 3161 autocall would overtake data access for objects with both
3156 3162 __getitem__ and __call__.
3157 3163
3158 3164 2003-08-19 *** Released version 0.5.0-rc1
3159 3165
3160 3166 2003-08-19 Fernando Perez <fperez@colorado.edu>
3161 3167
3162 3168 * IPython/deep_reload.py (load_tail): single tiny change here
3163 3169 seems to fix the long-standing bug of dreload() failing to work
3164 3170 for dotted names. But this module is pretty tricky, so I may have
3165 3171 missed some subtlety. Needs more testing!.
3166 3172
3167 3173 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
3168 3174 exceptions which have badly implemented __str__ methods.
3169 3175 (VerboseTB.text): harden against inspect.getinnerframes crashing,
3170 3176 which I've been getting reports about from Python 2.3 users. I
3171 3177 wish I had a simple test case to reproduce the problem, so I could
3172 3178 either write a cleaner workaround or file a bug report if
3173 3179 necessary.
3174 3180
3175 3181 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
3176 3182 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
3177 3183 a bug report by Tjabo Kloppenburg.
3178 3184
3179 3185 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
3180 3186 crashes. Wrapped the pdb call in a blanket try/except, since pdb
3181 3187 seems rather unstable. Thanks to a bug report by Tjabo
3182 3188 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
3183 3189
3184 3190 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
3185 3191 this out soon because of the critical fixes in the inner loop for
3186 3192 generators.
3187 3193
3188 3194 * IPython/Magic.py (Magic.getargspec): removed. This (and
3189 3195 _get_def) have been obsoleted by OInspect for a long time, I
3190 3196 hadn't noticed that they were dead code.
3191 3197 (Magic._ofind): restored _ofind functionality for a few literals
3192 3198 (those in ["''",'""','[]','{}','()']). But it won't work anymore
3193 3199 for things like "hello".capitalize?, since that would require a
3194 3200 potentially dangerous eval() again.
3195 3201
3196 3202 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
3197 3203 logic a bit more to clean up the escapes handling and minimize the
3198 3204 use of _ofind to only necessary cases. The interactive 'feel' of
3199 3205 IPython should have improved quite a bit with the changes in
3200 3206 _prefilter and _ofind (besides being far safer than before).
3201 3207
3202 3208 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
3203 3209 obscure, never reported). Edit would fail to find the object to
3204 3210 edit under some circumstances.
3205 3211 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
3206 3212 which were causing double-calling of generators. Those eval calls
3207 3213 were _very_ dangerous, since code with side effects could be
3208 3214 triggered. As they say, 'eval is evil'... These were the
3209 3215 nastiest evals in IPython. Besides, _ofind is now far simpler,
3210 3216 and it should also be quite a bit faster. Its use of inspect is
3211 3217 also safer, so perhaps some of the inspect-related crashes I've
3212 3218 seen lately with Python 2.3 might be taken care of. That will
3213 3219 need more testing.
3214 3220
3215 3221 2003-08-17 Fernando Perez <fperez@colorado.edu>
3216 3222
3217 3223 * IPython/iplib.py (InteractiveShell._prefilter): significant
3218 3224 simplifications to the logic for handling user escapes. Faster
3219 3225 and simpler code.
3220 3226
3221 3227 2003-08-14 Fernando Perez <fperez@colorado.edu>
3222 3228
3223 3229 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
3224 3230 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
3225 3231 but it should be quite a bit faster. And the recursive version
3226 3232 generated O(log N) intermediate storage for all rank>1 arrays,
3227 3233 even if they were contiguous.
3228 3234 (l1norm): Added this function.
3229 3235 (norm): Added this function for arbitrary norms (including
3230 3236 l-infinity). l1 and l2 are still special cases for convenience
3231 3237 and speed.
3232 3238
3233 3239 2003-08-03 Fernando Perez <fperez@colorado.edu>
3234 3240
3235 3241 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
3236 3242 exceptions, which now raise PendingDeprecationWarnings in Python
3237 3243 2.3. There were some in Magic and some in Gnuplot2.
3238 3244
3239 3245 2003-06-30 Fernando Perez <fperez@colorado.edu>
3240 3246
3241 3247 * IPython/genutils.py (page): modified to call curses only for
3242 3248 terminals where TERM=='xterm'. After problems under many other
3243 3249 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
3244 3250
3245 3251 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
3246 3252 would be triggered when readline was absent. This was just an old
3247 3253 debugging statement I'd forgotten to take out.
3248 3254
3249 3255 2003-06-20 Fernando Perez <fperez@colorado.edu>
3250 3256
3251 3257 * IPython/genutils.py (clock): modified to return only user time
3252 3258 (not counting system time), after a discussion on scipy. While
3253 3259 system time may be a useful quantity occasionally, it may much
3254 3260 more easily be skewed by occasional swapping or other similar
3255 3261 activity.
3256 3262
3257 3263 2003-06-05 Fernando Perez <fperez@colorado.edu>
3258 3264
3259 3265 * IPython/numutils.py (identity): new function, for building
3260 3266 arbitrary rank Kronecker deltas (mostly backwards compatible with
3261 3267 Numeric.identity)
3262 3268
3263 3269 2003-06-03 Fernando Perez <fperez@colorado.edu>
3264 3270
3265 3271 * IPython/iplib.py (InteractiveShell.handle_magic): protect
3266 3272 arguments passed to magics with spaces, to allow trailing '\' to
3267 3273 work normally (mainly for Windows users).
3268 3274
3269 3275 2003-05-29 Fernando Perez <fperez@colorado.edu>
3270 3276
3271 3277 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
3272 3278 instead of pydoc.help. This fixes a bizarre behavior where
3273 3279 printing '%s' % locals() would trigger the help system. Now
3274 3280 ipython behaves like normal python does.
3275 3281
3276 3282 Note that if one does 'from pydoc import help', the bizarre
3277 3283 behavior returns, but this will also happen in normal python, so
3278 3284 it's not an ipython bug anymore (it has to do with how pydoc.help
3279 3285 is implemented).
3280 3286
3281 3287 2003-05-22 Fernando Perez <fperez@colorado.edu>
3282 3288
3283 3289 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
3284 3290 return [] instead of None when nothing matches, also match to end
3285 3291 of line. Patch by Gary Bishop.
3286 3292
3287 3293 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
3288 3294 protection as before, for files passed on the command line. This
3289 3295 prevents the CrashHandler from kicking in if user files call into
3290 3296 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
3291 3297 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
3292 3298
3293 3299 2003-05-20 *** Released version 0.4.0
3294 3300
3295 3301 2003-05-20 Fernando Perez <fperez@colorado.edu>
3296 3302
3297 3303 * setup.py: added support for manpages. It's a bit hackish b/c of
3298 3304 a bug in the way the bdist_rpm distutils target handles gzipped
3299 3305 manpages, but it works. After a patch by Jack.
3300 3306
3301 3307 2003-05-19 Fernando Perez <fperez@colorado.edu>
3302 3308
3303 3309 * IPython/numutils.py: added a mockup of the kinds module, since
3304 3310 it was recently removed from Numeric. This way, numutils will
3305 3311 work for all users even if they are missing kinds.
3306 3312
3307 3313 * IPython/Magic.py (Magic._ofind): Harden against an inspect
3308 3314 failure, which can occur with SWIG-wrapped extensions. After a
3309 3315 crash report from Prabhu.
3310 3316
3311 3317 2003-05-16 Fernando Perez <fperez@colorado.edu>
3312 3318
3313 3319 * IPython/iplib.py (InteractiveShell.excepthook): New method to
3314 3320 protect ipython from user code which may call directly
3315 3321 sys.excepthook (this looks like an ipython crash to the user, even
3316 3322 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
3317 3323 This is especially important to help users of WxWindows, but may
3318 3324 also be useful in other cases.
3319 3325
3320 3326 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
3321 3327 an optional tb_offset to be specified, and to preserve exception
3322 3328 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
3323 3329
3324 3330 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
3325 3331
3326 3332 2003-05-15 Fernando Perez <fperez@colorado.edu>
3327 3333
3328 3334 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
3329 3335 installing for a new user under Windows.
3330 3336
3331 3337 2003-05-12 Fernando Perez <fperez@colorado.edu>
3332 3338
3333 3339 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
3334 3340 handler for Emacs comint-based lines. Currently it doesn't do
3335 3341 much (but importantly, it doesn't update the history cache). In
3336 3342 the future it may be expanded if Alex needs more functionality
3337 3343 there.
3338 3344
3339 3345 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
3340 3346 info to crash reports.
3341 3347
3342 3348 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
3343 3349 just like Python's -c. Also fixed crash with invalid -color
3344 3350 option value at startup. Thanks to Will French
3345 3351 <wfrench-AT-bestweb.net> for the bug report.
3346 3352
3347 3353 2003-05-09 Fernando Perez <fperez@colorado.edu>
3348 3354
3349 3355 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
3350 3356 to EvalDict (it's a mapping, after all) and simplified its code
3351 3357 quite a bit, after a nice discussion on c.l.py where Gustavo
3352 3358 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
3353 3359
3354 3360 2003-04-30 Fernando Perez <fperez@colorado.edu>
3355 3361
3356 3362 * IPython/genutils.py (timings_out): modified it to reduce its
3357 3363 overhead in the common reps==1 case.
3358 3364
3359 3365 2003-04-29 Fernando Perez <fperez@colorado.edu>
3360 3366
3361 3367 * IPython/genutils.py (timings_out): Modified to use the resource
3362 3368 module, which avoids the wraparound problems of time.clock().
3363 3369
3364 3370 2003-04-17 *** Released version 0.2.15pre4
3365 3371
3366 3372 2003-04-17 Fernando Perez <fperez@colorado.edu>
3367 3373
3368 3374 * setup.py (scriptfiles): Split windows-specific stuff over to a
3369 3375 separate file, in an attempt to have a Windows GUI installer.
3370 3376 That didn't work, but part of the groundwork is done.
3371 3377
3372 3378 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
3373 3379 indent/unindent with 4 spaces. Particularly useful in combination
3374 3380 with the new auto-indent option.
3375 3381
3376 3382 2003-04-16 Fernando Perez <fperez@colorado.edu>
3377 3383
3378 3384 * IPython/Magic.py: various replacements of self.rc for
3379 3385 self.shell.rc. A lot more remains to be done to fully disentangle
3380 3386 this class from the main Shell class.
3381 3387
3382 3388 * IPython/GnuplotRuntime.py: added checks for mouse support so
3383 3389 that we don't try to enable it if the current gnuplot doesn't
3384 3390 really support it. Also added checks so that we don't try to
3385 3391 enable persist under Windows (where Gnuplot doesn't recognize the
3386 3392 option).
3387 3393
3388 3394 * IPython/iplib.py (InteractiveShell.interact): Added optional
3389 3395 auto-indenting code, after a patch by King C. Shu
3390 3396 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
3391 3397 get along well with pasting indented code. If I ever figure out
3392 3398 how to make that part go well, it will become on by default.
3393 3399
3394 3400 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
3395 3401 crash ipython if there was an unmatched '%' in the user's prompt
3396 3402 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3397 3403
3398 3404 * IPython/iplib.py (InteractiveShell.interact): removed the
3399 3405 ability to ask the user whether he wants to crash or not at the
3400 3406 'last line' exception handler. Calling functions at that point
3401 3407 changes the stack, and the error reports would have incorrect
3402 3408 tracebacks.
3403 3409
3404 3410 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
3405 3411 pass through a peger a pretty-printed form of any object. After a
3406 3412 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
3407 3413
3408 3414 2003-04-14 Fernando Perez <fperez@colorado.edu>
3409 3415
3410 3416 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
3411 3417 all files in ~ would be modified at first install (instead of
3412 3418 ~/.ipython). This could be potentially disastrous, as the
3413 3419 modification (make line-endings native) could damage binary files.
3414 3420
3415 3421 2003-04-10 Fernando Perez <fperez@colorado.edu>
3416 3422
3417 3423 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
3418 3424 handle only lines which are invalid python. This now means that
3419 3425 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
3420 3426 for the bug report.
3421 3427
3422 3428 2003-04-01 Fernando Perez <fperez@colorado.edu>
3423 3429
3424 3430 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
3425 3431 where failing to set sys.last_traceback would crash pdb.pm().
3426 3432 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
3427 3433 report.
3428 3434
3429 3435 2003-03-25 Fernando Perez <fperez@colorado.edu>
3430 3436
3431 3437 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
3432 3438 before printing it (it had a lot of spurious blank lines at the
3433 3439 end).
3434 3440
3435 3441 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
3436 3442 output would be sent 21 times! Obviously people don't use this
3437 3443 too often, or I would have heard about it.
3438 3444
3439 3445 2003-03-24 Fernando Perez <fperez@colorado.edu>
3440 3446
3441 3447 * setup.py (scriptfiles): renamed the data_files parameter from
3442 3448 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
3443 3449 for the patch.
3444 3450
3445 3451 2003-03-20 Fernando Perez <fperez@colorado.edu>
3446 3452
3447 3453 * IPython/genutils.py (error): added error() and fatal()
3448 3454 functions.
3449 3455
3450 3456 2003-03-18 *** Released version 0.2.15pre3
3451 3457
3452 3458 2003-03-18 Fernando Perez <fperez@colorado.edu>
3453 3459
3454 3460 * setupext/install_data_ext.py
3455 3461 (install_data_ext.initialize_options): Class contributed by Jack
3456 3462 Moffit for fixing the old distutils hack. He is sending this to
3457 3463 the distutils folks so in the future we may not need it as a
3458 3464 private fix.
3459 3465
3460 3466 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
3461 3467 changes for Debian packaging. See his patch for full details.
3462 3468 The old distutils hack of making the ipythonrc* files carry a
3463 3469 bogus .py extension is gone, at last. Examples were moved to a
3464 3470 separate subdir under doc/, and the separate executable scripts
3465 3471 now live in their own directory. Overall a great cleanup. The
3466 3472 manual was updated to use the new files, and setup.py has been
3467 3473 fixed for this setup.
3468 3474
3469 3475 * IPython/PyColorize.py (Parser.usage): made non-executable and
3470 3476 created a pycolor wrapper around it to be included as a script.
3471 3477
3472 3478 2003-03-12 *** Released version 0.2.15pre2
3473 3479
3474 3480 2003-03-12 Fernando Perez <fperez@colorado.edu>
3475 3481
3476 3482 * IPython/ColorANSI.py (make_color_table): Finally fixed the
3477 3483 long-standing problem with garbage characters in some terminals.
3478 3484 The issue was really that the \001 and \002 escapes must _only_ be
3479 3485 passed to input prompts (which call readline), but _never_ to
3480 3486 normal text to be printed on screen. I changed ColorANSI to have
3481 3487 two classes: TermColors and InputTermColors, each with the
3482 3488 appropriate escapes for input prompts or normal text. The code in
3483 3489 Prompts.py got slightly more complicated, but this very old and
3484 3490 annoying bug is finally fixed.
3485 3491
3486 3492 All the credit for nailing down the real origin of this problem
3487 3493 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
3488 3494 *Many* thanks to him for spending quite a bit of effort on this.
3489 3495
3490 3496 2003-03-05 *** Released version 0.2.15pre1
3491 3497
3492 3498 2003-03-03 Fernando Perez <fperez@colorado.edu>
3493 3499
3494 3500 * IPython/FakeModule.py: Moved the former _FakeModule to a
3495 3501 separate file, because it's also needed by Magic (to fix a similar
3496 3502 pickle-related issue in @run).
3497 3503
3498 3504 2003-03-02 Fernando Perez <fperez@colorado.edu>
3499 3505
3500 3506 * IPython/Magic.py (Magic.magic_autocall): new magic to control
3501 3507 the autocall option at runtime.
3502 3508 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
3503 3509 across Magic.py to start separating Magic from InteractiveShell.
3504 3510 (Magic._ofind): Fixed to return proper namespace for dotted
3505 3511 names. Before, a dotted name would always return 'not currently
3506 3512 defined', because it would find the 'parent'. s.x would be found,
3507 3513 but since 'x' isn't defined by itself, it would get confused.
3508 3514 (Magic.magic_run): Fixed pickling problems reported by Ralf
3509 3515 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
3510 3516 that I'd used when Mike Heeter reported similar issues at the
3511 3517 top-level, but now for @run. It boils down to injecting the
3512 3518 namespace where code is being executed with something that looks
3513 3519 enough like a module to fool pickle.dump(). Since a pickle stores
3514 3520 a named reference to the importing module, we need this for
3515 3521 pickles to save something sensible.
3516 3522
3517 3523 * IPython/ipmaker.py (make_IPython): added an autocall option.
3518 3524
3519 3525 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
3520 3526 the auto-eval code. Now autocalling is an option, and the code is
3521 3527 also vastly safer. There is no more eval() involved at all.
3522 3528
3523 3529 2003-03-01 Fernando Perez <fperez@colorado.edu>
3524 3530
3525 3531 * IPython/Magic.py (Magic._ofind): Changed interface to return a
3526 3532 dict with named keys instead of a tuple.
3527 3533
3528 3534 * IPython: Started using CVS for IPython as of 0.2.15pre1.
3529 3535
3530 3536 * setup.py (make_shortcut): Fixed message about directories
3531 3537 created during Windows installation (the directories were ok, just
3532 3538 the printed message was misleading). Thanks to Chris Liechti
3533 3539 <cliechti-AT-gmx.net> for the heads up.
3534 3540
3535 3541 2003-02-21 Fernando Perez <fperez@colorado.edu>
3536 3542
3537 3543 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
3538 3544 of ValueError exception when checking for auto-execution. This
3539 3545 one is raised by things like Numeric arrays arr.flat when the
3540 3546 array is non-contiguous.
3541 3547
3542 3548 2003-01-31 Fernando Perez <fperez@colorado.edu>
3543 3549
3544 3550 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
3545 3551 not return any value at all (even though the command would get
3546 3552 executed).
3547 3553 (xsys): Flush stdout right after printing the command to ensure
3548 3554 proper ordering of commands and command output in the total
3549 3555 output.
3550 3556 (SystemExec/xsys/bq): Switched the names of xsys/bq and
3551 3557 system/getoutput as defaults. The old ones are kept for
3552 3558 compatibility reasons, so no code which uses this library needs
3553 3559 changing.
3554 3560
3555 3561 2003-01-27 *** Released version 0.2.14
3556 3562
3557 3563 2003-01-25 Fernando Perez <fperez@colorado.edu>
3558 3564
3559 3565 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
3560 3566 functions defined in previous edit sessions could not be re-edited
3561 3567 (because the temp files were immediately removed). Now temp files
3562 3568 are removed only at IPython's exit.
3563 3569 (Magic.magic_run): Improved @run to perform shell-like expansions
3564 3570 on its arguments (~users and $VARS). With this, @run becomes more
3565 3571 like a normal command-line.
3566 3572
3567 3573 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
3568 3574 bugs related to embedding and cleaned up that code. A fairly
3569 3575 important one was the impossibility to access the global namespace
3570 3576 through the embedded IPython (only local variables were visible).
3571 3577
3572 3578 2003-01-14 Fernando Perez <fperez@colorado.edu>
3573 3579
3574 3580 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
3575 3581 auto-calling to be a bit more conservative. Now it doesn't get
3576 3582 triggered if any of '!=()<>' are in the rest of the input line, to
3577 3583 allow comparing callables. Thanks to Alex for the heads up.
3578 3584
3579 3585 2003-01-07 Fernando Perez <fperez@colorado.edu>
3580 3586
3581 3587 * IPython/genutils.py (page): fixed estimation of the number of
3582 3588 lines in a string to be paged to simply count newlines. This
3583 3589 prevents over-guessing due to embedded escape sequences. A better
3584 3590 long-term solution would involve stripping out the control chars
3585 3591 for the count, but it's potentially so expensive I just don't
3586 3592 think it's worth doing.
3587 3593
3588 3594 2002-12-19 *** Released version 0.2.14pre50
3589 3595
3590 3596 2002-12-19 Fernando Perez <fperez@colorado.edu>
3591 3597
3592 3598 * tools/release (version): Changed release scripts to inform
3593 3599 Andrea and build a NEWS file with a list of recent changes.
3594 3600
3595 3601 * IPython/ColorANSI.py (__all__): changed terminal detection
3596 3602 code. Seems to work better for xterms without breaking
3597 3603 konsole. Will need more testing to determine if WinXP and Mac OSX
3598 3604 also work ok.
3599 3605
3600 3606 2002-12-18 *** Released version 0.2.14pre49
3601 3607
3602 3608 2002-12-18 Fernando Perez <fperez@colorado.edu>
3603 3609
3604 3610 * Docs: added new info about Mac OSX, from Andrea.
3605 3611
3606 3612 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
3607 3613 allow direct plotting of python strings whose format is the same
3608 3614 of gnuplot data files.
3609 3615
3610 3616 2002-12-16 Fernando Perez <fperez@colorado.edu>
3611 3617
3612 3618 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
3613 3619 value of exit question to be acknowledged.
3614 3620
3615 3621 2002-12-03 Fernando Perez <fperez@colorado.edu>
3616 3622
3617 3623 * IPython/ipmaker.py: removed generators, which had been added
3618 3624 by mistake in an earlier debugging run. This was causing trouble
3619 3625 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
3620 3626 for pointing this out.
3621 3627
3622 3628 2002-11-17 Fernando Perez <fperez@colorado.edu>
3623 3629
3624 3630 * Manual: updated the Gnuplot section.
3625 3631
3626 3632 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
3627 3633 a much better split of what goes in Runtime and what goes in
3628 3634 Interactive.
3629 3635
3630 3636 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
3631 3637 being imported from iplib.
3632 3638
3633 3639 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
3634 3640 for command-passing. Now the global Gnuplot instance is called
3635 3641 'gp' instead of 'g', which was really a far too fragile and
3636 3642 common name.
3637 3643
3638 3644 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
3639 3645 bounding boxes generated by Gnuplot for square plots.
3640 3646
3641 3647 * IPython/genutils.py (popkey): new function added. I should
3642 3648 suggest this on c.l.py as a dict method, it seems useful.
3643 3649
3644 3650 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
3645 3651 to transparently handle PostScript generation. MUCH better than
3646 3652 the previous plot_eps/replot_eps (which I removed now). The code
3647 3653 is also fairly clean and well documented now (including
3648 3654 docstrings).
3649 3655
3650 3656 2002-11-13 Fernando Perez <fperez@colorado.edu>
3651 3657
3652 3658 * IPython/Magic.py (Magic.magic_edit): fixed docstring
3653 3659 (inconsistent with options).
3654 3660
3655 3661 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
3656 3662 manually disabled, I don't know why. Fixed it.
3657 3663 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
3658 3664 eps output.
3659 3665
3660 3666 2002-11-12 Fernando Perez <fperez@colorado.edu>
3661 3667
3662 3668 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
3663 3669 don't propagate up to caller. Fixes crash reported by François
3664 3670 Pinard.
3665 3671
3666 3672 2002-11-09 Fernando Perez <fperez@colorado.edu>
3667 3673
3668 3674 * IPython/ipmaker.py (make_IPython): fixed problem with writing
3669 3675 history file for new users.
3670 3676 (make_IPython): fixed bug where initial install would leave the
3671 3677 user running in the .ipython dir.
3672 3678 (make_IPython): fixed bug where config dir .ipython would be
3673 3679 created regardless of the given -ipythondir option. Thanks to Cory
3674 3680 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
3675 3681
3676 3682 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
3677 3683 type confirmations. Will need to use it in all of IPython's code
3678 3684 consistently.
3679 3685
3680 3686 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
3681 3687 context to print 31 lines instead of the default 5. This will make
3682 3688 the crash reports extremely detailed in case the problem is in
3683 3689 libraries I don't have access to.
3684 3690
3685 3691 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
3686 3692 line of defense' code to still crash, but giving users fair
3687 3693 warning. I don't want internal errors to go unreported: if there's
3688 3694 an internal problem, IPython should crash and generate a full
3689 3695 report.
3690 3696
3691 3697 2002-11-08 Fernando Perez <fperez@colorado.edu>
3692 3698
3693 3699 * IPython/iplib.py (InteractiveShell.interact): added code to trap
3694 3700 otherwise uncaught exceptions which can appear if people set
3695 3701 sys.stdout to something badly broken. Thanks to a crash report
3696 3702 from henni-AT-mail.brainbot.com.
3697 3703
3698 3704 2002-11-04 Fernando Perez <fperez@colorado.edu>
3699 3705
3700 3706 * IPython/iplib.py (InteractiveShell.interact): added
3701 3707 __IPYTHON__active to the builtins. It's a flag which goes on when
3702 3708 the interaction starts and goes off again when it stops. This
3703 3709 allows embedding code to detect being inside IPython. Before this
3704 3710 was done via __IPYTHON__, but that only shows that an IPython
3705 3711 instance has been created.
3706 3712
3707 3713 * IPython/Magic.py (Magic.magic_env): I realized that in a
3708 3714 UserDict, instance.data holds the data as a normal dict. So I
3709 3715 modified @env to return os.environ.data instead of rebuilding a
3710 3716 dict by hand.
3711 3717
3712 3718 2002-11-02 Fernando Perez <fperez@colorado.edu>
3713 3719
3714 3720 * IPython/genutils.py (warn): changed so that level 1 prints no
3715 3721 header. Level 2 is now the default (with 'WARNING' header, as
3716 3722 before). I think I tracked all places where changes were needed in
3717 3723 IPython, but outside code using the old level numbering may have
3718 3724 broken.
3719 3725
3720 3726 * IPython/iplib.py (InteractiveShell.runcode): added this to
3721 3727 handle the tracebacks in SystemExit traps correctly. The previous
3722 3728 code (through interact) was printing more of the stack than
3723 3729 necessary, showing IPython internal code to the user.
3724 3730
3725 3731 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
3726 3732 default. Now that the default at the confirmation prompt is yes,
3727 3733 it's not so intrusive. François' argument that ipython sessions
3728 3734 tend to be complex enough not to lose them from an accidental C-d,
3729 3735 is a valid one.
3730 3736
3731 3737 * IPython/iplib.py (InteractiveShell.interact): added a
3732 3738 showtraceback() call to the SystemExit trap, and modified the exit
3733 3739 confirmation to have yes as the default.
3734 3740
3735 3741 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
3736 3742 this file. It's been gone from the code for a long time, this was
3737 3743 simply leftover junk.
3738 3744
3739 3745 2002-11-01 Fernando Perez <fperez@colorado.edu>
3740 3746
3741 3747 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
3742 3748 added. If set, IPython now traps EOF and asks for
3743 3749 confirmation. After a request by François Pinard.
3744 3750
3745 3751 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
3746 3752 of @abort, and with a new (better) mechanism for handling the
3747 3753 exceptions.
3748 3754
3749 3755 2002-10-27 Fernando Perez <fperez@colorado.edu>
3750 3756
3751 3757 * IPython/usage.py (__doc__): updated the --help information and
3752 3758 the ipythonrc file to indicate that -log generates
3753 3759 ./ipython.log. Also fixed the corresponding info in @logstart.
3754 3760 This and several other fixes in the manuals thanks to reports by
3755 3761 François Pinard <pinard-AT-iro.umontreal.ca>.
3756 3762
3757 3763 * IPython/Logger.py (Logger.switch_log): Fixed error message to
3758 3764 refer to @logstart (instead of @log, which doesn't exist).
3759 3765
3760 3766 * IPython/iplib.py (InteractiveShell._prefilter): fixed
3761 3767 AttributeError crash. Thanks to Christopher Armstrong
3762 3768 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
3763 3769 introduced recently (in 0.2.14pre37) with the fix to the eval
3764 3770 problem mentioned below.
3765 3771
3766 3772 2002-10-17 Fernando Perez <fperez@colorado.edu>
3767 3773
3768 3774 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
3769 3775 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
3770 3776
3771 3777 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
3772 3778 this function to fix a problem reported by Alex Schmolck. He saw
3773 3779 it with list comprehensions and generators, which were getting
3774 3780 called twice. The real problem was an 'eval' call in testing for
3775 3781 automagic which was evaluating the input line silently.
3776 3782
3777 3783 This is a potentially very nasty bug, if the input has side
3778 3784 effects which must not be repeated. The code is much cleaner now,
3779 3785 without any blanket 'except' left and with a regexp test for
3780 3786 actual function names.
3781 3787
3782 3788 But an eval remains, which I'm not fully comfortable with. I just
3783 3789 don't know how to find out if an expression could be a callable in
3784 3790 the user's namespace without doing an eval on the string. However
3785 3791 that string is now much more strictly checked so that no code
3786 3792 slips by, so the eval should only happen for things that can
3787 3793 really be only function/method names.
3788 3794
3789 3795 2002-10-15 Fernando Perez <fperez@colorado.edu>
3790 3796
3791 3797 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
3792 3798 OSX information to main manual, removed README_Mac_OSX file from
3793 3799 distribution. Also updated credits for recent additions.
3794 3800
3795 3801 2002-10-10 Fernando Perez <fperez@colorado.edu>
3796 3802
3797 3803 * README_Mac_OSX: Added a README for Mac OSX users for fixing
3798 3804 terminal-related issues. Many thanks to Andrea Riciputi
3799 3805 <andrea.riciputi-AT-libero.it> for writing it.
3800 3806
3801 3807 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
3802 3808 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3803 3809
3804 3810 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
3805 3811 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
3806 3812 <syver-en-AT-online.no> who both submitted patches for this problem.
3807 3813
3808 3814 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
3809 3815 global embedding to make sure that things don't overwrite user
3810 3816 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
3811 3817
3812 3818 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
3813 3819 compatibility. Thanks to Hayden Callow
3814 3820 <h.callow-AT-elec.canterbury.ac.nz>
3815 3821
3816 3822 2002-10-04 Fernando Perez <fperez@colorado.edu>
3817 3823
3818 3824 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
3819 3825 Gnuplot.File objects.
3820 3826
3821 3827 2002-07-23 Fernando Perez <fperez@colorado.edu>
3822 3828
3823 3829 * IPython/genutils.py (timing): Added timings() and timing() for
3824 3830 quick access to the most commonly needed data, the execution
3825 3831 times. Old timing() renamed to timings_out().
3826 3832
3827 3833 2002-07-18 Fernando Perez <fperez@colorado.edu>
3828 3834
3829 3835 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
3830 3836 bug with nested instances disrupting the parent's tab completion.
3831 3837
3832 3838 * IPython/iplib.py (all_completions): Added Alex Schmolck's
3833 3839 all_completions code to begin the emacs integration.
3834 3840
3835 3841 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
3836 3842 argument to allow titling individual arrays when plotting.
3837 3843
3838 3844 2002-07-15 Fernando Perez <fperez@colorado.edu>
3839 3845
3840 3846 * setup.py (make_shortcut): changed to retrieve the value of
3841 3847 'Program Files' directory from the registry (this value changes in
3842 3848 non-english versions of Windows). Thanks to Thomas Fanslau
3843 3849 <tfanslau-AT-gmx.de> for the report.
3844 3850
3845 3851 2002-07-10 Fernando Perez <fperez@colorado.edu>
3846 3852
3847 3853 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
3848 3854 a bug in pdb, which crashes if a line with only whitespace is
3849 3855 entered. Bug report submitted to sourceforge.
3850 3856
3851 3857 2002-07-09 Fernando Perez <fperez@colorado.edu>
3852 3858
3853 3859 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
3854 3860 reporting exceptions (it's a bug in inspect.py, I just set a
3855 3861 workaround).
3856 3862
3857 3863 2002-07-08 Fernando Perez <fperez@colorado.edu>
3858 3864
3859 3865 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
3860 3866 __IPYTHON__ in __builtins__ to show up in user_ns.
3861 3867
3862 3868 2002-07-03 Fernando Perez <fperez@colorado.edu>
3863 3869
3864 3870 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
3865 3871 name from @gp_set_instance to @gp_set_default.
3866 3872
3867 3873 * IPython/ipmaker.py (make_IPython): default editor value set to
3868 3874 '0' (a string), to match the rc file. Otherwise will crash when
3869 3875 .strip() is called on it.
3870 3876
3871 3877
3872 3878 2002-06-28 Fernando Perez <fperez@colorado.edu>
3873 3879
3874 3880 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
3875 3881 of files in current directory when a file is executed via
3876 3882 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
3877 3883
3878 3884 * setup.py (manfiles): fix for rpm builds, submitted by RA
3879 3885 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
3880 3886
3881 3887 * IPython/ipmaker.py (make_IPython): fixed lookup of default
3882 3888 editor when set to '0'. Problem was, '0' evaluates to True (it's a
3883 3889 string!). A. Schmolck caught this one.
3884 3890
3885 3891 2002-06-27 Fernando Perez <fperez@colorado.edu>
3886 3892
3887 3893 * IPython/ipmaker.py (make_IPython): fixed bug when running user
3888 3894 defined files at the cmd line. __name__ wasn't being set to
3889 3895 __main__.
3890 3896
3891 3897 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
3892 3898 regular lists and tuples besides Numeric arrays.
3893 3899
3894 3900 * IPython/Prompts.py (CachedOutput.__call__): Added output
3895 3901 supression for input ending with ';'. Similar to Mathematica and
3896 3902 Matlab. The _* vars and Out[] list are still updated, just like
3897 3903 Mathematica behaves.
3898 3904
3899 3905 2002-06-25 Fernando Perez <fperez@colorado.edu>
3900 3906
3901 3907 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
3902 3908 .ini extensions for profiels under Windows.
3903 3909
3904 3910 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
3905 3911 string form. Fix contributed by Alexander Schmolck
3906 3912 <a.schmolck-AT-gmx.net>
3907 3913
3908 3914 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
3909 3915 pre-configured Gnuplot instance.
3910 3916
3911 3917 2002-06-21 Fernando Perez <fperez@colorado.edu>
3912 3918
3913 3919 * IPython/numutils.py (exp_safe): new function, works around the
3914 3920 underflow problems in Numeric.
3915 3921 (log2): New fn. Safe log in base 2: returns exact integer answer
3916 3922 for exact integer powers of 2.
3917 3923
3918 3924 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
3919 3925 properly.
3920 3926
3921 3927 2002-06-20 Fernando Perez <fperez@colorado.edu>
3922 3928
3923 3929 * IPython/genutils.py (timing): new function like
3924 3930 Mathematica's. Similar to time_test, but returns more info.
3925 3931
3926 3932 2002-06-18 Fernando Perez <fperez@colorado.edu>
3927 3933
3928 3934 * IPython/Magic.py (Magic.magic_save): modified @save and @r
3929 3935 according to Mike Heeter's suggestions.
3930 3936
3931 3937 2002-06-16 Fernando Perez <fperez@colorado.edu>
3932 3938
3933 3939 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
3934 3940 system. GnuplotMagic is gone as a user-directory option. New files
3935 3941 make it easier to use all the gnuplot stuff both from external
3936 3942 programs as well as from IPython. Had to rewrite part of
3937 3943 hardcopy() b/c of a strange bug: often the ps files simply don't
3938 3944 get created, and require a repeat of the command (often several
3939 3945 times).
3940 3946
3941 3947 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
3942 3948 resolve output channel at call time, so that if sys.stderr has
3943 3949 been redirected by user this gets honored.
3944 3950
3945 3951 2002-06-13 Fernando Perez <fperez@colorado.edu>
3946 3952
3947 3953 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
3948 3954 IPShell. Kept a copy with the old names to avoid breaking people's
3949 3955 embedded code.
3950 3956
3951 3957 * IPython/ipython: simplified it to the bare minimum after
3952 3958 Holger's suggestions. Added info about how to use it in
3953 3959 PYTHONSTARTUP.
3954 3960
3955 3961 * IPython/Shell.py (IPythonShell): changed the options passing
3956 3962 from a string with funky %s replacements to a straight list. Maybe
3957 3963 a bit more typing, but it follows sys.argv conventions, so there's
3958 3964 less special-casing to remember.
3959 3965
3960 3966 2002-06-12 Fernando Perez <fperez@colorado.edu>
3961 3967
3962 3968 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
3963 3969 command. Thanks to a suggestion by Mike Heeter.
3964 3970 (Magic.magic_pfile): added behavior to look at filenames if given
3965 3971 arg is not a defined object.
3966 3972 (Magic.magic_save): New @save function to save code snippets. Also
3967 3973 a Mike Heeter idea.
3968 3974
3969 3975 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
3970 3976 plot() and replot(). Much more convenient now, especially for
3971 3977 interactive use.
3972 3978
3973 3979 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
3974 3980 filenames.
3975 3981
3976 3982 2002-06-02 Fernando Perez <fperez@colorado.edu>
3977 3983
3978 3984 * IPython/Struct.py (Struct.__init__): modified to admit
3979 3985 initialization via another struct.
3980 3986
3981 3987 * IPython/genutils.py (SystemExec.__init__): New stateful
3982 3988 interface to xsys and bq. Useful for writing system scripts.
3983 3989
3984 3990 2002-05-30 Fernando Perez <fperez@colorado.edu>
3985 3991
3986 3992 * MANIFEST.in: Changed docfile selection to exclude all the lyx
3987 3993 documents. This will make the user download smaller (it's getting
3988 3994 too big).
3989 3995
3990 3996 2002-05-29 Fernando Perez <fperez@colorado.edu>
3991 3997
3992 3998 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
3993 3999 fix problems with shelve and pickle. Seems to work, but I don't
3994 4000 know if corner cases break it. Thanks to Mike Heeter
3995 4001 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
3996 4002
3997 4003 2002-05-24 Fernando Perez <fperez@colorado.edu>
3998 4004
3999 4005 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
4000 4006 macros having broken.
4001 4007
4002 4008 2002-05-21 Fernando Perez <fperez@colorado.edu>
4003 4009
4004 4010 * IPython/Magic.py (Magic.magic_logstart): fixed recently
4005 4011 introduced logging bug: all history before logging started was
4006 4012 being written one character per line! This came from the redesign
4007 4013 of the input history as a special list which slices to strings,
4008 4014 not to lists.
4009 4015
4010 4016 2002-05-20 Fernando Perez <fperez@colorado.edu>
4011 4017
4012 4018 * IPython/Prompts.py (CachedOutput.__init__): made the color table
4013 4019 be an attribute of all classes in this module. The design of these
4014 4020 classes needs some serious overhauling.
4015 4021
4016 4022 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
4017 4023 which was ignoring '_' in option names.
4018 4024
4019 4025 * IPython/ultraTB.py (FormattedTB.__init__): Changed
4020 4026 'Verbose_novars' to 'Context' and made it the new default. It's a
4021 4027 bit more readable and also safer than verbose.
4022 4028
4023 4029 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
4024 4030 triple-quoted strings.
4025 4031
4026 4032 * IPython/OInspect.py (__all__): new module exposing the object
4027 4033 introspection facilities. Now the corresponding magics are dummy
4028 4034 wrappers around this. Having this module will make it much easier
4029 4035 to put these functions into our modified pdb.
4030 4036 This new object inspector system uses the new colorizing module,
4031 4037 so source code and other things are nicely syntax highlighted.
4032 4038
4033 4039 2002-05-18 Fernando Perez <fperez@colorado.edu>
4034 4040
4035 4041 * IPython/ColorANSI.py: Split the coloring tools into a separate
4036 4042 module so I can use them in other code easier (they were part of
4037 4043 ultraTB).
4038 4044
4039 4045 2002-05-17 Fernando Perez <fperez@colorado.edu>
4040 4046
4041 4047 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4042 4048 fixed it to set the global 'g' also to the called instance, as
4043 4049 long as 'g' was still a gnuplot instance (so it doesn't overwrite
4044 4050 user's 'g' variables).
4045 4051
4046 4052 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
4047 4053 global variables (aliases to _ih,_oh) so that users which expect
4048 4054 In[5] or Out[7] to work aren't unpleasantly surprised.
4049 4055 (InputList.__getslice__): new class to allow executing slices of
4050 4056 input history directly. Very simple class, complements the use of
4051 4057 macros.
4052 4058
4053 4059 2002-05-16 Fernando Perez <fperez@colorado.edu>
4054 4060
4055 4061 * setup.py (docdirbase): make doc directory be just doc/IPython
4056 4062 without version numbers, it will reduce clutter for users.
4057 4063
4058 4064 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
4059 4065 execfile call to prevent possible memory leak. See for details:
4060 4066 http://mail.python.org/pipermail/python-list/2002-February/088476.html
4061 4067
4062 4068 2002-05-15 Fernando Perez <fperez@colorado.edu>
4063 4069
4064 4070 * IPython/Magic.py (Magic.magic_psource): made the object
4065 4071 introspection names be more standard: pdoc, pdef, pfile and
4066 4072 psource. They all print/page their output, and it makes
4067 4073 remembering them easier. Kept old names for compatibility as
4068 4074 aliases.
4069 4075
4070 4076 2002-05-14 Fernando Perez <fperez@colorado.edu>
4071 4077
4072 4078 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
4073 4079 what the mouse problem was. The trick is to use gnuplot with temp
4074 4080 files and NOT with pipes (for data communication), because having
4075 4081 both pipes and the mouse on is bad news.
4076 4082
4077 4083 2002-05-13 Fernando Perez <fperez@colorado.edu>
4078 4084
4079 4085 * IPython/Magic.py (Magic._ofind): fixed namespace order search
4080 4086 bug. Information would be reported about builtins even when
4081 4087 user-defined functions overrode them.
4082 4088
4083 4089 2002-05-11 Fernando Perez <fperez@colorado.edu>
4084 4090
4085 4091 * IPython/__init__.py (__all__): removed FlexCompleter from
4086 4092 __all__ so that things don't fail in platforms without readline.
4087 4093
4088 4094 2002-05-10 Fernando Perez <fperez@colorado.edu>
4089 4095
4090 4096 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
4091 4097 it requires Numeric, effectively making Numeric a dependency for
4092 4098 IPython.
4093 4099
4094 4100 * Released 0.2.13
4095 4101
4096 4102 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
4097 4103 profiler interface. Now all the major options from the profiler
4098 4104 module are directly supported in IPython, both for single
4099 4105 expressions (@prun) and for full programs (@run -p).
4100 4106
4101 4107 2002-05-09 Fernando Perez <fperez@colorado.edu>
4102 4108
4103 4109 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
4104 4110 magic properly formatted for screen.
4105 4111
4106 4112 * setup.py (make_shortcut): Changed things to put pdf version in
4107 4113 doc/ instead of doc/manual (had to change lyxport a bit).
4108 4114
4109 4115 * IPython/Magic.py (Profile.string_stats): made profile runs go
4110 4116 through pager (they are long and a pager allows searching, saving,
4111 4117 etc.)
4112 4118
4113 4119 2002-05-08 Fernando Perez <fperez@colorado.edu>
4114 4120
4115 4121 * Released 0.2.12
4116 4122
4117 4123 2002-05-06 Fernando Perez <fperez@colorado.edu>
4118 4124
4119 4125 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
4120 4126 introduced); 'hist n1 n2' was broken.
4121 4127 (Magic.magic_pdb): added optional on/off arguments to @pdb
4122 4128 (Magic.magic_run): added option -i to @run, which executes code in
4123 4129 the IPython namespace instead of a clean one. Also added @irun as
4124 4130 an alias to @run -i.
4125 4131
4126 4132 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4127 4133 fixed (it didn't really do anything, the namespaces were wrong).
4128 4134
4129 4135 * IPython/Debugger.py (__init__): Added workaround for python 2.1
4130 4136
4131 4137 * IPython/__init__.py (__all__): Fixed package namespace, now
4132 4138 'import IPython' does give access to IPython.<all> as
4133 4139 expected. Also renamed __release__ to Release.
4134 4140
4135 4141 * IPython/Debugger.py (__license__): created new Pdb class which
4136 4142 functions like a drop-in for the normal pdb.Pdb but does NOT
4137 4143 import readline by default. This way it doesn't muck up IPython's
4138 4144 readline handling, and now tab-completion finally works in the
4139 4145 debugger -- sort of. It completes things globally visible, but the
4140 4146 completer doesn't track the stack as pdb walks it. That's a bit
4141 4147 tricky, and I'll have to implement it later.
4142 4148
4143 4149 2002-05-05 Fernando Perez <fperez@colorado.edu>
4144 4150
4145 4151 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
4146 4152 magic docstrings when printed via ? (explicit \'s were being
4147 4153 printed).
4148 4154
4149 4155 * IPython/ipmaker.py (make_IPython): fixed namespace
4150 4156 identification bug. Now variables loaded via logs or command-line
4151 4157 files are recognized in the interactive namespace by @who.
4152 4158
4153 4159 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
4154 4160 log replay system stemming from the string form of Structs.
4155 4161
4156 4162 * IPython/Magic.py (Macro.__init__): improved macros to properly
4157 4163 handle magic commands in them.
4158 4164 (Magic.magic_logstart): usernames are now expanded so 'logstart
4159 4165 ~/mylog' now works.
4160 4166
4161 4167 * IPython/iplib.py (complete): fixed bug where paths starting with
4162 4168 '/' would be completed as magic names.
4163 4169
4164 4170 2002-05-04 Fernando Perez <fperez@colorado.edu>
4165 4171
4166 4172 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
4167 4173 allow running full programs under the profiler's control.
4168 4174
4169 4175 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
4170 4176 mode to report exceptions verbosely but without formatting
4171 4177 variables. This addresses the issue of ipython 'freezing' (it's
4172 4178 not frozen, but caught in an expensive formatting loop) when huge
4173 4179 variables are in the context of an exception.
4174 4180 (VerboseTB.text): Added '--->' markers at line where exception was
4175 4181 triggered. Much clearer to read, especially in NoColor modes.
4176 4182
4177 4183 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
4178 4184 implemented in reverse when changing to the new parse_options().
4179 4185
4180 4186 2002-05-03 Fernando Perez <fperez@colorado.edu>
4181 4187
4182 4188 * IPython/Magic.py (Magic.parse_options): new function so that
4183 4189 magics can parse options easier.
4184 4190 (Magic.magic_prun): new function similar to profile.run(),
4185 4191 suggested by Chris Hart.
4186 4192 (Magic.magic_cd): fixed behavior so that it only changes if
4187 4193 directory actually is in history.
4188 4194
4189 4195 * IPython/usage.py (__doc__): added information about potential
4190 4196 slowness of Verbose exception mode when there are huge data
4191 4197 structures to be formatted (thanks to Archie Paulson).
4192 4198
4193 4199 * IPython/ipmaker.py (make_IPython): Changed default logging
4194 4200 (when simply called with -log) to use curr_dir/ipython.log in
4195 4201 rotate mode. Fixed crash which was occuring with -log before
4196 4202 (thanks to Jim Boyle).
4197 4203
4198 4204 2002-05-01 Fernando Perez <fperez@colorado.edu>
4199 4205
4200 4206 * Released 0.2.11 for these fixes (mainly the ultraTB one which
4201 4207 was nasty -- though somewhat of a corner case).
4202 4208
4203 4209 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
4204 4210 text (was a bug).
4205 4211
4206 4212 2002-04-30 Fernando Perez <fperez@colorado.edu>
4207 4213
4208 4214 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
4209 4215 a print after ^D or ^C from the user so that the In[] prompt
4210 4216 doesn't over-run the gnuplot one.
4211 4217
4212 4218 2002-04-29 Fernando Perez <fperez@colorado.edu>
4213 4219
4214 4220 * Released 0.2.10
4215 4221
4216 4222 * IPython/__release__.py (version): get date dynamically.
4217 4223
4218 4224 * Misc. documentation updates thanks to Arnd's comments. Also ran
4219 4225 a full spellcheck on the manual (hadn't been done in a while).
4220 4226
4221 4227 2002-04-27 Fernando Perez <fperez@colorado.edu>
4222 4228
4223 4229 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
4224 4230 starting a log in mid-session would reset the input history list.
4225 4231
4226 4232 2002-04-26 Fernando Perez <fperez@colorado.edu>
4227 4233
4228 4234 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
4229 4235 all files were being included in an update. Now anything in
4230 4236 UserConfig that matches [A-Za-z]*.py will go (this excludes
4231 4237 __init__.py)
4232 4238
4233 4239 2002-04-25 Fernando Perez <fperez@colorado.edu>
4234 4240
4235 4241 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
4236 4242 to __builtins__ so that any form of embedded or imported code can
4237 4243 test for being inside IPython.
4238 4244
4239 4245 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
4240 4246 changed to GnuplotMagic because it's now an importable module,
4241 4247 this makes the name follow that of the standard Gnuplot module.
4242 4248 GnuplotMagic can now be loaded at any time in mid-session.
4243 4249
4244 4250 2002-04-24 Fernando Perez <fperez@colorado.edu>
4245 4251
4246 4252 * IPython/numutils.py: removed SIUnits. It doesn't properly set
4247 4253 the globals (IPython has its own namespace) and the
4248 4254 PhysicalQuantity stuff is much better anyway.
4249 4255
4250 4256 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
4251 4257 embedding example to standard user directory for
4252 4258 distribution. Also put it in the manual.
4253 4259
4254 4260 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
4255 4261 instance as first argument (so it doesn't rely on some obscure
4256 4262 hidden global).
4257 4263
4258 4264 * IPython/UserConfig/ipythonrc.py: put () back in accepted
4259 4265 delimiters. While it prevents ().TAB from working, it allows
4260 4266 completions in open (... expressions. This is by far a more common
4261 4267 case.
4262 4268
4263 4269 2002-04-23 Fernando Perez <fperez@colorado.edu>
4264 4270
4265 4271 * IPython/Extensions/InterpreterPasteInput.py: new
4266 4272 syntax-processing module for pasting lines with >>> or ... at the
4267 4273 start.
4268 4274
4269 4275 * IPython/Extensions/PhysicalQ_Interactive.py
4270 4276 (PhysicalQuantityInteractive.__int__): fixed to work with either
4271 4277 Numeric or math.
4272 4278
4273 4279 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
4274 4280 provided profiles. Now we have:
4275 4281 -math -> math module as * and cmath with its own namespace.
4276 4282 -numeric -> Numeric as *, plus gnuplot & grace
4277 4283 -physics -> same as before
4278 4284
4279 4285 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
4280 4286 user-defined magics wouldn't be found by @magic if they were
4281 4287 defined as class methods. Also cleaned up the namespace search
4282 4288 logic and the string building (to use %s instead of many repeated
4283 4289 string adds).
4284 4290
4285 4291 * IPython/UserConfig/example-magic.py (magic_foo): updated example
4286 4292 of user-defined magics to operate with class methods (cleaner, in
4287 4293 line with the gnuplot code).
4288 4294
4289 4295 2002-04-22 Fernando Perez <fperez@colorado.edu>
4290 4296
4291 4297 * setup.py: updated dependency list so that manual is updated when
4292 4298 all included files change.
4293 4299
4294 4300 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
4295 4301 the delimiter removal option (the fix is ugly right now).
4296 4302
4297 4303 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
4298 4304 all of the math profile (quicker loading, no conflict between
4299 4305 g-9.8 and g-gnuplot).
4300 4306
4301 4307 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
4302 4308 name of post-mortem files to IPython_crash_report.txt.
4303 4309
4304 4310 * Cleanup/update of the docs. Added all the new readline info and
4305 4311 formatted all lists as 'real lists'.
4306 4312
4307 4313 * IPython/ipmaker.py (make_IPython): removed now-obsolete
4308 4314 tab-completion options, since the full readline parse_and_bind is
4309 4315 now accessible.
4310 4316
4311 4317 * IPython/iplib.py (InteractiveShell.init_readline): Changed
4312 4318 handling of readline options. Now users can specify any string to
4313 4319 be passed to parse_and_bind(), as well as the delimiters to be
4314 4320 removed.
4315 4321 (InteractiveShell.__init__): Added __name__ to the global
4316 4322 namespace so that things like Itpl which rely on its existence
4317 4323 don't crash.
4318 4324 (InteractiveShell._prefilter): Defined the default with a _ so
4319 4325 that prefilter() is easier to override, while the default one
4320 4326 remains available.
4321 4327
4322 4328 2002-04-18 Fernando Perez <fperez@colorado.edu>
4323 4329
4324 4330 * Added information about pdb in the docs.
4325 4331
4326 4332 2002-04-17 Fernando Perez <fperez@colorado.edu>
4327 4333
4328 4334 * IPython/ipmaker.py (make_IPython): added rc_override option to
4329 4335 allow passing config options at creation time which may override
4330 4336 anything set in the config files or command line. This is
4331 4337 particularly useful for configuring embedded instances.
4332 4338
4333 4339 2002-04-15 Fernando Perez <fperez@colorado.edu>
4334 4340
4335 4341 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
4336 4342 crash embedded instances because of the input cache falling out of
4337 4343 sync with the output counter.
4338 4344
4339 4345 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
4340 4346 mode which calls pdb after an uncaught exception in IPython itself.
4341 4347
4342 4348 2002-04-14 Fernando Perez <fperez@colorado.edu>
4343 4349
4344 4350 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
4345 4351 readline, fix it back after each call.
4346 4352
4347 4353 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
4348 4354 method to force all access via __call__(), which guarantees that
4349 4355 traceback references are properly deleted.
4350 4356
4351 4357 * IPython/Prompts.py (CachedOutput._display): minor fixes to
4352 4358 improve printing when pprint is in use.
4353 4359
4354 4360 2002-04-13 Fernando Perez <fperez@colorado.edu>
4355 4361
4356 4362 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
4357 4363 exceptions aren't caught anymore. If the user triggers one, he
4358 4364 should know why he's doing it and it should go all the way up,
4359 4365 just like any other exception. So now @abort will fully kill the
4360 4366 embedded interpreter and the embedding code (unless that happens
4361 4367 to catch SystemExit).
4362 4368
4363 4369 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
4364 4370 and a debugger() method to invoke the interactive pdb debugger
4365 4371 after printing exception information. Also added the corresponding
4366 4372 -pdb option and @pdb magic to control this feature, and updated
4367 4373 the docs. After a suggestion from Christopher Hart
4368 4374 (hart-AT-caltech.edu).
4369 4375
4370 4376 2002-04-12 Fernando Perez <fperez@colorado.edu>
4371 4377
4372 4378 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
4373 4379 the exception handlers defined by the user (not the CrashHandler)
4374 4380 so that user exceptions don't trigger an ipython bug report.
4375 4381
4376 4382 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
4377 4383 configurable (it should have always been so).
4378 4384
4379 4385 2002-03-26 Fernando Perez <fperez@colorado.edu>
4380 4386
4381 4387 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
4382 4388 and there to fix embedding namespace issues. This should all be
4383 4389 done in a more elegant way.
4384 4390
4385 4391 2002-03-25 Fernando Perez <fperez@colorado.edu>
4386 4392
4387 4393 * IPython/genutils.py (get_home_dir): Try to make it work under
4388 4394 win9x also.
4389 4395
4390 4396 2002-03-20 Fernando Perez <fperez@colorado.edu>
4391 4397
4392 4398 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
4393 4399 sys.displayhook untouched upon __init__.
4394 4400
4395 4401 2002-03-19 Fernando Perez <fperez@colorado.edu>
4396 4402
4397 4403 * Released 0.2.9 (for embedding bug, basically).
4398 4404
4399 4405 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
4400 4406 exceptions so that enclosing shell's state can be restored.
4401 4407
4402 4408 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
4403 4409 naming conventions in the .ipython/ dir.
4404 4410
4405 4411 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
4406 4412 from delimiters list so filenames with - in them get expanded.
4407 4413
4408 4414 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
4409 4415 sys.displayhook not being properly restored after an embedded call.
4410 4416
4411 4417 2002-03-18 Fernando Perez <fperez@colorado.edu>
4412 4418
4413 4419 * Released 0.2.8
4414 4420
4415 4421 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
4416 4422 some files weren't being included in a -upgrade.
4417 4423 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
4418 4424 on' so that the first tab completes.
4419 4425 (InteractiveShell.handle_magic): fixed bug with spaces around
4420 4426 quotes breaking many magic commands.
4421 4427
4422 4428 * setup.py: added note about ignoring the syntax error messages at
4423 4429 installation.
4424 4430
4425 4431 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
4426 4432 streamlining the gnuplot interface, now there's only one magic @gp.
4427 4433
4428 4434 2002-03-17 Fernando Perez <fperez@colorado.edu>
4429 4435
4430 4436 * IPython/UserConfig/magic_gnuplot.py: new name for the
4431 4437 example-magic_pm.py file. Much enhanced system, now with a shell
4432 4438 for communicating directly with gnuplot, one command at a time.
4433 4439
4434 4440 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
4435 4441 setting __name__=='__main__'.
4436 4442
4437 4443 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
4438 4444 mini-shell for accessing gnuplot from inside ipython. Should
4439 4445 extend it later for grace access too. Inspired by Arnd's
4440 4446 suggestion.
4441 4447
4442 4448 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
4443 4449 calling magic functions with () in their arguments. Thanks to Arnd
4444 4450 Baecker for pointing this to me.
4445 4451
4446 4452 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
4447 4453 infinitely for integer or complex arrays (only worked with floats).
4448 4454
4449 4455 2002-03-16 Fernando Perez <fperez@colorado.edu>
4450 4456
4451 4457 * setup.py: Merged setup and setup_windows into a single script
4452 4458 which properly handles things for windows users.
4453 4459
4454 4460 2002-03-15 Fernando Perez <fperez@colorado.edu>
4455 4461
4456 4462 * Big change to the manual: now the magics are all automatically
4457 4463 documented. This information is generated from their docstrings
4458 4464 and put in a latex file included by the manual lyx file. This way
4459 4465 we get always up to date information for the magics. The manual
4460 4466 now also has proper version information, also auto-synced.
4461 4467
4462 4468 For this to work, an undocumented --magic_docstrings option was added.
4463 4469
4464 4470 2002-03-13 Fernando Perez <fperez@colorado.edu>
4465 4471
4466 4472 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
4467 4473 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
4468 4474
4469 4475 2002-03-12 Fernando Perez <fperez@colorado.edu>
4470 4476
4471 4477 * IPython/ultraTB.py (TermColors): changed color escapes again to
4472 4478 fix the (old, reintroduced) line-wrapping bug. Basically, if
4473 4479 \001..\002 aren't given in the color escapes, lines get wrapped
4474 4480 weirdly. But giving those screws up old xterms and emacs terms. So
4475 4481 I added some logic for emacs terms to be ok, but I can't identify old
4476 4482 xterms separately ($TERM=='xterm' for many terminals, like konsole).
4477 4483
4478 4484 2002-03-10 Fernando Perez <fperez@colorado.edu>
4479 4485
4480 4486 * IPython/usage.py (__doc__): Various documentation cleanups and
4481 4487 updates, both in usage docstrings and in the manual.
4482 4488
4483 4489 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
4484 4490 handling of caching. Set minimum acceptabe value for having a
4485 4491 cache at 20 values.
4486 4492
4487 4493 * IPython/iplib.py (InteractiveShell.user_setup): moved the
4488 4494 install_first_time function to a method, renamed it and added an
4489 4495 'upgrade' mode. Now people can update their config directory with
4490 4496 a simple command line switch (-upgrade, also new).
4491 4497
4492 4498 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
4493 4499 @file (convenient for automagic users under Python >= 2.2).
4494 4500 Removed @files (it seemed more like a plural than an abbrev. of
4495 4501 'file show').
4496 4502
4497 4503 * IPython/iplib.py (install_first_time): Fixed crash if there were
4498 4504 backup files ('~') in .ipython/ install directory.
4499 4505
4500 4506 * IPython/ipmaker.py (make_IPython): fixes for new prompt
4501 4507 system. Things look fine, but these changes are fairly
4502 4508 intrusive. Test them for a few days.
4503 4509
4504 4510 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
4505 4511 the prompts system. Now all in/out prompt strings are user
4506 4512 controllable. This is particularly useful for embedding, as one
4507 4513 can tag embedded instances with particular prompts.
4508 4514
4509 4515 Also removed global use of sys.ps1/2, which now allows nested
4510 4516 embeddings without any problems. Added command-line options for
4511 4517 the prompt strings.
4512 4518
4513 4519 2002-03-08 Fernando Perez <fperez@colorado.edu>
4514 4520
4515 4521 * IPython/UserConfig/example-embed-short.py (ipshell): added
4516 4522 example file with the bare minimum code for embedding.
4517 4523
4518 4524 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
4519 4525 functionality for the embeddable shell to be activated/deactivated
4520 4526 either globally or at each call.
4521 4527
4522 4528 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
4523 4529 rewriting the prompt with '--->' for auto-inputs with proper
4524 4530 coloring. Now the previous UGLY hack in handle_auto() is gone, and
4525 4531 this is handled by the prompts class itself, as it should.
4526 4532
4527 4533 2002-03-05 Fernando Perez <fperez@colorado.edu>
4528 4534
4529 4535 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
4530 4536 @logstart to avoid name clashes with the math log function.
4531 4537
4532 4538 * Big updates to X/Emacs section of the manual.
4533 4539
4534 4540 * Removed ipython_emacs. Milan explained to me how to pass
4535 4541 arguments to ipython through Emacs. Some day I'm going to end up
4536 4542 learning some lisp...
4537 4543
4538 4544 2002-03-04 Fernando Perez <fperez@colorado.edu>
4539 4545
4540 4546 * IPython/ipython_emacs: Created script to be used as the
4541 4547 py-python-command Emacs variable so we can pass IPython
4542 4548 parameters. I can't figure out how to tell Emacs directly to pass
4543 4549 parameters to IPython, so a dummy shell script will do it.
4544 4550
4545 4551 Other enhancements made for things to work better under Emacs'
4546 4552 various types of terminals. Many thanks to Milan Zamazal
4547 4553 <pdm-AT-zamazal.org> for all the suggestions and pointers.
4548 4554
4549 4555 2002-03-01 Fernando Perez <fperez@colorado.edu>
4550 4556
4551 4557 * IPython/ipmaker.py (make_IPython): added a --readline! option so
4552 4558 that loading of readline is now optional. This gives better
4553 4559 control to emacs users.
4554 4560
4555 4561 * IPython/ultraTB.py (__date__): Modified color escape sequences
4556 4562 and now things work fine under xterm and in Emacs' term buffers
4557 4563 (though not shell ones). Well, in emacs you get colors, but all
4558 4564 seem to be 'light' colors (no difference between dark and light
4559 4565 ones). But the garbage chars are gone, and also in xterms. It
4560 4566 seems that now I'm using 'cleaner' ansi sequences.
4561 4567
4562 4568 2002-02-21 Fernando Perez <fperez@colorado.edu>
4563 4569
4564 4570 * Released 0.2.7 (mainly to publish the scoping fix).
4565 4571
4566 4572 * IPython/Logger.py (Logger.logstate): added. A corresponding
4567 4573 @logstate magic was created.
4568 4574
4569 4575 * IPython/Magic.py: fixed nested scoping problem under Python
4570 4576 2.1.x (automagic wasn't working).
4571 4577
4572 4578 2002-02-20 Fernando Perez <fperez@colorado.edu>
4573 4579
4574 4580 * Released 0.2.6.
4575 4581
4576 4582 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
4577 4583 option so that logs can come out without any headers at all.
4578 4584
4579 4585 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
4580 4586 SciPy.
4581 4587
4582 4588 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
4583 4589 that embedded IPython calls don't require vars() to be explicitly
4584 4590 passed. Now they are extracted from the caller's frame (code
4585 4591 snatched from Eric Jones' weave). Added better documentation to
4586 4592 the section on embedding and the example file.
4587 4593
4588 4594 * IPython/genutils.py (page): Changed so that under emacs, it just
4589 4595 prints the string. You can then page up and down in the emacs
4590 4596 buffer itself. This is how the builtin help() works.
4591 4597
4592 4598 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
4593 4599 macro scoping: macros need to be executed in the user's namespace
4594 4600 to work as if they had been typed by the user.
4595 4601
4596 4602 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
4597 4603 execute automatically (no need to type 'exec...'). They then
4598 4604 behave like 'true macros'. The printing system was also modified
4599 4605 for this to work.
4600 4606
4601 4607 2002-02-19 Fernando Perez <fperez@colorado.edu>
4602 4608
4603 4609 * IPython/genutils.py (page_file): new function for paging files
4604 4610 in an OS-independent way. Also necessary for file viewing to work
4605 4611 well inside Emacs buffers.
4606 4612 (page): Added checks for being in an emacs buffer.
4607 4613 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
4608 4614 same bug in iplib.
4609 4615
4610 4616 2002-02-18 Fernando Perez <fperez@colorado.edu>
4611 4617
4612 4618 * IPython/iplib.py (InteractiveShell.init_readline): modified use
4613 4619 of readline so that IPython can work inside an Emacs buffer.
4614 4620
4615 4621 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
4616 4622 method signatures (they weren't really bugs, but it looks cleaner
4617 4623 and keeps PyChecker happy).
4618 4624
4619 4625 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
4620 4626 for implementing various user-defined hooks. Currently only
4621 4627 display is done.
4622 4628
4623 4629 * IPython/Prompts.py (CachedOutput._display): changed display
4624 4630 functions so that they can be dynamically changed by users easily.
4625 4631
4626 4632 * IPython/Extensions/numeric_formats.py (num_display): added an
4627 4633 extension for printing NumPy arrays in flexible manners. It
4628 4634 doesn't do anything yet, but all the structure is in
4629 4635 place. Ultimately the plan is to implement output format control
4630 4636 like in Octave.
4631 4637
4632 4638 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
4633 4639 methods are found at run-time by all the automatic machinery.
4634 4640
4635 4641 2002-02-17 Fernando Perez <fperez@colorado.edu>
4636 4642
4637 4643 * setup_Windows.py (make_shortcut): documented. Cleaned up the
4638 4644 whole file a little.
4639 4645
4640 4646 * ToDo: closed this document. Now there's a new_design.lyx
4641 4647 document for all new ideas. Added making a pdf of it for the
4642 4648 end-user distro.
4643 4649
4644 4650 * IPython/Logger.py (Logger.switch_log): Created this to replace
4645 4651 logon() and logoff(). It also fixes a nasty crash reported by
4646 4652 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
4647 4653
4648 4654 * IPython/iplib.py (complete): got auto-completion to work with
4649 4655 automagic (I had wanted this for a long time).
4650 4656
4651 4657 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
4652 4658 to @file, since file() is now a builtin and clashes with automagic
4653 4659 for @file.
4654 4660
4655 4661 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
4656 4662 of this was previously in iplib, which had grown to more than 2000
4657 4663 lines, way too long. No new functionality, but it makes managing
4658 4664 the code a bit easier.
4659 4665
4660 4666 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
4661 4667 information to crash reports.
4662 4668
4663 4669 2002-02-12 Fernando Perez <fperez@colorado.edu>
4664 4670
4665 4671 * Released 0.2.5.
4666 4672
4667 4673 2002-02-11 Fernando Perez <fperez@colorado.edu>
4668 4674
4669 4675 * Wrote a relatively complete Windows installer. It puts
4670 4676 everything in place, creates Start Menu entries and fixes the
4671 4677 color issues. Nothing fancy, but it works.
4672 4678
4673 4679 2002-02-10 Fernando Perez <fperez@colorado.edu>
4674 4680
4675 4681 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
4676 4682 os.path.expanduser() call so that we can type @run ~/myfile.py and
4677 4683 have thigs work as expected.
4678 4684
4679 4685 * IPython/genutils.py (page): fixed exception handling so things
4680 4686 work both in Unix and Windows correctly. Quitting a pager triggers
4681 4687 an IOError/broken pipe in Unix, and in windows not finding a pager
4682 4688 is also an IOError, so I had to actually look at the return value
4683 4689 of the exception, not just the exception itself. Should be ok now.
4684 4690
4685 4691 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
4686 4692 modified to allow case-insensitive color scheme changes.
4687 4693
4688 4694 2002-02-09 Fernando Perez <fperez@colorado.edu>
4689 4695
4690 4696 * IPython/genutils.py (native_line_ends): new function to leave
4691 4697 user config files with os-native line-endings.
4692 4698
4693 4699 * README and manual updates.
4694 4700
4695 4701 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
4696 4702 instead of StringType to catch Unicode strings.
4697 4703
4698 4704 * IPython/genutils.py (filefind): fixed bug for paths with
4699 4705 embedded spaces (very common in Windows).
4700 4706
4701 4707 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
4702 4708 files under Windows, so that they get automatically associated
4703 4709 with a text editor. Windows makes it a pain to handle
4704 4710 extension-less files.
4705 4711
4706 4712 * IPython/iplib.py (InteractiveShell.init_readline): Made the
4707 4713 warning about readline only occur for Posix. In Windows there's no
4708 4714 way to get readline, so why bother with the warning.
4709 4715
4710 4716 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
4711 4717 for __str__ instead of dir(self), since dir() changed in 2.2.
4712 4718
4713 4719 * Ported to Windows! Tested on XP, I suspect it should work fine
4714 4720 on NT/2000, but I don't think it will work on 98 et al. That
4715 4721 series of Windows is such a piece of junk anyway that I won't try
4716 4722 porting it there. The XP port was straightforward, showed a few
4717 4723 bugs here and there (fixed all), in particular some string
4718 4724 handling stuff which required considering Unicode strings (which
4719 4725 Windows uses). This is good, but hasn't been too tested :) No
4720 4726 fancy installer yet, I'll put a note in the manual so people at
4721 4727 least make manually a shortcut.
4722 4728
4723 4729 * IPython/iplib.py (Magic.magic_colors): Unified the color options
4724 4730 into a single one, "colors". This now controls both prompt and
4725 4731 exception color schemes, and can be changed both at startup
4726 4732 (either via command-line switches or via ipythonrc files) and at
4727 4733 runtime, with @colors.
4728 4734 (Magic.magic_run): renamed @prun to @run and removed the old
4729 4735 @run. The two were too similar to warrant keeping both.
4730 4736
4731 4737 2002-02-03 Fernando Perez <fperez@colorado.edu>
4732 4738
4733 4739 * IPython/iplib.py (install_first_time): Added comment on how to
4734 4740 configure the color options for first-time users. Put a <return>
4735 4741 request at the end so that small-terminal users get a chance to
4736 4742 read the startup info.
4737 4743
4738 4744 2002-01-23 Fernando Perez <fperez@colorado.edu>
4739 4745
4740 4746 * IPython/iplib.py (CachedOutput.update): Changed output memory
4741 4747 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
4742 4748 input history we still use _i. Did this b/c these variable are
4743 4749 very commonly used in interactive work, so the less we need to
4744 4750 type the better off we are.
4745 4751 (Magic.magic_prun): updated @prun to better handle the namespaces
4746 4752 the file will run in, including a fix for __name__ not being set
4747 4753 before.
4748 4754
4749 4755 2002-01-20 Fernando Perez <fperez@colorado.edu>
4750 4756
4751 4757 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
4752 4758 extra garbage for Python 2.2. Need to look more carefully into
4753 4759 this later.
4754 4760
4755 4761 2002-01-19 Fernando Perez <fperez@colorado.edu>
4756 4762
4757 4763 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
4758 4764 display SyntaxError exceptions properly formatted when they occur
4759 4765 (they can be triggered by imported code).
4760 4766
4761 4767 2002-01-18 Fernando Perez <fperez@colorado.edu>
4762 4768
4763 4769 * IPython/iplib.py (InteractiveShell.safe_execfile): now
4764 4770 SyntaxError exceptions are reported nicely formatted, instead of
4765 4771 spitting out only offset information as before.
4766 4772 (Magic.magic_prun): Added the @prun function for executing
4767 4773 programs with command line args inside IPython.
4768 4774
4769 4775 2002-01-16 Fernando Perez <fperez@colorado.edu>
4770 4776
4771 4777 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
4772 4778 to *not* include the last item given in a range. This brings their
4773 4779 behavior in line with Python's slicing:
4774 4780 a[n1:n2] -> a[n1]...a[n2-1]
4775 4781 It may be a bit less convenient, but I prefer to stick to Python's
4776 4782 conventions *everywhere*, so users never have to wonder.
4777 4783 (Magic.magic_macro): Added @macro function to ease the creation of
4778 4784 macros.
4779 4785
4780 4786 2002-01-05 Fernando Perez <fperez@colorado.edu>
4781 4787
4782 4788 * Released 0.2.4.
4783 4789
4784 4790 * IPython/iplib.py (Magic.magic_pdef):
4785 4791 (InteractiveShell.safe_execfile): report magic lines and error
4786 4792 lines without line numbers so one can easily copy/paste them for
4787 4793 re-execution.
4788 4794
4789 4795 * Updated manual with recent changes.
4790 4796
4791 4797 * IPython/iplib.py (Magic.magic_oinfo): added constructor
4792 4798 docstring printing when class? is called. Very handy for knowing
4793 4799 how to create class instances (as long as __init__ is well
4794 4800 documented, of course :)
4795 4801 (Magic.magic_doc): print both class and constructor docstrings.
4796 4802 (Magic.magic_pdef): give constructor info if passed a class and
4797 4803 __call__ info for callable object instances.
4798 4804
4799 4805 2002-01-04 Fernando Perez <fperez@colorado.edu>
4800 4806
4801 4807 * Made deep_reload() off by default. It doesn't always work
4802 4808 exactly as intended, so it's probably safer to have it off. It's
4803 4809 still available as dreload() anyway, so nothing is lost.
4804 4810
4805 4811 2002-01-02 Fernando Perez <fperez@colorado.edu>
4806 4812
4807 4813 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
4808 4814 so I wanted an updated release).
4809 4815
4810 4816 2001-12-27 Fernando Perez <fperez@colorado.edu>
4811 4817
4812 4818 * IPython/iplib.py (InteractiveShell.interact): Added the original
4813 4819 code from 'code.py' for this module in order to change the
4814 4820 handling of a KeyboardInterrupt. This was necessary b/c otherwise
4815 4821 the history cache would break when the user hit Ctrl-C, and
4816 4822 interact() offers no way to add any hooks to it.
4817 4823
4818 4824 2001-12-23 Fernando Perez <fperez@colorado.edu>
4819 4825
4820 4826 * setup.py: added check for 'MANIFEST' before trying to remove
4821 4827 it. Thanks to Sean Reifschneider.
4822 4828
4823 4829 2001-12-22 Fernando Perez <fperez@colorado.edu>
4824 4830
4825 4831 * Released 0.2.2.
4826 4832
4827 4833 * Finished (reasonably) writing the manual. Later will add the
4828 4834 python-standard navigation stylesheets, but for the time being
4829 4835 it's fairly complete. Distribution will include html and pdf
4830 4836 versions.
4831 4837
4832 4838 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
4833 4839 (MayaVi author).
4834 4840
4835 4841 2001-12-21 Fernando Perez <fperez@colorado.edu>
4836 4842
4837 4843 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
4838 4844 good public release, I think (with the manual and the distutils
4839 4845 installer). The manual can use some work, but that can go
4840 4846 slowly. Otherwise I think it's quite nice for end users. Next
4841 4847 summer, rewrite the guts of it...
4842 4848
4843 4849 * Changed format of ipythonrc files to use whitespace as the
4844 4850 separator instead of an explicit '='. Cleaner.
4845 4851
4846 4852 2001-12-20 Fernando Perez <fperez@colorado.edu>
4847 4853
4848 4854 * Started a manual in LyX. For now it's just a quick merge of the
4849 4855 various internal docstrings and READMEs. Later it may grow into a
4850 4856 nice, full-blown manual.
4851 4857
4852 4858 * Set up a distutils based installer. Installation should now be
4853 4859 trivially simple for end-users.
4854 4860
4855 4861 2001-12-11 Fernando Perez <fperez@colorado.edu>
4856 4862
4857 4863 * Released 0.2.0. First public release, announced it at
4858 4864 comp.lang.python. From now on, just bugfixes...
4859 4865
4860 4866 * Went through all the files, set copyright/license notices and
4861 4867 cleaned up things. Ready for release.
4862 4868
4863 4869 2001-12-10 Fernando Perez <fperez@colorado.edu>
4864 4870
4865 4871 * Changed the first-time installer not to use tarfiles. It's more
4866 4872 robust now and less unix-dependent. Also makes it easier for
4867 4873 people to later upgrade versions.
4868 4874
4869 4875 * Changed @exit to @abort to reflect the fact that it's pretty
4870 4876 brutal (a sys.exit()). The difference between @abort and Ctrl-D
4871 4877 becomes significant only when IPyhton is embedded: in that case,
4872 4878 C-D closes IPython only, but @abort kills the enclosing program
4873 4879 too (unless it had called IPython inside a try catching
4874 4880 SystemExit).
4875 4881
4876 4882 * Created Shell module which exposes the actuall IPython Shell
4877 4883 classes, currently the normal and the embeddable one. This at
4878 4884 least offers a stable interface we won't need to change when
4879 4885 (later) the internals are rewritten. That rewrite will be confined
4880 4886 to iplib and ipmaker, but the Shell interface should remain as is.
4881 4887
4882 4888 * Added embed module which offers an embeddable IPShell object,
4883 4889 useful to fire up IPython *inside* a running program. Great for
4884 4890 debugging or dynamical data analysis.
4885 4891
4886 4892 2001-12-08 Fernando Perez <fperez@colorado.edu>
4887 4893
4888 4894 * Fixed small bug preventing seeing info from methods of defined
4889 4895 objects (incorrect namespace in _ofind()).
4890 4896
4891 4897 * Documentation cleanup. Moved the main usage docstrings to a
4892 4898 separate file, usage.py (cleaner to maintain, and hopefully in the
4893 4899 future some perlpod-like way of producing interactive, man and
4894 4900 html docs out of it will be found).
4895 4901
4896 4902 * Added @profile to see your profile at any time.
4897 4903
4898 4904 * Added @p as an alias for 'print'. It's especially convenient if
4899 4905 using automagic ('p x' prints x).
4900 4906
4901 4907 * Small cleanups and fixes after a pychecker run.
4902 4908
4903 4909 * Changed the @cd command to handle @cd - and @cd -<n> for
4904 4910 visiting any directory in _dh.
4905 4911
4906 4912 * Introduced _dh, a history of visited directories. @dhist prints
4907 4913 it out with numbers.
4908 4914
4909 4915 2001-12-07 Fernando Perez <fperez@colorado.edu>
4910 4916
4911 4917 * Released 0.1.22
4912 4918
4913 4919 * Made initialization a bit more robust against invalid color
4914 4920 options in user input (exit, not traceback-crash).
4915 4921
4916 4922 * Changed the bug crash reporter to write the report only in the
4917 4923 user's .ipython directory. That way IPython won't litter people's
4918 4924 hard disks with crash files all over the place. Also print on
4919 4925 screen the necessary mail command.
4920 4926
4921 4927 * With the new ultraTB, implemented LightBG color scheme for light
4922 4928 background terminals. A lot of people like white backgrounds, so I
4923 4929 guess we should at least give them something readable.
4924 4930
4925 4931 2001-12-06 Fernando Perez <fperez@colorado.edu>
4926 4932
4927 4933 * Modified the structure of ultraTB. Now there's a proper class
4928 4934 for tables of color schemes which allow adding schemes easily and
4929 4935 switching the active scheme without creating a new instance every
4930 4936 time (which was ridiculous). The syntax for creating new schemes
4931 4937 is also cleaner. I think ultraTB is finally done, with a clean
4932 4938 class structure. Names are also much cleaner (now there's proper
4933 4939 color tables, no need for every variable to also have 'color' in
4934 4940 its name).
4935 4941
4936 4942 * Broke down genutils into separate files. Now genutils only
4937 4943 contains utility functions, and classes have been moved to their
4938 4944 own files (they had enough independent functionality to warrant
4939 4945 it): ConfigLoader, OutputTrap, Struct.
4940 4946
4941 4947 2001-12-05 Fernando Perez <fperez@colorado.edu>
4942 4948
4943 4949 * IPython turns 21! Released version 0.1.21, as a candidate for
4944 4950 public consumption. If all goes well, release in a few days.
4945 4951
4946 4952 * Fixed path bug (files in Extensions/ directory wouldn't be found
4947 4953 unless IPython/ was explicitly in sys.path).
4948 4954
4949 4955 * Extended the FlexCompleter class as MagicCompleter to allow
4950 4956 completion of @-starting lines.
4951 4957
4952 4958 * Created __release__.py file as a central repository for release
4953 4959 info that other files can read from.
4954 4960
4955 4961 * Fixed small bug in logging: when logging was turned on in
4956 4962 mid-session, old lines with special meanings (!@?) were being
4957 4963 logged without the prepended comment, which is necessary since
4958 4964 they are not truly valid python syntax. This should make session
4959 4965 restores produce less errors.
4960 4966
4961 4967 * The namespace cleanup forced me to make a FlexCompleter class
4962 4968 which is nothing but a ripoff of rlcompleter, but with selectable
4963 4969 namespace (rlcompleter only works in __main__.__dict__). I'll try
4964 4970 to submit a note to the authors to see if this change can be
4965 4971 incorporated in future rlcompleter releases (Dec.6: done)
4966 4972
4967 4973 * More fixes to namespace handling. It was a mess! Now all
4968 4974 explicit references to __main__.__dict__ are gone (except when
4969 4975 really needed) and everything is handled through the namespace
4970 4976 dicts in the IPython instance. We seem to be getting somewhere
4971 4977 with this, finally...
4972 4978
4973 4979 * Small documentation updates.
4974 4980
4975 4981 * Created the Extensions directory under IPython (with an
4976 4982 __init__.py). Put the PhysicalQ stuff there. This directory should
4977 4983 be used for all special-purpose extensions.
4978 4984
4979 4985 * File renaming:
4980 4986 ipythonlib --> ipmaker
4981 4987 ipplib --> iplib
4982 4988 This makes a bit more sense in terms of what these files actually do.
4983 4989
4984 4990 * Moved all the classes and functions in ipythonlib to ipplib, so
4985 4991 now ipythonlib only has make_IPython(). This will ease up its
4986 4992 splitting in smaller functional chunks later.
4987 4993
4988 4994 * Cleaned up (done, I think) output of @whos. Better column
4989 4995 formatting, and now shows str(var) for as much as it can, which is
4990 4996 typically what one gets with a 'print var'.
4991 4997
4992 4998 2001-12-04 Fernando Perez <fperez@colorado.edu>
4993 4999
4994 5000 * Fixed namespace problems. Now builtin/IPyhton/user names get
4995 5001 properly reported in their namespace. Internal namespace handling
4996 5002 is finally getting decent (not perfect yet, but much better than
4997 5003 the ad-hoc mess we had).
4998 5004
4999 5005 * Removed -exit option. If people just want to run a python
5000 5006 script, that's what the normal interpreter is for. Less
5001 5007 unnecessary options, less chances for bugs.
5002 5008
5003 5009 * Added a crash handler which generates a complete post-mortem if
5004 5010 IPython crashes. This will help a lot in tracking bugs down the
5005 5011 road.
5006 5012
5007 5013 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
5008 5014 which were boud to functions being reassigned would bypass the
5009 5015 logger, breaking the sync of _il with the prompt counter. This
5010 5016 would then crash IPython later when a new line was logged.
5011 5017
5012 5018 2001-12-02 Fernando Perez <fperez@colorado.edu>
5013 5019
5014 5020 * Made IPython a package. This means people don't have to clutter
5015 5021 their sys.path with yet another directory. Changed the INSTALL
5016 5022 file accordingly.
5017 5023
5018 5024 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
5019 5025 sorts its output (so @who shows it sorted) and @whos formats the
5020 5026 table according to the width of the first column. Nicer, easier to
5021 5027 read. Todo: write a generic table_format() which takes a list of
5022 5028 lists and prints it nicely formatted, with optional row/column
5023 5029 separators and proper padding and justification.
5024 5030
5025 5031 * Released 0.1.20
5026 5032
5027 5033 * Fixed bug in @log which would reverse the inputcache list (a
5028 5034 copy operation was missing).
5029 5035
5030 5036 * Code cleanup. @config was changed to use page(). Better, since
5031 5037 its output is always quite long.
5032 5038
5033 5039 * Itpl is back as a dependency. I was having too many problems
5034 5040 getting the parametric aliases to work reliably, and it's just
5035 5041 easier to code weird string operations with it than playing %()s
5036 5042 games. It's only ~6k, so I don't think it's too big a deal.
5037 5043
5038 5044 * Found (and fixed) a very nasty bug with history. !lines weren't
5039 5045 getting cached, and the out of sync caches would crash
5040 5046 IPython. Fixed it by reorganizing the prefilter/handlers/logger
5041 5047 division of labor a bit better. Bug fixed, cleaner structure.
5042 5048
5043 5049 2001-12-01 Fernando Perez <fperez@colorado.edu>
5044 5050
5045 5051 * Released 0.1.19
5046 5052
5047 5053 * Added option -n to @hist to prevent line number printing. Much
5048 5054 easier to copy/paste code this way.
5049 5055
5050 5056 * Created global _il to hold the input list. Allows easy
5051 5057 re-execution of blocks of code by slicing it (inspired by Janko's
5052 5058 comment on 'macros').
5053 5059
5054 5060 * Small fixes and doc updates.
5055 5061
5056 5062 * Rewrote @history function (was @h). Renamed it to @hist, @h is
5057 5063 much too fragile with automagic. Handles properly multi-line
5058 5064 statements and takes parameters.
5059 5065
5060 5066 2001-11-30 Fernando Perez <fperez@colorado.edu>
5061 5067
5062 5068 * Version 0.1.18 released.
5063 5069
5064 5070 * Fixed nasty namespace bug in initial module imports.
5065 5071
5066 5072 * Added copyright/license notes to all code files (except
5067 5073 DPyGetOpt). For the time being, LGPL. That could change.
5068 5074
5069 5075 * Rewrote a much nicer README, updated INSTALL, cleaned up
5070 5076 ipythonrc-* samples.
5071 5077
5072 5078 * Overall code/documentation cleanup. Basically ready for
5073 5079 release. Only remaining thing: licence decision (LGPL?).
5074 5080
5075 5081 * Converted load_config to a class, ConfigLoader. Now recursion
5076 5082 control is better organized. Doesn't include the same file twice.
5077 5083
5078 5084 2001-11-29 Fernando Perez <fperez@colorado.edu>
5079 5085
5080 5086 * Got input history working. Changed output history variables from
5081 5087 _p to _o so that _i is for input and _o for output. Just cleaner
5082 5088 convention.
5083 5089
5084 5090 * Implemented parametric aliases. This pretty much allows the
5085 5091 alias system to offer full-blown shell convenience, I think.
5086 5092
5087 5093 * Version 0.1.17 released, 0.1.18 opened.
5088 5094
5089 5095 * dot_ipython/ipythonrc (alias): added documentation.
5090 5096 (xcolor): Fixed small bug (xcolors -> xcolor)
5091 5097
5092 5098 * Changed the alias system. Now alias is a magic command to define
5093 5099 aliases just like the shell. Rationale: the builtin magics should
5094 5100 be there for things deeply connected to IPython's
5095 5101 architecture. And this is a much lighter system for what I think
5096 5102 is the really important feature: allowing users to define quickly
5097 5103 magics that will do shell things for them, so they can customize
5098 5104 IPython easily to match their work habits. If someone is really
5099 5105 desperate to have another name for a builtin alias, they can
5100 5106 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
5101 5107 works.
5102 5108
5103 5109 2001-11-28 Fernando Perez <fperez@colorado.edu>
5104 5110
5105 5111 * Changed @file so that it opens the source file at the proper
5106 5112 line. Since it uses less, if your EDITOR environment is
5107 5113 configured, typing v will immediately open your editor of choice
5108 5114 right at the line where the object is defined. Not as quick as
5109 5115 having a direct @edit command, but for all intents and purposes it
5110 5116 works. And I don't have to worry about writing @edit to deal with
5111 5117 all the editors, less does that.
5112 5118
5113 5119 * Version 0.1.16 released, 0.1.17 opened.
5114 5120
5115 5121 * Fixed some nasty bugs in the page/page_dumb combo that could
5116 5122 crash IPython.
5117 5123
5118 5124 2001-11-27 Fernando Perez <fperez@colorado.edu>
5119 5125
5120 5126 * Version 0.1.15 released, 0.1.16 opened.
5121 5127
5122 5128 * Finally got ? and ?? to work for undefined things: now it's
5123 5129 possible to type {}.get? and get information about the get method
5124 5130 of dicts, or os.path? even if only os is defined (so technically
5125 5131 os.path isn't). Works at any level. For example, after import os,
5126 5132 os?, os.path?, os.path.abspath? all work. This is great, took some
5127 5133 work in _ofind.
5128 5134
5129 5135 * Fixed more bugs with logging. The sanest way to do it was to add
5130 5136 to @log a 'mode' parameter. Killed two in one shot (this mode
5131 5137 option was a request of Janko's). I think it's finally clean
5132 5138 (famous last words).
5133 5139
5134 5140 * Added a page_dumb() pager which does a decent job of paging on
5135 5141 screen, if better things (like less) aren't available. One less
5136 5142 unix dependency (someday maybe somebody will port this to
5137 5143 windows).
5138 5144
5139 5145 * Fixed problem in magic_log: would lock of logging out if log
5140 5146 creation failed (because it would still think it had succeeded).
5141 5147
5142 5148 * Improved the page() function using curses to auto-detect screen
5143 5149 size. Now it can make a much better decision on whether to print
5144 5150 or page a string. Option screen_length was modified: a value 0
5145 5151 means auto-detect, and that's the default now.
5146 5152
5147 5153 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
5148 5154 go out. I'll test it for a few days, then talk to Janko about
5149 5155 licences and announce it.
5150 5156
5151 5157 * Fixed the length of the auto-generated ---> prompt which appears
5152 5158 for auto-parens and auto-quotes. Getting this right isn't trivial,
5153 5159 with all the color escapes, different prompt types and optional
5154 5160 separators. But it seems to be working in all the combinations.
5155 5161
5156 5162 2001-11-26 Fernando Perez <fperez@colorado.edu>
5157 5163
5158 5164 * Wrote a regexp filter to get option types from the option names
5159 5165 string. This eliminates the need to manually keep two duplicate
5160 5166 lists.
5161 5167
5162 5168 * Removed the unneeded check_option_names. Now options are handled
5163 5169 in a much saner manner and it's easy to visually check that things
5164 5170 are ok.
5165 5171
5166 5172 * Updated version numbers on all files I modified to carry a
5167 5173 notice so Janko and Nathan have clear version markers.
5168 5174
5169 5175 * Updated docstring for ultraTB with my changes. I should send
5170 5176 this to Nathan.
5171 5177
5172 5178 * Lots of small fixes. Ran everything through pychecker again.
5173 5179
5174 5180 * Made loading of deep_reload an cmd line option. If it's not too
5175 5181 kosher, now people can just disable it. With -nodeep_reload it's
5176 5182 still available as dreload(), it just won't overwrite reload().
5177 5183
5178 5184 * Moved many options to the no| form (-opt and -noopt
5179 5185 accepted). Cleaner.
5180 5186
5181 5187 * Changed magic_log so that if called with no parameters, it uses
5182 5188 'rotate' mode. That way auto-generated logs aren't automatically
5183 5189 over-written. For normal logs, now a backup is made if it exists
5184 5190 (only 1 level of backups). A new 'backup' mode was added to the
5185 5191 Logger class to support this. This was a request by Janko.
5186 5192
5187 5193 * Added @logoff/@logon to stop/restart an active log.
5188 5194
5189 5195 * Fixed a lot of bugs in log saving/replay. It was pretty
5190 5196 broken. Now special lines (!@,/) appear properly in the command
5191 5197 history after a log replay.
5192 5198
5193 5199 * Tried and failed to implement full session saving via pickle. My
5194 5200 idea was to pickle __main__.__dict__, but modules can't be
5195 5201 pickled. This would be a better alternative to replaying logs, but
5196 5202 seems quite tricky to get to work. Changed -session to be called
5197 5203 -logplay, which more accurately reflects what it does. And if we
5198 5204 ever get real session saving working, -session is now available.
5199 5205
5200 5206 * Implemented color schemes for prompts also. As for tracebacks,
5201 5207 currently only NoColor and Linux are supported. But now the
5202 5208 infrastructure is in place, based on a generic ColorScheme
5203 5209 class. So writing and activating new schemes both for the prompts
5204 5210 and the tracebacks should be straightforward.
5205 5211
5206 5212 * Version 0.1.13 released, 0.1.14 opened.
5207 5213
5208 5214 * Changed handling of options for output cache. Now counter is
5209 5215 hardwired starting at 1 and one specifies the maximum number of
5210 5216 entries *in the outcache* (not the max prompt counter). This is
5211 5217 much better, since many statements won't increase the cache
5212 5218 count. It also eliminated some confusing options, now there's only
5213 5219 one: cache_size.
5214 5220
5215 5221 * Added 'alias' magic function and magic_alias option in the
5216 5222 ipythonrc file. Now the user can easily define whatever names he
5217 5223 wants for the magic functions without having to play weird
5218 5224 namespace games. This gives IPython a real shell-like feel.
5219 5225
5220 5226 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
5221 5227 @ or not).
5222 5228
5223 5229 This was one of the last remaining 'visible' bugs (that I know
5224 5230 of). I think if I can clean up the session loading so it works
5225 5231 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
5226 5232 about licensing).
5227 5233
5228 5234 2001-11-25 Fernando Perez <fperez@colorado.edu>
5229 5235
5230 5236 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
5231 5237 there's a cleaner distinction between what ? and ?? show.
5232 5238
5233 5239 * Added screen_length option. Now the user can define his own
5234 5240 screen size for page() operations.
5235 5241
5236 5242 * Implemented magic shell-like functions with automatic code
5237 5243 generation. Now adding another function is just a matter of adding
5238 5244 an entry to a dict, and the function is dynamically generated at
5239 5245 run-time. Python has some really cool features!
5240 5246
5241 5247 * Renamed many options to cleanup conventions a little. Now all
5242 5248 are lowercase, and only underscores where needed. Also in the code
5243 5249 option name tables are clearer.
5244 5250
5245 5251 * Changed prompts a little. Now input is 'In [n]:' instead of
5246 5252 'In[n]:='. This allows it the numbers to be aligned with the
5247 5253 Out[n] numbers, and removes usage of ':=' which doesn't exist in
5248 5254 Python (it was a Mathematica thing). The '...' continuation prompt
5249 5255 was also changed a little to align better.
5250 5256
5251 5257 * Fixed bug when flushing output cache. Not all _p<n> variables
5252 5258 exist, so their deletion needs to be wrapped in a try:
5253 5259
5254 5260 * Figured out how to properly use inspect.formatargspec() (it
5255 5261 requires the args preceded by *). So I removed all the code from
5256 5262 _get_pdef in Magic, which was just replicating that.
5257 5263
5258 5264 * Added test to prefilter to allow redefining magic function names
5259 5265 as variables. This is ok, since the @ form is always available,
5260 5266 but whe should allow the user to define a variable called 'ls' if
5261 5267 he needs it.
5262 5268
5263 5269 * Moved the ToDo information from README into a separate ToDo.
5264 5270
5265 5271 * General code cleanup and small bugfixes. I think it's close to a
5266 5272 state where it can be released, obviously with a big 'beta'
5267 5273 warning on it.
5268 5274
5269 5275 * Got the magic function split to work. Now all magics are defined
5270 5276 in a separate class. It just organizes things a bit, and now
5271 5277 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
5272 5278 was too long).
5273 5279
5274 5280 * Changed @clear to @reset to avoid potential confusions with
5275 5281 the shell command clear. Also renamed @cl to @clear, which does
5276 5282 exactly what people expect it to from their shell experience.
5277 5283
5278 5284 Added a check to the @reset command (since it's so
5279 5285 destructive, it's probably a good idea to ask for confirmation).
5280 5286 But now reset only works for full namespace resetting. Since the
5281 5287 del keyword is already there for deleting a few specific
5282 5288 variables, I don't see the point of having a redundant magic
5283 5289 function for the same task.
5284 5290
5285 5291 2001-11-24 Fernando Perez <fperez@colorado.edu>
5286 5292
5287 5293 * Updated the builtin docs (esp. the ? ones).
5288 5294
5289 5295 * Ran all the code through pychecker. Not terribly impressed with
5290 5296 it: lots of spurious warnings and didn't really find anything of
5291 5297 substance (just a few modules being imported and not used).
5292 5298
5293 5299 * Implemented the new ultraTB functionality into IPython. New
5294 5300 option: xcolors. This chooses color scheme. xmode now only selects
5295 5301 between Plain and Verbose. Better orthogonality.
5296 5302
5297 5303 * Large rewrite of ultraTB. Much cleaner now, with a separation of
5298 5304 mode and color scheme for the exception handlers. Now it's
5299 5305 possible to have the verbose traceback with no coloring.
5300 5306
5301 5307 2001-11-23 Fernando Perez <fperez@colorado.edu>
5302 5308
5303 5309 * Version 0.1.12 released, 0.1.13 opened.
5304 5310
5305 5311 * Removed option to set auto-quote and auto-paren escapes by
5306 5312 user. The chances of breaking valid syntax are just too high. If
5307 5313 someone *really* wants, they can always dig into the code.
5308 5314
5309 5315 * Made prompt separators configurable.
5310 5316
5311 5317 2001-11-22 Fernando Perez <fperez@colorado.edu>
5312 5318
5313 5319 * Small bugfixes in many places.
5314 5320
5315 5321 * Removed the MyCompleter class from ipplib. It seemed redundant
5316 5322 with the C-p,C-n history search functionality. Less code to
5317 5323 maintain.
5318 5324
5319 5325 * Moved all the original ipython.py code into ipythonlib.py. Right
5320 5326 now it's just one big dump into a function called make_IPython, so
5321 5327 no real modularity has been gained. But at least it makes the
5322 5328 wrapper script tiny, and since ipythonlib is a module, it gets
5323 5329 compiled and startup is much faster.
5324 5330
5325 5331 This is a reasobably 'deep' change, so we should test it for a
5326 5332 while without messing too much more with the code.
5327 5333
5328 5334 2001-11-21 Fernando Perez <fperez@colorado.edu>
5329 5335
5330 5336 * Version 0.1.11 released, 0.1.12 opened for further work.
5331 5337
5332 5338 * Removed dependency on Itpl. It was only needed in one place. It
5333 5339 would be nice if this became part of python, though. It makes life
5334 5340 *a lot* easier in some cases.
5335 5341
5336 5342 * Simplified the prefilter code a bit. Now all handlers are
5337 5343 expected to explicitly return a value (at least a blank string).
5338 5344
5339 5345 * Heavy edits in ipplib. Removed the help system altogether. Now
5340 5346 obj?/?? is used for inspecting objects, a magic @doc prints
5341 5347 docstrings, and full-blown Python help is accessed via the 'help'
5342 5348 keyword. This cleans up a lot of code (less to maintain) and does
5343 5349 the job. Since 'help' is now a standard Python component, might as
5344 5350 well use it and remove duplicate functionality.
5345 5351
5346 5352 Also removed the option to use ipplib as a standalone program. By
5347 5353 now it's too dependent on other parts of IPython to function alone.
5348 5354
5349 5355 * Fixed bug in genutils.pager. It would crash if the pager was
5350 5356 exited immediately after opening (broken pipe).
5351 5357
5352 5358 * Trimmed down the VerboseTB reporting a little. The header is
5353 5359 much shorter now and the repeated exception arguments at the end
5354 5360 have been removed. For interactive use the old header seemed a bit
5355 5361 excessive.
5356 5362
5357 5363 * Fixed small bug in output of @whos for variables with multi-word
5358 5364 types (only first word was displayed).
5359 5365
5360 5366 2001-11-17 Fernando Perez <fperez@colorado.edu>
5361 5367
5362 5368 * Version 0.1.10 released, 0.1.11 opened for further work.
5363 5369
5364 5370 * Modified dirs and friends. dirs now *returns* the stack (not
5365 5371 prints), so one can manipulate it as a variable. Convenient to
5366 5372 travel along many directories.
5367 5373
5368 5374 * Fixed bug in magic_pdef: would only work with functions with
5369 5375 arguments with default values.
5370 5376
5371 5377 2001-11-14 Fernando Perez <fperez@colorado.edu>
5372 5378
5373 5379 * Added the PhysicsInput stuff to dot_ipython so it ships as an
5374 5380 example with IPython. Various other minor fixes and cleanups.
5375 5381
5376 5382 * Version 0.1.9 released, 0.1.10 opened for further work.
5377 5383
5378 5384 * Added sys.path to the list of directories searched in the
5379 5385 execfile= option. It used to be the current directory and the
5380 5386 user's IPYTHONDIR only.
5381 5387
5382 5388 2001-11-13 Fernando Perez <fperez@colorado.edu>
5383 5389
5384 5390 * Reinstated the raw_input/prefilter separation that Janko had
5385 5391 initially. This gives a more convenient setup for extending the
5386 5392 pre-processor from the outside: raw_input always gets a string,
5387 5393 and prefilter has to process it. We can then redefine prefilter
5388 5394 from the outside and implement extensions for special
5389 5395 purposes.
5390 5396
5391 5397 Today I got one for inputting PhysicalQuantity objects
5392 5398 (from Scientific) without needing any function calls at
5393 5399 all. Extremely convenient, and it's all done as a user-level
5394 5400 extension (no IPython code was touched). Now instead of:
5395 5401 a = PhysicalQuantity(4.2,'m/s**2')
5396 5402 one can simply say
5397 5403 a = 4.2 m/s**2
5398 5404 or even
5399 5405 a = 4.2 m/s^2
5400 5406
5401 5407 I use this, but it's also a proof of concept: IPython really is
5402 5408 fully user-extensible, even at the level of the parsing of the
5403 5409 command line. It's not trivial, but it's perfectly doable.
5404 5410
5405 5411 * Added 'add_flip' method to inclusion conflict resolver. Fixes
5406 5412 the problem of modules being loaded in the inverse order in which
5407 5413 they were defined in
5408 5414
5409 5415 * Version 0.1.8 released, 0.1.9 opened for further work.
5410 5416
5411 5417 * Added magics pdef, source and file. They respectively show the
5412 5418 definition line ('prototype' in C), source code and full python
5413 5419 file for any callable object. The object inspector oinfo uses
5414 5420 these to show the same information.
5415 5421
5416 5422 * Version 0.1.7 released, 0.1.8 opened for further work.
5417 5423
5418 5424 * Separated all the magic functions into a class called Magic. The
5419 5425 InteractiveShell class was becoming too big for Xemacs to handle
5420 5426 (de-indenting a line would lock it up for 10 seconds while it
5421 5427 backtracked on the whole class!)
5422 5428
5423 5429 FIXME: didn't work. It can be done, but right now namespaces are
5424 5430 all messed up. Do it later (reverted it for now, so at least
5425 5431 everything works as before).
5426 5432
5427 5433 * Got the object introspection system (magic_oinfo) working! I
5428 5434 think this is pretty much ready for release to Janko, so he can
5429 5435 test it for a while and then announce it. Pretty much 100% of what
5430 5436 I wanted for the 'phase 1' release is ready. Happy, tired.
5431 5437
5432 5438 2001-11-12 Fernando Perez <fperez@colorado.edu>
5433 5439
5434 5440 * Version 0.1.6 released, 0.1.7 opened for further work.
5435 5441
5436 5442 * Fixed bug in printing: it used to test for truth before
5437 5443 printing, so 0 wouldn't print. Now checks for None.
5438 5444
5439 5445 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
5440 5446 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
5441 5447 reaches by hand into the outputcache. Think of a better way to do
5442 5448 this later.
5443 5449
5444 5450 * Various small fixes thanks to Nathan's comments.
5445 5451
5446 5452 * Changed magic_pprint to magic_Pprint. This way it doesn't
5447 5453 collide with pprint() and the name is consistent with the command
5448 5454 line option.
5449 5455
5450 5456 * Changed prompt counter behavior to be fully like
5451 5457 Mathematica's. That is, even input that doesn't return a result
5452 5458 raises the prompt counter. The old behavior was kind of confusing
5453 5459 (getting the same prompt number several times if the operation
5454 5460 didn't return a result).
5455 5461
5456 5462 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
5457 5463
5458 5464 * Fixed -Classic mode (wasn't working anymore).
5459 5465
5460 5466 * Added colored prompts using Nathan's new code. Colors are
5461 5467 currently hardwired, they can be user-configurable. For
5462 5468 developers, they can be chosen in file ipythonlib.py, at the
5463 5469 beginning of the CachedOutput class def.
5464 5470
5465 5471 2001-11-11 Fernando Perez <fperez@colorado.edu>
5466 5472
5467 5473 * Version 0.1.5 released, 0.1.6 opened for further work.
5468 5474
5469 5475 * Changed magic_env to *return* the environment as a dict (not to
5470 5476 print it). This way it prints, but it can also be processed.
5471 5477
5472 5478 * Added Verbose exception reporting to interactive
5473 5479 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
5474 5480 traceback. Had to make some changes to the ultraTB file. This is
5475 5481 probably the last 'big' thing in my mental todo list. This ties
5476 5482 in with the next entry:
5477 5483
5478 5484 * Changed -Xi and -Xf to a single -xmode option. Now all the user
5479 5485 has to specify is Plain, Color or Verbose for all exception
5480 5486 handling.
5481 5487
5482 5488 * Removed ShellServices option. All this can really be done via
5483 5489 the magic system. It's easier to extend, cleaner and has automatic
5484 5490 namespace protection and documentation.
5485 5491
5486 5492 2001-11-09 Fernando Perez <fperez@colorado.edu>
5487 5493
5488 5494 * Fixed bug in output cache flushing (missing parameter to
5489 5495 __init__). Other small bugs fixed (found using pychecker).
5490 5496
5491 5497 * Version 0.1.4 opened for bugfixing.
5492 5498
5493 5499 2001-11-07 Fernando Perez <fperez@colorado.edu>
5494 5500
5495 5501 * Version 0.1.3 released, mainly because of the raw_input bug.
5496 5502
5497 5503 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
5498 5504 and when testing for whether things were callable, a call could
5499 5505 actually be made to certain functions. They would get called again
5500 5506 once 'really' executed, with a resulting double call. A disaster
5501 5507 in many cases (list.reverse() would never work!).
5502 5508
5503 5509 * Removed prefilter() function, moved its code to raw_input (which
5504 5510 after all was just a near-empty caller for prefilter). This saves
5505 5511 a function call on every prompt, and simplifies the class a tiny bit.
5506 5512
5507 5513 * Fix _ip to __ip name in magic example file.
5508 5514
5509 5515 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
5510 5516 work with non-gnu versions of tar.
5511 5517
5512 5518 2001-11-06 Fernando Perez <fperez@colorado.edu>
5513 5519
5514 5520 * Version 0.1.2. Just to keep track of the recent changes.
5515 5521
5516 5522 * Fixed nasty bug in output prompt routine. It used to check 'if
5517 5523 arg != None...'. Problem is, this fails if arg implements a
5518 5524 special comparison (__cmp__) which disallows comparing to
5519 5525 None. Found it when trying to use the PhysicalQuantity module from
5520 5526 ScientificPython.
5521 5527
5522 5528 2001-11-05 Fernando Perez <fperez@colorado.edu>
5523 5529
5524 5530 * Also added dirs. Now the pushd/popd/dirs family functions
5525 5531 basically like the shell, with the added convenience of going home
5526 5532 when called with no args.
5527 5533
5528 5534 * pushd/popd slightly modified to mimic shell behavior more
5529 5535 closely.
5530 5536
5531 5537 * Added env,pushd,popd from ShellServices as magic functions. I
5532 5538 think the cleanest will be to port all desired functions from
5533 5539 ShellServices as magics and remove ShellServices altogether. This
5534 5540 will provide a single, clean way of adding functionality
5535 5541 (shell-type or otherwise) to IP.
5536 5542
5537 5543 2001-11-04 Fernando Perez <fperez@colorado.edu>
5538 5544
5539 5545 * Added .ipython/ directory to sys.path. This way users can keep
5540 5546 customizations there and access them via import.
5541 5547
5542 5548 2001-11-03 Fernando Perez <fperez@colorado.edu>
5543 5549
5544 5550 * Opened version 0.1.1 for new changes.
5545 5551
5546 5552 * Changed version number to 0.1.0: first 'public' release, sent to
5547 5553 Nathan and Janko.
5548 5554
5549 5555 * Lots of small fixes and tweaks.
5550 5556
5551 5557 * Minor changes to whos format. Now strings are shown, snipped if
5552 5558 too long.
5553 5559
5554 5560 * Changed ShellServices to work on __main__ so they show up in @who
5555 5561
5556 5562 * Help also works with ? at the end of a line:
5557 5563 ?sin and sin?
5558 5564 both produce the same effect. This is nice, as often I use the
5559 5565 tab-complete to find the name of a method, but I used to then have
5560 5566 to go to the beginning of the line to put a ? if I wanted more
5561 5567 info. Now I can just add the ? and hit return. Convenient.
5562 5568
5563 5569 2001-11-02 Fernando Perez <fperez@colorado.edu>
5564 5570
5565 5571 * Python version check (>=2.1) added.
5566 5572
5567 5573 * Added LazyPython documentation. At this point the docs are quite
5568 5574 a mess. A cleanup is in order.
5569 5575
5570 5576 * Auto-installer created. For some bizarre reason, the zipfiles
5571 5577 module isn't working on my system. So I made a tar version
5572 5578 (hopefully the command line options in various systems won't kill
5573 5579 me).
5574 5580
5575 5581 * Fixes to Struct in genutils. Now all dictionary-like methods are
5576 5582 protected (reasonably).
5577 5583
5578 5584 * Added pager function to genutils and changed ? to print usage
5579 5585 note through it (it was too long).
5580 5586
5581 5587 * Added the LazyPython functionality. Works great! I changed the
5582 5588 auto-quote escape to ';', it's on home row and next to '. But
5583 5589 both auto-quote and auto-paren (still /) escapes are command-line
5584 5590 parameters.
5585 5591
5586 5592
5587 5593 2001-11-01 Fernando Perez <fperez@colorado.edu>
5588 5594
5589 5595 * Version changed to 0.0.7. Fairly large change: configuration now
5590 5596 is all stored in a directory, by default .ipython. There, all
5591 5597 config files have normal looking names (not .names)
5592 5598
5593 5599 * Version 0.0.6 Released first to Lucas and Archie as a test
5594 5600 run. Since it's the first 'semi-public' release, change version to
5595 5601 > 0.0.6 for any changes now.
5596 5602
5597 5603 * Stuff I had put in the ipplib.py changelog:
5598 5604
5599 5605 Changes to InteractiveShell:
5600 5606
5601 5607 - Made the usage message a parameter.
5602 5608
5603 5609 - Require the name of the shell variable to be given. It's a bit
5604 5610 of a hack, but allows the name 'shell' not to be hardwired in the
5605 5611 magic (@) handler, which is problematic b/c it requires
5606 5612 polluting the global namespace with 'shell'. This in turn is
5607 5613 fragile: if a user redefines a variable called shell, things
5608 5614 break.
5609 5615
5610 5616 - magic @: all functions available through @ need to be defined
5611 5617 as magic_<name>, even though they can be called simply as
5612 5618 @<name>. This allows the special command @magic to gather
5613 5619 information automatically about all existing magic functions,
5614 5620 even if they are run-time user extensions, by parsing the shell
5615 5621 instance __dict__ looking for special magic_ names.
5616 5622
5617 5623 - mainloop: added *two* local namespace parameters. This allows
5618 5624 the class to differentiate between parameters which were there
5619 5625 before and after command line initialization was processed. This
5620 5626 way, later @who can show things loaded at startup by the
5621 5627 user. This trick was necessary to make session saving/reloading
5622 5628 really work: ideally after saving/exiting/reloading a session,
5623 5629 *everything* should look the same, including the output of @who. I
5624 5630 was only able to make this work with this double namespace
5625 5631 trick.
5626 5632
5627 5633 - added a header to the logfile which allows (almost) full
5628 5634 session restoring.
5629 5635
5630 5636 - prepend lines beginning with @ or !, with a and log
5631 5637 them. Why? !lines: may be useful to know what you did @lines:
5632 5638 they may affect session state. So when restoring a session, at
5633 5639 least inform the user of their presence. I couldn't quite get
5634 5640 them to properly re-execute, but at least the user is warned.
5635 5641
5636 5642 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now