##// END OF EJS Templates
- new doctest_mode magic to toggle doctest pasting/prompts....
fperez -
Show More
@@ -1,118 +1,122 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Modified input prompt for entering text with >>> or ... at the start.
3 3
4 4 We define a special input line filter to allow typing lines which begin with
5 5 '>>> ' or '... '. These two strings, if present at the start of the input
6 6 line, are stripped. This allows for direct pasting of code from examples such
7 7 as those available in the standard Python tutorial.
8 8
9 9 Normally pasting such code is one chunk is impossible because of the
10 10 extraneous >>> and ..., requiring one to do a line by line paste with careful
11 11 removal of those characters. This module allows pasting that kind of
12 12 multi-line examples in one pass.
13 13
14 14 Here is an 'screenshot' of a section of the tutorial pasted into IPython with
15 15 this feature enabled:
16 16
17 17 In [1]: >>> def fib2(n): # return Fibonacci series up to n
18 18 ...: ... '''Return a list containing the Fibonacci series up to n.'''
19 19 ...: ... result = []
20 20 ...: ... a, b = 0, 1
21 21 ...: ... while b < n:
22 22 ...: ... result.append(b) # see below
23 23 ...: ... a, b = b, a+b
24 24 ...: ... return result
25 25 ...:
26 26
27 27 In [2]: fib2(10)
28 28 Out[2]: [1, 1, 2, 3, 5, 8]
29 29
30 30 The >>> and ... are stripped from the input so that the python interpreter
31 31 only sees the real part of the code.
32 32
33 33 All other input is processed normally.
34 34
35 35 Notes
36 36 =====
37 37
38 38 * You can even paste code that has extra initial spaces, such as is common in
39 39 doctests:
40 40
41 41 In [3]: >>> a = ['Mary', 'had', 'a', 'little', 'lamb']
42 42
43 43 In [4]: >>> for i in range(len(a)):
44 44 ...: ... print i, a[i]
45 45 ...: ...
46 46 0 Mary
47 47 1 had
48 48 2 a
49 49 3 little
50 50 4 lamb
51 51 """
52 52
53 53 #*****************************************************************************
54 54 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
55 55 #
56 56 # Distributed under the terms of the BSD License. The full license is in
57 57 # the file COPYING, distributed as part of this software.
58 58 #*****************************************************************************
59 59
60 60 from IPython import Release
61 61 __author__ = '%s <%s>' % Release.authors['Fernando']
62 62 __license__ = Release.license
63 63
64 64 # This file is an example of how to modify IPython's line-processing behavior
65 65 # without touching the internal code. We'll define an alternate pre-processing
66 66 # stage which allows a special form of input (which is invalid Python syntax)
67 67 # for certain quantities, rewrites a line of proper Python in those cases, and
68 68 # then passes it off to IPython's normal processor for further work.
69 69
70 70 # With this kind of customization, IPython can be adapted for many
71 71 # special-purpose scenarios providing alternate input syntaxes.
72 72
73 73 # This file can be imported like a regular module.
74 74
75 75 # IPython has a prefilter() function that analyzes each input line. We redefine
76 76 # it here to first pre-process certain forms of input
77 77
78 78 # The prototype of any alternate prefilter must be like this one (the name
79 79 # doesn't matter):
80 80 # - line is a string containing the user input line.
81 81 # - continuation is a parameter which tells us if we are processing a first
82 82 # line of user input or the second or higher of a multi-line statement.
83 83
84 84 import re
85 85
86 from IPython.iplib import InteractiveShell
87
86 88 PROMPT_RE = re.compile(r'(^[ \t]*>>> |^[ \t]*\.\.\. )')
87 89
88 90 def prefilter_paste(self,line,continuation):
89 91 """Alternate prefilter for input of pasted code from an interpreter.
90 92 """
91 93 if not line:
92 94 return ''
93 95 m = PROMPT_RE.match(line)
94 96 if m:
95 97 # In the end, always call the default IPython _prefilter() function.
96 98 # Note that self must be passed explicitly, b/c we're calling the
97 99 # unbound class method (since this method will overwrite the instance
98 100 # prefilter())
99 101 return self._prefilter(line[len(m.group(0)):],continuation)
100 102 elif line.strip() == '...':
101 103 return self._prefilter('',continuation)
102 104 elif line.isspace():
103 105 # This allows us to recognize multiple input prompts separated by blank
104 106 # lines and pasted in a single chunk, very common when pasting doctests
105 107 # or long tutorial passages.
106 108 return ''
107 109 else:
108 110 return self._prefilter(line,continuation)
109 111
110 # Rebind this to be the new IPython prefilter:
111 from IPython.iplib import InteractiveShell
112 def activate_prefilter():
113 """Rebind the input-pasting filter to be the new IPython prefilter"""
112 114 InteractiveShell.prefilter = prefilter_paste
113 115
114 # Clean up the namespace.
115 del InteractiveShell,prefilter_paste
116 def deactivate_prefilter():
117 """Reset the filter."""
118 InteractiveShell.prefilter = InteractiveShell._prefilter
116 119
117 120 # Just a heads up at the console
121 activate_prefilter()
118 122 print '*** Pasting of code with ">>>" or "..." has been enabled.'
@@ -1,45 +1,48 b''
1 1 """Config file for 'doctest' profile.
2 2
3 3 This profile modifies the prompts to be the standard Python ones, so that you
4 4 can generate easily doctests from an IPython session.
5 5
6 6 But more importantly, it enables pasting of code with '>>>' prompts and
7 7 arbitrary initial whitespace, as is typical of doctests in reST files and
8 8 docstrings. This allows you to easily re-run existing doctests and iteratively
9 9 work on them as part of your development workflow.
10 10
11 11 The exception mode is also set to 'plain' so the generated exceptions are as
12 12 similar as possible to the default Python ones, for inclusion in doctests."""
13 13
14 14 # get various stuff that are there for historical / familiarity reasons
15 15 import ipy_legacy
16 16
17 17 from IPython import ipapi
18 18
19 19 from IPython.Extensions import InterpreterPasteInput
20 20
21 21 def main():
22 22 ip = ipapi.get()
23 23 o = ip.options
24 24
25 25 # Set the prompts similar to the defaults
26 26 o.prompt_in1 = '>>> '
27 27 o.prompt_in2 = '... '
28 28 o.prompt_out = ''
29 29
30 30 # No separation between successive inputs
31 31 o.separate_in = ''
32 32 o.separate_out = ''
33 33 # But add a blank line after any output, to help separate doctests from
34 34 # each other. This is needed by doctest to distinguish each test from the
35 35 # next.
36 36 o.separate_out2 = '\n'
37 37
38 38 # Disable pprint, so that outputs are printed as similarly to standard
39 39 # python as possible
40 40 o.pprint = False
41 41
42 42 # Use plain exceptions, to also resemble normal pyhton.
43 43 o.xmode = 'plain'
44 44
45 # Store the activity flag in the metadata bag from the running shell
46 ip.IP.meta.doctest_mode = True
47
45 48 main()
@@ -1,25 +1,25 b''
1 1 """ IPython 'sci' profile
2 2
3 3 Replaces the old scipy profile.
4 4
5 5 """
6 6
7 7
8 8 import IPython.ipapi
9 9 import ipy_defaults
10 10
11 11 def main():
12 12 ip = IPython.ipapi.get()
13 13
14 14 try:
15 ip.ex("import scipy")
16 15 ip.ex("import numpy")
16 ip.ex("import scipy")
17 17
18 ip.ex("from scipy import *")
19 18 ip.ex("from numpy import *")
19 ip.ex("from scipy import *")
20 20 print "SciPy profile successfully loaded."
21 21 except ImportError:
22 22 print "Unable to start scipy profile, are scipy and numpy installed?"
23 23
24 24
25 25 main()
@@ -1,2915 +1,3001 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Magic functions for InteractiveShell.
3 3
4 $Id: Magic.py 2595 2007-08-08 09:41:33Z vivainio $"""
4 $Id: Magic.py 2601 2007-08-10 07:01:29Z fperez $"""
5 5
6 6 #*****************************************************************************
7 7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
8 8 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
9 9 #
10 10 # Distributed under the terms of the BSD License. The full license is in
11 11 # the file COPYING, distributed as part of this software.
12 12 #*****************************************************************************
13 13
14 14 #****************************************************************************
15 15 # Modules and globals
16 16
17 17 from IPython import Release
18 18 __author__ = '%s <%s>\n%s <%s>' % \
19 19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
20 20 __license__ = Release.license
21 21
22 22 # Python standard modules
23 23 import __builtin__
24 24 import bdb
25 25 import inspect
26 26 import os
27 27 import pdb
28 28 import pydoc
29 29 import sys
30 30 import re
31 31 import tempfile
32 32 import time
33 33 import cPickle as pickle
34 34 import textwrap
35 35 from cStringIO import StringIO
36 36 from getopt import getopt,GetoptError
37 37 from pprint import pprint, pformat
38 38 from sets import Set
39 39
40 40 # cProfile was added in Python2.5
41 41 try:
42 42 import cProfile as profile
43 43 import pstats
44 44 except ImportError:
45 45 # profile isn't bundled by default in Debian for license reasons
46 46 try:
47 47 import profile,pstats
48 48 except ImportError:
49 49 profile = pstats = None
50 50
51 51 # Homebrewed
52 52 import IPython
53 53 from IPython import Debugger, OInspect, wildcard
54 54 from IPython.FakeModule import FakeModule
55 55 from IPython.Itpl import Itpl, itpl, printpl,itplns
56 56 from IPython.PyColorize import Parser
57 57 from IPython.ipstruct import Struct
58 58 from IPython.macro import Macro
59 59 from IPython.genutils import *
60 60 from IPython import platutils
61 61 import IPython.generics
62 62 import IPython.ipapi
63 63
64 64 #***************************************************************************
65 65 # Utility functions
66 66 def on_off(tag):
67 67 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
68 68 return ['OFF','ON'][tag]
69 69
70 70 class Bunch: pass
71 71
72 72 def compress_dhist(dh):
73 73 head, tail = dh[:-10], dh[-10:]
74 74
75 75 newhead = []
76 76 done = Set()
77 77 for h in head:
78 78 if h in done:
79 79 continue
80 80 newhead.append(h)
81 81 done.add(h)
82 82
83 83 return newhead + tail
84 84
85 85
86 86 #***************************************************************************
87 87 # Main class implementing Magic functionality
88 88 class Magic:
89 89 """Magic functions for InteractiveShell.
90 90
91 91 Shell functions which can be reached as %function_name. All magic
92 92 functions should accept a string, which they can parse for their own
93 93 needs. This can make some functions easier to type, eg `%cd ../`
94 94 vs. `%cd("../")`
95 95
96 96 ALL definitions MUST begin with the prefix magic_. The user won't need it
97 97 at the command line, but it is is needed in the definition. """
98 98
99 99 # class globals
100 100 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
101 101 'Automagic is ON, % prefix NOT needed for magic functions.']
102 102
103 103 #......................................................................
104 104 # some utility functions
105 105
106 106 def __init__(self,shell):
107 107
108 108 self.options_table = {}
109 109 if profile is None:
110 110 self.magic_prun = self.profile_missing_notice
111 111 self.shell = shell
112 112
113 113 # namespace for holding state we may need
114 114 self._magic_state = Bunch()
115 115
116 116 def profile_missing_notice(self, *args, **kwargs):
117 117 error("""\
118 118 The profile module could not be found. If you are a Debian user,
119 119 it has been removed from the standard Debian package because of its non-free
120 120 license. To use profiling, please install"python2.3-profiler" from non-free.""")
121 121
122 122 def default_option(self,fn,optstr):
123 123 """Make an entry in the options_table for fn, with value optstr"""
124 124
125 125 if fn not in self.lsmagic():
126 126 error("%s is not a magic function" % fn)
127 127 self.options_table[fn] = optstr
128 128
129 129 def lsmagic(self):
130 130 """Return a list of currently available magic functions.
131 131
132 132 Gives a list of the bare names after mangling (['ls','cd', ...], not
133 133 ['magic_ls','magic_cd',...]"""
134 134
135 135 # FIXME. This needs a cleanup, in the way the magics list is built.
136 136
137 137 # magics in class definition
138 138 class_magic = lambda fn: fn.startswith('magic_') and \
139 139 callable(Magic.__dict__[fn])
140 140 # in instance namespace (run-time user additions)
141 141 inst_magic = lambda fn: fn.startswith('magic_') and \
142 142 callable(self.__dict__[fn])
143 143 # and bound magics by user (so they can access self):
144 144 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
145 145 callable(self.__class__.__dict__[fn])
146 146 magics = filter(class_magic,Magic.__dict__.keys()) + \
147 147 filter(inst_magic,self.__dict__.keys()) + \
148 148 filter(inst_bound_magic,self.__class__.__dict__.keys())
149 149 out = []
150 150 for fn in magics:
151 151 out.append(fn.replace('magic_','',1))
152 152 out.sort()
153 153 return out
154 154
155 155 def extract_input_slices(self,slices,raw=False):
156 156 """Return as a string a set of input history slices.
157 157
158 158 Inputs:
159 159
160 160 - slices: the set of slices is given as a list of strings (like
161 161 ['1','4:8','9'], since this function is for use by magic functions
162 162 which get their arguments as strings.
163 163
164 164 Optional inputs:
165 165
166 166 - raw(False): by default, the processed input is used. If this is
167 167 true, the raw input history is used instead.
168 168
169 169 Note that slices can be called with two notations:
170 170
171 171 N:M -> standard python form, means including items N...(M-1).
172 172
173 173 N-M -> include items N..M (closed endpoint)."""
174 174
175 175 if raw:
176 176 hist = self.shell.input_hist_raw
177 177 else:
178 178 hist = self.shell.input_hist
179 179
180 180 cmds = []
181 181 for chunk in slices:
182 182 if ':' in chunk:
183 183 ini,fin = map(int,chunk.split(':'))
184 184 elif '-' in chunk:
185 185 ini,fin = map(int,chunk.split('-'))
186 186 fin += 1
187 187 else:
188 188 ini = int(chunk)
189 189 fin = ini+1
190 190 cmds.append(hist[ini:fin])
191 191 return cmds
192 192
193 193 def _ofind(self, oname, namespaces=None):
194 194 """Find an object in the available namespaces.
195 195
196 196 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
197 197
198 198 Has special code to detect magic functions.
199 199 """
200 200
201 201 oname = oname.strip()
202 202
203 203 alias_ns = None
204 204 if namespaces is None:
205 205 # Namespaces to search in:
206 206 # Put them in a list. The order is important so that we
207 207 # find things in the same order that Python finds them.
208 208 namespaces = [ ('Interactive', self.shell.user_ns),
209 209 ('IPython internal', self.shell.internal_ns),
210 210 ('Python builtin', __builtin__.__dict__),
211 211 ('Alias', self.shell.alias_table),
212 212 ]
213 213 alias_ns = self.shell.alias_table
214 214
215 215 # initialize results to 'null'
216 216 found = 0; obj = None; ospace = None; ds = None;
217 217 ismagic = 0; isalias = 0; parent = None
218 218
219 219 # Look for the given name by splitting it in parts. If the head is
220 220 # found, then we look for all the remaining parts as members, and only
221 221 # declare success if we can find them all.
222 222 oname_parts = oname.split('.')
223 223 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
224 224 for nsname,ns in namespaces:
225 225 try:
226 226 obj = ns[oname_head]
227 227 except KeyError:
228 228 continue
229 229 else:
230 230 #print 'oname_rest:', oname_rest # dbg
231 231 for part in oname_rest:
232 232 try:
233 233 parent = obj
234 234 obj = getattr(obj,part)
235 235 except:
236 236 # Blanket except b/c some badly implemented objects
237 237 # allow __getattr__ to raise exceptions other than
238 238 # AttributeError, which then crashes IPython.
239 239 break
240 240 else:
241 241 # If we finish the for loop (no break), we got all members
242 242 found = 1
243 243 ospace = nsname
244 244 if ns == alias_ns:
245 245 isalias = 1
246 246 break # namespace loop
247 247
248 248 # Try to see if it's magic
249 249 if not found:
250 250 if oname.startswith(self.shell.ESC_MAGIC):
251 251 oname = oname[1:]
252 252 obj = getattr(self,'magic_'+oname,None)
253 253 if obj is not None:
254 254 found = 1
255 255 ospace = 'IPython internal'
256 256 ismagic = 1
257 257
258 258 # Last try: special-case some literals like '', [], {}, etc:
259 259 if not found and oname_head in ["''",'""','[]','{}','()']:
260 260 obj = eval(oname_head)
261 261 found = 1
262 262 ospace = 'Interactive'
263 263
264 264 return {'found':found, 'obj':obj, 'namespace':ospace,
265 265 'ismagic':ismagic, 'isalias':isalias, 'parent':parent}
266 266
267 267 def arg_err(self,func):
268 268 """Print docstring if incorrect arguments were passed"""
269 269 print 'Error in arguments:'
270 270 print OInspect.getdoc(func)
271 271
272 272 def format_latex(self,strng):
273 273 """Format a string for latex inclusion."""
274 274
275 275 # Characters that need to be escaped for latex:
276 276 escape_re = re.compile(r'(%|_|\$|#|&)',re.MULTILINE)
277 277 # Magic command names as headers:
278 278 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
279 279 re.MULTILINE)
280 280 # Magic commands
281 281 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
282 282 re.MULTILINE)
283 283 # Paragraph continue
284 284 par_re = re.compile(r'\\$',re.MULTILINE)
285 285
286 286 # The "\n" symbol
287 287 newline_re = re.compile(r'\\n')
288 288
289 289 # Now build the string for output:
290 290 #strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng)
291 291 strng = cmd_name_re.sub(r'\n\\bigskip\n\\texttt{\\textbf{ \1}}:',
292 292 strng)
293 293 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
294 294 strng = par_re.sub(r'\\\\',strng)
295 295 strng = escape_re.sub(r'\\\1',strng)
296 296 strng = newline_re.sub(r'\\textbackslash{}n',strng)
297 297 return strng
298 298
299 299 def format_screen(self,strng):
300 300 """Format a string for screen printing.
301 301
302 302 This removes some latex-type format codes."""
303 303 # Paragraph continue
304 304 par_re = re.compile(r'\\$',re.MULTILINE)
305 305 strng = par_re.sub('',strng)
306 306 return strng
307 307
308 308 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
309 309 """Parse options passed to an argument string.
310 310
311 311 The interface is similar to that of getopt(), but it returns back a
312 312 Struct with the options as keys and the stripped argument string still
313 313 as a string.
314 314
315 315 arg_str is quoted as a true sys.argv vector by using shlex.split.
316 316 This allows us to easily expand variables, glob files, quote
317 317 arguments, etc.
318 318
319 319 Options:
320 320 -mode: default 'string'. If given as 'list', the argument string is
321 321 returned as a list (split on whitespace) instead of a string.
322 322
323 323 -list_all: put all option values in lists. Normally only options
324 324 appearing more than once are put in a list.
325 325
326 326 -posix (True): whether to split the input line in POSIX mode or not,
327 327 as per the conventions outlined in the shlex module from the
328 328 standard library."""
329 329
330 330 # inject default options at the beginning of the input line
331 331 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
332 332 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
333 333
334 334 mode = kw.get('mode','string')
335 335 if mode not in ['string','list']:
336 336 raise ValueError,'incorrect mode given: %s' % mode
337 337 # Get options
338 338 list_all = kw.get('list_all',0)
339 339 posix = kw.get('posix',True)
340 340
341 341 # Check if we have more than one argument to warrant extra processing:
342 342 odict = {} # Dictionary with options
343 343 args = arg_str.split()
344 344 if len(args) >= 1:
345 345 # If the list of inputs only has 0 or 1 thing in it, there's no
346 346 # need to look for options
347 347 argv = arg_split(arg_str,posix)
348 348 # Do regular option processing
349 349 try:
350 350 opts,args = getopt(argv,opt_str,*long_opts)
351 351 except GetoptError,e:
352 352 raise GetoptError('%s ( allowed: "%s" %s)' % (e.msg,opt_str,
353 353 " ".join(long_opts)))
354 354 for o,a in opts:
355 355 if o.startswith('--'):
356 356 o = o[2:]
357 357 else:
358 358 o = o[1:]
359 359 try:
360 360 odict[o].append(a)
361 361 except AttributeError:
362 362 odict[o] = [odict[o],a]
363 363 except KeyError:
364 364 if list_all:
365 365 odict[o] = [a]
366 366 else:
367 367 odict[o] = a
368 368
369 369 # Prepare opts,args for return
370 370 opts = Struct(odict)
371 371 if mode == 'string':
372 372 args = ' '.join(args)
373 373
374 374 return opts,args
375 375
376 376 #......................................................................
377 377 # And now the actual magic functions
378 378
379 379 # Functions for IPython shell work (vars,funcs, config, etc)
380 380 def magic_lsmagic(self, parameter_s = ''):
381 381 """List currently available magic functions."""
382 382 mesc = self.shell.ESC_MAGIC
383 383 print 'Available magic functions:\n'+mesc+\
384 384 (' '+mesc).join(self.lsmagic())
385 385 print '\n' + Magic.auto_status[self.shell.rc.automagic]
386 386 return None
387 387
388 388 def magic_magic(self, parameter_s = ''):
389 389 """Print information about the magic function system."""
390 390
391 391 mode = ''
392 392 try:
393 393 if parameter_s.split()[0] == '-latex':
394 394 mode = 'latex'
395 395 if parameter_s.split()[0] == '-brief':
396 396 mode = 'brief'
397 397 except:
398 398 pass
399 399
400 400 magic_docs = []
401 401 for fname in self.lsmagic():
402 402 mname = 'magic_' + fname
403 403 for space in (Magic,self,self.__class__):
404 404 try:
405 405 fn = space.__dict__[mname]
406 406 except KeyError:
407 407 pass
408 408 else:
409 409 break
410 410 if mode == 'brief':
411 411 # only first line
412 412 fndoc = fn.__doc__.split('\n',1)[0]
413 413 else:
414 414 fndoc = fn.__doc__
415 415
416 416 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
417 417 fname,fndoc))
418 418 magic_docs = ''.join(magic_docs)
419 419
420 420 if mode == 'latex':
421 421 print self.format_latex(magic_docs)
422 422 return
423 423 else:
424 424 magic_docs = self.format_screen(magic_docs)
425 425 if mode == 'brief':
426 426 return magic_docs
427 427
428 428 outmsg = """
429 429 IPython's 'magic' functions
430 430 ===========================
431 431
432 432 The magic function system provides a series of functions which allow you to
433 433 control the behavior of IPython itself, plus a lot of system-type
434 434 features. All these functions are prefixed with a % character, but parameters
435 435 are given without parentheses or quotes.
436 436
437 437 NOTE: If you have 'automagic' enabled (via the command line option or with the
438 438 %automagic function), you don't need to type in the % explicitly. By default,
439 439 IPython ships with automagic on, so you should only rarely need the % escape.
440 440
441 441 Example: typing '%cd mydir' (without the quotes) changes you working directory
442 442 to 'mydir', if it exists.
443 443
444 444 You can define your own magic functions to extend the system. See the supplied
445 445 ipythonrc and example-magic.py files for details (in your ipython
446 446 configuration directory, typically $HOME/.ipython/).
447 447
448 448 You can also define your own aliased names for magic functions. In your
449 449 ipythonrc file, placing a line like:
450 450
451 451 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
452 452
453 453 will define %pf as a new name for %profile.
454 454
455 455 You can also call magics in code using the ipmagic() function, which IPython
456 456 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
457 457
458 458 For a list of the available magic functions, use %lsmagic. For a description
459 459 of any of them, type %magic_name?, e.g. '%cd?'.
460 460
461 461 Currently the magic system has the following functions:\n"""
462 462
463 463 mesc = self.shell.ESC_MAGIC
464 464 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
465 465 "\n\n%s%s\n\n%s" % (outmsg,
466 466 magic_docs,mesc,mesc,
467 467 (' '+mesc).join(self.lsmagic()),
468 468 Magic.auto_status[self.shell.rc.automagic] ) )
469 469
470 470 page(outmsg,screen_lines=self.shell.rc.screen_length)
471 471
472 472
473 473 def magic_autoindent(self, parameter_s = ''):
474 474 """Toggle autoindent on/off (if available)."""
475 475
476 476 self.shell.set_autoindent()
477 477 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
478 478
479 479 def magic_system_verbose(self, parameter_s = ''):
480 480 """Set verbose printing of system calls.
481 481
482 482 If called without an argument, act as a toggle"""
483 483
484 484 if parameter_s:
485 485 val = bool(eval(parameter_s))
486 486 else:
487 487 val = None
488 488
489 489 self.shell.rc_set_toggle('system_verbose',val)
490 490 print "System verbose printing is:",\
491 491 ['OFF','ON'][self.shell.rc.system_verbose]
492 492
493 493
494 494 def magic_page(self, parameter_s=''):
495 495 """Pretty print the object and display it through a pager.
496 496
497 497 %page [options] OBJECT
498 498
499 499 If no object is given, use _ (last output).
500 500
501 501 Options:
502 502
503 503 -r: page str(object), don't pretty-print it."""
504 504
505 505 # After a function contributed by Olivier Aubert, slightly modified.
506 506
507 507 # Process options/args
508 508 opts,args = self.parse_options(parameter_s,'r')
509 509 raw = 'r' in opts
510 510
511 511 oname = args and args or '_'
512 512 info = self._ofind(oname)
513 513 if info['found']:
514 514 txt = (raw and str or pformat)( info['obj'] )
515 515 page(txt)
516 516 else:
517 517 print 'Object `%s` not found' % oname
518 518
519 519 def magic_profile(self, parameter_s=''):
520 520 """Print your currently active IPyhton profile."""
521 521 if self.shell.rc.profile:
522 522 printpl('Current IPython profile: $self.shell.rc.profile.')
523 523 else:
524 524 print 'No profile active.'
525 525
526 526 def magic_pinfo(self, parameter_s='', namespaces=None):
527 527 """Provide detailed information about an object.
528 528
529 529 '%pinfo object' is just a synonym for object? or ?object."""
530 530
531 531 #print 'pinfo par: <%s>' % parameter_s # dbg
532 532
533 533
534 534 # detail_level: 0 -> obj? , 1 -> obj??
535 535 detail_level = 0
536 536 # We need to detect if we got called as 'pinfo pinfo foo', which can
537 537 # happen if the user types 'pinfo foo?' at the cmd line.
538 538 pinfo,qmark1,oname,qmark2 = \
539 539 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
540 540 if pinfo or qmark1 or qmark2:
541 541 detail_level = 1
542 542 if "*" in oname:
543 543 self.magic_psearch(oname)
544 544 else:
545 545 self._inspect('pinfo', oname, detail_level=detail_level,
546 546 namespaces=namespaces)
547 547
548 548 def _inspect(self,meth,oname,namespaces=None,**kw):
549 549 """Generic interface to the inspector system.
550 550
551 551 This function is meant to be called by pdef, pdoc & friends."""
552 552
553 553 #oname = oname.strip()
554 554 #print '1- oname: <%r>' % oname # dbg
555 555 try:
556 556 oname = oname.strip().encode('ascii')
557 557 #print '2- oname: <%r>' % oname # dbg
558 558 except UnicodeEncodeError:
559 559 print 'Python identifiers can only contain ascii characters.'
560 560 return 'not found'
561 561
562 562 info = Struct(self._ofind(oname, namespaces))
563 563
564 564 if info.found:
565 565 try:
566 566 IPython.generics.inspect_object(info.obj)
567 567 return
568 568 except IPython.ipapi.TryNext:
569 569 pass
570 570 # Get the docstring of the class property if it exists.
571 571 path = oname.split('.')
572 572 root = '.'.join(path[:-1])
573 573 if info.parent is not None:
574 574 try:
575 575 target = getattr(info.parent, '__class__')
576 576 # The object belongs to a class instance.
577 577 try:
578 578 target = getattr(target, path[-1])
579 579 # The class defines the object.
580 580 if isinstance(target, property):
581 581 oname = root + '.__class__.' + path[-1]
582 582 info = Struct(self._ofind(oname))
583 583 except AttributeError: pass
584 584 except AttributeError: pass
585 585
586 586 pmethod = getattr(self.shell.inspector,meth)
587 587 formatter = info.ismagic and self.format_screen or None
588 588 if meth == 'pdoc':
589 589 pmethod(info.obj,oname,formatter)
590 590 elif meth == 'pinfo':
591 591 pmethod(info.obj,oname,formatter,info,**kw)
592 592 else:
593 593 pmethod(info.obj,oname)
594 594 else:
595 595 print 'Object `%s` not found.' % oname
596 596 return 'not found' # so callers can take other action
597 597
598 598 def magic_psearch(self, parameter_s=''):
599 599 """Search for object in namespaces by wildcard.
600 600
601 601 %psearch [options] PATTERN [OBJECT TYPE]
602 602
603 603 Note: ? can be used as a synonym for %psearch, at the beginning or at
604 604 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
605 605 rest of the command line must be unchanged (options come first), so
606 606 for example the following forms are equivalent
607 607
608 608 %psearch -i a* function
609 609 -i a* function?
610 610 ?-i a* function
611 611
612 612 Arguments:
613 613
614 614 PATTERN
615 615
616 616 where PATTERN is a string containing * as a wildcard similar to its
617 617 use in a shell. The pattern is matched in all namespaces on the
618 618 search path. By default objects starting with a single _ are not
619 619 matched, many IPython generated objects have a single
620 620 underscore. The default is case insensitive matching. Matching is
621 621 also done on the attributes of objects and not only on the objects
622 622 in a module.
623 623
624 624 [OBJECT TYPE]
625 625
626 626 Is the name of a python type from the types module. The name is
627 627 given in lowercase without the ending type, ex. StringType is
628 628 written string. By adding a type here only objects matching the
629 629 given type are matched. Using all here makes the pattern match all
630 630 types (this is the default).
631 631
632 632 Options:
633 633
634 634 -a: makes the pattern match even objects whose names start with a
635 635 single underscore. These names are normally ommitted from the
636 636 search.
637 637
638 638 -i/-c: make the pattern case insensitive/sensitive. If neither of
639 639 these options is given, the default is read from your ipythonrc
640 640 file. The option name which sets this value is
641 641 'wildcards_case_sensitive'. If this option is not specified in your
642 642 ipythonrc file, IPython's internal default is to do a case sensitive
643 643 search.
644 644
645 645 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
646 646 specifiy can be searched in any of the following namespaces:
647 647 'builtin', 'user', 'user_global','internal', 'alias', where
648 648 'builtin' and 'user' are the search defaults. Note that you should
649 649 not use quotes when specifying namespaces.
650 650
651 651 'Builtin' contains the python module builtin, 'user' contains all
652 652 user data, 'alias' only contain the shell aliases and no python
653 653 objects, 'internal' contains objects used by IPython. The
654 654 'user_global' namespace is only used by embedded IPython instances,
655 655 and it contains module-level globals. You can add namespaces to the
656 656 search with -s or exclude them with -e (these options can be given
657 657 more than once).
658 658
659 659 Examples:
660 660
661 661 %psearch a* -> objects beginning with an a
662 662 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
663 663 %psearch a* function -> all functions beginning with an a
664 664 %psearch re.e* -> objects beginning with an e in module re
665 665 %psearch r*.e* -> objects that start with e in modules starting in r
666 666 %psearch r*.* string -> all strings in modules beginning with r
667 667
668 668 Case sensitve search:
669 669
670 670 %psearch -c a* list all object beginning with lower case a
671 671
672 672 Show objects beginning with a single _:
673 673
674 674 %psearch -a _* list objects beginning with a single underscore"""
675 675 try:
676 676 parameter_s = parameter_s.encode('ascii')
677 677 except UnicodeEncodeError:
678 678 print 'Python identifiers can only contain ascii characters.'
679 679 return
680 680
681 681 # default namespaces to be searched
682 682 def_search = ['user','builtin']
683 683
684 684 # Process options/args
685 685 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
686 686 opt = opts.get
687 687 shell = self.shell
688 688 psearch = shell.inspector.psearch
689 689
690 690 # select case options
691 691 if opts.has_key('i'):
692 692 ignore_case = True
693 693 elif opts.has_key('c'):
694 694 ignore_case = False
695 695 else:
696 696 ignore_case = not shell.rc.wildcards_case_sensitive
697 697
698 698 # Build list of namespaces to search from user options
699 699 def_search.extend(opt('s',[]))
700 700 ns_exclude = ns_exclude=opt('e',[])
701 701 ns_search = [nm for nm in def_search if nm not in ns_exclude]
702 702
703 703 # Call the actual search
704 704 try:
705 705 psearch(args,shell.ns_table,ns_search,
706 706 show_all=opt('a'),ignore_case=ignore_case)
707 707 except:
708 708 shell.showtraceback()
709 709
710 710 def magic_who_ls(self, parameter_s=''):
711 711 """Return a sorted list of all interactive variables.
712 712
713 713 If arguments are given, only variables of types matching these
714 714 arguments are returned."""
715 715
716 716 user_ns = self.shell.user_ns
717 717 internal_ns = self.shell.internal_ns
718 718 user_config_ns = self.shell.user_config_ns
719 719 out = []
720 720 typelist = parameter_s.split()
721 721
722 722 for i in user_ns:
723 723 if not (i.startswith('_') or i.startswith('_i')) \
724 724 and not (i in internal_ns or i in user_config_ns):
725 725 if typelist:
726 726 if type(user_ns[i]).__name__ in typelist:
727 727 out.append(i)
728 728 else:
729 729 out.append(i)
730 730 out.sort()
731 731 return out
732 732
733 733 def magic_who(self, parameter_s=''):
734 734 """Print all interactive variables, with some minimal formatting.
735 735
736 736 If any arguments are given, only variables whose type matches one of
737 737 these are printed. For example:
738 738
739 739 %who function str
740 740
741 741 will only list functions and strings, excluding all other types of
742 742 variables. To find the proper type names, simply use type(var) at a
743 743 command line to see how python prints type names. For example:
744 744
745 745 In [1]: type('hello')\\
746 746 Out[1]: <type 'str'>
747 747
748 748 indicates that the type name for strings is 'str'.
749 749
750 750 %who always excludes executed names loaded through your configuration
751 751 file and things which are internal to IPython.
752 752
753 753 This is deliberate, as typically you may load many modules and the
754 754 purpose of %who is to show you only what you've manually defined."""
755 755
756 756 varlist = self.magic_who_ls(parameter_s)
757 757 if not varlist:
758 758 if parameter_s:
759 759 print 'No variables match your requested type.'
760 760 else:
761 761 print 'Interactive namespace is empty.'
762 762 return
763 763
764 764 # if we have variables, move on...
765 765 count = 0
766 766 for i in varlist:
767 767 print i+'\t',
768 768 count += 1
769 769 if count > 8:
770 770 count = 0
771 771 print
772 772 print
773 773
774 774 def magic_whos(self, parameter_s=''):
775 775 """Like %who, but gives some extra information about each variable.
776 776
777 777 The same type filtering of %who can be applied here.
778 778
779 779 For all variables, the type is printed. Additionally it prints:
780 780
781 781 - For {},[],(): their length.
782 782
783 783 - For numpy and Numeric arrays, a summary with shape, number of
784 784 elements, typecode and size in memory.
785 785
786 786 - Everything else: a string representation, snipping their middle if
787 787 too long."""
788 788
789 789 varnames = self.magic_who_ls(parameter_s)
790 790 if not varnames:
791 791 if parameter_s:
792 792 print 'No variables match your requested type.'
793 793 else:
794 794 print 'Interactive namespace is empty.'
795 795 return
796 796
797 797 # if we have variables, move on...
798 798
799 799 # for these types, show len() instead of data:
800 800 seq_types = [types.DictType,types.ListType,types.TupleType]
801 801
802 802 # for numpy/Numeric arrays, display summary info
803 803 try:
804 804 import numpy
805 805 except ImportError:
806 806 ndarray_type = None
807 807 else:
808 808 ndarray_type = numpy.ndarray.__name__
809 809 try:
810 810 import Numeric
811 811 except ImportError:
812 812 array_type = None
813 813 else:
814 814 array_type = Numeric.ArrayType.__name__
815 815
816 816 # Find all variable names and types so we can figure out column sizes
817 817 def get_vars(i):
818 818 return self.shell.user_ns[i]
819 819
820 820 # some types are well known and can be shorter
821 821 abbrevs = {'IPython.macro.Macro' : 'Macro'}
822 822 def type_name(v):
823 823 tn = type(v).__name__
824 824 return abbrevs.get(tn,tn)
825 825
826 826 varlist = map(get_vars,varnames)
827 827
828 828 typelist = []
829 829 for vv in varlist:
830 830 tt = type_name(vv)
831 831
832 832 if tt=='instance':
833 833 typelist.append( abbrevs.get(str(vv.__class__),
834 834 str(vv.__class__)))
835 835 else:
836 836 typelist.append(tt)
837 837
838 838 # column labels and # of spaces as separator
839 839 varlabel = 'Variable'
840 840 typelabel = 'Type'
841 841 datalabel = 'Data/Info'
842 842 colsep = 3
843 843 # variable format strings
844 844 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
845 845 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
846 846 aformat = "%s: %s elems, type `%s`, %s bytes"
847 847 # find the size of the columns to format the output nicely
848 848 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
849 849 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
850 850 # table header
851 851 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
852 852 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
853 853 # and the table itself
854 854 kb = 1024
855 855 Mb = 1048576 # kb**2
856 856 for vname,var,vtype in zip(varnames,varlist,typelist):
857 857 print itpl(vformat),
858 858 if vtype in seq_types:
859 859 print len(var)
860 860 elif vtype in [array_type,ndarray_type]:
861 861 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
862 862 if vtype==ndarray_type:
863 863 # numpy
864 864 vsize = var.size
865 865 vbytes = vsize*var.itemsize
866 866 vdtype = var.dtype
867 867 else:
868 868 # Numeric
869 869 vsize = Numeric.size(var)
870 870 vbytes = vsize*var.itemsize()
871 871 vdtype = var.typecode()
872 872
873 873 if vbytes < 100000:
874 874 print aformat % (vshape,vsize,vdtype,vbytes)
875 875 else:
876 876 print aformat % (vshape,vsize,vdtype,vbytes),
877 877 if vbytes < Mb:
878 878 print '(%s kb)' % (vbytes/kb,)
879 879 else:
880 880 print '(%s Mb)' % (vbytes/Mb,)
881 881 else:
882 882 try:
883 883 vstr = str(var)
884 884 except UnicodeEncodeError:
885 885 vstr = unicode(var).encode(sys.getdefaultencoding(),
886 886 'backslashreplace')
887 887 vstr = vstr.replace('\n','\\n')
888 888 if len(vstr) < 50:
889 889 print vstr
890 890 else:
891 891 printpl(vfmt_short)
892 892
893 893 def magic_reset(self, parameter_s=''):
894 894 """Resets the namespace by removing all names defined by the user.
895 895
896 896 Input/Output history are left around in case you need them."""
897 897
898 898 ans = self.shell.ask_yes_no(
899 899 "Once deleted, variables cannot be recovered. Proceed (y/[n])? ")
900 900 if not ans:
901 901 print 'Nothing done.'
902 902 return
903 903 user_ns = self.shell.user_ns
904 904 for i in self.magic_who_ls():
905 905 del(user_ns[i])
906 906
907 907 def magic_logstart(self,parameter_s=''):
908 908 """Start logging anywhere in a session.
909 909
910 910 %logstart [-o|-r|-t] [log_name [log_mode]]
911 911
912 912 If no name is given, it defaults to a file named 'ipython_log.py' in your
913 913 current directory, in 'rotate' mode (see below).
914 914
915 915 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
916 916 history up to that point and then continues logging.
917 917
918 918 %logstart takes a second optional parameter: logging mode. This can be one
919 919 of (note that the modes are given unquoted):\\
920 920 append: well, that says it.\\
921 921 backup: rename (if exists) to name~ and start name.\\
922 922 global: single logfile in your home dir, appended to.\\
923 923 over : overwrite existing log.\\
924 924 rotate: create rotating logs name.1~, name.2~, etc.
925 925
926 926 Options:
927 927
928 928 -o: log also IPython's output. In this mode, all commands which
929 929 generate an Out[NN] prompt are recorded to the logfile, right after
930 930 their corresponding input line. The output lines are always
931 931 prepended with a '#[Out]# ' marker, so that the log remains valid
932 932 Python code.
933 933
934 934 Since this marker is always the same, filtering only the output from
935 935 a log is very easy, using for example a simple awk call:
936 936
937 937 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
938 938
939 939 -r: log 'raw' input. Normally, IPython's logs contain the processed
940 940 input, so that user lines are logged in their final form, converted
941 941 into valid Python. For example, %Exit is logged as
942 942 '_ip.magic("Exit"). If the -r flag is given, all input is logged
943 943 exactly as typed, with no transformations applied.
944 944
945 945 -t: put timestamps before each input line logged (these are put in
946 946 comments)."""
947 947
948 948 opts,par = self.parse_options(parameter_s,'ort')
949 949 log_output = 'o' in opts
950 950 log_raw_input = 'r' in opts
951 951 timestamp = 't' in opts
952 952
953 953 rc = self.shell.rc
954 954 logger = self.shell.logger
955 955
956 956 # if no args are given, the defaults set in the logger constructor by
957 957 # ipytohn remain valid
958 958 if par:
959 959 try:
960 960 logfname,logmode = par.split()
961 961 except:
962 962 logfname = par
963 963 logmode = 'backup'
964 964 else:
965 965 logfname = logger.logfname
966 966 logmode = logger.logmode
967 967 # put logfname into rc struct as if it had been called on the command
968 968 # line, so it ends up saved in the log header Save it in case we need
969 969 # to restore it...
970 970 old_logfile = rc.opts.get('logfile','')
971 971 if logfname:
972 972 logfname = os.path.expanduser(logfname)
973 973 rc.opts.logfile = logfname
974 974 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
975 975 try:
976 976 started = logger.logstart(logfname,loghead,logmode,
977 977 log_output,timestamp,log_raw_input)
978 978 except:
979 979 rc.opts.logfile = old_logfile
980 980 warn("Couldn't start log: %s" % sys.exc_info()[1])
981 981 else:
982 982 # log input history up to this point, optionally interleaving
983 983 # output if requested
984 984
985 985 if timestamp:
986 986 # disable timestamping for the previous history, since we've
987 987 # lost those already (no time machine here).
988 988 logger.timestamp = False
989 989
990 990 if log_raw_input:
991 991 input_hist = self.shell.input_hist_raw
992 992 else:
993 993 input_hist = self.shell.input_hist
994 994
995 995 if log_output:
996 996 log_write = logger.log_write
997 997 output_hist = self.shell.output_hist
998 998 for n in range(1,len(input_hist)-1):
999 999 log_write(input_hist[n].rstrip())
1000 1000 if n in output_hist:
1001 1001 log_write(repr(output_hist[n]),'output')
1002 1002 else:
1003 1003 logger.log_write(input_hist[1:])
1004 1004 if timestamp:
1005 1005 # re-enable timestamping
1006 1006 logger.timestamp = True
1007 1007
1008 1008 print ('Activating auto-logging. '
1009 1009 'Current session state plus future input saved.')
1010 1010 logger.logstate()
1011 1011
1012 1012 def magic_logoff(self,parameter_s=''):
1013 1013 """Temporarily stop logging.
1014 1014
1015 1015 You must have previously started logging."""
1016 1016 self.shell.logger.switch_log(0)
1017 1017
1018 1018 def magic_logon(self,parameter_s=''):
1019 1019 """Restart logging.
1020 1020
1021 1021 This function is for restarting logging which you've temporarily
1022 1022 stopped with %logoff. For starting logging for the first time, you
1023 1023 must use the %logstart function, which allows you to specify an
1024 1024 optional log filename."""
1025 1025
1026 1026 self.shell.logger.switch_log(1)
1027 1027
1028 1028 def magic_logstate(self,parameter_s=''):
1029 1029 """Print the status of the logging system."""
1030 1030
1031 1031 self.shell.logger.logstate()
1032 1032
1033 1033 def magic_pdb(self, parameter_s=''):
1034 1034 """Control the automatic calling of the pdb interactive debugger.
1035 1035
1036 1036 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1037 1037 argument it works as a toggle.
1038 1038
1039 1039 When an exception is triggered, IPython can optionally call the
1040 1040 interactive pdb debugger after the traceback printout. %pdb toggles
1041 1041 this feature on and off.
1042 1042
1043 1043 The initial state of this feature is set in your ipythonrc
1044 1044 configuration file (the variable is called 'pdb').
1045 1045
1046 1046 If you want to just activate the debugger AFTER an exception has fired,
1047 1047 without having to type '%pdb on' and rerunning your code, you can use
1048 1048 the %debug magic."""
1049 1049
1050 1050 par = parameter_s.strip().lower()
1051 1051
1052 1052 if par:
1053 1053 try:
1054 1054 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1055 1055 except KeyError:
1056 1056 print ('Incorrect argument. Use on/1, off/0, '
1057 1057 'or nothing for a toggle.')
1058 1058 return
1059 1059 else:
1060 1060 # toggle
1061 1061 new_pdb = not self.shell.call_pdb
1062 1062
1063 1063 # set on the shell
1064 1064 self.shell.call_pdb = new_pdb
1065 1065 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1066 1066
1067 1067 def magic_debug(self, parameter_s=''):
1068 1068 """Activate the interactive debugger in post-mortem mode.
1069 1069
1070 1070 If an exception has just occurred, this lets you inspect its stack
1071 1071 frames interactively. Note that this will always work only on the last
1072 1072 traceback that occurred, so you must call this quickly after an
1073 1073 exception that you wish to inspect has fired, because if another one
1074 1074 occurs, it clobbers the previous one.
1075 1075
1076 1076 If you want IPython to automatically do this on every exception, see
1077 1077 the %pdb magic for more details.
1078 1078 """
1079 1079
1080 1080 self.shell.debugger(force=True)
1081 1081
1082 1082 def magic_prun(self, parameter_s ='',user_mode=1,
1083 1083 opts=None,arg_lst=None,prog_ns=None):
1084 1084
1085 1085 """Run a statement through the python code profiler.
1086 1086
1087 1087 Usage:\\
1088 1088 %prun [options] statement
1089 1089
1090 1090 The given statement (which doesn't require quote marks) is run via the
1091 1091 python profiler in a manner similar to the profile.run() function.
1092 1092 Namespaces are internally managed to work correctly; profile.run
1093 1093 cannot be used in IPython because it makes certain assumptions about
1094 1094 namespaces which do not hold under IPython.
1095 1095
1096 1096 Options:
1097 1097
1098 1098 -l <limit>: you can place restrictions on what or how much of the
1099 1099 profile gets printed. The limit value can be:
1100 1100
1101 1101 * A string: only information for function names containing this string
1102 1102 is printed.
1103 1103
1104 1104 * An integer: only these many lines are printed.
1105 1105
1106 1106 * A float (between 0 and 1): this fraction of the report is printed
1107 1107 (for example, use a limit of 0.4 to see the topmost 40% only).
1108 1108
1109 1109 You can combine several limits with repeated use of the option. For
1110 1110 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1111 1111 information about class constructors.
1112 1112
1113 1113 -r: return the pstats.Stats object generated by the profiling. This
1114 1114 object has all the information about the profile in it, and you can
1115 1115 later use it for further analysis or in other functions.
1116 1116
1117 1117 -s <key>: sort profile by given key. You can provide more than one key
1118 1118 by using the option several times: '-s key1 -s key2 -s key3...'. The
1119 1119 default sorting key is 'time'.
1120 1120
1121 1121 The following is copied verbatim from the profile documentation
1122 1122 referenced below:
1123 1123
1124 1124 When more than one key is provided, additional keys are used as
1125 1125 secondary criteria when the there is equality in all keys selected
1126 1126 before them.
1127 1127
1128 1128 Abbreviations can be used for any key names, as long as the
1129 1129 abbreviation is unambiguous. The following are the keys currently
1130 1130 defined:
1131 1131
1132 1132 Valid Arg Meaning\\
1133 1133 "calls" call count\\
1134 1134 "cumulative" cumulative time\\
1135 1135 "file" file name\\
1136 1136 "module" file name\\
1137 1137 "pcalls" primitive call count\\
1138 1138 "line" line number\\
1139 1139 "name" function name\\
1140 1140 "nfl" name/file/line\\
1141 1141 "stdname" standard name\\
1142 1142 "time" internal time
1143 1143
1144 1144 Note that all sorts on statistics are in descending order (placing
1145 1145 most time consuming items first), where as name, file, and line number
1146 1146 searches are in ascending order (i.e., alphabetical). The subtle
1147 1147 distinction between "nfl" and "stdname" is that the standard name is a
1148 1148 sort of the name as printed, which means that the embedded line
1149 1149 numbers get compared in an odd way. For example, lines 3, 20, and 40
1150 1150 would (if the file names were the same) appear in the string order
1151 1151 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1152 1152 line numbers. In fact, sort_stats("nfl") is the same as
1153 1153 sort_stats("name", "file", "line").
1154 1154
1155 1155 -T <filename>: save profile results as shown on screen to a text
1156 1156 file. The profile is still shown on screen.
1157 1157
1158 1158 -D <filename>: save (via dump_stats) profile statistics to given
1159 1159 filename. This data is in a format understod by the pstats module, and
1160 1160 is generated by a call to the dump_stats() method of profile
1161 1161 objects. The profile is still shown on screen.
1162 1162
1163 1163 If you want to run complete programs under the profiler's control, use
1164 1164 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1165 1165 contains profiler specific options as described here.
1166 1166
1167 1167 You can read the complete documentation for the profile module with:\\
1168 1168 In [1]: import profile; profile.help() """
1169 1169
1170 1170 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1171 1171 # protect user quote marks
1172 1172 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1173 1173
1174 1174 if user_mode: # regular user call
1175 1175 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1176 1176 list_all=1)
1177 1177 namespace = self.shell.user_ns
1178 1178 else: # called to run a program by %run -p
1179 1179 try:
1180 1180 filename = get_py_filename(arg_lst[0])
1181 1181 except IOError,msg:
1182 1182 error(msg)
1183 1183 return
1184 1184
1185 1185 arg_str = 'execfile(filename,prog_ns)'
1186 1186 namespace = locals()
1187 1187
1188 1188 opts.merge(opts_def)
1189 1189
1190 1190 prof = profile.Profile()
1191 1191 try:
1192 1192 prof = prof.runctx(arg_str,namespace,namespace)
1193 1193 sys_exit = ''
1194 1194 except SystemExit:
1195 1195 sys_exit = """*** SystemExit exception caught in code being profiled."""
1196 1196
1197 1197 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1198 1198
1199 1199 lims = opts.l
1200 1200 if lims:
1201 1201 lims = [] # rebuild lims with ints/floats/strings
1202 1202 for lim in opts.l:
1203 1203 try:
1204 1204 lims.append(int(lim))
1205 1205 except ValueError:
1206 1206 try:
1207 1207 lims.append(float(lim))
1208 1208 except ValueError:
1209 1209 lims.append(lim)
1210 1210
1211 1211 # Trap output.
1212 1212 stdout_trap = StringIO()
1213 1213
1214 1214 if hasattr(stats,'stream'):
1215 1215 # In newer versions of python, the stats object has a 'stream'
1216 1216 # attribute to write into.
1217 1217 stats.stream = stdout_trap
1218 1218 stats.print_stats(*lims)
1219 1219 else:
1220 1220 # For older versions, we manually redirect stdout during printing
1221 1221 sys_stdout = sys.stdout
1222 1222 try:
1223 1223 sys.stdout = stdout_trap
1224 1224 stats.print_stats(*lims)
1225 1225 finally:
1226 1226 sys.stdout = sys_stdout
1227 1227
1228 1228 output = stdout_trap.getvalue()
1229 1229 output = output.rstrip()
1230 1230
1231 1231 page(output,screen_lines=self.shell.rc.screen_length)
1232 1232 print sys_exit,
1233 1233
1234 1234 dump_file = opts.D[0]
1235 1235 text_file = opts.T[0]
1236 1236 if dump_file:
1237 1237 prof.dump_stats(dump_file)
1238 1238 print '\n*** Profile stats marshalled to file',\
1239 1239 `dump_file`+'.',sys_exit
1240 1240 if text_file:
1241 1241 pfile = file(text_file,'w')
1242 1242 pfile.write(output)
1243 1243 pfile.close()
1244 1244 print '\n*** Profile printout saved to text file',\
1245 1245 `text_file`+'.',sys_exit
1246 1246
1247 1247 if opts.has_key('r'):
1248 1248 return stats
1249 1249 else:
1250 1250 return None
1251 1251
1252 1252 def magic_run(self, parameter_s ='',runner=None):
1253 1253 """Run the named file inside IPython as a program.
1254 1254
1255 1255 Usage:\\
1256 1256 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1257 1257
1258 1258 Parameters after the filename are passed as command-line arguments to
1259 1259 the program (put in sys.argv). Then, control returns to IPython's
1260 1260 prompt.
1261 1261
1262 1262 This is similar to running at a system prompt:\\
1263 1263 $ python file args\\
1264 1264 but with the advantage of giving you IPython's tracebacks, and of
1265 1265 loading all variables into your interactive namespace for further use
1266 1266 (unless -p is used, see below).
1267 1267
1268 1268 The file is executed in a namespace initially consisting only of
1269 1269 __name__=='__main__' and sys.argv constructed as indicated. It thus
1270 1270 sees its environment as if it were being run as a stand-alone
1271 1271 program. But after execution, the IPython interactive namespace gets
1272 1272 updated with all variables defined in the program (except for __name__
1273 1273 and sys.argv). This allows for very convenient loading of code for
1274 1274 interactive work, while giving each program a 'clean sheet' to run in.
1275 1275
1276 1276 Options:
1277 1277
1278 1278 -n: __name__ is NOT set to '__main__', but to the running file's name
1279 1279 without extension (as python does under import). This allows running
1280 1280 scripts and reloading the definitions in them without calling code
1281 1281 protected by an ' if __name__ == "__main__" ' clause.
1282 1282
1283 1283 -i: run the file in IPython's namespace instead of an empty one. This
1284 1284 is useful if you are experimenting with code written in a text editor
1285 1285 which depends on variables defined interactively.
1286 1286
1287 1287 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1288 1288 being run. This is particularly useful if IPython is being used to
1289 1289 run unittests, which always exit with a sys.exit() call. In such
1290 1290 cases you are interested in the output of the test results, not in
1291 1291 seeing a traceback of the unittest module.
1292 1292
1293 1293 -t: print timing information at the end of the run. IPython will give
1294 1294 you an estimated CPU time consumption for your script, which under
1295 1295 Unix uses the resource module to avoid the wraparound problems of
1296 1296 time.clock(). Under Unix, an estimate of time spent on system tasks
1297 1297 is also given (for Windows platforms this is reported as 0.0).
1298 1298
1299 1299 If -t is given, an additional -N<N> option can be given, where <N>
1300 1300 must be an integer indicating how many times you want the script to
1301 1301 run. The final timing report will include total and per run results.
1302 1302
1303 1303 For example (testing the script uniq_stable.py):
1304 1304
1305 1305 In [1]: run -t uniq_stable
1306 1306
1307 1307 IPython CPU timings (estimated):\\
1308 1308 User : 0.19597 s.\\
1309 1309 System: 0.0 s.\\
1310 1310
1311 1311 In [2]: run -t -N5 uniq_stable
1312 1312
1313 1313 IPython CPU timings (estimated):\\
1314 1314 Total runs performed: 5\\
1315 1315 Times : Total Per run\\
1316 1316 User : 0.910862 s, 0.1821724 s.\\
1317 1317 System: 0.0 s, 0.0 s.
1318 1318
1319 1319 -d: run your program under the control of pdb, the Python debugger.
1320 1320 This allows you to execute your program step by step, watch variables,
1321 1321 etc. Internally, what IPython does is similar to calling:
1322 1322
1323 1323 pdb.run('execfile("YOURFILENAME")')
1324 1324
1325 1325 with a breakpoint set on line 1 of your file. You can change the line
1326 1326 number for this automatic breakpoint to be <N> by using the -bN option
1327 1327 (where N must be an integer). For example:
1328 1328
1329 1329 %run -d -b40 myscript
1330 1330
1331 1331 will set the first breakpoint at line 40 in myscript.py. Note that
1332 1332 the first breakpoint must be set on a line which actually does
1333 1333 something (not a comment or docstring) for it to stop execution.
1334 1334
1335 1335 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1336 1336 first enter 'c' (without qoutes) to start execution up to the first
1337 1337 breakpoint.
1338 1338
1339 1339 Entering 'help' gives information about the use of the debugger. You
1340 1340 can easily see pdb's full documentation with "import pdb;pdb.help()"
1341 1341 at a prompt.
1342 1342
1343 1343 -p: run program under the control of the Python profiler module (which
1344 1344 prints a detailed report of execution times, function calls, etc).
1345 1345
1346 1346 You can pass other options after -p which affect the behavior of the
1347 1347 profiler itself. See the docs for %prun for details.
1348 1348
1349 1349 In this mode, the program's variables do NOT propagate back to the
1350 1350 IPython interactive namespace (because they remain in the namespace
1351 1351 where the profiler executes them).
1352 1352
1353 1353 Internally this triggers a call to %prun, see its documentation for
1354 1354 details on the options available specifically for profiling.
1355 1355
1356 1356 There is one special usage for which the text above doesn't apply:
1357 1357 if the filename ends with .ipy, the file is run as ipython script,
1358 1358 just as if the commands were written on IPython prompt.
1359 1359 """
1360 1360
1361 1361 # get arguments and set sys.argv for program to be run.
1362 1362 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1363 1363 mode='list',list_all=1)
1364 1364
1365 1365 try:
1366 1366 filename = get_py_filename(arg_lst[0])
1367 1367 except IndexError:
1368 1368 warn('you must provide at least a filename.')
1369 1369 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1370 1370 return
1371 1371 except IOError,msg:
1372 1372 error(msg)
1373 1373 return
1374 1374
1375 1375 if filename.lower().endswith('.ipy'):
1376 1376 self.api.runlines(open(filename).read())
1377 1377 return
1378 1378
1379 1379 # Control the response to exit() calls made by the script being run
1380 1380 exit_ignore = opts.has_key('e')
1381 1381
1382 1382 # Make sure that the running script gets a proper sys.argv as if it
1383 1383 # were run from a system shell.
1384 1384 save_argv = sys.argv # save it for later restoring
1385 1385 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1386 1386
1387 1387 if opts.has_key('i'):
1388 1388 prog_ns = self.shell.user_ns
1389 1389 __name__save = self.shell.user_ns['__name__']
1390 1390 prog_ns['__name__'] = '__main__'
1391 1391 else:
1392 1392 if opts.has_key('n'):
1393 1393 name = os.path.splitext(os.path.basename(filename))[0]
1394 1394 else:
1395 1395 name = '__main__'
1396 1396 prog_ns = {'__name__':name}
1397 1397
1398 1398 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
1399 1399 # set the __file__ global in the script's namespace
1400 1400 prog_ns['__file__'] = filename
1401 1401
1402 1402 # pickle fix. See iplib for an explanation. But we need to make sure
1403 1403 # that, if we overwrite __main__, we replace it at the end
1404 1404 if prog_ns['__name__'] == '__main__':
1405 1405 restore_main = sys.modules['__main__']
1406 1406 else:
1407 1407 restore_main = False
1408 1408
1409 1409 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1410 1410
1411 1411 stats = None
1412 1412 try:
1413 1413 if self.shell.has_readline:
1414 1414 self.shell.savehist()
1415 1415
1416 1416 if opts.has_key('p'):
1417 1417 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1418 1418 else:
1419 1419 if opts.has_key('d'):
1420 1420 deb = Debugger.Pdb(self.shell.rc.colors)
1421 1421 # reset Breakpoint state, which is moronically kept
1422 1422 # in a class
1423 1423 bdb.Breakpoint.next = 1
1424 1424 bdb.Breakpoint.bplist = {}
1425 1425 bdb.Breakpoint.bpbynumber = [None]
1426 1426 # Set an initial breakpoint to stop execution
1427 1427 maxtries = 10
1428 1428 bp = int(opts.get('b',[1])[0])
1429 1429 checkline = deb.checkline(filename,bp)
1430 1430 if not checkline:
1431 1431 for bp in range(bp+1,bp+maxtries+1):
1432 1432 if deb.checkline(filename,bp):
1433 1433 break
1434 1434 else:
1435 1435 msg = ("\nI failed to find a valid line to set "
1436 1436 "a breakpoint\n"
1437 1437 "after trying up to line: %s.\n"
1438 1438 "Please set a valid breakpoint manually "
1439 1439 "with the -b option." % bp)
1440 1440 error(msg)
1441 1441 return
1442 1442 # if we find a good linenumber, set the breakpoint
1443 1443 deb.do_break('%s:%s' % (filename,bp))
1444 1444 # Start file run
1445 1445 print "NOTE: Enter 'c' at the",
1446 1446 print "%s prompt to start your script." % deb.prompt
1447 1447 try:
1448 1448 deb.run('execfile("%s")' % filename,prog_ns)
1449 1449
1450 1450 except:
1451 1451 etype, value, tb = sys.exc_info()
1452 1452 # Skip three frames in the traceback: the %run one,
1453 1453 # one inside bdb.py, and the command-line typed by the
1454 1454 # user (run by exec in pdb itself).
1455 1455 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1456 1456 else:
1457 1457 if runner is None:
1458 1458 runner = self.shell.safe_execfile
1459 1459 if opts.has_key('t'):
1460 1460 try:
1461 1461 nruns = int(opts['N'][0])
1462 1462 if nruns < 1:
1463 1463 error('Number of runs must be >=1')
1464 1464 return
1465 1465 except (KeyError):
1466 1466 nruns = 1
1467 1467 if nruns == 1:
1468 1468 t0 = clock2()
1469 1469 runner(filename,prog_ns,prog_ns,
1470 1470 exit_ignore=exit_ignore)
1471 1471 t1 = clock2()
1472 1472 t_usr = t1[0]-t0[0]
1473 1473 t_sys = t1[1]-t1[1]
1474 1474 print "\nIPython CPU timings (estimated):"
1475 1475 print " User : %10s s." % t_usr
1476 1476 print " System: %10s s." % t_sys
1477 1477 else:
1478 1478 runs = range(nruns)
1479 1479 t0 = clock2()
1480 1480 for nr in runs:
1481 1481 runner(filename,prog_ns,prog_ns,
1482 1482 exit_ignore=exit_ignore)
1483 1483 t1 = clock2()
1484 1484 t_usr = t1[0]-t0[0]
1485 1485 t_sys = t1[1]-t1[1]
1486 1486 print "\nIPython CPU timings (estimated):"
1487 1487 print "Total runs performed:",nruns
1488 1488 print " Times : %10s %10s" % ('Total','Per run')
1489 1489 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1490 1490 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1491 1491
1492 1492 else:
1493 1493 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1494 1494 if opts.has_key('i'):
1495 1495 self.shell.user_ns['__name__'] = __name__save
1496 1496 else:
1497 1497 # update IPython interactive namespace
1498 1498 del prog_ns['__name__']
1499 1499 self.shell.user_ns.update(prog_ns)
1500 1500 finally:
1501 1501 sys.argv = save_argv
1502 1502 if restore_main:
1503 1503 sys.modules['__main__'] = restore_main
1504 1504 self.shell.reloadhist()
1505 1505
1506 1506 return stats
1507 1507
1508 1508 def magic_runlog(self, parameter_s =''):
1509 1509 """Run files as logs.
1510 1510
1511 1511 Usage:\\
1512 1512 %runlog file1 file2 ...
1513 1513
1514 1514 Run the named files (treating them as log files) in sequence inside
1515 1515 the interpreter, and return to the prompt. This is much slower than
1516 1516 %run because each line is executed in a try/except block, but it
1517 1517 allows running files with syntax errors in them.
1518 1518
1519 1519 Normally IPython will guess when a file is one of its own logfiles, so
1520 1520 you can typically use %run even for logs. This shorthand allows you to
1521 1521 force any file to be treated as a log file."""
1522 1522
1523 1523 for f in parameter_s.split():
1524 1524 self.shell.safe_execfile(f,self.shell.user_ns,
1525 1525 self.shell.user_ns,islog=1)
1526 1526
1527 1527 def magic_timeit(self, parameter_s =''):
1528 1528 """Time execution of a Python statement or expression
1529 1529
1530 1530 Usage:\\
1531 1531 %timeit [-n<N> -r<R> [-t|-c]] statement
1532 1532
1533 1533 Time execution of a Python statement or expression using the timeit
1534 1534 module.
1535 1535
1536 1536 Options:
1537 1537 -n<N>: execute the given statement <N> times in a loop. If this value
1538 1538 is not given, a fitting value is chosen.
1539 1539
1540 1540 -r<R>: repeat the loop iteration <R> times and take the best result.
1541 1541 Default: 3
1542 1542
1543 1543 -t: use time.time to measure the time, which is the default on Unix.
1544 1544 This function measures wall time.
1545 1545
1546 1546 -c: use time.clock to measure the time, which is the default on
1547 1547 Windows and measures wall time. On Unix, resource.getrusage is used
1548 1548 instead and returns the CPU user time.
1549 1549
1550 1550 -p<P>: use a precision of <P> digits to display the timing result.
1551 1551 Default: 3
1552 1552
1553 1553
1554 1554 Examples:\\
1555 1555 In [1]: %timeit pass
1556 1556 10000000 loops, best of 3: 53.3 ns per loop
1557 1557
1558 1558 In [2]: u = None
1559 1559
1560 1560 In [3]: %timeit u is None
1561 1561 10000000 loops, best of 3: 184 ns per loop
1562 1562
1563 1563 In [4]: %timeit -r 4 u == None
1564 1564 1000000 loops, best of 4: 242 ns per loop
1565 1565
1566 1566 In [5]: import time
1567 1567
1568 1568 In [6]: %timeit -n1 time.sleep(2)
1569 1569 1 loops, best of 3: 2 s per loop
1570 1570
1571 1571
1572 1572 The times reported by %timeit will be slightly higher than those
1573 1573 reported by the timeit.py script when variables are accessed. This is
1574 1574 due to the fact that %timeit executes the statement in the namespace
1575 1575 of the shell, compared with timeit.py, which uses a single setup
1576 1576 statement to import function or create variables. Generally, the bias
1577 1577 does not matter as long as results from timeit.py are not mixed with
1578 1578 those from %timeit."""
1579 1579
1580 1580 import timeit
1581 1581 import math
1582 1582
1583 1583 units = ["s", "ms", "\xc2\xb5s", "ns"]
1584 1584 scaling = [1, 1e3, 1e6, 1e9]
1585 1585
1586 1586 opts, stmt = self.parse_options(parameter_s,'n:r:tcp:',
1587 1587 posix=False)
1588 1588 if stmt == "":
1589 1589 return
1590 1590 timefunc = timeit.default_timer
1591 1591 number = int(getattr(opts, "n", 0))
1592 1592 repeat = int(getattr(opts, "r", timeit.default_repeat))
1593 1593 precision = int(getattr(opts, "p", 3))
1594 1594 if hasattr(opts, "t"):
1595 1595 timefunc = time.time
1596 1596 if hasattr(opts, "c"):
1597 1597 timefunc = clock
1598 1598
1599 1599 timer = timeit.Timer(timer=timefunc)
1600 1600 # this code has tight coupling to the inner workings of timeit.Timer,
1601 1601 # but is there a better way to achieve that the code stmt has access
1602 1602 # to the shell namespace?
1603 1603
1604 1604 src = timeit.template % {'stmt': timeit.reindent(stmt, 8),
1605 1605 'setup': "pass"}
1606 1606 code = compile(src, "<magic-timeit>", "exec")
1607 1607 ns = {}
1608 1608 exec code in self.shell.user_ns, ns
1609 1609 timer.inner = ns["inner"]
1610 1610
1611 1611 if number == 0:
1612 1612 # determine number so that 0.2 <= total time < 2.0
1613 1613 number = 1
1614 1614 for i in range(1, 10):
1615 1615 number *= 10
1616 1616 if timer.timeit(number) >= 0.2:
1617 1617 break
1618 1618
1619 1619 best = min(timer.repeat(repeat, number)) / number
1620 1620
1621 1621 if best > 0.0:
1622 1622 order = min(-int(math.floor(math.log10(best)) // 3), 3)
1623 1623 else:
1624 1624 order = 3
1625 1625 print "%d loops, best of %d: %.*g %s per loop" % (number, repeat,
1626 1626 precision,
1627 1627 best * scaling[order],
1628 1628 units[order])
1629 1629
1630 1630 def magic_time(self,parameter_s = ''):
1631 1631 """Time execution of a Python statement or expression.
1632 1632
1633 1633 The CPU and wall clock times are printed, and the value of the
1634 1634 expression (if any) is returned. Note that under Win32, system time
1635 1635 is always reported as 0, since it can not be measured.
1636 1636
1637 1637 This function provides very basic timing functionality. In Python
1638 1638 2.3, the timeit module offers more control and sophistication, so this
1639 1639 could be rewritten to use it (patches welcome).
1640 1640
1641 1641 Some examples:
1642 1642
1643 1643 In [1]: time 2**128
1644 1644 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1645 1645 Wall time: 0.00
1646 1646 Out[1]: 340282366920938463463374607431768211456L
1647 1647
1648 1648 In [2]: n = 1000000
1649 1649
1650 1650 In [3]: time sum(range(n))
1651 1651 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1652 1652 Wall time: 1.37
1653 1653 Out[3]: 499999500000L
1654 1654
1655 1655 In [4]: time print 'hello world'
1656 1656 hello world
1657 1657 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1658 1658 Wall time: 0.00
1659 1659 """
1660 1660
1661 1661 # fail immediately if the given expression can't be compiled
1662 1662 try:
1663 1663 mode = 'eval'
1664 1664 code = compile(parameter_s,'<timed eval>',mode)
1665 1665 except SyntaxError:
1666 1666 mode = 'exec'
1667 1667 code = compile(parameter_s,'<timed exec>',mode)
1668 1668 # skew measurement as little as possible
1669 1669 glob = self.shell.user_ns
1670 1670 clk = clock2
1671 1671 wtime = time.time
1672 1672 # time execution
1673 1673 wall_st = wtime()
1674 1674 if mode=='eval':
1675 1675 st = clk()
1676 1676 out = eval(code,glob)
1677 1677 end = clk()
1678 1678 else:
1679 1679 st = clk()
1680 1680 exec code in glob
1681 1681 end = clk()
1682 1682 out = None
1683 1683 wall_end = wtime()
1684 1684 # Compute actual times and report
1685 1685 wall_time = wall_end-wall_st
1686 1686 cpu_user = end[0]-st[0]
1687 1687 cpu_sys = end[1]-st[1]
1688 1688 cpu_tot = cpu_user+cpu_sys
1689 1689 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1690 1690 (cpu_user,cpu_sys,cpu_tot)
1691 1691 print "Wall time: %.2f" % wall_time
1692 1692 return out
1693 1693
1694 1694 def magic_macro(self,parameter_s = ''):
1695 1695 """Define a set of input lines as a macro for future re-execution.
1696 1696
1697 1697 Usage:\\
1698 1698 %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...
1699 1699
1700 1700 Options:
1701 1701
1702 1702 -r: use 'raw' input. By default, the 'processed' history is used,
1703 1703 so that magics are loaded in their transformed version to valid
1704 1704 Python. If this option is given, the raw input as typed as the
1705 1705 command line is used instead.
1706 1706
1707 1707 This will define a global variable called `name` which is a string
1708 1708 made of joining the slices and lines you specify (n1,n2,... numbers
1709 1709 above) from your input history into a single string. This variable
1710 1710 acts like an automatic function which re-executes those lines as if
1711 1711 you had typed them. You just type 'name' at the prompt and the code
1712 1712 executes.
1713 1713
1714 1714 The notation for indicating number ranges is: n1-n2 means 'use line
1715 1715 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1716 1716 using the lines numbered 5,6 and 7.
1717 1717
1718 1718 Note: as a 'hidden' feature, you can also use traditional python slice
1719 1719 notation, where N:M means numbers N through M-1.
1720 1720
1721 1721 For example, if your history contains (%hist prints it):
1722 1722
1723 1723 44: x=1\\
1724 1724 45: y=3\\
1725 1725 46: z=x+y\\
1726 1726 47: print x\\
1727 1727 48: a=5\\
1728 1728 49: print 'x',x,'y',y\\
1729 1729
1730 1730 you can create a macro with lines 44 through 47 (included) and line 49
1731 1731 called my_macro with:
1732 1732
1733 1733 In [51]: %macro my_macro 44-47 49
1734 1734
1735 1735 Now, typing `my_macro` (without quotes) will re-execute all this code
1736 1736 in one pass.
1737 1737
1738 1738 You don't need to give the line-numbers in order, and any given line
1739 1739 number can appear multiple times. You can assemble macros with any
1740 1740 lines from your input history in any order.
1741 1741
1742 1742 The macro is a simple object which holds its value in an attribute,
1743 1743 but IPython's display system checks for macros and executes them as
1744 1744 code instead of printing them when you type their name.
1745 1745
1746 1746 You can view a macro's contents by explicitly printing it with:
1747 1747
1748 1748 'print macro_name'.
1749 1749
1750 1750 For one-off cases which DON'T contain magic function calls in them you
1751 1751 can obtain similar results by explicitly executing slices from your
1752 1752 input history with:
1753 1753
1754 1754 In [60]: exec In[44:48]+In[49]"""
1755 1755
1756 1756 opts,args = self.parse_options(parameter_s,'r',mode='list')
1757 1757 if not args:
1758 1758 macs = [k for k,v in self.shell.user_ns.items() if isinstance(v, Macro)]
1759 1759 macs.sort()
1760 1760 return macs
1761 1761 name,ranges = args[0], args[1:]
1762 1762 #print 'rng',ranges # dbg
1763 1763 lines = self.extract_input_slices(ranges,opts.has_key('r'))
1764 1764 macro = Macro(lines)
1765 1765 self.shell.user_ns.update({name:macro})
1766 1766 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1767 1767 print 'Macro contents:'
1768 1768 print macro,
1769 1769
1770 1770 def magic_save(self,parameter_s = ''):
1771 1771 """Save a set of lines to a given filename.
1772 1772
1773 1773 Usage:\\
1774 1774 %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...
1775 1775
1776 1776 Options:
1777 1777
1778 1778 -r: use 'raw' input. By default, the 'processed' history is used,
1779 1779 so that magics are loaded in their transformed version to valid
1780 1780 Python. If this option is given, the raw input as typed as the
1781 1781 command line is used instead.
1782 1782
1783 1783 This function uses the same syntax as %macro for line extraction, but
1784 1784 instead of creating a macro it saves the resulting string to the
1785 1785 filename you specify.
1786 1786
1787 1787 It adds a '.py' extension to the file if you don't do so yourself, and
1788 1788 it asks for confirmation before overwriting existing files."""
1789 1789
1790 1790 opts,args = self.parse_options(parameter_s,'r',mode='list')
1791 1791 fname,ranges = args[0], args[1:]
1792 1792 if not fname.endswith('.py'):
1793 1793 fname += '.py'
1794 1794 if os.path.isfile(fname):
1795 1795 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1796 1796 if ans.lower() not in ['y','yes']:
1797 1797 print 'Operation cancelled.'
1798 1798 return
1799 1799 cmds = ''.join(self.extract_input_slices(ranges,opts.has_key('r')))
1800 1800 f = file(fname,'w')
1801 1801 f.write(cmds)
1802 1802 f.close()
1803 1803 print 'The following commands were written to file `%s`:' % fname
1804 1804 print cmds
1805 1805
1806 1806 def _edit_macro(self,mname,macro):
1807 1807 """open an editor with the macro data in a file"""
1808 1808 filename = self.shell.mktempfile(macro.value)
1809 1809 self.shell.hooks.editor(filename)
1810 1810
1811 1811 # and make a new macro object, to replace the old one
1812 1812 mfile = open(filename)
1813 1813 mvalue = mfile.read()
1814 1814 mfile.close()
1815 1815 self.shell.user_ns[mname] = Macro(mvalue)
1816 1816
1817 1817 def magic_ed(self,parameter_s=''):
1818 1818 """Alias to %edit."""
1819 1819 return self.magic_edit(parameter_s)
1820 1820
1821 1821 def magic_edit(self,parameter_s='',last_call=['','']):
1822 1822 """Bring up an editor and execute the resulting code.
1823 1823
1824 1824 Usage:
1825 1825 %edit [options] [args]
1826 1826
1827 1827 %edit runs IPython's editor hook. The default version of this hook is
1828 1828 set to call the __IPYTHON__.rc.editor command. This is read from your
1829 1829 environment variable $EDITOR. If this isn't found, it will default to
1830 1830 vi under Linux/Unix and to notepad under Windows. See the end of this
1831 1831 docstring for how to change the editor hook.
1832 1832
1833 1833 You can also set the value of this editor via the command line option
1834 1834 '-editor' or in your ipythonrc file. This is useful if you wish to use
1835 1835 specifically for IPython an editor different from your typical default
1836 1836 (and for Windows users who typically don't set environment variables).
1837 1837
1838 1838 This command allows you to conveniently edit multi-line code right in
1839 1839 your IPython session.
1840 1840
1841 1841 If called without arguments, %edit opens up an empty editor with a
1842 1842 temporary file and will execute the contents of this file when you
1843 1843 close it (don't forget to save it!).
1844 1844
1845 1845
1846 1846 Options:
1847 1847
1848 1848 -n <number>: open the editor at a specified line number. By default,
1849 1849 the IPython editor hook uses the unix syntax 'editor +N filename', but
1850 1850 you can configure this by providing your own modified hook if your
1851 1851 favorite editor supports line-number specifications with a different
1852 1852 syntax.
1853 1853
1854 1854 -p: this will call the editor with the same data as the previous time
1855 1855 it was used, regardless of how long ago (in your current session) it
1856 1856 was.
1857 1857
1858 1858 -r: use 'raw' input. This option only applies to input taken from the
1859 1859 user's history. By default, the 'processed' history is used, so that
1860 1860 magics are loaded in their transformed version to valid Python. If
1861 1861 this option is given, the raw input as typed as the command line is
1862 1862 used instead. When you exit the editor, it will be executed by
1863 1863 IPython's own processor.
1864 1864
1865 1865 -x: do not execute the edited code immediately upon exit. This is
1866 1866 mainly useful if you are editing programs which need to be called with
1867 1867 command line arguments, which you can then do using %run.
1868 1868
1869 1869
1870 1870 Arguments:
1871 1871
1872 1872 If arguments are given, the following possibilites exist:
1873 1873
1874 1874 - The arguments are numbers or pairs of colon-separated numbers (like
1875 1875 1 4:8 9). These are interpreted as lines of previous input to be
1876 1876 loaded into the editor. The syntax is the same of the %macro command.
1877 1877
1878 1878 - If the argument doesn't start with a number, it is evaluated as a
1879 1879 variable and its contents loaded into the editor. You can thus edit
1880 1880 any string which contains python code (including the result of
1881 1881 previous edits).
1882 1882
1883 1883 - If the argument is the name of an object (other than a string),
1884 1884 IPython will try to locate the file where it was defined and open the
1885 1885 editor at the point where it is defined. You can use `%edit function`
1886 1886 to load an editor exactly at the point where 'function' is defined,
1887 1887 edit it and have the file be executed automatically.
1888 1888
1889 1889 If the object is a macro (see %macro for details), this opens up your
1890 1890 specified editor with a temporary file containing the macro's data.
1891 1891 Upon exit, the macro is reloaded with the contents of the file.
1892 1892
1893 1893 Note: opening at an exact line is only supported under Unix, and some
1894 1894 editors (like kedit and gedit up to Gnome 2.8) do not understand the
1895 1895 '+NUMBER' parameter necessary for this feature. Good editors like
1896 1896 (X)Emacs, vi, jed, pico and joe all do.
1897 1897
1898 1898 - If the argument is not found as a variable, IPython will look for a
1899 1899 file with that name (adding .py if necessary) and load it into the
1900 1900 editor. It will execute its contents with execfile() when you exit,
1901 1901 loading any code in the file into your interactive namespace.
1902 1902
1903 1903 After executing your code, %edit will return as output the code you
1904 1904 typed in the editor (except when it was an existing file). This way
1905 1905 you can reload the code in further invocations of %edit as a variable,
1906 1906 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
1907 1907 the output.
1908 1908
1909 1909 Note that %edit is also available through the alias %ed.
1910 1910
1911 1911 This is an example of creating a simple function inside the editor and
1912 1912 then modifying it. First, start up the editor:
1913 1913
1914 1914 In [1]: ed\\
1915 1915 Editing... done. Executing edited code...\\
1916 1916 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
1917 1917
1918 1918 We can then call the function foo():
1919 1919
1920 1920 In [2]: foo()\\
1921 1921 foo() was defined in an editing session
1922 1922
1923 1923 Now we edit foo. IPython automatically loads the editor with the
1924 1924 (temporary) file where foo() was previously defined:
1925 1925
1926 1926 In [3]: ed foo\\
1927 1927 Editing... done. Executing edited code...
1928 1928
1929 1929 And if we call foo() again we get the modified version:
1930 1930
1931 1931 In [4]: foo()\\
1932 1932 foo() has now been changed!
1933 1933
1934 1934 Here is an example of how to edit a code snippet successive
1935 1935 times. First we call the editor:
1936 1936
1937 1937 In [8]: ed\\
1938 1938 Editing... done. Executing edited code...\\
1939 1939 hello\\
1940 1940 Out[8]: "print 'hello'\\n"
1941 1941
1942 1942 Now we call it again with the previous output (stored in _):
1943 1943
1944 1944 In [9]: ed _\\
1945 1945 Editing... done. Executing edited code...\\
1946 1946 hello world\\
1947 1947 Out[9]: "print 'hello world'\\n"
1948 1948
1949 1949 Now we call it with the output #8 (stored in _8, also as Out[8]):
1950 1950
1951 1951 In [10]: ed _8\\
1952 1952 Editing... done. Executing edited code...\\
1953 1953 hello again\\
1954 1954 Out[10]: "print 'hello again'\\n"
1955 1955
1956 1956
1957 1957 Changing the default editor hook:
1958 1958
1959 1959 If you wish to write your own editor hook, you can put it in a
1960 1960 configuration file which you load at startup time. The default hook
1961 1961 is defined in the IPython.hooks module, and you can use that as a
1962 1962 starting example for further modifications. That file also has
1963 1963 general instructions on how to set a new hook for use once you've
1964 1964 defined it."""
1965 1965
1966 1966 # FIXME: This function has become a convoluted mess. It needs a
1967 1967 # ground-up rewrite with clean, simple logic.
1968 1968
1969 1969 def make_filename(arg):
1970 1970 "Make a filename from the given args"
1971 1971 try:
1972 1972 filename = get_py_filename(arg)
1973 1973 except IOError:
1974 1974 if args.endswith('.py'):
1975 1975 filename = arg
1976 1976 else:
1977 1977 filename = None
1978 1978 return filename
1979 1979
1980 1980 # custom exceptions
1981 1981 class DataIsObject(Exception): pass
1982 1982
1983 1983 opts,args = self.parse_options(parameter_s,'prxn:')
1984 1984 # Set a few locals from the options for convenience:
1985 1985 opts_p = opts.has_key('p')
1986 1986 opts_r = opts.has_key('r')
1987 1987
1988 1988 # Default line number value
1989 1989 lineno = opts.get('n',None)
1990 1990
1991 1991 if opts_p:
1992 1992 args = '_%s' % last_call[0]
1993 1993 if not self.shell.user_ns.has_key(args):
1994 1994 args = last_call[1]
1995 1995
1996 1996 # use last_call to remember the state of the previous call, but don't
1997 1997 # let it be clobbered by successive '-p' calls.
1998 1998 try:
1999 1999 last_call[0] = self.shell.outputcache.prompt_count
2000 2000 if not opts_p:
2001 2001 last_call[1] = parameter_s
2002 2002 except:
2003 2003 pass
2004 2004
2005 2005 # by default this is done with temp files, except when the given
2006 2006 # arg is a filename
2007 2007 use_temp = 1
2008 2008
2009 2009 if re.match(r'\d',args):
2010 2010 # Mode where user specifies ranges of lines, like in %macro.
2011 2011 # This means that you can't edit files whose names begin with
2012 2012 # numbers this way. Tough.
2013 2013 ranges = args.split()
2014 2014 data = ''.join(self.extract_input_slices(ranges,opts_r))
2015 2015 elif args.endswith('.py'):
2016 2016 filename = make_filename(args)
2017 2017 data = ''
2018 2018 use_temp = 0
2019 2019 elif args:
2020 2020 try:
2021 2021 # Load the parameter given as a variable. If not a string,
2022 2022 # process it as an object instead (below)
2023 2023
2024 2024 #print '*** args',args,'type',type(args) # dbg
2025 2025 data = eval(args,self.shell.user_ns)
2026 2026 if not type(data) in StringTypes:
2027 2027 raise DataIsObject
2028 2028
2029 2029 except (NameError,SyntaxError):
2030 2030 # given argument is not a variable, try as a filename
2031 2031 filename = make_filename(args)
2032 2032 if filename is None:
2033 2033 warn("Argument given (%s) can't be found as a variable "
2034 2034 "or as a filename." % args)
2035 2035 return
2036 2036
2037 2037 data = ''
2038 2038 use_temp = 0
2039 2039 except DataIsObject:
2040 2040
2041 2041 # macros have a special edit function
2042 2042 if isinstance(data,Macro):
2043 2043 self._edit_macro(args,data)
2044 2044 return
2045 2045
2046 2046 # For objects, try to edit the file where they are defined
2047 2047 try:
2048 2048 filename = inspect.getabsfile(data)
2049 2049 datafile = 1
2050 2050 except TypeError:
2051 2051 filename = make_filename(args)
2052 2052 datafile = 1
2053 2053 warn('Could not find file where `%s` is defined.\n'
2054 2054 'Opening a file named `%s`' % (args,filename))
2055 2055 # Now, make sure we can actually read the source (if it was in
2056 2056 # a temp file it's gone by now).
2057 2057 if datafile:
2058 2058 try:
2059 2059 if lineno is None:
2060 2060 lineno = inspect.getsourcelines(data)[1]
2061 2061 except IOError:
2062 2062 filename = make_filename(args)
2063 2063 if filename is None:
2064 2064 warn('The file `%s` where `%s` was defined cannot '
2065 2065 'be read.' % (filename,data))
2066 2066 return
2067 2067 use_temp = 0
2068 2068 else:
2069 2069 data = ''
2070 2070
2071 2071 if use_temp:
2072 2072 filename = self.shell.mktempfile(data)
2073 2073 print 'IPython will make a temporary file named:',filename
2074 2074
2075 2075 # do actual editing here
2076 2076 print 'Editing...',
2077 2077 sys.stdout.flush()
2078 2078 self.shell.hooks.editor(filename,lineno)
2079 2079 if opts.has_key('x'): # -x prevents actual execution
2080 2080 print
2081 2081 else:
2082 2082 print 'done. Executing edited code...'
2083 2083 if opts_r:
2084 2084 self.shell.runlines(file_read(filename))
2085 2085 else:
2086 2086 self.shell.safe_execfile(filename,self.shell.user_ns,
2087 2087 self.shell.user_ns)
2088 2088 if use_temp:
2089 2089 try:
2090 2090 return open(filename).read()
2091 2091 except IOError,msg:
2092 2092 if msg.filename == filename:
2093 2093 warn('File not found. Did you forget to save?')
2094 2094 return
2095 2095 else:
2096 2096 self.shell.showtraceback()
2097 2097
2098 2098 def magic_xmode(self,parameter_s = ''):
2099 2099 """Switch modes for the exception handlers.
2100 2100
2101 2101 Valid modes: Plain, Context and Verbose.
2102 2102
2103 2103 If called without arguments, acts as a toggle."""
2104 2104
2105 2105 def xmode_switch_err(name):
2106 2106 warn('Error changing %s exception modes.\n%s' %
2107 2107 (name,sys.exc_info()[1]))
2108 2108
2109 2109 shell = self.shell
2110 2110 new_mode = parameter_s.strip().capitalize()
2111 2111 try:
2112 2112 shell.InteractiveTB.set_mode(mode=new_mode)
2113 2113 print 'Exception reporting mode:',shell.InteractiveTB.mode
2114 2114 except:
2115 2115 xmode_switch_err('user')
2116 2116
2117 2117 # threaded shells use a special handler in sys.excepthook
2118 2118 if shell.isthreaded:
2119 2119 try:
2120 2120 shell.sys_excepthook.set_mode(mode=new_mode)
2121 2121 except:
2122 2122 xmode_switch_err('threaded')
2123 2123
2124 2124 def magic_colors(self,parameter_s = ''):
2125 2125 """Switch color scheme for prompts, info system and exception handlers.
2126 2126
2127 2127 Currently implemented schemes: NoColor, Linux, LightBG.
2128 2128
2129 2129 Color scheme names are not case-sensitive."""
2130 2130
2131 2131 def color_switch_err(name):
2132 2132 warn('Error changing %s color schemes.\n%s' %
2133 2133 (name,sys.exc_info()[1]))
2134 2134
2135 2135
2136 2136 new_scheme = parameter_s.strip()
2137 2137 if not new_scheme:
2138 2138 print 'You must specify a color scheme.'
2139 2139 return
2140 2140 import IPython.rlineimpl as readline
2141 2141 if not readline.have_readline and sys.platform == "win32":
2142 2142 msg = """\
2143 2143 Proper color support under MS Windows requires the pyreadline library.
2144 2144 You can find it at:
2145 2145 http://ipython.scipy.org/moin/PyReadline/Intro
2146 2146 Gary's readline needs the ctypes module, from:
2147 2147 http://starship.python.net/crew/theller/ctypes
2148 2148 (Note that ctypes is already part of Python versions 2.5 and newer).
2149 2149
2150 2150 Defaulting color scheme to 'NoColor'"""
2151 2151 new_scheme = 'NoColor'
2152 2152 warn(msg)
2153 2153 # local shortcut
2154 2154 shell = self.shell
2155 2155
2156 2156 # Set prompt colors
2157 2157 try:
2158 2158 shell.outputcache.set_colors(new_scheme)
2159 2159 except:
2160 2160 color_switch_err('prompt')
2161 2161 else:
2162 2162 shell.rc.colors = \
2163 2163 shell.outputcache.color_table.active_scheme_name
2164 2164 # Set exception colors
2165 2165 try:
2166 2166 shell.InteractiveTB.set_colors(scheme = new_scheme)
2167 2167 shell.SyntaxTB.set_colors(scheme = new_scheme)
2168 2168 except:
2169 2169 color_switch_err('exception')
2170 2170
2171 2171 # threaded shells use a verbose traceback in sys.excepthook
2172 2172 if shell.isthreaded:
2173 2173 try:
2174 2174 shell.sys_excepthook.set_colors(scheme=new_scheme)
2175 2175 except:
2176 2176 color_switch_err('system exception handler')
2177 2177
2178 2178 # Set info (for 'object?') colors
2179 2179 if shell.rc.color_info:
2180 2180 try:
2181 2181 shell.inspector.set_active_scheme(new_scheme)
2182 2182 except:
2183 2183 color_switch_err('object inspector')
2184 2184 else:
2185 2185 shell.inspector.set_active_scheme('NoColor')
2186 2186
2187 2187 def magic_color_info(self,parameter_s = ''):
2188 2188 """Toggle color_info.
2189 2189
2190 2190 The color_info configuration parameter controls whether colors are
2191 2191 used for displaying object details (by things like %psource, %pfile or
2192 2192 the '?' system). This function toggles this value with each call.
2193 2193
2194 2194 Note that unless you have a fairly recent pager (less works better
2195 2195 than more) in your system, using colored object information displays
2196 2196 will not work properly. Test it and see."""
2197 2197
2198 2198 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2199 2199 self.magic_colors(self.shell.rc.colors)
2200 2200 print 'Object introspection functions have now coloring:',
2201 2201 print ['OFF','ON'][self.shell.rc.color_info]
2202 2202
2203 2203 def magic_Pprint(self, parameter_s=''):
2204 2204 """Toggle pretty printing on/off."""
2205 2205
2206 2206 self.shell.rc.pprint = 1 - self.shell.rc.pprint
2207 2207 print 'Pretty printing has been turned', \
2208 2208 ['OFF','ON'][self.shell.rc.pprint]
2209 2209
2210 2210 def magic_exit(self, parameter_s=''):
2211 2211 """Exit IPython, confirming if configured to do so.
2212 2212
2213 2213 You can configure whether IPython asks for confirmation upon exit by
2214 2214 setting the confirm_exit flag in the ipythonrc file."""
2215 2215
2216 2216 self.shell.exit()
2217 2217
2218 2218 def magic_quit(self, parameter_s=''):
2219 2219 """Exit IPython, confirming if configured to do so (like %exit)"""
2220 2220
2221 2221 self.shell.exit()
2222 2222
2223 2223 def magic_Exit(self, parameter_s=''):
2224 2224 """Exit IPython without confirmation."""
2225 2225
2226 2226 self.shell.exit_now = True
2227 2227
2228 2228 #......................................................................
2229 2229 # Functions to implement unix shell-type things
2230 2230
2231 2231 def magic_alias(self, parameter_s = ''):
2232 2232 """Define an alias for a system command.
2233 2233
2234 2234 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2235 2235
2236 2236 Then, typing 'alias_name params' will execute the system command 'cmd
2237 2237 params' (from your underlying operating system).
2238 2238
2239 2239 Aliases have lower precedence than magic functions and Python normal
2240 2240 variables, so if 'foo' is both a Python variable and an alias, the
2241 2241 alias can not be executed until 'del foo' removes the Python variable.
2242 2242
2243 2243 You can use the %l specifier in an alias definition to represent the
2244 2244 whole line when the alias is called. For example:
2245 2245
2246 2246 In [2]: alias all echo "Input in brackets: <%l>"\\
2247 2247 In [3]: all hello world\\
2248 2248 Input in brackets: <hello world>
2249 2249
2250 2250 You can also define aliases with parameters using %s specifiers (one
2251 2251 per parameter):
2252 2252
2253 2253 In [1]: alias parts echo first %s second %s\\
2254 2254 In [2]: %parts A B\\
2255 2255 first A second B\\
2256 2256 In [3]: %parts A\\
2257 2257 Incorrect number of arguments: 2 expected.\\
2258 2258 parts is an alias to: 'echo first %s second %s'
2259 2259
2260 2260 Note that %l and %s are mutually exclusive. You can only use one or
2261 2261 the other in your aliases.
2262 2262
2263 2263 Aliases expand Python variables just like system calls using ! or !!
2264 2264 do: all expressions prefixed with '$' get expanded. For details of
2265 2265 the semantic rules, see PEP-215:
2266 2266 http://www.python.org/peps/pep-0215.html. This is the library used by
2267 2267 IPython for variable expansion. If you want to access a true shell
2268 2268 variable, an extra $ is necessary to prevent its expansion by IPython:
2269 2269
2270 2270 In [6]: alias show echo\\
2271 2271 In [7]: PATH='A Python string'\\
2272 2272 In [8]: show $PATH\\
2273 2273 A Python string\\
2274 2274 In [9]: show $$PATH\\
2275 2275 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2276 2276
2277 2277 You can use the alias facility to acess all of $PATH. See the %rehash
2278 2278 and %rehashx functions, which automatically create aliases for the
2279 2279 contents of your $PATH.
2280 2280
2281 2281 If called with no parameters, %alias prints the current alias table."""
2282 2282
2283 2283 par = parameter_s.strip()
2284 2284 if not par:
2285 2285 stored = self.db.get('stored_aliases', {} )
2286 2286 atab = self.shell.alias_table
2287 2287 aliases = atab.keys()
2288 2288 aliases.sort()
2289 2289 res = []
2290 2290 showlast = []
2291 2291 for alias in aliases:
2292 2292 tgt = atab[alias][1]
2293 2293 # 'interesting' aliases
2294 2294 if (alias in stored or
2295 2295 alias.lower() != os.path.splitext(tgt)[0].lower() or
2296 2296 ' ' in tgt):
2297 2297 showlast.append((alias, tgt))
2298 2298 else:
2299 2299 res.append((alias, tgt ))
2300 2300
2301 2301 # show most interesting aliases last
2302 2302 res.extend(showlast)
2303 2303 print "Total number of aliases:",len(aliases)
2304 2304 return res
2305 2305 try:
2306 2306 alias,cmd = par.split(None,1)
2307 2307 except:
2308 2308 print OInspect.getdoc(self.magic_alias)
2309 2309 else:
2310 2310 nargs = cmd.count('%s')
2311 2311 if nargs>0 and cmd.find('%l')>=0:
2312 2312 error('The %s and %l specifiers are mutually exclusive '
2313 2313 'in alias definitions.')
2314 2314 else: # all looks OK
2315 2315 self.shell.alias_table[alias] = (nargs,cmd)
2316 2316 self.shell.alias_table_validate(verbose=0)
2317 2317 # end magic_alias
2318 2318
2319 2319 def magic_unalias(self, parameter_s = ''):
2320 2320 """Remove an alias"""
2321 2321
2322 2322 aname = parameter_s.strip()
2323 2323 if aname in self.shell.alias_table:
2324 2324 del self.shell.alias_table[aname]
2325 2325 stored = self.db.get('stored_aliases', {} )
2326 2326 if aname in stored:
2327 2327 print "Removing %stored alias",aname
2328 2328 del stored[aname]
2329 2329 self.db['stored_aliases'] = stored
2330 2330
2331 2331
2332 2332 def magic_rehashx(self, parameter_s = ''):
2333 2333 """Update the alias table with all executable files in $PATH.
2334 2334
2335 2335 This version explicitly checks that every entry in $PATH is a file
2336 2336 with execute access (os.X_OK), so it is much slower than %rehash.
2337 2337
2338 2338 Under Windows, it checks executability as a match agains a
2339 2339 '|'-separated string of extensions, stored in the IPython config
2340 2340 variable win_exec_ext. This defaults to 'exe|com|bat'.
2341 2341
2342 2342 This function also resets the root module cache of module completer,
2343 2343 used on slow filesystems.
2344 2344 """
2345 2345
2346 2346
2347 2347 ip = self.api
2348 2348
2349 2349 # for the benefit of module completer in ipy_completers.py
2350 2350 del ip.db['rootmodules']
2351 2351
2352 2352 path = [os.path.abspath(os.path.expanduser(p)) for p in
2353 2353 os.environ.get('PATH','').split(os.pathsep)]
2354 2354 path = filter(os.path.isdir,path)
2355 2355
2356 2356 alias_table = self.shell.alias_table
2357 2357 syscmdlist = []
2358 2358 if os.name == 'posix':
2359 2359 isexec = lambda fname:os.path.isfile(fname) and \
2360 2360 os.access(fname,os.X_OK)
2361 2361 else:
2362 2362
2363 2363 try:
2364 2364 winext = os.environ['pathext'].replace(';','|').replace('.','')
2365 2365 except KeyError:
2366 2366 winext = 'exe|com|bat|py'
2367 2367 if 'py' not in winext:
2368 2368 winext += '|py'
2369 2369 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2370 2370 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2371 2371 savedir = os.getcwd()
2372 2372 try:
2373 2373 # write the whole loop for posix/Windows so we don't have an if in
2374 2374 # the innermost part
2375 2375 if os.name == 'posix':
2376 2376 for pdir in path:
2377 2377 os.chdir(pdir)
2378 2378 for ff in os.listdir(pdir):
2379 2379 if isexec(ff) and ff not in self.shell.no_alias:
2380 2380 # each entry in the alias table must be (N,name),
2381 2381 # where N is the number of positional arguments of the
2382 2382 # alias.
2383 2383 alias_table[ff] = (0,ff)
2384 2384 syscmdlist.append(ff)
2385 2385 else:
2386 2386 for pdir in path:
2387 2387 os.chdir(pdir)
2388 2388 for ff in os.listdir(pdir):
2389 2389 base, ext = os.path.splitext(ff)
2390 2390 if isexec(ff) and base not in self.shell.no_alias:
2391 2391 if ext.lower() == '.exe':
2392 2392 ff = base
2393 2393 alias_table[base.lower()] = (0,ff)
2394 2394 syscmdlist.append(ff)
2395 2395 # Make sure the alias table doesn't contain keywords or builtins
2396 2396 self.shell.alias_table_validate()
2397 2397 # Call again init_auto_alias() so we get 'rm -i' and other
2398 2398 # modified aliases since %rehashx will probably clobber them
2399 2399
2400 2400 # no, we don't want them. if %rehashx clobbers them, good,
2401 2401 # we'll probably get better versions
2402 2402 # self.shell.init_auto_alias()
2403 2403 db = ip.db
2404 2404 db['syscmdlist'] = syscmdlist
2405 2405 finally:
2406 2406 os.chdir(savedir)
2407 2407
2408 2408 def magic_pwd(self, parameter_s = ''):
2409 2409 """Return the current working directory path."""
2410 2410 return os.getcwd()
2411 2411
2412 2412 def magic_cd(self, parameter_s=''):
2413 2413 """Change the current working directory.
2414 2414
2415 2415 This command automatically maintains an internal list of directories
2416 2416 you visit during your IPython session, in the variable _dh. The
2417 2417 command %dhist shows this history nicely formatted. You can also
2418 2418 do 'cd -<tab>' to see directory history conveniently.
2419 2419
2420 2420 Usage:
2421 2421
2422 2422 cd 'dir': changes to directory 'dir'.
2423 2423
2424 2424 cd -: changes to the last visited directory.
2425 2425
2426 2426 cd -<n>: changes to the n-th directory in the directory history.
2427 2427
2428 2428 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2429 2429 (note: cd <bookmark_name> is enough if there is no
2430 2430 directory <bookmark_name>, but a bookmark with the name exists.)
2431 2431 'cd -b <tab>' allows you to tab-complete bookmark names.
2432 2432
2433 2433 Options:
2434 2434
2435 2435 -q: quiet. Do not print the working directory after the cd command is
2436 2436 executed. By default IPython's cd command does print this directory,
2437 2437 since the default prompts do not display path information.
2438 2438
2439 2439 Note that !cd doesn't work for this purpose because the shell where
2440 2440 !command runs is immediately discarded after executing 'command'."""
2441 2441
2442 2442 parameter_s = parameter_s.strip()
2443 2443 #bkms = self.shell.persist.get("bookmarks",{})
2444 2444
2445 2445 numcd = re.match(r'(-)(\d+)$',parameter_s)
2446 2446 # jump in directory history by number
2447 2447 if numcd:
2448 2448 nn = int(numcd.group(2))
2449 2449 try:
2450 2450 ps = self.shell.user_ns['_dh'][nn]
2451 2451 except IndexError:
2452 2452 print 'The requested directory does not exist in history.'
2453 2453 return
2454 2454 else:
2455 2455 opts = {}
2456 2456 else:
2457 2457 #turn all non-space-escaping backslashes to slashes,
2458 2458 # for c:\windows\directory\names\
2459 2459 parameter_s = re.sub(r'\\(?! )','/', parameter_s)
2460 2460 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2461 2461 # jump to previous
2462 2462 if ps == '-':
2463 2463 try:
2464 2464 ps = self.shell.user_ns['_dh'][-2]
2465 2465 except IndexError:
2466 2466 print 'No previous directory to change to.'
2467 2467 return
2468 2468 # jump to bookmark if needed
2469 2469 else:
2470 2470 if not os.path.isdir(ps) or opts.has_key('b'):
2471 2471 bkms = self.db.get('bookmarks', {})
2472 2472
2473 2473 if bkms.has_key(ps):
2474 2474 target = bkms[ps]
2475 2475 print '(bookmark:%s) -> %s' % (ps,target)
2476 2476 ps = target
2477 2477 else:
2478 2478 if opts.has_key('b'):
2479 2479 error("Bookmark '%s' not found. "
2480 2480 "Use '%%bookmark -l' to see your bookmarks." % ps)
2481 2481 return
2482 2482
2483 2483 # at this point ps should point to the target dir
2484 2484 if ps:
2485 2485 try:
2486 2486 os.chdir(os.path.expanduser(ps))
2487 2487 if self.shell.rc.term_title:
2488 2488 #print 'set term title:',self.shell.rc.term_title # dbg
2489 2489 ttitle = ("IPy:" + (
2490 2490 os.getcwd() == '/' and '/' or \
2491 2491 os.path.basename(os.getcwd())))
2492 2492 platutils.set_term_title(ttitle)
2493 2493 except OSError:
2494 2494 print sys.exc_info()[1]
2495 2495 else:
2496 2496 cwd = os.getcwd()
2497 2497 dhist = self.shell.user_ns['_dh']
2498 2498 dhist.append(cwd)
2499 2499 self.db['dhist'] = compress_dhist(dhist)[-100:]
2500 2500
2501 2501 else:
2502 2502 os.chdir(self.shell.home_dir)
2503 2503 if self.shell.rc.term_title:
2504 2504 platutils.set_term_title("IPy:~")
2505 2505 cwd = os.getcwd()
2506 2506 dhist = self.shell.user_ns['_dh']
2507 2507 dhist.append(cwd)
2508 2508 self.db['dhist'] = compress_dhist(dhist)[-100:]
2509 2509 if not 'q' in opts:
2510 2510 print self.shell.user_ns['_dh'][-1]
2511 2511
2512 2512
2513 2513 def magic_env(self, parameter_s=''):
2514 2514 """List environment variables."""
2515 2515
2516 2516 return os.environ.data
2517 2517
2518 2518 def magic_pushd(self, parameter_s=''):
2519 2519 """Place the current dir on stack and change directory.
2520 2520
2521 2521 Usage:\\
2522 2522 %pushd ['dirname']
2523 2523
2524 2524 %pushd with no arguments does a %pushd to your home directory.
2525 2525 """
2526 2526 if parameter_s == '': parameter_s = '~'
2527 2527 dir_s = self.shell.dir_stack
2528 2528 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2529 2529 os.path.expanduser(self.shell.dir_stack[0]):
2530 2530 try:
2531 2531 self.magic_cd(parameter_s)
2532 2532 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2533 2533 self.magic_dirs()
2534 2534 except:
2535 2535 print 'Invalid directory'
2536 2536 else:
2537 2537 print 'You are already there!'
2538 2538
2539 2539 def magic_popd(self, parameter_s=''):
2540 2540 """Change to directory popped off the top of the stack.
2541 2541 """
2542 2542 if len (self.shell.dir_stack) > 1:
2543 2543 self.shell.dir_stack.pop(0)
2544 2544 self.magic_cd(self.shell.dir_stack[0])
2545 2545 print self.shell.dir_stack[0]
2546 2546 else:
2547 2547 print "You can't remove the starting directory from the stack:",\
2548 2548 self.shell.dir_stack
2549 2549
2550 2550 def magic_dirs(self, parameter_s=''):
2551 2551 """Return the current directory stack."""
2552 2552
2553 2553 return self.shell.dir_stack[:]
2554 2554
2555 2555 def magic_sc(self, parameter_s=''):
2556 2556 """Shell capture - execute a shell command and capture its output.
2557 2557
2558 2558 DEPRECATED. Suboptimal, retained for backwards compatibility.
2559 2559
2560 2560 You should use the form 'var = !command' instead. Example:
2561 2561
2562 2562 "%sc -l myfiles = ls ~" should now be written as
2563 2563
2564 2564 "myfiles = !ls ~"
2565 2565
2566 2566 myfiles.s, myfiles.l and myfiles.n still apply as documented
2567 2567 below.
2568 2568
2569 2569 --
2570 2570 %sc [options] varname=command
2571 2571
2572 2572 IPython will run the given command using commands.getoutput(), and
2573 2573 will then update the user's interactive namespace with a variable
2574 2574 called varname, containing the value of the call. Your command can
2575 2575 contain shell wildcards, pipes, etc.
2576 2576
2577 2577 The '=' sign in the syntax is mandatory, and the variable name you
2578 2578 supply must follow Python's standard conventions for valid names.
2579 2579
2580 2580 (A special format without variable name exists for internal use)
2581 2581
2582 2582 Options:
2583 2583
2584 2584 -l: list output. Split the output on newlines into a list before
2585 2585 assigning it to the given variable. By default the output is stored
2586 2586 as a single string.
2587 2587
2588 2588 -v: verbose. Print the contents of the variable.
2589 2589
2590 2590 In most cases you should not need to split as a list, because the
2591 2591 returned value is a special type of string which can automatically
2592 2592 provide its contents either as a list (split on newlines) or as a
2593 2593 space-separated string. These are convenient, respectively, either
2594 2594 for sequential processing or to be passed to a shell command.
2595 2595
2596 2596 For example:
2597 2597
2598 2598 # Capture into variable a
2599 2599 In [9]: sc a=ls *py
2600 2600
2601 2601 # a is a string with embedded newlines
2602 2602 In [10]: a
2603 2603 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2604 2604
2605 2605 # which can be seen as a list:
2606 2606 In [11]: a.l
2607 2607 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2608 2608
2609 2609 # or as a whitespace-separated string:
2610 2610 In [12]: a.s
2611 2611 Out[12]: 'setup.py win32_manual_post_install.py'
2612 2612
2613 2613 # a.s is useful to pass as a single command line:
2614 2614 In [13]: !wc -l $a.s
2615 2615 146 setup.py
2616 2616 130 win32_manual_post_install.py
2617 2617 276 total
2618 2618
2619 2619 # while the list form is useful to loop over:
2620 2620 In [14]: for f in a.l:
2621 2621 ....: !wc -l $f
2622 2622 ....:
2623 2623 146 setup.py
2624 2624 130 win32_manual_post_install.py
2625 2625
2626 2626 Similiarly, the lists returned by the -l option are also special, in
2627 2627 the sense that you can equally invoke the .s attribute on them to
2628 2628 automatically get a whitespace-separated string from their contents:
2629 2629
2630 2630 In [1]: sc -l b=ls *py
2631 2631
2632 2632 In [2]: b
2633 2633 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2634 2634
2635 2635 In [3]: b.s
2636 2636 Out[3]: 'setup.py win32_manual_post_install.py'
2637 2637
2638 2638 In summary, both the lists and strings used for ouptut capture have
2639 2639 the following special attributes:
2640 2640
2641 2641 .l (or .list) : value as list.
2642 2642 .n (or .nlstr): value as newline-separated string.
2643 2643 .s (or .spstr): value as space-separated string.
2644 2644 """
2645 2645
2646 2646 opts,args = self.parse_options(parameter_s,'lv')
2647 2647 # Try to get a variable name and command to run
2648 2648 try:
2649 2649 # the variable name must be obtained from the parse_options
2650 2650 # output, which uses shlex.split to strip options out.
2651 2651 var,_ = args.split('=',1)
2652 2652 var = var.strip()
2653 2653 # But the the command has to be extracted from the original input
2654 2654 # parameter_s, not on what parse_options returns, to avoid the
2655 2655 # quote stripping which shlex.split performs on it.
2656 2656 _,cmd = parameter_s.split('=',1)
2657 2657 except ValueError:
2658 2658 var,cmd = '',''
2659 2659 # If all looks ok, proceed
2660 2660 out,err = self.shell.getoutputerror(cmd)
2661 2661 if err:
2662 2662 print >> Term.cerr,err
2663 2663 if opts.has_key('l'):
2664 2664 out = SList(out.split('\n'))
2665 2665 else:
2666 2666 out = LSString(out)
2667 2667 if opts.has_key('v'):
2668 2668 print '%s ==\n%s' % (var,pformat(out))
2669 2669 if var:
2670 2670 self.shell.user_ns.update({var:out})
2671 2671 else:
2672 2672 return out
2673 2673
2674 2674 def magic_sx(self, parameter_s=''):
2675 2675 """Shell execute - run a shell command and capture its output.
2676 2676
2677 2677 %sx command
2678 2678
2679 2679 IPython will run the given command using commands.getoutput(), and
2680 2680 return the result formatted as a list (split on '\\n'). Since the
2681 2681 output is _returned_, it will be stored in ipython's regular output
2682 2682 cache Out[N] and in the '_N' automatic variables.
2683 2683
2684 2684 Notes:
2685 2685
2686 2686 1) If an input line begins with '!!', then %sx is automatically
2687 2687 invoked. That is, while:
2688 2688 !ls
2689 2689 causes ipython to simply issue system('ls'), typing
2690 2690 !!ls
2691 2691 is a shorthand equivalent to:
2692 2692 %sx ls
2693 2693
2694 2694 2) %sx differs from %sc in that %sx automatically splits into a list,
2695 2695 like '%sc -l'. The reason for this is to make it as easy as possible
2696 2696 to process line-oriented shell output via further python commands.
2697 2697 %sc is meant to provide much finer control, but requires more
2698 2698 typing.
2699 2699
2700 2700 3) Just like %sc -l, this is a list with special attributes:
2701 2701
2702 2702 .l (or .list) : value as list.
2703 2703 .n (or .nlstr): value as newline-separated string.
2704 2704 .s (or .spstr): value as whitespace-separated string.
2705 2705
2706 2706 This is very useful when trying to use such lists as arguments to
2707 2707 system commands."""
2708 2708
2709 2709 if parameter_s:
2710 2710 out,err = self.shell.getoutputerror(parameter_s)
2711 2711 if err:
2712 2712 print >> Term.cerr,err
2713 2713 return SList(out.split('\n'))
2714 2714
2715 2715 def magic_bg(self, parameter_s=''):
2716 2716 """Run a job in the background, in a separate thread.
2717 2717
2718 2718 For example,
2719 2719
2720 2720 %bg myfunc(x,y,z=1)
2721 2721
2722 2722 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2723 2723 execution starts, a message will be printed indicating the job
2724 2724 number. If your job number is 5, you can use
2725 2725
2726 2726 myvar = jobs.result(5) or myvar = jobs[5].result
2727 2727
2728 2728 to assign this result to variable 'myvar'.
2729 2729
2730 2730 IPython has a job manager, accessible via the 'jobs' object. You can
2731 2731 type jobs? to get more information about it, and use jobs.<TAB> to see
2732 2732 its attributes. All attributes not starting with an underscore are
2733 2733 meant for public use.
2734 2734
2735 2735 In particular, look at the jobs.new() method, which is used to create
2736 2736 new jobs. This magic %bg function is just a convenience wrapper
2737 2737 around jobs.new(), for expression-based jobs. If you want to create a
2738 2738 new job with an explicit function object and arguments, you must call
2739 2739 jobs.new() directly.
2740 2740
2741 2741 The jobs.new docstring also describes in detail several important
2742 2742 caveats associated with a thread-based model for background job
2743 2743 execution. Type jobs.new? for details.
2744 2744
2745 2745 You can check the status of all jobs with jobs.status().
2746 2746
2747 2747 The jobs variable is set by IPython into the Python builtin namespace.
2748 2748 If you ever declare a variable named 'jobs', you will shadow this
2749 2749 name. You can either delete your global jobs variable to regain
2750 2750 access to the job manager, or make a new name and assign it manually
2751 2751 to the manager (stored in IPython's namespace). For example, to
2752 2752 assign the job manager to the Jobs name, use:
2753 2753
2754 2754 Jobs = __builtins__.jobs"""
2755 2755
2756 2756 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2757 2757
2758 2758
2759 2759 def magic_bookmark(self, parameter_s=''):
2760 2760 """Manage IPython's bookmark system.
2761 2761
2762 2762 %bookmark <name> - set bookmark to current dir
2763 2763 %bookmark <name> <dir> - set bookmark to <dir>
2764 2764 %bookmark -l - list all bookmarks
2765 2765 %bookmark -d <name> - remove bookmark
2766 2766 %bookmark -r - remove all bookmarks
2767 2767
2768 2768 You can later on access a bookmarked folder with:
2769 2769 %cd -b <name>
2770 2770 or simply '%cd <name>' if there is no directory called <name> AND
2771 2771 there is such a bookmark defined.
2772 2772
2773 2773 Your bookmarks persist through IPython sessions, but they are
2774 2774 associated with each profile."""
2775 2775
2776 2776 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2777 2777 if len(args) > 2:
2778 2778 error('You can only give at most two arguments')
2779 2779 return
2780 2780
2781 2781 bkms = self.db.get('bookmarks',{})
2782 2782
2783 2783 if opts.has_key('d'):
2784 2784 try:
2785 2785 todel = args[0]
2786 2786 except IndexError:
2787 2787 error('You must provide a bookmark to delete')
2788 2788 else:
2789 2789 try:
2790 2790 del bkms[todel]
2791 2791 except:
2792 2792 error("Can't delete bookmark '%s'" % todel)
2793 2793 elif opts.has_key('r'):
2794 2794 bkms = {}
2795 2795 elif opts.has_key('l'):
2796 2796 bks = bkms.keys()
2797 2797 bks.sort()
2798 2798 if bks:
2799 2799 size = max(map(len,bks))
2800 2800 else:
2801 2801 size = 0
2802 2802 fmt = '%-'+str(size)+'s -> %s'
2803 2803 print 'Current bookmarks:'
2804 2804 for bk in bks:
2805 2805 print fmt % (bk,bkms[bk])
2806 2806 else:
2807 2807 if not args:
2808 2808 error("You must specify the bookmark name")
2809 2809 elif len(args)==1:
2810 2810 bkms[args[0]] = os.getcwd()
2811 2811 elif len(args)==2:
2812 2812 bkms[args[0]] = args[1]
2813 2813 self.db['bookmarks'] = bkms
2814 2814
2815 2815 def magic_pycat(self, parameter_s=''):
2816 2816 """Show a syntax-highlighted file through a pager.
2817 2817
2818 2818 This magic is similar to the cat utility, but it will assume the file
2819 2819 to be Python source and will show it with syntax highlighting. """
2820 2820
2821 2821 try:
2822 2822 filename = get_py_filename(parameter_s)
2823 2823 cont = file_read(filename)
2824 2824 except IOError:
2825 2825 try:
2826 2826 cont = eval(parameter_s,self.user_ns)
2827 2827 except NameError:
2828 2828 cont = None
2829 2829 if cont is None:
2830 2830 print "Error: no such file or variable"
2831 2831 return
2832 2832
2833 2833 page(self.shell.pycolorize(cont),
2834 2834 screen_lines=self.shell.rc.screen_length)
2835 2835
2836 2836 def magic_cpaste(self, parameter_s=''):
2837 2837 """Allows you to paste & execute a pre-formatted code block from clipboard
2838 2838
2839 2839 You must terminate the block with '--' (two minus-signs) alone on the
2840 2840 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
2841 2841 is the new sentinel for this operation)
2842 2842
2843 2843 The block is dedented prior to execution to enable execution of method
2844 2844 definitions. '>' and '+' characters at the beginning of a line are
2845 2845 ignored, to allow pasting directly from e-mails or diff files. The
2846 2846 executed block is also assigned to variable named 'pasted_block' for
2847 2847 later editing with '%edit pasted_block'.
2848 2848
2849 2849 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
2850 2850 This assigns the pasted block to variable 'foo' as string, without
2851 2851 dedenting or executing it.
2852 2852
2853 2853 Do not be alarmed by garbled output on Windows (it's a readline bug).
2854 2854 Just press enter and type -- (and press enter again) and the block
2855 2855 will be what was just pasted.
2856 2856
2857 2857 IPython statements (magics, shell escapes) are not supported (yet).
2858 2858 """
2859 2859 opts,args = self.parse_options(parameter_s,'s:',mode='string')
2860 2860 par = args.strip()
2861 2861 sentinel = opts.get('s','--')
2862 2862
2863 2863 from IPython import iplib
2864 2864 lines = []
2865 2865 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
2866 2866 while 1:
2867 2867 l = iplib.raw_input_original(':')
2868 2868 if l ==sentinel:
2869 2869 break
2870 2870 lines.append(l.lstrip('>').lstrip('+'))
2871 2871 block = "\n".join(lines) + '\n'
2872 2872 #print "block:\n",block
2873 2873 if not par:
2874 2874 b = textwrap.dedent(block)
2875 2875 exec b in self.user_ns
2876 2876 self.user_ns['pasted_block'] = b
2877 2877 else:
2878 2878 self.user_ns[par] = block
2879 2879 print "Block assigned to '%s'" % par
2880 2880
2881 2881 def magic_quickref(self,arg):
2882 2882 """ Show a quick reference sheet """
2883 2883 import IPython.usage
2884 2884 qr = IPython.usage.quick_reference + self.magic_magic('-brief')
2885 2885
2886 2886 page(qr)
2887 2887
2888 2888 def magic_upgrade(self,arg):
2889 2889 """ Upgrade your IPython installation
2890 2890
2891 2891 This will copy the config files that don't yet exist in your
2892 2892 ipython dir from the system config dir. Use this after upgrading
2893 2893 IPython if you don't wish to delete your .ipython dir.
2894 2894
2895 2895 Call with -nolegacy to get rid of ipythonrc* files (recommended for
2896 2896 new users)
2897 2897
2898 2898 """
2899 2899 ip = self.getapi()
2900 2900 ipinstallation = path(IPython.__file__).dirname()
2901 2901 upgrade_script = '%s "%s"' % (sys.executable,ipinstallation / 'upgrade_dir.py')
2902 2902 src_config = ipinstallation / 'UserConfig'
2903 2903 userdir = path(ip.options.ipythondir)
2904 2904 cmd = '%s "%s" "%s"' % (upgrade_script, src_config, userdir)
2905 2905 print ">",cmd
2906 2906 shell(cmd)
2907 2907 if arg == '-nolegacy':
2908 2908 legacy = userdir.files('ipythonrc*')
2909 2909 print "Nuking legacy files:",legacy
2910 2910
2911 2911 [p.remove() for p in legacy]
2912 2912 suffix = (sys.platform == 'win32' and '.ini' or '')
2913 2913 (userdir / ('ipythonrc' + suffix)).write_text('# Empty, see ipy_user_conf.py\n')
2914 2914
2915
2916 def magic_doctest_mode(self,parameter_s=''):
2917 """Toggle doctest mode on and off.
2918
2919 This mode allows you to toggle the prompt behavior between normal
2920 IPython prompts and ones that are as similar to the default IPython
2921 interpreter as possible.
2922
2923 It also supports the pasting of code snippets that have leading '>>>'
2924 and '...' prompts in them. This means that you can paste doctests from
2925 files or docstrings (even if they have leading whitespace), and the
2926 code will execute correctly. You can then use '%history -tn' to see
2927 the translated history without line numbers; this will give you the
2928 input after removal of all the leading prompts and whitespace, which
2929 can be pasted back into an editor.
2930
2931 With these features, you can switch into this mode easily whenever you
2932 need to do testing and changes to doctests, without having to leave
2933 your existing IPython session.
2934 """
2935
2936 # XXX - Fix this to have cleaner activate/deactivate calls.
2937 from IPython.Extensions import InterpreterPasteInput as ipaste
2938 from IPython.ipstruct import Struct
2939
2940 # Shorthands
2941 shell = self.shell
2942 oc = shell.outputcache
2943 rc = shell.rc
2944 meta = shell.meta
2945 # dstore is a data store kept in the instance metadata bag to track any
2946 # changes we make, so we can undo them later.
2947 dstore = meta.setdefault('doctest_mode',Struct())
2948 save_dstore = dstore.setdefault
2949
2950 # save a few values we'll need to recover later
2951 mode = save_dstore('mode',False)
2952 save_dstore('rc_pprint',rc.pprint)
2953 save_dstore('xmode',shell.InteractiveTB.mode)
2954 save_dstore('rc_separate_in',rc.separate_in)
2955 save_dstore('rc_separate_out',rc.separate_out)
2956 save_dstore('rc_separate_out2',rc.separate_out2)
2957 save_dstore('rc_prompts_pad_left',rc.prompts_pad_left)
2958
2959 if mode == False:
2960 # turn on
2961 ipaste.activate_prefilter()
2962
2963 oc.prompt1.p_template = '>>> '
2964 oc.prompt2.p_template = '... '
2965 oc.prompt_out.p_template = ''
2966
2967 oc.prompt1.sep = ''
2968 oc.prompt_out.output_sep = ''
2969 oc.prompt_out.output_sep2 = '\n'
2970
2971 oc.prompt1.pad_left = oc.prompt2.pad_left = \
2972 oc.prompt_out.pad_left = False
2973
2974 shell.magic_xmode('Plain')
2975
2976 rc.pprint = False
2977
2978 else:
2979 # turn off
2980 ipaste.deactivate_prefilter()
2981
2982 oc.prompt1.p_template = rc.prompt_in1
2983 oc.prompt2.p_template = rc.prompt_in2
2984 oc.prompt_out.p_template = rc.prompt_out
2985
2986 oc.prompt1.sep = dstore.rc_separate_in
2987 oc.prompt_out.output_sep = dstore.rc_separate_out
2988 oc.prompt_out.output_sep2 = dstore.rc_separate_out2
2989
2990 oc.prompt1.pad_left = oc.prompt2.pad_left = \
2991 oc.prompt_out.pad_left = dstore.rc_prompts_pad_left
2992 shell.magic_xmode(dstore.xmode)
2993
2994 rc.pprint = dstore.rc_pprint
2995
2996 # Store new mode and inform
2997 dstore.mode = bool(1-int(mode))
2998 print 'Doctest mode is:',
2999 print ['OFF','ON'][dstore.mode]
3000
2915 3001 # end Magic
@@ -1,591 +1,604 b''
1 1 # -*- coding: utf-8 -*-
2 2 """
3 3 Classes for handling input/output prompts.
4 4
5 $Id: Prompts.py 2397 2007-05-26 10:06:26Z vivainio $"""
5 $Id: Prompts.py 2601 2007-08-10 07:01:29Z fperez $"""
6 6
7 7 #*****************************************************************************
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 from IPython import Release
15 15 __author__ = '%s <%s>' % Release.authors['Fernando']
16 16 __license__ = Release.license
17 17 __version__ = Release.version
18 18
19 19 #****************************************************************************
20 20 # Required modules
21 21 import __builtin__
22 22 import os
23 23 import socket
24 24 import sys
25 25 import time
26 26
27 27 # IPython's own
28 28 from IPython import ColorANSI
29 29 from IPython.Itpl import ItplNS
30 30 from IPython.ipstruct import Struct
31 31 from IPython.macro import Macro
32 32 from IPython.genutils import *
33 33 from IPython.ipapi import TryNext
34 34
35 35 #****************************************************************************
36 36 #Color schemes for Prompts.
37 37
38 38 PromptColors = ColorANSI.ColorSchemeTable()
39 39 InputColors = ColorANSI.InputTermColors # just a shorthand
40 40 Colors = ColorANSI.TermColors # just a shorthand
41 41
42 42 PromptColors.add_scheme(ColorANSI.ColorScheme(
43 43 'NoColor',
44 44 in_prompt = InputColors.NoColor, # Input prompt
45 45 in_number = InputColors.NoColor, # Input prompt number
46 46 in_prompt2 = InputColors.NoColor, # Continuation prompt
47 47 in_normal = InputColors.NoColor, # color off (usu. Colors.Normal)
48 48
49 49 out_prompt = Colors.NoColor, # Output prompt
50 50 out_number = Colors.NoColor, # Output prompt number
51 51
52 52 normal = Colors.NoColor # color off (usu. Colors.Normal)
53 53 ))
54 54
55 55 # make some schemes as instances so we can copy them for modification easily:
56 56 __PColLinux = ColorANSI.ColorScheme(
57 57 'Linux',
58 58 in_prompt = InputColors.Green,
59 59 in_number = InputColors.LightGreen,
60 60 in_prompt2 = InputColors.Green,
61 61 in_normal = InputColors.Normal, # color off (usu. Colors.Normal)
62 62
63 63 out_prompt = Colors.Red,
64 64 out_number = Colors.LightRed,
65 65
66 66 normal = Colors.Normal
67 67 )
68 68 # Don't forget to enter it into the table!
69 69 PromptColors.add_scheme(__PColLinux)
70 70
71 71 # Slightly modified Linux for light backgrounds
72 72 __PColLightBG = __PColLinux.copy('LightBG')
73 73
74 74 __PColLightBG.colors.update(
75 75 in_prompt = InputColors.Blue,
76 76 in_number = InputColors.LightBlue,
77 77 in_prompt2 = InputColors.Blue
78 78 )
79 79 PromptColors.add_scheme(__PColLightBG)
80 80
81 81 del Colors,InputColors
82 82
83 83 #-----------------------------------------------------------------------------
84 84 def multiple_replace(dict, text):
85 85 """ Replace in 'text' all occurences of any key in the given
86 86 dictionary by its corresponding value. Returns the new string."""
87 87
88 88 # Function by Xavier Defrang, originally found at:
89 89 # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81330
90 90
91 91 # Create a regular expression from the dictionary keys
92 92 regex = re.compile("(%s)" % "|".join(map(re.escape, dict.keys())))
93 93 # For each match, look-up corresponding value in dictionary
94 94 return regex.sub(lambda mo: dict[mo.string[mo.start():mo.end()]], text)
95 95
96 96 #-----------------------------------------------------------------------------
97 97 # Special characters that can be used in prompt templates, mainly bash-like
98 98
99 99 # If $HOME isn't defined (Windows), make it an absurd string so that it can
100 100 # never be expanded out into '~'. Basically anything which can never be a
101 101 # reasonable directory name will do, we just want the $HOME -> '~' operation
102 102 # to become a no-op. We pre-compute $HOME here so it's not done on every
103 103 # prompt call.
104 104
105 105 # FIXME:
106 106
107 107 # - This should be turned into a class which does proper namespace management,
108 108 # since the prompt specials need to be evaluated in a certain namespace.
109 109 # Currently it's just globals, which need to be managed manually by code
110 110 # below.
111 111
112 112 # - I also need to split up the color schemes from the prompt specials
113 113 # somehow. I don't have a clean design for that quite yet.
114 114
115 115 HOME = os.environ.get("HOME","//////:::::ZZZZZ,,,~~~")
116 116
117 117 # We precompute a few more strings here for the prompt_specials, which are
118 118 # fixed once ipython starts. This reduces the runtime overhead of computing
119 119 # prompt strings.
120 120 USER = os.environ.get("USER")
121 121 HOSTNAME = socket.gethostname()
122 122 HOSTNAME_SHORT = HOSTNAME.split(".")[0]
123 123 ROOT_SYMBOL = "$#"[os.name=='nt' or os.getuid()==0]
124 124
125 125 prompt_specials_color = {
126 126 # Prompt/history count
127 127 '%n' : '${self.col_num}' '${self.cache.prompt_count}' '${self.col_p}',
128 128 r'\#': '${self.col_num}' '${self.cache.prompt_count}' '${self.col_p}',
129 129 # Just the prompt counter number, WITHOUT any coloring wrappers, so users
130 130 # can get numbers displayed in whatever color they want.
131 131 r'\N': '${self.cache.prompt_count}',
132 132 # Prompt/history count, with the actual digits replaced by dots. Used
133 133 # mainly in continuation prompts (prompt_in2)
134 134 r'\D': '${"."*len(str(self.cache.prompt_count))}',
135 135 # Current working directory
136 136 r'\w': '${os.getcwd()}',
137 137 # Current time
138 138 r'\t' : '${time.strftime("%H:%M:%S")}',
139 139 # Basename of current working directory.
140 140 # (use os.sep to make this portable across OSes)
141 141 r'\W' : '${os.getcwd().split("%s")[-1]}' % os.sep,
142 142 # These X<N> are an extension to the normal bash prompts. They return
143 143 # N terms of the path, after replacing $HOME with '~'
144 144 r'\X0': '${os.getcwd().replace("%s","~")}' % HOME,
145 145 r'\X1': '${self.cwd_filt(1)}',
146 146 r'\X2': '${self.cwd_filt(2)}',
147 147 r'\X3': '${self.cwd_filt(3)}',
148 148 r'\X4': '${self.cwd_filt(4)}',
149 149 r'\X5': '${self.cwd_filt(5)}',
150 150 # Y<N> are similar to X<N>, but they show '~' if it's the directory
151 151 # N+1 in the list. Somewhat like %cN in tcsh.
152 152 r'\Y0': '${self.cwd_filt2(0)}',
153 153 r'\Y1': '${self.cwd_filt2(1)}',
154 154 r'\Y2': '${self.cwd_filt2(2)}',
155 155 r'\Y3': '${self.cwd_filt2(3)}',
156 156 r'\Y4': '${self.cwd_filt2(4)}',
157 157 r'\Y5': '${self.cwd_filt2(5)}',
158 158 # Hostname up to first .
159 159 r'\h': HOSTNAME_SHORT,
160 160 # Full hostname
161 161 r'\H': HOSTNAME,
162 162 # Username of current user
163 163 r'\u': USER,
164 164 # Escaped '\'
165 165 '\\\\': '\\',
166 166 # Newline
167 167 r'\n': '\n',
168 168 # Carriage return
169 169 r'\r': '\r',
170 170 # Release version
171 171 r'\v': __version__,
172 172 # Root symbol ($ or #)
173 173 r'\$': ROOT_SYMBOL,
174 174 }
175 175
176 176 # A copy of the prompt_specials dictionary but with all color escapes removed,
177 177 # so we can correctly compute the prompt length for the auto_rewrite method.
178 178 prompt_specials_nocolor = prompt_specials_color.copy()
179 179 prompt_specials_nocolor['%n'] = '${self.cache.prompt_count}'
180 180 prompt_specials_nocolor[r'\#'] = '${self.cache.prompt_count}'
181 181
182 182 # Add in all the InputTermColors color escapes as valid prompt characters.
183 183 # They all get added as \\C_COLORNAME, so that we don't have any conflicts
184 184 # with a color name which may begin with a letter used by any other of the
185 185 # allowed specials. This of course means that \\C will never be allowed for
186 186 # anything else.
187 187 input_colors = ColorANSI.InputTermColors
188 188 for _color in dir(input_colors):
189 189 if _color[0] != '_':
190 190 c_name = r'\C_'+_color
191 191 prompt_specials_color[c_name] = getattr(input_colors,_color)
192 192 prompt_specials_nocolor[c_name] = ''
193 193
194 194 # we default to no color for safety. Note that prompt_specials is a global
195 195 # variable used by all prompt objects.
196 196 prompt_specials = prompt_specials_nocolor
197 197
198 198 #-----------------------------------------------------------------------------
199 199 def str_safe(arg):
200 200 """Convert to a string, without ever raising an exception.
201 201
202 202 If str(arg) fails, <ERROR: ... > is returned, where ... is the exception
203 203 error message."""
204 204
205 205 try:
206 206 out = str(arg)
207 207 except UnicodeError:
208 208 try:
209 209 out = arg.encode('utf_8','replace')
210 210 except Exception,msg:
211 211 # let's keep this little duplication here, so that the most common
212 212 # case doesn't suffer from a double try wrapping.
213 213 out = '<ERROR: %s>' % msg
214 214 except Exception,msg:
215 215 out = '<ERROR: %s>' % msg
216 216 return out
217 217
218 class BasePrompt:
218 class BasePrompt(object):
219 219 """Interactive prompt similar to Mathematica's."""
220
221 def _get_p_template(self):
222 return self._p_template
223
224 def _set_p_template(self,val):
225 self._p_template = val
226 self.set_p_str()
227
228 p_template = property(_get_p_template,_set_p_template,
229 doc='Template for prompt string creation')
230
220 231 def __init__(self,cache,sep,prompt,pad_left=False):
221 232
222 233 # Hack: we access information about the primary prompt through the
223 234 # cache argument. We need this, because we want the secondary prompt
224 235 # to be aligned with the primary one. Color table info is also shared
225 236 # by all prompt classes through the cache. Nice OO spaghetti code!
226 237 self.cache = cache
227 238 self.sep = sep
228 239
229 240 # regexp to count the number of spaces at the end of a prompt
230 241 # expression, useful for prompt auto-rewriting
231 242 self.rspace = re.compile(r'(\s*)$')
232 243 # Flag to left-pad prompt strings to match the length of the primary
233 244 # prompt
234 245 self.pad_left = pad_left
235 # Set template to create each actual prompt (where numbers change)
246
247 # Set template to create each actual prompt (where numbers change).
248 # Use a property
236 249 self.p_template = prompt
237 250 self.set_p_str()
238 251
239 252 def set_p_str(self):
240 253 """ Set the interpolating prompt strings.
241 254
242 255 This must be called every time the color settings change, because the
243 256 prompt_specials global may have changed."""
244 257
245 258 import os,time # needed in locals for prompt string handling
246 259 loc = locals()
247 260 self.p_str = ItplNS('%s%s%s' %
248 261 ('${self.sep}${self.col_p}',
249 262 multiple_replace(prompt_specials, self.p_template),
250 263 '${self.col_norm}'),self.cache.user_ns,loc)
251 264
252 265 self.p_str_nocolor = ItplNS(multiple_replace(prompt_specials_nocolor,
253 266 self.p_template),
254 267 self.cache.user_ns,loc)
255 268
256 269 def write(self,msg): # dbg
257 270 sys.stdout.write(msg)
258 271 return ''
259 272
260 273 def __str__(self):
261 274 """Return a string form of the prompt.
262 275
263 276 This for is useful for continuation and output prompts, since it is
264 277 left-padded to match lengths with the primary one (if the
265 278 self.pad_left attribute is set)."""
266 279
267 280 out_str = str_safe(self.p_str)
268 281 if self.pad_left:
269 282 # We must find the amount of padding required to match lengths,
270 283 # taking the color escapes (which are invisible on-screen) into
271 284 # account.
272 285 esc_pad = len(out_str) - len(str_safe(self.p_str_nocolor))
273 286 format = '%%%ss' % (len(str(self.cache.last_prompt))+esc_pad)
274 287 return format % out_str
275 288 else:
276 289 return out_str
277 290
278 291 # these path filters are put in as methods so that we can control the
279 292 # namespace where the prompt strings get evaluated
280 293 def cwd_filt(self,depth):
281 294 """Return the last depth elements of the current working directory.
282 295
283 296 $HOME is always replaced with '~'.
284 297 If depth==0, the full path is returned."""
285 298
286 299 cwd = os.getcwd().replace(HOME,"~")
287 300 out = os.sep.join(cwd.split(os.sep)[-depth:])
288 301 if out:
289 302 return out
290 303 else:
291 304 return os.sep
292 305
293 306 def cwd_filt2(self,depth):
294 307 """Return the last depth elements of the current working directory.
295 308
296 309 $HOME is always replaced with '~'.
297 310 If depth==0, the full path is returned."""
298 311
299 312 cwd = os.getcwd().replace(HOME,"~").split(os.sep)
300 313 if '~' in cwd and len(cwd) == depth+1:
301 314 depth += 1
302 315 out = os.sep.join(cwd[-depth:])
303 316 if out:
304 317 return out
305 318 else:
306 319 return os.sep
307 320
308 321 class Prompt1(BasePrompt):
309 322 """Input interactive prompt similar to Mathematica's."""
310 323
311 324 def __init__(self,cache,sep='\n',prompt='In [\\#]: ',pad_left=True):
312 325 BasePrompt.__init__(self,cache,sep,prompt,pad_left)
313 326
314 327 def set_colors(self):
315 328 self.set_p_str()
316 329 Colors = self.cache.color_table.active_colors # shorthand
317 330 self.col_p = Colors.in_prompt
318 331 self.col_num = Colors.in_number
319 332 self.col_norm = Colors.in_normal
320 333 # We need a non-input version of these escapes for the '--->'
321 334 # auto-call prompts used in the auto_rewrite() method.
322 335 self.col_p_ni = self.col_p.replace('\001','').replace('\002','')
323 336 self.col_norm_ni = Colors.normal
324 337
325 338 def __str__(self):
326 339 self.cache.prompt_count += 1
327 340 self.cache.last_prompt = str_safe(self.p_str_nocolor).split('\n')[-1]
328 341 return str_safe(self.p_str)
329 342
330 343 def auto_rewrite(self):
331 344 """Print a string of the form '--->' which lines up with the previous
332 345 input string. Useful for systems which re-write the user input when
333 346 handling automatically special syntaxes."""
334 347
335 348 curr = str(self.cache.last_prompt)
336 349 nrspaces = len(self.rspace.search(curr).group())
337 350 return '%s%s>%s%s' % (self.col_p_ni,'-'*(len(curr)-nrspaces-1),
338 351 ' '*nrspaces,self.col_norm_ni)
339 352
340 353 class PromptOut(BasePrompt):
341 354 """Output interactive prompt similar to Mathematica's."""
342 355
343 356 def __init__(self,cache,sep='',prompt='Out[\\#]: ',pad_left=True):
344 357 BasePrompt.__init__(self,cache,sep,prompt,pad_left)
345 358 if not self.p_template:
346 359 self.__str__ = lambda: ''
347 360
348 361 def set_colors(self):
349 362 self.set_p_str()
350 363 Colors = self.cache.color_table.active_colors # shorthand
351 364 self.col_p = Colors.out_prompt
352 365 self.col_num = Colors.out_number
353 366 self.col_norm = Colors.normal
354 367
355 368 class Prompt2(BasePrompt):
356 369 """Interactive continuation prompt."""
357 370
358 371 def __init__(self,cache,prompt=' .\\D.: ',pad_left=True):
359 372 self.cache = cache
360 373 self.p_template = prompt
361 374 self.pad_left = pad_left
362 375 self.set_p_str()
363 376
364 377 def set_p_str(self):
365 378 import os,time # needed in locals for prompt string handling
366 379 loc = locals()
367 380 self.p_str = ItplNS('%s%s%s' %
368 381 ('${self.col_p2}',
369 382 multiple_replace(prompt_specials, self.p_template),
370 383 '$self.col_norm'),
371 384 self.cache.user_ns,loc)
372 385 self.p_str_nocolor = ItplNS(multiple_replace(prompt_specials_nocolor,
373 386 self.p_template),
374 387 self.cache.user_ns,loc)
375 388
376 389 def set_colors(self):
377 390 self.set_p_str()
378 391 Colors = self.cache.color_table.active_colors
379 392 self.col_p2 = Colors.in_prompt2
380 393 self.col_norm = Colors.in_normal
381 394 # FIXME (2004-06-16) HACK: prevent crashes for users who haven't
382 395 # updated their prompt_in2 definitions. Remove eventually.
383 396 self.col_p = Colors.out_prompt
384 397 self.col_num = Colors.out_number
385 398
386 399
387 400 #-----------------------------------------------------------------------------
388 401 class CachedOutput:
389 402 """Class for printing output from calculations while keeping a cache of
390 403 reults. It dynamically creates global variables prefixed with _ which
391 404 contain these results.
392 405
393 406 Meant to be used as a sys.displayhook replacement, providing numbered
394 407 prompts and cache services.
395 408
396 409 Initialize with initial and final values for cache counter (this defines
397 410 the maximum size of the cache."""
398 411
399 412 def __init__(self,shell,cache_size,Pprint,
400 413 colors='NoColor',input_sep='\n',
401 414 output_sep='\n',output_sep2='',
402 415 ps1 = None, ps2 = None,ps_out = None,pad_left=True):
403 416
404 417 cache_size_min = 3
405 418 if cache_size <= 0:
406 419 self.do_full_cache = 0
407 420 cache_size = 0
408 421 elif cache_size < cache_size_min:
409 422 self.do_full_cache = 0
410 423 cache_size = 0
411 424 warn('caching was disabled (min value for cache size is %s).' %
412 425 cache_size_min,level=3)
413 426 else:
414 427 self.do_full_cache = 1
415 428
416 429 self.cache_size = cache_size
417 430 self.input_sep = input_sep
418 431
419 432 # we need a reference to the user-level namespace
420 433 self.shell = shell
421 434 self.user_ns = shell.user_ns
422 435 # and to the user's input
423 436 self.input_hist = shell.input_hist
424 437 # and to the user's logger, for logging output
425 438 self.logger = shell.logger
426 439
427 440 # Set input prompt strings and colors
428 441 if cache_size == 0:
429 442 if ps1.find('%n') > -1 or ps1.find(r'\#') > -1 \
430 443 or ps1.find(r'\N') > -1:
431 444 ps1 = '>>> '
432 445 if ps2.find('%n') > -1 or ps2.find(r'\#') > -1 \
433 446 or ps2.find(r'\N') > -1:
434 447 ps2 = '... '
435 448 self.ps1_str = self._set_prompt_str(ps1,'In [\\#]: ','>>> ')
436 449 self.ps2_str = self._set_prompt_str(ps2,' .\\D.: ','... ')
437 450 self.ps_out_str = self._set_prompt_str(ps_out,'Out[\\#]: ','')
438 451
439 452 self.color_table = PromptColors
440 453 self.prompt1 = Prompt1(self,sep=input_sep,prompt=self.ps1_str,
441 454 pad_left=pad_left)
442 455 self.prompt2 = Prompt2(self,prompt=self.ps2_str,pad_left=pad_left)
443 456 self.prompt_out = PromptOut(self,sep='',prompt=self.ps_out_str,
444 457 pad_left=pad_left)
445 458 self.set_colors(colors)
446 459
447 460 # other more normal stuff
448 461 # b/c each call to the In[] prompt raises it by 1, even the first.
449 462 self.prompt_count = 0
450 463 # Store the last prompt string each time, we need it for aligning
451 464 # continuation and auto-rewrite prompts
452 465 self.last_prompt = ''
453 466 self.Pprint = Pprint
454 467 self.output_sep = output_sep
455 468 self.output_sep2 = output_sep2
456 469 self._,self.__,self.___ = '','',''
457 470 self.pprint_types = map(type,[(),[],{}])
458 471
459 472 # these are deliberately global:
460 473 to_user_ns = {'_':self._,'__':self.__,'___':self.___}
461 474 self.user_ns.update(to_user_ns)
462 475
463 476 def _set_prompt_str(self,p_str,cache_def,no_cache_def):
464 477 if p_str is None:
465 478 if self.do_full_cache:
466 479 return cache_def
467 480 else:
468 481 return no_cache_def
469 482 else:
470 483 return p_str
471 484
472 485 def set_colors(self,colors):
473 486 """Set the active color scheme and configure colors for the three
474 487 prompt subsystems."""
475 488
476 489 # FIXME: the prompt_specials global should be gobbled inside this
477 490 # class instead. Do it when cleaning up the whole 3-prompt system.
478 491 global prompt_specials
479 492 if colors.lower()=='nocolor':
480 493 prompt_specials = prompt_specials_nocolor
481 494 else:
482 495 prompt_specials = prompt_specials_color
483 496
484 497 self.color_table.set_active_scheme(colors)
485 498 self.prompt1.set_colors()
486 499 self.prompt2.set_colors()
487 500 self.prompt_out.set_colors()
488 501
489 502 def __call__(self,arg=None):
490 503 """Printing with history cache management.
491 504
492 505 This is invoked everytime the interpreter needs to print, and is
493 506 activated by setting the variable sys.displayhook to it."""
494 507
495 508 # If something injected a '_' variable in __builtin__, delete
496 509 # ipython's automatic one so we don't clobber that. gettext() in
497 510 # particular uses _, so we need to stay away from it.
498 511 if '_' in __builtin__.__dict__:
499 512 try:
500 513 del self.user_ns['_']
501 514 except KeyError:
502 515 pass
503 516 if arg is not None:
504 517 cout_write = Term.cout.write # fast lookup
505 518 # first handle the cache and counters
506 519
507 520 # do not print output if input ends in ';'
508 521 if self.input_hist[self.prompt_count].endswith(';\n'):
509 522 return
510 523 # don't use print, puts an extra space
511 524 cout_write(self.output_sep)
512 525 outprompt = self.shell.hooks.generate_output_prompt()
513 526 if self.do_full_cache:
514 527 cout_write(outprompt)
515 528
516 529 # and now call a possibly user-defined print mechanism
517 530 manipulated_val = self.display(arg)
518 531
519 532 # user display hooks can change the variable to be stored in
520 533 # output history
521 534
522 535 if manipulated_val is not None:
523 536 arg = manipulated_val
524 537
525 538 # avoid recursive reference when displaying _oh/Out
526 539 if arg is not self.user_ns['_oh']:
527 540 self.update(arg)
528 541
529 542 if self.logger.log_output:
530 543 self.logger.log_write(repr(arg),'output')
531 544 cout_write(self.output_sep2)
532 545 Term.cout.flush()
533 546
534 547 def _display(self,arg):
535 548 """Default printer method, uses pprint.
536 549
537 550 Do ip.set_hook("result_display", my_displayhook) for custom result
538 551 display, e.g. when your own objects need special formatting.
539 552 """
540 553 try:
541 554 return IPython.generics.result_display(arg)
542 555 except TryNext:
543 556 return self.shell.hooks.result_display(arg)
544 557
545 558 # Assign the default display method:
546 559 display = _display
547 560
548 561 def update(self,arg):
549 562 #print '***cache_count', self.cache_count # dbg
550 563 if len(self.user_ns['_oh']) >= self.cache_size and self.do_full_cache:
551 564 warn('Output cache limit (currently '+
552 565 `self.cache_size`+' entries) hit.\n'
553 566 'Flushing cache and resetting history counter...\n'
554 567 'The only history variables available will be _,__,___ and _1\n'
555 568 'with the current result.')
556 569
557 570 self.flush()
558 571 # Don't overwrite '_' and friends if '_' is in __builtin__ (otherwise
559 572 # we cause buggy behavior for things like gettext).
560 573 if '_' not in __builtin__.__dict__:
561 574 self.___ = self.__
562 575 self.__ = self._
563 576 self._ = arg
564 577 self.user_ns.update({'_':self._,'__':self.__,'___':self.___})
565 578
566 579 # hackish access to top-level namespace to create _1,_2... dynamically
567 580 to_main = {}
568 581 if self.do_full_cache:
569 582 new_result = '_'+`self.prompt_count`
570 583 to_main[new_result] = arg
571 584 self.user_ns.update(to_main)
572 585 self.user_ns['_oh'][self.prompt_count] = arg
573 586
574 587 def flush(self):
575 588 if not self.do_full_cache:
576 589 raise ValueError,"You shouldn't have reached the cache flush "\
577 590 "if full caching is not enabled!"
578 591 # delete auto-generated vars from global namespace
579 592
580 593 for n in range(1,self.prompt_count + 1):
581 594 key = '_'+`n`
582 595 try:
583 596 del self.user_ns[key]
584 597 except: pass
585 598 self.user_ns['_oh'].clear()
586 599
587 600 if '_' not in __builtin__.__dict__:
588 601 self.user_ns.update({'_':None,'__':None, '___':None})
589 602 import gc
590 603 gc.collect() # xxx needed?
591 604
@@ -1,463 +1,484 b''
1 1 ''' IPython customization API
2 2
3 3 Your one-stop module for configuring & extending ipython
4 4
5 5 The API will probably break when ipython 1.0 is released, but so
6 6 will the other configuration method (rc files).
7 7
8 8 All names prefixed by underscores are for internal use, not part
9 9 of the public api.
10 10
11 11 Below is an example that you can just put to a module and import from ipython.
12 12
13 13 A good practice is to install the config script below as e.g.
14 14
15 15 ~/.ipython/my_private_conf.py
16 16
17 17 And do
18 18
19 19 import_mod my_private_conf
20 20
21 21 in ~/.ipython/ipythonrc
22 22
23 23 That way the module is imported at startup and you can have all your
24 24 personal configuration (as opposed to boilerplate ipythonrc-PROFILENAME
25 25 stuff) in there.
26 26
27 27 -----------------------------------------------
28 28 import IPython.ipapi
29 29 ip = IPython.ipapi.get()
30 30
31 31 def ankka_f(self, arg):
32 32 print "Ankka",self,"says uppercase:",arg.upper()
33 33
34 34 ip.expose_magic("ankka",ankka_f)
35 35
36 36 ip.magic('alias sayhi echo "Testing, hi ok"')
37 37 ip.magic('alias helloworld echo "Hello world"')
38 38 ip.system('pwd')
39 39
40 40 ip.ex('import re')
41 41 ip.ex("""
42 42 def funcci(a,b):
43 43 print a+b
44 44 print funcci(3,4)
45 45 """)
46 46 ip.ex("funcci(348,9)")
47 47
48 48 def jed_editor(self,filename, linenum=None):
49 49 print "Calling my own editor, jed ... via hook!"
50 50 import os
51 51 if linenum is None: linenum = 0
52 52 os.system('jed +%d %s' % (linenum, filename))
53 53 print "exiting jed"
54 54
55 55 ip.set_hook('editor',jed_editor)
56 56
57 57 o = ip.options
58 58 o.autocall = 2 # FULL autocall mode
59 59
60 60 print "done!"
61 61 '''
62 62
63 63 # stdlib imports
64 64 import __builtin__
65 65 import sys
66 66
67 67 # our own
68 68 #from IPython.genutils import warn,error
69 69
70 70 class TryNext(Exception):
71 71 """Try next hook exception.
72 72
73 73 Raise this in your hook function to indicate that the next hook handler
74 74 should be used to handle the operation. If you pass arguments to the
75 75 constructor those arguments will be used by the next hook instead of the
76 76 original ones.
77 77 """
78 78
79 79 def __init__(self, *args, **kwargs):
80 80 self.args = args
81 81 self.kwargs = kwargs
82 82
83 83 class IPyAutocall:
84 84 """ Instances of this class are always autocalled
85 85
86 86 This happens regardless of 'autocall' variable state. Use this to
87 87 develop macro-like mechanisms.
88 88 """
89 89
90 90 def set_ip(self,ip):
91 91 """ Will be used to set _ip point to current ipython instance b/f call
92 92
93 93 Override this method if you don't want this to happen.
94 94
95 95 """
96 96 self._ip = ip
97 97
98 98
99 99 # contains the most recently instantiated IPApi
100 100
101 101 class IPythonNotRunning:
102 102 """Dummy do-nothing class.
103 103
104 104 Instances of this class return a dummy attribute on all accesses, which
105 105 can be called and warns. This makes it easier to write scripts which use
106 106 the ipapi.get() object for informational purposes to operate both with and
107 107 without ipython. Obviously code which uses the ipython object for
108 108 computations will not work, but this allows a wider range of code to
109 109 transparently work whether ipython is being used or not."""
110 110
111 111 def __init__(self,warn=True):
112 112 if warn:
113 113 self.dummy = self._dummy_warn
114 114 else:
115 115 self.dummy = self._dummy_silent
116 116
117 117 def __str__(self):
118 118 return "<IPythonNotRunning>"
119 119
120 120 __repr__ = __str__
121 121
122 122 def __getattr__(self,name):
123 123 return self.dummy
124 124
125 125 def _dummy_warn(self,*args,**kw):
126 126 """Dummy function, which doesn't do anything but warn."""
127 127
128 128 print ("IPython is not running, this is a dummy no-op function")
129 129
130 130 def _dummy_silent(self,*args,**kw):
131 131 """Dummy function, which doesn't do anything and emits no warnings."""
132 132 pass
133 133
134 134 _recent = None
135 135
136 136
137 137 def get(allow_dummy=False,dummy_warn=True):
138 138 """Get an IPApi object.
139 139
140 140 If allow_dummy is true, returns an instance of IPythonNotRunning
141 141 instead of None if not running under IPython.
142 142
143 143 If dummy_warn is false, the dummy instance will be completely silent.
144 144
145 145 Running this should be the first thing you do when writing extensions that
146 146 can be imported as normal modules. You can then direct all the
147 147 configuration operations against the returned object.
148 148 """
149 149 global _recent
150 150 if allow_dummy and not _recent:
151 151 _recent = IPythonNotRunning(dummy_warn)
152 152 return _recent
153 153
154 154 class IPApi:
155 155 """ The actual API class for configuring IPython
156 156
157 157 You should do all of the IPython configuration by getting an IPApi object
158 158 with IPython.ipapi.get() and using the attributes and methods of the
159 159 returned object."""
160 160
161 161 def __init__(self,ip):
162 162
163 163 # All attributes exposed here are considered to be the public API of
164 164 # IPython. As needs dictate, some of these may be wrapped as
165 165 # properties.
166 166
167 167 self.magic = ip.ipmagic
168 168
169 169 self.system = ip.system
170 170
171 171 self.set_hook = ip.set_hook
172 172
173 173 self.set_custom_exc = ip.set_custom_exc
174 174
175 175 self.user_ns = ip.user_ns
176 176
177 177 self.set_crash_handler = ip.set_crash_handler
178 178
179 179 # Session-specific data store, which can be used to store
180 180 # data that should persist through the ipython session.
181 181 self.meta = ip.meta
182 182
183 183 # The ipython instance provided
184 184 self.IP = ip
185 185
186 186 self.extensions = {}
187 187 global _recent
188 188 _recent = self
189 189
190 190 # Use a property for some things which are added to the instance very
191 191 # late. I don't have time right now to disentangle the initialization
192 192 # order issues, so a property lets us delay item extraction while
193 193 # providing a normal attribute API.
194 194 def get_db(self):
195 195 """A handle to persistent dict-like database (a PickleShareDB object)"""
196 196 return self.IP.db
197 197
198 198 db = property(get_db,None,None,get_db.__doc__)
199 199
200 200 def get_options(self):
201 201 """All configurable variables."""
202 202
203 203 # catch typos by disabling new attribute creation. If new attr creation
204 204 # is in fact wanted (e.g. when exposing new options), do allow_new_attr(True)
205 205 # for the received rc struct.
206 206
207 207 self.IP.rc.allow_new_attr(False)
208 208 return self.IP.rc
209 209
210 210 options = property(get_options,None,None,get_options.__doc__)
211 211
212 212 def expose_magic(self,magicname, func):
213 213 ''' Expose own function as magic function for ipython
214 214
215 215 def foo_impl(self,parameter_s=''):
216 216 """My very own magic!. (Use docstrings, IPython reads them)."""
217 217 print 'Magic function. Passed parameter is between < >: <'+parameter_s+'>'
218 218 print 'The self object is:',self
219 219
220 220 ipapi.expose_magic("foo",foo_impl)
221 221 '''
222 222
223 223 import new
224 224 im = new.instancemethod(func,self.IP, self.IP.__class__)
225 225 setattr(self.IP, "magic_" + magicname, im)
226 226
227 227 def ex(self,cmd):
228 228 """ Execute a normal python statement in user namespace """
229 229 exec cmd in self.user_ns
230 230
231 231 def ev(self,expr):
232 232 """ Evaluate python expression expr in user namespace
233 233
234 234 Returns the result of evaluation"""
235 235 return eval(expr,self.user_ns)
236 236
237 237 def runlines(self,lines):
238 238 """ Run the specified lines in interpreter, honoring ipython directives.
239 239
240 240 This allows %magic and !shell escape notations.
241 241
242 242 Takes either all lines in one string or list of lines.
243 243 """
244 244 if isinstance(lines,basestring):
245 245 self.IP.runlines(lines)
246 246 else:
247 247 self.IP.runlines('\n'.join(lines))
248 248
249 249 def to_user_ns(self,vars, interactive = True):
250 250 """Inject a group of variables into the IPython user namespace.
251 251
252 252 Inputs:
253 253
254 - vars: string with variable names separated by whitespace
254 - vars: string with variable names separated by whitespace, or a
255 dict with name/value pairs.
255 256
256 257 - interactive: if True (default), the var will be listed with
257 258 %whos et. al.
258 259
259 260 This utility routine is meant to ease interactive debugging work,
260 261 where you want to easily propagate some internal variable in your code
261 262 up to the interactive namespace for further exploration.
262 263
263 264 When you run code via %run, globals in your script become visible at
264 265 the interactive prompt, but this doesn't happen for locals inside your
265 266 own functions and methods. Yet when debugging, it is common to want
266 267 to explore some internal variables further at the interactive propmt.
267 268
268 269 Examples:
269 270
270 271 To use this, you first must obtain a handle on the ipython object as
271 272 indicated above, via:
272 273
273 274 import IPython.ipapi
274 275 ip = IPython.ipapi.get()
275 276
276 277 Once this is done, inside a routine foo() where you want to expose
277 278 variables x and y, you do the following:
278 279
279 280 def foo():
280 281 ...
281 282 x = your_computation()
282 283 y = something_else()
283 284
284 285 # This pushes x and y to the interactive prompt immediately, even
285 286 # if this routine crashes on the next line after:
286 287 ip.to_user_ns('x y')
287 288 ...
289
290 # To expose *ALL* the local variables from the function, use:
291 ip.to_user_ns(locals())
292
293 ...
288 294 # return
289 295
290 If you need to rename variables, just use ip.user_ns with dict
291 and update:
292 296
293 # exposes variables 'foo' as 'x' and 'bar' as 'y' in IPython
294 # user namespace
295 ip.user_ns.update(dict(x=foo,y=bar))
297 If you need to rename variables, the dict input makes it easy. For
298 example, this call exposes variables 'foo' as 'x' and 'bar' as 'y'
299 in IPython user namespace:
300
301 ip.to_user_ns(dict(x=foo,y=bar))
296 302 """
297 303
298 304 # print 'vars given:',vars # dbg
299 # Get the caller's frame to evaluate the given names in
300 cf = sys._getframe(1)
301 305
302 user_ns = self.user_ns
303 config_ns = self.IP.user_config_ns
306 # We need a dict of name/value pairs to do namespace updates.
307 if isinstance(vars,dict):
308 # If a dict was given, no need to change anything.
309 vdict = vars
310 elif isinstance(vars,basestring):
311 # If a string with names was given, get the caller's frame to
312 # evaluate the given names in
313 cf = sys._getframe(1)
314 vdict = {}
304 315 for name in vars.split():
305 316 try:
306 val = eval(name,cf.f_globals,cf.f_locals)
307 user_ns[name] = val
308 if not interactive:
309 config_ns[name] = val
310 else:
311 config_ns.pop(name,None)
317 vdict[name] = eval(name,cf.f_globals,cf.f_locals)
312 318 except:
313 319 print ('could not get var. %s from %s' %
314 320 (name,cf.f_code.co_name))
321 else:
322 raise ValueError('vars must be a string or a dict')
323
324 # Propagate variables to user namespace
325 self.user_ns.update(vdict)
326
327 # And configure interactive visibility
328 config_ns = self.IP.user_config_ns
329 if interactive:
330 for name,val in vdict.iteritems():
331 config_ns.pop(name,None)
332 else:
333 for name,val in vdict.iteritems():
334 config_ns[name] = val
335
315 336
316 337 def expand_alias(self,line):
317 338 """ Expand an alias in the command line
318 339
319 340 Returns the provided command line, possibly with the first word
320 341 (command) translated according to alias expansion rules.
321 342
322 343 [ipython]|16> _ip.expand_aliases("np myfile.txt")
323 344 <16> 'q:/opt/np/notepad++.exe myfile.txt'
324 345 """
325 346
326 347 pre,fn,rest = self.IP.split_user_input(line)
327 348 res = pre + self.IP.expand_aliases(fn,rest)
328 349 return res
329 350
330 351 def defalias(self, name, cmd):
331 352 """ Define a new alias
332 353
333 354 _ip.defalias('bb','bldmake bldfiles')
334 355
335 356 Creates a new alias named 'bb' in ipython user namespace
336 357 """
337 358
338 359 if callable(cmd):
339 360 self.IP.alias_table[name] = cmd
340 361 import IPython.shawodns
341 362 setattr(IPython.shadowns, name,cmd)
342 363 return
343 364
344 365
345 366 nargs = cmd.count('%s')
346 367 if nargs>0 and cmd.find('%l')>=0:
347 368 raise Exception('The %s and %l specifiers are mutually exclusive '
348 369 'in alias definitions.')
349 370
350 371 else: # all looks OK
351 372 self.IP.alias_table[name] = (nargs,cmd)
352 373
353 374 def defmacro(self, *args):
354 375 """ Define a new macro
355 376
356 377 2 forms of calling:
357 378
358 379 mac = _ip.defmacro('print "hello"\nprint "world"')
359 380
360 381 (doesn't put the created macro on user namespace)
361 382
362 383 _ip.defmacro('build', 'bldmake bldfiles\nabld build winscw udeb')
363 384
364 385 (creates a macro named 'build' in user namespace)
365 386 """
366 387
367 388 import IPython.macro
368 389
369 390 if len(args) == 1:
370 391 return IPython.macro.Macro(args[0])
371 392 elif len(args) == 2:
372 393 self.user_ns[args[0]] = IPython.macro.Macro(args[1])
373 394 else:
374 395 return Exception("_ip.defmacro must be called with 1 or 2 arguments")
375 396
376 397 def set_next_input(self, s):
377 398 """ Sets the 'default' input string for the next command line.
378 399
379 400 Requires readline.
380 401
381 402 Example:
382 403
383 404 [D:\ipython]|1> _ip.set_next_input("Hello Word")
384 405 [D:\ipython]|2> Hello Word_ # cursor is here
385 406 """
386 407
387 408 self.IP.rl_next_input = s
388 409
389 410 def load(self, mod):
390 411 if mod in self.extensions:
391 412 # just to make sure we don't init it twice
392 413 # note that if you 'load' a module that has already been
393 414 # imported, init_ipython gets run anyway
394 415
395 416 return self.extensions[mod]
396 417 __import__(mod)
397 418 m = sys.modules[mod]
398 419 if hasattr(m,'init_ipython'):
399 420 m.init_ipython(self)
400 421 self.extensions[mod] = m
401 422 return m
402 423
403 424
404 425 def launch_new_instance(user_ns = None):
405 426 """ Make and start a new ipython instance.
406 427
407 428 This can be called even without having an already initialized
408 429 ipython session running.
409 430
410 431 This is also used as the egg entry point for the 'ipython' script.
411 432
412 433 """
413 434 ses = make_session(user_ns)
414 435 ses.mainloop()
415 436
416 437
417 438 def make_user_ns(user_ns = None):
418 439 """Return a valid user interactive namespace.
419 440
420 441 This builds a dict with the minimal information needed to operate as a
421 442 valid IPython user namespace, which you can pass to the various embedding
422 443 classes in ipython.
423 444 """
424 445
425 446 if user_ns is None:
426 447 # Set __name__ to __main__ to better match the behavior of the
427 448 # normal interpreter.
428 449 user_ns = {'__name__' :'__main__',
429 450 '__builtins__' : __builtin__,
430 451 }
431 452 else:
432 453 user_ns.setdefault('__name__','__main__')
433 454 user_ns.setdefault('__builtins__',__builtin__)
434 455
435 456 return user_ns
436 457
437 458
438 459 def make_user_global_ns(ns = None):
439 460 """Return a valid user global namespace.
440 461
441 462 Similar to make_user_ns(), but global namespaces are really only needed in
442 463 embedded applications, where there is a distinction between the user's
443 464 interactive namespace and the global one where ipython is running."""
444 465
445 466 if ns is None: ns = {}
446 467 return ns
447 468
448 469
449 470 def make_session(user_ns = None):
450 471 """Makes, but does not launch an IPython session.
451 472
452 473 Later on you can call obj.mainloop() on the returned object.
453 474
454 475 Inputs:
455 476
456 477 - user_ns(None): a dict to be used as the user's namespace with initial
457 478 data.
458 479
459 480 WARNING: This should *not* be run when a session exists already."""
460 481
461 482 import IPython
462 483 return IPython.Shell.start(user_ns)
463 484
@@ -1,6954 +1,6965 b''
1 2007-8-9 Fernando Perez <fperez@planck.colorado.edu>
2
3 * IPython/ipapi.py (to_user_ns): update to accept a dict as well as
4 a string with names.
5
6 2007-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
7
8 * IPython/Magic.py (magic_doctest_mode): added new %doctest_mode
9 magic to toggle on/off the doctest pasting support without having
10 to leave a session to switch to a separate profile.
11
1 12 2007-08-08 Fernando Perez <Fernando.Perez@colorado.edu>
2 13
3 14 * IPython/Extensions/ipy_profile_doctest.py (main): fix prompt to
4 15 introduce a blank line between inputs, to conform to doctest
5 16 requirements.
6 17
7 18 * IPython/OInspect.py (Inspector.pinfo): fix another part where
8 19 auto-generated docstrings for new-style classes were showing up.
9 20
10 21 2007-08-07 Fernando Perez <Fernando.Perez@colorado.edu>
11 22
12 23 * api_changes: Add new file to track backward-incompatible
13 24 user-visible changes.
14 25
15 26 2007-08-06 Ville Vainio <vivainio@gmail.com>
16 27
17 28 * ipmaker.py: fix bug where user_config_ns didn't exist at all
18 29 before all the config files were handled.
19 30
20 31 2007-08-04 Fernando Perez <Fernando.Perez@colorado.edu>
21 32
22 33 * IPython/irunner.py (RunnerFactory): Add new factory class for
23 34 creating reusable runners based on filenames.
24 35
25 36 * IPython/Extensions/ipy_profile_doctest.py: New profile for
26 37 doctest support. It sets prompts/exceptions as similar to
27 38 standard Python as possible, so that ipython sessions in this
28 39 profile can be easily pasted as doctests with minimal
29 40 modifications. It also enables pasting of doctests from external
30 41 sources (even if they have leading whitespace), so that you can
31 42 rerun doctests from existing sources.
32 43
33 44 * IPython/iplib.py (_prefilter): fix a buglet where after entering
34 45 some whitespace, the prompt would become a continuation prompt
35 46 with no way of exiting it other than Ctrl-C. This fix brings us
36 47 into conformity with how the default python prompt works.
37 48
38 49 * IPython/Extensions/InterpreterPasteInput.py (prefilter_paste):
39 50 Add support for pasting not only lines that start with '>>>', but
40 51 also with ' >>>'. That is, arbitrary whitespace can now precede
41 52 the prompts. This makes the system useful for pasting doctests
42 53 from docstrings back into a normal session.
43 54
44 55 2007-08-02 Fernando Perez <Fernando.Perez@colorado.edu>
45 56
46 57 * IPython/Shell.py (IPShellEmbed.__call__): fix bug introduced in
47 58 r1357, which had killed multiple invocations of an embedded
48 59 ipython (this means that example-embed has been broken for over 1
49 60 year!!!). Rather than possibly breaking the batch stuff for which
50 61 the code in iplib.py/interact was introduced, I worked around the
51 62 problem in the embedding class in Shell.py. We really need a
52 63 bloody test suite for this code, I'm sick of finding stuff that
53 64 used to work breaking left and right every time I use an old
54 65 feature I hadn't touched in a few months.
55 66 (kill_embedded): Add a new magic that only shows up in embedded
56 67 mode, to allow users to permanently deactivate an embedded instance.
57 68
58 69 2007-08-01 Ville Vainio <vivainio@gmail.com>
59 70
60 71 * iplib.py, ipy_profile_sh.py (runlines): Fix the bug where raw
61 72 history gets out of sync on runlines (e.g. when running macros).
62 73
63 74 2007-07-31 Fernando Perez <Fernando.Perez@colorado.edu>
64 75
65 76 * IPython/Magic.py (magic_colors): fix win32-related error message
66 77 that could appear under *nix when readline was missing. Patch by
67 78 Scott Jackson, closes #175.
68 79
69 80 2007-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
70 81
71 82 * IPython/Extensions/ipy_traits_completer.py: Add a new custom
72 83 completer that it traits-aware, so that traits objects don't show
73 84 all of their internal attributes all the time.
74 85
75 86 * IPython/genutils.py (dir2): moved this code from inside
76 87 completer.py to expose it publicly, so I could use it in the
77 88 wildcards bugfix.
78 89
79 90 * IPython/wildcard.py (NameSpace.__init__): fix a bug reported by
80 91 Stefan with Traits.
81 92
82 93 * IPython/completer.py (Completer.attr_matches): change internal
83 94 var name from 'object' to 'obj', since 'object' is now a builtin
84 95 and this can lead to weird bugs if reusing this code elsewhere.
85 96
86 97 2007-07-25 Fernando Perez <Fernando.Perez@colorado.edu>
87 98
88 99 * IPython/OInspect.py (Inspector.pinfo): fix small glitches in
89 100 'foo?' and update the code to prevent printing of default
90 101 docstrings that started appearing after I added support for
91 102 new-style classes. The approach I'm using isn't ideal (I just
92 103 special-case those strings) but I'm not sure how to more robustly
93 104 differentiate between truly user-written strings and Python's
94 105 automatic ones.
95 106
96 107 2007-07-09 Ville Vainio <vivainio@gmail.com>
97 108
98 109 * completer.py: Applied Matthew Neeley's patch:
99 110 Dynamic attributes from trait_names and _getAttributeNames are added
100 111 to the list of tab completions, but when this happens, the attribute
101 112 list is turned into a set, so the attributes are unordered when
102 113 printed, which makes it hard to find the right completion. This patch
103 114 turns this set back into a list and sort it.
104 115
105 116 2007-07-06 Fernando Perez <Fernando.Perez@colorado.edu>
106 117
107 118 * IPython/OInspect.py (Inspector.pinfo): Add support for new-style
108 119 classes in various inspector functions.
109 120
110 121 2007-06-28 Ville Vainio <vivainio@gmail.com>
111 122
112 123 * shadowns.py, iplib.py, ipapi.py, OInspect.py:
113 124 Implement "shadow" namespace, and callable aliases that reside there.
114 125 Use them by:
115 126
116 127 _ip.defalias('foo',myfunc) # creates _sh.foo that points to myfunc
117 128
118 129 foo hello world
119 130 (gets translated to:)
120 131 _sh.foo(r"""hello world""")
121 132
122 133 In practice, this kind of alias can take the role of a magic function
123 134
124 135 * New generic inspect_object, called on obj? and obj??
125 136
126 137 2007-06-15 Fernando Perez <Fernando.Perez@colorado.edu>
127 138
128 139 * IPython/ultraTB.py (findsource): fix a problem with
129 140 inspect.getfile that can cause crashes during traceback construction.
130 141
131 142 2007-06-14 Ville Vainio <vivainio@gmail.com>
132 143
133 144 * iplib.py (handle_auto): Try to use ascii for printing "--->"
134 145 autocall rewrite indication, becausesometimes unicode fails to print
135 146 properly (and you get ' - - - '). Use plain uncoloured ---> for
136 147 unicode.
137 148
138 149 * shadow history. Usable through "%hist -g <pat>" and "%rep 0123".
139 150
140 151 . pickleshare 'hash' commands (hget, hset, hcompress,
141 152 hdict) for efficient shadow history storage.
142 153
143 154 2007-06-13 Ville Vainio <vivainio@gmail.com>
144 155
145 156 * ipapi.py: _ip.to_user_ns(vars, interactive = True).
146 157 Added kw arg 'interactive', tell whether vars should be visible
147 158 with %whos.
148 159
149 160 2007-06-11 Ville Vainio <vivainio@gmail.com>
150 161
151 162 * pspersistence.py, Magic.py, iplib.py: directory history now saved
152 163 to db
153 164
154 165 * iplib.py: "ipython -c <cmd>" now passes the command through prefilter.
155 166 Also, it exits IPython immediately after evaluating the command (just like
156 167 std python)
157 168
158 169 2007-06-05 Walter Doerwald <walter@livinglogic.de>
159 170
160 171 * IPython/Extensions/ipipe.py: Added a new table icap, which executes a
161 172 Python string and captures the output. (Idea and original patch by
162 173 StοΏ½fan van der Walt)
163 174
164 175 2007-06-01 Fernando Perez <Fernando.Perez@colorado.edu>
165 176
166 177 * IPython/ultraTB.py (VerboseTB.text): update printing of
167 178 exception types for Python 2.5 (now all exceptions in the stdlib
168 179 are new-style classes).
169 180
170 181 2007-05-31 Walter Doerwald <walter@livinglogic.de>
171 182
172 183 * IPython/Extensions/igrid.py: Add new commands refresh and
173 184 refresh_timer (mapped to "R"/"F5" and to the menu) which restarts
174 185 the iterator once (refresh) or after every x seconds (refresh_timer).
175 186 Add a working implementation of "searchexpression", where the text
176 187 entered is not the text to search for, but an expression that must
177 188 be true. Added display of shortcuts to the menu. Added commands "pickinput"
178 189 and "pickinputattr" that put the object or attribute under the cursor
179 190 in the input line. Split the statusbar to be able to display the currently
180 191 active refresh interval. (Patch by Nik Tautenhahn)
181 192
182 193 2007-05-29 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
183 194
184 195 * fixing set_term_title to use ctypes as default
185 196
186 197 * fixing set_term_title fallback to work when curent dir
187 198 is on a windows network share
188 199
189 200 2007-05-28 Ville Vainio <vivainio@gmail.com>
190 201
191 202 * %cpaste: strip + with > from left (diffs).
192 203
193 204 * iplib.py: Fix crash when readline not installed
194 205
195 206 2007-05-26 Ville Vainio <vivainio@gmail.com>
196 207
197 208 * generics.py: intruduce easy to extend result_display generic
198 209 function (using simplegeneric.py).
199 210
200 211 * Fixed the append functionality of %set.
201 212
202 213 2007-05-25 Ville Vainio <vivainio@gmail.com>
203 214
204 215 * New magic: %rep (fetch / run old commands from history)
205 216
206 217 * New extension: mglob (%mglob magic), for powerful glob / find /filter
207 218 like functionality
208 219
209 220 % maghistory.py: %hist -g PATTERM greps the history for pattern
210 221
211 222 2007-05-24 Walter Doerwald <walter@livinglogic.de>
212 223
213 224 * IPython/Extensions/ipipe.py: Added a Table ihist that can be used to
214 225 browse the IPython input history
215 226
216 227 * IPython/Extensions/ibrowse.py: Added two command to ibrowse: pickinput
217 228 (mapped to "i") can be used to put the object under the curser in the input
218 229 line. pickinputattr (mapped to "I") does the same for the attribute under
219 230 the cursor.
220 231
221 232 2007-05-24 Ville Vainio <vivainio@gmail.com>
222 233
223 234 * Grand magic cleansing (changeset [2380]):
224 235
225 236 * Introduce ipy_legacy.py where the following magics were
226 237 moved:
227 238
228 239 pdef pdoc psource pfile rehash dhist Quit p r automagic autocall
229 240
230 241 If you need them, either use default profile or "import ipy_legacy"
231 242 in your ipy_user_conf.py
232 243
233 244 * Move sh and scipy profile to Extensions from UserConfig. this implies
234 245 you should not edit them, but you don't need to run %upgrade when
235 246 upgrading IPython anymore.
236 247
237 248 * %hist/%history now operates in "raw" mode by default. To get the old
238 249 behaviour, run '%hist -n' (native mode).
239 250
240 251 * split ipy_stock_completers.py to ipy_stock_completers.py and
241 252 ipy_app_completers.py. Stock completers (%cd, import, %run) are now
242 253 installed as default.
243 254
244 255 * sh profile now installs ipy_signals.py, for (hopefully) better ctrl+c
245 256 handling.
246 257
247 258 * iplib.py, ipapi.py: _ip.set_next_input(s) sets the next ("default")
248 259 input if readline is available.
249 260
250 261 2007-05-23 Ville Vainio <vivainio@gmail.com>
251 262
252 263 * macro.py: %store uses __getstate__ properly
253 264
254 265 * exesetup.py: added new setup script for creating
255 266 standalone IPython executables with py2exe (i.e.
256 267 no python installation required).
257 268
258 269 * Removed ipythonrc-scipy, ipy_profile_scipy.py takes
259 270 its place.
260 271
261 272 * rlineimpl.py, genutils.py (get_home_dir): py2exe support
262 273
263 274 2007-05-21 Ville Vainio <vivainio@gmail.com>
264 275
265 276 * platutil_win32.py (set_term_title): handle
266 277 failure of 'title' system call properly.
267 278
268 279 2007-05-17 Walter Doerwald <walter@livinglogic.de>
269 280
270 281 * IPython/Extensions/ipipe.py: Fix xrepr for ifiles.
271 282 (Bug detected by Paul Mueller).
272 283
273 284 2007-05-16 Ville Vainio <vivainio@gmail.com>
274 285
275 286 * ipy_profile_sci.py, ipython_win_post_install.py: Create
276 287 new "sci" profile, effectively a modern version of the old
277 288 "scipy" profile (which is now slated for deprecation).
278 289
279 290 2007-05-15 Ville Vainio <vivainio@gmail.com>
280 291
281 292 * pycolorize.py, pycolor.1: Paul Mueller's patches that
282 293 make pycolorize read input from stdin when run without arguments.
283 294
284 295 * Magic.py: do not require 'PATH' in %rehash/%rehashx. Closes #155
285 296
286 297 * ipy_rehashdir.py: rename ext_rehashdir to ipy_rehashdir, import
287 298 it in sh profile (instead of ipy_system_conf.py).
288 299
289 300 * Magic.py, ipy_rehashdir.py, ipy_profile_sh.py: System command
290 301 aliases are now lower case on windows (MyCommand.exe => mycommand).
291 302
292 303 * macro.py, ipapi.py, iplib.py, Prompts.py: Macro system rehaul.
293 304 Macros are now callable objects that inherit from ipapi.IPyAutocall,
294 305 i.e. get autocalled regardless of system autocall setting.
295 306
296 307 2007-05-10 Fernando Perez <Fernando.Perez@colorado.edu>
297 308
298 309 * IPython/rlineimpl.py: check for clear_history in readline and
299 310 make it a dummy no-op if not available. This function isn't
300 311 guaranteed to be in the API and appeared in Python 2.4, so we need
301 312 to check it ourselves. Also, clean up this file quite a bit.
302 313
303 314 * ipython.1: update man page and full manual with information
304 315 about threads (remove outdated warning). Closes #151.
305 316
306 317 2007-05-09 Fernando Perez <Fernando.Perez@colorado.edu>
307 318
308 319 * IPython/Extensions/ipy_constants.py: Add Gael's constants module
309 320 in trunk (note that this made it into the 0.8.1 release already,
310 321 but the changelogs didn't get coordinated). Many thanks to Gael
311 322 Varoquaux <gael.varoquaux-AT-normalesup.org>
312 323
313 324 2007-05-09 *** Released version 0.8.1
314 325
315 326 2007-05-10 Walter Doerwald <walter@livinglogic.de>
316 327
317 328 * IPython/Extensions/igrid.py: Incorporate html help into
318 329 the module, so we don't have to search for the file.
319 330
320 331 2007-05-02 Fernando Perez <Fernando.Perez@colorado.edu>
321 332
322 333 * test/test_irunner.py (RunnerTestCase._test_runner): Close #147.
323 334
324 335 2007-04-30 Ville Vainio <vivainio@gmail.com>
325 336
326 337 * iplib.py: (pre_config_initialization) Catch UnicodeDecodeError if the
327 338 user has illegal (non-ascii) home directory name
328 339
329 340 2007-04-27 Ville Vainio <vivainio@gmail.com>
330 341
331 342 * platutils_win32.py: implement set_term_title for windows
332 343
333 344 * Update version number
334 345
335 346 * ipy_profile_sh.py: more informative prompt (2 dir levels)
336 347
337 348 2007-04-26 Walter Doerwald <walter@livinglogic.de>
338 349
339 350 * IPython/Extensions/igrid.py: (igrid) Fix bug that surfaced
340 351 when the igrid input raised an exception. (Patch by Nik Tautenhahn,
341 352 bug discovered by Ville).
342 353
343 354 2007-04-26 Ville Vainio <vivainio@gmail.com>
344 355
345 356 * Extensions/ipy_completers.py: Olivier's module completer now
346 357 saves the list of root modules if it takes > 4 secs on the first run.
347 358
348 359 * Magic.py (%rehashx): %rehashx now clears the completer cache
349 360
350 361
351 362 2007-04-26 Fernando Perez <Fernando.Perez@colorado.edu>
352 363
353 364 * ipython.el: fix incorrect color scheme, reported by Stefan.
354 365 Closes #149.
355 366
356 367 * IPython/PyColorize.py (Parser.format2): fix state-handling
357 368 logic. I still don't like how that code handles state, but at
358 369 least now it should be correct, if inelegant. Closes #146.
359 370
360 371 2007-04-25 Ville Vainio <vivainio@gmail.com>
361 372
362 373 * Extensions/ipy_which.py: added extension for %which magic, works
363 374 a lot like unix 'which' but also finds and expands aliases, and
364 375 allows wildcards.
365 376
366 377 * ipapi.py (expand_alias): Now actually *return* the expanded alias,
367 378 as opposed to returning nothing.
368 379
369 380 * UserConfig/ipy_user_conf.py, ipy_profile_sh.py: do not import
370 381 ipy_stock_completers on default profile, do import on sh profile.
371 382
372 383 2007-04-22 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
373 384
374 385 * Fix bug in iplib.py/safe_execfile when launching ipython with a script
375 386 like ipython.py foo.py which raised a IndexError.
376 387
377 388 2007-04-21 Ville Vainio <vivainio@gmail.com>
378 389
379 390 * Extensions/ipy_extutil.py: added extension to manage other ipython
380 391 extensions. Now only supports 'ls' == list extensions.
381 392
382 393 2007-04-20 Fernando Perez <Fernando.Perez@colorado.edu>
383 394
384 395 * IPython/Debugger.py (BdbQuit_excepthook): fix small bug that
385 396 would prevent use of the exception system outside of a running
386 397 IPython instance.
387 398
388 399 2007-04-20 Ville Vainio <vivainio@gmail.com>
389 400
390 401 * Extensions/ipy_render.py: added extension for easy
391 402 interactive text template rendering (to clipboard). Uses Ka-Ping Yee's
392 403 'Iptl' template notation,
393 404
394 405 * Extensions/ipy_completers.py: introduced Olivier Lauzanne's
395 406 safer & faster 'import' completer.
396 407
397 408 * ipapi.py: Introduced new ipapi methods, _ip.defmacro(name, value)
398 409 and _ip.defalias(name, command).
399 410
400 411 * Extensions/ipy_exportdb.py: New extension for exporting all the
401 412 %store'd data in a portable format (normal ipapi calls like
402 413 defmacro() etc.)
403 414
404 415 2007-04-19 Ville Vainio <vivainio@gmail.com>
405 416
406 417 * upgrade_dir.py: skip junk files like *.pyc
407 418
408 419 * Release.py: version number to 0.8.1
409 420
410 421 2007-04-18 Ville Vainio <vivainio@gmail.com>
411 422
412 423 * iplib.py (safe_execfile): make "ipython foo.py" work with 2.5.1c1
413 424 and later on win32.
414 425
415 426 2007-04-16 Ville Vainio <vivainio@gmail.com>
416 427
417 428 * iplib.py (showtraceback): Do not crash when running w/o readline.
418 429
419 430 2007-04-12 Walter Doerwald <walter@livinglogic.de>
420 431
421 432 * IPython/Extensions/ipipe.py: (ils) Directoy listings are now
422 433 sorted (case sensitive with files and dirs mixed).
423 434
424 435 2007-04-10 Fernando Perez <Fernando.Perez@colorado.edu>
425 436
426 437 * IPython/Release.py (version): Open trunk for 0.8.1 development.
427 438
428 439 2007-04-10 *** Released version 0.8.0
429 440
430 441 2007-04-07 Fernando Perez <Fernando.Perez@colorado.edu>
431 442
432 443 * Tag 0.8.0 for release.
433 444
434 445 * IPython/iplib.py (reloadhist): add API function to cleanly
435 446 reload the readline history, which was growing inappropriately on
436 447 every %run call.
437 448
438 449 * win32_manual_post_install.py (run): apply last part of Nicolas
439 450 Pernetty's patch (I'd accidentally applied it in a different
440 451 directory and this particular file didn't get patched).
441 452
442 453 2007-04-05 Fernando Perez <Fernando.Perez@colorado.edu>
443 454
444 455 * IPython/Shell.py (MAIN_THREAD_ID): get rid of my stupid hack to
445 456 find the main thread id and use the proper API call. Thanks to
446 457 Stefan for the fix.
447 458
448 459 * test/test_prefilter.py (esc_handler_tests): udpate one of Dan's
449 460 unit tests to reflect fixed ticket #52, and add more tests sent by
450 461 him.
451 462
452 463 * IPython/iplib.py (raw_input): restore the readline completer
453 464 state on every input, in case third-party code messed it up.
454 465 (_prefilter): revert recent addition of early-escape checks which
455 466 prevent many valid alias calls from working.
456 467
457 468 * IPython/Shell.py (MTInteractiveShell.runcode): add a tracking
458 469 flag for sigint handler so we don't run a full signal() call on
459 470 each runcode access.
460 471
461 472 * IPython/Magic.py (magic_whos): small improvement to diagnostic
462 473 message.
463 474
464 475 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
465 476
466 477 * IPython/Shell.py (sigint_handler): I *THINK* I finally got
467 478 asynchronous exceptions working, i.e., Ctrl-C can actually
468 479 interrupt long-running code in the multithreaded shells.
469 480
470 481 This is using Tomer Filiba's great ctypes-based trick:
471 482 http://sebulba.wikispaces.com/recipe+thread2. I'd already tried
472 483 this in the past, but hadn't been able to make it work before. So
473 484 far it looks like it's actually running, but this needs more
474 485 testing. If it really works, I'll be *very* happy, and we'll owe
475 486 a huge thank you to Tomer. My current implementation is ugly,
476 487 hackish and uses nasty globals, but I don't want to try and clean
477 488 anything up until we know if it actually works.
478 489
479 490 NOTE: this feature needs ctypes to work. ctypes is included in
480 491 Python2.5, but 2.4 users will need to manually install it. This
481 492 feature makes multi-threaded shells so much more usable that it's
482 493 a minor price to pay (ctypes is very easy to install, already a
483 494 requirement for win32 and available in major linux distros).
484 495
485 496 2007-04-04 Ville Vainio <vivainio@gmail.com>
486 497
487 498 * Extensions/ipy_completers.py, ipy_stock_completers.py:
488 499 Moved implementations of 'bundled' completers to ipy_completers.py,
489 500 they are only enabled in ipy_stock_completers.py.
490 501
491 502 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
492 503
493 504 * IPython/PyColorize.py (Parser.format2): Fix identation of
494 505 colorzied output and return early if color scheme is NoColor, to
495 506 avoid unnecessary and expensive tokenization. Closes #131.
496 507
497 508 2007-04-03 Fernando Perez <Fernando.Perez@colorado.edu>
498 509
499 510 * IPython/Debugger.py: disable the use of pydb version 1.17. It
500 511 has a critical bug (a missing import that makes post-mortem not
501 512 work at all). Unfortunately as of this time, this is the version
502 513 shipped with Ubuntu Edgy, so quite a few people have this one. I
503 514 hope Edgy will update to a more recent package.
504 515
505 516 2007-04-02 Fernando Perez <Fernando.Perez@colorado.edu>
506 517
507 518 * IPython/iplib.py (_prefilter): close #52, second part of a patch
508 519 set by Stefan (only the first part had been applied before).
509 520
510 521 * IPython/Extensions/ipy_stock_completers.py (module_completer):
511 522 remove usage of the dangerous pkgutil.walk_packages(). See
512 523 details in comments left in the code.
513 524
514 525 * IPython/Magic.py (magic_whos): add support for numpy arrays
515 526 similar to what we had for Numeric.
516 527
517 528 * IPython/completer.py (IPCompleter.complete): extend the
518 529 complete() call API to support completions by other mechanisms
519 530 than readline. Closes #109.
520 531
521 532 * IPython/iplib.py (safe_execfile): add a safeguard under Win32 to
522 533 protect against a bug in Python's execfile(). Closes #123.
523 534
524 535 2007-04-01 Fernando Perez <Fernando.Perez@colorado.edu>
525 536
526 537 * IPython/iplib.py (split_user_input): ensure that when splitting
527 538 user input, the part that can be treated as a python name is pure
528 539 ascii (Python identifiers MUST be pure ascii). Part of the
529 540 ongoing Unicode support work.
530 541
531 542 * IPython/Prompts.py (prompt_specials_color): Add \N for the
532 543 actual prompt number, without any coloring. This allows users to
533 544 produce numbered prompts with their own colors. Added after a
534 545 report/request by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
535 546
536 547 2007-03-31 Walter Doerwald <walter@livinglogic.de>
537 548
538 549 * IPython/Extensions/igrid.py: Map the return key
539 550 to enter() and shift-return to enterattr().
540 551
541 552 2007-03-30 Fernando Perez <Fernando.Perez@colorado.edu>
542 553
543 554 * IPython/Magic.py (magic_psearch): add unicode support by
544 555 encoding to ascii the input, since this routine also only deals
545 556 with valid Python names. Fixes a bug reported by Stefan.
546 557
547 558 2007-03-29 Fernando Perez <Fernando.Perez@colorado.edu>
548 559
549 560 * IPython/Magic.py (_inspect): convert unicode input into ascii
550 561 before trying to evaluate it as a Python identifier. This fixes a
551 562 problem that the new unicode support had introduced when analyzing
552 563 long definition lines for functions.
553 564
554 565 2007-03-24 Walter Doerwald <walter@livinglogic.de>
555 566
556 567 * IPython/Extensions/igrid.py: Fix picking. Using
557 568 igrid with wxPython 2.6 and -wthread should work now.
558 569 igrid.display() simply tries to create a frame without
559 570 an application. Only if this fails an application is created.
560 571
561 572 2007-03-23 Walter Doerwald <walter@livinglogic.de>
562 573
563 574 * IPython/Extensions/path.py: Updated to version 2.2.
564 575
565 576 2007-03-23 Ville Vainio <vivainio@gmail.com>
566 577
567 578 * iplib.py: recursive alias expansion now works better, so that
568 579 cases like 'top' -> 'd:/cygwin/top' -> 'ls :/cygwin/top'
569 580 doesn't trip up the process, if 'd' has been aliased to 'ls'.
570 581
571 582 * Extensions/ipy_gnuglobal.py added, provides %global magic
572 583 for users of http://www.gnu.org/software/global
573 584
574 585 * iplib.py: '!command /?' now doesn't invoke IPython's help system.
575 586 Closes #52. Patch by Stefan van der Walt.
576 587
577 588 2007-03-23 Fernando Perez <Fernando.Perez@colorado.edu>
578 589
579 590 * IPython/FakeModule.py (FakeModule.__init__): Small fix to
580 591 respect the __file__ attribute when using %run. Thanks to a bug
581 592 report by Sebastian Rooks <sebastian.rooks-AT-free.fr>.
582 593
583 594 2007-03-22 Fernando Perez <Fernando.Perez@colorado.edu>
584 595
585 596 * IPython/iplib.py (raw_input): Fix mishandling of unicode at
586 597 input. Patch sent by Stefan.
587 598
588 599 2007-03-20 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
589 600 * IPython/Extensions/ipy_stock_completer.py
590 601 shlex_split, fix bug in shlex_split. len function
591 602 call was missing an if statement. Caused shlex_split to
592 603 sometimes return "" as last element.
593 604
594 605 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu>
595 606
596 607 * IPython/completer.py
597 608 (IPCompleter.file_matches.single_dir_expand): fix a problem
598 609 reported by Stefan, where directories containign a single subdir
599 610 would be completed too early.
600 611
601 612 * IPython/Shell.py (_load_pylab): Make the execution of 'from
602 613 pylab import *' when -pylab is given be optional. A new flag,
603 614 pylab_import_all controls this behavior, the default is True for
604 615 backwards compatibility.
605 616
606 617 * IPython/ultraTB.py (_formatTracebackLines): Added (slightly
607 618 modified) R. Bernstein's patch for fully syntax highlighted
608 619 tracebacks. The functionality is also available under ultraTB for
609 620 non-ipython users (someone using ultraTB but outside an ipython
610 621 session). They can select the color scheme by setting the
611 622 module-level global DEFAULT_SCHEME. The highlight functionality
612 623 also works when debugging.
613 624
614 625 * IPython/genutils.py (IOStream.close): small patch by
615 626 R. Bernstein for improved pydb support.
616 627
617 628 * IPython/Debugger.py (Pdb.format_stack_entry): Added patch by
618 629 DaveS <davls@telus.net> to improve support of debugging under
619 630 NTEmacs, including improved pydb behavior.
620 631
621 632 * IPython/Magic.py (magic_prun): Fix saving of profile info for
622 633 Python 2.5, where the stats object API changed a little. Thanks
623 634 to a bug report by Paul Smith <paul.smith-AT-catugmt.com>.
624 635
625 636 * IPython/ColorANSI.py (InputTermColors.Normal): applied Nicolas
626 637 Pernetty's patch to improve support for (X)Emacs under Win32.
627 638
628 639 2007-03-17 Fernando Perez <Fernando.Perez@colorado.edu>
629 640
630 641 * IPython/Shell.py (hijack_wx): ipmort WX with current semantics
631 642 to quiet a deprecation warning that fires with Wx 2.8. Thanks to
632 643 a report by Nik Tautenhahn.
633 644
634 645 2007-03-16 Walter Doerwald <walter@livinglogic.de>
635 646
636 647 * setup.py: Add the igrid help files to the list of data files
637 648 to be installed alongside igrid.
638 649 * IPython/Extensions/igrid.py: (Patch by Nik Tautenhahn)
639 650 Show the input object of the igrid browser as the window tile.
640 651 Show the object the cursor is on in the statusbar.
641 652
642 653 2007-03-15 Ville Vainio <vivainio@gmail.com>
643 654
644 655 * Extensions/ipy_stock_completers.py: Fixed exception
645 656 on mismatching quotes in %run completer. Patch by
646 657 JοΏ½rgen Stenarson. Closes #127.
647 658
648 659 2007-03-14 Ville Vainio <vivainio@gmail.com>
649 660
650 661 * Extensions/ext_rehashdir.py: Do not do auto_alias
651 662 in %rehashdir, it clobbers %store'd aliases.
652 663
653 664 * UserConfig/ipy_profile_sh.py: envpersist.py extension
654 665 (beefed up %env) imported for sh profile.
655 666
656 667 2007-03-10 Walter Doerwald <walter@livinglogic.de>
657 668
658 669 * IPython/Extensions/ipipe.py: Prefer ibrowse over igrid
659 670 as the default browser.
660 671 * IPython/Extensions/igrid.py: Make a few igrid attributes private.
661 672 As igrid displays all attributes it ever encounters, fetch() (which has
662 673 been renamed to _fetch()) doesn't have to recalculate the display attributes
663 674 every time a new item is fetched. This should speed up scrolling.
664 675
665 676 2007-03-10 Fernando Perez <Fernando.Perez@colorado.edu>
666 677
667 678 * IPython/iplib.py (InteractiveShell.__init__): fix for Alex
668 679 Schmolck's recently reported tab-completion bug (my previous one
669 680 had a problem). Patch by Dan Milstein <danmil-AT-comcast.net>.
670 681
671 682 2007-03-09 Walter Doerwald <walter@livinglogic.de>
672 683
673 684 * IPython/Extensions/igrid.py: Patch by Nik Tautenhahn:
674 685 Close help window if exiting igrid.
675 686
676 687 2007-03-02 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
677 688
678 689 * IPython/Extensions/ipy_defaults.py: Check if readline is available
679 690 before calling functions from readline.
680 691
681 692 2007-03-02 Walter Doerwald <walter@livinglogic.de>
682 693
683 694 * IPython/Extensions/igrid.py: Add Nik Tautenhahns igrid extension.
684 695 igrid is a wxPython-based display object for ipipe. If your system has
685 696 wx installed igrid will be the default display. Without wx ipipe falls
686 697 back to ibrowse (which needs curses). If no curses is installed ipipe
687 698 falls back to idump.
688 699
689 700 2007-03-01 Fernando Perez <Fernando.Perez@colorado.edu>
690 701
691 702 * IPython/iplib.py (split_user_inputBROKEN): temporarily disable
692 703 my changes from yesterday, they introduced bugs. Will reactivate
693 704 once I get a correct solution, which will be much easier thanks to
694 705 Dan Milstein's new prefilter test suite.
695 706
696 707 2007-02-28 Fernando Perez <Fernando.Perez@colorado.edu>
697 708
698 709 * IPython/iplib.py (split_user_input): fix input splitting so we
699 710 don't attempt attribute accesses on things that can't possibly be
700 711 valid Python attributes. After a bug report by Alex Schmolck.
701 712 (InteractiveShell.__init__): brown-paper bag fix; regexp broke
702 713 %magic with explicit % prefix.
703 714
704 715 2007-02-27 Fernando Perez <Fernando.Perez@colorado.edu>
705 716
706 717 * IPython/Shell.py (IPShellGTK.mainloop): update threads calls to
707 718 avoid a DeprecationWarning from GTK.
708 719
709 720 2007-02-22 Fernando Perez <Fernando.Perez@colorado.edu>
710 721
711 722 * IPython/genutils.py (clock): I modified clock() to return total
712 723 time, user+system. This is a more commonly needed metric. I also
713 724 introduced the new clocku/clocks to get only user/system time if
714 725 one wants those instead.
715 726
716 727 ***WARNING: API CHANGE*** clock() used to return only user time,
717 728 so if you want exactly the same results as before, use clocku
718 729 instead.
719 730
720 731 2007-02-22 Ville Vainio <vivainio@gmail.com>
721 732
722 733 * IPython/Extensions/ipy_p4.py: Extension for improved
723 734 p4 (perforce version control system) experience.
724 735 Adds %p4 magic with p4 command completion and
725 736 automatic -G argument (marshall output as python dict)
726 737
727 738 2007-02-19 Fernando Perez <Fernando.Perez@colorado.edu>
728 739
729 740 * IPython/demo.py (Demo.re_stop): make dashes optional in demo
730 741 stop marks.
731 742 (ClearingMixin): a simple mixin to easily make a Demo class clear
732 743 the screen in between blocks and have empty marquees. The
733 744 ClearDemo and ClearIPDemo classes that use it are included.
734 745
735 746 2007-02-18 Fernando Perez <Fernando.Perez@colorado.edu>
736 747
737 748 * IPython/irunner.py (pexpect_monkeypatch): patch pexpect to
738 749 protect against exceptions at Python shutdown time. Patch
739 750 sumbmitted to upstream.
740 751
741 752 2007-02-14 Walter Doerwald <walter@livinglogic.de>
742 753
743 754 * IPython/Extensions/ibrowse.py: If entering the first object level
744 755 (i.e. the object for which the browser has been started) fails,
745 756 now the error is raised directly (aborting the browser) instead of
746 757 running into an empty levels list later.
747 758
748 759 2007-02-03 Walter Doerwald <walter@livinglogic.de>
749 760
750 761 * IPython/Extensions/ipipe.py: Add an xrepr implementation
751 762 for the noitem object.
752 763
753 764 2007-01-31 Fernando Perez <Fernando.Perez@colorado.edu>
754 765
755 766 * IPython/completer.py (Completer.attr_matches): Fix small
756 767 tab-completion bug with Enthought Traits objects with units.
757 768 Thanks to a bug report by Tom Denniston
758 769 <tom.denniston-AT-alum.dartmouth.org>.
759 770
760 771 2007-01-27 Fernando Perez <Fernando.Perez@colorado.edu>
761 772
762 773 * IPython/Extensions/ipy_stock_completers.py (runlistpy): fix a
763 774 bug where only .ipy or .py would be completed. Once the first
764 775 argument to %run has been given, all completions are valid because
765 776 they are the arguments to the script, which may well be non-python
766 777 filenames.
767 778
768 779 * IPython/irunner.py (InteractiveRunner.run_source): major updates
769 780 to irunner to allow it to correctly support real doctesting of
770 781 out-of-process ipython code.
771 782
772 783 * IPython/Magic.py (magic_cd): Make the setting of the terminal
773 784 title an option (-noterm_title) because it completely breaks
774 785 doctesting.
775 786
776 787 * IPython/demo.py: fix IPythonDemo class that was not actually working.
777 788
778 789 2007-01-24 Fernando Perez <Fernando.Perez@colorado.edu>
779 790
780 791 * IPython/irunner.py (main): fix small bug where extensions were
781 792 not being correctly recognized.
782 793
783 794 2007-01-23 Walter Doerwald <walter@livinglogic.de>
784 795
785 796 * IPython/Extensions/ipipe.py (xiter): Make sure that iterating
786 797 a string containing a single line yields the string itself as the
787 798 only item.
788 799
789 800 * IPython/Extensions/ibrowse.py (ibrowse): Avoid entering an
790 801 object if it's the same as the one on the last level (This avoids
791 802 infinite recursion for one line strings).
792 803
793 804 2007-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
794 805
795 806 * IPython/ultraTB.py (AutoFormattedTB.__call__): properly flush
796 807 all output streams before printing tracebacks. This ensures that
797 808 user output doesn't end up interleaved with traceback output.
798 809
799 810 2007-01-10 Ville Vainio <vivainio@gmail.com>
800 811
801 812 * Extensions/envpersist.py: Turbocharged %env that remembers
802 813 env vars across sessions; e.g. "%env PATH+=;/opt/scripts" or
803 814 "%env VISUAL=jed".
804 815
805 816 2007-01-05 Fernando Perez <Fernando.Perez@colorado.edu>
806 817
807 818 * IPython/iplib.py (showtraceback): ensure that we correctly call
808 819 custom handlers in all cases (some with pdb were slipping through,
809 820 but I'm not exactly sure why).
810 821
811 822 * IPython/Debugger.py (Tracer.__init__): added new class to
812 823 support set_trace-like usage of IPython's enhanced debugger.
813 824
814 825 2006-12-24 Ville Vainio <vivainio@gmail.com>
815 826
816 827 * ipmaker.py: more informative message when ipy_user_conf
817 828 import fails (suggest running %upgrade).
818 829
819 830 * tools/run_ipy_in_profiler.py: Utility to see where
820 831 the time during IPython startup is spent.
821 832
822 833 2006-12-20 Ville Vainio <vivainio@gmail.com>
823 834
824 835 * 0.7.3 is out - merge all from 0.7.3 branch to trunk
825 836
826 837 * ipapi.py: Add new ipapi method, expand_alias.
827 838
828 839 * Release.py: Bump up version to 0.7.4.svn
829 840
830 841 2006-12-17 Ville Vainio <vivainio@gmail.com>
831 842
832 843 * Extensions/jobctrl.py: Fixed &cmd arg arg...
833 844 to work properly on posix too
834 845
835 846 * Release.py: Update revnum (version is still just 0.7.3).
836 847
837 848 2006-12-15 Ville Vainio <vivainio@gmail.com>
838 849
839 850 * scripts/ipython_win_post_install: create ipython.py in
840 851 prefix + "/scripts".
841 852
842 853 * Release.py: Update version to 0.7.3.
843 854
844 855 2006-12-14 Ville Vainio <vivainio@gmail.com>
845 856
846 857 * scripts/ipython_win_post_install: Overwrite old shortcuts
847 858 if they already exist
848 859
849 860 * Release.py: release 0.7.3rc2
850 861
851 862 2006-12-13 Ville Vainio <vivainio@gmail.com>
852 863
853 864 * Branch and update Release.py for 0.7.3rc1
854 865
855 866 2006-12-13 Fernando Perez <Fernando.Perez@colorado.edu>
856 867
857 868 * IPython/Shell.py (IPShellWX): update for current WX naming
858 869 conventions, to avoid a deprecation warning with current WX
859 870 versions. Thanks to a report by Danny Shevitz.
860 871
861 872 2006-12-12 Ville Vainio <vivainio@gmail.com>
862 873
863 874 * ipmaker.py: apply david cournapeau's patch to make
864 875 import_some work properly even when ipythonrc does
865 876 import_some on empty list (it was an old bug!).
866 877
867 878 * UserConfig/ipy_user_conf.py, UserConfig/ipythonrc:
868 879 Add deprecation note to ipythonrc and a url to wiki
869 880 in ipy_user_conf.py
870 881
871 882
872 883 * Magic.py (%run): %run myscript.ipy now runs myscript.ipy
873 884 as if it was typed on IPython command prompt, i.e.
874 885 as IPython script.
875 886
876 887 * example-magic.py, magic_grepl.py: remove outdated examples
877 888
878 889 2006-12-11 Fernando Perez <Fernando.Perez@colorado.edu>
879 890
880 891 * IPython/iplib.py (debugger): prevent a nasty traceback if %debug
881 892 is called before any exception has occurred.
882 893
883 894 2006-12-08 Ville Vainio <vivainio@gmail.com>
884 895
885 896 * Extensions/ipy_stock_completers.py: fix cd completer
886 897 to translate /'s to \'s again.
887 898
888 899 * completer.py: prevent traceback on file completions w/
889 900 backslash.
890 901
891 902 * Release.py: Update release number to 0.7.3b3 for release
892 903
893 904 2006-12-07 Ville Vainio <vivainio@gmail.com>
894 905
895 906 * Extensions/ipy_signals.py: Ignore ctrl+C in IPython process
896 907 while executing external code. Provides more shell-like behaviour
897 908 and overall better response to ctrl + C / ctrl + break.
898 909
899 910 * tools/make_tarball.py: new script to create tarball straight from svn
900 911 (setup.py sdist doesn't work on win32).
901 912
902 913 * Extensions/ipy_stock_completers.py: fix cd completer to give up
903 914 on dirnames with spaces and use the default completer instead.
904 915
905 916 * Revision.py: Change version to 0.7.3b2 for release.
906 917
907 918 2006-12-05 Ville Vainio <vivainio@gmail.com>
908 919
909 920 * Magic.py, iplib.py, completer.py: Apply R. Bernstein's
910 921 pydb patch 4 (rm debug printing, py 2.5 checking)
911 922
912 923 2006-11-30 Walter Doerwald <walter@livinglogic.de>
913 924 * IPython/Extensions/ibrowse.py: Add two new commands to ibrowse:
914 925 "refresh" (mapped to "r") refreshes the screen by restarting the iterator.
915 926 "refreshfind" (mapped to "R") does the same but tries to go back to the same
916 927 object the cursor was on before the refresh. The command "markrange" is
917 928 mapped to "%" now.
918 929 * IPython/Extensions/ibrowse.py: Make igrpentry and ipwdentry comparable.
919 930
920 931 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu>
921 932
922 933 * IPython/Magic.py (magic_debug): new %debug magic to activate the
923 934 interactive debugger on the last traceback, without having to call
924 935 %pdb and rerun your code. Made minor changes in various modules,
925 936 should automatically recognize pydb if available.
926 937
927 938 2006-11-28 Ville Vainio <vivainio@gmail.com>
928 939
929 940 * completer.py: If the text start with !, show file completions
930 941 properly. This helps when trying to complete command name
931 942 for shell escapes.
932 943
933 944 2006-11-27 Ville Vainio <vivainio@gmail.com>
934 945
935 946 * ipy_stock_completers.py: bzr completer submitted by Stefan van
936 947 der Walt. Clean up svn and hg completers by using a common
937 948 vcs_completer.
938 949
939 950 2006-11-26 Ville Vainio <vivainio@gmail.com>
940 951
941 952 * Remove ipconfig and %config; you should use _ip.options structure
942 953 directly instead!
943 954
944 955 * genutils.py: add wrap_deprecated function for deprecating callables
945 956
946 957 * iplib.py: deprecate ipmagic, ipsystem, ipalias. Use _ip.magic and
947 958 _ip.system instead. ipalias is redundant.
948 959
949 960 * Magic.py: %rehashdir no longer aliases 'cmdname' to 'cmdname.exe' on
950 961 win32, but just 'cmdname'. Other extensions (non-'exe') are still made
951 962 explicit.
952 963
953 964 * ipy_stock_completers.py: 'hg' (mercurial VCS) now has a custom
954 965 completer. Try it by entering 'hg ' and pressing tab.
955 966
956 967 * macro.py: Give Macro a useful __repr__ method
957 968
958 969 * Magic.py: %whos abbreviates the typename of Macro for brevity.
959 970
960 971 2006-11-24 Walter Doerwald <walter@livinglogic.de>
961 972 * IPython/Extensions/astyle.py: Do a relative import of ipipe, so that
962 973 we don't get a duplicate ipipe module, where registration of the xrepr
963 974 implementation for Text is useless.
964 975
965 976 * IPython/Extensions/ipipe.py: Fix __xrepr__() implementation for ils.
966 977
967 978 * IPython/Extensions/ibrowse.py: Fix keymapping for the enter command.
968 979
969 980 2006-11-24 Ville Vainio <vivainio@gmail.com>
970 981
971 982 * Magic.py, manual_base.lyx: Kirill Smelkov patch:
972 983 try to use "cProfile" instead of the slower pure python
973 984 "profile"
974 985
975 986 2006-11-23 Ville Vainio <vivainio@gmail.com>
976 987
977 988 * manual_base.lyx: Kirill Smelkov patch: Fix wrong
978 989 Qt+IPython+Designer link in documentation.
979 990
980 991 * Extensions/ipy_pydb.py: R. Bernstein's patch for passing
981 992 correct Pdb object to %pydb.
982 993
983 994
984 995 2006-11-22 Walter Doerwald <walter@livinglogic.de>
985 996 * IPython/Extensions/astyle.py: Text needs it's own implemenation of the
986 997 generic xrepr(), otherwise the list implementation would kick in.
987 998
988 999 2006-11-21 Ville Vainio <vivainio@gmail.com>
989 1000
990 1001 * upgrade_dir.py: Now actually overwrites a nonmodified user file
991 1002 with one from UserConfig.
992 1003
993 1004 * ipy_profile_sh.py: Add dummy "depth" to var_expand lambda,
994 1005 it was missing which broke the sh profile.
995 1006
996 1007 * completer.py: file completer now uses explicit '/' instead
997 1008 of os.path.join, expansion of 'foo' was broken on win32
998 1009 if there was one directory with name 'foobar'.
999 1010
1000 1011 * A bunch of patches from Kirill Smelkov:
1001 1012
1002 1013 * [patch 9/9] doc: point bug-tracker URL to IPythons trac-tickets.
1003 1014
1004 1015 * [patch 7/9] Implement %page -r (page in raw mode) -
1005 1016
1006 1017 * [patch 5/9] ScientificPython webpage has moved
1007 1018
1008 1019 * [patch 4/9] The manual mentions %ds, should be %dhist
1009 1020
1010 1021 * [patch 3/9] Kill old bits from %prun doc.
1011 1022
1012 1023 * [patch 1/9] Fix typos here and there.
1013 1024
1014 1025 2006-11-08 Ville Vainio <vivainio@gmail.com>
1015 1026
1016 1027 * completer.py (attr_matches): catch all exceptions raised
1017 1028 by eval of expr with dots.
1018 1029
1019 1030 2006-11-07 Fernando Perez <Fernando.Perez@colorado.edu>
1020 1031
1021 1032 * IPython/iplib.py (runsource): Prepend an 'if 1:' to the user
1022 1033 input if it starts with whitespace. This allows you to paste
1023 1034 indented input from any editor without manually having to type in
1024 1035 the 'if 1:', which is convenient when working interactively.
1025 1036 Slightly modifed version of a patch by Bo Peng
1026 1037 <bpeng-AT-rice.edu>.
1027 1038
1028 1039 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
1029 1040
1030 1041 * IPython/irunner.py (main): modified irunner so it automatically
1031 1042 recognizes the right runner to use based on the extension (.py for
1032 1043 python, .ipy for ipython and .sage for sage).
1033 1044
1034 1045 * IPython/iplib.py (InteractiveShell.ipconfig): new builtin, also
1035 1046 visible in ipapi as ip.config(), to programatically control the
1036 1047 internal rc object. There's an accompanying %config magic for
1037 1048 interactive use, which has been enhanced to match the
1038 1049 funtionality in ipconfig.
1039 1050
1040 1051 * IPython/Magic.py (magic_system_verbose): Change %system_verbose
1041 1052 so it's not just a toggle, it now takes an argument. Add support
1042 1053 for a customizable header when making system calls, as the new
1043 1054 system_header variable in the ipythonrc file.
1044 1055
1045 1056 2006-11-03 Walter Doerwald <walter@livinglogic.de>
1046 1057
1047 1058 * IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now
1048 1059 generic functions (using Philip J. Eby's simplegeneric package).
1049 1060 This makes it possible to customize the display of third-party classes
1050 1061 without having to monkeypatch them. xiter() no longer supports a mode
1051 1062 argument and the XMode class has been removed. The same functionality can
1052 1063 be implemented via IterAttributeDescriptor and IterMethodDescriptor.
1053 1064 One consequence of the switch to generic functions is that xrepr() and
1054 1065 xattrs() implementation must define the default value for the mode
1055 1066 argument themselves and xattrs() implementations must return real
1056 1067 descriptors.
1057 1068
1058 1069 * IPython/external: This new subpackage will contain all third-party
1059 1070 packages that are bundled with IPython. (The first one is simplegeneric).
1060 1071
1061 1072 * IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent
1062 1073 directory which as been dropped in r1703.
1063 1074
1064 1075 * IPython/Extensions/ipipe.py (iless): Fixed.
1065 1076
1066 1077 * IPython/Extensions/ibrowse: Fixed sorting under Python 2.3.
1067 1078
1068 1079 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
1069 1080
1070 1081 * IPython/iplib.py (InteractiveShell.var_expand): fix stack
1071 1082 handling in variable expansion so that shells and magics recognize
1072 1083 function local scopes correctly. Bug reported by Brian.
1073 1084
1074 1085 * scripts/ipython: remove the very first entry in sys.path which
1075 1086 Python auto-inserts for scripts, so that sys.path under IPython is
1076 1087 as similar as possible to that under plain Python.
1077 1088
1078 1089 * IPython/completer.py (IPCompleter.file_matches): Fix
1079 1090 tab-completion so that quotes are not closed unless the completion
1080 1091 is unambiguous. After a request by Stefan. Minor cleanups in
1081 1092 ipy_stock_completers.
1082 1093
1083 1094 2006-11-02 Ville Vainio <vivainio@gmail.com>
1084 1095
1085 1096 * ipy_stock_completers.py: Add %run and %cd completers.
1086 1097
1087 1098 * completer.py: Try running custom completer for both
1088 1099 "foo" and "%foo" if the command is just "foo". Ignore case
1089 1100 when filtering possible completions.
1090 1101
1091 1102 * UserConfig/ipy_user_conf.py: install stock completers as default
1092 1103
1093 1104 * iplib.py (history_saving_wrapper), debugger(), ipy_pydb.py:
1094 1105 simplified readline history save / restore through a wrapper
1095 1106 function
1096 1107
1097 1108
1098 1109 2006-10-31 Ville Vainio <vivainio@gmail.com>
1099 1110
1100 1111 * strdispatch.py, completer.py, ipy_stock_completers.py:
1101 1112 Allow str_key ("command") in completer hooks. Implement
1102 1113 trivial completer for 'import' (stdlib modules only). Rename
1103 1114 ipy_linux_package_managers.py to ipy_stock_completers.py.
1104 1115 SVN completer.
1105 1116
1106 1117 * Extensions/ledit.py: %magic line editor for easily and
1107 1118 incrementally manipulating lists of strings. The magic command
1108 1119 name is %led.
1109 1120
1110 1121 2006-10-30 Ville Vainio <vivainio@gmail.com>
1111 1122
1112 1123 * Debugger.py, iplib.py (debugger()): Add last set of Rocky
1113 1124 Bernsteins's patches for pydb integration.
1114 1125 http://bashdb.sourceforge.net/pydb/
1115 1126
1116 1127 * strdispatch.py, iplib.py, completer.py, IPython/__init__.py,
1117 1128 Extensions/ipy_linux_package_managers.py, hooks.py: Implement
1118 1129 custom completer hook to allow the users to implement their own
1119 1130 completers. See ipy_linux_package_managers.py for example. The
1120 1131 hook name is 'complete_command'.
1121 1132
1122 1133 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
1123 1134
1124 1135 * IPython/UserConfig/ipythonrc-scipy: minor cleanups to remove old
1125 1136 Numeric leftovers.
1126 1137
1127 1138 * ipython.el (py-execute-region): apply Stefan's patch to fix
1128 1139 garbled results if the python shell hasn't been previously started.
1129 1140
1130 1141 * IPython/genutils.py (arg_split): moved to genutils, since it's a
1131 1142 pretty generic function and useful for other things.
1132 1143
1133 1144 * IPython/OInspect.py (getsource): Add customizable source
1134 1145 extractor. After a request/patch form W. Stein (SAGE).
1135 1146
1136 1147 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
1137 1148 window size to a more reasonable value from what pexpect does,
1138 1149 since their choice causes wrapping bugs with long input lines.
1139 1150
1140 1151 2006-10-28 Ville Vainio <vivainio@gmail.com>
1141 1152
1142 1153 * Magic.py (%run): Save and restore the readline history from
1143 1154 file around %run commands to prevent side effects from
1144 1155 %runned programs that might use readline (e.g. pydb).
1145 1156
1146 1157 * extensions/ipy_pydb.py: Adds %pydb magic when imported, for
1147 1158 invoking the pydb enhanced debugger.
1148 1159
1149 1160 2006-10-23 Walter Doerwald <walter@livinglogic.de>
1150 1161
1151 1162 * IPython/Extensions/ipipe.py (ifile): Remove all methods that
1152 1163 call the base class method and propagate the return value to
1153 1164 ifile. This is now done by path itself.
1154 1165
1155 1166 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
1156 1167
1157 1168 * IPython/ipapi.py (IPApi.__init__): Added new entry to public
1158 1169 api: set_crash_handler(), to expose the ability to change the
1159 1170 internal crash handler.
1160 1171
1161 1172 * IPython/CrashHandler.py (CrashHandler.__init__): abstract out
1162 1173 the various parameters of the crash handler so that apps using
1163 1174 IPython as their engine can customize crash handling. Ipmlemented
1164 1175 at the request of SAGE.
1165 1176
1166 1177 2006-10-14 Ville Vainio <vivainio@gmail.com>
1167 1178
1168 1179 * Magic.py, ipython.el: applied first "safe" part of Rocky
1169 1180 Bernstein's patch set for pydb integration.
1170 1181
1171 1182 * Magic.py (%unalias, %alias): %store'd aliases can now be
1172 1183 removed with '%unalias'. %alias w/o args now shows most
1173 1184 interesting (stored / manually defined) aliases last
1174 1185 where they catch the eye w/o scrolling.
1175 1186
1176 1187 * Magic.py (%rehashx), ext_rehashdir.py: files with
1177 1188 'py' extension are always considered executable, even
1178 1189 when not in PATHEXT environment variable.
1179 1190
1180 1191 2006-10-12 Ville Vainio <vivainio@gmail.com>
1181 1192
1182 1193 * jobctrl.py: Add new "jobctrl" extension for spawning background
1183 1194 processes with "&find /". 'import jobctrl' to try it out. Requires
1184 1195 'subprocess' module, standard in python 2.4+.
1185 1196
1186 1197 * iplib.py (expand_aliases, handle_alias): Aliases expand transitively,
1187 1198 so if foo -> bar and bar -> baz, then foo -> baz.
1188 1199
1189 1200 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
1190 1201
1191 1202 * IPython/Magic.py (Magic.parse_options): add a new posix option
1192 1203 to allow parsing of input args in magics that doesn't strip quotes
1193 1204 (if posix=False). This also closes %timeit bug reported by
1194 1205 Stefan.
1195 1206
1196 1207 2006-10-03 Ville Vainio <vivainio@gmail.com>
1197 1208
1198 1209 * iplib.py (raw_input, interact): Return ValueError catching for
1199 1210 raw_input. Fixes infinite loop for sys.stdin.close() or
1200 1211 sys.stdout.close().
1201 1212
1202 1213 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1203 1214
1204 1215 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
1205 1216 to help in handling doctests. irunner is now pretty useful for
1206 1217 running standalone scripts and simulate a full interactive session
1207 1218 in a format that can be then pasted as a doctest.
1208 1219
1209 1220 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
1210 1221 on top of the default (useless) ones. This also fixes the nasty
1211 1222 way in which 2.5's Quitter() exits (reverted [1785]).
1212 1223
1213 1224 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
1214 1225 2.5.
1215 1226
1216 1227 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
1217 1228 color scheme is updated as well when color scheme is changed
1218 1229 interactively.
1219 1230
1220 1231 2006-09-27 Ville Vainio <vivainio@gmail.com>
1221 1232
1222 1233 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
1223 1234 infinite loop and just exit. It's a hack, but will do for a while.
1224 1235
1225 1236 2006-08-25 Walter Doerwald <walter@livinglogic.de>
1226 1237
1227 1238 * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to
1228 1239 the constructor, this makes it possible to get a list of only directories
1229 1240 or only files.
1230 1241
1231 1242 2006-08-12 Ville Vainio <vivainio@gmail.com>
1232 1243
1233 1244 * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,
1234 1245 they broke unittest
1235 1246
1236 1247 2006-08-11 Ville Vainio <vivainio@gmail.com>
1237 1248
1238 1249 * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch
1239 1250 by resolving issue properly, i.e. by inheriting FakeModule
1240 1251 from types.ModuleType. Pickling ipython interactive data
1241 1252 should still work as usual (testing appreciated).
1242 1253
1243 1254 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
1244 1255
1245 1256 * IPython/OInspect.py: monkeypatch inspect from the stdlib if
1246 1257 running under python 2.3 with code from 2.4 to fix a bug with
1247 1258 help(). Reported by the Debian maintainers, Norbert Tretkowski
1248 1259 <norbert-AT-tretkowski.de> and Alexandre Fayolle
1249 1260 <afayolle-AT-debian.org>.
1250 1261
1251 1262 2006-08-04 Walter Doerwald <walter@livinglogic.de>
1252 1263
1253 1264 * IPython/Extensions/ibrowse.py: Fixed the help message in the footer
1254 1265 (which was displaying "quit" twice).
1255 1266
1256 1267 2006-07-28 Walter Doerwald <walter@livinglogic.de>
1257 1268
1258 1269 * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using
1259 1270 the mode argument).
1260 1271
1261 1272 2006-07-27 Walter Doerwald <walter@livinglogic.de>
1262 1273
1263 1274 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
1264 1275 not running under IPython.
1265 1276
1266 1277 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
1267 1278 and make it iterable (iterating over the attribute itself). Add two new
1268 1279 magic strings for __xattrs__(): If the string starts with "-", the attribute
1269 1280 will not be displayed in ibrowse's detail view (but it can still be
1270 1281 iterated over). This makes it possible to add attributes that are large
1271 1282 lists or generator methods to the detail view. Replace magic attribute names
1272 1283 and _attrname() and _getattr() with "descriptors": For each type of magic
1273 1284 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
1274 1285 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
1275 1286 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
1276 1287 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
1277 1288 are still supported.
1278 1289
1279 1290 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
1280 1291 fails in ibrowse.fetch(), the exception object is added as the last item
1281 1292 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
1282 1293 a generator throws an exception midway through execution.
1283 1294
1284 1295 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
1285 1296 encoding into methods.
1286 1297
1287 1298 2006-07-26 Ville Vainio <vivainio@gmail.com>
1288 1299
1289 1300 * iplib.py: history now stores multiline input as single
1290 1301 history entries. Patch by Jorgen Cederlof.
1291 1302
1292 1303 2006-07-18 Walter Doerwald <walter@livinglogic.de>
1293 1304
1294 1305 * IPython/Extensions/ibrowse.py: Make cursor visible over
1295 1306 non existing attributes.
1296 1307
1297 1308 2006-07-14 Walter Doerwald <walter@livinglogic.de>
1298 1309
1299 1310 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
1300 1311 error output of the running command doesn't mess up the screen.
1301 1312
1302 1313 2006-07-13 Walter Doerwald <walter@livinglogic.de>
1303 1314
1304 1315 * IPython/Extensions/ipipe.py (isort): Make isort usable without
1305 1316 argument. This sorts the items themselves.
1306 1317
1307 1318 2006-07-12 Walter Doerwald <walter@livinglogic.de>
1308 1319
1309 1320 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
1310 1321 Compile expression strings into code objects. This should speed
1311 1322 up ifilter and friends somewhat.
1312 1323
1313 1324 2006-07-08 Ville Vainio <vivainio@gmail.com>
1314 1325
1315 1326 * Magic.py: %cpaste now strips > from the beginning of lines
1316 1327 to ease pasting quoted code from emails. Contributed by
1317 1328 Stefan van der Walt.
1318 1329
1319 1330 2006-06-29 Ville Vainio <vivainio@gmail.com>
1320 1331
1321 1332 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
1322 1333 mode, patch contributed by Darren Dale. NEEDS TESTING!
1323 1334
1324 1335 2006-06-28 Walter Doerwald <walter@livinglogic.de>
1325 1336
1326 1337 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
1327 1338 a blue background. Fix fetching new display rows when the browser
1328 1339 scrolls more than a screenful (e.g. by using the goto command).
1329 1340
1330 1341 2006-06-27 Ville Vainio <vivainio@gmail.com>
1331 1342
1332 1343 * Magic.py (_inspect, _ofind) Apply David Huard's
1333 1344 patch for displaying the correct docstring for 'property'
1334 1345 attributes.
1335 1346
1336 1347 2006-06-23 Walter Doerwald <walter@livinglogic.de>
1337 1348
1338 1349 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
1339 1350 commands into the methods implementing them.
1340 1351
1341 1352 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
1342 1353
1343 1354 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
1344 1355 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
1345 1356 autoindent support was authored by Jin Liu.
1346 1357
1347 1358 2006-06-22 Walter Doerwald <walter@livinglogic.de>
1348 1359
1349 1360 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
1350 1361 for keymaps with a custom class that simplifies handling.
1351 1362
1352 1363 2006-06-19 Walter Doerwald <walter@livinglogic.de>
1353 1364
1354 1365 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
1355 1366 resizing. This requires Python 2.5 to work.
1356 1367
1357 1368 2006-06-16 Walter Doerwald <walter@livinglogic.de>
1358 1369
1359 1370 * IPython/Extensions/ibrowse.py: Add two new commands to
1360 1371 ibrowse: "hideattr" (mapped to "h") hides the attribute under
1361 1372 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
1362 1373 attributes again. Remapped the help command to "?". Display
1363 1374 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
1364 1375 as keys for the "home" and "end" commands. Add three new commands
1365 1376 to the input mode for "find" and friends: "delend" (CTRL-K)
1366 1377 deletes to the end of line. "incsearchup" searches upwards in the
1367 1378 command history for an input that starts with the text before the cursor.
1368 1379 "incsearchdown" does the same downwards. Removed a bogus mapping of
1369 1380 the x key to "delete".
1370 1381
1371 1382 2006-06-15 Ville Vainio <vivainio@gmail.com>
1372 1383
1373 1384 * iplib.py, hooks.py: Added new generate_prompt hook that can be
1374 1385 used to create prompts dynamically, instead of the "old" way of
1375 1386 assigning "magic" strings to prompt_in1 and prompt_in2. The old
1376 1387 way still works (it's invoked by the default hook), of course.
1377 1388
1378 1389 * Prompts.py: added generate_output_prompt hook for altering output
1379 1390 prompt
1380 1391
1381 1392 * Release.py: Changed version string to 0.7.3.svn.
1382 1393
1383 1394 2006-06-15 Walter Doerwald <walter@livinglogic.de>
1384 1395
1385 1396 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
1386 1397 the call to fetch() always tries to fetch enough data for at least one
1387 1398 full screen. This makes it possible to simply call moveto(0,0,True) in
1388 1399 the constructor. Fix typos and removed the obsolete goto attribute.
1389 1400
1390 1401 2006-06-12 Ville Vainio <vivainio@gmail.com>
1391 1402
1392 1403 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
1393 1404 allowing $variable interpolation within multiline statements,
1394 1405 though so far only with "sh" profile for a testing period.
1395 1406 The patch also enables splitting long commands with \ but it
1396 1407 doesn't work properly yet.
1397 1408
1398 1409 2006-06-12 Walter Doerwald <walter@livinglogic.de>
1399 1410
1400 1411 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
1401 1412 input history and the position of the cursor in the input history for
1402 1413 the find, findbackwards and goto command.
1403 1414
1404 1415 2006-06-10 Walter Doerwald <walter@livinglogic.de>
1405 1416
1406 1417 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
1407 1418 implements the basic functionality of browser commands that require
1408 1419 input. Reimplement the goto, find and findbackwards commands as
1409 1420 subclasses of _CommandInput. Add an input history and keymaps to those
1410 1421 commands. Add "\r" as a keyboard shortcut for the enterdefault and
1411 1422 execute commands.
1412 1423
1413 1424 2006-06-07 Ville Vainio <vivainio@gmail.com>
1414 1425
1415 1426 * iplib.py: ipython mybatch.ipy exits ipython immediately after
1416 1427 running the batch files instead of leaving the session open.
1417 1428
1418 1429 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
1419 1430
1420 1431 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
1421 1432 the original fix was incomplete. Patch submitted by W. Maier.
1422 1433
1423 1434 2006-06-07 Ville Vainio <vivainio@gmail.com>
1424 1435
1425 1436 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
1426 1437 Confirmation prompts can be supressed by 'quiet' option.
1427 1438 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
1428 1439
1429 1440 2006-06-06 *** Released version 0.7.2
1430 1441
1431 1442 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
1432 1443
1433 1444 * IPython/Release.py (version): Made 0.7.2 final for release.
1434 1445 Repo tagged and release cut.
1435 1446
1436 1447 2006-06-05 Ville Vainio <vivainio@gmail.com>
1437 1448
1438 1449 * Magic.py (magic_rehashx): Honor no_alias list earlier in
1439 1450 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
1440 1451
1441 1452 * upgrade_dir.py: try import 'path' module a bit harder
1442 1453 (for %upgrade)
1443 1454
1444 1455 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
1445 1456
1446 1457 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
1447 1458 instead of looping 20 times.
1448 1459
1449 1460 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
1450 1461 correctly at initialization time. Bug reported by Krishna Mohan
1451 1462 Gundu <gkmohan-AT-gmail.com> on the user list.
1452 1463
1453 1464 * IPython/Release.py (version): Mark 0.7.2 version to start
1454 1465 testing for release on 06/06.
1455 1466
1456 1467 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
1457 1468
1458 1469 * scripts/irunner: thin script interface so users don't have to
1459 1470 find the module and call it as an executable, since modules rarely
1460 1471 live in people's PATH.
1461 1472
1462 1473 * IPython/irunner.py (InteractiveRunner.__init__): added
1463 1474 delaybeforesend attribute to control delays with newer versions of
1464 1475 pexpect. Thanks to detailed help from pexpect's author, Noah
1465 1476 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
1466 1477 correctly (it works in NoColor mode).
1467 1478
1468 1479 * IPython/iplib.py (handle_normal): fix nasty crash reported on
1469 1480 SAGE list, from improper log() calls.
1470 1481
1471 1482 2006-05-31 Ville Vainio <vivainio@gmail.com>
1472 1483
1473 1484 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
1474 1485 with args in parens to work correctly with dirs that have spaces.
1475 1486
1476 1487 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
1477 1488
1478 1489 * IPython/Logger.py (Logger.logstart): add option to log raw input
1479 1490 instead of the processed one. A -r flag was added to the
1480 1491 %logstart magic used for controlling logging.
1481 1492
1482 1493 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
1483 1494
1484 1495 * IPython/iplib.py (InteractiveShell.__init__): add check for the
1485 1496 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
1486 1497 recognize the option. After a bug report by Will Maier. This
1487 1498 closes #64 (will do it after confirmation from W. Maier).
1488 1499
1489 1500 * IPython/irunner.py: New module to run scripts as if manually
1490 1501 typed into an interactive environment, based on pexpect. After a
1491 1502 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
1492 1503 ipython-user list. Simple unittests in the tests/ directory.
1493 1504
1494 1505 * tools/release: add Will Maier, OpenBSD port maintainer, to
1495 1506 recepients list. We are now officially part of the OpenBSD ports:
1496 1507 http://www.openbsd.org/ports.html ! Many thanks to Will for the
1497 1508 work.
1498 1509
1499 1510 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
1500 1511
1501 1512 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
1502 1513 so that it doesn't break tkinter apps.
1503 1514
1504 1515 * IPython/iplib.py (_prefilter): fix bug where aliases would
1505 1516 shadow variables when autocall was fully off. Reported by SAGE
1506 1517 author William Stein.
1507 1518
1508 1519 * IPython/OInspect.py (Inspector.__init__): add a flag to control
1509 1520 at what detail level strings are computed when foo? is requested.
1510 1521 This allows users to ask for example that the string form of an
1511 1522 object is only computed when foo?? is called, or even never, by
1512 1523 setting the object_info_string_level >= 2 in the configuration
1513 1524 file. This new option has been added and documented. After a
1514 1525 request by SAGE to be able to control the printing of very large
1515 1526 objects more easily.
1516 1527
1517 1528 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
1518 1529
1519 1530 * IPython/ipmaker.py (make_IPython): remove the ipython call path
1520 1531 from sys.argv, to be 100% consistent with how Python itself works
1521 1532 (as seen for example with python -i file.py). After a bug report
1522 1533 by Jeffrey Collins.
1523 1534
1524 1535 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
1525 1536 nasty bug which was preventing custom namespaces with -pylab,
1526 1537 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
1527 1538 compatibility (long gone from mpl).
1528 1539
1529 1540 * IPython/ipapi.py (make_session): name change: create->make. We
1530 1541 use make in other places (ipmaker,...), it's shorter and easier to
1531 1542 type and say, etc. I'm trying to clean things before 0.7.2 so
1532 1543 that I can keep things stable wrt to ipapi in the chainsaw branch.
1533 1544
1534 1545 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
1535 1546 python-mode recognizes our debugger mode. Add support for
1536 1547 autoindent inside (X)emacs. After a patch sent in by Jin Liu
1537 1548 <m.liu.jin-AT-gmail.com> originally written by
1538 1549 doxgen-AT-newsmth.net (with minor modifications for xemacs
1539 1550 compatibility)
1540 1551
1541 1552 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
1542 1553 tracebacks when walking the stack so that the stack tracking system
1543 1554 in emacs' python-mode can identify the frames correctly.
1544 1555
1545 1556 * IPython/ipmaker.py (make_IPython): make the internal (and
1546 1557 default config) autoedit_syntax value false by default. Too many
1547 1558 users have complained to me (both on and off-list) about problems
1548 1559 with this option being on by default, so I'm making it default to
1549 1560 off. It can still be enabled by anyone via the usual mechanisms.
1550 1561
1551 1562 * IPython/completer.py (Completer.attr_matches): add support for
1552 1563 PyCrust-style _getAttributeNames magic method. Patch contributed
1553 1564 by <mscott-AT-goldenspud.com>. Closes #50.
1554 1565
1555 1566 * IPython/iplib.py (InteractiveShell.__init__): remove the
1556 1567 deletion of exit/quit from __builtin__, which can break
1557 1568 third-party tools like the Zope debugging console. The
1558 1569 %exit/%quit magics remain. In general, it's probably a good idea
1559 1570 not to delete anything from __builtin__, since we never know what
1560 1571 that will break. In any case, python now (for 2.5) will support
1561 1572 'real' exit/quit, so this issue is moot. Closes #55.
1562 1573
1563 1574 * IPython/genutils.py (with_obj): rename the 'with' function to
1564 1575 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
1565 1576 becomes a language keyword. Closes #53.
1566 1577
1567 1578 * IPython/FakeModule.py (FakeModule.__init__): add a proper
1568 1579 __file__ attribute to this so it fools more things into thinking
1569 1580 it is a real module. Closes #59.
1570 1581
1571 1582 * IPython/Magic.py (magic_edit): add -n option to open the editor
1572 1583 at a specific line number. After a patch by Stefan van der Walt.
1573 1584
1574 1585 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
1575 1586
1576 1587 * IPython/iplib.py (edit_syntax_error): fix crash when for some
1577 1588 reason the file could not be opened. After automatic crash
1578 1589 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
1579 1590 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
1580 1591 (_should_recompile): Don't fire editor if using %bg, since there
1581 1592 is no file in the first place. From the same report as above.
1582 1593 (raw_input): protect against faulty third-party prefilters. After
1583 1594 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
1584 1595 while running under SAGE.
1585 1596
1586 1597 2006-05-23 Ville Vainio <vivainio@gmail.com>
1587 1598
1588 1599 * ipapi.py: Stripped down ip.to_user_ns() to work only as
1589 1600 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
1590 1601 now returns None (again), unless dummy is specifically allowed by
1591 1602 ipapi.get(allow_dummy=True).
1592 1603
1593 1604 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
1594 1605
1595 1606 * IPython: remove all 2.2-compatibility objects and hacks from
1596 1607 everywhere, since we only support 2.3 at this point. Docs
1597 1608 updated.
1598 1609
1599 1610 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
1600 1611 Anything requiring extra validation can be turned into a Python
1601 1612 property in the future. I used a property for the db one b/c
1602 1613 there was a nasty circularity problem with the initialization
1603 1614 order, which right now I don't have time to clean up.
1604 1615
1605 1616 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
1606 1617 another locking bug reported by Jorgen. I'm not 100% sure though,
1607 1618 so more testing is needed...
1608 1619
1609 1620 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
1610 1621
1611 1622 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
1612 1623 local variables from any routine in user code (typically executed
1613 1624 with %run) directly into the interactive namespace. Very useful
1614 1625 when doing complex debugging.
1615 1626 (IPythonNotRunning): Changed the default None object to a dummy
1616 1627 whose attributes can be queried as well as called without
1617 1628 exploding, to ease writing code which works transparently both in
1618 1629 and out of ipython and uses some of this API.
1619 1630
1620 1631 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
1621 1632
1622 1633 * IPython/hooks.py (result_display): Fix the fact that our display
1623 1634 hook was using str() instead of repr(), as the default python
1624 1635 console does. This had gone unnoticed b/c it only happened if
1625 1636 %Pprint was off, but the inconsistency was there.
1626 1637
1627 1638 2006-05-15 Ville Vainio <vivainio@gmail.com>
1628 1639
1629 1640 * Oinspect.py: Only show docstring for nonexisting/binary files
1630 1641 when doing object??, closing ticket #62
1631 1642
1632 1643 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
1633 1644
1634 1645 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
1635 1646 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
1636 1647 was being released in a routine which hadn't checked if it had
1637 1648 been the one to acquire it.
1638 1649
1639 1650 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
1640 1651
1641 1652 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
1642 1653
1643 1654 2006-04-11 Ville Vainio <vivainio@gmail.com>
1644 1655
1645 1656 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
1646 1657 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
1647 1658 prefilters, allowing stuff like magics and aliases in the file.
1648 1659
1649 1660 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
1650 1661 added. Supported now are "%clear in" and "%clear out" (clear input and
1651 1662 output history, respectively). Also fixed CachedOutput.flush to
1652 1663 properly flush the output cache.
1653 1664
1654 1665 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
1655 1666 half-success (and fail explicitly).
1656 1667
1657 1668 2006-03-28 Ville Vainio <vivainio@gmail.com>
1658 1669
1659 1670 * iplib.py: Fix quoting of aliases so that only argless ones
1660 1671 are quoted
1661 1672
1662 1673 2006-03-28 Ville Vainio <vivainio@gmail.com>
1663 1674
1664 1675 * iplib.py: Quote aliases with spaces in the name.
1665 1676 "c:\program files\blah\bin" is now legal alias target.
1666 1677
1667 1678 * ext_rehashdir.py: Space no longer allowed as arg
1668 1679 separator, since space is legal in path names.
1669 1680
1670 1681 2006-03-16 Ville Vainio <vivainio@gmail.com>
1671 1682
1672 1683 * upgrade_dir.py: Take path.py from Extensions, correcting
1673 1684 %upgrade magic
1674 1685
1675 1686 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
1676 1687
1677 1688 * hooks.py: Only enclose editor binary in quotes if legal and
1678 1689 necessary (space in the name, and is an existing file). Fixes a bug
1679 1690 reported by Zachary Pincus.
1680 1691
1681 1692 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
1682 1693
1683 1694 * Manual: thanks to a tip on proper color handling for Emacs, by
1684 1695 Eric J Haywiser <ejh1-AT-MIT.EDU>.
1685 1696
1686 1697 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
1687 1698 by applying the provided patch. Thanks to Liu Jin
1688 1699 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
1689 1700 XEmacs/Linux, I'm trusting the submitter that it actually helps
1690 1701 under win32/GNU Emacs. Will revisit if any problems are reported.
1691 1702
1692 1703 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1693 1704
1694 1705 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
1695 1706 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
1696 1707
1697 1708 2006-03-12 Ville Vainio <vivainio@gmail.com>
1698 1709
1699 1710 * Magic.py (magic_timeit): Added %timeit magic, contributed by
1700 1711 Torsten Marek.
1701 1712
1702 1713 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1703 1714
1704 1715 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
1705 1716 line ranges works again.
1706 1717
1707 1718 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
1708 1719
1709 1720 * IPython/iplib.py (showtraceback): add back sys.last_traceback
1710 1721 and friends, after a discussion with Zach Pincus on ipython-user.
1711 1722 I'm not 100% sure, but after thinking about it quite a bit, it may
1712 1723 be OK. Testing with the multithreaded shells didn't reveal any
1713 1724 problems, but let's keep an eye out.
1714 1725
1715 1726 In the process, I fixed a few things which were calling
1716 1727 self.InteractiveTB() directly (like safe_execfile), which is a
1717 1728 mistake: ALL exception reporting should be done by calling
1718 1729 self.showtraceback(), which handles state and tab-completion and
1719 1730 more.
1720 1731
1721 1732 2006-03-01 Ville Vainio <vivainio@gmail.com>
1722 1733
1723 1734 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
1724 1735 To use, do "from ipipe import *".
1725 1736
1726 1737 2006-02-24 Ville Vainio <vivainio@gmail.com>
1727 1738
1728 1739 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
1729 1740 "cleanly" and safely than the older upgrade mechanism.
1730 1741
1731 1742 2006-02-21 Ville Vainio <vivainio@gmail.com>
1732 1743
1733 1744 * Magic.py: %save works again.
1734 1745
1735 1746 2006-02-15 Ville Vainio <vivainio@gmail.com>
1736 1747
1737 1748 * Magic.py: %Pprint works again
1738 1749
1739 1750 * Extensions/ipy_sane_defaults.py: Provide everything provided
1740 1751 in default ipythonrc, to make it possible to have a completely empty
1741 1752 ipythonrc (and thus completely rc-file free configuration)
1742 1753
1743 1754 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
1744 1755
1745 1756 * IPython/hooks.py (editor): quote the call to the editor command,
1746 1757 to allow commands with spaces in them. Problem noted by watching
1747 1758 Ian Oswald's video about textpad under win32 at
1748 1759 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
1749 1760
1750 1761 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
1751 1762 describing magics (we haven't used @ for a loong time).
1752 1763
1753 1764 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
1754 1765 contributed by marienz to close
1755 1766 http://www.scipy.net/roundup/ipython/issue53.
1756 1767
1757 1768 2006-02-10 Ville Vainio <vivainio@gmail.com>
1758 1769
1759 1770 * genutils.py: getoutput now works in win32 too
1760 1771
1761 1772 * completer.py: alias and magic completion only invoked
1762 1773 at the first "item" in the line, to avoid "cd %store"
1763 1774 nonsense.
1764 1775
1765 1776 2006-02-09 Ville Vainio <vivainio@gmail.com>
1766 1777
1767 1778 * test/*: Added a unit testing framework (finally).
1768 1779 '%run runtests.py' to run test_*.
1769 1780
1770 1781 * ipapi.py: Exposed runlines and set_custom_exc
1771 1782
1772 1783 2006-02-07 Ville Vainio <vivainio@gmail.com>
1773 1784
1774 1785 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
1775 1786 instead use "f(1 2)" as before.
1776 1787
1777 1788 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
1778 1789
1779 1790 * IPython/demo.py (IPythonDemo): Add new classes to the demo
1780 1791 facilities, for demos processed by the IPython input filter
1781 1792 (IPythonDemo), and for running a script one-line-at-a-time as a
1782 1793 demo, both for pure Python (LineDemo) and for IPython-processed
1783 1794 input (IPythonLineDemo). After a request by Dave Kohel, from the
1784 1795 SAGE team.
1785 1796 (Demo.edit): added an edit() method to the demo objects, to edit
1786 1797 the in-memory copy of the last executed block.
1787 1798
1788 1799 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
1789 1800 processing to %edit, %macro and %save. These commands can now be
1790 1801 invoked on the unprocessed input as it was typed by the user
1791 1802 (without any prefilters applied). After requests by the SAGE team
1792 1803 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
1793 1804
1794 1805 2006-02-01 Ville Vainio <vivainio@gmail.com>
1795 1806
1796 1807 * setup.py, eggsetup.py: easy_install ipython==dev works
1797 1808 correctly now (on Linux)
1798 1809
1799 1810 * ipy_user_conf,ipmaker: user config changes, removed spurious
1800 1811 warnings
1801 1812
1802 1813 * iplib: if rc.banner is string, use it as is.
1803 1814
1804 1815 * Magic: %pycat accepts a string argument and pages it's contents.
1805 1816
1806 1817
1807 1818 2006-01-30 Ville Vainio <vivainio@gmail.com>
1808 1819
1809 1820 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
1810 1821 Now %store and bookmarks work through PickleShare, meaning that
1811 1822 concurrent access is possible and all ipython sessions see the
1812 1823 same database situation all the time, instead of snapshot of
1813 1824 the situation when the session was started. Hence, %bookmark
1814 1825 results are immediately accessible from othes sessions. The database
1815 1826 is also available for use by user extensions. See:
1816 1827 http://www.python.org/pypi/pickleshare
1817 1828
1818 1829 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
1819 1830
1820 1831 * aliases can now be %store'd
1821 1832
1822 1833 * path.py moved to Extensions so that pickleshare does not need
1823 1834 IPython-specific import. Extensions added to pythonpath right
1824 1835 at __init__.
1825 1836
1826 1837 * iplib.py: ipalias deprecated/redundant; aliases are converted and
1827 1838 called with _ip.system and the pre-transformed command string.
1828 1839
1829 1840 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
1830 1841
1831 1842 * IPython/iplib.py (interact): Fix that we were not catching
1832 1843 KeyboardInterrupt exceptions properly. I'm not quite sure why the
1833 1844 logic here had to change, but it's fixed now.
1834 1845
1835 1846 2006-01-29 Ville Vainio <vivainio@gmail.com>
1836 1847
1837 1848 * iplib.py: Try to import pyreadline on Windows.
1838 1849
1839 1850 2006-01-27 Ville Vainio <vivainio@gmail.com>
1840 1851
1841 1852 * iplib.py: Expose ipapi as _ip in builtin namespace.
1842 1853 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
1843 1854 and ip_set_hook (-> _ip.set_hook) redundant. % and !
1844 1855 syntax now produce _ip.* variant of the commands.
1845 1856
1846 1857 * "_ip.options().autoedit_syntax = 2" automatically throws
1847 1858 user to editor for syntax error correction without prompting.
1848 1859
1849 1860 2006-01-27 Ville Vainio <vivainio@gmail.com>
1850 1861
1851 1862 * ipmaker.py: Give "realistic" sys.argv for scripts (without
1852 1863 'ipython' at argv[0]) executed through command line.
1853 1864 NOTE: this DEPRECATES calling ipython with multiple scripts
1854 1865 ("ipython a.py b.py c.py")
1855 1866
1856 1867 * iplib.py, hooks.py: Added configurable input prefilter,
1857 1868 named 'input_prefilter'. See ext_rescapture.py for example
1858 1869 usage.
1859 1870
1860 1871 * ext_rescapture.py, Magic.py: Better system command output capture
1861 1872 through 'var = !ls' (deprecates user-visible %sc). Same notation
1862 1873 applies for magics, 'var = %alias' assigns alias list to var.
1863 1874
1864 1875 * ipapi.py: added meta() for accessing extension-usable data store.
1865 1876
1866 1877 * iplib.py: added InteractiveShell.getapi(). New magics should be
1867 1878 written doing self.getapi() instead of using the shell directly.
1868 1879
1869 1880 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
1870 1881 %store foo >> ~/myfoo.txt to store variables to files (in clean
1871 1882 textual form, not a restorable pickle).
1872 1883
1873 1884 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
1874 1885
1875 1886 * usage.py, Magic.py: added %quickref
1876 1887
1877 1888 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
1878 1889
1879 1890 * GetoptErrors when invoking magics etc. with wrong args
1880 1891 are now more helpful:
1881 1892 GetoptError: option -l not recognized (allowed: "qb" )
1882 1893
1883 1894 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
1884 1895
1885 1896 * IPython/demo.py (Demo.show): Flush stdout after each block, so
1886 1897 computationally intensive blocks don't appear to stall the demo.
1887 1898
1888 1899 2006-01-24 Ville Vainio <vivainio@gmail.com>
1889 1900
1890 1901 * iplib.py, hooks.py: 'result_display' hook can return a non-None
1891 1902 value to manipulate resulting history entry.
1892 1903
1893 1904 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
1894 1905 to instance methods of IPApi class, to make extending an embedded
1895 1906 IPython feasible. See ext_rehashdir.py for example usage.
1896 1907
1897 1908 * Merged 1071-1076 from branches/0.7.1
1898 1909
1899 1910
1900 1911 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
1901 1912
1902 1913 * tools/release (daystamp): Fix build tools to use the new
1903 1914 eggsetup.py script to build lightweight eggs.
1904 1915
1905 1916 * Applied changesets 1062 and 1064 before 0.7.1 release.
1906 1917
1907 1918 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
1908 1919 see the raw input history (without conversions like %ls ->
1909 1920 ipmagic("ls")). After a request from W. Stein, SAGE
1910 1921 (http://modular.ucsd.edu/sage) developer. This information is
1911 1922 stored in the input_hist_raw attribute of the IPython instance, so
1912 1923 developers can access it if needed (it's an InputList instance).
1913 1924
1914 1925 * Versionstring = 0.7.2.svn
1915 1926
1916 1927 * eggsetup.py: A separate script for constructing eggs, creates
1917 1928 proper launch scripts even on Windows (an .exe file in
1918 1929 \python24\scripts).
1919 1930
1920 1931 * ipapi.py: launch_new_instance, launch entry point needed for the
1921 1932 egg.
1922 1933
1923 1934 2006-01-23 Ville Vainio <vivainio@gmail.com>
1924 1935
1925 1936 * Added %cpaste magic for pasting python code
1926 1937
1927 1938 2006-01-22 Ville Vainio <vivainio@gmail.com>
1928 1939
1929 1940 * Merge from branches/0.7.1 into trunk, revs 1052-1057
1930 1941
1931 1942 * Versionstring = 0.7.2.svn
1932 1943
1933 1944 * eggsetup.py: A separate script for constructing eggs, creates
1934 1945 proper launch scripts even on Windows (an .exe file in
1935 1946 \python24\scripts).
1936 1947
1937 1948 * ipapi.py: launch_new_instance, launch entry point needed for the
1938 1949 egg.
1939 1950
1940 1951 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
1941 1952
1942 1953 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
1943 1954 %pfile foo would print the file for foo even if it was a binary.
1944 1955 Now, extensions '.so' and '.dll' are skipped.
1945 1956
1946 1957 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
1947 1958 bug, where macros would fail in all threaded modes. I'm not 100%
1948 1959 sure, so I'm going to put out an rc instead of making a release
1949 1960 today, and wait for feedback for at least a few days.
1950 1961
1951 1962 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
1952 1963 it...) the handling of pasting external code with autoindent on.
1953 1964 To get out of a multiline input, the rule will appear for most
1954 1965 users unchanged: two blank lines or change the indent level
1955 1966 proposed by IPython. But there is a twist now: you can
1956 1967 add/subtract only *one or two spaces*. If you add/subtract three
1957 1968 or more (unless you completely delete the line), IPython will
1958 1969 accept that line, and you'll need to enter a second one of pure
1959 1970 whitespace. I know it sounds complicated, but I can't find a
1960 1971 different solution that covers all the cases, with the right
1961 1972 heuristics. Hopefully in actual use, nobody will really notice
1962 1973 all these strange rules and things will 'just work'.
1963 1974
1964 1975 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
1965 1976
1966 1977 * IPython/iplib.py (interact): catch exceptions which can be
1967 1978 triggered asynchronously by signal handlers. Thanks to an
1968 1979 automatic crash report, submitted by Colin Kingsley
1969 1980 <tercel-AT-gentoo.org>.
1970 1981
1971 1982 2006-01-20 Ville Vainio <vivainio@gmail.com>
1972 1983
1973 1984 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
1974 1985 (%rehashdir, very useful, try it out) of how to extend ipython
1975 1986 with new magics. Also added Extensions dir to pythonpath to make
1976 1987 importing extensions easy.
1977 1988
1978 1989 * %store now complains when trying to store interactively declared
1979 1990 classes / instances of those classes.
1980 1991
1981 1992 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
1982 1993 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
1983 1994 if they exist, and ipy_user_conf.py with some defaults is created for
1984 1995 the user.
1985 1996
1986 1997 * Startup rehashing done by the config file, not InterpreterExec.
1987 1998 This means system commands are available even without selecting the
1988 1999 pysh profile. It's the sensible default after all.
1989 2000
1990 2001 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
1991 2002
1992 2003 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
1993 2004 multiline code with autoindent on working. But I am really not
1994 2005 sure, so this needs more testing. Will commit a debug-enabled
1995 2006 version for now, while I test it some more, so that Ville and
1996 2007 others may also catch any problems. Also made
1997 2008 self.indent_current_str() a method, to ensure that there's no
1998 2009 chance of the indent space count and the corresponding string
1999 2010 falling out of sync. All code needing the string should just call
2000 2011 the method.
2001 2012
2002 2013 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
2003 2014
2004 2015 * IPython/Magic.py (magic_edit): fix check for when users don't
2005 2016 save their output files, the try/except was in the wrong section.
2006 2017
2007 2018 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
2008 2019
2009 2020 * IPython/Magic.py (magic_run): fix __file__ global missing from
2010 2021 script's namespace when executed via %run. After a report by
2011 2022 Vivian.
2012 2023
2013 2024 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
2014 2025 when using python 2.4. The parent constructor changed in 2.4, and
2015 2026 we need to track it directly (we can't call it, as it messes up
2016 2027 readline and tab-completion inside our pdb would stop working).
2017 2028 After a bug report by R. Bernstein <rocky-AT-panix.com>.
2018 2029
2019 2030 2006-01-16 Ville Vainio <vivainio@gmail.com>
2020 2031
2021 2032 * Ipython/magic.py: Reverted back to old %edit functionality
2022 2033 that returns file contents on exit.
2023 2034
2024 2035 * IPython/path.py: Added Jason Orendorff's "path" module to
2025 2036 IPython tree, http://www.jorendorff.com/articles/python/path/.
2026 2037 You can get path objects conveniently through %sc, and !!, e.g.:
2027 2038 sc files=ls
2028 2039 for p in files.paths: # or files.p
2029 2040 print p,p.mtime
2030 2041
2031 2042 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
2032 2043 now work again without considering the exclusion regexp -
2033 2044 hence, things like ',foo my/path' turn to 'foo("my/path")'
2034 2045 instead of syntax error.
2035 2046
2036 2047
2037 2048 2006-01-14 Ville Vainio <vivainio@gmail.com>
2038 2049
2039 2050 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
2040 2051 ipapi decorators for python 2.4 users, options() provides access to rc
2041 2052 data.
2042 2053
2043 2054 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
2044 2055 as path separators (even on Linux ;-). Space character after
2045 2056 backslash (as yielded by tab completer) is still space;
2046 2057 "%cd long\ name" works as expected.
2047 2058
2048 2059 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
2049 2060 as "chain of command", with priority. API stays the same,
2050 2061 TryNext exception raised by a hook function signals that
2051 2062 current hook failed and next hook should try handling it, as
2052 2063 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
2053 2064 requested configurable display hook, which is now implemented.
2054 2065
2055 2066 2006-01-13 Ville Vainio <vivainio@gmail.com>
2056 2067
2057 2068 * IPython/platutils*.py: platform specific utility functions,
2058 2069 so far only set_term_title is implemented (change terminal
2059 2070 label in windowing systems). %cd now changes the title to
2060 2071 current dir.
2061 2072
2062 2073 * IPython/Release.py: Added myself to "authors" list,
2063 2074 had to create new files.
2064 2075
2065 2076 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
2066 2077 shell escape; not a known bug but had potential to be one in the
2067 2078 future.
2068 2079
2069 2080 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
2070 2081 extension API for IPython! See the module for usage example. Fix
2071 2082 OInspect for docstring-less magic functions.
2072 2083
2073 2084
2074 2085 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
2075 2086
2076 2087 * IPython/iplib.py (raw_input): temporarily deactivate all
2077 2088 attempts at allowing pasting of code with autoindent on. It
2078 2089 introduced bugs (reported by Prabhu) and I can't seem to find a
2079 2090 robust combination which works in all cases. Will have to revisit
2080 2091 later.
2081 2092
2082 2093 * IPython/genutils.py: remove isspace() function. We've dropped
2083 2094 2.2 compatibility, so it's OK to use the string method.
2084 2095
2085 2096 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
2086 2097
2087 2098 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
2088 2099 matching what NOT to autocall on, to include all python binary
2089 2100 operators (including things like 'and', 'or', 'is' and 'in').
2090 2101 Prompted by a bug report on 'foo & bar', but I realized we had
2091 2102 many more potential bug cases with other operators. The regexp is
2092 2103 self.re_exclude_auto, it's fairly commented.
2093 2104
2094 2105 2006-01-12 Ville Vainio <vivainio@gmail.com>
2095 2106
2096 2107 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
2097 2108 Prettified and hardened string/backslash quoting with ipsystem(),
2098 2109 ipalias() and ipmagic(). Now even \ characters are passed to
2099 2110 %magics, !shell escapes and aliases exactly as they are in the
2100 2111 ipython command line. Should improve backslash experience,
2101 2112 particularly in Windows (path delimiter for some commands that
2102 2113 won't understand '/'), but Unix benefits as well (regexps). %cd
2103 2114 magic still doesn't support backslash path delimiters, though. Also
2104 2115 deleted all pretense of supporting multiline command strings in
2105 2116 !system or %magic commands. Thanks to Jerry McRae for suggestions.
2106 2117
2107 2118 * doc/build_doc_instructions.txt added. Documentation on how to
2108 2119 use doc/update_manual.py, added yesterday. Both files contributed
2109 2120 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
2110 2121 doc/*.sh for deprecation at a later date.
2111 2122
2112 2123 * /ipython.py Added ipython.py to root directory for
2113 2124 zero-installation (tar xzvf ipython.tgz; cd ipython; python
2114 2125 ipython.py) and development convenience (no need to keep doing
2115 2126 "setup.py install" between changes).
2116 2127
2117 2128 * Made ! and !! shell escapes work (again) in multiline expressions:
2118 2129 if 1:
2119 2130 !ls
2120 2131 !!ls
2121 2132
2122 2133 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
2123 2134
2124 2135 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
2125 2136 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
2126 2137 module in case-insensitive installation. Was causing crashes
2127 2138 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
2128 2139
2129 2140 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
2130 2141 <marienz-AT-gentoo.org>, closes
2131 2142 http://www.scipy.net/roundup/ipython/issue51.
2132 2143
2133 2144 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
2134 2145
2135 2146 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
2136 2147 problem of excessive CPU usage under *nix and keyboard lag under
2137 2148 win32.
2138 2149
2139 2150 2006-01-10 *** Released version 0.7.0
2140 2151
2141 2152 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
2142 2153
2143 2154 * IPython/Release.py (revision): tag version number to 0.7.0,
2144 2155 ready for release.
2145 2156
2146 2157 * IPython/Magic.py (magic_edit): Add print statement to %edit so
2147 2158 it informs the user of the name of the temp. file used. This can
2148 2159 help if you decide later to reuse that same file, so you know
2149 2160 where to copy the info from.
2150 2161
2151 2162 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
2152 2163
2153 2164 * setup_bdist_egg.py: little script to build an egg. Added
2154 2165 support in the release tools as well.
2155 2166
2156 2167 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
2157 2168
2158 2169 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
2159 2170 version selection (new -wxversion command line and ipythonrc
2160 2171 parameter). Patch contributed by Arnd Baecker
2161 2172 <arnd.baecker-AT-web.de>.
2162 2173
2163 2174 * IPython/iplib.py (embed_mainloop): fix tab-completion in
2164 2175 embedded instances, for variables defined at the interactive
2165 2176 prompt of the embedded ipython. Reported by Arnd.
2166 2177
2167 2178 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
2168 2179 it can be used as a (stateful) toggle, or with a direct parameter.
2169 2180
2170 2181 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
2171 2182 could be triggered in certain cases and cause the traceback
2172 2183 printer not to work.
2173 2184
2174 2185 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
2175 2186
2176 2187 * IPython/iplib.py (_should_recompile): Small fix, closes
2177 2188 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
2178 2189
2179 2190 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
2180 2191
2181 2192 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
2182 2193 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
2183 2194 Moad for help with tracking it down.
2184 2195
2185 2196 * IPython/iplib.py (handle_auto): fix autocall handling for
2186 2197 objects which support BOTH __getitem__ and __call__ (so that f [x]
2187 2198 is left alone, instead of becoming f([x]) automatically).
2188 2199
2189 2200 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
2190 2201 Ville's patch.
2191 2202
2192 2203 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
2193 2204
2194 2205 * IPython/iplib.py (handle_auto): changed autocall semantics to
2195 2206 include 'smart' mode, where the autocall transformation is NOT
2196 2207 applied if there are no arguments on the line. This allows you to
2197 2208 just type 'foo' if foo is a callable to see its internal form,
2198 2209 instead of having it called with no arguments (typically a
2199 2210 mistake). The old 'full' autocall still exists: for that, you
2200 2211 need to set the 'autocall' parameter to 2 in your ipythonrc file.
2201 2212
2202 2213 * IPython/completer.py (Completer.attr_matches): add
2203 2214 tab-completion support for Enthoughts' traits. After a report by
2204 2215 Arnd and a patch by Prabhu.
2205 2216
2206 2217 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
2207 2218
2208 2219 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
2209 2220 Schmolck's patch to fix inspect.getinnerframes().
2210 2221
2211 2222 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
2212 2223 for embedded instances, regarding handling of namespaces and items
2213 2224 added to the __builtin__ one. Multiple embedded instances and
2214 2225 recursive embeddings should work better now (though I'm not sure
2215 2226 I've got all the corner cases fixed, that code is a bit of a brain
2216 2227 twister).
2217 2228
2218 2229 * IPython/Magic.py (magic_edit): added support to edit in-memory
2219 2230 macros (automatically creates the necessary temp files). %edit
2220 2231 also doesn't return the file contents anymore, it's just noise.
2221 2232
2222 2233 * IPython/completer.py (Completer.attr_matches): revert change to
2223 2234 complete only on attributes listed in __all__. I realized it
2224 2235 cripples the tab-completion system as a tool for exploring the
2225 2236 internals of unknown libraries (it renders any non-__all__
2226 2237 attribute off-limits). I got bit by this when trying to see
2227 2238 something inside the dis module.
2228 2239
2229 2240 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
2230 2241
2231 2242 * IPython/iplib.py (InteractiveShell.__init__): add .meta
2232 2243 namespace for users and extension writers to hold data in. This
2233 2244 follows the discussion in
2234 2245 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
2235 2246
2236 2247 * IPython/completer.py (IPCompleter.complete): small patch to help
2237 2248 tab-completion under Emacs, after a suggestion by John Barnard
2238 2249 <barnarj-AT-ccf.org>.
2239 2250
2240 2251 * IPython/Magic.py (Magic.extract_input_slices): added support for
2241 2252 the slice notation in magics to use N-M to represent numbers N...M
2242 2253 (closed endpoints). This is used by %macro and %save.
2243 2254
2244 2255 * IPython/completer.py (Completer.attr_matches): for modules which
2245 2256 define __all__, complete only on those. After a patch by Jeffrey
2246 2257 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
2247 2258 speed up this routine.
2248 2259
2249 2260 * IPython/Logger.py (Logger.log): fix a history handling bug. I
2250 2261 don't know if this is the end of it, but the behavior now is
2251 2262 certainly much more correct. Note that coupled with macros,
2252 2263 slightly surprising (at first) behavior may occur: a macro will in
2253 2264 general expand to multiple lines of input, so upon exiting, the
2254 2265 in/out counters will both be bumped by the corresponding amount
2255 2266 (as if the macro's contents had been typed interactively). Typing
2256 2267 %hist will reveal the intermediate (silently processed) lines.
2257 2268
2258 2269 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
2259 2270 pickle to fail (%run was overwriting __main__ and not restoring
2260 2271 it, but pickle relies on __main__ to operate).
2261 2272
2262 2273 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
2263 2274 using properties, but forgot to make the main InteractiveShell
2264 2275 class a new-style class. Properties fail silently, and
2265 2276 mysteriously, with old-style class (getters work, but
2266 2277 setters don't do anything).
2267 2278
2268 2279 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
2269 2280
2270 2281 * IPython/Magic.py (magic_history): fix history reporting bug (I
2271 2282 know some nasties are still there, I just can't seem to find a
2272 2283 reproducible test case to track them down; the input history is
2273 2284 falling out of sync...)
2274 2285
2275 2286 * IPython/iplib.py (handle_shell_escape): fix bug where both
2276 2287 aliases and system accesses where broken for indented code (such
2277 2288 as loops).
2278 2289
2279 2290 * IPython/genutils.py (shell): fix small but critical bug for
2280 2291 win32 system access.
2281 2292
2282 2293 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
2283 2294
2284 2295 * IPython/iplib.py (showtraceback): remove use of the
2285 2296 sys.last_{type/value/traceback} structures, which are non
2286 2297 thread-safe.
2287 2298 (_prefilter): change control flow to ensure that we NEVER
2288 2299 introspect objects when autocall is off. This will guarantee that
2289 2300 having an input line of the form 'x.y', where access to attribute
2290 2301 'y' has side effects, doesn't trigger the side effect TWICE. It
2291 2302 is important to note that, with autocall on, these side effects
2292 2303 can still happen.
2293 2304 (ipsystem): new builtin, to complete the ip{magic/alias/system}
2294 2305 trio. IPython offers these three kinds of special calls which are
2295 2306 not python code, and it's a good thing to have their call method
2296 2307 be accessible as pure python functions (not just special syntax at
2297 2308 the command line). It gives us a better internal implementation
2298 2309 structure, as well as exposing these for user scripting more
2299 2310 cleanly.
2300 2311
2301 2312 * IPython/macro.py (Macro.__init__): moved macros to a standalone
2302 2313 file. Now that they'll be more likely to be used with the
2303 2314 persistance system (%store), I want to make sure their module path
2304 2315 doesn't change in the future, so that we don't break things for
2305 2316 users' persisted data.
2306 2317
2307 2318 * IPython/iplib.py (autoindent_update): move indentation
2308 2319 management into the _text_ processing loop, not the keyboard
2309 2320 interactive one. This is necessary to correctly process non-typed
2310 2321 multiline input (such as macros).
2311 2322
2312 2323 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
2313 2324 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
2314 2325 which was producing problems in the resulting manual.
2315 2326 (magic_whos): improve reporting of instances (show their class,
2316 2327 instead of simply printing 'instance' which isn't terribly
2317 2328 informative).
2318 2329
2319 2330 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
2320 2331 (minor mods) to support network shares under win32.
2321 2332
2322 2333 * IPython/winconsole.py (get_console_size): add new winconsole
2323 2334 module and fixes to page_dumb() to improve its behavior under
2324 2335 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
2325 2336
2326 2337 * IPython/Magic.py (Macro): simplified Macro class to just
2327 2338 subclass list. We've had only 2.2 compatibility for a very long
2328 2339 time, yet I was still avoiding subclassing the builtin types. No
2329 2340 more (I'm also starting to use properties, though I won't shift to
2330 2341 2.3-specific features quite yet).
2331 2342 (magic_store): added Ville's patch for lightweight variable
2332 2343 persistence, after a request on the user list by Matt Wilkie
2333 2344 <maphew-AT-gmail.com>. The new %store magic's docstring has full
2334 2345 details.
2335 2346
2336 2347 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2337 2348 changed the default logfile name from 'ipython.log' to
2338 2349 'ipython_log.py'. These logs are real python files, and now that
2339 2350 we have much better multiline support, people are more likely to
2340 2351 want to use them as such. Might as well name them correctly.
2341 2352
2342 2353 * IPython/Magic.py: substantial cleanup. While we can't stop
2343 2354 using magics as mixins, due to the existing customizations 'out
2344 2355 there' which rely on the mixin naming conventions, at least I
2345 2356 cleaned out all cross-class name usage. So once we are OK with
2346 2357 breaking compatibility, the two systems can be separated.
2347 2358
2348 2359 * IPython/Logger.py: major cleanup. This one is NOT a mixin
2349 2360 anymore, and the class is a fair bit less hideous as well. New
2350 2361 features were also introduced: timestamping of input, and logging
2351 2362 of output results. These are user-visible with the -t and -o
2352 2363 options to %logstart. Closes
2353 2364 http://www.scipy.net/roundup/ipython/issue11 and a request by
2354 2365 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
2355 2366
2356 2367 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
2357 2368
2358 2369 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
2359 2370 better handle backslashes in paths. See the thread 'More Windows
2360 2371 questions part 2 - \/ characters revisited' on the iypthon user
2361 2372 list:
2362 2373 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
2363 2374
2364 2375 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
2365 2376
2366 2377 (InteractiveShell.__init__): change threaded shells to not use the
2367 2378 ipython crash handler. This was causing more problems than not,
2368 2379 as exceptions in the main thread (GUI code, typically) would
2369 2380 always show up as a 'crash', when they really weren't.
2370 2381
2371 2382 The colors and exception mode commands (%colors/%xmode) have been
2372 2383 synchronized to also take this into account, so users can get
2373 2384 verbose exceptions for their threaded code as well. I also added
2374 2385 support for activating pdb inside this exception handler as well,
2375 2386 so now GUI authors can use IPython's enhanced pdb at runtime.
2376 2387
2377 2388 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
2378 2389 true by default, and add it to the shipped ipythonrc file. Since
2379 2390 this asks the user before proceeding, I think it's OK to make it
2380 2391 true by default.
2381 2392
2382 2393 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
2383 2394 of the previous special-casing of input in the eval loop. I think
2384 2395 this is cleaner, as they really are commands and shouldn't have
2385 2396 a special role in the middle of the core code.
2386 2397
2387 2398 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
2388 2399
2389 2400 * IPython/iplib.py (edit_syntax_error): added support for
2390 2401 automatically reopening the editor if the file had a syntax error
2391 2402 in it. Thanks to scottt who provided the patch at:
2392 2403 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
2393 2404 version committed).
2394 2405
2395 2406 * IPython/iplib.py (handle_normal): add suport for multi-line
2396 2407 input with emtpy lines. This fixes
2397 2408 http://www.scipy.net/roundup/ipython/issue43 and a similar
2398 2409 discussion on the user list.
2399 2410
2400 2411 WARNING: a behavior change is necessarily introduced to support
2401 2412 blank lines: now a single blank line with whitespace does NOT
2402 2413 break the input loop, which means that when autoindent is on, by
2403 2414 default hitting return on the next (indented) line does NOT exit.
2404 2415
2405 2416 Instead, to exit a multiline input you can either have:
2406 2417
2407 2418 - TWO whitespace lines (just hit return again), or
2408 2419 - a single whitespace line of a different length than provided
2409 2420 by the autoindent (add or remove a space).
2410 2421
2411 2422 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
2412 2423 module to better organize all readline-related functionality.
2413 2424 I've deleted FlexCompleter and put all completion clases here.
2414 2425
2415 2426 * IPython/iplib.py (raw_input): improve indentation management.
2416 2427 It is now possible to paste indented code with autoindent on, and
2417 2428 the code is interpreted correctly (though it still looks bad on
2418 2429 screen, due to the line-oriented nature of ipython).
2419 2430 (MagicCompleter.complete): change behavior so that a TAB key on an
2420 2431 otherwise empty line actually inserts a tab, instead of completing
2421 2432 on the entire global namespace. This makes it easier to use the
2422 2433 TAB key for indentation. After a request by Hans Meine
2423 2434 <hans_meine-AT-gmx.net>
2424 2435 (_prefilter): add support so that typing plain 'exit' or 'quit'
2425 2436 does a sensible thing. Originally I tried to deviate as little as
2426 2437 possible from the default python behavior, but even that one may
2427 2438 change in this direction (thread on python-dev to that effect).
2428 2439 Regardless, ipython should do the right thing even if CPython's
2429 2440 '>>>' prompt doesn't.
2430 2441 (InteractiveShell): removed subclassing code.InteractiveConsole
2431 2442 class. By now we'd overridden just about all of its methods: I've
2432 2443 copied the remaining two over, and now ipython is a standalone
2433 2444 class. This will provide a clearer picture for the chainsaw
2434 2445 branch refactoring.
2435 2446
2436 2447 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
2437 2448
2438 2449 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
2439 2450 failures for objects which break when dir() is called on them.
2440 2451
2441 2452 * IPython/FlexCompleter.py (Completer.__init__): Added support for
2442 2453 distinct local and global namespaces in the completer API. This
2443 2454 change allows us to properly handle completion with distinct
2444 2455 scopes, including in embedded instances (this had never really
2445 2456 worked correctly).
2446 2457
2447 2458 Note: this introduces a change in the constructor for
2448 2459 MagicCompleter, as a new global_namespace parameter is now the
2449 2460 second argument (the others were bumped one position).
2450 2461
2451 2462 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
2452 2463
2453 2464 * IPython/iplib.py (embed_mainloop): fix tab-completion in
2454 2465 embedded instances (which can be done now thanks to Vivian's
2455 2466 frame-handling fixes for pdb).
2456 2467 (InteractiveShell.__init__): Fix namespace handling problem in
2457 2468 embedded instances. We were overwriting __main__ unconditionally,
2458 2469 and this should only be done for 'full' (non-embedded) IPython;
2459 2470 embedded instances must respect the caller's __main__. Thanks to
2460 2471 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
2461 2472
2462 2473 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
2463 2474
2464 2475 * setup.py: added download_url to setup(). This registers the
2465 2476 download address at PyPI, which is not only useful to humans
2466 2477 browsing the site, but is also picked up by setuptools (the Eggs
2467 2478 machinery). Thanks to Ville and R. Kern for the info/discussion
2468 2479 on this.
2469 2480
2470 2481 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
2471 2482
2472 2483 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
2473 2484 This brings a lot of nice functionality to the pdb mode, which now
2474 2485 has tab-completion, syntax highlighting, and better stack handling
2475 2486 than before. Many thanks to Vivian De Smedt
2476 2487 <vivian-AT-vdesmedt.com> for the original patches.
2477 2488
2478 2489 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
2479 2490
2480 2491 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
2481 2492 sequence to consistently accept the banner argument. The
2482 2493 inconsistency was tripping SAGE, thanks to Gary Zablackis
2483 2494 <gzabl-AT-yahoo.com> for the report.
2484 2495
2485 2496 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2486 2497
2487 2498 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2488 2499 Fix bug where a naked 'alias' call in the ipythonrc file would
2489 2500 cause a crash. Bug reported by Jorgen Stenarson.
2490 2501
2491 2502 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2492 2503
2493 2504 * IPython/ipmaker.py (make_IPython): cleanups which should improve
2494 2505 startup time.
2495 2506
2496 2507 * IPython/iplib.py (runcode): my globals 'fix' for embedded
2497 2508 instances had introduced a bug with globals in normal code. Now
2498 2509 it's working in all cases.
2499 2510
2500 2511 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
2501 2512 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
2502 2513 has been introduced to set the default case sensitivity of the
2503 2514 searches. Users can still select either mode at runtime on a
2504 2515 per-search basis.
2505 2516
2506 2517 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
2507 2518
2508 2519 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
2509 2520 attributes in wildcard searches for subclasses. Modified version
2510 2521 of a patch by Jorgen.
2511 2522
2512 2523 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
2513 2524
2514 2525 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
2515 2526 embedded instances. I added a user_global_ns attribute to the
2516 2527 InteractiveShell class to handle this.
2517 2528
2518 2529 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
2519 2530
2520 2531 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
2521 2532 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
2522 2533 (reported under win32, but may happen also in other platforms).
2523 2534 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
2524 2535
2525 2536 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
2526 2537
2527 2538 * IPython/Magic.py (magic_psearch): new support for wildcard
2528 2539 patterns. Now, typing ?a*b will list all names which begin with a
2529 2540 and end in b, for example. The %psearch magic has full
2530 2541 docstrings. Many thanks to JΓΆrgen Stenarson
2531 2542 <jorgen.stenarson-AT-bostream.nu>, author of the patches
2532 2543 implementing this functionality.
2533 2544
2534 2545 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2535 2546
2536 2547 * Manual: fixed long-standing annoyance of double-dashes (as in
2537 2548 --prefix=~, for example) being stripped in the HTML version. This
2538 2549 is a latex2html bug, but a workaround was provided. Many thanks
2539 2550 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
2540 2551 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
2541 2552 rolling. This seemingly small issue had tripped a number of users
2542 2553 when first installing, so I'm glad to see it gone.
2543 2554
2544 2555 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2545 2556
2546 2557 * IPython/Extensions/numeric_formats.py: fix missing import,
2547 2558 reported by Stephen Walton.
2548 2559
2549 2560 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
2550 2561
2551 2562 * IPython/demo.py: finish demo module, fully documented now.
2552 2563
2553 2564 * IPython/genutils.py (file_read): simple little utility to read a
2554 2565 file and ensure it's closed afterwards.
2555 2566
2556 2567 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
2557 2568
2558 2569 * IPython/demo.py (Demo.__init__): added support for individually
2559 2570 tagging blocks for automatic execution.
2560 2571
2561 2572 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
2562 2573 syntax-highlighted python sources, requested by John.
2563 2574
2564 2575 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
2565 2576
2566 2577 * IPython/demo.py (Demo.again): fix bug where again() blocks after
2567 2578 finishing.
2568 2579
2569 2580 * IPython/genutils.py (shlex_split): moved from Magic to here,
2570 2581 where all 2.2 compatibility stuff lives. I needed it for demo.py.
2571 2582
2572 2583 * IPython/demo.py (Demo.__init__): added support for silent
2573 2584 blocks, improved marks as regexps, docstrings written.
2574 2585 (Demo.__init__): better docstring, added support for sys.argv.
2575 2586
2576 2587 * IPython/genutils.py (marquee): little utility used by the demo
2577 2588 code, handy in general.
2578 2589
2579 2590 * IPython/demo.py (Demo.__init__): new class for interactive
2580 2591 demos. Not documented yet, I just wrote it in a hurry for
2581 2592 scipy'05. Will docstring later.
2582 2593
2583 2594 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
2584 2595
2585 2596 * IPython/Shell.py (sigint_handler): Drastic simplification which
2586 2597 also seems to make Ctrl-C work correctly across threads! This is
2587 2598 so simple, that I can't beleive I'd missed it before. Needs more
2588 2599 testing, though.
2589 2600 (KBINT): Never mind, revert changes. I'm sure I'd tried something
2590 2601 like this before...
2591 2602
2592 2603 * IPython/genutils.py (get_home_dir): add protection against
2593 2604 non-dirs in win32 registry.
2594 2605
2595 2606 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
2596 2607 bug where dict was mutated while iterating (pysh crash).
2597 2608
2598 2609 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
2599 2610
2600 2611 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
2601 2612 spurious newlines added by this routine. After a report by
2602 2613 F. Mantegazza.
2603 2614
2604 2615 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
2605 2616
2606 2617 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
2607 2618 calls. These were a leftover from the GTK 1.x days, and can cause
2608 2619 problems in certain cases (after a report by John Hunter).
2609 2620
2610 2621 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
2611 2622 os.getcwd() fails at init time. Thanks to patch from David Remahl
2612 2623 <chmod007-AT-mac.com>.
2613 2624 (InteractiveShell.__init__): prevent certain special magics from
2614 2625 being shadowed by aliases. Closes
2615 2626 http://www.scipy.net/roundup/ipython/issue41.
2616 2627
2617 2628 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
2618 2629
2619 2630 * IPython/iplib.py (InteractiveShell.complete): Added new
2620 2631 top-level completion method to expose the completion mechanism
2621 2632 beyond readline-based environments.
2622 2633
2623 2634 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
2624 2635
2625 2636 * tools/ipsvnc (svnversion): fix svnversion capture.
2626 2637
2627 2638 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
2628 2639 attribute to self, which was missing. Before, it was set by a
2629 2640 routine which in certain cases wasn't being called, so the
2630 2641 instance could end up missing the attribute. This caused a crash.
2631 2642 Closes http://www.scipy.net/roundup/ipython/issue40.
2632 2643
2633 2644 2005-08-16 Fernando Perez <fperez@colorado.edu>
2634 2645
2635 2646 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
2636 2647 contains non-string attribute. Closes
2637 2648 http://www.scipy.net/roundup/ipython/issue38.
2638 2649
2639 2650 2005-08-14 Fernando Perez <fperez@colorado.edu>
2640 2651
2641 2652 * tools/ipsvnc: Minor improvements, to add changeset info.
2642 2653
2643 2654 2005-08-12 Fernando Perez <fperez@colorado.edu>
2644 2655
2645 2656 * IPython/iplib.py (runsource): remove self.code_to_run_src
2646 2657 attribute. I realized this is nothing more than
2647 2658 '\n'.join(self.buffer), and having the same data in two different
2648 2659 places is just asking for synchronization bugs. This may impact
2649 2660 people who have custom exception handlers, so I need to warn
2650 2661 ipython-dev about it (F. Mantegazza may use them).
2651 2662
2652 2663 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
2653 2664
2654 2665 * IPython/genutils.py: fix 2.2 compatibility (generators)
2655 2666
2656 2667 2005-07-18 Fernando Perez <fperez@colorado.edu>
2657 2668
2658 2669 * IPython/genutils.py (get_home_dir): fix to help users with
2659 2670 invalid $HOME under win32.
2660 2671
2661 2672 2005-07-17 Fernando Perez <fperez@colorado.edu>
2662 2673
2663 2674 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
2664 2675 some old hacks and clean up a bit other routines; code should be
2665 2676 simpler and a bit faster.
2666 2677
2667 2678 * IPython/iplib.py (interact): removed some last-resort attempts
2668 2679 to survive broken stdout/stderr. That code was only making it
2669 2680 harder to abstract out the i/o (necessary for gui integration),
2670 2681 and the crashes it could prevent were extremely rare in practice
2671 2682 (besides being fully user-induced in a pretty violent manner).
2672 2683
2673 2684 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
2674 2685 Nothing major yet, but the code is simpler to read; this should
2675 2686 make it easier to do more serious modifications in the future.
2676 2687
2677 2688 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
2678 2689 which broke in .15 (thanks to a report by Ville).
2679 2690
2680 2691 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
2681 2692 be quite correct, I know next to nothing about unicode). This
2682 2693 will allow unicode strings to be used in prompts, amongst other
2683 2694 cases. It also will prevent ipython from crashing when unicode
2684 2695 shows up unexpectedly in many places. If ascii encoding fails, we
2685 2696 assume utf_8. Currently the encoding is not a user-visible
2686 2697 setting, though it could be made so if there is demand for it.
2687 2698
2688 2699 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
2689 2700
2690 2701 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
2691 2702
2692 2703 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
2693 2704
2694 2705 * IPython/genutils.py: Add 2.2 compatibility here, so all other
2695 2706 code can work transparently for 2.2/2.3.
2696 2707
2697 2708 2005-07-16 Fernando Perez <fperez@colorado.edu>
2698 2709
2699 2710 * IPython/ultraTB.py (ExceptionColors): Make a global variable
2700 2711 out of the color scheme table used for coloring exception
2701 2712 tracebacks. This allows user code to add new schemes at runtime.
2702 2713 This is a minimally modified version of the patch at
2703 2714 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
2704 2715 for the contribution.
2705 2716
2706 2717 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
2707 2718 slightly modified version of the patch in
2708 2719 http://www.scipy.net/roundup/ipython/issue34, which also allows me
2709 2720 to remove the previous try/except solution (which was costlier).
2710 2721 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
2711 2722
2712 2723 2005-06-08 Fernando Perez <fperez@colorado.edu>
2713 2724
2714 2725 * IPython/iplib.py (write/write_err): Add methods to abstract all
2715 2726 I/O a bit more.
2716 2727
2717 2728 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
2718 2729 warning, reported by Aric Hagberg, fix by JD Hunter.
2719 2730
2720 2731 2005-06-02 *** Released version 0.6.15
2721 2732
2722 2733 2005-06-01 Fernando Perez <fperez@colorado.edu>
2723 2734
2724 2735 * IPython/iplib.py (MagicCompleter.file_matches): Fix
2725 2736 tab-completion of filenames within open-quoted strings. Note that
2726 2737 this requires that in ~/.ipython/ipythonrc, users change the
2727 2738 readline delimiters configuration to read:
2728 2739
2729 2740 readline_remove_delims -/~
2730 2741
2731 2742
2732 2743 2005-05-31 *** Released version 0.6.14
2733 2744
2734 2745 2005-05-29 Fernando Perez <fperez@colorado.edu>
2735 2746
2736 2747 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
2737 2748 with files not on the filesystem. Reported by Eliyahu Sandler
2738 2749 <eli@gondolin.net>
2739 2750
2740 2751 2005-05-22 Fernando Perez <fperez@colorado.edu>
2741 2752
2742 2753 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
2743 2754 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
2744 2755
2745 2756 2005-05-19 Fernando Perez <fperez@colorado.edu>
2746 2757
2747 2758 * IPython/iplib.py (safe_execfile): close a file which could be
2748 2759 left open (causing problems in win32, which locks open files).
2749 2760 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
2750 2761
2751 2762 2005-05-18 Fernando Perez <fperez@colorado.edu>
2752 2763
2753 2764 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
2754 2765 keyword arguments correctly to safe_execfile().
2755 2766
2756 2767 2005-05-13 Fernando Perez <fperez@colorado.edu>
2757 2768
2758 2769 * ipython.1: Added info about Qt to manpage, and threads warning
2759 2770 to usage page (invoked with --help).
2760 2771
2761 2772 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
2762 2773 new matcher (it goes at the end of the priority list) to do
2763 2774 tab-completion on named function arguments. Submitted by George
2764 2775 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
2765 2776 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
2766 2777 for more details.
2767 2778
2768 2779 * IPython/Magic.py (magic_run): Added new -e flag to ignore
2769 2780 SystemExit exceptions in the script being run. Thanks to a report
2770 2781 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
2771 2782 producing very annoying behavior when running unit tests.
2772 2783
2773 2784 2005-05-12 Fernando Perez <fperez@colorado.edu>
2774 2785
2775 2786 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
2776 2787 which I'd broken (again) due to a changed regexp. In the process,
2777 2788 added ';' as an escape to auto-quote the whole line without
2778 2789 splitting its arguments. Thanks to a report by Jerry McRae
2779 2790 <qrs0xyc02-AT-sneakemail.com>.
2780 2791
2781 2792 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
2782 2793 possible crashes caused by a TokenError. Reported by Ed Schofield
2783 2794 <schofield-AT-ftw.at>.
2784 2795
2785 2796 2005-05-06 Fernando Perez <fperez@colorado.edu>
2786 2797
2787 2798 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
2788 2799
2789 2800 2005-04-29 Fernando Perez <fperez@colorado.edu>
2790 2801
2791 2802 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
2792 2803 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
2793 2804 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
2794 2805 which provides support for Qt interactive usage (similar to the
2795 2806 existing one for WX and GTK). This had been often requested.
2796 2807
2797 2808 2005-04-14 *** Released version 0.6.13
2798 2809
2799 2810 2005-04-08 Fernando Perez <fperez@colorado.edu>
2800 2811
2801 2812 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
2802 2813 from _ofind, which gets called on almost every input line. Now,
2803 2814 we only try to get docstrings if they are actually going to be
2804 2815 used (the overhead of fetching unnecessary docstrings can be
2805 2816 noticeable for certain objects, such as Pyro proxies).
2806 2817
2807 2818 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
2808 2819 for completers. For some reason I had been passing them the state
2809 2820 variable, which completers never actually need, and was in
2810 2821 conflict with the rlcompleter API. Custom completers ONLY need to
2811 2822 take the text parameter.
2812 2823
2813 2824 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
2814 2825 work correctly in pysh. I've also moved all the logic which used
2815 2826 to be in pysh.py here, which will prevent problems with future
2816 2827 upgrades. However, this time I must warn users to update their
2817 2828 pysh profile to include the line
2818 2829
2819 2830 import_all IPython.Extensions.InterpreterExec
2820 2831
2821 2832 because otherwise things won't work for them. They MUST also
2822 2833 delete pysh.py and the line
2823 2834
2824 2835 execfile pysh.py
2825 2836
2826 2837 from their ipythonrc-pysh.
2827 2838
2828 2839 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
2829 2840 robust in the face of objects whose dir() returns non-strings
2830 2841 (which it shouldn't, but some broken libs like ITK do). Thanks to
2831 2842 a patch by John Hunter (implemented differently, though). Also
2832 2843 minor improvements by using .extend instead of + on lists.
2833 2844
2834 2845 * pysh.py:
2835 2846
2836 2847 2005-04-06 Fernando Perez <fperez@colorado.edu>
2837 2848
2838 2849 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
2839 2850 by default, so that all users benefit from it. Those who don't
2840 2851 want it can still turn it off.
2841 2852
2842 2853 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
2843 2854 config file, I'd forgotten about this, so users were getting it
2844 2855 off by default.
2845 2856
2846 2857 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
2847 2858 consistency. Now magics can be called in multiline statements,
2848 2859 and python variables can be expanded in magic calls via $var.
2849 2860 This makes the magic system behave just like aliases or !system
2850 2861 calls.
2851 2862
2852 2863 2005-03-28 Fernando Perez <fperez@colorado.edu>
2853 2864
2854 2865 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
2855 2866 expensive string additions for building command. Add support for
2856 2867 trailing ';' when autocall is used.
2857 2868
2858 2869 2005-03-26 Fernando Perez <fperez@colorado.edu>
2859 2870
2860 2871 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
2861 2872 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
2862 2873 ipython.el robust against prompts with any number of spaces
2863 2874 (including 0) after the ':' character.
2864 2875
2865 2876 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
2866 2877 continuation prompt, which misled users to think the line was
2867 2878 already indented. Closes debian Bug#300847, reported to me by
2868 2879 Norbert Tretkowski <tretkowski-AT-inittab.de>.
2869 2880
2870 2881 2005-03-23 Fernando Perez <fperez@colorado.edu>
2871 2882
2872 2883 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
2873 2884 properly aligned if they have embedded newlines.
2874 2885
2875 2886 * IPython/iplib.py (runlines): Add a public method to expose
2876 2887 IPython's code execution machinery, so that users can run strings
2877 2888 as if they had been typed at the prompt interactively.
2878 2889 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
2879 2890 methods which can call the system shell, but with python variable
2880 2891 expansion. The three such methods are: __IPYTHON__.system,
2881 2892 .getoutput and .getoutputerror. These need to be documented in a
2882 2893 'public API' section (to be written) of the manual.
2883 2894
2884 2895 2005-03-20 Fernando Perez <fperez@colorado.edu>
2885 2896
2886 2897 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
2887 2898 for custom exception handling. This is quite powerful, and it
2888 2899 allows for user-installable exception handlers which can trap
2889 2900 custom exceptions at runtime and treat them separately from
2890 2901 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
2891 2902 Mantegazza <mantegazza-AT-ill.fr>.
2892 2903 (InteractiveShell.set_custom_completer): public API function to
2893 2904 add new completers at runtime.
2894 2905
2895 2906 2005-03-19 Fernando Perez <fperez@colorado.edu>
2896 2907
2897 2908 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
2898 2909 allow objects which provide their docstrings via non-standard
2899 2910 mechanisms (like Pyro proxies) to still be inspected by ipython's
2900 2911 ? system.
2901 2912
2902 2913 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
2903 2914 automatic capture system. I tried quite hard to make it work
2904 2915 reliably, and simply failed. I tried many combinations with the
2905 2916 subprocess module, but eventually nothing worked in all needed
2906 2917 cases (not blocking stdin for the child, duplicating stdout
2907 2918 without blocking, etc). The new %sc/%sx still do capture to these
2908 2919 magical list/string objects which make shell use much more
2909 2920 conveninent, so not all is lost.
2910 2921
2911 2922 XXX - FIX MANUAL for the change above!
2912 2923
2913 2924 (runsource): I copied code.py's runsource() into ipython to modify
2914 2925 it a bit. Now the code object and source to be executed are
2915 2926 stored in ipython. This makes this info accessible to third-party
2916 2927 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
2917 2928 Mantegazza <mantegazza-AT-ill.fr>.
2918 2929
2919 2930 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
2920 2931 history-search via readline (like C-p/C-n). I'd wanted this for a
2921 2932 long time, but only recently found out how to do it. For users
2922 2933 who already have their ipythonrc files made and want this, just
2923 2934 add:
2924 2935
2925 2936 readline_parse_and_bind "\e[A": history-search-backward
2926 2937 readline_parse_and_bind "\e[B": history-search-forward
2927 2938
2928 2939 2005-03-18 Fernando Perez <fperez@colorado.edu>
2929 2940
2930 2941 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
2931 2942 LSString and SList classes which allow transparent conversions
2932 2943 between list mode and whitespace-separated string.
2933 2944 (magic_r): Fix recursion problem in %r.
2934 2945
2935 2946 * IPython/genutils.py (LSString): New class to be used for
2936 2947 automatic storage of the results of all alias/system calls in _o
2937 2948 and _e (stdout/err). These provide a .l/.list attribute which
2938 2949 does automatic splitting on newlines. This means that for most
2939 2950 uses, you'll never need to do capturing of output with %sc/%sx
2940 2951 anymore, since ipython keeps this always done for you. Note that
2941 2952 only the LAST results are stored, the _o/e variables are
2942 2953 overwritten on each call. If you need to save their contents
2943 2954 further, simply bind them to any other name.
2944 2955
2945 2956 2005-03-17 Fernando Perez <fperez@colorado.edu>
2946 2957
2947 2958 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
2948 2959 prompt namespace handling.
2949 2960
2950 2961 2005-03-16 Fernando Perez <fperez@colorado.edu>
2951 2962
2952 2963 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
2953 2964 classic prompts to be '>>> ' (final space was missing, and it
2954 2965 trips the emacs python mode).
2955 2966 (BasePrompt.__str__): Added safe support for dynamic prompt
2956 2967 strings. Now you can set your prompt string to be '$x', and the
2957 2968 value of x will be printed from your interactive namespace. The
2958 2969 interpolation syntax includes the full Itpl support, so
2959 2970 ${foo()+x+bar()} is a valid prompt string now, and the function
2960 2971 calls will be made at runtime.
2961 2972
2962 2973 2005-03-15 Fernando Perez <fperez@colorado.edu>
2963 2974
2964 2975 * IPython/Magic.py (magic_history): renamed %hist to %history, to
2965 2976 avoid name clashes in pylab. %hist still works, it just forwards
2966 2977 the call to %history.
2967 2978
2968 2979 2005-03-02 *** Released version 0.6.12
2969 2980
2970 2981 2005-03-02 Fernando Perez <fperez@colorado.edu>
2971 2982
2972 2983 * IPython/iplib.py (handle_magic): log magic calls properly as
2973 2984 ipmagic() function calls.
2974 2985
2975 2986 * IPython/Magic.py (magic_time): Improved %time to support
2976 2987 statements and provide wall-clock as well as CPU time.
2977 2988
2978 2989 2005-02-27 Fernando Perez <fperez@colorado.edu>
2979 2990
2980 2991 * IPython/hooks.py: New hooks module, to expose user-modifiable
2981 2992 IPython functionality in a clean manner. For now only the editor
2982 2993 hook is actually written, and other thigns which I intend to turn
2983 2994 into proper hooks aren't yet there. The display and prefilter
2984 2995 stuff, for example, should be hooks. But at least now the
2985 2996 framework is in place, and the rest can be moved here with more
2986 2997 time later. IPython had had a .hooks variable for a long time for
2987 2998 this purpose, but I'd never actually used it for anything.
2988 2999
2989 3000 2005-02-26 Fernando Perez <fperez@colorado.edu>
2990 3001
2991 3002 * IPython/ipmaker.py (make_IPython): make the default ipython
2992 3003 directory be called _ipython under win32, to follow more the
2993 3004 naming peculiarities of that platform (where buggy software like
2994 3005 Visual Sourcesafe breaks with .named directories). Reported by
2995 3006 Ville Vainio.
2996 3007
2997 3008 2005-02-23 Fernando Perez <fperez@colorado.edu>
2998 3009
2999 3010 * IPython/iplib.py (InteractiveShell.__init__): removed a few
3000 3011 auto_aliases for win32 which were causing problems. Users can
3001 3012 define the ones they personally like.
3002 3013
3003 3014 2005-02-21 Fernando Perez <fperez@colorado.edu>
3004 3015
3005 3016 * IPython/Magic.py (magic_time): new magic to time execution of
3006 3017 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
3007 3018
3008 3019 2005-02-19 Fernando Perez <fperez@colorado.edu>
3009 3020
3010 3021 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
3011 3022 into keys (for prompts, for example).
3012 3023
3013 3024 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
3014 3025 prompts in case users want them. This introduces a small behavior
3015 3026 change: ipython does not automatically add a space to all prompts
3016 3027 anymore. To get the old prompts with a space, users should add it
3017 3028 manually to their ipythonrc file, so for example prompt_in1 should
3018 3029 now read 'In [\#]: ' instead of 'In [\#]:'.
3019 3030 (BasePrompt.__init__): New option prompts_pad_left (only in rc
3020 3031 file) to control left-padding of secondary prompts.
3021 3032
3022 3033 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
3023 3034 the profiler can't be imported. Fix for Debian, which removed
3024 3035 profile.py because of License issues. I applied a slightly
3025 3036 modified version of the original Debian patch at
3026 3037 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
3027 3038
3028 3039 2005-02-17 Fernando Perez <fperez@colorado.edu>
3029 3040
3030 3041 * IPython/genutils.py (native_line_ends): Fix bug which would
3031 3042 cause improper line-ends under win32 b/c I was not opening files
3032 3043 in binary mode. Bug report and fix thanks to Ville.
3033 3044
3034 3045 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
3035 3046 trying to catch spurious foo[1] autocalls. My fix actually broke
3036 3047 ',/' autoquote/call with explicit escape (bad regexp).
3037 3048
3038 3049 2005-02-15 *** Released version 0.6.11
3039 3050
3040 3051 2005-02-14 Fernando Perez <fperez@colorado.edu>
3041 3052
3042 3053 * IPython/background_jobs.py: New background job management
3043 3054 subsystem. This is implemented via a new set of classes, and
3044 3055 IPython now provides a builtin 'jobs' object for background job
3045 3056 execution. A convenience %bg magic serves as a lightweight
3046 3057 frontend for starting the more common type of calls. This was
3047 3058 inspired by discussions with B. Granger and the BackgroundCommand
3048 3059 class described in the book Python Scripting for Computational
3049 3060 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
3050 3061 (although ultimately no code from this text was used, as IPython's
3051 3062 system is a separate implementation).
3052 3063
3053 3064 * IPython/iplib.py (MagicCompleter.python_matches): add new option
3054 3065 to control the completion of single/double underscore names
3055 3066 separately. As documented in the example ipytonrc file, the
3056 3067 readline_omit__names variable can now be set to 2, to omit even
3057 3068 single underscore names. Thanks to a patch by Brian Wong
3058 3069 <BrianWong-AT-AirgoNetworks.Com>.
3059 3070 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
3060 3071 be autocalled as foo([1]) if foo were callable. A problem for
3061 3072 things which are both callable and implement __getitem__.
3062 3073 (init_readline): Fix autoindentation for win32. Thanks to a patch
3063 3074 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
3064 3075
3065 3076 2005-02-12 Fernando Perez <fperez@colorado.edu>
3066 3077
3067 3078 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
3068 3079 which I had written long ago to sort out user error messages which
3069 3080 may occur during startup. This seemed like a good idea initially,
3070 3081 but it has proven a disaster in retrospect. I don't want to
3071 3082 change much code for now, so my fix is to set the internal 'debug'
3072 3083 flag to true everywhere, whose only job was precisely to control
3073 3084 this subsystem. This closes issue 28 (as well as avoiding all
3074 3085 sorts of strange hangups which occur from time to time).
3075 3086
3076 3087 2005-02-07 Fernando Perez <fperez@colorado.edu>
3077 3088
3078 3089 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
3079 3090 previous call produced a syntax error.
3080 3091
3081 3092 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
3082 3093 classes without constructor.
3083 3094
3084 3095 2005-02-06 Fernando Perez <fperez@colorado.edu>
3085 3096
3086 3097 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
3087 3098 completions with the results of each matcher, so we return results
3088 3099 to the user from all namespaces. This breaks with ipython
3089 3100 tradition, but I think it's a nicer behavior. Now you get all
3090 3101 possible completions listed, from all possible namespaces (python,
3091 3102 filesystem, magics...) After a request by John Hunter
3092 3103 <jdhunter-AT-nitace.bsd.uchicago.edu>.
3093 3104
3094 3105 2005-02-05 Fernando Perez <fperez@colorado.edu>
3095 3106
3096 3107 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
3097 3108 the call had quote characters in it (the quotes were stripped).
3098 3109
3099 3110 2005-01-31 Fernando Perez <fperez@colorado.edu>
3100 3111
3101 3112 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
3102 3113 Itpl.itpl() to make the code more robust against psyco
3103 3114 optimizations.
3104 3115
3105 3116 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
3106 3117 of causing an exception. Quicker, cleaner.
3107 3118
3108 3119 2005-01-28 Fernando Perez <fperez@colorado.edu>
3109 3120
3110 3121 * scripts/ipython_win_post_install.py (install): hardcode
3111 3122 sys.prefix+'python.exe' as the executable path. It turns out that
3112 3123 during the post-installation run, sys.executable resolves to the
3113 3124 name of the binary installer! I should report this as a distutils
3114 3125 bug, I think. I updated the .10 release with this tiny fix, to
3115 3126 avoid annoying the lists further.
3116 3127
3117 3128 2005-01-27 *** Released version 0.6.10
3118 3129
3119 3130 2005-01-27 Fernando Perez <fperez@colorado.edu>
3120 3131
3121 3132 * IPython/numutils.py (norm): Added 'inf' as optional name for
3122 3133 L-infinity norm, included references to mathworld.com for vector
3123 3134 norm definitions.
3124 3135 (amin/amax): added amin/amax for array min/max. Similar to what
3125 3136 pylab ships with after the recent reorganization of names.
3126 3137 (spike/spike_odd): removed deprecated spike/spike_odd functions.
3127 3138
3128 3139 * ipython.el: committed Alex's recent fixes and improvements.
3129 3140 Tested with python-mode from CVS, and it looks excellent. Since
3130 3141 python-mode hasn't released anything in a while, I'm temporarily
3131 3142 putting a copy of today's CVS (v 4.70) of python-mode in:
3132 3143 http://ipython.scipy.org/tmp/python-mode.el
3133 3144
3134 3145 * scripts/ipython_win_post_install.py (install): Win32 fix to use
3135 3146 sys.executable for the executable name, instead of assuming it's
3136 3147 called 'python.exe' (the post-installer would have produced broken
3137 3148 setups on systems with a differently named python binary).
3138 3149
3139 3150 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
3140 3151 references to os.linesep, to make the code more
3141 3152 platform-independent. This is also part of the win32 coloring
3142 3153 fixes.
3143 3154
3144 3155 * IPython/genutils.py (page_dumb): Remove attempts to chop long
3145 3156 lines, which actually cause coloring bugs because the length of
3146 3157 the line is very difficult to correctly compute with embedded
3147 3158 escapes. This was the source of all the coloring problems under
3148 3159 Win32. I think that _finally_, Win32 users have a properly
3149 3160 working ipython in all respects. This would never have happened
3150 3161 if not for Gary Bishop and Viktor Ransmayr's great help and work.
3151 3162
3152 3163 2005-01-26 *** Released version 0.6.9
3153 3164
3154 3165 2005-01-25 Fernando Perez <fperez@colorado.edu>
3155 3166
3156 3167 * setup.py: finally, we have a true Windows installer, thanks to
3157 3168 the excellent work of Viktor Ransmayr
3158 3169 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
3159 3170 Windows users. The setup routine is quite a bit cleaner thanks to
3160 3171 this, and the post-install script uses the proper functions to
3161 3172 allow a clean de-installation using the standard Windows Control
3162 3173 Panel.
3163 3174
3164 3175 * IPython/genutils.py (get_home_dir): changed to use the $HOME
3165 3176 environment variable under all OSes (including win32) if
3166 3177 available. This will give consistency to win32 users who have set
3167 3178 this variable for any reason. If os.environ['HOME'] fails, the
3168 3179 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
3169 3180
3170 3181 2005-01-24 Fernando Perez <fperez@colorado.edu>
3171 3182
3172 3183 * IPython/numutils.py (empty_like): add empty_like(), similar to
3173 3184 zeros_like() but taking advantage of the new empty() Numeric routine.
3174 3185
3175 3186 2005-01-23 *** Released version 0.6.8
3176 3187
3177 3188 2005-01-22 Fernando Perez <fperez@colorado.edu>
3178 3189
3179 3190 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
3180 3191 automatic show() calls. After discussing things with JDH, it
3181 3192 turns out there are too many corner cases where this can go wrong.
3182 3193 It's best not to try to be 'too smart', and simply have ipython
3183 3194 reproduce as much as possible the default behavior of a normal
3184 3195 python shell.
3185 3196
3186 3197 * IPython/iplib.py (InteractiveShell.__init__): Modified the
3187 3198 line-splitting regexp and _prefilter() to avoid calling getattr()
3188 3199 on assignments. This closes
3189 3200 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
3190 3201 readline uses getattr(), so a simple <TAB> keypress is still
3191 3202 enough to trigger getattr() calls on an object.
3192 3203
3193 3204 2005-01-21 Fernando Perez <fperez@colorado.edu>
3194 3205
3195 3206 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
3196 3207 docstring under pylab so it doesn't mask the original.
3197 3208
3198 3209 2005-01-21 *** Released version 0.6.7
3199 3210
3200 3211 2005-01-21 Fernando Perez <fperez@colorado.edu>
3201 3212
3202 3213 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
3203 3214 signal handling for win32 users in multithreaded mode.
3204 3215
3205 3216 2005-01-17 Fernando Perez <fperez@colorado.edu>
3206 3217
3207 3218 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
3208 3219 instances with no __init__. After a crash report by Norbert Nemec
3209 3220 <Norbert-AT-nemec-online.de>.
3210 3221
3211 3222 2005-01-14 Fernando Perez <fperez@colorado.edu>
3212 3223
3213 3224 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
3214 3225 names for verbose exceptions, when multiple dotted names and the
3215 3226 'parent' object were present on the same line.
3216 3227
3217 3228 2005-01-11 Fernando Perez <fperez@colorado.edu>
3218 3229
3219 3230 * IPython/genutils.py (flag_calls): new utility to trap and flag
3220 3231 calls in functions. I need it to clean up matplotlib support.
3221 3232 Also removed some deprecated code in genutils.
3222 3233
3223 3234 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
3224 3235 that matplotlib scripts called with %run, which don't call show()
3225 3236 themselves, still have their plotting windows open.
3226 3237
3227 3238 2005-01-05 Fernando Perez <fperez@colorado.edu>
3228 3239
3229 3240 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
3230 3241 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
3231 3242
3232 3243 2004-12-19 Fernando Perez <fperez@colorado.edu>
3233 3244
3234 3245 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
3235 3246 parent_runcode, which was an eyesore. The same result can be
3236 3247 obtained with Python's regular superclass mechanisms.
3237 3248
3238 3249 2004-12-17 Fernando Perez <fperez@colorado.edu>
3239 3250
3240 3251 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
3241 3252 reported by Prabhu.
3242 3253 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
3243 3254 sys.stderr) instead of explicitly calling sys.stderr. This helps
3244 3255 maintain our I/O abstractions clean, for future GUI embeddings.
3245 3256
3246 3257 * IPython/genutils.py (info): added new utility for sys.stderr
3247 3258 unified info message handling (thin wrapper around warn()).
3248 3259
3249 3260 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
3250 3261 composite (dotted) names on verbose exceptions.
3251 3262 (VerboseTB.nullrepr): harden against another kind of errors which
3252 3263 Python's inspect module can trigger, and which were crashing
3253 3264 IPython. Thanks to a report by Marco Lombardi
3254 3265 <mlombard-AT-ma010192.hq.eso.org>.
3255 3266
3256 3267 2004-12-13 *** Released version 0.6.6
3257 3268
3258 3269 2004-12-12 Fernando Perez <fperez@colorado.edu>
3259 3270
3260 3271 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
3261 3272 generated by pygtk upon initialization if it was built without
3262 3273 threads (for matplotlib users). After a crash reported by
3263 3274 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
3264 3275
3265 3276 * IPython/ipmaker.py (make_IPython): fix small bug in the
3266 3277 import_some parameter for multiple imports.
3267 3278
3268 3279 * IPython/iplib.py (ipmagic): simplified the interface of
3269 3280 ipmagic() to take a single string argument, just as it would be
3270 3281 typed at the IPython cmd line.
3271 3282 (ipalias): Added new ipalias() with an interface identical to
3272 3283 ipmagic(). This completes exposing a pure python interface to the
3273 3284 alias and magic system, which can be used in loops or more complex
3274 3285 code where IPython's automatic line mangling is not active.
3275 3286
3276 3287 * IPython/genutils.py (timing): changed interface of timing to
3277 3288 simply run code once, which is the most common case. timings()
3278 3289 remains unchanged, for the cases where you want multiple runs.
3279 3290
3280 3291 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
3281 3292 bug where Python2.2 crashes with exec'ing code which does not end
3282 3293 in a single newline. Python 2.3 is OK, so I hadn't noticed this
3283 3294 before.
3284 3295
3285 3296 2004-12-10 Fernando Perez <fperez@colorado.edu>
3286 3297
3287 3298 * IPython/Magic.py (Magic.magic_prun): changed name of option from
3288 3299 -t to -T, to accomodate the new -t flag in %run (the %run and
3289 3300 %prun options are kind of intermixed, and it's not easy to change
3290 3301 this with the limitations of python's getopt).
3291 3302
3292 3303 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
3293 3304 the execution of scripts. It's not as fine-tuned as timeit.py,
3294 3305 but it works from inside ipython (and under 2.2, which lacks
3295 3306 timeit.py). Optionally a number of runs > 1 can be given for
3296 3307 timing very short-running code.
3297 3308
3298 3309 * IPython/genutils.py (uniq_stable): new routine which returns a
3299 3310 list of unique elements in any iterable, but in stable order of
3300 3311 appearance. I needed this for the ultraTB fixes, and it's a handy
3301 3312 utility.
3302 3313
3303 3314 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
3304 3315 dotted names in Verbose exceptions. This had been broken since
3305 3316 the very start, now x.y will properly be printed in a Verbose
3306 3317 traceback, instead of x being shown and y appearing always as an
3307 3318 'undefined global'. Getting this to work was a bit tricky,
3308 3319 because by default python tokenizers are stateless. Saved by
3309 3320 python's ability to easily add a bit of state to an arbitrary
3310 3321 function (without needing to build a full-blown callable object).
3311 3322
3312 3323 Also big cleanup of this code, which had horrendous runtime
3313 3324 lookups of zillions of attributes for colorization. Moved all
3314 3325 this code into a few templates, which make it cleaner and quicker.
3315 3326
3316 3327 Printout quality was also improved for Verbose exceptions: one
3317 3328 variable per line, and memory addresses are printed (this can be
3318 3329 quite handy in nasty debugging situations, which is what Verbose
3319 3330 is for).
3320 3331
3321 3332 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
3322 3333 the command line as scripts to be loaded by embedded instances.
3323 3334 Doing so has the potential for an infinite recursion if there are
3324 3335 exceptions thrown in the process. This fixes a strange crash
3325 3336 reported by Philippe MULLER <muller-AT-irit.fr>.
3326 3337
3327 3338 2004-12-09 Fernando Perez <fperez@colorado.edu>
3328 3339
3329 3340 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
3330 3341 to reflect new names in matplotlib, which now expose the
3331 3342 matlab-compatible interface via a pylab module instead of the
3332 3343 'matlab' name. The new code is backwards compatible, so users of
3333 3344 all matplotlib versions are OK. Patch by J. Hunter.
3334 3345
3335 3346 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
3336 3347 of __init__ docstrings for instances (class docstrings are already
3337 3348 automatically printed). Instances with customized docstrings
3338 3349 (indep. of the class) are also recognized and all 3 separate
3339 3350 docstrings are printed (instance, class, constructor). After some
3340 3351 comments/suggestions by J. Hunter.
3341 3352
3342 3353 2004-12-05 Fernando Perez <fperez@colorado.edu>
3343 3354
3344 3355 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
3345 3356 warnings when tab-completion fails and triggers an exception.
3346 3357
3347 3358 2004-12-03 Fernando Perez <fperez@colorado.edu>
3348 3359
3349 3360 * IPython/Magic.py (magic_prun): Fix bug where an exception would
3350 3361 be triggered when using 'run -p'. An incorrect option flag was
3351 3362 being set ('d' instead of 'D').
3352 3363 (manpage): fix missing escaped \- sign.
3353 3364
3354 3365 2004-11-30 *** Released version 0.6.5
3355 3366
3356 3367 2004-11-30 Fernando Perez <fperez@colorado.edu>
3357 3368
3358 3369 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
3359 3370 setting with -d option.
3360 3371
3361 3372 * setup.py (docfiles): Fix problem where the doc glob I was using
3362 3373 was COMPLETELY BROKEN. It was giving the right files by pure
3363 3374 accident, but failed once I tried to include ipython.el. Note:
3364 3375 glob() does NOT allow you to do exclusion on multiple endings!
3365 3376
3366 3377 2004-11-29 Fernando Perez <fperez@colorado.edu>
3367 3378
3368 3379 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
3369 3380 the manpage as the source. Better formatting & consistency.
3370 3381
3371 3382 * IPython/Magic.py (magic_run): Added new -d option, to run
3372 3383 scripts under the control of the python pdb debugger. Note that
3373 3384 this required changing the %prun option -d to -D, to avoid a clash
3374 3385 (since %run must pass options to %prun, and getopt is too dumb to
3375 3386 handle options with string values with embedded spaces). Thanks
3376 3387 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
3377 3388 (magic_who_ls): added type matching to %who and %whos, so that one
3378 3389 can filter their output to only include variables of certain
3379 3390 types. Another suggestion by Matthew.
3380 3391 (magic_whos): Added memory summaries in kb and Mb for arrays.
3381 3392 (magic_who): Improve formatting (break lines every 9 vars).
3382 3393
3383 3394 2004-11-28 Fernando Perez <fperez@colorado.edu>
3384 3395
3385 3396 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
3386 3397 cache when empty lines were present.
3387 3398
3388 3399 2004-11-24 Fernando Perez <fperez@colorado.edu>
3389 3400
3390 3401 * IPython/usage.py (__doc__): document the re-activated threading
3391 3402 options for WX and GTK.
3392 3403
3393 3404 2004-11-23 Fernando Perez <fperez@colorado.edu>
3394 3405
3395 3406 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
3396 3407 the -wthread and -gthread options, along with a new -tk one to try
3397 3408 and coordinate Tk threading with wx/gtk. The tk support is very
3398 3409 platform dependent, since it seems to require Tcl and Tk to be
3399 3410 built with threads (Fedora1/2 appears NOT to have it, but in
3400 3411 Prabhu's Debian boxes it works OK). But even with some Tk
3401 3412 limitations, this is a great improvement.
3402 3413
3403 3414 * IPython/Prompts.py (prompt_specials_color): Added \t for time
3404 3415 info in user prompts. Patch by Prabhu.
3405 3416
3406 3417 2004-11-18 Fernando Perez <fperez@colorado.edu>
3407 3418
3408 3419 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
3409 3420 EOFErrors and bail, to avoid infinite loops if a non-terminating
3410 3421 file is fed into ipython. Patch submitted in issue 19 by user,
3411 3422 many thanks.
3412 3423
3413 3424 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
3414 3425 autoquote/parens in continuation prompts, which can cause lots of
3415 3426 problems. Closes roundup issue 20.
3416 3427
3417 3428 2004-11-17 Fernando Perez <fperez@colorado.edu>
3418 3429
3419 3430 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
3420 3431 reported as debian bug #280505. I'm not sure my local changelog
3421 3432 entry has the proper debian format (Jack?).
3422 3433
3423 3434 2004-11-08 *** Released version 0.6.4
3424 3435
3425 3436 2004-11-08 Fernando Perez <fperez@colorado.edu>
3426 3437
3427 3438 * IPython/iplib.py (init_readline): Fix exit message for Windows
3428 3439 when readline is active. Thanks to a report by Eric Jones
3429 3440 <eric-AT-enthought.com>.
3430 3441
3431 3442 2004-11-07 Fernando Perez <fperez@colorado.edu>
3432 3443
3433 3444 * IPython/genutils.py (page): Add a trap for OSError exceptions,
3434 3445 sometimes seen by win2k/cygwin users.
3435 3446
3436 3447 2004-11-06 Fernando Perez <fperez@colorado.edu>
3437 3448
3438 3449 * IPython/iplib.py (interact): Change the handling of %Exit from
3439 3450 trying to propagate a SystemExit to an internal ipython flag.
3440 3451 This is less elegant than using Python's exception mechanism, but
3441 3452 I can't get that to work reliably with threads, so under -pylab
3442 3453 %Exit was hanging IPython. Cross-thread exception handling is
3443 3454 really a bitch. Thaks to a bug report by Stephen Walton
3444 3455 <stephen.walton-AT-csun.edu>.
3445 3456
3446 3457 2004-11-04 Fernando Perez <fperez@colorado.edu>
3447 3458
3448 3459 * IPython/iplib.py (raw_input_original): store a pointer to the
3449 3460 true raw_input to harden against code which can modify it
3450 3461 (wx.py.PyShell does this and would otherwise crash ipython).
3451 3462 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
3452 3463
3453 3464 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
3454 3465 Ctrl-C problem, which does not mess up the input line.
3455 3466
3456 3467 2004-11-03 Fernando Perez <fperez@colorado.edu>
3457 3468
3458 3469 * IPython/Release.py: Changed licensing to BSD, in all files.
3459 3470 (name): lowercase name for tarball/RPM release.
3460 3471
3461 3472 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
3462 3473 use throughout ipython.
3463 3474
3464 3475 * IPython/Magic.py (Magic._ofind): Switch to using the new
3465 3476 OInspect.getdoc() function.
3466 3477
3467 3478 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
3468 3479 of the line currently being canceled via Ctrl-C. It's extremely
3469 3480 ugly, but I don't know how to do it better (the problem is one of
3470 3481 handling cross-thread exceptions).
3471 3482
3472 3483 2004-10-28 Fernando Perez <fperez@colorado.edu>
3473 3484
3474 3485 * IPython/Shell.py (signal_handler): add signal handlers to trap
3475 3486 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
3476 3487 report by Francesc Alted.
3477 3488
3478 3489 2004-10-21 Fernando Perez <fperez@colorado.edu>
3479 3490
3480 3491 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
3481 3492 to % for pysh syntax extensions.
3482 3493
3483 3494 2004-10-09 Fernando Perez <fperez@colorado.edu>
3484 3495
3485 3496 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
3486 3497 arrays to print a more useful summary, without calling str(arr).
3487 3498 This avoids the problem of extremely lengthy computations which
3488 3499 occur if arr is large, and appear to the user as a system lockup
3489 3500 with 100% cpu activity. After a suggestion by Kristian Sandberg
3490 3501 <Kristian.Sandberg@colorado.edu>.
3491 3502 (Magic.__init__): fix bug in global magic escapes not being
3492 3503 correctly set.
3493 3504
3494 3505 2004-10-08 Fernando Perez <fperez@colorado.edu>
3495 3506
3496 3507 * IPython/Magic.py (__license__): change to absolute imports of
3497 3508 ipython's own internal packages, to start adapting to the absolute
3498 3509 import requirement of PEP-328.
3499 3510
3500 3511 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
3501 3512 files, and standardize author/license marks through the Release
3502 3513 module instead of having per/file stuff (except for files with
3503 3514 particular licenses, like the MIT/PSF-licensed codes).
3504 3515
3505 3516 * IPython/Debugger.py: remove dead code for python 2.1
3506 3517
3507 3518 2004-10-04 Fernando Perez <fperez@colorado.edu>
3508 3519
3509 3520 * IPython/iplib.py (ipmagic): New function for accessing magics
3510 3521 via a normal python function call.
3511 3522
3512 3523 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
3513 3524 from '@' to '%', to accomodate the new @decorator syntax of python
3514 3525 2.4.
3515 3526
3516 3527 2004-09-29 Fernando Perez <fperez@colorado.edu>
3517 3528
3518 3529 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
3519 3530 matplotlib.use to prevent running scripts which try to switch
3520 3531 interactive backends from within ipython. This will just crash
3521 3532 the python interpreter, so we can't allow it (but a detailed error
3522 3533 is given to the user).
3523 3534
3524 3535 2004-09-28 Fernando Perez <fperez@colorado.edu>
3525 3536
3526 3537 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
3527 3538 matplotlib-related fixes so that using @run with non-matplotlib
3528 3539 scripts doesn't pop up spurious plot windows. This requires
3529 3540 matplotlib >= 0.63, where I had to make some changes as well.
3530 3541
3531 3542 * IPython/ipmaker.py (make_IPython): update version requirement to
3532 3543 python 2.2.
3533 3544
3534 3545 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
3535 3546 banner arg for embedded customization.
3536 3547
3537 3548 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
3538 3549 explicit uses of __IP as the IPython's instance name. Now things
3539 3550 are properly handled via the shell.name value. The actual code
3540 3551 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
3541 3552 is much better than before. I'll clean things completely when the
3542 3553 magic stuff gets a real overhaul.
3543 3554
3544 3555 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
3545 3556 minor changes to debian dir.
3546 3557
3547 3558 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
3548 3559 pointer to the shell itself in the interactive namespace even when
3549 3560 a user-supplied dict is provided. This is needed for embedding
3550 3561 purposes (found by tests with Michel Sanner).
3551 3562
3552 3563 2004-09-27 Fernando Perez <fperez@colorado.edu>
3553 3564
3554 3565 * IPython/UserConfig/ipythonrc: remove []{} from
3555 3566 readline_remove_delims, so that things like [modname.<TAB> do
3556 3567 proper completion. This disables [].TAB, but that's a less common
3557 3568 case than module names in list comprehensions, for example.
3558 3569 Thanks to a report by Andrea Riciputi.
3559 3570
3560 3571 2004-09-09 Fernando Perez <fperez@colorado.edu>
3561 3572
3562 3573 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
3563 3574 blocking problems in win32 and osx. Fix by John.
3564 3575
3565 3576 2004-09-08 Fernando Perez <fperez@colorado.edu>
3566 3577
3567 3578 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
3568 3579 for Win32 and OSX. Fix by John Hunter.
3569 3580
3570 3581 2004-08-30 *** Released version 0.6.3
3571 3582
3572 3583 2004-08-30 Fernando Perez <fperez@colorado.edu>
3573 3584
3574 3585 * setup.py (isfile): Add manpages to list of dependent files to be
3575 3586 updated.
3576 3587
3577 3588 2004-08-27 Fernando Perez <fperez@colorado.edu>
3578 3589
3579 3590 * IPython/Shell.py (start): I've disabled -wthread and -gthread
3580 3591 for now. They don't really work with standalone WX/GTK code
3581 3592 (though matplotlib IS working fine with both of those backends).
3582 3593 This will neeed much more testing. I disabled most things with
3583 3594 comments, so turning it back on later should be pretty easy.
3584 3595
3585 3596 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
3586 3597 autocalling of expressions like r'foo', by modifying the line
3587 3598 split regexp. Closes
3588 3599 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
3589 3600 Riley <ipythonbugs-AT-sabi.net>.
3590 3601 (InteractiveShell.mainloop): honor --nobanner with banner
3591 3602 extensions.
3592 3603
3593 3604 * IPython/Shell.py: Significant refactoring of all classes, so
3594 3605 that we can really support ALL matplotlib backends and threading
3595 3606 models (John spotted a bug with Tk which required this). Now we
3596 3607 should support single-threaded, WX-threads and GTK-threads, both
3597 3608 for generic code and for matplotlib.
3598 3609
3599 3610 * IPython/ipmaker.py (__call__): Changed -mpthread option to
3600 3611 -pylab, to simplify things for users. Will also remove the pylab
3601 3612 profile, since now all of matplotlib configuration is directly
3602 3613 handled here. This also reduces startup time.
3603 3614
3604 3615 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
3605 3616 shell wasn't being correctly called. Also in IPShellWX.
3606 3617
3607 3618 * IPython/iplib.py (InteractiveShell.__init__): Added option to
3608 3619 fine-tune banner.
3609 3620
3610 3621 * IPython/numutils.py (spike): Deprecate these spike functions,
3611 3622 delete (long deprecated) gnuplot_exec handler.
3612 3623
3613 3624 2004-08-26 Fernando Perez <fperez@colorado.edu>
3614 3625
3615 3626 * ipython.1: Update for threading options, plus some others which
3616 3627 were missing.
3617 3628
3618 3629 * IPython/ipmaker.py (__call__): Added -wthread option for
3619 3630 wxpython thread handling. Make sure threading options are only
3620 3631 valid at the command line.
3621 3632
3622 3633 * scripts/ipython: moved shell selection into a factory function
3623 3634 in Shell.py, to keep the starter script to a minimum.
3624 3635
3625 3636 2004-08-25 Fernando Perez <fperez@colorado.edu>
3626 3637
3627 3638 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
3628 3639 John. Along with some recent changes he made to matplotlib, the
3629 3640 next versions of both systems should work very well together.
3630 3641
3631 3642 2004-08-24 Fernando Perez <fperez@colorado.edu>
3632 3643
3633 3644 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
3634 3645 tried to switch the profiling to using hotshot, but I'm getting
3635 3646 strange errors from prof.runctx() there. I may be misreading the
3636 3647 docs, but it looks weird. For now the profiling code will
3637 3648 continue to use the standard profiler.
3638 3649
3639 3650 2004-08-23 Fernando Perez <fperez@colorado.edu>
3640 3651
3641 3652 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
3642 3653 threaded shell, by John Hunter. It's not quite ready yet, but
3643 3654 close.
3644 3655
3645 3656 2004-08-22 Fernando Perez <fperez@colorado.edu>
3646 3657
3647 3658 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
3648 3659 in Magic and ultraTB.
3649 3660
3650 3661 * ipython.1: document threading options in manpage.
3651 3662
3652 3663 * scripts/ipython: Changed name of -thread option to -gthread,
3653 3664 since this is GTK specific. I want to leave the door open for a
3654 3665 -wthread option for WX, which will most likely be necessary. This
3655 3666 change affects usage and ipmaker as well.
3656 3667
3657 3668 * IPython/Shell.py (matplotlib_shell): Add a factory function to
3658 3669 handle the matplotlib shell issues. Code by John Hunter
3659 3670 <jdhunter-AT-nitace.bsd.uchicago.edu>.
3660 3671 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
3661 3672 broken (and disabled for end users) for now, but it puts the
3662 3673 infrastructure in place.
3663 3674
3664 3675 2004-08-21 Fernando Perez <fperez@colorado.edu>
3665 3676
3666 3677 * ipythonrc-pylab: Add matplotlib support.
3667 3678
3668 3679 * matplotlib_config.py: new files for matplotlib support, part of
3669 3680 the pylab profile.
3670 3681
3671 3682 * IPython/usage.py (__doc__): documented the threading options.
3672 3683
3673 3684 2004-08-20 Fernando Perez <fperez@colorado.edu>
3674 3685
3675 3686 * ipython: Modified the main calling routine to handle the -thread
3676 3687 and -mpthread options. This needs to be done as a top-level hack,
3677 3688 because it determines which class to instantiate for IPython
3678 3689 itself.
3679 3690
3680 3691 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
3681 3692 classes to support multithreaded GTK operation without blocking,
3682 3693 and matplotlib with all backends. This is a lot of still very
3683 3694 experimental code, and threads are tricky. So it may still have a
3684 3695 few rough edges... This code owes a lot to
3685 3696 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
3686 3697 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
3687 3698 to John Hunter for all the matplotlib work.
3688 3699
3689 3700 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
3690 3701 options for gtk thread and matplotlib support.
3691 3702
3692 3703 2004-08-16 Fernando Perez <fperez@colorado.edu>
3693 3704
3694 3705 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
3695 3706 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
3696 3707 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
3697 3708
3698 3709 2004-08-11 Fernando Perez <fperez@colorado.edu>
3699 3710
3700 3711 * setup.py (isfile): Fix build so documentation gets updated for
3701 3712 rpms (it was only done for .tgz builds).
3702 3713
3703 3714 2004-08-10 Fernando Perez <fperez@colorado.edu>
3704 3715
3705 3716 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
3706 3717
3707 3718 * iplib.py : Silence syntax error exceptions in tab-completion.
3708 3719
3709 3720 2004-08-05 Fernando Perez <fperez@colorado.edu>
3710 3721
3711 3722 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
3712 3723 'color off' mark for continuation prompts. This was causing long
3713 3724 continuation lines to mis-wrap.
3714 3725
3715 3726 2004-08-01 Fernando Perez <fperez@colorado.edu>
3716 3727
3717 3728 * IPython/ipmaker.py (make_IPython): Allow the shell class used
3718 3729 for building ipython to be a parameter. All this is necessary
3719 3730 right now to have a multithreaded version, but this insane
3720 3731 non-design will be cleaned up soon. For now, it's a hack that
3721 3732 works.
3722 3733
3723 3734 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
3724 3735 args in various places. No bugs so far, but it's a dangerous
3725 3736 practice.
3726 3737
3727 3738 2004-07-31 Fernando Perez <fperez@colorado.edu>
3728 3739
3729 3740 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
3730 3741 fix completion of files with dots in their names under most
3731 3742 profiles (pysh was OK because the completion order is different).
3732 3743
3733 3744 2004-07-27 Fernando Perez <fperez@colorado.edu>
3734 3745
3735 3746 * IPython/iplib.py (InteractiveShell.__init__): build dict of
3736 3747 keywords manually, b/c the one in keyword.py was removed in python
3737 3748 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
3738 3749 This is NOT a bug under python 2.3 and earlier.
3739 3750
3740 3751 2004-07-26 Fernando Perez <fperez@colorado.edu>
3741 3752
3742 3753 * IPython/ultraTB.py (VerboseTB.text): Add another
3743 3754 linecache.checkcache() call to try to prevent inspect.py from
3744 3755 crashing under python 2.3. I think this fixes
3745 3756 http://www.scipy.net/roundup/ipython/issue17.
3746 3757
3747 3758 2004-07-26 *** Released version 0.6.2
3748 3759
3749 3760 2004-07-26 Fernando Perez <fperez@colorado.edu>
3750 3761
3751 3762 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
3752 3763 fail for any number.
3753 3764 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
3754 3765 empty bookmarks.
3755 3766
3756 3767 2004-07-26 *** Released version 0.6.1
3757 3768
3758 3769 2004-07-26 Fernando Perez <fperez@colorado.edu>
3759 3770
3760 3771 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
3761 3772
3762 3773 * IPython/iplib.py (protect_filename): Applied Ville's patch for
3763 3774 escaping '()[]{}' in filenames.
3764 3775
3765 3776 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
3766 3777 Python 2.2 users who lack a proper shlex.split.
3767 3778
3768 3779 2004-07-19 Fernando Perez <fperez@colorado.edu>
3769 3780
3770 3781 * IPython/iplib.py (InteractiveShell.init_readline): Add support
3771 3782 for reading readline's init file. I follow the normal chain:
3772 3783 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
3773 3784 report by Mike Heeter. This closes
3774 3785 http://www.scipy.net/roundup/ipython/issue16.
3775 3786
3776 3787 2004-07-18 Fernando Perez <fperez@colorado.edu>
3777 3788
3778 3789 * IPython/iplib.py (__init__): Add better handling of '\' under
3779 3790 Win32 for filenames. After a patch by Ville.
3780 3791
3781 3792 2004-07-17 Fernando Perez <fperez@colorado.edu>
3782 3793
3783 3794 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3784 3795 autocalling would be triggered for 'foo is bar' if foo is
3785 3796 callable. I also cleaned up the autocall detection code to use a
3786 3797 regexp, which is faster. Bug reported by Alexander Schmolck.
3787 3798
3788 3799 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
3789 3800 '?' in them would confuse the help system. Reported by Alex
3790 3801 Schmolck.
3791 3802
3792 3803 2004-07-16 Fernando Perez <fperez@colorado.edu>
3793 3804
3794 3805 * IPython/GnuplotInteractive.py (__all__): added plot2.
3795 3806
3796 3807 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
3797 3808 plotting dictionaries, lists or tuples of 1d arrays.
3798 3809
3799 3810 * IPython/Magic.py (Magic.magic_hist): small clenaups and
3800 3811 optimizations.
3801 3812
3802 3813 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
3803 3814 the information which was there from Janko's original IPP code:
3804 3815
3805 3816 03.05.99 20:53 porto.ifm.uni-kiel.de
3806 3817 --Started changelog.
3807 3818 --make clear do what it say it does
3808 3819 --added pretty output of lines from inputcache
3809 3820 --Made Logger a mixin class, simplifies handling of switches
3810 3821 --Added own completer class. .string<TAB> expands to last history
3811 3822 line which starts with string. The new expansion is also present
3812 3823 with Ctrl-r from the readline library. But this shows, who this
3813 3824 can be done for other cases.
3814 3825 --Added convention that all shell functions should accept a
3815 3826 parameter_string This opens the door for different behaviour for
3816 3827 each function. @cd is a good example of this.
3817 3828
3818 3829 04.05.99 12:12 porto.ifm.uni-kiel.de
3819 3830 --added logfile rotation
3820 3831 --added new mainloop method which freezes first the namespace
3821 3832
3822 3833 07.05.99 21:24 porto.ifm.uni-kiel.de
3823 3834 --added the docreader classes. Now there is a help system.
3824 3835 -This is only a first try. Currently it's not easy to put new
3825 3836 stuff in the indices. But this is the way to go. Info would be
3826 3837 better, but HTML is every where and not everybody has an info
3827 3838 system installed and it's not so easy to change html-docs to info.
3828 3839 --added global logfile option
3829 3840 --there is now a hook for object inspection method pinfo needs to
3830 3841 be provided for this. Can be reached by two '??'.
3831 3842
3832 3843 08.05.99 20:51 porto.ifm.uni-kiel.de
3833 3844 --added a README
3834 3845 --bug in rc file. Something has changed so functions in the rc
3835 3846 file need to reference the shell and not self. Not clear if it's a
3836 3847 bug or feature.
3837 3848 --changed rc file for new behavior
3838 3849
3839 3850 2004-07-15 Fernando Perez <fperez@colorado.edu>
3840 3851
3841 3852 * IPython/Logger.py (Logger.log): fixed recent bug where the input
3842 3853 cache was falling out of sync in bizarre manners when multi-line
3843 3854 input was present. Minor optimizations and cleanup.
3844 3855
3845 3856 (Logger): Remove old Changelog info for cleanup. This is the
3846 3857 information which was there from Janko's original code:
3847 3858
3848 3859 Changes to Logger: - made the default log filename a parameter
3849 3860
3850 3861 - put a check for lines beginning with !@? in log(). Needed
3851 3862 (even if the handlers properly log their lines) for mid-session
3852 3863 logging activation to work properly. Without this, lines logged
3853 3864 in mid session, which get read from the cache, would end up
3854 3865 'bare' (with !@? in the open) in the log. Now they are caught
3855 3866 and prepended with a #.
3856 3867
3857 3868 * IPython/iplib.py (InteractiveShell.init_readline): added check
3858 3869 in case MagicCompleter fails to be defined, so we don't crash.
3859 3870
3860 3871 2004-07-13 Fernando Perez <fperez@colorado.edu>
3861 3872
3862 3873 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
3863 3874 of EPS if the requested filename ends in '.eps'.
3864 3875
3865 3876 2004-07-04 Fernando Perez <fperez@colorado.edu>
3866 3877
3867 3878 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
3868 3879 escaping of quotes when calling the shell.
3869 3880
3870 3881 2004-07-02 Fernando Perez <fperez@colorado.edu>
3871 3882
3872 3883 * IPython/Prompts.py (CachedOutput.update): Fix problem with
3873 3884 gettext not working because we were clobbering '_'. Fixes
3874 3885 http://www.scipy.net/roundup/ipython/issue6.
3875 3886
3876 3887 2004-07-01 Fernando Perez <fperez@colorado.edu>
3877 3888
3878 3889 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
3879 3890 into @cd. Patch by Ville.
3880 3891
3881 3892 * IPython/iplib.py (InteractiveShell.post_config_initialization):
3882 3893 new function to store things after ipmaker runs. Patch by Ville.
3883 3894 Eventually this will go away once ipmaker is removed and the class
3884 3895 gets cleaned up, but for now it's ok. Key functionality here is
3885 3896 the addition of the persistent storage mechanism, a dict for
3886 3897 keeping data across sessions (for now just bookmarks, but more can
3887 3898 be implemented later).
3888 3899
3889 3900 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
3890 3901 persistent across sections. Patch by Ville, I modified it
3891 3902 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
3892 3903 added a '-l' option to list all bookmarks.
3893 3904
3894 3905 * IPython/iplib.py (InteractiveShell.atexit_operations): new
3895 3906 center for cleanup. Registered with atexit.register(). I moved
3896 3907 here the old exit_cleanup(). After a patch by Ville.
3897 3908
3898 3909 * IPython/Magic.py (get_py_filename): added '~' to the accepted
3899 3910 characters in the hacked shlex_split for python 2.2.
3900 3911
3901 3912 * IPython/iplib.py (file_matches): more fixes to filenames with
3902 3913 whitespace in them. It's not perfect, but limitations in python's
3903 3914 readline make it impossible to go further.
3904 3915
3905 3916 2004-06-29 Fernando Perez <fperez@colorado.edu>
3906 3917
3907 3918 * IPython/iplib.py (file_matches): escape whitespace correctly in
3908 3919 filename completions. Bug reported by Ville.
3909 3920
3910 3921 2004-06-28 Fernando Perez <fperez@colorado.edu>
3911 3922
3912 3923 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
3913 3924 the history file will be called 'history-PROFNAME' (or just
3914 3925 'history' if no profile is loaded). I was getting annoyed at
3915 3926 getting my Numerical work history clobbered by pysh sessions.
3916 3927
3917 3928 * IPython/iplib.py (InteractiveShell.__init__): Internal
3918 3929 getoutputerror() function so that we can honor the system_verbose
3919 3930 flag for _all_ system calls. I also added escaping of #
3920 3931 characters here to avoid confusing Itpl.
3921 3932
3922 3933 * IPython/Magic.py (shlex_split): removed call to shell in
3923 3934 parse_options and replaced it with shlex.split(). The annoying
3924 3935 part was that in Python 2.2, shlex.split() doesn't exist, so I had
3925 3936 to backport it from 2.3, with several frail hacks (the shlex
3926 3937 module is rather limited in 2.2). Thanks to a suggestion by Ville
3927 3938 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
3928 3939 problem.
3929 3940
3930 3941 (Magic.magic_system_verbose): new toggle to print the actual
3931 3942 system calls made by ipython. Mainly for debugging purposes.
3932 3943
3933 3944 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
3934 3945 doesn't support persistence. Reported (and fix suggested) by
3935 3946 Travis Caldwell <travis_caldwell2000@yahoo.com>.
3936 3947
3937 3948 2004-06-26 Fernando Perez <fperez@colorado.edu>
3938 3949
3939 3950 * IPython/Logger.py (Logger.log): fix to handle correctly empty
3940 3951 continue prompts.
3941 3952
3942 3953 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
3943 3954 function (basically a big docstring) and a few more things here to
3944 3955 speedup startup. pysh.py is now very lightweight. We want because
3945 3956 it gets execfile'd, while InterpreterExec gets imported, so
3946 3957 byte-compilation saves time.
3947 3958
3948 3959 2004-06-25 Fernando Perez <fperez@colorado.edu>
3949 3960
3950 3961 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
3951 3962 -NUM', which was recently broken.
3952 3963
3953 3964 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
3954 3965 in multi-line input (but not !!, which doesn't make sense there).
3955 3966
3956 3967 * IPython/UserConfig/ipythonrc: made autoindent on by default.
3957 3968 It's just too useful, and people can turn it off in the less
3958 3969 common cases where it's a problem.
3959 3970
3960 3971 2004-06-24 Fernando Perez <fperez@colorado.edu>
3961 3972
3962 3973 * IPython/iplib.py (InteractiveShell._prefilter): big change -
3963 3974 special syntaxes (like alias calling) is now allied in multi-line
3964 3975 input. This is still _very_ experimental, but it's necessary for
3965 3976 efficient shell usage combining python looping syntax with system
3966 3977 calls. For now it's restricted to aliases, I don't think it
3967 3978 really even makes sense to have this for magics.
3968 3979
3969 3980 2004-06-23 Fernando Perez <fperez@colorado.edu>
3970 3981
3971 3982 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
3972 3983 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
3973 3984
3974 3985 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
3975 3986 extensions under Windows (after code sent by Gary Bishop). The
3976 3987 extensions considered 'executable' are stored in IPython's rc
3977 3988 structure as win_exec_ext.
3978 3989
3979 3990 * IPython/genutils.py (shell): new function, like system() but
3980 3991 without return value. Very useful for interactive shell work.
3981 3992
3982 3993 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
3983 3994 delete aliases.
3984 3995
3985 3996 * IPython/iplib.py (InteractiveShell.alias_table_update): make
3986 3997 sure that the alias table doesn't contain python keywords.
3987 3998
3988 3999 2004-06-21 Fernando Perez <fperez@colorado.edu>
3989 4000
3990 4001 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
3991 4002 non-existent items are found in $PATH. Reported by Thorsten.
3992 4003
3993 4004 2004-06-20 Fernando Perez <fperez@colorado.edu>
3994 4005
3995 4006 * IPython/iplib.py (complete): modified the completer so that the
3996 4007 order of priorities can be easily changed at runtime.
3997 4008
3998 4009 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
3999 4010 Modified to auto-execute all lines beginning with '~', '/' or '.'.
4000 4011
4001 4012 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
4002 4013 expand Python variables prepended with $ in all system calls. The
4003 4014 same was done to InteractiveShell.handle_shell_escape. Now all
4004 4015 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
4005 4016 expansion of python variables and expressions according to the
4006 4017 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
4007 4018
4008 4019 Though PEP-215 has been rejected, a similar (but simpler) one
4009 4020 seems like it will go into Python 2.4, PEP-292 -
4010 4021 http://www.python.org/peps/pep-0292.html.
4011 4022
4012 4023 I'll keep the full syntax of PEP-215, since IPython has since the
4013 4024 start used Ka-Ping Yee's reference implementation discussed there
4014 4025 (Itpl), and I actually like the powerful semantics it offers.
4015 4026
4016 4027 In order to access normal shell variables, the $ has to be escaped
4017 4028 via an extra $. For example:
4018 4029
4019 4030 In [7]: PATH='a python variable'
4020 4031
4021 4032 In [8]: !echo $PATH
4022 4033 a python variable
4023 4034
4024 4035 In [9]: !echo $$PATH
4025 4036 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
4026 4037
4027 4038 (Magic.parse_options): escape $ so the shell doesn't evaluate
4028 4039 things prematurely.
4029 4040
4030 4041 * IPython/iplib.py (InteractiveShell.call_alias): added the
4031 4042 ability for aliases to expand python variables via $.
4032 4043
4033 4044 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
4034 4045 system, now there's a @rehash/@rehashx pair of magics. These work
4035 4046 like the csh rehash command, and can be invoked at any time. They
4036 4047 build a table of aliases to everything in the user's $PATH
4037 4048 (@rehash uses everything, @rehashx is slower but only adds
4038 4049 executable files). With this, the pysh.py-based shell profile can
4039 4050 now simply call rehash upon startup, and full access to all
4040 4051 programs in the user's path is obtained.
4041 4052
4042 4053 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
4043 4054 functionality is now fully in place. I removed the old dynamic
4044 4055 code generation based approach, in favor of a much lighter one
4045 4056 based on a simple dict. The advantage is that this allows me to
4046 4057 now have thousands of aliases with negligible cost (unthinkable
4047 4058 with the old system).
4048 4059
4049 4060 2004-06-19 Fernando Perez <fperez@colorado.edu>
4050 4061
4051 4062 * IPython/iplib.py (__init__): extended MagicCompleter class to
4052 4063 also complete (last in priority) on user aliases.
4053 4064
4054 4065 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
4055 4066 call to eval.
4056 4067 (ItplNS.__init__): Added a new class which functions like Itpl,
4057 4068 but allows configuring the namespace for the evaluation to occur
4058 4069 in.
4059 4070
4060 4071 2004-06-18 Fernando Perez <fperez@colorado.edu>
4061 4072
4062 4073 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
4063 4074 better message when 'exit' or 'quit' are typed (a common newbie
4064 4075 confusion).
4065 4076
4066 4077 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
4067 4078 check for Windows users.
4068 4079
4069 4080 * IPython/iplib.py (InteractiveShell.user_setup): removed
4070 4081 disabling of colors for Windows. I'll test at runtime and issue a
4071 4082 warning if Gary's readline isn't found, as to nudge users to
4072 4083 download it.
4073 4084
4074 4085 2004-06-16 Fernando Perez <fperez@colorado.edu>
4075 4086
4076 4087 * IPython/genutils.py (Stream.__init__): changed to print errors
4077 4088 to sys.stderr. I had a circular dependency here. Now it's
4078 4089 possible to run ipython as IDLE's shell (consider this pre-alpha,
4079 4090 since true stdout things end up in the starting terminal instead
4080 4091 of IDLE's out).
4081 4092
4082 4093 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
4083 4094 users who haven't # updated their prompt_in2 definitions. Remove
4084 4095 eventually.
4085 4096 (multiple_replace): added credit to original ASPN recipe.
4086 4097
4087 4098 2004-06-15 Fernando Perez <fperez@colorado.edu>
4088 4099
4089 4100 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
4090 4101 list of auto-defined aliases.
4091 4102
4092 4103 2004-06-13 Fernando Perez <fperez@colorado.edu>
4093 4104
4094 4105 * setup.py (scriptfiles): Don't trigger win_post_install unless an
4095 4106 install was really requested (so setup.py can be used for other
4096 4107 things under Windows).
4097 4108
4098 4109 2004-06-10 Fernando Perez <fperez@colorado.edu>
4099 4110
4100 4111 * IPython/Logger.py (Logger.create_log): Manually remove any old
4101 4112 backup, since os.remove may fail under Windows. Fixes bug
4102 4113 reported by Thorsten.
4103 4114
4104 4115 2004-06-09 Fernando Perez <fperez@colorado.edu>
4105 4116
4106 4117 * examples/example-embed.py: fixed all references to %n (replaced
4107 4118 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
4108 4119 for all examples and the manual as well.
4109 4120
4110 4121 2004-06-08 Fernando Perez <fperez@colorado.edu>
4111 4122
4112 4123 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
4113 4124 alignment and color management. All 3 prompt subsystems now
4114 4125 inherit from BasePrompt.
4115 4126
4116 4127 * tools/release: updates for windows installer build and tag rpms
4117 4128 with python version (since paths are fixed).
4118 4129
4119 4130 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
4120 4131 which will become eventually obsolete. Also fixed the default
4121 4132 prompt_in2 to use \D, so at least new users start with the correct
4122 4133 defaults.
4123 4134 WARNING: Users with existing ipythonrc files will need to apply
4124 4135 this fix manually!
4125 4136
4126 4137 * setup.py: make windows installer (.exe). This is finally the
4127 4138 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
4128 4139 which I hadn't included because it required Python 2.3 (or recent
4129 4140 distutils).
4130 4141
4131 4142 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
4132 4143 usage of new '\D' escape.
4133 4144
4134 4145 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
4135 4146 lacks os.getuid())
4136 4147 (CachedOutput.set_colors): Added the ability to turn coloring
4137 4148 on/off with @colors even for manually defined prompt colors. It
4138 4149 uses a nasty global, but it works safely and via the generic color
4139 4150 handling mechanism.
4140 4151 (Prompt2.__init__): Introduced new escape '\D' for continuation
4141 4152 prompts. It represents the counter ('\#') as dots.
4142 4153 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
4143 4154 need to update their ipythonrc files and replace '%n' with '\D' in
4144 4155 their prompt_in2 settings everywhere. Sorry, but there's
4145 4156 otherwise no clean way to get all prompts to properly align. The
4146 4157 ipythonrc shipped with IPython has been updated.
4147 4158
4148 4159 2004-06-07 Fernando Perez <fperez@colorado.edu>
4149 4160
4150 4161 * setup.py (isfile): Pass local_icons option to latex2html, so the
4151 4162 resulting HTML file is self-contained. Thanks to
4152 4163 dryice-AT-liu.com.cn for the tip.
4153 4164
4154 4165 * pysh.py: I created a new profile 'shell', which implements a
4155 4166 _rudimentary_ IPython-based shell. This is in NO WAY a realy
4156 4167 system shell, nor will it become one anytime soon. It's mainly
4157 4168 meant to illustrate the use of the new flexible bash-like prompts.
4158 4169 I guess it could be used by hardy souls for true shell management,
4159 4170 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
4160 4171 profile. This uses the InterpreterExec extension provided by
4161 4172 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
4162 4173
4163 4174 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
4164 4175 auto-align itself with the length of the previous input prompt
4165 4176 (taking into account the invisible color escapes).
4166 4177 (CachedOutput.__init__): Large restructuring of this class. Now
4167 4178 all three prompts (primary1, primary2, output) are proper objects,
4168 4179 managed by the 'parent' CachedOutput class. The code is still a
4169 4180 bit hackish (all prompts share state via a pointer to the cache),
4170 4181 but it's overall far cleaner than before.
4171 4182
4172 4183 * IPython/genutils.py (getoutputerror): modified to add verbose,
4173 4184 debug and header options. This makes the interface of all getout*
4174 4185 functions uniform.
4175 4186 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
4176 4187
4177 4188 * IPython/Magic.py (Magic.default_option): added a function to
4178 4189 allow registering default options for any magic command. This
4179 4190 makes it easy to have profiles which customize the magics globally
4180 4191 for a certain use. The values set through this function are
4181 4192 picked up by the parse_options() method, which all magics should
4182 4193 use to parse their options.
4183 4194
4184 4195 * IPython/genutils.py (warn): modified the warnings framework to
4185 4196 use the Term I/O class. I'm trying to slowly unify all of
4186 4197 IPython's I/O operations to pass through Term.
4187 4198
4188 4199 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
4189 4200 the secondary prompt to correctly match the length of the primary
4190 4201 one for any prompt. Now multi-line code will properly line up
4191 4202 even for path dependent prompts, such as the new ones available
4192 4203 via the prompt_specials.
4193 4204
4194 4205 2004-06-06 Fernando Perez <fperez@colorado.edu>
4195 4206
4196 4207 * IPython/Prompts.py (prompt_specials): Added the ability to have
4197 4208 bash-like special sequences in the prompts, which get
4198 4209 automatically expanded. Things like hostname, current working
4199 4210 directory and username are implemented already, but it's easy to
4200 4211 add more in the future. Thanks to a patch by W.J. van der Laan
4201 4212 <gnufnork-AT-hetdigitalegat.nl>
4202 4213 (prompt_specials): Added color support for prompt strings, so
4203 4214 users can define arbitrary color setups for their prompts.
4204 4215
4205 4216 2004-06-05 Fernando Perez <fperez@colorado.edu>
4206 4217
4207 4218 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
4208 4219 code to load Gary Bishop's readline and configure it
4209 4220 automatically. Thanks to Gary for help on this.
4210 4221
4211 4222 2004-06-01 Fernando Perez <fperez@colorado.edu>
4212 4223
4213 4224 * IPython/Logger.py (Logger.create_log): fix bug for logging
4214 4225 with no filename (previous fix was incomplete).
4215 4226
4216 4227 2004-05-25 Fernando Perez <fperez@colorado.edu>
4217 4228
4218 4229 * IPython/Magic.py (Magic.parse_options): fix bug where naked
4219 4230 parens would get passed to the shell.
4220 4231
4221 4232 2004-05-20 Fernando Perez <fperez@colorado.edu>
4222 4233
4223 4234 * IPython/Magic.py (Magic.magic_prun): changed default profile
4224 4235 sort order to 'time' (the more common profiling need).
4225 4236
4226 4237 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
4227 4238 so that source code shown is guaranteed in sync with the file on
4228 4239 disk (also changed in psource). Similar fix to the one for
4229 4240 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
4230 4241 <yann.ledu-AT-noos.fr>.
4231 4242
4232 4243 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
4233 4244 with a single option would not be correctly parsed. Closes
4234 4245 http://www.scipy.net/roundup/ipython/issue14. This bug had been
4235 4246 introduced in 0.6.0 (on 2004-05-06).
4236 4247
4237 4248 2004-05-13 *** Released version 0.6.0
4238 4249
4239 4250 2004-05-13 Fernando Perez <fperez@colorado.edu>
4240 4251
4241 4252 * debian/: Added debian/ directory to CVS, so that debian support
4242 4253 is publicly accessible. The debian package is maintained by Jack
4243 4254 Moffit <jack-AT-xiph.org>.
4244 4255
4245 4256 * Documentation: included the notes about an ipython-based system
4246 4257 shell (the hypothetical 'pysh') into the new_design.pdf document,
4247 4258 so that these ideas get distributed to users along with the
4248 4259 official documentation.
4249 4260
4250 4261 2004-05-10 Fernando Perez <fperez@colorado.edu>
4251 4262
4252 4263 * IPython/Logger.py (Logger.create_log): fix recently introduced
4253 4264 bug (misindented line) where logstart would fail when not given an
4254 4265 explicit filename.
4255 4266
4256 4267 2004-05-09 Fernando Perez <fperez@colorado.edu>
4257 4268
4258 4269 * IPython/Magic.py (Magic.parse_options): skip system call when
4259 4270 there are no options to look for. Faster, cleaner for the common
4260 4271 case.
4261 4272
4262 4273 * Documentation: many updates to the manual: describing Windows
4263 4274 support better, Gnuplot updates, credits, misc small stuff. Also
4264 4275 updated the new_design doc a bit.
4265 4276
4266 4277 2004-05-06 *** Released version 0.6.0.rc1
4267 4278
4268 4279 2004-05-06 Fernando Perez <fperez@colorado.edu>
4269 4280
4270 4281 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
4271 4282 operations to use the vastly more efficient list/''.join() method.
4272 4283 (FormattedTB.text): Fix
4273 4284 http://www.scipy.net/roundup/ipython/issue12 - exception source
4274 4285 extract not updated after reload. Thanks to Mike Salib
4275 4286 <msalib-AT-mit.edu> for pinning the source of the problem.
4276 4287 Fortunately, the solution works inside ipython and doesn't require
4277 4288 any changes to python proper.
4278 4289
4279 4290 * IPython/Magic.py (Magic.parse_options): Improved to process the
4280 4291 argument list as a true shell would (by actually using the
4281 4292 underlying system shell). This way, all @magics automatically get
4282 4293 shell expansion for variables. Thanks to a comment by Alex
4283 4294 Schmolck.
4284 4295
4285 4296 2004-04-04 Fernando Perez <fperez@colorado.edu>
4286 4297
4287 4298 * IPython/iplib.py (InteractiveShell.interact): Added a special
4288 4299 trap for a debugger quit exception, which is basically impossible
4289 4300 to handle by normal mechanisms, given what pdb does to the stack.
4290 4301 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
4291 4302
4292 4303 2004-04-03 Fernando Perez <fperez@colorado.edu>
4293 4304
4294 4305 * IPython/genutils.py (Term): Standardized the names of the Term
4295 4306 class streams to cin/cout/cerr, following C++ naming conventions
4296 4307 (I can't use in/out/err because 'in' is not a valid attribute
4297 4308 name).
4298 4309
4299 4310 * IPython/iplib.py (InteractiveShell.interact): don't increment
4300 4311 the prompt if there's no user input. By Daniel 'Dang' Griffith
4301 4312 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
4302 4313 Francois Pinard.
4303 4314
4304 4315 2004-04-02 Fernando Perez <fperez@colorado.edu>
4305 4316
4306 4317 * IPython/genutils.py (Stream.__init__): Modified to survive at
4307 4318 least importing in contexts where stdin/out/err aren't true file
4308 4319 objects, such as PyCrust (they lack fileno() and mode). However,
4309 4320 the recovery facilities which rely on these things existing will
4310 4321 not work.
4311 4322
4312 4323 2004-04-01 Fernando Perez <fperez@colorado.edu>
4313 4324
4314 4325 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
4315 4326 use the new getoutputerror() function, so it properly
4316 4327 distinguishes stdout/err.
4317 4328
4318 4329 * IPython/genutils.py (getoutputerror): added a function to
4319 4330 capture separately the standard output and error of a command.
4320 4331 After a comment from dang on the mailing lists. This code is
4321 4332 basically a modified version of commands.getstatusoutput(), from
4322 4333 the standard library.
4323 4334
4324 4335 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
4325 4336 '!!' as a special syntax (shorthand) to access @sx.
4326 4337
4327 4338 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
4328 4339 command and return its output as a list split on '\n'.
4329 4340
4330 4341 2004-03-31 Fernando Perez <fperez@colorado.edu>
4331 4342
4332 4343 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
4333 4344 method to dictionaries used as FakeModule instances if they lack
4334 4345 it. At least pydoc in python2.3 breaks for runtime-defined
4335 4346 functions without this hack. At some point I need to _really_
4336 4347 understand what FakeModule is doing, because it's a gross hack.
4337 4348 But it solves Arnd's problem for now...
4338 4349
4339 4350 2004-02-27 Fernando Perez <fperez@colorado.edu>
4340 4351
4341 4352 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
4342 4353 mode would behave erratically. Also increased the number of
4343 4354 possible logs in rotate mod to 999. Thanks to Rod Holland
4344 4355 <rhh@StructureLABS.com> for the report and fixes.
4345 4356
4346 4357 2004-02-26 Fernando Perez <fperez@colorado.edu>
4347 4358
4348 4359 * IPython/genutils.py (page): Check that the curses module really
4349 4360 has the initscr attribute before trying to use it. For some
4350 4361 reason, the Solaris curses module is missing this. I think this
4351 4362 should be considered a Solaris python bug, but I'm not sure.
4352 4363
4353 4364 2004-01-17 Fernando Perez <fperez@colorado.edu>
4354 4365
4355 4366 * IPython/genutils.py (Stream.__init__): Changes to try to make
4356 4367 ipython robust against stdin/out/err being closed by the user.
4357 4368 This is 'user error' (and blocks a normal python session, at least
4358 4369 the stdout case). However, Ipython should be able to survive such
4359 4370 instances of abuse as gracefully as possible. To simplify the
4360 4371 coding and maintain compatibility with Gary Bishop's Term
4361 4372 contributions, I've made use of classmethods for this. I think
4362 4373 this introduces a dependency on python 2.2.
4363 4374
4364 4375 2004-01-13 Fernando Perez <fperez@colorado.edu>
4365 4376
4366 4377 * IPython/numutils.py (exp_safe): simplified the code a bit and
4367 4378 removed the need for importing the kinds module altogether.
4368 4379
4369 4380 2004-01-06 Fernando Perez <fperez@colorado.edu>
4370 4381
4371 4382 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
4372 4383 a magic function instead, after some community feedback. No
4373 4384 special syntax will exist for it, but its name is deliberately
4374 4385 very short.
4375 4386
4376 4387 2003-12-20 Fernando Perez <fperez@colorado.edu>
4377 4388
4378 4389 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
4379 4390 new functionality, to automagically assign the result of a shell
4380 4391 command to a variable. I'll solicit some community feedback on
4381 4392 this before making it permanent.
4382 4393
4383 4394 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
4384 4395 requested about callables for which inspect couldn't obtain a
4385 4396 proper argspec. Thanks to a crash report sent by Etienne
4386 4397 Posthumus <etienne-AT-apple01.cs.vu.nl>.
4387 4398
4388 4399 2003-12-09 Fernando Perez <fperez@colorado.edu>
4389 4400
4390 4401 * IPython/genutils.py (page): patch for the pager to work across
4391 4402 various versions of Windows. By Gary Bishop.
4392 4403
4393 4404 2003-12-04 Fernando Perez <fperez@colorado.edu>
4394 4405
4395 4406 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
4396 4407 Gnuplot.py version 1.7, whose internal names changed quite a bit.
4397 4408 While I tested this and it looks ok, there may still be corner
4398 4409 cases I've missed.
4399 4410
4400 4411 2003-12-01 Fernando Perez <fperez@colorado.edu>
4401 4412
4402 4413 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
4403 4414 where a line like 'p,q=1,2' would fail because the automagic
4404 4415 system would be triggered for @p.
4405 4416
4406 4417 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
4407 4418 cleanups, code unmodified.
4408 4419
4409 4420 * IPython/genutils.py (Term): added a class for IPython to handle
4410 4421 output. In most cases it will just be a proxy for stdout/err, but
4411 4422 having this allows modifications to be made for some platforms,
4412 4423 such as handling color escapes under Windows. All of this code
4413 4424 was contributed by Gary Bishop, with minor modifications by me.
4414 4425 The actual changes affect many files.
4415 4426
4416 4427 2003-11-30 Fernando Perez <fperez@colorado.edu>
4417 4428
4418 4429 * IPython/iplib.py (file_matches): new completion code, courtesy
4419 4430 of Jeff Collins. This enables filename completion again under
4420 4431 python 2.3, which disabled it at the C level.
4421 4432
4422 4433 2003-11-11 Fernando Perez <fperez@colorado.edu>
4423 4434
4424 4435 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
4425 4436 for Numeric.array(map(...)), but often convenient.
4426 4437
4427 4438 2003-11-05 Fernando Perez <fperez@colorado.edu>
4428 4439
4429 4440 * IPython/numutils.py (frange): Changed a call from int() to
4430 4441 int(round()) to prevent a problem reported with arange() in the
4431 4442 numpy list.
4432 4443
4433 4444 2003-10-06 Fernando Perez <fperez@colorado.edu>
4434 4445
4435 4446 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
4436 4447 prevent crashes if sys lacks an argv attribute (it happens with
4437 4448 embedded interpreters which build a bare-bones sys module).
4438 4449 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
4439 4450
4440 4451 2003-09-24 Fernando Perez <fperez@colorado.edu>
4441 4452
4442 4453 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
4443 4454 to protect against poorly written user objects where __getattr__
4444 4455 raises exceptions other than AttributeError. Thanks to a bug
4445 4456 report by Oliver Sander <osander-AT-gmx.de>.
4446 4457
4447 4458 * IPython/FakeModule.py (FakeModule.__repr__): this method was
4448 4459 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
4449 4460
4450 4461 2003-09-09 Fernando Perez <fperez@colorado.edu>
4451 4462
4452 4463 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
4453 4464 unpacking a list whith a callable as first element would
4454 4465 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
4455 4466 Collins.
4456 4467
4457 4468 2003-08-25 *** Released version 0.5.0
4458 4469
4459 4470 2003-08-22 Fernando Perez <fperez@colorado.edu>
4460 4471
4461 4472 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
4462 4473 improperly defined user exceptions. Thanks to feedback from Mark
4463 4474 Russell <mrussell-AT-verio.net>.
4464 4475
4465 4476 2003-08-20 Fernando Perez <fperez@colorado.edu>
4466 4477
4467 4478 * IPython/OInspect.py (Inspector.pinfo): changed String Form
4468 4479 printing so that it would print multi-line string forms starting
4469 4480 with a new line. This way the formatting is better respected for
4470 4481 objects which work hard to make nice string forms.
4471 4482
4472 4483 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
4473 4484 autocall would overtake data access for objects with both
4474 4485 __getitem__ and __call__.
4475 4486
4476 4487 2003-08-19 *** Released version 0.5.0-rc1
4477 4488
4478 4489 2003-08-19 Fernando Perez <fperez@colorado.edu>
4479 4490
4480 4491 * IPython/deep_reload.py (load_tail): single tiny change here
4481 4492 seems to fix the long-standing bug of dreload() failing to work
4482 4493 for dotted names. But this module is pretty tricky, so I may have
4483 4494 missed some subtlety. Needs more testing!.
4484 4495
4485 4496 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
4486 4497 exceptions which have badly implemented __str__ methods.
4487 4498 (VerboseTB.text): harden against inspect.getinnerframes crashing,
4488 4499 which I've been getting reports about from Python 2.3 users. I
4489 4500 wish I had a simple test case to reproduce the problem, so I could
4490 4501 either write a cleaner workaround or file a bug report if
4491 4502 necessary.
4492 4503
4493 4504 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
4494 4505 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
4495 4506 a bug report by Tjabo Kloppenburg.
4496 4507
4497 4508 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
4498 4509 crashes. Wrapped the pdb call in a blanket try/except, since pdb
4499 4510 seems rather unstable. Thanks to a bug report by Tjabo
4500 4511 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
4501 4512
4502 4513 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
4503 4514 this out soon because of the critical fixes in the inner loop for
4504 4515 generators.
4505 4516
4506 4517 * IPython/Magic.py (Magic.getargspec): removed. This (and
4507 4518 _get_def) have been obsoleted by OInspect for a long time, I
4508 4519 hadn't noticed that they were dead code.
4509 4520 (Magic._ofind): restored _ofind functionality for a few literals
4510 4521 (those in ["''",'""','[]','{}','()']). But it won't work anymore
4511 4522 for things like "hello".capitalize?, since that would require a
4512 4523 potentially dangerous eval() again.
4513 4524
4514 4525 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
4515 4526 logic a bit more to clean up the escapes handling and minimize the
4516 4527 use of _ofind to only necessary cases. The interactive 'feel' of
4517 4528 IPython should have improved quite a bit with the changes in
4518 4529 _prefilter and _ofind (besides being far safer than before).
4519 4530
4520 4531 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
4521 4532 obscure, never reported). Edit would fail to find the object to
4522 4533 edit under some circumstances.
4523 4534 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
4524 4535 which were causing double-calling of generators. Those eval calls
4525 4536 were _very_ dangerous, since code with side effects could be
4526 4537 triggered. As they say, 'eval is evil'... These were the
4527 4538 nastiest evals in IPython. Besides, _ofind is now far simpler,
4528 4539 and it should also be quite a bit faster. Its use of inspect is
4529 4540 also safer, so perhaps some of the inspect-related crashes I've
4530 4541 seen lately with Python 2.3 might be taken care of. That will
4531 4542 need more testing.
4532 4543
4533 4544 2003-08-17 Fernando Perez <fperez@colorado.edu>
4534 4545
4535 4546 * IPython/iplib.py (InteractiveShell._prefilter): significant
4536 4547 simplifications to the logic for handling user escapes. Faster
4537 4548 and simpler code.
4538 4549
4539 4550 2003-08-14 Fernando Perez <fperez@colorado.edu>
4540 4551
4541 4552 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
4542 4553 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
4543 4554 but it should be quite a bit faster. And the recursive version
4544 4555 generated O(log N) intermediate storage for all rank>1 arrays,
4545 4556 even if they were contiguous.
4546 4557 (l1norm): Added this function.
4547 4558 (norm): Added this function for arbitrary norms (including
4548 4559 l-infinity). l1 and l2 are still special cases for convenience
4549 4560 and speed.
4550 4561
4551 4562 2003-08-03 Fernando Perez <fperez@colorado.edu>
4552 4563
4553 4564 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
4554 4565 exceptions, which now raise PendingDeprecationWarnings in Python
4555 4566 2.3. There were some in Magic and some in Gnuplot2.
4556 4567
4557 4568 2003-06-30 Fernando Perez <fperez@colorado.edu>
4558 4569
4559 4570 * IPython/genutils.py (page): modified to call curses only for
4560 4571 terminals where TERM=='xterm'. After problems under many other
4561 4572 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
4562 4573
4563 4574 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
4564 4575 would be triggered when readline was absent. This was just an old
4565 4576 debugging statement I'd forgotten to take out.
4566 4577
4567 4578 2003-06-20 Fernando Perez <fperez@colorado.edu>
4568 4579
4569 4580 * IPython/genutils.py (clock): modified to return only user time
4570 4581 (not counting system time), after a discussion on scipy. While
4571 4582 system time may be a useful quantity occasionally, it may much
4572 4583 more easily be skewed by occasional swapping or other similar
4573 4584 activity.
4574 4585
4575 4586 2003-06-05 Fernando Perez <fperez@colorado.edu>
4576 4587
4577 4588 * IPython/numutils.py (identity): new function, for building
4578 4589 arbitrary rank Kronecker deltas (mostly backwards compatible with
4579 4590 Numeric.identity)
4580 4591
4581 4592 2003-06-03 Fernando Perez <fperez@colorado.edu>
4582 4593
4583 4594 * IPython/iplib.py (InteractiveShell.handle_magic): protect
4584 4595 arguments passed to magics with spaces, to allow trailing '\' to
4585 4596 work normally (mainly for Windows users).
4586 4597
4587 4598 2003-05-29 Fernando Perez <fperez@colorado.edu>
4588 4599
4589 4600 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
4590 4601 instead of pydoc.help. This fixes a bizarre behavior where
4591 4602 printing '%s' % locals() would trigger the help system. Now
4592 4603 ipython behaves like normal python does.
4593 4604
4594 4605 Note that if one does 'from pydoc import help', the bizarre
4595 4606 behavior returns, but this will also happen in normal python, so
4596 4607 it's not an ipython bug anymore (it has to do with how pydoc.help
4597 4608 is implemented).
4598 4609
4599 4610 2003-05-22 Fernando Perez <fperez@colorado.edu>
4600 4611
4601 4612 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
4602 4613 return [] instead of None when nothing matches, also match to end
4603 4614 of line. Patch by Gary Bishop.
4604 4615
4605 4616 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
4606 4617 protection as before, for files passed on the command line. This
4607 4618 prevents the CrashHandler from kicking in if user files call into
4608 4619 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
4609 4620 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
4610 4621
4611 4622 2003-05-20 *** Released version 0.4.0
4612 4623
4613 4624 2003-05-20 Fernando Perez <fperez@colorado.edu>
4614 4625
4615 4626 * setup.py: added support for manpages. It's a bit hackish b/c of
4616 4627 a bug in the way the bdist_rpm distutils target handles gzipped
4617 4628 manpages, but it works. After a patch by Jack.
4618 4629
4619 4630 2003-05-19 Fernando Perez <fperez@colorado.edu>
4620 4631
4621 4632 * IPython/numutils.py: added a mockup of the kinds module, since
4622 4633 it was recently removed from Numeric. This way, numutils will
4623 4634 work for all users even if they are missing kinds.
4624 4635
4625 4636 * IPython/Magic.py (Magic._ofind): Harden against an inspect
4626 4637 failure, which can occur with SWIG-wrapped extensions. After a
4627 4638 crash report from Prabhu.
4628 4639
4629 4640 2003-05-16 Fernando Perez <fperez@colorado.edu>
4630 4641
4631 4642 * IPython/iplib.py (InteractiveShell.excepthook): New method to
4632 4643 protect ipython from user code which may call directly
4633 4644 sys.excepthook (this looks like an ipython crash to the user, even
4634 4645 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4635 4646 This is especially important to help users of WxWindows, but may
4636 4647 also be useful in other cases.
4637 4648
4638 4649 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
4639 4650 an optional tb_offset to be specified, and to preserve exception
4640 4651 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4641 4652
4642 4653 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
4643 4654
4644 4655 2003-05-15 Fernando Perez <fperez@colorado.edu>
4645 4656
4646 4657 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
4647 4658 installing for a new user under Windows.
4648 4659
4649 4660 2003-05-12 Fernando Perez <fperez@colorado.edu>
4650 4661
4651 4662 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
4652 4663 handler for Emacs comint-based lines. Currently it doesn't do
4653 4664 much (but importantly, it doesn't update the history cache). In
4654 4665 the future it may be expanded if Alex needs more functionality
4655 4666 there.
4656 4667
4657 4668 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
4658 4669 info to crash reports.
4659 4670
4660 4671 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
4661 4672 just like Python's -c. Also fixed crash with invalid -color
4662 4673 option value at startup. Thanks to Will French
4663 4674 <wfrench-AT-bestweb.net> for the bug report.
4664 4675
4665 4676 2003-05-09 Fernando Perez <fperez@colorado.edu>
4666 4677
4667 4678 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
4668 4679 to EvalDict (it's a mapping, after all) and simplified its code
4669 4680 quite a bit, after a nice discussion on c.l.py where Gustavo
4670 4681 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
4671 4682
4672 4683 2003-04-30 Fernando Perez <fperez@colorado.edu>
4673 4684
4674 4685 * IPython/genutils.py (timings_out): modified it to reduce its
4675 4686 overhead in the common reps==1 case.
4676 4687
4677 4688 2003-04-29 Fernando Perez <fperez@colorado.edu>
4678 4689
4679 4690 * IPython/genutils.py (timings_out): Modified to use the resource
4680 4691 module, which avoids the wraparound problems of time.clock().
4681 4692
4682 4693 2003-04-17 *** Released version 0.2.15pre4
4683 4694
4684 4695 2003-04-17 Fernando Perez <fperez@colorado.edu>
4685 4696
4686 4697 * setup.py (scriptfiles): Split windows-specific stuff over to a
4687 4698 separate file, in an attempt to have a Windows GUI installer.
4688 4699 That didn't work, but part of the groundwork is done.
4689 4700
4690 4701 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
4691 4702 indent/unindent with 4 spaces. Particularly useful in combination
4692 4703 with the new auto-indent option.
4693 4704
4694 4705 2003-04-16 Fernando Perez <fperez@colorado.edu>
4695 4706
4696 4707 * IPython/Magic.py: various replacements of self.rc for
4697 4708 self.shell.rc. A lot more remains to be done to fully disentangle
4698 4709 this class from the main Shell class.
4699 4710
4700 4711 * IPython/GnuplotRuntime.py: added checks for mouse support so
4701 4712 that we don't try to enable it if the current gnuplot doesn't
4702 4713 really support it. Also added checks so that we don't try to
4703 4714 enable persist under Windows (where Gnuplot doesn't recognize the
4704 4715 option).
4705 4716
4706 4717 * IPython/iplib.py (InteractiveShell.interact): Added optional
4707 4718 auto-indenting code, after a patch by King C. Shu
4708 4719 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
4709 4720 get along well with pasting indented code. If I ever figure out
4710 4721 how to make that part go well, it will become on by default.
4711 4722
4712 4723 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
4713 4724 crash ipython if there was an unmatched '%' in the user's prompt
4714 4725 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4715 4726
4716 4727 * IPython/iplib.py (InteractiveShell.interact): removed the
4717 4728 ability to ask the user whether he wants to crash or not at the
4718 4729 'last line' exception handler. Calling functions at that point
4719 4730 changes the stack, and the error reports would have incorrect
4720 4731 tracebacks.
4721 4732
4722 4733 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
4723 4734 pass through a peger a pretty-printed form of any object. After a
4724 4735 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
4725 4736
4726 4737 2003-04-14 Fernando Perez <fperez@colorado.edu>
4727 4738
4728 4739 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
4729 4740 all files in ~ would be modified at first install (instead of
4730 4741 ~/.ipython). This could be potentially disastrous, as the
4731 4742 modification (make line-endings native) could damage binary files.
4732 4743
4733 4744 2003-04-10 Fernando Perez <fperez@colorado.edu>
4734 4745
4735 4746 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
4736 4747 handle only lines which are invalid python. This now means that
4737 4748 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
4738 4749 for the bug report.
4739 4750
4740 4751 2003-04-01 Fernando Perez <fperez@colorado.edu>
4741 4752
4742 4753 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
4743 4754 where failing to set sys.last_traceback would crash pdb.pm().
4744 4755 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
4745 4756 report.
4746 4757
4747 4758 2003-03-25 Fernando Perez <fperez@colorado.edu>
4748 4759
4749 4760 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
4750 4761 before printing it (it had a lot of spurious blank lines at the
4751 4762 end).
4752 4763
4753 4764 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
4754 4765 output would be sent 21 times! Obviously people don't use this
4755 4766 too often, or I would have heard about it.
4756 4767
4757 4768 2003-03-24 Fernando Perez <fperez@colorado.edu>
4758 4769
4759 4770 * setup.py (scriptfiles): renamed the data_files parameter from
4760 4771 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
4761 4772 for the patch.
4762 4773
4763 4774 2003-03-20 Fernando Perez <fperez@colorado.edu>
4764 4775
4765 4776 * IPython/genutils.py (error): added error() and fatal()
4766 4777 functions.
4767 4778
4768 4779 2003-03-18 *** Released version 0.2.15pre3
4769 4780
4770 4781 2003-03-18 Fernando Perez <fperez@colorado.edu>
4771 4782
4772 4783 * setupext/install_data_ext.py
4773 4784 (install_data_ext.initialize_options): Class contributed by Jack
4774 4785 Moffit for fixing the old distutils hack. He is sending this to
4775 4786 the distutils folks so in the future we may not need it as a
4776 4787 private fix.
4777 4788
4778 4789 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
4779 4790 changes for Debian packaging. See his patch for full details.
4780 4791 The old distutils hack of making the ipythonrc* files carry a
4781 4792 bogus .py extension is gone, at last. Examples were moved to a
4782 4793 separate subdir under doc/, and the separate executable scripts
4783 4794 now live in their own directory. Overall a great cleanup. The
4784 4795 manual was updated to use the new files, and setup.py has been
4785 4796 fixed for this setup.
4786 4797
4787 4798 * IPython/PyColorize.py (Parser.usage): made non-executable and
4788 4799 created a pycolor wrapper around it to be included as a script.
4789 4800
4790 4801 2003-03-12 *** Released version 0.2.15pre2
4791 4802
4792 4803 2003-03-12 Fernando Perez <fperez@colorado.edu>
4793 4804
4794 4805 * IPython/ColorANSI.py (make_color_table): Finally fixed the
4795 4806 long-standing problem with garbage characters in some terminals.
4796 4807 The issue was really that the \001 and \002 escapes must _only_ be
4797 4808 passed to input prompts (which call readline), but _never_ to
4798 4809 normal text to be printed on screen. I changed ColorANSI to have
4799 4810 two classes: TermColors and InputTermColors, each with the
4800 4811 appropriate escapes for input prompts or normal text. The code in
4801 4812 Prompts.py got slightly more complicated, but this very old and
4802 4813 annoying bug is finally fixed.
4803 4814
4804 4815 All the credit for nailing down the real origin of this problem
4805 4816 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
4806 4817 *Many* thanks to him for spending quite a bit of effort on this.
4807 4818
4808 4819 2003-03-05 *** Released version 0.2.15pre1
4809 4820
4810 4821 2003-03-03 Fernando Perez <fperez@colorado.edu>
4811 4822
4812 4823 * IPython/FakeModule.py: Moved the former _FakeModule to a
4813 4824 separate file, because it's also needed by Magic (to fix a similar
4814 4825 pickle-related issue in @run).
4815 4826
4816 4827 2003-03-02 Fernando Perez <fperez@colorado.edu>
4817 4828
4818 4829 * IPython/Magic.py (Magic.magic_autocall): new magic to control
4819 4830 the autocall option at runtime.
4820 4831 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
4821 4832 across Magic.py to start separating Magic from InteractiveShell.
4822 4833 (Magic._ofind): Fixed to return proper namespace for dotted
4823 4834 names. Before, a dotted name would always return 'not currently
4824 4835 defined', because it would find the 'parent'. s.x would be found,
4825 4836 but since 'x' isn't defined by itself, it would get confused.
4826 4837 (Magic.magic_run): Fixed pickling problems reported by Ralf
4827 4838 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
4828 4839 that I'd used when Mike Heeter reported similar issues at the
4829 4840 top-level, but now for @run. It boils down to injecting the
4830 4841 namespace where code is being executed with something that looks
4831 4842 enough like a module to fool pickle.dump(). Since a pickle stores
4832 4843 a named reference to the importing module, we need this for
4833 4844 pickles to save something sensible.
4834 4845
4835 4846 * IPython/ipmaker.py (make_IPython): added an autocall option.
4836 4847
4837 4848 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
4838 4849 the auto-eval code. Now autocalling is an option, and the code is
4839 4850 also vastly safer. There is no more eval() involved at all.
4840 4851
4841 4852 2003-03-01 Fernando Perez <fperez@colorado.edu>
4842 4853
4843 4854 * IPython/Magic.py (Magic._ofind): Changed interface to return a
4844 4855 dict with named keys instead of a tuple.
4845 4856
4846 4857 * IPython: Started using CVS for IPython as of 0.2.15pre1.
4847 4858
4848 4859 * setup.py (make_shortcut): Fixed message about directories
4849 4860 created during Windows installation (the directories were ok, just
4850 4861 the printed message was misleading). Thanks to Chris Liechti
4851 4862 <cliechti-AT-gmx.net> for the heads up.
4852 4863
4853 4864 2003-02-21 Fernando Perez <fperez@colorado.edu>
4854 4865
4855 4866 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
4856 4867 of ValueError exception when checking for auto-execution. This
4857 4868 one is raised by things like Numeric arrays arr.flat when the
4858 4869 array is non-contiguous.
4859 4870
4860 4871 2003-01-31 Fernando Perez <fperez@colorado.edu>
4861 4872
4862 4873 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
4863 4874 not return any value at all (even though the command would get
4864 4875 executed).
4865 4876 (xsys): Flush stdout right after printing the command to ensure
4866 4877 proper ordering of commands and command output in the total
4867 4878 output.
4868 4879 (SystemExec/xsys/bq): Switched the names of xsys/bq and
4869 4880 system/getoutput as defaults. The old ones are kept for
4870 4881 compatibility reasons, so no code which uses this library needs
4871 4882 changing.
4872 4883
4873 4884 2003-01-27 *** Released version 0.2.14
4874 4885
4875 4886 2003-01-25 Fernando Perez <fperez@colorado.edu>
4876 4887
4877 4888 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
4878 4889 functions defined in previous edit sessions could not be re-edited
4879 4890 (because the temp files were immediately removed). Now temp files
4880 4891 are removed only at IPython's exit.
4881 4892 (Magic.magic_run): Improved @run to perform shell-like expansions
4882 4893 on its arguments (~users and $VARS). With this, @run becomes more
4883 4894 like a normal command-line.
4884 4895
4885 4896 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
4886 4897 bugs related to embedding and cleaned up that code. A fairly
4887 4898 important one was the impossibility to access the global namespace
4888 4899 through the embedded IPython (only local variables were visible).
4889 4900
4890 4901 2003-01-14 Fernando Perez <fperez@colorado.edu>
4891 4902
4892 4903 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
4893 4904 auto-calling to be a bit more conservative. Now it doesn't get
4894 4905 triggered if any of '!=()<>' are in the rest of the input line, to
4895 4906 allow comparing callables. Thanks to Alex for the heads up.
4896 4907
4897 4908 2003-01-07 Fernando Perez <fperez@colorado.edu>
4898 4909
4899 4910 * IPython/genutils.py (page): fixed estimation of the number of
4900 4911 lines in a string to be paged to simply count newlines. This
4901 4912 prevents over-guessing due to embedded escape sequences. A better
4902 4913 long-term solution would involve stripping out the control chars
4903 4914 for the count, but it's potentially so expensive I just don't
4904 4915 think it's worth doing.
4905 4916
4906 4917 2002-12-19 *** Released version 0.2.14pre50
4907 4918
4908 4919 2002-12-19 Fernando Perez <fperez@colorado.edu>
4909 4920
4910 4921 * tools/release (version): Changed release scripts to inform
4911 4922 Andrea and build a NEWS file with a list of recent changes.
4912 4923
4913 4924 * IPython/ColorANSI.py (__all__): changed terminal detection
4914 4925 code. Seems to work better for xterms without breaking
4915 4926 konsole. Will need more testing to determine if WinXP and Mac OSX
4916 4927 also work ok.
4917 4928
4918 4929 2002-12-18 *** Released version 0.2.14pre49
4919 4930
4920 4931 2002-12-18 Fernando Perez <fperez@colorado.edu>
4921 4932
4922 4933 * Docs: added new info about Mac OSX, from Andrea.
4923 4934
4924 4935 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
4925 4936 allow direct plotting of python strings whose format is the same
4926 4937 of gnuplot data files.
4927 4938
4928 4939 2002-12-16 Fernando Perez <fperez@colorado.edu>
4929 4940
4930 4941 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
4931 4942 value of exit question to be acknowledged.
4932 4943
4933 4944 2002-12-03 Fernando Perez <fperez@colorado.edu>
4934 4945
4935 4946 * IPython/ipmaker.py: removed generators, which had been added
4936 4947 by mistake in an earlier debugging run. This was causing trouble
4937 4948 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
4938 4949 for pointing this out.
4939 4950
4940 4951 2002-11-17 Fernando Perez <fperez@colorado.edu>
4941 4952
4942 4953 * Manual: updated the Gnuplot section.
4943 4954
4944 4955 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
4945 4956 a much better split of what goes in Runtime and what goes in
4946 4957 Interactive.
4947 4958
4948 4959 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
4949 4960 being imported from iplib.
4950 4961
4951 4962 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
4952 4963 for command-passing. Now the global Gnuplot instance is called
4953 4964 'gp' instead of 'g', which was really a far too fragile and
4954 4965 common name.
4955 4966
4956 4967 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
4957 4968 bounding boxes generated by Gnuplot for square plots.
4958 4969
4959 4970 * IPython/genutils.py (popkey): new function added. I should
4960 4971 suggest this on c.l.py as a dict method, it seems useful.
4961 4972
4962 4973 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
4963 4974 to transparently handle PostScript generation. MUCH better than
4964 4975 the previous plot_eps/replot_eps (which I removed now). The code
4965 4976 is also fairly clean and well documented now (including
4966 4977 docstrings).
4967 4978
4968 4979 2002-11-13 Fernando Perez <fperez@colorado.edu>
4969 4980
4970 4981 * IPython/Magic.py (Magic.magic_edit): fixed docstring
4971 4982 (inconsistent with options).
4972 4983
4973 4984 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
4974 4985 manually disabled, I don't know why. Fixed it.
4975 4986 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
4976 4987 eps output.
4977 4988
4978 4989 2002-11-12 Fernando Perez <fperez@colorado.edu>
4979 4990
4980 4991 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
4981 4992 don't propagate up to caller. Fixes crash reported by François
4982 4993 Pinard.
4983 4994
4984 4995 2002-11-09 Fernando Perez <fperez@colorado.edu>
4985 4996
4986 4997 * IPython/ipmaker.py (make_IPython): fixed problem with writing
4987 4998 history file for new users.
4988 4999 (make_IPython): fixed bug where initial install would leave the
4989 5000 user running in the .ipython dir.
4990 5001 (make_IPython): fixed bug where config dir .ipython would be
4991 5002 created regardless of the given -ipythondir option. Thanks to Cory
4992 5003 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
4993 5004
4994 5005 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
4995 5006 type confirmations. Will need to use it in all of IPython's code
4996 5007 consistently.
4997 5008
4998 5009 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
4999 5010 context to print 31 lines instead of the default 5. This will make
5000 5011 the crash reports extremely detailed in case the problem is in
5001 5012 libraries I don't have access to.
5002 5013
5003 5014 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
5004 5015 line of defense' code to still crash, but giving users fair
5005 5016 warning. I don't want internal errors to go unreported: if there's
5006 5017 an internal problem, IPython should crash and generate a full
5007 5018 report.
5008 5019
5009 5020 2002-11-08 Fernando Perez <fperez@colorado.edu>
5010 5021
5011 5022 * IPython/iplib.py (InteractiveShell.interact): added code to trap
5012 5023 otherwise uncaught exceptions which can appear if people set
5013 5024 sys.stdout to something badly broken. Thanks to a crash report
5014 5025 from henni-AT-mail.brainbot.com.
5015 5026
5016 5027 2002-11-04 Fernando Perez <fperez@colorado.edu>
5017 5028
5018 5029 * IPython/iplib.py (InteractiveShell.interact): added
5019 5030 __IPYTHON__active to the builtins. It's a flag which goes on when
5020 5031 the interaction starts and goes off again when it stops. This
5021 5032 allows embedding code to detect being inside IPython. Before this
5022 5033 was done via __IPYTHON__, but that only shows that an IPython
5023 5034 instance has been created.
5024 5035
5025 5036 * IPython/Magic.py (Magic.magic_env): I realized that in a
5026 5037 UserDict, instance.data holds the data as a normal dict. So I
5027 5038 modified @env to return os.environ.data instead of rebuilding a
5028 5039 dict by hand.
5029 5040
5030 5041 2002-11-02 Fernando Perez <fperez@colorado.edu>
5031 5042
5032 5043 * IPython/genutils.py (warn): changed so that level 1 prints no
5033 5044 header. Level 2 is now the default (with 'WARNING' header, as
5034 5045 before). I think I tracked all places where changes were needed in
5035 5046 IPython, but outside code using the old level numbering may have
5036 5047 broken.
5037 5048
5038 5049 * IPython/iplib.py (InteractiveShell.runcode): added this to
5039 5050 handle the tracebacks in SystemExit traps correctly. The previous
5040 5051 code (through interact) was printing more of the stack than
5041 5052 necessary, showing IPython internal code to the user.
5042 5053
5043 5054 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
5044 5055 default. Now that the default at the confirmation prompt is yes,
5045 5056 it's not so intrusive. François' argument that ipython sessions
5046 5057 tend to be complex enough not to lose them from an accidental C-d,
5047 5058 is a valid one.
5048 5059
5049 5060 * IPython/iplib.py (InteractiveShell.interact): added a
5050 5061 showtraceback() call to the SystemExit trap, and modified the exit
5051 5062 confirmation to have yes as the default.
5052 5063
5053 5064 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
5054 5065 this file. It's been gone from the code for a long time, this was
5055 5066 simply leftover junk.
5056 5067
5057 5068 2002-11-01 Fernando Perez <fperez@colorado.edu>
5058 5069
5059 5070 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
5060 5071 added. If set, IPython now traps EOF and asks for
5061 5072 confirmation. After a request by François Pinard.
5062 5073
5063 5074 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
5064 5075 of @abort, and with a new (better) mechanism for handling the
5065 5076 exceptions.
5066 5077
5067 5078 2002-10-27 Fernando Perez <fperez@colorado.edu>
5068 5079
5069 5080 * IPython/usage.py (__doc__): updated the --help information and
5070 5081 the ipythonrc file to indicate that -log generates
5071 5082 ./ipython.log. Also fixed the corresponding info in @logstart.
5072 5083 This and several other fixes in the manuals thanks to reports by
5073 5084 François Pinard <pinard-AT-iro.umontreal.ca>.
5074 5085
5075 5086 * IPython/Logger.py (Logger.switch_log): Fixed error message to
5076 5087 refer to @logstart (instead of @log, which doesn't exist).
5077 5088
5078 5089 * IPython/iplib.py (InteractiveShell._prefilter): fixed
5079 5090 AttributeError crash. Thanks to Christopher Armstrong
5080 5091 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
5081 5092 introduced recently (in 0.2.14pre37) with the fix to the eval
5082 5093 problem mentioned below.
5083 5094
5084 5095 2002-10-17 Fernando Perez <fperez@colorado.edu>
5085 5096
5086 5097 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
5087 5098 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
5088 5099
5089 5100 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
5090 5101 this function to fix a problem reported by Alex Schmolck. He saw
5091 5102 it with list comprehensions and generators, which were getting
5092 5103 called twice. The real problem was an 'eval' call in testing for
5093 5104 automagic which was evaluating the input line silently.
5094 5105
5095 5106 This is a potentially very nasty bug, if the input has side
5096 5107 effects which must not be repeated. The code is much cleaner now,
5097 5108 without any blanket 'except' left and with a regexp test for
5098 5109 actual function names.
5099 5110
5100 5111 But an eval remains, which I'm not fully comfortable with. I just
5101 5112 don't know how to find out if an expression could be a callable in
5102 5113 the user's namespace without doing an eval on the string. However
5103 5114 that string is now much more strictly checked so that no code
5104 5115 slips by, so the eval should only happen for things that can
5105 5116 really be only function/method names.
5106 5117
5107 5118 2002-10-15 Fernando Perez <fperez@colorado.edu>
5108 5119
5109 5120 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
5110 5121 OSX information to main manual, removed README_Mac_OSX file from
5111 5122 distribution. Also updated credits for recent additions.
5112 5123
5113 5124 2002-10-10 Fernando Perez <fperez@colorado.edu>
5114 5125
5115 5126 * README_Mac_OSX: Added a README for Mac OSX users for fixing
5116 5127 terminal-related issues. Many thanks to Andrea Riciputi
5117 5128 <andrea.riciputi-AT-libero.it> for writing it.
5118 5129
5119 5130 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
5120 5131 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
5121 5132
5122 5133 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
5123 5134 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
5124 5135 <syver-en-AT-online.no> who both submitted patches for this problem.
5125 5136
5126 5137 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
5127 5138 global embedding to make sure that things don't overwrite user
5128 5139 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
5129 5140
5130 5141 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
5131 5142 compatibility. Thanks to Hayden Callow
5132 5143 <h.callow-AT-elec.canterbury.ac.nz>
5133 5144
5134 5145 2002-10-04 Fernando Perez <fperez@colorado.edu>
5135 5146
5136 5147 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
5137 5148 Gnuplot.File objects.
5138 5149
5139 5150 2002-07-23 Fernando Perez <fperez@colorado.edu>
5140 5151
5141 5152 * IPython/genutils.py (timing): Added timings() and timing() for
5142 5153 quick access to the most commonly needed data, the execution
5143 5154 times. Old timing() renamed to timings_out().
5144 5155
5145 5156 2002-07-18 Fernando Perez <fperez@colorado.edu>
5146 5157
5147 5158 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
5148 5159 bug with nested instances disrupting the parent's tab completion.
5149 5160
5150 5161 * IPython/iplib.py (all_completions): Added Alex Schmolck's
5151 5162 all_completions code to begin the emacs integration.
5152 5163
5153 5164 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
5154 5165 argument to allow titling individual arrays when plotting.
5155 5166
5156 5167 2002-07-15 Fernando Perez <fperez@colorado.edu>
5157 5168
5158 5169 * setup.py (make_shortcut): changed to retrieve the value of
5159 5170 'Program Files' directory from the registry (this value changes in
5160 5171 non-english versions of Windows). Thanks to Thomas Fanslau
5161 5172 <tfanslau-AT-gmx.de> for the report.
5162 5173
5163 5174 2002-07-10 Fernando Perez <fperez@colorado.edu>
5164 5175
5165 5176 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
5166 5177 a bug in pdb, which crashes if a line with only whitespace is
5167 5178 entered. Bug report submitted to sourceforge.
5168 5179
5169 5180 2002-07-09 Fernando Perez <fperez@colorado.edu>
5170 5181
5171 5182 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
5172 5183 reporting exceptions (it's a bug in inspect.py, I just set a
5173 5184 workaround).
5174 5185
5175 5186 2002-07-08 Fernando Perez <fperez@colorado.edu>
5176 5187
5177 5188 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
5178 5189 __IPYTHON__ in __builtins__ to show up in user_ns.
5179 5190
5180 5191 2002-07-03 Fernando Perez <fperez@colorado.edu>
5181 5192
5182 5193 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
5183 5194 name from @gp_set_instance to @gp_set_default.
5184 5195
5185 5196 * IPython/ipmaker.py (make_IPython): default editor value set to
5186 5197 '0' (a string), to match the rc file. Otherwise will crash when
5187 5198 .strip() is called on it.
5188 5199
5189 5200
5190 5201 2002-06-28 Fernando Perez <fperez@colorado.edu>
5191 5202
5192 5203 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
5193 5204 of files in current directory when a file is executed via
5194 5205 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
5195 5206
5196 5207 * setup.py (manfiles): fix for rpm builds, submitted by RA
5197 5208 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
5198 5209
5199 5210 * IPython/ipmaker.py (make_IPython): fixed lookup of default
5200 5211 editor when set to '0'. Problem was, '0' evaluates to True (it's a
5201 5212 string!). A. Schmolck caught this one.
5202 5213
5203 5214 2002-06-27 Fernando Perez <fperez@colorado.edu>
5204 5215
5205 5216 * IPython/ipmaker.py (make_IPython): fixed bug when running user
5206 5217 defined files at the cmd line. __name__ wasn't being set to
5207 5218 __main__.
5208 5219
5209 5220 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
5210 5221 regular lists and tuples besides Numeric arrays.
5211 5222
5212 5223 * IPython/Prompts.py (CachedOutput.__call__): Added output
5213 5224 supression for input ending with ';'. Similar to Mathematica and
5214 5225 Matlab. The _* vars and Out[] list are still updated, just like
5215 5226 Mathematica behaves.
5216 5227
5217 5228 2002-06-25 Fernando Perez <fperez@colorado.edu>
5218 5229
5219 5230 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
5220 5231 .ini extensions for profiels under Windows.
5221 5232
5222 5233 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
5223 5234 string form. Fix contributed by Alexander Schmolck
5224 5235 <a.schmolck-AT-gmx.net>
5225 5236
5226 5237 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
5227 5238 pre-configured Gnuplot instance.
5228 5239
5229 5240 2002-06-21 Fernando Perez <fperez@colorado.edu>
5230 5241
5231 5242 * IPython/numutils.py (exp_safe): new function, works around the
5232 5243 underflow problems in Numeric.
5233 5244 (log2): New fn. Safe log in base 2: returns exact integer answer
5234 5245 for exact integer powers of 2.
5235 5246
5236 5247 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
5237 5248 properly.
5238 5249
5239 5250 2002-06-20 Fernando Perez <fperez@colorado.edu>
5240 5251
5241 5252 * IPython/genutils.py (timing): new function like
5242 5253 Mathematica's. Similar to time_test, but returns more info.
5243 5254
5244 5255 2002-06-18 Fernando Perez <fperez@colorado.edu>
5245 5256
5246 5257 * IPython/Magic.py (Magic.magic_save): modified @save and @r
5247 5258 according to Mike Heeter's suggestions.
5248 5259
5249 5260 2002-06-16 Fernando Perez <fperez@colorado.edu>
5250 5261
5251 5262 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
5252 5263 system. GnuplotMagic is gone as a user-directory option. New files
5253 5264 make it easier to use all the gnuplot stuff both from external
5254 5265 programs as well as from IPython. Had to rewrite part of
5255 5266 hardcopy() b/c of a strange bug: often the ps files simply don't
5256 5267 get created, and require a repeat of the command (often several
5257 5268 times).
5258 5269
5259 5270 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
5260 5271 resolve output channel at call time, so that if sys.stderr has
5261 5272 been redirected by user this gets honored.
5262 5273
5263 5274 2002-06-13 Fernando Perez <fperez@colorado.edu>
5264 5275
5265 5276 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
5266 5277 IPShell. Kept a copy with the old names to avoid breaking people's
5267 5278 embedded code.
5268 5279
5269 5280 * IPython/ipython: simplified it to the bare minimum after
5270 5281 Holger's suggestions. Added info about how to use it in
5271 5282 PYTHONSTARTUP.
5272 5283
5273 5284 * IPython/Shell.py (IPythonShell): changed the options passing
5274 5285 from a string with funky %s replacements to a straight list. Maybe
5275 5286 a bit more typing, but it follows sys.argv conventions, so there's
5276 5287 less special-casing to remember.
5277 5288
5278 5289 2002-06-12 Fernando Perez <fperez@colorado.edu>
5279 5290
5280 5291 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
5281 5292 command. Thanks to a suggestion by Mike Heeter.
5282 5293 (Magic.magic_pfile): added behavior to look at filenames if given
5283 5294 arg is not a defined object.
5284 5295 (Magic.magic_save): New @save function to save code snippets. Also
5285 5296 a Mike Heeter idea.
5286 5297
5287 5298 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
5288 5299 plot() and replot(). Much more convenient now, especially for
5289 5300 interactive use.
5290 5301
5291 5302 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
5292 5303 filenames.
5293 5304
5294 5305 2002-06-02 Fernando Perez <fperez@colorado.edu>
5295 5306
5296 5307 * IPython/Struct.py (Struct.__init__): modified to admit
5297 5308 initialization via another struct.
5298 5309
5299 5310 * IPython/genutils.py (SystemExec.__init__): New stateful
5300 5311 interface to xsys and bq. Useful for writing system scripts.
5301 5312
5302 5313 2002-05-30 Fernando Perez <fperez@colorado.edu>
5303 5314
5304 5315 * MANIFEST.in: Changed docfile selection to exclude all the lyx
5305 5316 documents. This will make the user download smaller (it's getting
5306 5317 too big).
5307 5318
5308 5319 2002-05-29 Fernando Perez <fperez@colorado.edu>
5309 5320
5310 5321 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
5311 5322 fix problems with shelve and pickle. Seems to work, but I don't
5312 5323 know if corner cases break it. Thanks to Mike Heeter
5313 5324 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
5314 5325
5315 5326 2002-05-24 Fernando Perez <fperez@colorado.edu>
5316 5327
5317 5328 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
5318 5329 macros having broken.
5319 5330
5320 5331 2002-05-21 Fernando Perez <fperez@colorado.edu>
5321 5332
5322 5333 * IPython/Magic.py (Magic.magic_logstart): fixed recently
5323 5334 introduced logging bug: all history before logging started was
5324 5335 being written one character per line! This came from the redesign
5325 5336 of the input history as a special list which slices to strings,
5326 5337 not to lists.
5327 5338
5328 5339 2002-05-20 Fernando Perez <fperez@colorado.edu>
5329 5340
5330 5341 * IPython/Prompts.py (CachedOutput.__init__): made the color table
5331 5342 be an attribute of all classes in this module. The design of these
5332 5343 classes needs some serious overhauling.
5333 5344
5334 5345 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
5335 5346 which was ignoring '_' in option names.
5336 5347
5337 5348 * IPython/ultraTB.py (FormattedTB.__init__): Changed
5338 5349 'Verbose_novars' to 'Context' and made it the new default. It's a
5339 5350 bit more readable and also safer than verbose.
5340 5351
5341 5352 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
5342 5353 triple-quoted strings.
5343 5354
5344 5355 * IPython/OInspect.py (__all__): new module exposing the object
5345 5356 introspection facilities. Now the corresponding magics are dummy
5346 5357 wrappers around this. Having this module will make it much easier
5347 5358 to put these functions into our modified pdb.
5348 5359 This new object inspector system uses the new colorizing module,
5349 5360 so source code and other things are nicely syntax highlighted.
5350 5361
5351 5362 2002-05-18 Fernando Perez <fperez@colorado.edu>
5352 5363
5353 5364 * IPython/ColorANSI.py: Split the coloring tools into a separate
5354 5365 module so I can use them in other code easier (they were part of
5355 5366 ultraTB).
5356 5367
5357 5368 2002-05-17 Fernando Perez <fperez@colorado.edu>
5358 5369
5359 5370 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
5360 5371 fixed it to set the global 'g' also to the called instance, as
5361 5372 long as 'g' was still a gnuplot instance (so it doesn't overwrite
5362 5373 user's 'g' variables).
5363 5374
5364 5375 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
5365 5376 global variables (aliases to _ih,_oh) so that users which expect
5366 5377 In[5] or Out[7] to work aren't unpleasantly surprised.
5367 5378 (InputList.__getslice__): new class to allow executing slices of
5368 5379 input history directly. Very simple class, complements the use of
5369 5380 macros.
5370 5381
5371 5382 2002-05-16 Fernando Perez <fperez@colorado.edu>
5372 5383
5373 5384 * setup.py (docdirbase): make doc directory be just doc/IPython
5374 5385 without version numbers, it will reduce clutter for users.
5375 5386
5376 5387 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
5377 5388 execfile call to prevent possible memory leak. See for details:
5378 5389 http://mail.python.org/pipermail/python-list/2002-February/088476.html
5379 5390
5380 5391 2002-05-15 Fernando Perez <fperez@colorado.edu>
5381 5392
5382 5393 * IPython/Magic.py (Magic.magic_psource): made the object
5383 5394 introspection names be more standard: pdoc, pdef, pfile and
5384 5395 psource. They all print/page their output, and it makes
5385 5396 remembering them easier. Kept old names for compatibility as
5386 5397 aliases.
5387 5398
5388 5399 2002-05-14 Fernando Perez <fperez@colorado.edu>
5389 5400
5390 5401 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
5391 5402 what the mouse problem was. The trick is to use gnuplot with temp
5392 5403 files and NOT with pipes (for data communication), because having
5393 5404 both pipes and the mouse on is bad news.
5394 5405
5395 5406 2002-05-13 Fernando Perez <fperez@colorado.edu>
5396 5407
5397 5408 * IPython/Magic.py (Magic._ofind): fixed namespace order search
5398 5409 bug. Information would be reported about builtins even when
5399 5410 user-defined functions overrode them.
5400 5411
5401 5412 2002-05-11 Fernando Perez <fperez@colorado.edu>
5402 5413
5403 5414 * IPython/__init__.py (__all__): removed FlexCompleter from
5404 5415 __all__ so that things don't fail in platforms without readline.
5405 5416
5406 5417 2002-05-10 Fernando Perez <fperez@colorado.edu>
5407 5418
5408 5419 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
5409 5420 it requires Numeric, effectively making Numeric a dependency for
5410 5421 IPython.
5411 5422
5412 5423 * Released 0.2.13
5413 5424
5414 5425 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
5415 5426 profiler interface. Now all the major options from the profiler
5416 5427 module are directly supported in IPython, both for single
5417 5428 expressions (@prun) and for full programs (@run -p).
5418 5429
5419 5430 2002-05-09 Fernando Perez <fperez@colorado.edu>
5420 5431
5421 5432 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
5422 5433 magic properly formatted for screen.
5423 5434
5424 5435 * setup.py (make_shortcut): Changed things to put pdf version in
5425 5436 doc/ instead of doc/manual (had to change lyxport a bit).
5426 5437
5427 5438 * IPython/Magic.py (Profile.string_stats): made profile runs go
5428 5439 through pager (they are long and a pager allows searching, saving,
5429 5440 etc.)
5430 5441
5431 5442 2002-05-08 Fernando Perez <fperez@colorado.edu>
5432 5443
5433 5444 * Released 0.2.12
5434 5445
5435 5446 2002-05-06 Fernando Perez <fperez@colorado.edu>
5436 5447
5437 5448 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
5438 5449 introduced); 'hist n1 n2' was broken.
5439 5450 (Magic.magic_pdb): added optional on/off arguments to @pdb
5440 5451 (Magic.magic_run): added option -i to @run, which executes code in
5441 5452 the IPython namespace instead of a clean one. Also added @irun as
5442 5453 an alias to @run -i.
5443 5454
5444 5455 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
5445 5456 fixed (it didn't really do anything, the namespaces were wrong).
5446 5457
5447 5458 * IPython/Debugger.py (__init__): Added workaround for python 2.1
5448 5459
5449 5460 * IPython/__init__.py (__all__): Fixed package namespace, now
5450 5461 'import IPython' does give access to IPython.<all> as
5451 5462 expected. Also renamed __release__ to Release.
5452 5463
5453 5464 * IPython/Debugger.py (__license__): created new Pdb class which
5454 5465 functions like a drop-in for the normal pdb.Pdb but does NOT
5455 5466 import readline by default. This way it doesn't muck up IPython's
5456 5467 readline handling, and now tab-completion finally works in the
5457 5468 debugger -- sort of. It completes things globally visible, but the
5458 5469 completer doesn't track the stack as pdb walks it. That's a bit
5459 5470 tricky, and I'll have to implement it later.
5460 5471
5461 5472 2002-05-05 Fernando Perez <fperez@colorado.edu>
5462 5473
5463 5474 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
5464 5475 magic docstrings when printed via ? (explicit \'s were being
5465 5476 printed).
5466 5477
5467 5478 * IPython/ipmaker.py (make_IPython): fixed namespace
5468 5479 identification bug. Now variables loaded via logs or command-line
5469 5480 files are recognized in the interactive namespace by @who.
5470 5481
5471 5482 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
5472 5483 log replay system stemming from the string form of Structs.
5473 5484
5474 5485 * IPython/Magic.py (Macro.__init__): improved macros to properly
5475 5486 handle magic commands in them.
5476 5487 (Magic.magic_logstart): usernames are now expanded so 'logstart
5477 5488 ~/mylog' now works.
5478 5489
5479 5490 * IPython/iplib.py (complete): fixed bug where paths starting with
5480 5491 '/' would be completed as magic names.
5481 5492
5482 5493 2002-05-04 Fernando Perez <fperez@colorado.edu>
5483 5494
5484 5495 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
5485 5496 allow running full programs under the profiler's control.
5486 5497
5487 5498 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
5488 5499 mode to report exceptions verbosely but without formatting
5489 5500 variables. This addresses the issue of ipython 'freezing' (it's
5490 5501 not frozen, but caught in an expensive formatting loop) when huge
5491 5502 variables are in the context of an exception.
5492 5503 (VerboseTB.text): Added '--->' markers at line where exception was
5493 5504 triggered. Much clearer to read, especially in NoColor modes.
5494 5505
5495 5506 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
5496 5507 implemented in reverse when changing to the new parse_options().
5497 5508
5498 5509 2002-05-03 Fernando Perez <fperez@colorado.edu>
5499 5510
5500 5511 * IPython/Magic.py (Magic.parse_options): new function so that
5501 5512 magics can parse options easier.
5502 5513 (Magic.magic_prun): new function similar to profile.run(),
5503 5514 suggested by Chris Hart.
5504 5515 (Magic.magic_cd): fixed behavior so that it only changes if
5505 5516 directory actually is in history.
5506 5517
5507 5518 * IPython/usage.py (__doc__): added information about potential
5508 5519 slowness of Verbose exception mode when there are huge data
5509 5520 structures to be formatted (thanks to Archie Paulson).
5510 5521
5511 5522 * IPython/ipmaker.py (make_IPython): Changed default logging
5512 5523 (when simply called with -log) to use curr_dir/ipython.log in
5513 5524 rotate mode. Fixed crash which was occuring with -log before
5514 5525 (thanks to Jim Boyle).
5515 5526
5516 5527 2002-05-01 Fernando Perez <fperez@colorado.edu>
5517 5528
5518 5529 * Released 0.2.11 for these fixes (mainly the ultraTB one which
5519 5530 was nasty -- though somewhat of a corner case).
5520 5531
5521 5532 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
5522 5533 text (was a bug).
5523 5534
5524 5535 2002-04-30 Fernando Perez <fperez@colorado.edu>
5525 5536
5526 5537 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
5527 5538 a print after ^D or ^C from the user so that the In[] prompt
5528 5539 doesn't over-run the gnuplot one.
5529 5540
5530 5541 2002-04-29 Fernando Perez <fperez@colorado.edu>
5531 5542
5532 5543 * Released 0.2.10
5533 5544
5534 5545 * IPython/__release__.py (version): get date dynamically.
5535 5546
5536 5547 * Misc. documentation updates thanks to Arnd's comments. Also ran
5537 5548 a full spellcheck on the manual (hadn't been done in a while).
5538 5549
5539 5550 2002-04-27 Fernando Perez <fperez@colorado.edu>
5540 5551
5541 5552 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
5542 5553 starting a log in mid-session would reset the input history list.
5543 5554
5544 5555 2002-04-26 Fernando Perez <fperez@colorado.edu>
5545 5556
5546 5557 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
5547 5558 all files were being included in an update. Now anything in
5548 5559 UserConfig that matches [A-Za-z]*.py will go (this excludes
5549 5560 __init__.py)
5550 5561
5551 5562 2002-04-25 Fernando Perez <fperez@colorado.edu>
5552 5563
5553 5564 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
5554 5565 to __builtins__ so that any form of embedded or imported code can
5555 5566 test for being inside IPython.
5556 5567
5557 5568 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
5558 5569 changed to GnuplotMagic because it's now an importable module,
5559 5570 this makes the name follow that of the standard Gnuplot module.
5560 5571 GnuplotMagic can now be loaded at any time in mid-session.
5561 5572
5562 5573 2002-04-24 Fernando Perez <fperez@colorado.edu>
5563 5574
5564 5575 * IPython/numutils.py: removed SIUnits. It doesn't properly set
5565 5576 the globals (IPython has its own namespace) and the
5566 5577 PhysicalQuantity stuff is much better anyway.
5567 5578
5568 5579 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
5569 5580 embedding example to standard user directory for
5570 5581 distribution. Also put it in the manual.
5571 5582
5572 5583 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
5573 5584 instance as first argument (so it doesn't rely on some obscure
5574 5585 hidden global).
5575 5586
5576 5587 * IPython/UserConfig/ipythonrc.py: put () back in accepted
5577 5588 delimiters. While it prevents ().TAB from working, it allows
5578 5589 completions in open (... expressions. This is by far a more common
5579 5590 case.
5580 5591
5581 5592 2002-04-23 Fernando Perez <fperez@colorado.edu>
5582 5593
5583 5594 * IPython/Extensions/InterpreterPasteInput.py: new
5584 5595 syntax-processing module for pasting lines with >>> or ... at the
5585 5596 start.
5586 5597
5587 5598 * IPython/Extensions/PhysicalQ_Interactive.py
5588 5599 (PhysicalQuantityInteractive.__int__): fixed to work with either
5589 5600 Numeric or math.
5590 5601
5591 5602 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
5592 5603 provided profiles. Now we have:
5593 5604 -math -> math module as * and cmath with its own namespace.
5594 5605 -numeric -> Numeric as *, plus gnuplot & grace
5595 5606 -physics -> same as before
5596 5607
5597 5608 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
5598 5609 user-defined magics wouldn't be found by @magic if they were
5599 5610 defined as class methods. Also cleaned up the namespace search
5600 5611 logic and the string building (to use %s instead of many repeated
5601 5612 string adds).
5602 5613
5603 5614 * IPython/UserConfig/example-magic.py (magic_foo): updated example
5604 5615 of user-defined magics to operate with class methods (cleaner, in
5605 5616 line with the gnuplot code).
5606 5617
5607 5618 2002-04-22 Fernando Perez <fperez@colorado.edu>
5608 5619
5609 5620 * setup.py: updated dependency list so that manual is updated when
5610 5621 all included files change.
5611 5622
5612 5623 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
5613 5624 the delimiter removal option (the fix is ugly right now).
5614 5625
5615 5626 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
5616 5627 all of the math profile (quicker loading, no conflict between
5617 5628 g-9.8 and g-gnuplot).
5618 5629
5619 5630 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
5620 5631 name of post-mortem files to IPython_crash_report.txt.
5621 5632
5622 5633 * Cleanup/update of the docs. Added all the new readline info and
5623 5634 formatted all lists as 'real lists'.
5624 5635
5625 5636 * IPython/ipmaker.py (make_IPython): removed now-obsolete
5626 5637 tab-completion options, since the full readline parse_and_bind is
5627 5638 now accessible.
5628 5639
5629 5640 * IPython/iplib.py (InteractiveShell.init_readline): Changed
5630 5641 handling of readline options. Now users can specify any string to
5631 5642 be passed to parse_and_bind(), as well as the delimiters to be
5632 5643 removed.
5633 5644 (InteractiveShell.__init__): Added __name__ to the global
5634 5645 namespace so that things like Itpl which rely on its existence
5635 5646 don't crash.
5636 5647 (InteractiveShell._prefilter): Defined the default with a _ so
5637 5648 that prefilter() is easier to override, while the default one
5638 5649 remains available.
5639 5650
5640 5651 2002-04-18 Fernando Perez <fperez@colorado.edu>
5641 5652
5642 5653 * Added information about pdb in the docs.
5643 5654
5644 5655 2002-04-17 Fernando Perez <fperez@colorado.edu>
5645 5656
5646 5657 * IPython/ipmaker.py (make_IPython): added rc_override option to
5647 5658 allow passing config options at creation time which may override
5648 5659 anything set in the config files or command line. This is
5649 5660 particularly useful for configuring embedded instances.
5650 5661
5651 5662 2002-04-15 Fernando Perez <fperez@colorado.edu>
5652 5663
5653 5664 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
5654 5665 crash embedded instances because of the input cache falling out of
5655 5666 sync with the output counter.
5656 5667
5657 5668 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
5658 5669 mode which calls pdb after an uncaught exception in IPython itself.
5659 5670
5660 5671 2002-04-14 Fernando Perez <fperez@colorado.edu>
5661 5672
5662 5673 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
5663 5674 readline, fix it back after each call.
5664 5675
5665 5676 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
5666 5677 method to force all access via __call__(), which guarantees that
5667 5678 traceback references are properly deleted.
5668 5679
5669 5680 * IPython/Prompts.py (CachedOutput._display): minor fixes to
5670 5681 improve printing when pprint is in use.
5671 5682
5672 5683 2002-04-13 Fernando Perez <fperez@colorado.edu>
5673 5684
5674 5685 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
5675 5686 exceptions aren't caught anymore. If the user triggers one, he
5676 5687 should know why he's doing it and it should go all the way up,
5677 5688 just like any other exception. So now @abort will fully kill the
5678 5689 embedded interpreter and the embedding code (unless that happens
5679 5690 to catch SystemExit).
5680 5691
5681 5692 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
5682 5693 and a debugger() method to invoke the interactive pdb debugger
5683 5694 after printing exception information. Also added the corresponding
5684 5695 -pdb option and @pdb magic to control this feature, and updated
5685 5696 the docs. After a suggestion from Christopher Hart
5686 5697 (hart-AT-caltech.edu).
5687 5698
5688 5699 2002-04-12 Fernando Perez <fperez@colorado.edu>
5689 5700
5690 5701 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
5691 5702 the exception handlers defined by the user (not the CrashHandler)
5692 5703 so that user exceptions don't trigger an ipython bug report.
5693 5704
5694 5705 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
5695 5706 configurable (it should have always been so).
5696 5707
5697 5708 2002-03-26 Fernando Perez <fperez@colorado.edu>
5698 5709
5699 5710 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
5700 5711 and there to fix embedding namespace issues. This should all be
5701 5712 done in a more elegant way.
5702 5713
5703 5714 2002-03-25 Fernando Perez <fperez@colorado.edu>
5704 5715
5705 5716 * IPython/genutils.py (get_home_dir): Try to make it work under
5706 5717 win9x also.
5707 5718
5708 5719 2002-03-20 Fernando Perez <fperez@colorado.edu>
5709 5720
5710 5721 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
5711 5722 sys.displayhook untouched upon __init__.
5712 5723
5713 5724 2002-03-19 Fernando Perez <fperez@colorado.edu>
5714 5725
5715 5726 * Released 0.2.9 (for embedding bug, basically).
5716 5727
5717 5728 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
5718 5729 exceptions so that enclosing shell's state can be restored.
5719 5730
5720 5731 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
5721 5732 naming conventions in the .ipython/ dir.
5722 5733
5723 5734 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
5724 5735 from delimiters list so filenames with - in them get expanded.
5725 5736
5726 5737 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
5727 5738 sys.displayhook not being properly restored after an embedded call.
5728 5739
5729 5740 2002-03-18 Fernando Perez <fperez@colorado.edu>
5730 5741
5731 5742 * Released 0.2.8
5732 5743
5733 5744 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
5734 5745 some files weren't being included in a -upgrade.
5735 5746 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
5736 5747 on' so that the first tab completes.
5737 5748 (InteractiveShell.handle_magic): fixed bug with spaces around
5738 5749 quotes breaking many magic commands.
5739 5750
5740 5751 * setup.py: added note about ignoring the syntax error messages at
5741 5752 installation.
5742 5753
5743 5754 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
5744 5755 streamlining the gnuplot interface, now there's only one magic @gp.
5745 5756
5746 5757 2002-03-17 Fernando Perez <fperez@colorado.edu>
5747 5758
5748 5759 * IPython/UserConfig/magic_gnuplot.py: new name for the
5749 5760 example-magic_pm.py file. Much enhanced system, now with a shell
5750 5761 for communicating directly with gnuplot, one command at a time.
5751 5762
5752 5763 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
5753 5764 setting __name__=='__main__'.
5754 5765
5755 5766 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
5756 5767 mini-shell for accessing gnuplot from inside ipython. Should
5757 5768 extend it later for grace access too. Inspired by Arnd's
5758 5769 suggestion.
5759 5770
5760 5771 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
5761 5772 calling magic functions with () in their arguments. Thanks to Arnd
5762 5773 Baecker for pointing this to me.
5763 5774
5764 5775 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
5765 5776 infinitely for integer or complex arrays (only worked with floats).
5766 5777
5767 5778 2002-03-16 Fernando Perez <fperez@colorado.edu>
5768 5779
5769 5780 * setup.py: Merged setup and setup_windows into a single script
5770 5781 which properly handles things for windows users.
5771 5782
5772 5783 2002-03-15 Fernando Perez <fperez@colorado.edu>
5773 5784
5774 5785 * Big change to the manual: now the magics are all automatically
5775 5786 documented. This information is generated from their docstrings
5776 5787 and put in a latex file included by the manual lyx file. This way
5777 5788 we get always up to date information for the magics. The manual
5778 5789 now also has proper version information, also auto-synced.
5779 5790
5780 5791 For this to work, an undocumented --magic_docstrings option was added.
5781 5792
5782 5793 2002-03-13 Fernando Perez <fperez@colorado.edu>
5783 5794
5784 5795 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
5785 5796 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
5786 5797
5787 5798 2002-03-12 Fernando Perez <fperez@colorado.edu>
5788 5799
5789 5800 * IPython/ultraTB.py (TermColors): changed color escapes again to
5790 5801 fix the (old, reintroduced) line-wrapping bug. Basically, if
5791 5802 \001..\002 aren't given in the color escapes, lines get wrapped
5792 5803 weirdly. But giving those screws up old xterms and emacs terms. So
5793 5804 I added some logic for emacs terms to be ok, but I can't identify old
5794 5805 xterms separately ($TERM=='xterm' for many terminals, like konsole).
5795 5806
5796 5807 2002-03-10 Fernando Perez <fperez@colorado.edu>
5797 5808
5798 5809 * IPython/usage.py (__doc__): Various documentation cleanups and
5799 5810 updates, both in usage docstrings and in the manual.
5800 5811
5801 5812 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
5802 5813 handling of caching. Set minimum acceptabe value for having a
5803 5814 cache at 20 values.
5804 5815
5805 5816 * IPython/iplib.py (InteractiveShell.user_setup): moved the
5806 5817 install_first_time function to a method, renamed it and added an
5807 5818 'upgrade' mode. Now people can update their config directory with
5808 5819 a simple command line switch (-upgrade, also new).
5809 5820
5810 5821 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
5811 5822 @file (convenient for automagic users under Python >= 2.2).
5812 5823 Removed @files (it seemed more like a plural than an abbrev. of
5813 5824 'file show').
5814 5825
5815 5826 * IPython/iplib.py (install_first_time): Fixed crash if there were
5816 5827 backup files ('~') in .ipython/ install directory.
5817 5828
5818 5829 * IPython/ipmaker.py (make_IPython): fixes for new prompt
5819 5830 system. Things look fine, but these changes are fairly
5820 5831 intrusive. Test them for a few days.
5821 5832
5822 5833 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
5823 5834 the prompts system. Now all in/out prompt strings are user
5824 5835 controllable. This is particularly useful for embedding, as one
5825 5836 can tag embedded instances with particular prompts.
5826 5837
5827 5838 Also removed global use of sys.ps1/2, which now allows nested
5828 5839 embeddings without any problems. Added command-line options for
5829 5840 the prompt strings.
5830 5841
5831 5842 2002-03-08 Fernando Perez <fperez@colorado.edu>
5832 5843
5833 5844 * IPython/UserConfig/example-embed-short.py (ipshell): added
5834 5845 example file with the bare minimum code for embedding.
5835 5846
5836 5847 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
5837 5848 functionality for the embeddable shell to be activated/deactivated
5838 5849 either globally or at each call.
5839 5850
5840 5851 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
5841 5852 rewriting the prompt with '--->' for auto-inputs with proper
5842 5853 coloring. Now the previous UGLY hack in handle_auto() is gone, and
5843 5854 this is handled by the prompts class itself, as it should.
5844 5855
5845 5856 2002-03-05 Fernando Perez <fperez@colorado.edu>
5846 5857
5847 5858 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
5848 5859 @logstart to avoid name clashes with the math log function.
5849 5860
5850 5861 * Big updates to X/Emacs section of the manual.
5851 5862
5852 5863 * Removed ipython_emacs. Milan explained to me how to pass
5853 5864 arguments to ipython through Emacs. Some day I'm going to end up
5854 5865 learning some lisp...
5855 5866
5856 5867 2002-03-04 Fernando Perez <fperez@colorado.edu>
5857 5868
5858 5869 * IPython/ipython_emacs: Created script to be used as the
5859 5870 py-python-command Emacs variable so we can pass IPython
5860 5871 parameters. I can't figure out how to tell Emacs directly to pass
5861 5872 parameters to IPython, so a dummy shell script will do it.
5862 5873
5863 5874 Other enhancements made for things to work better under Emacs'
5864 5875 various types of terminals. Many thanks to Milan Zamazal
5865 5876 <pdm-AT-zamazal.org> for all the suggestions and pointers.
5866 5877
5867 5878 2002-03-01 Fernando Perez <fperez@colorado.edu>
5868 5879
5869 5880 * IPython/ipmaker.py (make_IPython): added a --readline! option so
5870 5881 that loading of readline is now optional. This gives better
5871 5882 control to emacs users.
5872 5883
5873 5884 * IPython/ultraTB.py (__date__): Modified color escape sequences
5874 5885 and now things work fine under xterm and in Emacs' term buffers
5875 5886 (though not shell ones). Well, in emacs you get colors, but all
5876 5887 seem to be 'light' colors (no difference between dark and light
5877 5888 ones). But the garbage chars are gone, and also in xterms. It
5878 5889 seems that now I'm using 'cleaner' ansi sequences.
5879 5890
5880 5891 2002-02-21 Fernando Perez <fperez@colorado.edu>
5881 5892
5882 5893 * Released 0.2.7 (mainly to publish the scoping fix).
5883 5894
5884 5895 * IPython/Logger.py (Logger.logstate): added. A corresponding
5885 5896 @logstate magic was created.
5886 5897
5887 5898 * IPython/Magic.py: fixed nested scoping problem under Python
5888 5899 2.1.x (automagic wasn't working).
5889 5900
5890 5901 2002-02-20 Fernando Perez <fperez@colorado.edu>
5891 5902
5892 5903 * Released 0.2.6.
5893 5904
5894 5905 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
5895 5906 option so that logs can come out without any headers at all.
5896 5907
5897 5908 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
5898 5909 SciPy.
5899 5910
5900 5911 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
5901 5912 that embedded IPython calls don't require vars() to be explicitly
5902 5913 passed. Now they are extracted from the caller's frame (code
5903 5914 snatched from Eric Jones' weave). Added better documentation to
5904 5915 the section on embedding and the example file.
5905 5916
5906 5917 * IPython/genutils.py (page): Changed so that under emacs, it just
5907 5918 prints the string. You can then page up and down in the emacs
5908 5919 buffer itself. This is how the builtin help() works.
5909 5920
5910 5921 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
5911 5922 macro scoping: macros need to be executed in the user's namespace
5912 5923 to work as if they had been typed by the user.
5913 5924
5914 5925 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
5915 5926 execute automatically (no need to type 'exec...'). They then
5916 5927 behave like 'true macros'. The printing system was also modified
5917 5928 for this to work.
5918 5929
5919 5930 2002-02-19 Fernando Perez <fperez@colorado.edu>
5920 5931
5921 5932 * IPython/genutils.py (page_file): new function for paging files
5922 5933 in an OS-independent way. Also necessary for file viewing to work
5923 5934 well inside Emacs buffers.
5924 5935 (page): Added checks for being in an emacs buffer.
5925 5936 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
5926 5937 same bug in iplib.
5927 5938
5928 5939 2002-02-18 Fernando Perez <fperez@colorado.edu>
5929 5940
5930 5941 * IPython/iplib.py (InteractiveShell.init_readline): modified use
5931 5942 of readline so that IPython can work inside an Emacs buffer.
5932 5943
5933 5944 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
5934 5945 method signatures (they weren't really bugs, but it looks cleaner
5935 5946 and keeps PyChecker happy).
5936 5947
5937 5948 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
5938 5949 for implementing various user-defined hooks. Currently only
5939 5950 display is done.
5940 5951
5941 5952 * IPython/Prompts.py (CachedOutput._display): changed display
5942 5953 functions so that they can be dynamically changed by users easily.
5943 5954
5944 5955 * IPython/Extensions/numeric_formats.py (num_display): added an
5945 5956 extension for printing NumPy arrays in flexible manners. It
5946 5957 doesn't do anything yet, but all the structure is in
5947 5958 place. Ultimately the plan is to implement output format control
5948 5959 like in Octave.
5949 5960
5950 5961 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
5951 5962 methods are found at run-time by all the automatic machinery.
5952 5963
5953 5964 2002-02-17 Fernando Perez <fperez@colorado.edu>
5954 5965
5955 5966 * setup_Windows.py (make_shortcut): documented. Cleaned up the
5956 5967 whole file a little.
5957 5968
5958 5969 * ToDo: closed this document. Now there's a new_design.lyx
5959 5970 document for all new ideas. Added making a pdf of it for the
5960 5971 end-user distro.
5961 5972
5962 5973 * IPython/Logger.py (Logger.switch_log): Created this to replace
5963 5974 logon() and logoff(). It also fixes a nasty crash reported by
5964 5975 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
5965 5976
5966 5977 * IPython/iplib.py (complete): got auto-completion to work with
5967 5978 automagic (I had wanted this for a long time).
5968 5979
5969 5980 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
5970 5981 to @file, since file() is now a builtin and clashes with automagic
5971 5982 for @file.
5972 5983
5973 5984 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
5974 5985 of this was previously in iplib, which had grown to more than 2000
5975 5986 lines, way too long. No new functionality, but it makes managing
5976 5987 the code a bit easier.
5977 5988
5978 5989 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
5979 5990 information to crash reports.
5980 5991
5981 5992 2002-02-12 Fernando Perez <fperez@colorado.edu>
5982 5993
5983 5994 * Released 0.2.5.
5984 5995
5985 5996 2002-02-11 Fernando Perez <fperez@colorado.edu>
5986 5997
5987 5998 * Wrote a relatively complete Windows installer. It puts
5988 5999 everything in place, creates Start Menu entries and fixes the
5989 6000 color issues. Nothing fancy, but it works.
5990 6001
5991 6002 2002-02-10 Fernando Perez <fperez@colorado.edu>
5992 6003
5993 6004 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
5994 6005 os.path.expanduser() call so that we can type @run ~/myfile.py and
5995 6006 have thigs work as expected.
5996 6007
5997 6008 * IPython/genutils.py (page): fixed exception handling so things
5998 6009 work both in Unix and Windows correctly. Quitting a pager triggers
5999 6010 an IOError/broken pipe in Unix, and in windows not finding a pager
6000 6011 is also an IOError, so I had to actually look at the return value
6001 6012 of the exception, not just the exception itself. Should be ok now.
6002 6013
6003 6014 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
6004 6015 modified to allow case-insensitive color scheme changes.
6005 6016
6006 6017 2002-02-09 Fernando Perez <fperez@colorado.edu>
6007 6018
6008 6019 * IPython/genutils.py (native_line_ends): new function to leave
6009 6020 user config files with os-native line-endings.
6010 6021
6011 6022 * README and manual updates.
6012 6023
6013 6024 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
6014 6025 instead of StringType to catch Unicode strings.
6015 6026
6016 6027 * IPython/genutils.py (filefind): fixed bug for paths with
6017 6028 embedded spaces (very common in Windows).
6018 6029
6019 6030 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
6020 6031 files under Windows, so that they get automatically associated
6021 6032 with a text editor. Windows makes it a pain to handle
6022 6033 extension-less files.
6023 6034
6024 6035 * IPython/iplib.py (InteractiveShell.init_readline): Made the
6025 6036 warning about readline only occur for Posix. In Windows there's no
6026 6037 way to get readline, so why bother with the warning.
6027 6038
6028 6039 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
6029 6040 for __str__ instead of dir(self), since dir() changed in 2.2.
6030 6041
6031 6042 * Ported to Windows! Tested on XP, I suspect it should work fine
6032 6043 on NT/2000, but I don't think it will work on 98 et al. That
6033 6044 series of Windows is such a piece of junk anyway that I won't try
6034 6045 porting it there. The XP port was straightforward, showed a few
6035 6046 bugs here and there (fixed all), in particular some string
6036 6047 handling stuff which required considering Unicode strings (which
6037 6048 Windows uses). This is good, but hasn't been too tested :) No
6038 6049 fancy installer yet, I'll put a note in the manual so people at
6039 6050 least make manually a shortcut.
6040 6051
6041 6052 * IPython/iplib.py (Magic.magic_colors): Unified the color options
6042 6053 into a single one, "colors". This now controls both prompt and
6043 6054 exception color schemes, and can be changed both at startup
6044 6055 (either via command-line switches or via ipythonrc files) and at
6045 6056 runtime, with @colors.
6046 6057 (Magic.magic_run): renamed @prun to @run and removed the old
6047 6058 @run. The two were too similar to warrant keeping both.
6048 6059
6049 6060 2002-02-03 Fernando Perez <fperez@colorado.edu>
6050 6061
6051 6062 * IPython/iplib.py (install_first_time): Added comment on how to
6052 6063 configure the color options for first-time users. Put a <return>
6053 6064 request at the end so that small-terminal users get a chance to
6054 6065 read the startup info.
6055 6066
6056 6067 2002-01-23 Fernando Perez <fperez@colorado.edu>
6057 6068
6058 6069 * IPython/iplib.py (CachedOutput.update): Changed output memory
6059 6070 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
6060 6071 input history we still use _i. Did this b/c these variable are
6061 6072 very commonly used in interactive work, so the less we need to
6062 6073 type the better off we are.
6063 6074 (Magic.magic_prun): updated @prun to better handle the namespaces
6064 6075 the file will run in, including a fix for __name__ not being set
6065 6076 before.
6066 6077
6067 6078 2002-01-20 Fernando Perez <fperez@colorado.edu>
6068 6079
6069 6080 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
6070 6081 extra garbage for Python 2.2. Need to look more carefully into
6071 6082 this later.
6072 6083
6073 6084 2002-01-19 Fernando Perez <fperez@colorado.edu>
6074 6085
6075 6086 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
6076 6087 display SyntaxError exceptions properly formatted when they occur
6077 6088 (they can be triggered by imported code).
6078 6089
6079 6090 2002-01-18 Fernando Perez <fperez@colorado.edu>
6080 6091
6081 6092 * IPython/iplib.py (InteractiveShell.safe_execfile): now
6082 6093 SyntaxError exceptions are reported nicely formatted, instead of
6083 6094 spitting out only offset information as before.
6084 6095 (Magic.magic_prun): Added the @prun function for executing
6085 6096 programs with command line args inside IPython.
6086 6097
6087 6098 2002-01-16 Fernando Perez <fperez@colorado.edu>
6088 6099
6089 6100 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
6090 6101 to *not* include the last item given in a range. This brings their
6091 6102 behavior in line with Python's slicing:
6092 6103 a[n1:n2] -> a[n1]...a[n2-1]
6093 6104 It may be a bit less convenient, but I prefer to stick to Python's
6094 6105 conventions *everywhere*, so users never have to wonder.
6095 6106 (Magic.magic_macro): Added @macro function to ease the creation of
6096 6107 macros.
6097 6108
6098 6109 2002-01-05 Fernando Perez <fperez@colorado.edu>
6099 6110
6100 6111 * Released 0.2.4.
6101 6112
6102 6113 * IPython/iplib.py (Magic.magic_pdef):
6103 6114 (InteractiveShell.safe_execfile): report magic lines and error
6104 6115 lines without line numbers so one can easily copy/paste them for
6105 6116 re-execution.
6106 6117
6107 6118 * Updated manual with recent changes.
6108 6119
6109 6120 * IPython/iplib.py (Magic.magic_oinfo): added constructor
6110 6121 docstring printing when class? is called. Very handy for knowing
6111 6122 how to create class instances (as long as __init__ is well
6112 6123 documented, of course :)
6113 6124 (Magic.magic_doc): print both class and constructor docstrings.
6114 6125 (Magic.magic_pdef): give constructor info if passed a class and
6115 6126 __call__ info for callable object instances.
6116 6127
6117 6128 2002-01-04 Fernando Perez <fperez@colorado.edu>
6118 6129
6119 6130 * Made deep_reload() off by default. It doesn't always work
6120 6131 exactly as intended, so it's probably safer to have it off. It's
6121 6132 still available as dreload() anyway, so nothing is lost.
6122 6133
6123 6134 2002-01-02 Fernando Perez <fperez@colorado.edu>
6124 6135
6125 6136 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
6126 6137 so I wanted an updated release).
6127 6138
6128 6139 2001-12-27 Fernando Perez <fperez@colorado.edu>
6129 6140
6130 6141 * IPython/iplib.py (InteractiveShell.interact): Added the original
6131 6142 code from 'code.py' for this module in order to change the
6132 6143 handling of a KeyboardInterrupt. This was necessary b/c otherwise
6133 6144 the history cache would break when the user hit Ctrl-C, and
6134 6145 interact() offers no way to add any hooks to it.
6135 6146
6136 6147 2001-12-23 Fernando Perez <fperez@colorado.edu>
6137 6148
6138 6149 * setup.py: added check for 'MANIFEST' before trying to remove
6139 6150 it. Thanks to Sean Reifschneider.
6140 6151
6141 6152 2001-12-22 Fernando Perez <fperez@colorado.edu>
6142 6153
6143 6154 * Released 0.2.2.
6144 6155
6145 6156 * Finished (reasonably) writing the manual. Later will add the
6146 6157 python-standard navigation stylesheets, but for the time being
6147 6158 it's fairly complete. Distribution will include html and pdf
6148 6159 versions.
6149 6160
6150 6161 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
6151 6162 (MayaVi author).
6152 6163
6153 6164 2001-12-21 Fernando Perez <fperez@colorado.edu>
6154 6165
6155 6166 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
6156 6167 good public release, I think (with the manual and the distutils
6157 6168 installer). The manual can use some work, but that can go
6158 6169 slowly. Otherwise I think it's quite nice for end users. Next
6159 6170 summer, rewrite the guts of it...
6160 6171
6161 6172 * Changed format of ipythonrc files to use whitespace as the
6162 6173 separator instead of an explicit '='. Cleaner.
6163 6174
6164 6175 2001-12-20 Fernando Perez <fperez@colorado.edu>
6165 6176
6166 6177 * Started a manual in LyX. For now it's just a quick merge of the
6167 6178 various internal docstrings and READMEs. Later it may grow into a
6168 6179 nice, full-blown manual.
6169 6180
6170 6181 * Set up a distutils based installer. Installation should now be
6171 6182 trivially simple for end-users.
6172 6183
6173 6184 2001-12-11 Fernando Perez <fperez@colorado.edu>
6174 6185
6175 6186 * Released 0.2.0. First public release, announced it at
6176 6187 comp.lang.python. From now on, just bugfixes...
6177 6188
6178 6189 * Went through all the files, set copyright/license notices and
6179 6190 cleaned up things. Ready for release.
6180 6191
6181 6192 2001-12-10 Fernando Perez <fperez@colorado.edu>
6182 6193
6183 6194 * Changed the first-time installer not to use tarfiles. It's more
6184 6195 robust now and less unix-dependent. Also makes it easier for
6185 6196 people to later upgrade versions.
6186 6197
6187 6198 * Changed @exit to @abort to reflect the fact that it's pretty
6188 6199 brutal (a sys.exit()). The difference between @abort and Ctrl-D
6189 6200 becomes significant only when IPyhton is embedded: in that case,
6190 6201 C-D closes IPython only, but @abort kills the enclosing program
6191 6202 too (unless it had called IPython inside a try catching
6192 6203 SystemExit).
6193 6204
6194 6205 * Created Shell module which exposes the actuall IPython Shell
6195 6206 classes, currently the normal and the embeddable one. This at
6196 6207 least offers a stable interface we won't need to change when
6197 6208 (later) the internals are rewritten. That rewrite will be confined
6198 6209 to iplib and ipmaker, but the Shell interface should remain as is.
6199 6210
6200 6211 * Added embed module which offers an embeddable IPShell object,
6201 6212 useful to fire up IPython *inside* a running program. Great for
6202 6213 debugging or dynamical data analysis.
6203 6214
6204 6215 2001-12-08 Fernando Perez <fperez@colorado.edu>
6205 6216
6206 6217 * Fixed small bug preventing seeing info from methods of defined
6207 6218 objects (incorrect namespace in _ofind()).
6208 6219
6209 6220 * Documentation cleanup. Moved the main usage docstrings to a
6210 6221 separate file, usage.py (cleaner to maintain, and hopefully in the
6211 6222 future some perlpod-like way of producing interactive, man and
6212 6223 html docs out of it will be found).
6213 6224
6214 6225 * Added @profile to see your profile at any time.
6215 6226
6216 6227 * Added @p as an alias for 'print'. It's especially convenient if
6217 6228 using automagic ('p x' prints x).
6218 6229
6219 6230 * Small cleanups and fixes after a pychecker run.
6220 6231
6221 6232 * Changed the @cd command to handle @cd - and @cd -<n> for
6222 6233 visiting any directory in _dh.
6223 6234
6224 6235 * Introduced _dh, a history of visited directories. @dhist prints
6225 6236 it out with numbers.
6226 6237
6227 6238 2001-12-07 Fernando Perez <fperez@colorado.edu>
6228 6239
6229 6240 * Released 0.1.22
6230 6241
6231 6242 * Made initialization a bit more robust against invalid color
6232 6243 options in user input (exit, not traceback-crash).
6233 6244
6234 6245 * Changed the bug crash reporter to write the report only in the
6235 6246 user's .ipython directory. That way IPython won't litter people's
6236 6247 hard disks with crash files all over the place. Also print on
6237 6248 screen the necessary mail command.
6238 6249
6239 6250 * With the new ultraTB, implemented LightBG color scheme for light
6240 6251 background terminals. A lot of people like white backgrounds, so I
6241 6252 guess we should at least give them something readable.
6242 6253
6243 6254 2001-12-06 Fernando Perez <fperez@colorado.edu>
6244 6255
6245 6256 * Modified the structure of ultraTB. Now there's a proper class
6246 6257 for tables of color schemes which allow adding schemes easily and
6247 6258 switching the active scheme without creating a new instance every
6248 6259 time (which was ridiculous). The syntax for creating new schemes
6249 6260 is also cleaner. I think ultraTB is finally done, with a clean
6250 6261 class structure. Names are also much cleaner (now there's proper
6251 6262 color tables, no need for every variable to also have 'color' in
6252 6263 its name).
6253 6264
6254 6265 * Broke down genutils into separate files. Now genutils only
6255 6266 contains utility functions, and classes have been moved to their
6256 6267 own files (they had enough independent functionality to warrant
6257 6268 it): ConfigLoader, OutputTrap, Struct.
6258 6269
6259 6270 2001-12-05 Fernando Perez <fperez@colorado.edu>
6260 6271
6261 6272 * IPython turns 21! Released version 0.1.21, as a candidate for
6262 6273 public consumption. If all goes well, release in a few days.
6263 6274
6264 6275 * Fixed path bug (files in Extensions/ directory wouldn't be found
6265 6276 unless IPython/ was explicitly in sys.path).
6266 6277
6267 6278 * Extended the FlexCompleter class as MagicCompleter to allow
6268 6279 completion of @-starting lines.
6269 6280
6270 6281 * Created __release__.py file as a central repository for release
6271 6282 info that other files can read from.
6272 6283
6273 6284 * Fixed small bug in logging: when logging was turned on in
6274 6285 mid-session, old lines with special meanings (!@?) were being
6275 6286 logged without the prepended comment, which is necessary since
6276 6287 they are not truly valid python syntax. This should make session
6277 6288 restores produce less errors.
6278 6289
6279 6290 * The namespace cleanup forced me to make a FlexCompleter class
6280 6291 which is nothing but a ripoff of rlcompleter, but with selectable
6281 6292 namespace (rlcompleter only works in __main__.__dict__). I'll try
6282 6293 to submit a note to the authors to see if this change can be
6283 6294 incorporated in future rlcompleter releases (Dec.6: done)
6284 6295
6285 6296 * More fixes to namespace handling. It was a mess! Now all
6286 6297 explicit references to __main__.__dict__ are gone (except when
6287 6298 really needed) and everything is handled through the namespace
6288 6299 dicts in the IPython instance. We seem to be getting somewhere
6289 6300 with this, finally...
6290 6301
6291 6302 * Small documentation updates.
6292 6303
6293 6304 * Created the Extensions directory under IPython (with an
6294 6305 __init__.py). Put the PhysicalQ stuff there. This directory should
6295 6306 be used for all special-purpose extensions.
6296 6307
6297 6308 * File renaming:
6298 6309 ipythonlib --> ipmaker
6299 6310 ipplib --> iplib
6300 6311 This makes a bit more sense in terms of what these files actually do.
6301 6312
6302 6313 * Moved all the classes and functions in ipythonlib to ipplib, so
6303 6314 now ipythonlib only has make_IPython(). This will ease up its
6304 6315 splitting in smaller functional chunks later.
6305 6316
6306 6317 * Cleaned up (done, I think) output of @whos. Better column
6307 6318 formatting, and now shows str(var) for as much as it can, which is
6308 6319 typically what one gets with a 'print var'.
6309 6320
6310 6321 2001-12-04 Fernando Perez <fperez@colorado.edu>
6311 6322
6312 6323 * Fixed namespace problems. Now builtin/IPyhton/user names get
6313 6324 properly reported in their namespace. Internal namespace handling
6314 6325 is finally getting decent (not perfect yet, but much better than
6315 6326 the ad-hoc mess we had).
6316 6327
6317 6328 * Removed -exit option. If people just want to run a python
6318 6329 script, that's what the normal interpreter is for. Less
6319 6330 unnecessary options, less chances for bugs.
6320 6331
6321 6332 * Added a crash handler which generates a complete post-mortem if
6322 6333 IPython crashes. This will help a lot in tracking bugs down the
6323 6334 road.
6324 6335
6325 6336 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
6326 6337 which were boud to functions being reassigned would bypass the
6327 6338 logger, breaking the sync of _il with the prompt counter. This
6328 6339 would then crash IPython later when a new line was logged.
6329 6340
6330 6341 2001-12-02 Fernando Perez <fperez@colorado.edu>
6331 6342
6332 6343 * Made IPython a package. This means people don't have to clutter
6333 6344 their sys.path with yet another directory. Changed the INSTALL
6334 6345 file accordingly.
6335 6346
6336 6347 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
6337 6348 sorts its output (so @who shows it sorted) and @whos formats the
6338 6349 table according to the width of the first column. Nicer, easier to
6339 6350 read. Todo: write a generic table_format() which takes a list of
6340 6351 lists and prints it nicely formatted, with optional row/column
6341 6352 separators and proper padding and justification.
6342 6353
6343 6354 * Released 0.1.20
6344 6355
6345 6356 * Fixed bug in @log which would reverse the inputcache list (a
6346 6357 copy operation was missing).
6347 6358
6348 6359 * Code cleanup. @config was changed to use page(). Better, since
6349 6360 its output is always quite long.
6350 6361
6351 6362 * Itpl is back as a dependency. I was having too many problems
6352 6363 getting the parametric aliases to work reliably, and it's just
6353 6364 easier to code weird string operations with it than playing %()s
6354 6365 games. It's only ~6k, so I don't think it's too big a deal.
6355 6366
6356 6367 * Found (and fixed) a very nasty bug with history. !lines weren't
6357 6368 getting cached, and the out of sync caches would crash
6358 6369 IPython. Fixed it by reorganizing the prefilter/handlers/logger
6359 6370 division of labor a bit better. Bug fixed, cleaner structure.
6360 6371
6361 6372 2001-12-01 Fernando Perez <fperez@colorado.edu>
6362 6373
6363 6374 * Released 0.1.19
6364 6375
6365 6376 * Added option -n to @hist to prevent line number printing. Much
6366 6377 easier to copy/paste code this way.
6367 6378
6368 6379 * Created global _il to hold the input list. Allows easy
6369 6380 re-execution of blocks of code by slicing it (inspired by Janko's
6370 6381 comment on 'macros').
6371 6382
6372 6383 * Small fixes and doc updates.
6373 6384
6374 6385 * Rewrote @history function (was @h). Renamed it to @hist, @h is
6375 6386 much too fragile with automagic. Handles properly multi-line
6376 6387 statements and takes parameters.
6377 6388
6378 6389 2001-11-30 Fernando Perez <fperez@colorado.edu>
6379 6390
6380 6391 * Version 0.1.18 released.
6381 6392
6382 6393 * Fixed nasty namespace bug in initial module imports.
6383 6394
6384 6395 * Added copyright/license notes to all code files (except
6385 6396 DPyGetOpt). For the time being, LGPL. That could change.
6386 6397
6387 6398 * Rewrote a much nicer README, updated INSTALL, cleaned up
6388 6399 ipythonrc-* samples.
6389 6400
6390 6401 * Overall code/documentation cleanup. Basically ready for
6391 6402 release. Only remaining thing: licence decision (LGPL?).
6392 6403
6393 6404 * Converted load_config to a class, ConfigLoader. Now recursion
6394 6405 control is better organized. Doesn't include the same file twice.
6395 6406
6396 6407 2001-11-29 Fernando Perez <fperez@colorado.edu>
6397 6408
6398 6409 * Got input history working. Changed output history variables from
6399 6410 _p to _o so that _i is for input and _o for output. Just cleaner
6400 6411 convention.
6401 6412
6402 6413 * Implemented parametric aliases. This pretty much allows the
6403 6414 alias system to offer full-blown shell convenience, I think.
6404 6415
6405 6416 * Version 0.1.17 released, 0.1.18 opened.
6406 6417
6407 6418 * dot_ipython/ipythonrc (alias): added documentation.
6408 6419 (xcolor): Fixed small bug (xcolors -> xcolor)
6409 6420
6410 6421 * Changed the alias system. Now alias is a magic command to define
6411 6422 aliases just like the shell. Rationale: the builtin magics should
6412 6423 be there for things deeply connected to IPython's
6413 6424 architecture. And this is a much lighter system for what I think
6414 6425 is the really important feature: allowing users to define quickly
6415 6426 magics that will do shell things for them, so they can customize
6416 6427 IPython easily to match their work habits. If someone is really
6417 6428 desperate to have another name for a builtin alias, they can
6418 6429 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
6419 6430 works.
6420 6431
6421 6432 2001-11-28 Fernando Perez <fperez@colorado.edu>
6422 6433
6423 6434 * Changed @file so that it opens the source file at the proper
6424 6435 line. Since it uses less, if your EDITOR environment is
6425 6436 configured, typing v will immediately open your editor of choice
6426 6437 right at the line where the object is defined. Not as quick as
6427 6438 having a direct @edit command, but for all intents and purposes it
6428 6439 works. And I don't have to worry about writing @edit to deal with
6429 6440 all the editors, less does that.
6430 6441
6431 6442 * Version 0.1.16 released, 0.1.17 opened.
6432 6443
6433 6444 * Fixed some nasty bugs in the page/page_dumb combo that could
6434 6445 crash IPython.
6435 6446
6436 6447 2001-11-27 Fernando Perez <fperez@colorado.edu>
6437 6448
6438 6449 * Version 0.1.15 released, 0.1.16 opened.
6439 6450
6440 6451 * Finally got ? and ?? to work for undefined things: now it's
6441 6452 possible to type {}.get? and get information about the get method
6442 6453 of dicts, or os.path? even if only os is defined (so technically
6443 6454 os.path isn't). Works at any level. For example, after import os,
6444 6455 os?, os.path?, os.path.abspath? all work. This is great, took some
6445 6456 work in _ofind.
6446 6457
6447 6458 * Fixed more bugs with logging. The sanest way to do it was to add
6448 6459 to @log a 'mode' parameter. Killed two in one shot (this mode
6449 6460 option was a request of Janko's). I think it's finally clean
6450 6461 (famous last words).
6451 6462
6452 6463 * Added a page_dumb() pager which does a decent job of paging on
6453 6464 screen, if better things (like less) aren't available. One less
6454 6465 unix dependency (someday maybe somebody will port this to
6455 6466 windows).
6456 6467
6457 6468 * Fixed problem in magic_log: would lock of logging out if log
6458 6469 creation failed (because it would still think it had succeeded).
6459 6470
6460 6471 * Improved the page() function using curses to auto-detect screen
6461 6472 size. Now it can make a much better decision on whether to print
6462 6473 or page a string. Option screen_length was modified: a value 0
6463 6474 means auto-detect, and that's the default now.
6464 6475
6465 6476 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
6466 6477 go out. I'll test it for a few days, then talk to Janko about
6467 6478 licences and announce it.
6468 6479
6469 6480 * Fixed the length of the auto-generated ---> prompt which appears
6470 6481 for auto-parens and auto-quotes. Getting this right isn't trivial,
6471 6482 with all the color escapes, different prompt types and optional
6472 6483 separators. But it seems to be working in all the combinations.
6473 6484
6474 6485 2001-11-26 Fernando Perez <fperez@colorado.edu>
6475 6486
6476 6487 * Wrote a regexp filter to get option types from the option names
6477 6488 string. This eliminates the need to manually keep two duplicate
6478 6489 lists.
6479 6490
6480 6491 * Removed the unneeded check_option_names. Now options are handled
6481 6492 in a much saner manner and it's easy to visually check that things
6482 6493 are ok.
6483 6494
6484 6495 * Updated version numbers on all files I modified to carry a
6485 6496 notice so Janko and Nathan have clear version markers.
6486 6497
6487 6498 * Updated docstring for ultraTB with my changes. I should send
6488 6499 this to Nathan.
6489 6500
6490 6501 * Lots of small fixes. Ran everything through pychecker again.
6491 6502
6492 6503 * Made loading of deep_reload an cmd line option. If it's not too
6493 6504 kosher, now people can just disable it. With -nodeep_reload it's
6494 6505 still available as dreload(), it just won't overwrite reload().
6495 6506
6496 6507 * Moved many options to the no| form (-opt and -noopt
6497 6508 accepted). Cleaner.
6498 6509
6499 6510 * Changed magic_log so that if called with no parameters, it uses
6500 6511 'rotate' mode. That way auto-generated logs aren't automatically
6501 6512 over-written. For normal logs, now a backup is made if it exists
6502 6513 (only 1 level of backups). A new 'backup' mode was added to the
6503 6514 Logger class to support this. This was a request by Janko.
6504 6515
6505 6516 * Added @logoff/@logon to stop/restart an active log.
6506 6517
6507 6518 * Fixed a lot of bugs in log saving/replay. It was pretty
6508 6519 broken. Now special lines (!@,/) appear properly in the command
6509 6520 history after a log replay.
6510 6521
6511 6522 * Tried and failed to implement full session saving via pickle. My
6512 6523 idea was to pickle __main__.__dict__, but modules can't be
6513 6524 pickled. This would be a better alternative to replaying logs, but
6514 6525 seems quite tricky to get to work. Changed -session to be called
6515 6526 -logplay, which more accurately reflects what it does. And if we
6516 6527 ever get real session saving working, -session is now available.
6517 6528
6518 6529 * Implemented color schemes for prompts also. As for tracebacks,
6519 6530 currently only NoColor and Linux are supported. But now the
6520 6531 infrastructure is in place, based on a generic ColorScheme
6521 6532 class. So writing and activating new schemes both for the prompts
6522 6533 and the tracebacks should be straightforward.
6523 6534
6524 6535 * Version 0.1.13 released, 0.1.14 opened.
6525 6536
6526 6537 * Changed handling of options for output cache. Now counter is
6527 6538 hardwired starting at 1 and one specifies the maximum number of
6528 6539 entries *in the outcache* (not the max prompt counter). This is
6529 6540 much better, since many statements won't increase the cache
6530 6541 count. It also eliminated some confusing options, now there's only
6531 6542 one: cache_size.
6532 6543
6533 6544 * Added 'alias' magic function and magic_alias option in the
6534 6545 ipythonrc file. Now the user can easily define whatever names he
6535 6546 wants for the magic functions without having to play weird
6536 6547 namespace games. This gives IPython a real shell-like feel.
6537 6548
6538 6549 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
6539 6550 @ or not).
6540 6551
6541 6552 This was one of the last remaining 'visible' bugs (that I know
6542 6553 of). I think if I can clean up the session loading so it works
6543 6554 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
6544 6555 about licensing).
6545 6556
6546 6557 2001-11-25 Fernando Perez <fperez@colorado.edu>
6547 6558
6548 6559 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
6549 6560 there's a cleaner distinction between what ? and ?? show.
6550 6561
6551 6562 * Added screen_length option. Now the user can define his own
6552 6563 screen size for page() operations.
6553 6564
6554 6565 * Implemented magic shell-like functions with automatic code
6555 6566 generation. Now adding another function is just a matter of adding
6556 6567 an entry to a dict, and the function is dynamically generated at
6557 6568 run-time. Python has some really cool features!
6558 6569
6559 6570 * Renamed many options to cleanup conventions a little. Now all
6560 6571 are lowercase, and only underscores where needed. Also in the code
6561 6572 option name tables are clearer.
6562 6573
6563 6574 * Changed prompts a little. Now input is 'In [n]:' instead of
6564 6575 'In[n]:='. This allows it the numbers to be aligned with the
6565 6576 Out[n] numbers, and removes usage of ':=' which doesn't exist in
6566 6577 Python (it was a Mathematica thing). The '...' continuation prompt
6567 6578 was also changed a little to align better.
6568 6579
6569 6580 * Fixed bug when flushing output cache. Not all _p<n> variables
6570 6581 exist, so their deletion needs to be wrapped in a try:
6571 6582
6572 6583 * Figured out how to properly use inspect.formatargspec() (it
6573 6584 requires the args preceded by *). So I removed all the code from
6574 6585 _get_pdef in Magic, which was just replicating that.
6575 6586
6576 6587 * Added test to prefilter to allow redefining magic function names
6577 6588 as variables. This is ok, since the @ form is always available,
6578 6589 but whe should allow the user to define a variable called 'ls' if
6579 6590 he needs it.
6580 6591
6581 6592 * Moved the ToDo information from README into a separate ToDo.
6582 6593
6583 6594 * General code cleanup and small bugfixes. I think it's close to a
6584 6595 state where it can be released, obviously with a big 'beta'
6585 6596 warning on it.
6586 6597
6587 6598 * Got the magic function split to work. Now all magics are defined
6588 6599 in a separate class. It just organizes things a bit, and now
6589 6600 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
6590 6601 was too long).
6591 6602
6592 6603 * Changed @clear to @reset to avoid potential confusions with
6593 6604 the shell command clear. Also renamed @cl to @clear, which does
6594 6605 exactly what people expect it to from their shell experience.
6595 6606
6596 6607 Added a check to the @reset command (since it's so
6597 6608 destructive, it's probably a good idea to ask for confirmation).
6598 6609 But now reset only works for full namespace resetting. Since the
6599 6610 del keyword is already there for deleting a few specific
6600 6611 variables, I don't see the point of having a redundant magic
6601 6612 function for the same task.
6602 6613
6603 6614 2001-11-24 Fernando Perez <fperez@colorado.edu>
6604 6615
6605 6616 * Updated the builtin docs (esp. the ? ones).
6606 6617
6607 6618 * Ran all the code through pychecker. Not terribly impressed with
6608 6619 it: lots of spurious warnings and didn't really find anything of
6609 6620 substance (just a few modules being imported and not used).
6610 6621
6611 6622 * Implemented the new ultraTB functionality into IPython. New
6612 6623 option: xcolors. This chooses color scheme. xmode now only selects
6613 6624 between Plain and Verbose. Better orthogonality.
6614 6625
6615 6626 * Large rewrite of ultraTB. Much cleaner now, with a separation of
6616 6627 mode and color scheme for the exception handlers. Now it's
6617 6628 possible to have the verbose traceback with no coloring.
6618 6629
6619 6630 2001-11-23 Fernando Perez <fperez@colorado.edu>
6620 6631
6621 6632 * Version 0.1.12 released, 0.1.13 opened.
6622 6633
6623 6634 * Removed option to set auto-quote and auto-paren escapes by
6624 6635 user. The chances of breaking valid syntax are just too high. If
6625 6636 someone *really* wants, they can always dig into the code.
6626 6637
6627 6638 * Made prompt separators configurable.
6628 6639
6629 6640 2001-11-22 Fernando Perez <fperez@colorado.edu>
6630 6641
6631 6642 * Small bugfixes in many places.
6632 6643
6633 6644 * Removed the MyCompleter class from ipplib. It seemed redundant
6634 6645 with the C-p,C-n history search functionality. Less code to
6635 6646 maintain.
6636 6647
6637 6648 * Moved all the original ipython.py code into ipythonlib.py. Right
6638 6649 now it's just one big dump into a function called make_IPython, so
6639 6650 no real modularity has been gained. But at least it makes the
6640 6651 wrapper script tiny, and since ipythonlib is a module, it gets
6641 6652 compiled and startup is much faster.
6642 6653
6643 6654 This is a reasobably 'deep' change, so we should test it for a
6644 6655 while without messing too much more with the code.
6645 6656
6646 6657 2001-11-21 Fernando Perez <fperez@colorado.edu>
6647 6658
6648 6659 * Version 0.1.11 released, 0.1.12 opened for further work.
6649 6660
6650 6661 * Removed dependency on Itpl. It was only needed in one place. It
6651 6662 would be nice if this became part of python, though. It makes life
6652 6663 *a lot* easier in some cases.
6653 6664
6654 6665 * Simplified the prefilter code a bit. Now all handlers are
6655 6666 expected to explicitly return a value (at least a blank string).
6656 6667
6657 6668 * Heavy edits in ipplib. Removed the help system altogether. Now
6658 6669 obj?/?? is used for inspecting objects, a magic @doc prints
6659 6670 docstrings, and full-blown Python help is accessed via the 'help'
6660 6671 keyword. This cleans up a lot of code (less to maintain) and does
6661 6672 the job. Since 'help' is now a standard Python component, might as
6662 6673 well use it and remove duplicate functionality.
6663 6674
6664 6675 Also removed the option to use ipplib as a standalone program. By
6665 6676 now it's too dependent on other parts of IPython to function alone.
6666 6677
6667 6678 * Fixed bug in genutils.pager. It would crash if the pager was
6668 6679 exited immediately after opening (broken pipe).
6669 6680
6670 6681 * Trimmed down the VerboseTB reporting a little. The header is
6671 6682 much shorter now and the repeated exception arguments at the end
6672 6683 have been removed. For interactive use the old header seemed a bit
6673 6684 excessive.
6674 6685
6675 6686 * Fixed small bug in output of @whos for variables with multi-word
6676 6687 types (only first word was displayed).
6677 6688
6678 6689 2001-11-17 Fernando Perez <fperez@colorado.edu>
6679 6690
6680 6691 * Version 0.1.10 released, 0.1.11 opened for further work.
6681 6692
6682 6693 * Modified dirs and friends. dirs now *returns* the stack (not
6683 6694 prints), so one can manipulate it as a variable. Convenient to
6684 6695 travel along many directories.
6685 6696
6686 6697 * Fixed bug in magic_pdef: would only work with functions with
6687 6698 arguments with default values.
6688 6699
6689 6700 2001-11-14 Fernando Perez <fperez@colorado.edu>
6690 6701
6691 6702 * Added the PhysicsInput stuff to dot_ipython so it ships as an
6692 6703 example with IPython. Various other minor fixes and cleanups.
6693 6704
6694 6705 * Version 0.1.9 released, 0.1.10 opened for further work.
6695 6706
6696 6707 * Added sys.path to the list of directories searched in the
6697 6708 execfile= option. It used to be the current directory and the
6698 6709 user's IPYTHONDIR only.
6699 6710
6700 6711 2001-11-13 Fernando Perez <fperez@colorado.edu>
6701 6712
6702 6713 * Reinstated the raw_input/prefilter separation that Janko had
6703 6714 initially. This gives a more convenient setup for extending the
6704 6715 pre-processor from the outside: raw_input always gets a string,
6705 6716 and prefilter has to process it. We can then redefine prefilter
6706 6717 from the outside and implement extensions for special
6707 6718 purposes.
6708 6719
6709 6720 Today I got one for inputting PhysicalQuantity objects
6710 6721 (from Scientific) without needing any function calls at
6711 6722 all. Extremely convenient, and it's all done as a user-level
6712 6723 extension (no IPython code was touched). Now instead of:
6713 6724 a = PhysicalQuantity(4.2,'m/s**2')
6714 6725 one can simply say
6715 6726 a = 4.2 m/s**2
6716 6727 or even
6717 6728 a = 4.2 m/s^2
6718 6729
6719 6730 I use this, but it's also a proof of concept: IPython really is
6720 6731 fully user-extensible, even at the level of the parsing of the
6721 6732 command line. It's not trivial, but it's perfectly doable.
6722 6733
6723 6734 * Added 'add_flip' method to inclusion conflict resolver. Fixes
6724 6735 the problem of modules being loaded in the inverse order in which
6725 6736 they were defined in
6726 6737
6727 6738 * Version 0.1.8 released, 0.1.9 opened for further work.
6728 6739
6729 6740 * Added magics pdef, source and file. They respectively show the
6730 6741 definition line ('prototype' in C), source code and full python
6731 6742 file for any callable object. The object inspector oinfo uses
6732 6743 these to show the same information.
6733 6744
6734 6745 * Version 0.1.7 released, 0.1.8 opened for further work.
6735 6746
6736 6747 * Separated all the magic functions into a class called Magic. The
6737 6748 InteractiveShell class was becoming too big for Xemacs to handle
6738 6749 (de-indenting a line would lock it up for 10 seconds while it
6739 6750 backtracked on the whole class!)
6740 6751
6741 6752 FIXME: didn't work. It can be done, but right now namespaces are
6742 6753 all messed up. Do it later (reverted it for now, so at least
6743 6754 everything works as before).
6744 6755
6745 6756 * Got the object introspection system (magic_oinfo) working! I
6746 6757 think this is pretty much ready for release to Janko, so he can
6747 6758 test it for a while and then announce it. Pretty much 100% of what
6748 6759 I wanted for the 'phase 1' release is ready. Happy, tired.
6749 6760
6750 6761 2001-11-12 Fernando Perez <fperez@colorado.edu>
6751 6762
6752 6763 * Version 0.1.6 released, 0.1.7 opened for further work.
6753 6764
6754 6765 * Fixed bug in printing: it used to test for truth before
6755 6766 printing, so 0 wouldn't print. Now checks for None.
6756 6767
6757 6768 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
6758 6769 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
6759 6770 reaches by hand into the outputcache. Think of a better way to do
6760 6771 this later.
6761 6772
6762 6773 * Various small fixes thanks to Nathan's comments.
6763 6774
6764 6775 * Changed magic_pprint to magic_Pprint. This way it doesn't
6765 6776 collide with pprint() and the name is consistent with the command
6766 6777 line option.
6767 6778
6768 6779 * Changed prompt counter behavior to be fully like
6769 6780 Mathematica's. That is, even input that doesn't return a result
6770 6781 raises the prompt counter. The old behavior was kind of confusing
6771 6782 (getting the same prompt number several times if the operation
6772 6783 didn't return a result).
6773 6784
6774 6785 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
6775 6786
6776 6787 * Fixed -Classic mode (wasn't working anymore).
6777 6788
6778 6789 * Added colored prompts using Nathan's new code. Colors are
6779 6790 currently hardwired, they can be user-configurable. For
6780 6791 developers, they can be chosen in file ipythonlib.py, at the
6781 6792 beginning of the CachedOutput class def.
6782 6793
6783 6794 2001-11-11 Fernando Perez <fperez@colorado.edu>
6784 6795
6785 6796 * Version 0.1.5 released, 0.1.6 opened for further work.
6786 6797
6787 6798 * Changed magic_env to *return* the environment as a dict (not to
6788 6799 print it). This way it prints, but it can also be processed.
6789 6800
6790 6801 * Added Verbose exception reporting to interactive
6791 6802 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
6792 6803 traceback. Had to make some changes to the ultraTB file. This is
6793 6804 probably the last 'big' thing in my mental todo list. This ties
6794 6805 in with the next entry:
6795 6806
6796 6807 * Changed -Xi and -Xf to a single -xmode option. Now all the user
6797 6808 has to specify is Plain, Color or Verbose for all exception
6798 6809 handling.
6799 6810
6800 6811 * Removed ShellServices option. All this can really be done via
6801 6812 the magic system. It's easier to extend, cleaner and has automatic
6802 6813 namespace protection and documentation.
6803 6814
6804 6815 2001-11-09 Fernando Perez <fperez@colorado.edu>
6805 6816
6806 6817 * Fixed bug in output cache flushing (missing parameter to
6807 6818 __init__). Other small bugs fixed (found using pychecker).
6808 6819
6809 6820 * Version 0.1.4 opened for bugfixing.
6810 6821
6811 6822 2001-11-07 Fernando Perez <fperez@colorado.edu>
6812 6823
6813 6824 * Version 0.1.3 released, mainly because of the raw_input bug.
6814 6825
6815 6826 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
6816 6827 and when testing for whether things were callable, a call could
6817 6828 actually be made to certain functions. They would get called again
6818 6829 once 'really' executed, with a resulting double call. A disaster
6819 6830 in many cases (list.reverse() would never work!).
6820 6831
6821 6832 * Removed prefilter() function, moved its code to raw_input (which
6822 6833 after all was just a near-empty caller for prefilter). This saves
6823 6834 a function call on every prompt, and simplifies the class a tiny bit.
6824 6835
6825 6836 * Fix _ip to __ip name in magic example file.
6826 6837
6827 6838 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
6828 6839 work with non-gnu versions of tar.
6829 6840
6830 6841 2001-11-06 Fernando Perez <fperez@colorado.edu>
6831 6842
6832 6843 * Version 0.1.2. Just to keep track of the recent changes.
6833 6844
6834 6845 * Fixed nasty bug in output prompt routine. It used to check 'if
6835 6846 arg != None...'. Problem is, this fails if arg implements a
6836 6847 special comparison (__cmp__) which disallows comparing to
6837 6848 None. Found it when trying to use the PhysicalQuantity module from
6838 6849 ScientificPython.
6839 6850
6840 6851 2001-11-05 Fernando Perez <fperez@colorado.edu>
6841 6852
6842 6853 * Also added dirs. Now the pushd/popd/dirs family functions
6843 6854 basically like the shell, with the added convenience of going home
6844 6855 when called with no args.
6845 6856
6846 6857 * pushd/popd slightly modified to mimic shell behavior more
6847 6858 closely.
6848 6859
6849 6860 * Added env,pushd,popd from ShellServices as magic functions. I
6850 6861 think the cleanest will be to port all desired functions from
6851 6862 ShellServices as magics and remove ShellServices altogether. This
6852 6863 will provide a single, clean way of adding functionality
6853 6864 (shell-type or otherwise) to IP.
6854 6865
6855 6866 2001-11-04 Fernando Perez <fperez@colorado.edu>
6856 6867
6857 6868 * Added .ipython/ directory to sys.path. This way users can keep
6858 6869 customizations there and access them via import.
6859 6870
6860 6871 2001-11-03 Fernando Perez <fperez@colorado.edu>
6861 6872
6862 6873 * Opened version 0.1.1 for new changes.
6863 6874
6864 6875 * Changed version number to 0.1.0: first 'public' release, sent to
6865 6876 Nathan and Janko.
6866 6877
6867 6878 * Lots of small fixes and tweaks.
6868 6879
6869 6880 * Minor changes to whos format. Now strings are shown, snipped if
6870 6881 too long.
6871 6882
6872 6883 * Changed ShellServices to work on __main__ so they show up in @who
6873 6884
6874 6885 * Help also works with ? at the end of a line:
6875 6886 ?sin and sin?
6876 6887 both produce the same effect. This is nice, as often I use the
6877 6888 tab-complete to find the name of a method, but I used to then have
6878 6889 to go to the beginning of the line to put a ? if I wanted more
6879 6890 info. Now I can just add the ? and hit return. Convenient.
6880 6891
6881 6892 2001-11-02 Fernando Perez <fperez@colorado.edu>
6882 6893
6883 6894 * Python version check (>=2.1) added.
6884 6895
6885 6896 * Added LazyPython documentation. At this point the docs are quite
6886 6897 a mess. A cleanup is in order.
6887 6898
6888 6899 * Auto-installer created. For some bizarre reason, the zipfiles
6889 6900 module isn't working on my system. So I made a tar version
6890 6901 (hopefully the command line options in various systems won't kill
6891 6902 me).
6892 6903
6893 6904 * Fixes to Struct in genutils. Now all dictionary-like methods are
6894 6905 protected (reasonably).
6895 6906
6896 6907 * Added pager function to genutils and changed ? to print usage
6897 6908 note through it (it was too long).
6898 6909
6899 6910 * Added the LazyPython functionality. Works great! I changed the
6900 6911 auto-quote escape to ';', it's on home row and next to '. But
6901 6912 both auto-quote and auto-paren (still /) escapes are command-line
6902 6913 parameters.
6903 6914
6904 6915
6905 6916 2001-11-01 Fernando Perez <fperez@colorado.edu>
6906 6917
6907 6918 * Version changed to 0.0.7. Fairly large change: configuration now
6908 6919 is all stored in a directory, by default .ipython. There, all
6909 6920 config files have normal looking names (not .names)
6910 6921
6911 6922 * Version 0.0.6 Released first to Lucas and Archie as a test
6912 6923 run. Since it's the first 'semi-public' release, change version to
6913 6924 > 0.0.6 for any changes now.
6914 6925
6915 6926 * Stuff I had put in the ipplib.py changelog:
6916 6927
6917 6928 Changes to InteractiveShell:
6918 6929
6919 6930 - Made the usage message a parameter.
6920 6931
6921 6932 - Require the name of the shell variable to be given. It's a bit
6922 6933 of a hack, but allows the name 'shell' not to be hardwired in the
6923 6934 magic (@) handler, which is problematic b/c it requires
6924 6935 polluting the global namespace with 'shell'. This in turn is
6925 6936 fragile: if a user redefines a variable called shell, things
6926 6937 break.
6927 6938
6928 6939 - magic @: all functions available through @ need to be defined
6929 6940 as magic_<name>, even though they can be called simply as
6930 6941 @<name>. This allows the special command @magic to gather
6931 6942 information automatically about all existing magic functions,
6932 6943 even if they are run-time user extensions, by parsing the shell
6933 6944 instance __dict__ looking for special magic_ names.
6934 6945
6935 6946 - mainloop: added *two* local namespace parameters. This allows
6936 6947 the class to differentiate between parameters which were there
6937 6948 before and after command line initialization was processed. This
6938 6949 way, later @who can show things loaded at startup by the
6939 6950 user. This trick was necessary to make session saving/reloading
6940 6951 really work: ideally after saving/exiting/reloading a session,
6941 6952 *everything* should look the same, including the output of @who. I
6942 6953 was only able to make this work with this double namespace
6943 6954 trick.
6944 6955
6945 6956 - added a header to the logfile which allows (almost) full
6946 6957 session restoring.
6947 6958
6948 6959 - prepend lines beginning with @ or !, with a and log
6949 6960 them. Why? !lines: may be useful to know what you did @lines:
6950 6961 they may affect session state. So when restoring a session, at
6951 6962 least inform the user of their presence. I couldn't quite get
6952 6963 them to properly re-execute, but at least the user is warned.
6953 6964
6954 6965 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now