##// END OF EJS Templates
- improve support for tab-completion under emacs...
fperez -
Show More
@@ -1,2677 +1,2690 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Magic functions for InteractiveShell.
2 """Magic functions for InteractiveShell.
3
3
4 $Id: Magic.py 984 2005-12-31 08:40:31Z fperez $"""
4 $Id: Magic.py 986 2005-12-31 23:07:31Z fperez $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
8 # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
8 # Copyright (C) 2001-2004 Fernando Perez <fperez@colorado.edu>
9 #
9 #
10 # Distributed under the terms of the BSD License. The full license is in
10 # Distributed under the terms of the BSD License. The full license is in
11 # the file COPYING, distributed as part of this software.
11 # the file COPYING, distributed as part of this software.
12 #*****************************************************************************
12 #*****************************************************************************
13
13
14 #****************************************************************************
14 #****************************************************************************
15 # Modules and globals
15 # Modules and globals
16
16
17 from IPython import Release
17 from IPython import Release
18 __author__ = '%s <%s>\n%s <%s>' % \
18 __author__ = '%s <%s>\n%s <%s>' % \
19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
19 ( Release.authors['Janko'] + Release.authors['Fernando'] )
20 __license__ = Release.license
20 __license__ = Release.license
21
21
22 # Python standard modules
22 # Python standard modules
23 import __builtin__
23 import __builtin__
24 import bdb
24 import bdb
25 import inspect
25 import inspect
26 import os
26 import os
27 import pdb
27 import pdb
28 import pydoc
28 import pydoc
29 import sys
29 import sys
30 import re
30 import re
31 import tempfile
31 import tempfile
32 import time
32 import time
33 import cPickle as pickle
33 import cPickle as pickle
34 from cStringIO import StringIO
34 from cStringIO import StringIO
35 from getopt import getopt
35 from getopt import getopt
36 from pprint import pprint, pformat
36 from pprint import pprint, pformat
37
37
38 # profile isn't bundled by default in Debian for license reasons
38 # profile isn't bundled by default in Debian for license reasons
39 try:
39 try:
40 import profile,pstats
40 import profile,pstats
41 except ImportError:
41 except ImportError:
42 profile = pstats = None
42 profile = pstats = None
43
43
44 # Homebrewed
44 # Homebrewed
45 from IPython import Debugger, OInspect, wildcard
45 from IPython import Debugger, OInspect, wildcard
46 from IPython.FakeModule import FakeModule
46 from IPython.FakeModule import FakeModule
47 from IPython.Itpl import Itpl, itpl, printpl,itplns
47 from IPython.Itpl import Itpl, itpl, printpl,itplns
48 from IPython.PyColorize import Parser
48 from IPython.PyColorize import Parser
49 from IPython.Struct import Struct
49 from IPython.Struct import Struct
50 from IPython.macro import Macro
50 from IPython.macro import Macro
51 from IPython.genutils import *
51 from IPython.genutils import *
52
52
53 #***************************************************************************
53 #***************************************************************************
54 # Utility functions
54 # Utility functions
55 def on_off(tag):
55 def on_off(tag):
56 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
56 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
57 return ['OFF','ON'][tag]
57 return ['OFF','ON'][tag]
58
58
59
59
60 #***************************************************************************
60 #***************************************************************************
61 # Main class implementing Magic functionality
61 # Main class implementing Magic functionality
62 class Magic:
62 class Magic:
63 """Magic functions for InteractiveShell.
63 """Magic functions for InteractiveShell.
64
64
65 Shell functions which can be reached as %function_name. All magic
65 Shell functions which can be reached as %function_name. All magic
66 functions should accept a string, which they can parse for their own
66 functions should accept a string, which they can parse for their own
67 needs. This can make some functions easier to type, eg `%cd ../`
67 needs. This can make some functions easier to type, eg `%cd ../`
68 vs. `%cd("../")`
68 vs. `%cd("../")`
69
69
70 ALL definitions MUST begin with the prefix magic_. The user won't need it
70 ALL definitions MUST begin with the prefix magic_. The user won't need it
71 at the command line, but it is is needed in the definition. """
71 at the command line, but it is is needed in the definition. """
72
72
73 # class globals
73 # class globals
74 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
74 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
75 'Automagic is ON, % prefix NOT needed for magic functions.']
75 'Automagic is ON, % prefix NOT needed for magic functions.']
76
76
77 #......................................................................
77 #......................................................................
78 # some utility functions
78 # some utility functions
79
79
80 def __init__(self,shell):
80 def __init__(self,shell):
81
81
82 self.options_table = {}
82 self.options_table = {}
83 if profile is None:
83 if profile is None:
84 self.magic_prun = self.profile_missing_notice
84 self.magic_prun = self.profile_missing_notice
85 self.shell = shell
85 self.shell = shell
86
86
87 def profile_missing_notice(self, *args, **kwargs):
87 def profile_missing_notice(self, *args, **kwargs):
88 error("""\
88 error("""\
89 The profile module could not be found. If you are a Debian user,
89 The profile module could not be found. If you are a Debian user,
90 it has been removed from the standard Debian package because of its non-free
90 it has been removed from the standard Debian package because of its non-free
91 license. To use profiling, please install"python2.3-profiler" from non-free.""")
91 license. To use profiling, please install"python2.3-profiler" from non-free.""")
92
92
93 def default_option(self,fn,optstr):
93 def default_option(self,fn,optstr):
94 """Make an entry in the options_table for fn, with value optstr"""
94 """Make an entry in the options_table for fn, with value optstr"""
95
95
96 if fn not in self.lsmagic():
96 if fn not in self.lsmagic():
97 error("%s is not a magic function" % fn)
97 error("%s is not a magic function" % fn)
98 self.options_table[fn] = optstr
98 self.options_table[fn] = optstr
99
99
100 def lsmagic(self):
100 def lsmagic(self):
101 """Return a list of currently available magic functions.
101 """Return a list of currently available magic functions.
102
102
103 Gives a list of the bare names after mangling (['ls','cd', ...], not
103 Gives a list of the bare names after mangling (['ls','cd', ...], not
104 ['magic_ls','magic_cd',...]"""
104 ['magic_ls','magic_cd',...]"""
105
105
106 # FIXME. This needs a cleanup, in the way the magics list is built.
106 # FIXME. This needs a cleanup, in the way the magics list is built.
107
107
108 # magics in class definition
108 # magics in class definition
109 class_magic = lambda fn: fn.startswith('magic_') and \
109 class_magic = lambda fn: fn.startswith('magic_') and \
110 callable(Magic.__dict__[fn])
110 callable(Magic.__dict__[fn])
111 # in instance namespace (run-time user additions)
111 # in instance namespace (run-time user additions)
112 inst_magic = lambda fn: fn.startswith('magic_') and \
112 inst_magic = lambda fn: fn.startswith('magic_') and \
113 callable(self.__dict__[fn])
113 callable(self.__dict__[fn])
114 # and bound magics by user (so they can access self):
114 # and bound magics by user (so they can access self):
115 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
115 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
116 callable(self.__class__.__dict__[fn])
116 callable(self.__class__.__dict__[fn])
117 magics = filter(class_magic,Magic.__dict__.keys()) + \
117 magics = filter(class_magic,Magic.__dict__.keys()) + \
118 filter(inst_magic,self.__dict__.keys()) + \
118 filter(inst_magic,self.__dict__.keys()) + \
119 filter(inst_bound_magic,self.__class__.__dict__.keys())
119 filter(inst_bound_magic,self.__class__.__dict__.keys())
120 out = []
120 out = []
121 for fn in magics:
121 for fn in magics:
122 out.append(fn.replace('magic_','',1))
122 out.append(fn.replace('magic_','',1))
123 out.sort()
123 out.sort()
124 return out
124 return out
125
125
126 def extract_input_slices(self,slices):
126 def extract_input_slices(self,slices):
127 """Return as a string a set of input history slices.
127 """Return as a string a set of input history slices.
128
128
129 The set of slices is given as a list of strings (like ['1','4:8','9'],
129 The set of slices is given as a list of strings (like ['1','4:8','9'],
130 since this function is for use by magic functions which get their
130 since this function is for use by magic functions which get their
131 arguments as strings."""
131 arguments as strings.
132
133 Note that slices can be called with two notations:
134
135 N:M -> standard python form, means including items N...(M-1).
136
137 N-M -> include items N..M (closed endpoint)."""
132
138
133 cmds = []
139 cmds = []
134 for chunk in slices:
140 for chunk in slices:
135 if ':' in chunk:
141 if ':' in chunk:
136 ini,fin = map(int,chunk.split(':'))
142 ini,fin = map(int,chunk.split(':'))
143 elif '-' in chunk:
144 ini,fin = map(int,chunk.split('-'))
145 fin += 1
137 else:
146 else:
138 ini = int(chunk)
147 ini = int(chunk)
139 fin = ini+1
148 fin = ini+1
140 cmds.append(self.shell.input_hist[ini:fin])
149 cmds.append(self.shell.input_hist[ini:fin])
141 return cmds
150 return cmds
142
151
143 def _ofind(self,oname):
152 def _ofind(self,oname):
144 """Find an object in the available namespaces.
153 """Find an object in the available namespaces.
145
154
146 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
155 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
147
156
148 Has special code to detect magic functions.
157 Has special code to detect magic functions.
149 """
158 """
150
159
151 oname = oname.strip()
160 oname = oname.strip()
152
161
153 # Namespaces to search in:
162 # Namespaces to search in:
154 user_ns = self.shell.user_ns
163 user_ns = self.shell.user_ns
155 internal_ns = self.shell.internal_ns
164 internal_ns = self.shell.internal_ns
156 builtin_ns = __builtin__.__dict__
165 builtin_ns = __builtin__.__dict__
157 alias_ns = self.shell.alias_table
166 alias_ns = self.shell.alias_table
158
167
159 # Put them in a list. The order is important so that we find things in
168 # Put them in a list. The order is important so that we find things in
160 # the same order that Python finds them.
169 # the same order that Python finds them.
161 namespaces = [ ('Interactive',user_ns),
170 namespaces = [ ('Interactive',user_ns),
162 ('IPython internal',internal_ns),
171 ('IPython internal',internal_ns),
163 ('Python builtin',builtin_ns),
172 ('Python builtin',builtin_ns),
164 ('Alias',alias_ns),
173 ('Alias',alias_ns),
165 ]
174 ]
166
175
167 # initialize results to 'null'
176 # initialize results to 'null'
168 found = 0; obj = None; ospace = None; ds = None;
177 found = 0; obj = None; ospace = None; ds = None;
169 ismagic = 0; isalias = 0
178 ismagic = 0; isalias = 0
170
179
171 # Look for the given name by splitting it in parts. If the head is
180 # Look for the given name by splitting it in parts. If the head is
172 # found, then we look for all the remaining parts as members, and only
181 # found, then we look for all the remaining parts as members, and only
173 # declare success if we can find them all.
182 # declare success if we can find them all.
174 oname_parts = oname.split('.')
183 oname_parts = oname.split('.')
175 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
184 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
176 for nsname,ns in namespaces:
185 for nsname,ns in namespaces:
177 try:
186 try:
178 obj = ns[oname_head]
187 obj = ns[oname_head]
179 except KeyError:
188 except KeyError:
180 continue
189 continue
181 else:
190 else:
182 for part in oname_rest:
191 for part in oname_rest:
183 try:
192 try:
184 obj = getattr(obj,part)
193 obj = getattr(obj,part)
185 except:
194 except:
186 # Blanket except b/c some badly implemented objects
195 # Blanket except b/c some badly implemented objects
187 # allow __getattr__ to raise exceptions other than
196 # allow __getattr__ to raise exceptions other than
188 # AttributeError, which then crashes IPython.
197 # AttributeError, which then crashes IPython.
189 break
198 break
190 else:
199 else:
191 # If we finish the for loop (no break), we got all members
200 # If we finish the for loop (no break), we got all members
192 found = 1
201 found = 1
193 ospace = nsname
202 ospace = nsname
194 if ns == alias_ns:
203 if ns == alias_ns:
195 isalias = 1
204 isalias = 1
196 break # namespace loop
205 break # namespace loop
197
206
198 # Try to see if it's magic
207 # Try to see if it's magic
199 if not found:
208 if not found:
200 if oname.startswith(self.shell.ESC_MAGIC):
209 if oname.startswith(self.shell.ESC_MAGIC):
201 oname = oname[1:]
210 oname = oname[1:]
202 obj = getattr(self,'magic_'+oname,None)
211 obj = getattr(self,'magic_'+oname,None)
203 if obj is not None:
212 if obj is not None:
204 found = 1
213 found = 1
205 ospace = 'IPython internal'
214 ospace = 'IPython internal'
206 ismagic = 1
215 ismagic = 1
207
216
208 # Last try: special-case some literals like '', [], {}, etc:
217 # Last try: special-case some literals like '', [], {}, etc:
209 if not found and oname_head in ["''",'""','[]','{}','()']:
218 if not found and oname_head in ["''",'""','[]','{}','()']:
210 obj = eval(oname_head)
219 obj = eval(oname_head)
211 found = 1
220 found = 1
212 ospace = 'Interactive'
221 ospace = 'Interactive'
213
222
214 return {'found':found, 'obj':obj, 'namespace':ospace,
223 return {'found':found, 'obj':obj, 'namespace':ospace,
215 'ismagic':ismagic, 'isalias':isalias}
224 'ismagic':ismagic, 'isalias':isalias}
216
225
217 def arg_err(self,func):
226 def arg_err(self,func):
218 """Print docstring if incorrect arguments were passed"""
227 """Print docstring if incorrect arguments were passed"""
219 print 'Error in arguments:'
228 print 'Error in arguments:'
220 print OInspect.getdoc(func)
229 print OInspect.getdoc(func)
221
230
222 def format_latex(self,strng):
231 def format_latex(self,strng):
223 """Format a string for latex inclusion."""
232 """Format a string for latex inclusion."""
224
233
225 # Characters that need to be escaped for latex:
234 # Characters that need to be escaped for latex:
226 escape_re = re.compile(r'(%|_|\$|#)',re.MULTILINE)
235 escape_re = re.compile(r'(%|_|\$|#)',re.MULTILINE)
227 # Magic command names as headers:
236 # Magic command names as headers:
228 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
237 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
229 re.MULTILINE)
238 re.MULTILINE)
230 # Magic commands
239 # Magic commands
231 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
240 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
232 re.MULTILINE)
241 re.MULTILINE)
233 # Paragraph continue
242 # Paragraph continue
234 par_re = re.compile(r'\\$',re.MULTILINE)
243 par_re = re.compile(r'\\$',re.MULTILINE)
235
244
236 # The "\n" symbol
245 # The "\n" symbol
237 newline_re = re.compile(r'\\n')
246 newline_re = re.compile(r'\\n')
238
247
239 # Now build the string for output:
248 # Now build the string for output:
240 strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng)
249 strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng)
241 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
250 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
242 strng = par_re.sub(r'\\\\',strng)
251 strng = par_re.sub(r'\\\\',strng)
243 strng = escape_re.sub(r'\\\1',strng)
252 strng = escape_re.sub(r'\\\1',strng)
244 strng = newline_re.sub(r'\\textbackslash{}n',strng)
253 strng = newline_re.sub(r'\\textbackslash{}n',strng)
245 return strng
254 return strng
246
255
247 def format_screen(self,strng):
256 def format_screen(self,strng):
248 """Format a string for screen printing.
257 """Format a string for screen printing.
249
258
250 This removes some latex-type format codes."""
259 This removes some latex-type format codes."""
251 # Paragraph continue
260 # Paragraph continue
252 par_re = re.compile(r'\\$',re.MULTILINE)
261 par_re = re.compile(r'\\$',re.MULTILINE)
253 strng = par_re.sub('',strng)
262 strng = par_re.sub('',strng)
254 return strng
263 return strng
255
264
256 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
265 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
257 """Parse options passed to an argument string.
266 """Parse options passed to an argument string.
258
267
259 The interface is similar to that of getopt(), but it returns back a
268 The interface is similar to that of getopt(), but it returns back a
260 Struct with the options as keys and the stripped argument string still
269 Struct with the options as keys and the stripped argument string still
261 as a string.
270 as a string.
262
271
263 arg_str is quoted as a true sys.argv vector by using shlex.split.
272 arg_str is quoted as a true sys.argv vector by using shlex.split.
264 This allows us to easily expand variables, glob files, quote
273 This allows us to easily expand variables, glob files, quote
265 arguments, etc.
274 arguments, etc.
266
275
267 Options:
276 Options:
268 -mode: default 'string'. If given as 'list', the argument string is
277 -mode: default 'string'. If given as 'list', the argument string is
269 returned as a list (split on whitespace) instead of a string.
278 returned as a list (split on whitespace) instead of a string.
270
279
271 -list_all: put all option values in lists. Normally only options
280 -list_all: put all option values in lists. Normally only options
272 appearing more than once are put in a list."""
281 appearing more than once are put in a list."""
273
282
274 # inject default options at the beginning of the input line
283 # inject default options at the beginning of the input line
275 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
284 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
276 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
285 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
277
286
278 mode = kw.get('mode','string')
287 mode = kw.get('mode','string')
279 if mode not in ['string','list']:
288 if mode not in ['string','list']:
280 raise ValueError,'incorrect mode given: %s' % mode
289 raise ValueError,'incorrect mode given: %s' % mode
281 # Get options
290 # Get options
282 list_all = kw.get('list_all',0)
291 list_all = kw.get('list_all',0)
283
292
284 # Check if we have more than one argument to warrant extra processing:
293 # Check if we have more than one argument to warrant extra processing:
285 odict = {} # Dictionary with options
294 odict = {} # Dictionary with options
286 args = arg_str.split()
295 args = arg_str.split()
287 if len(args) >= 1:
296 if len(args) >= 1:
288 # If the list of inputs only has 0 or 1 thing in it, there's no
297 # If the list of inputs only has 0 or 1 thing in it, there's no
289 # need to look for options
298 # need to look for options
290 argv = shlex_split(arg_str)
299 argv = shlex_split(arg_str)
291 # Do regular option processing
300 # Do regular option processing
292 opts,args = getopt(argv,opt_str,*long_opts)
301 opts,args = getopt(argv,opt_str,*long_opts)
293 for o,a in opts:
302 for o,a in opts:
294 if o.startswith('--'):
303 if o.startswith('--'):
295 o = o[2:]
304 o = o[2:]
296 else:
305 else:
297 o = o[1:]
306 o = o[1:]
298 try:
307 try:
299 odict[o].append(a)
308 odict[o].append(a)
300 except AttributeError:
309 except AttributeError:
301 odict[o] = [odict[o],a]
310 odict[o] = [odict[o],a]
302 except KeyError:
311 except KeyError:
303 if list_all:
312 if list_all:
304 odict[o] = [a]
313 odict[o] = [a]
305 else:
314 else:
306 odict[o] = a
315 odict[o] = a
307
316
308 # Prepare opts,args for return
317 # Prepare opts,args for return
309 opts = Struct(odict)
318 opts = Struct(odict)
310 if mode == 'string':
319 if mode == 'string':
311 args = ' '.join(args)
320 args = ' '.join(args)
312
321
313 return opts,args
322 return opts,args
314
323
315 #......................................................................
324 #......................................................................
316 # And now the actual magic functions
325 # And now the actual magic functions
317
326
318 # Functions for IPython shell work (vars,funcs, config, etc)
327 # Functions for IPython shell work (vars,funcs, config, etc)
319 def magic_lsmagic(self, parameter_s = ''):
328 def magic_lsmagic(self, parameter_s = ''):
320 """List currently available magic functions."""
329 """List currently available magic functions."""
321 mesc = self.shell.ESC_MAGIC
330 mesc = self.shell.ESC_MAGIC
322 print 'Available magic functions:\n'+mesc+\
331 print 'Available magic functions:\n'+mesc+\
323 (' '+mesc).join(self.lsmagic())
332 (' '+mesc).join(self.lsmagic())
324 print '\n' + Magic.auto_status[self.shell.rc.automagic]
333 print '\n' + Magic.auto_status[self.shell.rc.automagic]
325 return None
334 return None
326
335
327 def magic_magic(self, parameter_s = ''):
336 def magic_magic(self, parameter_s = ''):
328 """Print information about the magic function system."""
337 """Print information about the magic function system."""
329
338
330 mode = ''
339 mode = ''
331 try:
340 try:
332 if parameter_s.split()[0] == '-latex':
341 if parameter_s.split()[0] == '-latex':
333 mode = 'latex'
342 mode = 'latex'
334 except:
343 except:
335 pass
344 pass
336
345
337 magic_docs = []
346 magic_docs = []
338 for fname in self.lsmagic():
347 for fname in self.lsmagic():
339 mname = 'magic_' + fname
348 mname = 'magic_' + fname
340 for space in (Magic,self,self.__class__):
349 for space in (Magic,self,self.__class__):
341 try:
350 try:
342 fn = space.__dict__[mname]
351 fn = space.__dict__[mname]
343 except KeyError:
352 except KeyError:
344 pass
353 pass
345 else:
354 else:
346 break
355 break
347 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
356 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
348 fname,fn.__doc__))
357 fname,fn.__doc__))
349 magic_docs = ''.join(magic_docs)
358 magic_docs = ''.join(magic_docs)
350
359
351 if mode == 'latex':
360 if mode == 'latex':
352 print self.format_latex(magic_docs)
361 print self.format_latex(magic_docs)
353 return
362 return
354 else:
363 else:
355 magic_docs = self.format_screen(magic_docs)
364 magic_docs = self.format_screen(magic_docs)
356
365
357 outmsg = """
366 outmsg = """
358 IPython's 'magic' functions
367 IPython's 'magic' functions
359 ===========================
368 ===========================
360
369
361 The magic function system provides a series of functions which allow you to
370 The magic function system provides a series of functions which allow you to
362 control the behavior of IPython itself, plus a lot of system-type
371 control the behavior of IPython itself, plus a lot of system-type
363 features. All these functions are prefixed with a % character, but parameters
372 features. All these functions are prefixed with a % character, but parameters
364 are given without parentheses or quotes.
373 are given without parentheses or quotes.
365
374
366 NOTE: If you have 'automagic' enabled (via the command line option or with the
375 NOTE: If you have 'automagic' enabled (via the command line option or with the
367 %automagic function), you don't need to type in the % explicitly. By default,
376 %automagic function), you don't need to type in the % explicitly. By default,
368 IPython ships with automagic on, so you should only rarely need the % escape.
377 IPython ships with automagic on, so you should only rarely need the % escape.
369
378
370 Example: typing '%cd mydir' (without the quotes) changes you working directory
379 Example: typing '%cd mydir' (without the quotes) changes you working directory
371 to 'mydir', if it exists.
380 to 'mydir', if it exists.
372
381
373 You can define your own magic functions to extend the system. See the supplied
382 You can define your own magic functions to extend the system. See the supplied
374 ipythonrc and example-magic.py files for details (in your ipython
383 ipythonrc and example-magic.py files for details (in your ipython
375 configuration directory, typically $HOME/.ipython/).
384 configuration directory, typically $HOME/.ipython/).
376
385
377 You can also define your own aliased names for magic functions. In your
386 You can also define your own aliased names for magic functions. In your
378 ipythonrc file, placing a line like:
387 ipythonrc file, placing a line like:
379
388
380 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
389 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
381
390
382 will define %pf as a new name for %profile.
391 will define %pf as a new name for %profile.
383
392
384 You can also call magics in code using the ipmagic() function, which IPython
393 You can also call magics in code using the ipmagic() function, which IPython
385 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
394 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
386
395
387 For a list of the available magic functions, use %lsmagic. For a description
396 For a list of the available magic functions, use %lsmagic. For a description
388 of any of them, type %magic_name?, e.g. '%cd?'.
397 of any of them, type %magic_name?, e.g. '%cd?'.
389
398
390 Currently the magic system has the following functions:\n"""
399 Currently the magic system has the following functions:\n"""
391
400
392 mesc = self.shell.ESC_MAGIC
401 mesc = self.shell.ESC_MAGIC
393 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
402 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
394 "\n\n%s%s\n\n%s" % (outmsg,
403 "\n\n%s%s\n\n%s" % (outmsg,
395 magic_docs,mesc,mesc,
404 magic_docs,mesc,mesc,
396 (' '+mesc).join(self.lsmagic()),
405 (' '+mesc).join(self.lsmagic()),
397 Magic.auto_status[self.shell.rc.automagic] ) )
406 Magic.auto_status[self.shell.rc.automagic] ) )
398
407
399 page(outmsg,screen_lines=self.shell.rc.screen_length)
408 page(outmsg,screen_lines=self.shell.rc.screen_length)
400
409
401 def magic_automagic(self, parameter_s = ''):
410 def magic_automagic(self, parameter_s = ''):
402 """Make magic functions callable without having to type the initial %.
411 """Make magic functions callable without having to type the initial %.
403
412
404 Toggles on/off (when off, you must call it as %automagic, of
413 Toggles on/off (when off, you must call it as %automagic, of
405 course). Note that magic functions have lowest priority, so if there's
414 course). Note that magic functions have lowest priority, so if there's
406 a variable whose name collides with that of a magic fn, automagic
415 a variable whose name collides with that of a magic fn, automagic
407 won't work for that function (you get the variable instead). However,
416 won't work for that function (you get the variable instead). However,
408 if you delete the variable (del var), the previously shadowed magic
417 if you delete the variable (del var), the previously shadowed magic
409 function becomes visible to automagic again."""
418 function becomes visible to automagic again."""
410
419
411 rc = self.shell.rc
420 rc = self.shell.rc
412 rc.automagic = not rc.automagic
421 rc.automagic = not rc.automagic
413 print '\n' + Magic.auto_status[rc.automagic]
422 print '\n' + Magic.auto_status[rc.automagic]
414
423
415 def magic_autocall(self, parameter_s = ''):
424 def magic_autocall(self, parameter_s = ''):
416 """Make functions callable without having to type parentheses.
425 """Make functions callable without having to type parentheses.
417
426
418 This toggles the autocall command line option on and off."""
427 This toggles the autocall command line option on and off."""
419
428
420 rc = self.shell.rc
429 rc = self.shell.rc
421 rc.autocall = not rc.autocall
430 rc.autocall = not rc.autocall
422 print "Automatic calling is:",['OFF','ON'][rc.autocall]
431 print "Automatic calling is:",['OFF','ON'][rc.autocall]
423
432
424 def magic_autoindent(self, parameter_s = ''):
433 def magic_autoindent(self, parameter_s = ''):
425 """Toggle autoindent on/off (if available)."""
434 """Toggle autoindent on/off (if available)."""
426
435
427 self.shell.set_autoindent()
436 self.shell.set_autoindent()
428 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
437 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
429
438
430 def magic_system_verbose(self, parameter_s = ''):
439 def magic_system_verbose(self, parameter_s = ''):
431 """Toggle verbose printing of system calls on/off."""
440 """Toggle verbose printing of system calls on/off."""
432
441
433 self.shell.rc_set_toggle('system_verbose')
442 self.shell.rc_set_toggle('system_verbose')
434 print "System verbose printing is:",\
443 print "System verbose printing is:",\
435 ['OFF','ON'][self.shell.rc.system_verbose]
444 ['OFF','ON'][self.shell.rc.system_verbose]
436
445
437 def magic_history(self, parameter_s = ''):
446 def magic_history(self, parameter_s = ''):
438 """Print input history (_i<n> variables), with most recent last.
447 """Print input history (_i<n> variables), with most recent last.
439
448
440 %history [-n] -> print at most 40 inputs (some may be multi-line)\\
449 %history [-n] -> print at most 40 inputs (some may be multi-line)\\
441 %history [-n] n -> print at most n inputs\\
450 %history [-n] n -> print at most n inputs\\
442 %history [-n] n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
451 %history [-n] n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
443
452
444 Each input's number <n> is shown, and is accessible as the
453 Each input's number <n> is shown, and is accessible as the
445 automatically generated variable _i<n>. Multi-line statements are
454 automatically generated variable _i<n>. Multi-line statements are
446 printed starting at a new line for easy copy/paste.
455 printed starting at a new line for easy copy/paste.
447
456
448 If option -n is used, input numbers are not printed. This is useful if
457 If option -n is used, input numbers are not printed. This is useful if
449 you want to get a printout of many lines which can be directly pasted
458 you want to get a printout of many lines which can be directly pasted
450 into a text editor.
459 into a text editor.
451
460
452 This feature is only available if numbered prompts are in use."""
461 This feature is only available if numbered prompts are in use."""
453
462
454 shell = self.shell
463 shell = self.shell
455 if not shell.outputcache.do_full_cache:
464 if not shell.outputcache.do_full_cache:
456 print 'This feature is only available if numbered prompts are in use.'
465 print 'This feature is only available if numbered prompts are in use.'
457 return
466 return
458 opts,args = self.parse_options(parameter_s,'n',mode='list')
467 opts,args = self.parse_options(parameter_s,'n',mode='list')
459
468
460 input_hist = shell.input_hist
469 input_hist = shell.input_hist
461 default_length = 40
470 default_length = 40
462 if len(args) == 0:
471 if len(args) == 0:
463 final = len(input_hist)
472 final = len(input_hist)
464 init = max(1,final-default_length)
473 init = max(1,final-default_length)
465 elif len(args) == 1:
474 elif len(args) == 1:
466 final = len(input_hist)
475 final = len(input_hist)
467 init = max(1,final-int(args[0]))
476 init = max(1,final-int(args[0]))
468 elif len(args) == 2:
477 elif len(args) == 2:
469 init,final = map(int,args)
478 init,final = map(int,args)
470 else:
479 else:
471 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
480 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
472 print self.magic_hist.__doc__
481 print self.magic_hist.__doc__
473 return
482 return
474 width = len(str(final))
483 width = len(str(final))
475 line_sep = ['','\n']
484 line_sep = ['','\n']
476 print_nums = not opts.has_key('n')
485 print_nums = not opts.has_key('n')
477 for in_num in range(init,final):
486 for in_num in range(init,final):
478 inline = input_hist[in_num]
487 inline = input_hist[in_num]
479 multiline = int(inline.count('\n') > 1)
488 multiline = int(inline.count('\n') > 1)
480 if print_nums:
489 if print_nums:
481 print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]),
490 print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]),
482 print inline,
491 print inline,
483
492
484 def magic_hist(self, parameter_s=''):
493 def magic_hist(self, parameter_s=''):
485 """Alternate name for %history."""
494 """Alternate name for %history."""
486 return self.magic_history(parameter_s)
495 return self.magic_history(parameter_s)
487
496
488 def magic_p(self, parameter_s=''):
497 def magic_p(self, parameter_s=''):
489 """Just a short alias for Python's 'print'."""
498 """Just a short alias for Python's 'print'."""
490 exec 'print ' + parameter_s in self.shell.user_ns
499 exec 'print ' + parameter_s in self.shell.user_ns
491
500
492 def magic_r(self, parameter_s=''):
501 def magic_r(self, parameter_s=''):
493 """Repeat previous input.
502 """Repeat previous input.
494
503
495 If given an argument, repeats the previous command which starts with
504 If given an argument, repeats the previous command which starts with
496 the same string, otherwise it just repeats the previous input.
505 the same string, otherwise it just repeats the previous input.
497
506
498 Shell escaped commands (with ! as first character) are not recognized
507 Shell escaped commands (with ! as first character) are not recognized
499 by this system, only pure python code and magic commands.
508 by this system, only pure python code and magic commands.
500 """
509 """
501
510
502 start = parameter_s.strip()
511 start = parameter_s.strip()
503 esc_magic = self.shell.ESC_MAGIC
512 esc_magic = self.shell.ESC_MAGIC
504 # Identify magic commands even if automagic is on (which means
513 # Identify magic commands even if automagic is on (which means
505 # the in-memory version is different from that typed by the user).
514 # the in-memory version is different from that typed by the user).
506 if self.shell.rc.automagic:
515 if self.shell.rc.automagic:
507 start_magic = esc_magic+start
516 start_magic = esc_magic+start
508 else:
517 else:
509 start_magic = start
518 start_magic = start
510 # Look through the input history in reverse
519 # Look through the input history in reverse
511 for n in range(len(self.shell.input_hist)-2,0,-1):
520 for n in range(len(self.shell.input_hist)-2,0,-1):
512 input = self.shell.input_hist[n]
521 input = self.shell.input_hist[n]
513 # skip plain 'r' lines so we don't recurse to infinity
522 # skip plain 'r' lines so we don't recurse to infinity
514 if input != 'ipmagic("r")\n' and \
523 if input != 'ipmagic("r")\n' and \
515 (input.startswith(start) or input.startswith(start_magic)):
524 (input.startswith(start) or input.startswith(start_magic)):
516 #print 'match',`input` # dbg
525 #print 'match',`input` # dbg
517 print 'Executing:',input,
526 print 'Executing:',input,
518 self.shell.runlines(input)
527 self.shell.runlines(input)
519 return
528 return
520 print 'No previous input matching `%s` found.' % start
529 print 'No previous input matching `%s` found.' % start
521
530
522 def magic_page(self, parameter_s=''):
531 def magic_page(self, parameter_s=''):
523 """Pretty print the object and display it through a pager.
532 """Pretty print the object and display it through a pager.
524
533
525 If no parameter is given, use _ (last output)."""
534 If no parameter is given, use _ (last output)."""
526 # After a function contributed by Olivier Aubert, slightly modified.
535 # After a function contributed by Olivier Aubert, slightly modified.
527
536
528 oname = parameter_s and parameter_s or '_'
537 oname = parameter_s and parameter_s or '_'
529 info = self._ofind(oname)
538 info = self._ofind(oname)
530 if info['found']:
539 if info['found']:
531 page(pformat(info['obj']))
540 page(pformat(info['obj']))
532 else:
541 else:
533 print 'Object `%s` not found' % oname
542 print 'Object `%s` not found' % oname
534
543
535 def magic_profile(self, parameter_s=''):
544 def magic_profile(self, parameter_s=''):
536 """Print your currently active IPyhton profile."""
545 """Print your currently active IPyhton profile."""
537 if self.shell.rc.profile:
546 if self.shell.rc.profile:
538 printpl('Current IPython profile: $self.shell.rc.profile.')
547 printpl('Current IPython profile: $self.shell.rc.profile.')
539 else:
548 else:
540 print 'No profile active.'
549 print 'No profile active.'
541
550
542 def _inspect(self,meth,oname,**kw):
551 def _inspect(self,meth,oname,**kw):
543 """Generic interface to the inspector system.
552 """Generic interface to the inspector system.
544
553
545 This function is meant to be called by pdef, pdoc & friends."""
554 This function is meant to be called by pdef, pdoc & friends."""
546
555
547 oname = oname.strip()
556 oname = oname.strip()
548 info = Struct(self._ofind(oname))
557 info = Struct(self._ofind(oname))
549 if info.found:
558 if info.found:
550 pmethod = getattr(self.shell.inspector,meth)
559 pmethod = getattr(self.shell.inspector,meth)
551 formatter = info.ismagic and self.format_screen or None
560 formatter = info.ismagic and self.format_screen or None
552 if meth == 'pdoc':
561 if meth == 'pdoc':
553 pmethod(info.obj,oname,formatter)
562 pmethod(info.obj,oname,formatter)
554 elif meth == 'pinfo':
563 elif meth == 'pinfo':
555 pmethod(info.obj,oname,formatter,info,**kw)
564 pmethod(info.obj,oname,formatter,info,**kw)
556 else:
565 else:
557 pmethod(info.obj,oname)
566 pmethod(info.obj,oname)
558 else:
567 else:
559 print 'Object `%s` not found.' % oname
568 print 'Object `%s` not found.' % oname
560 return 'not found' # so callers can take other action
569 return 'not found' # so callers can take other action
561
570
562 def magic_pdef(self, parameter_s=''):
571 def magic_pdef(self, parameter_s=''):
563 """Print the definition header for any callable object.
572 """Print the definition header for any callable object.
564
573
565 If the object is a class, print the constructor information."""
574 If the object is a class, print the constructor information."""
566 self._inspect('pdef',parameter_s)
575 self._inspect('pdef',parameter_s)
567
576
568 def magic_pdoc(self, parameter_s=''):
577 def magic_pdoc(self, parameter_s=''):
569 """Print the docstring for an object.
578 """Print the docstring for an object.
570
579
571 If the given object is a class, it will print both the class and the
580 If the given object is a class, it will print both the class and the
572 constructor docstrings."""
581 constructor docstrings."""
573 self._inspect('pdoc',parameter_s)
582 self._inspect('pdoc',parameter_s)
574
583
575 def magic_psource(self, parameter_s=''):
584 def magic_psource(self, parameter_s=''):
576 """Print (or run through pager) the source code for an object."""
585 """Print (or run through pager) the source code for an object."""
577 self._inspect('psource',parameter_s)
586 self._inspect('psource',parameter_s)
578
587
579 def magic_pfile(self, parameter_s=''):
588 def magic_pfile(self, parameter_s=''):
580 """Print (or run through pager) the file where an object is defined.
589 """Print (or run through pager) the file where an object is defined.
581
590
582 The file opens at the line where the object definition begins. IPython
591 The file opens at the line where the object definition begins. IPython
583 will honor the environment variable PAGER if set, and otherwise will
592 will honor the environment variable PAGER if set, and otherwise will
584 do its best to print the file in a convenient form.
593 do its best to print the file in a convenient form.
585
594
586 If the given argument is not an object currently defined, IPython will
595 If the given argument is not an object currently defined, IPython will
587 try to interpret it as a filename (automatically adding a .py extension
596 try to interpret it as a filename (automatically adding a .py extension
588 if needed). You can thus use %pfile as a syntax highlighting code
597 if needed). You can thus use %pfile as a syntax highlighting code
589 viewer."""
598 viewer."""
590
599
591 # first interpret argument as an object name
600 # first interpret argument as an object name
592 out = self._inspect('pfile',parameter_s)
601 out = self._inspect('pfile',parameter_s)
593 # if not, try the input as a filename
602 # if not, try the input as a filename
594 if out == 'not found':
603 if out == 'not found':
595 try:
604 try:
596 filename = get_py_filename(parameter_s)
605 filename = get_py_filename(parameter_s)
597 except IOError,msg:
606 except IOError,msg:
598 print msg
607 print msg
599 return
608 return
600 page(self.shell.inspector.format(file(filename).read()))
609 page(self.shell.inspector.format(file(filename).read()))
601
610
602 def magic_pinfo(self, parameter_s=''):
611 def magic_pinfo(self, parameter_s=''):
603 """Provide detailed information about an object.
612 """Provide detailed information about an object.
604
613
605 '%pinfo object' is just a synonym for object? or ?object."""
614 '%pinfo object' is just a synonym for object? or ?object."""
606
615
607 #print 'pinfo par: <%s>' % parameter_s # dbg
616 #print 'pinfo par: <%s>' % parameter_s # dbg
608
617
609 # detail_level: 0 -> obj? , 1 -> obj??
618 # detail_level: 0 -> obj? , 1 -> obj??
610 detail_level = 0
619 detail_level = 0
611 # We need to detect if we got called as 'pinfo pinfo foo', which can
620 # We need to detect if we got called as 'pinfo pinfo foo', which can
612 # happen if the user types 'pinfo foo?' at the cmd line.
621 # happen if the user types 'pinfo foo?' at the cmd line.
613 pinfo,qmark1,oname,qmark2 = \
622 pinfo,qmark1,oname,qmark2 = \
614 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
623 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
615 if pinfo or qmark1 or qmark2:
624 if pinfo or qmark1 or qmark2:
616 detail_level = 1
625 detail_level = 1
617 if "*" in oname:
626 if "*" in oname:
618 self.magic_psearch(oname)
627 self.magic_psearch(oname)
619 else:
628 else:
620 self._inspect('pinfo',oname,detail_level=detail_level)
629 self._inspect('pinfo',oname,detail_level=detail_level)
621
630
622 def magic_psearch(self, parameter_s=''):
631 def magic_psearch(self, parameter_s=''):
623 """Search for object in namespaces by wildcard.
632 """Search for object in namespaces by wildcard.
624
633
625 %psearch [options] PATTERN [OBJECT TYPE]
634 %psearch [options] PATTERN [OBJECT TYPE]
626
635
627 Note: ? can be used as a synonym for %psearch, at the beginning or at
636 Note: ? can be used as a synonym for %psearch, at the beginning or at
628 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
637 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
629 rest of the command line must be unchanged (options come first), so
638 rest of the command line must be unchanged (options come first), so
630 for example the following forms are equivalent
639 for example the following forms are equivalent
631
640
632 %psearch -i a* function
641 %psearch -i a* function
633 -i a* function?
642 -i a* function?
634 ?-i a* function
643 ?-i a* function
635
644
636 Arguments:
645 Arguments:
637
646
638 PATTERN
647 PATTERN
639
648
640 where PATTERN is a string containing * as a wildcard similar to its
649 where PATTERN is a string containing * as a wildcard similar to its
641 use in a shell. The pattern is matched in all namespaces on the
650 use in a shell. The pattern is matched in all namespaces on the
642 search path. By default objects starting with a single _ are not
651 search path. By default objects starting with a single _ are not
643 matched, many IPython generated objects have a single
652 matched, many IPython generated objects have a single
644 underscore. The default is case insensitive matching. Matching is
653 underscore. The default is case insensitive matching. Matching is
645 also done on the attributes of objects and not only on the objects
654 also done on the attributes of objects and not only on the objects
646 in a module.
655 in a module.
647
656
648 [OBJECT TYPE]
657 [OBJECT TYPE]
649
658
650 Is the name of a python type from the types module. The name is
659 Is the name of a python type from the types module. The name is
651 given in lowercase without the ending type, ex. StringType is
660 given in lowercase without the ending type, ex. StringType is
652 written string. By adding a type here only objects matching the
661 written string. By adding a type here only objects matching the
653 given type are matched. Using all here makes the pattern match all
662 given type are matched. Using all here makes the pattern match all
654 types (this is the default).
663 types (this is the default).
655
664
656 Options:
665 Options:
657
666
658 -a: makes the pattern match even objects whose names start with a
667 -a: makes the pattern match even objects whose names start with a
659 single underscore. These names are normally ommitted from the
668 single underscore. These names are normally ommitted from the
660 search.
669 search.
661
670
662 -i/-c: make the pattern case insensitive/sensitive. If neither of
671 -i/-c: make the pattern case insensitive/sensitive. If neither of
663 these options is given, the default is read from your ipythonrc
672 these options is given, the default is read from your ipythonrc
664 file. The option name which sets this value is
673 file. The option name which sets this value is
665 'wildcards_case_sensitive'. If this option is not specified in your
674 'wildcards_case_sensitive'. If this option is not specified in your
666 ipythonrc file, IPython's internal default is to do a case sensitive
675 ipythonrc file, IPython's internal default is to do a case sensitive
667 search.
676 search.
668
677
669 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
678 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
670 specifiy can be searched in any of the following namespaces:
679 specifiy can be searched in any of the following namespaces:
671 'builtin', 'user', 'user_global','internal', 'alias', where
680 'builtin', 'user', 'user_global','internal', 'alias', where
672 'builtin' and 'user' are the search defaults. Note that you should
681 'builtin' and 'user' are the search defaults. Note that you should
673 not use quotes when specifying namespaces.
682 not use quotes when specifying namespaces.
674
683
675 'Builtin' contains the python module builtin, 'user' contains all
684 'Builtin' contains the python module builtin, 'user' contains all
676 user data, 'alias' only contain the shell aliases and no python
685 user data, 'alias' only contain the shell aliases and no python
677 objects, 'internal' contains objects used by IPython. The
686 objects, 'internal' contains objects used by IPython. The
678 'user_global' namespace is only used by embedded IPython instances,
687 'user_global' namespace is only used by embedded IPython instances,
679 and it contains module-level globals. You can add namespaces to the
688 and it contains module-level globals. You can add namespaces to the
680 search with -s or exclude them with -e (these options can be given
689 search with -s or exclude them with -e (these options can be given
681 more than once).
690 more than once).
682
691
683 Examples:
692 Examples:
684
693
685 %psearch a* -> objects beginning with an a
694 %psearch a* -> objects beginning with an a
686 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
695 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
687 %psearch a* function -> all functions beginning with an a
696 %psearch a* function -> all functions beginning with an a
688 %psearch re.e* -> objects beginning with an e in module re
697 %psearch re.e* -> objects beginning with an e in module re
689 %psearch r*.e* -> objects that start with e in modules starting in r
698 %psearch r*.e* -> objects that start with e in modules starting in r
690 %psearch r*.* string -> all strings in modules beginning with r
699 %psearch r*.* string -> all strings in modules beginning with r
691
700
692 Case sensitve search:
701 Case sensitve search:
693
702
694 %psearch -c a* list all object beginning with lower case a
703 %psearch -c a* list all object beginning with lower case a
695
704
696 Show objects beginning with a single _:
705 Show objects beginning with a single _:
697
706
698 %psearch -a _* list objects beginning with a single underscore"""
707 %psearch -a _* list objects beginning with a single underscore"""
699
708
700 # default namespaces to be searched
709 # default namespaces to be searched
701 def_search = ['user','builtin']
710 def_search = ['user','builtin']
702
711
703 # Process options/args
712 # Process options/args
704 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
713 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
705 opt = opts.get
714 opt = opts.get
706 shell = self.shell
715 shell = self.shell
707 psearch = shell.inspector.psearch
716 psearch = shell.inspector.psearch
708
717
709 # select case options
718 # select case options
710 if opts.has_key('i'):
719 if opts.has_key('i'):
711 ignore_case = True
720 ignore_case = True
712 elif opts.has_key('c'):
721 elif opts.has_key('c'):
713 ignore_case = False
722 ignore_case = False
714 else:
723 else:
715 ignore_case = not shell.rc.wildcards_case_sensitive
724 ignore_case = not shell.rc.wildcards_case_sensitive
716
725
717 # Build list of namespaces to search from user options
726 # Build list of namespaces to search from user options
718 def_search.extend(opt('s',[]))
727 def_search.extend(opt('s',[]))
719 ns_exclude = ns_exclude=opt('e',[])
728 ns_exclude = ns_exclude=opt('e',[])
720 ns_search = [nm for nm in def_search if nm not in ns_exclude]
729 ns_search = [nm for nm in def_search if nm not in ns_exclude]
721
730
722 # Call the actual search
731 # Call the actual search
723 try:
732 try:
724 psearch(args,shell.ns_table,ns_search,
733 psearch(args,shell.ns_table,ns_search,
725 show_all=opt('a'),ignore_case=ignore_case)
734 show_all=opt('a'),ignore_case=ignore_case)
726 except:
735 except:
727 shell.showtraceback()
736 shell.showtraceback()
728
737
729 def magic_who_ls(self, parameter_s=''):
738 def magic_who_ls(self, parameter_s=''):
730 """Return a sorted list of all interactive variables.
739 """Return a sorted list of all interactive variables.
731
740
732 If arguments are given, only variables of types matching these
741 If arguments are given, only variables of types matching these
733 arguments are returned."""
742 arguments are returned."""
734
743
735 user_ns = self.shell.user_ns
744 user_ns = self.shell.user_ns
736 out = []
745 out = []
737 typelist = parameter_s.split()
746 typelist = parameter_s.split()
738 for i in self.shell.user_ns.keys():
747 for i in self.shell.user_ns.keys():
739 if not (i.startswith('_') or i.startswith('_i')) \
748 if not (i.startswith('_') or i.startswith('_i')) \
740 and not (self.shell.internal_ns.has_key(i) or
749 and not (self.shell.internal_ns.has_key(i) or
741 self.shell.user_config_ns.has_key(i)):
750 self.shell.user_config_ns.has_key(i)):
742 if typelist:
751 if typelist:
743 if type(user_ns[i]).__name__ in typelist:
752 if type(user_ns[i]).__name__ in typelist:
744 out.append(i)
753 out.append(i)
745 else:
754 else:
746 out.append(i)
755 out.append(i)
747 out.sort()
756 out.sort()
748 return out
757 return out
749
758
750 def magic_who(self, parameter_s=''):
759 def magic_who(self, parameter_s=''):
751 """Print all interactive variables, with some minimal formatting.
760 """Print all interactive variables, with some minimal formatting.
752
761
753 If any arguments are given, only variables whose type matches one of
762 If any arguments are given, only variables whose type matches one of
754 these are printed. For example:
763 these are printed. For example:
755
764
756 %who function str
765 %who function str
757
766
758 will only list functions and strings, excluding all other types of
767 will only list functions and strings, excluding all other types of
759 variables. To find the proper type names, simply use type(var) at a
768 variables. To find the proper type names, simply use type(var) at a
760 command line to see how python prints type names. For example:
769 command line to see how python prints type names. For example:
761
770
762 In [1]: type('hello')\\
771 In [1]: type('hello')\\
763 Out[1]: <type 'str'>
772 Out[1]: <type 'str'>
764
773
765 indicates that the type name for strings is 'str'.
774 indicates that the type name for strings is 'str'.
766
775
767 %who always excludes executed names loaded through your configuration
776 %who always excludes executed names loaded through your configuration
768 file and things which are internal to IPython.
777 file and things which are internal to IPython.
769
778
770 This is deliberate, as typically you may load many modules and the
779 This is deliberate, as typically you may load many modules and the
771 purpose of %who is to show you only what you've manually defined."""
780 purpose of %who is to show you only what you've manually defined."""
772
781
773 varlist = self.magic_who_ls(parameter_s)
782 varlist = self.magic_who_ls(parameter_s)
774 if not varlist:
783 if not varlist:
775 print 'Interactive namespace is empty.'
784 print 'Interactive namespace is empty.'
776 return
785 return
777
786
778 # if we have variables, move on...
787 # if we have variables, move on...
779
788
780 # stupid flushing problem: when prompts have no separators, stdout is
789 # stupid flushing problem: when prompts have no separators, stdout is
781 # getting lost. I'm starting to think this is a python bug. I'm having
790 # getting lost. I'm starting to think this is a python bug. I'm having
782 # to force a flush with a print because even a sys.stdout.flush
791 # to force a flush with a print because even a sys.stdout.flush
783 # doesn't seem to do anything!
792 # doesn't seem to do anything!
784
793
785 count = 0
794 count = 0
786 for i in varlist:
795 for i in varlist:
787 print i+'\t',
796 print i+'\t',
788 count += 1
797 count += 1
789 if count > 8:
798 if count > 8:
790 count = 0
799 count = 0
791 print
800 print
792 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
801 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
793
802
794 print # well, this does force a flush at the expense of an extra \n
803 print # well, this does force a flush at the expense of an extra \n
795
804
796 def magic_whos(self, parameter_s=''):
805 def magic_whos(self, parameter_s=''):
797 """Like %who, but gives some extra information about each variable.
806 """Like %who, but gives some extra information about each variable.
798
807
799 The same type filtering of %who can be applied here.
808 The same type filtering of %who can be applied here.
800
809
801 For all variables, the type is printed. Additionally it prints:
810 For all variables, the type is printed. Additionally it prints:
802
811
803 - For {},[],(): their length.
812 - For {},[],(): their length.
804
813
805 - For Numeric arrays, a summary with shape, number of elements,
814 - For Numeric arrays, a summary with shape, number of elements,
806 typecode and size in memory.
815 typecode and size in memory.
807
816
808 - Everything else: a string representation, snipping their middle if
817 - Everything else: a string representation, snipping their middle if
809 too long."""
818 too long."""
810
819
811 varnames = self.magic_who_ls(parameter_s)
820 varnames = self.magic_who_ls(parameter_s)
812 if not varnames:
821 if not varnames:
813 print 'Interactive namespace is empty.'
822 print 'Interactive namespace is empty.'
814 return
823 return
815
824
816 # if we have variables, move on...
825 # if we have variables, move on...
817
826
818 # for these types, show len() instead of data:
827 # for these types, show len() instead of data:
819 seq_types = [types.DictType,types.ListType,types.TupleType]
828 seq_types = [types.DictType,types.ListType,types.TupleType]
820
829
821 # for Numeric arrays, display summary info
830 # for Numeric arrays, display summary info
822 try:
831 try:
823 import Numeric
832 import Numeric
824 except ImportError:
833 except ImportError:
825 array_type = None
834 array_type = None
826 else:
835 else:
827 array_type = Numeric.ArrayType.__name__
836 array_type = Numeric.ArrayType.__name__
828
837
829 # Find all variable names and types so we can figure out column sizes
838 # Find all variable names and types so we can figure out column sizes
830 get_vars = lambda i: self.shell.user_ns[i]
839 get_vars = lambda i: self.shell.user_ns[i]
831 type_name = lambda v: type(v).__name__
840 type_name = lambda v: type(v).__name__
832 varlist = map(get_vars,varnames)
841 varlist = map(get_vars,varnames)
833
842
834 typelist = []
843 typelist = []
835 for vv in varlist:
844 for vv in varlist:
836 tt = type_name(vv)
845 tt = type_name(vv)
837 if tt=='instance':
846 if tt=='instance':
838 typelist.append(str(vv.__class__))
847 typelist.append(str(vv.__class__))
839 else:
848 else:
840 typelist.append(tt)
849 typelist.append(tt)
841
850
842 # column labels and # of spaces as separator
851 # column labels and # of spaces as separator
843 varlabel = 'Variable'
852 varlabel = 'Variable'
844 typelabel = 'Type'
853 typelabel = 'Type'
845 datalabel = 'Data/Info'
854 datalabel = 'Data/Info'
846 colsep = 3
855 colsep = 3
847 # variable format strings
856 # variable format strings
848 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
857 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
849 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
858 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
850 aformat = "%s: %s elems, type `%s`, %s bytes"
859 aformat = "%s: %s elems, type `%s`, %s bytes"
851 # find the size of the columns to format the output nicely
860 # find the size of the columns to format the output nicely
852 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
861 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
853 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
862 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
854 # table header
863 # table header
855 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
864 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
856 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
865 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
857 # and the table itself
866 # and the table itself
858 kb = 1024
867 kb = 1024
859 Mb = 1048576 # kb**2
868 Mb = 1048576 # kb**2
860 for vname,var,vtype in zip(varnames,varlist,typelist):
869 for vname,var,vtype in zip(varnames,varlist,typelist):
861 print itpl(vformat),
870 print itpl(vformat),
862 if vtype in seq_types:
871 if vtype in seq_types:
863 print len(var)
872 print len(var)
864 elif vtype==array_type:
873 elif vtype==array_type:
865 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
874 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
866 vsize = Numeric.size(var)
875 vsize = Numeric.size(var)
867 vbytes = vsize*var.itemsize()
876 vbytes = vsize*var.itemsize()
868 if vbytes < 100000:
877 if vbytes < 100000:
869 print aformat % (vshape,vsize,var.typecode(),vbytes)
878 print aformat % (vshape,vsize,var.typecode(),vbytes)
870 else:
879 else:
871 print aformat % (vshape,vsize,var.typecode(),vbytes),
880 print aformat % (vshape,vsize,var.typecode(),vbytes),
872 if vbytes < Mb:
881 if vbytes < Mb:
873 print '(%s kb)' % (vbytes/kb,)
882 print '(%s kb)' % (vbytes/kb,)
874 else:
883 else:
875 print '(%s Mb)' % (vbytes/Mb,)
884 print '(%s Mb)' % (vbytes/Mb,)
876 else:
885 else:
877 vstr = str(var).replace('\n','\\n')
886 vstr = str(var).replace('\n','\\n')
878 if len(vstr) < 50:
887 if len(vstr) < 50:
879 print vstr
888 print vstr
880 else:
889 else:
881 printpl(vfmt_short)
890 printpl(vfmt_short)
882
891
883 def magic_reset(self, parameter_s=''):
892 def magic_reset(self, parameter_s=''):
884 """Resets the namespace by removing all names defined by the user.
893 """Resets the namespace by removing all names defined by the user.
885
894
886 Input/Output history are left around in case you need them."""
895 Input/Output history are left around in case you need them."""
887
896
888 ans = raw_input(
897 ans = raw_input(
889 "Once deleted, variables cannot be recovered. Proceed (y/n)? ")
898 "Once deleted, variables cannot be recovered. Proceed (y/n)? ")
890 if not ans.lower() == 'y':
899 if not ans.lower() == 'y':
891 print 'Nothing done.'
900 print 'Nothing done.'
892 return
901 return
893 user_ns = self.shell.user_ns
902 user_ns = self.shell.user_ns
894 for i in self.magic_who_ls():
903 for i in self.magic_who_ls():
895 del(user_ns[i])
904 del(user_ns[i])
896
905
897 def magic_config(self,parameter_s=''):
906 def magic_config(self,parameter_s=''):
898 """Show IPython's internal configuration."""
907 """Show IPython's internal configuration."""
899
908
900 page('Current configuration structure:\n'+
909 page('Current configuration structure:\n'+
901 pformat(self.shell.rc.dict()))
910 pformat(self.shell.rc.dict()))
902
911
903 def magic_logstart(self,parameter_s=''):
912 def magic_logstart(self,parameter_s=''):
904 """Start logging anywhere in a session.
913 """Start logging anywhere in a session.
905
914
906 %logstart [-o|-t] [log_name [log_mode]]
915 %logstart [-o|-t] [log_name [log_mode]]
907
916
908 If no name is given, it defaults to a file named 'ipython_log.py' in your
917 If no name is given, it defaults to a file named 'ipython_log.py' in your
909 current directory, in 'rotate' mode (see below).
918 current directory, in 'rotate' mode (see below).
910
919
911 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
920 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
912 history up to that point and then continues logging.
921 history up to that point and then continues logging.
913
922
914 %logstart takes a second optional parameter: logging mode. This can be one
923 %logstart takes a second optional parameter: logging mode. This can be one
915 of (note that the modes are given unquoted):\\
924 of (note that the modes are given unquoted):\\
916 append: well, that says it.\\
925 append: well, that says it.\\
917 backup: rename (if exists) to name~ and start name.\\
926 backup: rename (if exists) to name~ and start name.\\
918 global: single logfile in your home dir, appended to.\\
927 global: single logfile in your home dir, appended to.\\
919 over : overwrite existing log.\\
928 over : overwrite existing log.\\
920 rotate: create rotating logs name.1~, name.2~, etc.
929 rotate: create rotating logs name.1~, name.2~, etc.
921
930
922 Options:
931 Options:
923
932
924 -o: log also IPython's output. In this mode, all commands which
933 -o: log also IPython's output. In this mode, all commands which
925 generate an Out[NN] prompt are recorded to the logfile, right after
934 generate an Out[NN] prompt are recorded to the logfile, right after
926 their corresponding input line. The output lines are always
935 their corresponding input line. The output lines are always
927 prepended with a '#[Out]# ' marker, so that the log remains valid
936 prepended with a '#[Out]# ' marker, so that the log remains valid
928 Python code.
937 Python code.
929
938
930 Since this marker is always the same, filtering only the output from
939 Since this marker is always the same, filtering only the output from
931 a log is very easy, using for example a simple awk call:
940 a log is very easy, using for example a simple awk call:
932
941
933 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
942 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
934
943
935 -t: put timestamps before each input line logged (these are put in
944 -t: put timestamps before each input line logged (these are put in
936 comments)."""
945 comments)."""
937
946
938 opts,par = self.parse_options(parameter_s,'ot')
947 opts,par = self.parse_options(parameter_s,'ot')
939 log_output = 'o' in opts
948 log_output = 'o' in opts
940 timestamp = 't' in opts
949 timestamp = 't' in opts
941
950
942 rc = self.shell.rc
951 rc = self.shell.rc
943 logger = self.shell.logger
952 logger = self.shell.logger
944
953
945 # if no args are given, the defaults set in the logger constructor by
954 # if no args are given, the defaults set in the logger constructor by
946 # ipytohn remain valid
955 # ipytohn remain valid
947 if par:
956 if par:
948 try:
957 try:
949 logfname,logmode = par.split()
958 logfname,logmode = par.split()
950 except:
959 except:
951 logfname = par
960 logfname = par
952 logmode = 'backup'
961 logmode = 'backup'
953 else:
962 else:
954 logfname = logger.logfname
963 logfname = logger.logfname
955 logmode = logger.logmode
964 logmode = logger.logmode
956 # put logfname into rc struct as if it had been called on the command
965 # put logfname into rc struct as if it had been called on the command
957 # line, so it ends up saved in the log header Save it in case we need
966 # line, so it ends up saved in the log header Save it in case we need
958 # to restore it...
967 # to restore it...
959 old_logfile = rc.opts.get('logfile','')
968 old_logfile = rc.opts.get('logfile','')
960 if logfname:
969 if logfname:
961 logfname = os.path.expanduser(logfname)
970 logfname = os.path.expanduser(logfname)
962 rc.opts.logfile = logfname
971 rc.opts.logfile = logfname
963 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
972 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
964 try:
973 try:
965 started = logger.logstart(logfname,loghead,logmode,
974 started = logger.logstart(logfname,loghead,logmode,
966 log_output,timestamp)
975 log_output,timestamp)
967 except:
976 except:
968 rc.opts.logfile = old_logfile
977 rc.opts.logfile = old_logfile
969 warn("Couldn't start log: %s" % sys.exc_info()[1])
978 warn("Couldn't start log: %s" % sys.exc_info()[1])
970 else:
979 else:
971 # log input history up to this point, optionally interleaving
980 # log input history up to this point, optionally interleaving
972 # output if requested
981 # output if requested
973
982
974 if timestamp:
983 if timestamp:
975 # disable timestamping for the previous history, since we've
984 # disable timestamping for the previous history, since we've
976 # lost those already (no time machine here).
985 # lost those already (no time machine here).
977 logger.timestamp = False
986 logger.timestamp = False
978 if log_output:
987 if log_output:
979 log_write = logger.log_write
988 log_write = logger.log_write
980 input_hist = self.shell.input_hist
989 input_hist = self.shell.input_hist
981 output_hist = self.shell.output_hist
990 output_hist = self.shell.output_hist
982 for n in range(1,len(input_hist)-1):
991 for n in range(1,len(input_hist)-1):
983 log_write(input_hist[n].rstrip())
992 log_write(input_hist[n].rstrip())
984 if n in output_hist:
993 if n in output_hist:
985 log_write(repr(output_hist[n]),'output')
994 log_write(repr(output_hist[n]),'output')
986 else:
995 else:
987 logger.log_write(self.shell.input_hist[1:])
996 logger.log_write(self.shell.input_hist[1:])
988 if timestamp:
997 if timestamp:
989 # re-enable timestamping
998 # re-enable timestamping
990 logger.timestamp = True
999 logger.timestamp = True
991
1000
992 print ('Activating auto-logging. '
1001 print ('Activating auto-logging. '
993 'Current session state plus future input saved.')
1002 'Current session state plus future input saved.')
994 logger.logstate()
1003 logger.logstate()
995
1004
996 def magic_logoff(self,parameter_s=''):
1005 def magic_logoff(self,parameter_s=''):
997 """Temporarily stop logging.
1006 """Temporarily stop logging.
998
1007
999 You must have previously started logging."""
1008 You must have previously started logging."""
1000 self.shell.logger.switch_log(0)
1009 self.shell.logger.switch_log(0)
1001
1010
1002 def magic_logon(self,parameter_s=''):
1011 def magic_logon(self,parameter_s=''):
1003 """Restart logging.
1012 """Restart logging.
1004
1013
1005 This function is for restarting logging which you've temporarily
1014 This function is for restarting logging which you've temporarily
1006 stopped with %logoff. For starting logging for the first time, you
1015 stopped with %logoff. For starting logging for the first time, you
1007 must use the %logstart function, which allows you to specify an
1016 must use the %logstart function, which allows you to specify an
1008 optional log filename."""
1017 optional log filename."""
1009
1018
1010 self.shell.logger.switch_log(1)
1019 self.shell.logger.switch_log(1)
1011
1020
1012 def magic_logstate(self,parameter_s=''):
1021 def magic_logstate(self,parameter_s=''):
1013 """Print the status of the logging system."""
1022 """Print the status of the logging system."""
1014
1023
1015 self.shell.logger.logstate()
1024 self.shell.logger.logstate()
1016
1025
1017 def magic_pdb(self, parameter_s=''):
1026 def magic_pdb(self, parameter_s=''):
1018 """Control the calling of the pdb interactive debugger.
1027 """Control the calling of the pdb interactive debugger.
1019
1028
1020 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1029 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1021 argument it works as a toggle.
1030 argument it works as a toggle.
1022
1031
1023 When an exception is triggered, IPython can optionally call the
1032 When an exception is triggered, IPython can optionally call the
1024 interactive pdb debugger after the traceback printout. %pdb toggles
1033 interactive pdb debugger after the traceback printout. %pdb toggles
1025 this feature on and off."""
1034 this feature on and off."""
1026
1035
1027 par = parameter_s.strip().lower()
1036 par = parameter_s.strip().lower()
1028
1037
1029 if par:
1038 if par:
1030 try:
1039 try:
1031 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1040 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1032 except KeyError:
1041 except KeyError:
1033 print ('Incorrect argument. Use on/1, off/0, '
1042 print ('Incorrect argument. Use on/1, off/0, '
1034 'or nothing for a toggle.')
1043 'or nothing for a toggle.')
1035 return
1044 return
1036 else:
1045 else:
1037 # toggle
1046 # toggle
1038 new_pdb = not self.shell.InteractiveTB.call_pdb
1047 new_pdb = not self.shell.InteractiveTB.call_pdb
1039
1048
1040 # set on the shell
1049 # set on the shell
1041 self.shell.call_pdb = new_pdb
1050 self.shell.call_pdb = new_pdb
1042 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1051 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1043
1052
1044 def magic_prun(self, parameter_s ='',user_mode=1,
1053 def magic_prun(self, parameter_s ='',user_mode=1,
1045 opts=None,arg_lst=None,prog_ns=None):
1054 opts=None,arg_lst=None,prog_ns=None):
1046
1055
1047 """Run a statement through the python code profiler.
1056 """Run a statement through the python code profiler.
1048
1057
1049 Usage:\\
1058 Usage:\\
1050 %prun [options] statement
1059 %prun [options] statement
1051
1060
1052 The given statement (which doesn't require quote marks) is run via the
1061 The given statement (which doesn't require quote marks) is run via the
1053 python profiler in a manner similar to the profile.run() function.
1062 python profiler in a manner similar to the profile.run() function.
1054 Namespaces are internally managed to work correctly; profile.run
1063 Namespaces are internally managed to work correctly; profile.run
1055 cannot be used in IPython because it makes certain assumptions about
1064 cannot be used in IPython because it makes certain assumptions about
1056 namespaces which do not hold under IPython.
1065 namespaces which do not hold under IPython.
1057
1066
1058 Options:
1067 Options:
1059
1068
1060 -l <limit>: you can place restrictions on what or how much of the
1069 -l <limit>: you can place restrictions on what or how much of the
1061 profile gets printed. The limit value can be:
1070 profile gets printed. The limit value can be:
1062
1071
1063 * A string: only information for function names containing this string
1072 * A string: only information for function names containing this string
1064 is printed.
1073 is printed.
1065
1074
1066 * An integer: only these many lines are printed.
1075 * An integer: only these many lines are printed.
1067
1076
1068 * A float (between 0 and 1): this fraction of the report is printed
1077 * A float (between 0 and 1): this fraction of the report is printed
1069 (for example, use a limit of 0.4 to see the topmost 40% only).
1078 (for example, use a limit of 0.4 to see the topmost 40% only).
1070
1079
1071 You can combine several limits with repeated use of the option. For
1080 You can combine several limits with repeated use of the option. For
1072 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1081 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1073 information about class constructors.
1082 information about class constructors.
1074
1083
1075 -r: return the pstats.Stats object generated by the profiling. This
1084 -r: return the pstats.Stats object generated by the profiling. This
1076 object has all the information about the profile in it, and you can
1085 object has all the information about the profile in it, and you can
1077 later use it for further analysis or in other functions.
1086 later use it for further analysis or in other functions.
1078
1087
1079 Since magic functions have a particular form of calling which prevents
1088 Since magic functions have a particular form of calling which prevents
1080 you from writing something like:\\
1089 you from writing something like:\\
1081 In [1]: p = %prun -r print 4 # invalid!\\
1090 In [1]: p = %prun -r print 4 # invalid!\\
1082 you must instead use IPython's automatic variables to assign this:\\
1091 you must instead use IPython's automatic variables to assign this:\\
1083 In [1]: %prun -r print 4 \\
1092 In [1]: %prun -r print 4 \\
1084 Out[1]: <pstats.Stats instance at 0x8222cec>\\
1093 Out[1]: <pstats.Stats instance at 0x8222cec>\\
1085 In [2]: stats = _
1094 In [2]: stats = _
1086
1095
1087 If you really need to assign this value via an explicit function call,
1096 If you really need to assign this value via an explicit function call,
1088 you can always tap directly into the true name of the magic function
1097 you can always tap directly into the true name of the magic function
1089 by using the ipmagic function (which IPython automatically adds to the
1098 by using the ipmagic function (which IPython automatically adds to the
1090 builtins):\\
1099 builtins):\\
1091 In [3]: stats = ipmagic('prun','-r print 4')
1100 In [3]: stats = ipmagic('prun','-r print 4')
1092
1101
1093 You can type ipmagic? for more details on ipmagic.
1102 You can type ipmagic? for more details on ipmagic.
1094
1103
1095 -s <key>: sort profile by given key. You can provide more than one key
1104 -s <key>: sort profile by given key. You can provide more than one key
1096 by using the option several times: '-s key1 -s key2 -s key3...'. The
1105 by using the option several times: '-s key1 -s key2 -s key3...'. The
1097 default sorting key is 'time'.
1106 default sorting key is 'time'.
1098
1107
1099 The following is copied verbatim from the profile documentation
1108 The following is copied verbatim from the profile documentation
1100 referenced below:
1109 referenced below:
1101
1110
1102 When more than one key is provided, additional keys are used as
1111 When more than one key is provided, additional keys are used as
1103 secondary criteria when the there is equality in all keys selected
1112 secondary criteria when the there is equality in all keys selected
1104 before them.
1113 before them.
1105
1114
1106 Abbreviations can be used for any key names, as long as the
1115 Abbreviations can be used for any key names, as long as the
1107 abbreviation is unambiguous. The following are the keys currently
1116 abbreviation is unambiguous. The following are the keys currently
1108 defined:
1117 defined:
1109
1118
1110 Valid Arg Meaning\\
1119 Valid Arg Meaning\\
1111 "calls" call count\\
1120 "calls" call count\\
1112 "cumulative" cumulative time\\
1121 "cumulative" cumulative time\\
1113 "file" file name\\
1122 "file" file name\\
1114 "module" file name\\
1123 "module" file name\\
1115 "pcalls" primitive call count\\
1124 "pcalls" primitive call count\\
1116 "line" line number\\
1125 "line" line number\\
1117 "name" function name\\
1126 "name" function name\\
1118 "nfl" name/file/line\\
1127 "nfl" name/file/line\\
1119 "stdname" standard name\\
1128 "stdname" standard name\\
1120 "time" internal time
1129 "time" internal time
1121
1130
1122 Note that all sorts on statistics are in descending order (placing
1131 Note that all sorts on statistics are in descending order (placing
1123 most time consuming items first), where as name, file, and line number
1132 most time consuming items first), where as name, file, and line number
1124 searches are in ascending order (i.e., alphabetical). The subtle
1133 searches are in ascending order (i.e., alphabetical). The subtle
1125 distinction between "nfl" and "stdname" is that the standard name is a
1134 distinction between "nfl" and "stdname" is that the standard name is a
1126 sort of the name as printed, which means that the embedded line
1135 sort of the name as printed, which means that the embedded line
1127 numbers get compared in an odd way. For example, lines 3, 20, and 40
1136 numbers get compared in an odd way. For example, lines 3, 20, and 40
1128 would (if the file names were the same) appear in the string order
1137 would (if the file names were the same) appear in the string order
1129 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1138 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1130 line numbers. In fact, sort_stats("nfl") is the same as
1139 line numbers. In fact, sort_stats("nfl") is the same as
1131 sort_stats("name", "file", "line").
1140 sort_stats("name", "file", "line").
1132
1141
1133 -T <filename>: save profile results as shown on screen to a text
1142 -T <filename>: save profile results as shown on screen to a text
1134 file. The profile is still shown on screen.
1143 file. The profile is still shown on screen.
1135
1144
1136 -D <filename>: save (via dump_stats) profile statistics to given
1145 -D <filename>: save (via dump_stats) profile statistics to given
1137 filename. This data is in a format understod by the pstats module, and
1146 filename. This data is in a format understod by the pstats module, and
1138 is generated by a call to the dump_stats() method of profile
1147 is generated by a call to the dump_stats() method of profile
1139 objects. The profile is still shown on screen.
1148 objects. The profile is still shown on screen.
1140
1149
1141 If you want to run complete programs under the profiler's control, use
1150 If you want to run complete programs under the profiler's control, use
1142 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1151 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1143 contains profiler specific options as described here.
1152 contains profiler specific options as described here.
1144
1153
1145 You can read the complete documentation for the profile module with:\\
1154 You can read the complete documentation for the profile module with:\\
1146 In [1]: import profile; profile.help() """
1155 In [1]: import profile; profile.help() """
1147
1156
1148 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1157 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1149 # protect user quote marks
1158 # protect user quote marks
1150 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1159 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1151
1160
1152 if user_mode: # regular user call
1161 if user_mode: # regular user call
1153 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1162 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1154 list_all=1)
1163 list_all=1)
1155 namespace = self.shell.user_ns
1164 namespace = self.shell.user_ns
1156 else: # called to run a program by %run -p
1165 else: # called to run a program by %run -p
1157 try:
1166 try:
1158 filename = get_py_filename(arg_lst[0])
1167 filename = get_py_filename(arg_lst[0])
1159 except IOError,msg:
1168 except IOError,msg:
1160 error(msg)
1169 error(msg)
1161 return
1170 return
1162
1171
1163 arg_str = 'execfile(filename,prog_ns)'
1172 arg_str = 'execfile(filename,prog_ns)'
1164 namespace = locals()
1173 namespace = locals()
1165
1174
1166 opts.merge(opts_def)
1175 opts.merge(opts_def)
1167
1176
1168 prof = profile.Profile()
1177 prof = profile.Profile()
1169 try:
1178 try:
1170 prof = prof.runctx(arg_str,namespace,namespace)
1179 prof = prof.runctx(arg_str,namespace,namespace)
1171 sys_exit = ''
1180 sys_exit = ''
1172 except SystemExit:
1181 except SystemExit:
1173 sys_exit = """*** SystemExit exception caught in code being profiled."""
1182 sys_exit = """*** SystemExit exception caught in code being profiled."""
1174
1183
1175 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1184 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1176
1185
1177 lims = opts.l
1186 lims = opts.l
1178 if lims:
1187 if lims:
1179 lims = [] # rebuild lims with ints/floats/strings
1188 lims = [] # rebuild lims with ints/floats/strings
1180 for lim in opts.l:
1189 for lim in opts.l:
1181 try:
1190 try:
1182 lims.append(int(lim))
1191 lims.append(int(lim))
1183 except ValueError:
1192 except ValueError:
1184 try:
1193 try:
1185 lims.append(float(lim))
1194 lims.append(float(lim))
1186 except ValueError:
1195 except ValueError:
1187 lims.append(lim)
1196 lims.append(lim)
1188
1197
1189 # trap output
1198 # trap output
1190 sys_stdout = sys.stdout
1199 sys_stdout = sys.stdout
1191 stdout_trap = StringIO()
1200 stdout_trap = StringIO()
1192 try:
1201 try:
1193 sys.stdout = stdout_trap
1202 sys.stdout = stdout_trap
1194 stats.print_stats(*lims)
1203 stats.print_stats(*lims)
1195 finally:
1204 finally:
1196 sys.stdout = sys_stdout
1205 sys.stdout = sys_stdout
1197 output = stdout_trap.getvalue()
1206 output = stdout_trap.getvalue()
1198 output = output.rstrip()
1207 output = output.rstrip()
1199
1208
1200 page(output,screen_lines=self.shell.rc.screen_length)
1209 page(output,screen_lines=self.shell.rc.screen_length)
1201 print sys_exit,
1210 print sys_exit,
1202
1211
1203 dump_file = opts.D[0]
1212 dump_file = opts.D[0]
1204 text_file = opts.T[0]
1213 text_file = opts.T[0]
1205 if dump_file:
1214 if dump_file:
1206 prof.dump_stats(dump_file)
1215 prof.dump_stats(dump_file)
1207 print '\n*** Profile stats marshalled to file',\
1216 print '\n*** Profile stats marshalled to file',\
1208 `dump_file`+'.',sys_exit
1217 `dump_file`+'.',sys_exit
1209 if text_file:
1218 if text_file:
1210 file(text_file,'w').write(output)
1219 file(text_file,'w').write(output)
1211 print '\n*** Profile printout saved to text file',\
1220 print '\n*** Profile printout saved to text file',\
1212 `text_file`+'.',sys_exit
1221 `text_file`+'.',sys_exit
1213
1222
1214 if opts.has_key('r'):
1223 if opts.has_key('r'):
1215 return stats
1224 return stats
1216 else:
1225 else:
1217 return None
1226 return None
1218
1227
1219 def magic_run(self, parameter_s ='',runner=None):
1228 def magic_run(self, parameter_s ='',runner=None):
1220 """Run the named file inside IPython as a program.
1229 """Run the named file inside IPython as a program.
1221
1230
1222 Usage:\\
1231 Usage:\\
1223 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1232 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1224
1233
1225 Parameters after the filename are passed as command-line arguments to
1234 Parameters after the filename are passed as command-line arguments to
1226 the program (put in sys.argv). Then, control returns to IPython's
1235 the program (put in sys.argv). Then, control returns to IPython's
1227 prompt.
1236 prompt.
1228
1237
1229 This is similar to running at a system prompt:\\
1238 This is similar to running at a system prompt:\\
1230 $ python file args\\
1239 $ python file args\\
1231 but with the advantage of giving you IPython's tracebacks, and of
1240 but with the advantage of giving you IPython's tracebacks, and of
1232 loading all variables into your interactive namespace for further use
1241 loading all variables into your interactive namespace for further use
1233 (unless -p is used, see below).
1242 (unless -p is used, see below).
1234
1243
1235 The file is executed in a namespace initially consisting only of
1244 The file is executed in a namespace initially consisting only of
1236 __name__=='__main__' and sys.argv constructed as indicated. It thus
1245 __name__=='__main__' and sys.argv constructed as indicated. It thus
1237 sees its environment as if it were being run as a stand-alone
1246 sees its environment as if it were being run as a stand-alone
1238 program. But after execution, the IPython interactive namespace gets
1247 program. But after execution, the IPython interactive namespace gets
1239 updated with all variables defined in the program (except for __name__
1248 updated with all variables defined in the program (except for __name__
1240 and sys.argv). This allows for very convenient loading of code for
1249 and sys.argv). This allows for very convenient loading of code for
1241 interactive work, while giving each program a 'clean sheet' to run in.
1250 interactive work, while giving each program a 'clean sheet' to run in.
1242
1251
1243 Options:
1252 Options:
1244
1253
1245 -n: __name__ is NOT set to '__main__', but to the running file's name
1254 -n: __name__ is NOT set to '__main__', but to the running file's name
1246 without extension (as python does under import). This allows running
1255 without extension (as python does under import). This allows running
1247 scripts and reloading the definitions in them without calling code
1256 scripts and reloading the definitions in them without calling code
1248 protected by an ' if __name__ == "__main__" ' clause.
1257 protected by an ' if __name__ == "__main__" ' clause.
1249
1258
1250 -i: run the file in IPython's namespace instead of an empty one. This
1259 -i: run the file in IPython's namespace instead of an empty one. This
1251 is useful if you are experimenting with code written in a text editor
1260 is useful if you are experimenting with code written in a text editor
1252 which depends on variables defined interactively.
1261 which depends on variables defined interactively.
1253
1262
1254 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1263 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1255 being run. This is particularly useful if IPython is being used to
1264 being run. This is particularly useful if IPython is being used to
1256 run unittests, which always exit with a sys.exit() call. In such
1265 run unittests, which always exit with a sys.exit() call. In such
1257 cases you are interested in the output of the test results, not in
1266 cases you are interested in the output of the test results, not in
1258 seeing a traceback of the unittest module.
1267 seeing a traceback of the unittest module.
1259
1268
1260 -t: print timing information at the end of the run. IPython will give
1269 -t: print timing information at the end of the run. IPython will give
1261 you an estimated CPU time consumption for your script, which under
1270 you an estimated CPU time consumption for your script, which under
1262 Unix uses the resource module to avoid the wraparound problems of
1271 Unix uses the resource module to avoid the wraparound problems of
1263 time.clock(). Under Unix, an estimate of time spent on system tasks
1272 time.clock(). Under Unix, an estimate of time spent on system tasks
1264 is also given (for Windows platforms this is reported as 0.0).
1273 is also given (for Windows platforms this is reported as 0.0).
1265
1274
1266 If -t is given, an additional -N<N> option can be given, where <N>
1275 If -t is given, an additional -N<N> option can be given, where <N>
1267 must be an integer indicating how many times you want the script to
1276 must be an integer indicating how many times you want the script to
1268 run. The final timing report will include total and per run results.
1277 run. The final timing report will include total and per run results.
1269
1278
1270 For example (testing the script uniq_stable.py):
1279 For example (testing the script uniq_stable.py):
1271
1280
1272 In [1]: run -t uniq_stable
1281 In [1]: run -t uniq_stable
1273
1282
1274 IPython CPU timings (estimated):\\
1283 IPython CPU timings (estimated):\\
1275 User : 0.19597 s.\\
1284 User : 0.19597 s.\\
1276 System: 0.0 s.\\
1285 System: 0.0 s.\\
1277
1286
1278 In [2]: run -t -N5 uniq_stable
1287 In [2]: run -t -N5 uniq_stable
1279
1288
1280 IPython CPU timings (estimated):\\
1289 IPython CPU timings (estimated):\\
1281 Total runs performed: 5\\
1290 Total runs performed: 5\\
1282 Times : Total Per run\\
1291 Times : Total Per run\\
1283 User : 0.910862 s, 0.1821724 s.\\
1292 User : 0.910862 s, 0.1821724 s.\\
1284 System: 0.0 s, 0.0 s.
1293 System: 0.0 s, 0.0 s.
1285
1294
1286 -d: run your program under the control of pdb, the Python debugger.
1295 -d: run your program under the control of pdb, the Python debugger.
1287 This allows you to execute your program step by step, watch variables,
1296 This allows you to execute your program step by step, watch variables,
1288 etc. Internally, what IPython does is similar to calling:
1297 etc. Internally, what IPython does is similar to calling:
1289
1298
1290 pdb.run('execfile("YOURFILENAME")')
1299 pdb.run('execfile("YOURFILENAME")')
1291
1300
1292 with a breakpoint set on line 1 of your file. You can change the line
1301 with a breakpoint set on line 1 of your file. You can change the line
1293 number for this automatic breakpoint to be <N> by using the -bN option
1302 number for this automatic breakpoint to be <N> by using the -bN option
1294 (where N must be an integer). For example:
1303 (where N must be an integer). For example:
1295
1304
1296 %run -d -b40 myscript
1305 %run -d -b40 myscript
1297
1306
1298 will set the first breakpoint at line 40 in myscript.py. Note that
1307 will set the first breakpoint at line 40 in myscript.py. Note that
1299 the first breakpoint must be set on a line which actually does
1308 the first breakpoint must be set on a line which actually does
1300 something (not a comment or docstring) for it to stop execution.
1309 something (not a comment or docstring) for it to stop execution.
1301
1310
1302 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1311 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1303 first enter 'c' (without qoutes) to start execution up to the first
1312 first enter 'c' (without qoutes) to start execution up to the first
1304 breakpoint.
1313 breakpoint.
1305
1314
1306 Entering 'help' gives information about the use of the debugger. You
1315 Entering 'help' gives information about the use of the debugger. You
1307 can easily see pdb's full documentation with "import pdb;pdb.help()"
1316 can easily see pdb's full documentation with "import pdb;pdb.help()"
1308 at a prompt.
1317 at a prompt.
1309
1318
1310 -p: run program under the control of the Python profiler module (which
1319 -p: run program under the control of the Python profiler module (which
1311 prints a detailed report of execution times, function calls, etc).
1320 prints a detailed report of execution times, function calls, etc).
1312
1321
1313 You can pass other options after -p which affect the behavior of the
1322 You can pass other options after -p which affect the behavior of the
1314 profiler itself. See the docs for %prun for details.
1323 profiler itself. See the docs for %prun for details.
1315
1324
1316 In this mode, the program's variables do NOT propagate back to the
1325 In this mode, the program's variables do NOT propagate back to the
1317 IPython interactive namespace (because they remain in the namespace
1326 IPython interactive namespace (because they remain in the namespace
1318 where the profiler executes them).
1327 where the profiler executes them).
1319
1328
1320 Internally this triggers a call to %prun, see its documentation for
1329 Internally this triggers a call to %prun, see its documentation for
1321 details on the options available specifically for profiling."""
1330 details on the options available specifically for profiling."""
1322
1331
1323 # get arguments and set sys.argv for program to be run.
1332 # get arguments and set sys.argv for program to be run.
1324 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1333 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1325 mode='list',list_all=1)
1334 mode='list',list_all=1)
1326
1335
1327 try:
1336 try:
1328 filename = get_py_filename(arg_lst[0])
1337 filename = get_py_filename(arg_lst[0])
1329 except IndexError:
1338 except IndexError:
1330 warn('you must provide at least a filename.')
1339 warn('you must provide at least a filename.')
1331 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1340 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1332 return
1341 return
1333 except IOError,msg:
1342 except IOError,msg:
1334 error(msg)
1343 error(msg)
1335 return
1344 return
1336
1345
1337 # Control the response to exit() calls made by the script being run
1346 # Control the response to exit() calls made by the script being run
1338 exit_ignore = opts.has_key('e')
1347 exit_ignore = opts.has_key('e')
1339
1348
1340 # Make sure that the running script gets a proper sys.argv as if it
1349 # Make sure that the running script gets a proper sys.argv as if it
1341 # were run from a system shell.
1350 # were run from a system shell.
1342 save_argv = sys.argv # save it for later restoring
1351 save_argv = sys.argv # save it for later restoring
1343 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1352 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1344
1353
1345 if opts.has_key('i'):
1354 if opts.has_key('i'):
1346 prog_ns = self.shell.user_ns
1355 prog_ns = self.shell.user_ns
1347 __name__save = self.shell.user_ns['__name__']
1356 __name__save = self.shell.user_ns['__name__']
1348 prog_ns['__name__'] = '__main__'
1357 prog_ns['__name__'] = '__main__'
1349 else:
1358 else:
1350 if opts.has_key('n'):
1359 if opts.has_key('n'):
1351 name = os.path.splitext(os.path.basename(filename))[0]
1360 name = os.path.splitext(os.path.basename(filename))[0]
1352 else:
1361 else:
1353 name = '__main__'
1362 name = '__main__'
1354 prog_ns = {'__name__':name}
1363 prog_ns = {'__name__':name}
1355
1364
1356 # pickle fix. See iplib for an explanation. But we need to make sure
1365 # pickle fix. See iplib for an explanation. But we need to make sure
1357 # that, if we overwrite __main__, we replace it at the end
1366 # that, if we overwrite __main__, we replace it at the end
1358 if prog_ns['__name__'] == '__main__':
1367 if prog_ns['__name__'] == '__main__':
1359 restore_main = sys.modules['__main__']
1368 restore_main = sys.modules['__main__']
1360 else:
1369 else:
1361 restore_main = False
1370 restore_main = False
1362
1371
1363 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1372 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1364
1373
1365 stats = None
1374 stats = None
1366 try:
1375 try:
1367 if opts.has_key('p'):
1376 if opts.has_key('p'):
1368 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1377 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1369 else:
1378 else:
1370 if opts.has_key('d'):
1379 if opts.has_key('d'):
1371 deb = Debugger.Pdb(self.shell.rc.colors)
1380 deb = Debugger.Pdb(self.shell.rc.colors)
1372 # reset Breakpoint state, which is moronically kept
1381 # reset Breakpoint state, which is moronically kept
1373 # in a class
1382 # in a class
1374 bdb.Breakpoint.next = 1
1383 bdb.Breakpoint.next = 1
1375 bdb.Breakpoint.bplist = {}
1384 bdb.Breakpoint.bplist = {}
1376 bdb.Breakpoint.bpbynumber = [None]
1385 bdb.Breakpoint.bpbynumber = [None]
1377 # Set an initial breakpoint to stop execution
1386 # Set an initial breakpoint to stop execution
1378 maxtries = 10
1387 maxtries = 10
1379 bp = int(opts.get('b',[1])[0])
1388 bp = int(opts.get('b',[1])[0])
1380 checkline = deb.checkline(filename,bp)
1389 checkline = deb.checkline(filename,bp)
1381 if not checkline:
1390 if not checkline:
1382 for bp in range(bp+1,bp+maxtries+1):
1391 for bp in range(bp+1,bp+maxtries+1):
1383 if deb.checkline(filename,bp):
1392 if deb.checkline(filename,bp):
1384 break
1393 break
1385 else:
1394 else:
1386 msg = ("\nI failed to find a valid line to set "
1395 msg = ("\nI failed to find a valid line to set "
1387 "a breakpoint\n"
1396 "a breakpoint\n"
1388 "after trying up to line: %s.\n"
1397 "after trying up to line: %s.\n"
1389 "Please set a valid breakpoint manually "
1398 "Please set a valid breakpoint manually "
1390 "with the -b option." % bp)
1399 "with the -b option." % bp)
1391 error(msg)
1400 error(msg)
1392 return
1401 return
1393 # if we find a good linenumber, set the breakpoint
1402 # if we find a good linenumber, set the breakpoint
1394 deb.do_break('%s:%s' % (filename,bp))
1403 deb.do_break('%s:%s' % (filename,bp))
1395 # Start file run
1404 # Start file run
1396 print "NOTE: Enter 'c' at the",
1405 print "NOTE: Enter 'c' at the",
1397 print "ipdb> prompt to start your script."
1406 print "ipdb> prompt to start your script."
1398 try:
1407 try:
1399 deb.run('execfile("%s")' % filename,prog_ns)
1408 deb.run('execfile("%s")' % filename,prog_ns)
1400 except:
1409 except:
1401 etype, value, tb = sys.exc_info()
1410 etype, value, tb = sys.exc_info()
1402 # Skip three frames in the traceback: the %run one,
1411 # Skip three frames in the traceback: the %run one,
1403 # one inside bdb.py, and the command-line typed by the
1412 # one inside bdb.py, and the command-line typed by the
1404 # user (run by exec in pdb itself).
1413 # user (run by exec in pdb itself).
1405 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1414 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1406 else:
1415 else:
1407 if runner is None:
1416 if runner is None:
1408 runner = self.shell.safe_execfile
1417 runner = self.shell.safe_execfile
1409 if opts.has_key('t'):
1418 if opts.has_key('t'):
1410 try:
1419 try:
1411 nruns = int(opts['N'][0])
1420 nruns = int(opts['N'][0])
1412 if nruns < 1:
1421 if nruns < 1:
1413 error('Number of runs must be >=1')
1422 error('Number of runs must be >=1')
1414 return
1423 return
1415 except (KeyError):
1424 except (KeyError):
1416 nruns = 1
1425 nruns = 1
1417 if nruns == 1:
1426 if nruns == 1:
1418 t0 = clock2()
1427 t0 = clock2()
1419 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1428 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1420 t1 = clock2()
1429 t1 = clock2()
1421 t_usr = t1[0]-t0[0]
1430 t_usr = t1[0]-t0[0]
1422 t_sys = t1[1]-t1[1]
1431 t_sys = t1[1]-t1[1]
1423 print "\nIPython CPU timings (estimated):"
1432 print "\nIPython CPU timings (estimated):"
1424 print " User : %10s s." % t_usr
1433 print " User : %10s s." % t_usr
1425 print " System: %10s s." % t_sys
1434 print " System: %10s s." % t_sys
1426 else:
1435 else:
1427 runs = range(nruns)
1436 runs = range(nruns)
1428 t0 = clock2()
1437 t0 = clock2()
1429 for nr in runs:
1438 for nr in runs:
1430 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1439 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1431 t1 = clock2()
1440 t1 = clock2()
1432 t_usr = t1[0]-t0[0]
1441 t_usr = t1[0]-t0[0]
1433 t_sys = t1[1]-t1[1]
1442 t_sys = t1[1]-t1[1]
1434 print "\nIPython CPU timings (estimated):"
1443 print "\nIPython CPU timings (estimated):"
1435 print "Total runs performed:",nruns
1444 print "Total runs performed:",nruns
1436 print " Times : %10s %10s" % ('Total','Per run')
1445 print " Times : %10s %10s" % ('Total','Per run')
1437 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1446 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1438 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1447 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1439
1448
1440 else:
1449 else:
1441 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1450 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1442 if opts.has_key('i'):
1451 if opts.has_key('i'):
1443 self.shell.user_ns['__name__'] = __name__save
1452 self.shell.user_ns['__name__'] = __name__save
1444 else:
1453 else:
1445 # update IPython interactive namespace
1454 # update IPython interactive namespace
1446 del prog_ns['__name__']
1455 del prog_ns['__name__']
1447 self.shell.user_ns.update(prog_ns)
1456 self.shell.user_ns.update(prog_ns)
1448 finally:
1457 finally:
1449 sys.argv = save_argv
1458 sys.argv = save_argv
1450 if restore_main:
1459 if restore_main:
1451 sys.modules['__main__'] = restore_main
1460 sys.modules['__main__'] = restore_main
1452 return stats
1461 return stats
1453
1462
1454 def magic_runlog(self, parameter_s =''):
1463 def magic_runlog(self, parameter_s =''):
1455 """Run files as logs.
1464 """Run files as logs.
1456
1465
1457 Usage:\\
1466 Usage:\\
1458 %runlog file1 file2 ...
1467 %runlog file1 file2 ...
1459
1468
1460 Run the named files (treating them as log files) in sequence inside
1469 Run the named files (treating them as log files) in sequence inside
1461 the interpreter, and return to the prompt. This is much slower than
1470 the interpreter, and return to the prompt. This is much slower than
1462 %run because each line is executed in a try/except block, but it
1471 %run because each line is executed in a try/except block, but it
1463 allows running files with syntax errors in them.
1472 allows running files with syntax errors in them.
1464
1473
1465 Normally IPython will guess when a file is one of its own logfiles, so
1474 Normally IPython will guess when a file is one of its own logfiles, so
1466 you can typically use %run even for logs. This shorthand allows you to
1475 you can typically use %run even for logs. This shorthand allows you to
1467 force any file to be treated as a log file."""
1476 force any file to be treated as a log file."""
1468
1477
1469 for f in parameter_s.split():
1478 for f in parameter_s.split():
1470 self.shell.safe_execfile(f,self.shell.user_ns,
1479 self.shell.safe_execfile(f,self.shell.user_ns,
1471 self.shell.user_ns,islog=1)
1480 self.shell.user_ns,islog=1)
1472
1481
1473 def magic_time(self,parameter_s = ''):
1482 def magic_time(self,parameter_s = ''):
1474 """Time execution of a Python statement or expression.
1483 """Time execution of a Python statement or expression.
1475
1484
1476 The CPU and wall clock times are printed, and the value of the
1485 The CPU and wall clock times are printed, and the value of the
1477 expression (if any) is returned. Note that under Win32, system time
1486 expression (if any) is returned. Note that under Win32, system time
1478 is always reported as 0, since it can not be measured.
1487 is always reported as 0, since it can not be measured.
1479
1488
1480 This function provides very basic timing functionality. In Python
1489 This function provides very basic timing functionality. In Python
1481 2.3, the timeit module offers more control and sophistication, but for
1490 2.3, the timeit module offers more control and sophistication, but for
1482 now IPython supports Python 2.2, so we can not rely on timeit being
1491 now IPython supports Python 2.2, so we can not rely on timeit being
1483 present.
1492 present.
1484
1493
1485 Some examples:
1494 Some examples:
1486
1495
1487 In [1]: time 2**128
1496 In [1]: time 2**128
1488 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1497 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1489 Wall time: 0.00
1498 Wall time: 0.00
1490 Out[1]: 340282366920938463463374607431768211456L
1499 Out[1]: 340282366920938463463374607431768211456L
1491
1500
1492 In [2]: n = 1000000
1501 In [2]: n = 1000000
1493
1502
1494 In [3]: time sum(range(n))
1503 In [3]: time sum(range(n))
1495 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1504 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1496 Wall time: 1.37
1505 Wall time: 1.37
1497 Out[3]: 499999500000L
1506 Out[3]: 499999500000L
1498
1507
1499 In [4]: time print 'hello world'
1508 In [4]: time print 'hello world'
1500 hello world
1509 hello world
1501 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1510 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1502 Wall time: 0.00
1511 Wall time: 0.00
1503 """
1512 """
1504
1513
1505 # fail immediately if the given expression can't be compiled
1514 # fail immediately if the given expression can't be compiled
1506 try:
1515 try:
1507 mode = 'eval'
1516 mode = 'eval'
1508 code = compile(parameter_s,'<timed eval>',mode)
1517 code = compile(parameter_s,'<timed eval>',mode)
1509 except SyntaxError:
1518 except SyntaxError:
1510 mode = 'exec'
1519 mode = 'exec'
1511 code = compile(parameter_s,'<timed exec>',mode)
1520 code = compile(parameter_s,'<timed exec>',mode)
1512 # skew measurement as little as possible
1521 # skew measurement as little as possible
1513 glob = self.shell.user_ns
1522 glob = self.shell.user_ns
1514 clk = clock2
1523 clk = clock2
1515 wtime = time.time
1524 wtime = time.time
1516 # time execution
1525 # time execution
1517 wall_st = wtime()
1526 wall_st = wtime()
1518 if mode=='eval':
1527 if mode=='eval':
1519 st = clk()
1528 st = clk()
1520 out = eval(code,glob)
1529 out = eval(code,glob)
1521 end = clk()
1530 end = clk()
1522 else:
1531 else:
1523 st = clk()
1532 st = clk()
1524 exec code in glob
1533 exec code in glob
1525 end = clk()
1534 end = clk()
1526 out = None
1535 out = None
1527 wall_end = wtime()
1536 wall_end = wtime()
1528 # Compute actual times and report
1537 # Compute actual times and report
1529 wall_time = wall_end-wall_st
1538 wall_time = wall_end-wall_st
1530 cpu_user = end[0]-st[0]
1539 cpu_user = end[0]-st[0]
1531 cpu_sys = end[1]-st[1]
1540 cpu_sys = end[1]-st[1]
1532 cpu_tot = cpu_user+cpu_sys
1541 cpu_tot = cpu_user+cpu_sys
1533 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1542 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1534 (cpu_user,cpu_sys,cpu_tot)
1543 (cpu_user,cpu_sys,cpu_tot)
1535 print "Wall time: %.2f" % wall_time
1544 print "Wall time: %.2f" % wall_time
1536 return out
1545 return out
1537
1546
1538 def magic_macro(self,parameter_s = ''):
1547 def magic_macro(self,parameter_s = ''):
1539 """Define a set of input lines as a macro for future re-execution.
1548 """Define a set of input lines as a macro for future re-execution.
1540
1549
1541 Usage:\\
1550 Usage:\\
1542 %macro name n1:n2 n3:n4 ... n5 .. n6 ...
1551 %macro name n1-n2 n3-n4 ... n5 .. n6 ...
1543
1552
1544 This will define a global variable called `name` which is a string
1553 This will define a global variable called `name` which is a string
1545 made of joining the slices and lines you specify (n1,n2,... numbers
1554 made of joining the slices and lines you specify (n1,n2,... numbers
1546 above) from your input history into a single string. This variable
1555 above) from your input history into a single string. This variable
1547 acts like an automatic function which re-executes those lines as if
1556 acts like an automatic function which re-executes those lines as if
1548 you had typed them. You just type 'name' at the prompt and the code
1557 you had typed them. You just type 'name' at the prompt and the code
1549 executes.
1558 executes.
1550
1559
1551 Note that the slices use the standard Python slicing notation (5:8
1560 The notation for indicating number ranges is: n1-n2 means 'use line
1552 means include lines numbered 5,6,7).
1561 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1562 using the lines numbered 5,6 and 7.
1563
1564 Note: as a 'hidden' feature, you can also use traditional python slice
1565 notation, where N:M means numbers N through M-1.
1553
1566
1554 For example, if your history contains (%hist prints it):
1567 For example, if your history contains (%hist prints it):
1555
1568
1556 44: x=1\\
1569 44: x=1\\
1557 45: y=3\\
1570 45: y=3\\
1558 46: z=x+y\\
1571 46: z=x+y\\
1559 47: print x\\
1572 47: print x\\
1560 48: a=5\\
1573 48: a=5\\
1561 49: print 'x',x,'y',y\\
1574 49: print 'x',x,'y',y\\
1562
1575
1563 you can create a macro with lines 44 through 47 (included) and line 49
1576 you can create a macro with lines 44 through 47 (included) and line 49
1564 called my_macro with:
1577 called my_macro with:
1565
1578
1566 In [51]: %macro my_macro 44:48 49
1579 In [51]: %macro my_macro 44-47 49
1567
1580
1568 Now, typing `my_macro` (without quotes) will re-execute all this code
1581 Now, typing `my_macro` (without quotes) will re-execute all this code
1569 in one pass.
1582 in one pass.
1570
1583
1571 You don't need to give the line-numbers in order, and any given line
1584 You don't need to give the line-numbers in order, and any given line
1572 number can appear multiple times. You can assemble macros with any
1585 number can appear multiple times. You can assemble macros with any
1573 lines from your input history in any order.
1586 lines from your input history in any order.
1574
1587
1575 The macro is a simple object which holds its value in an attribute,
1588 The macro is a simple object which holds its value in an attribute,
1576 but IPython's display system checks for macros and executes them as
1589 but IPython's display system checks for macros and executes them as
1577 code instead of printing them when you type their name.
1590 code instead of printing them when you type their name.
1578
1591
1579 You can view a macro's contents by explicitly printing it with:
1592 You can view a macro's contents by explicitly printing it with:
1580
1593
1581 'print macro_name'.
1594 'print macro_name'.
1582
1595
1583 For one-off cases which DON'T contain magic function calls in them you
1596 For one-off cases which DON'T contain magic function calls in them you
1584 can obtain similar results by explicitly executing slices from your
1597 can obtain similar results by explicitly executing slices from your
1585 input history with:
1598 input history with:
1586
1599
1587 In [60]: exec In[44:48]+In[49]"""
1600 In [60]: exec In[44:48]+In[49]"""
1588
1601
1589 args = parameter_s.split()
1602 args = parameter_s.split()
1590 name,ranges = args[0], args[1:]
1603 name,ranges = args[0], args[1:]
1591 #print 'rng',ranges # dbg
1604 #print 'rng',ranges # dbg
1592 lines = self.extract_input_slices(ranges)
1605 lines = self.extract_input_slices(ranges)
1593 macro = Macro(lines)
1606 macro = Macro(lines)
1594 self.shell.user_ns.update({name:macro})
1607 self.shell.user_ns.update({name:macro})
1595 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1608 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1596 print 'Macro contents:'
1609 print 'Macro contents:'
1597 print macro,
1610 print macro,
1598
1611
1599 def magic_save(self,parameter_s = ''):
1612 def magic_save(self,parameter_s = ''):
1600 """Save a set of lines to a given filename.
1613 """Save a set of lines to a given filename.
1601
1614
1602 Usage:\\
1615 Usage:\\
1603 %save filename n1:n2 n3:n4 ... n5 .. n6 ...
1616 %save filename n1-n2 n3-n4 ... n5 .. n6 ...
1604
1617
1605 This function uses the same syntax as %macro for line extraction, but
1618 This function uses the same syntax as %macro for line extraction, but
1606 instead of creating a macro it saves the resulting string to the
1619 instead of creating a macro it saves the resulting string to the
1607 filename you specify.
1620 filename you specify.
1608
1621
1609 It adds a '.py' extension to the file if you don't do so yourself, and
1622 It adds a '.py' extension to the file if you don't do so yourself, and
1610 it asks for confirmation before overwriting existing files."""
1623 it asks for confirmation before overwriting existing files."""
1611
1624
1612 args = parameter_s.split()
1625 args = parameter_s.split()
1613 fname,ranges = args[0], args[1:]
1626 fname,ranges = args[0], args[1:]
1614 if not fname.endswith('.py'):
1627 if not fname.endswith('.py'):
1615 fname += '.py'
1628 fname += '.py'
1616 if os.path.isfile(fname):
1629 if os.path.isfile(fname):
1617 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1630 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1618 if ans.lower() not in ['y','yes']:
1631 if ans.lower() not in ['y','yes']:
1619 print 'Operation cancelled.'
1632 print 'Operation cancelled.'
1620 return
1633 return
1621 cmds = ''.join(self.extract_input_slices(ranges))
1634 cmds = ''.join(self.extract_input_slices(ranges))
1622 f = file(fname,'w')
1635 f = file(fname,'w')
1623 f.write(cmds)
1636 f.write(cmds)
1624 f.close()
1637 f.close()
1625 print 'The following commands were written to file `%s`:' % fname
1638 print 'The following commands were written to file `%s`:' % fname
1626 print cmds
1639 print cmds
1627
1640
1628 def magic_ed(self,parameter_s = ''):
1641 def magic_ed(self,parameter_s = ''):
1629 """Alias to %edit."""
1642 """Alias to %edit."""
1630 return self.magic_edit(parameter_s)
1643 return self.magic_edit(parameter_s)
1631
1644
1632 def magic_edit(self,parameter_s = '',last_call=['','']):
1645 def magic_edit(self,parameter_s = '',last_call=['','']):
1633 """Bring up an editor and execute the resulting code.
1646 """Bring up an editor and execute the resulting code.
1634
1647
1635 Usage:
1648 Usage:
1636 %edit [options] [args]
1649 %edit [options] [args]
1637
1650
1638 %edit runs IPython's editor hook. The default version of this hook is
1651 %edit runs IPython's editor hook. The default version of this hook is
1639 set to call the __IPYTHON__.rc.editor command. This is read from your
1652 set to call the __IPYTHON__.rc.editor command. This is read from your
1640 environment variable $EDITOR. If this isn't found, it will default to
1653 environment variable $EDITOR. If this isn't found, it will default to
1641 vi under Linux/Unix and to notepad under Windows. See the end of this
1654 vi under Linux/Unix and to notepad under Windows. See the end of this
1642 docstring for how to change the editor hook.
1655 docstring for how to change the editor hook.
1643
1656
1644 You can also set the value of this editor via the command line option
1657 You can also set the value of this editor via the command line option
1645 '-editor' or in your ipythonrc file. This is useful if you wish to use
1658 '-editor' or in your ipythonrc file. This is useful if you wish to use
1646 specifically for IPython an editor different from your typical default
1659 specifically for IPython an editor different from your typical default
1647 (and for Windows users who typically don't set environment variables).
1660 (and for Windows users who typically don't set environment variables).
1648
1661
1649 This command allows you to conveniently edit multi-line code right in
1662 This command allows you to conveniently edit multi-line code right in
1650 your IPython session.
1663 your IPython session.
1651
1664
1652 If called without arguments, %edit opens up an empty editor with a
1665 If called without arguments, %edit opens up an empty editor with a
1653 temporary file and will execute the contents of this file when you
1666 temporary file and will execute the contents of this file when you
1654 close it (don't forget to save it!).
1667 close it (don't forget to save it!).
1655
1668
1656 Options:
1669 Options:
1657
1670
1658 -p: this will call the editor with the same data as the previous time
1671 -p: this will call the editor with the same data as the previous time
1659 it was used, regardless of how long ago (in your current session) it
1672 it was used, regardless of how long ago (in your current session) it
1660 was.
1673 was.
1661
1674
1662 -x: do not execute the edited code immediately upon exit. This is
1675 -x: do not execute the edited code immediately upon exit. This is
1663 mainly useful if you are editing programs which need to be called with
1676 mainly useful if you are editing programs which need to be called with
1664 command line arguments, which you can then do using %run.
1677 command line arguments, which you can then do using %run.
1665
1678
1666 Arguments:
1679 Arguments:
1667
1680
1668 If arguments are given, the following possibilites exist:
1681 If arguments are given, the following possibilites exist:
1669
1682
1670 - The arguments are numbers or pairs of colon-separated numbers (like
1683 - The arguments are numbers or pairs of colon-separated numbers (like
1671 1 4:8 9). These are interpreted as lines of previous input to be
1684 1 4:8 9). These are interpreted as lines of previous input to be
1672 loaded into the editor. The syntax is the same of the %macro command.
1685 loaded into the editor. The syntax is the same of the %macro command.
1673
1686
1674 - If the argument doesn't start with a number, it is evaluated as a
1687 - If the argument doesn't start with a number, it is evaluated as a
1675 variable and its contents loaded into the editor. You can thus edit
1688 variable and its contents loaded into the editor. You can thus edit
1676 any string which contains python code (including the result of
1689 any string which contains python code (including the result of
1677 previous edits).
1690 previous edits).
1678
1691
1679 - If the argument is the name of an object (other than a string),
1692 - If the argument is the name of an object (other than a string),
1680 IPython will try to locate the file where it was defined and open the
1693 IPython will try to locate the file where it was defined and open the
1681 editor at the point where it is defined. You can use `%edit function`
1694 editor at the point where it is defined. You can use `%edit function`
1682 to load an editor exactly at the point where 'function' is defined,
1695 to load an editor exactly at the point where 'function' is defined,
1683 edit it and have the file be executed automatically.
1696 edit it and have the file be executed automatically.
1684
1697
1685 Note: opening at an exact line is only supported under Unix, and some
1698 Note: opening at an exact line is only supported under Unix, and some
1686 editors (like kedit and gedit up to Gnome 2.8) do not understand the
1699 editors (like kedit and gedit up to Gnome 2.8) do not understand the
1687 '+NUMBER' parameter necessary for this feature. Good editors like
1700 '+NUMBER' parameter necessary for this feature. Good editors like
1688 (X)Emacs, vi, jed, pico and joe all do.
1701 (X)Emacs, vi, jed, pico and joe all do.
1689
1702
1690 - If the argument is not found as a variable, IPython will look for a
1703 - If the argument is not found as a variable, IPython will look for a
1691 file with that name (adding .py if necessary) and load it into the
1704 file with that name (adding .py if necessary) and load it into the
1692 editor. It will execute its contents with execfile() when you exit,
1705 editor. It will execute its contents with execfile() when you exit,
1693 loading any code in the file into your interactive namespace.
1706 loading any code in the file into your interactive namespace.
1694
1707
1695 After executing your code, %edit will return as output the code you
1708 After executing your code, %edit will return as output the code you
1696 typed in the editor (except when it was an existing file). This way
1709 typed in the editor (except when it was an existing file). This way
1697 you can reload the code in further invocations of %edit as a variable,
1710 you can reload the code in further invocations of %edit as a variable,
1698 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
1711 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
1699 the output.
1712 the output.
1700
1713
1701 Note that %edit is also available through the alias %ed.
1714 Note that %edit is also available through the alias %ed.
1702
1715
1703 This is an example of creating a simple function inside the editor and
1716 This is an example of creating a simple function inside the editor and
1704 then modifying it. First, start up the editor:
1717 then modifying it. First, start up the editor:
1705
1718
1706 In [1]: ed\\
1719 In [1]: ed\\
1707 Editing... done. Executing edited code...\\
1720 Editing... done. Executing edited code...\\
1708 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
1721 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
1709
1722
1710 We can then call the function foo():
1723 We can then call the function foo():
1711
1724
1712 In [2]: foo()\\
1725 In [2]: foo()\\
1713 foo() was defined in an editing session
1726 foo() was defined in an editing session
1714
1727
1715 Now we edit foo. IPython automatically loads the editor with the
1728 Now we edit foo. IPython automatically loads the editor with the
1716 (temporary) file where foo() was previously defined:
1729 (temporary) file where foo() was previously defined:
1717
1730
1718 In [3]: ed foo\\
1731 In [3]: ed foo\\
1719 Editing... done. Executing edited code...
1732 Editing... done. Executing edited code...
1720
1733
1721 And if we call foo() again we get the modified version:
1734 And if we call foo() again we get the modified version:
1722
1735
1723 In [4]: foo()\\
1736 In [4]: foo()\\
1724 foo() has now been changed!
1737 foo() has now been changed!
1725
1738
1726 Here is an example of how to edit a code snippet successive
1739 Here is an example of how to edit a code snippet successive
1727 times. First we call the editor:
1740 times. First we call the editor:
1728
1741
1729 In [8]: ed\\
1742 In [8]: ed\\
1730 Editing... done. Executing edited code...\\
1743 Editing... done. Executing edited code...\\
1731 hello\\
1744 hello\\
1732 Out[8]: "print 'hello'\\n"
1745 Out[8]: "print 'hello'\\n"
1733
1746
1734 Now we call it again with the previous output (stored in _):
1747 Now we call it again with the previous output (stored in _):
1735
1748
1736 In [9]: ed _\\
1749 In [9]: ed _\\
1737 Editing... done. Executing edited code...\\
1750 Editing... done. Executing edited code...\\
1738 hello world\\
1751 hello world\\
1739 Out[9]: "print 'hello world'\\n"
1752 Out[9]: "print 'hello world'\\n"
1740
1753
1741 Now we call it with the output #8 (stored in _8, also as Out[8]):
1754 Now we call it with the output #8 (stored in _8, also as Out[8]):
1742
1755
1743 In [10]: ed _8\\
1756 In [10]: ed _8\\
1744 Editing... done. Executing edited code...\\
1757 Editing... done. Executing edited code...\\
1745 hello again\\
1758 hello again\\
1746 Out[10]: "print 'hello again'\\n"
1759 Out[10]: "print 'hello again'\\n"
1747
1760
1748
1761
1749 Changing the default editor hook:
1762 Changing the default editor hook:
1750
1763
1751 If you wish to write your own editor hook, you can put it in a
1764 If you wish to write your own editor hook, you can put it in a
1752 configuration file which you load at startup time. The default hook
1765 configuration file which you load at startup time. The default hook
1753 is defined in the IPython.hooks module, and you can use that as a
1766 is defined in the IPython.hooks module, and you can use that as a
1754 starting example for further modifications. That file also has
1767 starting example for further modifications. That file also has
1755 general instructions on how to set a new hook for use once you've
1768 general instructions on how to set a new hook for use once you've
1756 defined it."""
1769 defined it."""
1757
1770
1758 # FIXME: This function has become a convoluted mess. It needs a
1771 # FIXME: This function has become a convoluted mess. It needs a
1759 # ground-up rewrite with clean, simple logic.
1772 # ground-up rewrite with clean, simple logic.
1760
1773
1761 def make_filename(arg):
1774 def make_filename(arg):
1762 "Make a filename from the given args"
1775 "Make a filename from the given args"
1763 try:
1776 try:
1764 filename = get_py_filename(arg)
1777 filename = get_py_filename(arg)
1765 except IOError:
1778 except IOError:
1766 if args.endswith('.py'):
1779 if args.endswith('.py'):
1767 filename = arg
1780 filename = arg
1768 else:
1781 else:
1769 filename = None
1782 filename = None
1770 return filename
1783 return filename
1771
1784
1772 # custom exceptions
1785 # custom exceptions
1773 class DataIsObject(Exception): pass
1786 class DataIsObject(Exception): pass
1774
1787
1775 opts,args = self.parse_options(parameter_s,'px')
1788 opts,args = self.parse_options(parameter_s,'px')
1776
1789
1777 # Default line number value
1790 # Default line number value
1778 lineno = None
1791 lineno = None
1779 if opts.has_key('p'):
1792 if opts.has_key('p'):
1780 args = '_%s' % last_call[0]
1793 args = '_%s' % last_call[0]
1781 if not self.shell.user_ns.has_key(args):
1794 if not self.shell.user_ns.has_key(args):
1782 args = last_call[1]
1795 args = last_call[1]
1783
1796
1784 # use last_call to remember the state of the previous call, but don't
1797 # use last_call to remember the state of the previous call, but don't
1785 # let it be clobbered by successive '-p' calls.
1798 # let it be clobbered by successive '-p' calls.
1786 try:
1799 try:
1787 last_call[0] = self.shell.outputcache.prompt_count
1800 last_call[0] = self.shell.outputcache.prompt_count
1788 if not opts.has_key('p'):
1801 if not opts.has_key('p'):
1789 last_call[1] = parameter_s
1802 last_call[1] = parameter_s
1790 except:
1803 except:
1791 pass
1804 pass
1792
1805
1793 # by default this is done with temp files, except when the given
1806 # by default this is done with temp files, except when the given
1794 # arg is a filename
1807 # arg is a filename
1795 use_temp = 1
1808 use_temp = 1
1796
1809
1797 if re.match(r'\d',args):
1810 if re.match(r'\d',args):
1798 # Mode where user specifies ranges of lines, like in %macro.
1811 # Mode where user specifies ranges of lines, like in %macro.
1799 # This means that you can't edit files whose names begin with
1812 # This means that you can't edit files whose names begin with
1800 # numbers this way. Tough.
1813 # numbers this way. Tough.
1801 ranges = args.split()
1814 ranges = args.split()
1802 data = ''.join(self.extract_input_slices(ranges))
1815 data = ''.join(self.extract_input_slices(ranges))
1803 elif args.endswith('.py'):
1816 elif args.endswith('.py'):
1804 filename = make_filename(args)
1817 filename = make_filename(args)
1805 data = ''
1818 data = ''
1806 use_temp = 0
1819 use_temp = 0
1807 elif args:
1820 elif args:
1808 try:
1821 try:
1809 # Load the parameter given as a variable. If not a string,
1822 # Load the parameter given as a variable. If not a string,
1810 # process it as an object instead (below)
1823 # process it as an object instead (below)
1811
1824
1812 #print '*** args',args,'type',type(args) # dbg
1825 #print '*** args',args,'type',type(args) # dbg
1813 data = eval(args,self.shell.user_ns)
1826 data = eval(args,self.shell.user_ns)
1814 if not type(data) in StringTypes:
1827 if not type(data) in StringTypes:
1815 raise DataIsObject
1828 raise DataIsObject
1816 except (NameError,SyntaxError):
1829 except (NameError,SyntaxError):
1817 # given argument is not a variable, try as a filename
1830 # given argument is not a variable, try as a filename
1818 filename = make_filename(args)
1831 filename = make_filename(args)
1819 if filename is None:
1832 if filename is None:
1820 warn("Argument given (%s) can't be found as a variable "
1833 warn("Argument given (%s) can't be found as a variable "
1821 "or as a filename." % args)
1834 "or as a filename." % args)
1822 return
1835 return
1823 data = ''
1836 data = ''
1824 use_temp = 0
1837 use_temp = 0
1825 except DataIsObject:
1838 except DataIsObject:
1826 # For objects, try to edit the file where they are defined
1839 # For objects, try to edit the file where they are defined
1827 try:
1840 try:
1828 filename = inspect.getabsfile(data)
1841 filename = inspect.getabsfile(data)
1829 datafile = 1
1842 datafile = 1
1830 except TypeError:
1843 except TypeError:
1831 filename = make_filename(args)
1844 filename = make_filename(args)
1832 datafile = 1
1845 datafile = 1
1833 warn('Could not find file where `%s` is defined.\n'
1846 warn('Could not find file where `%s` is defined.\n'
1834 'Opening a file named `%s`' % (args,filename))
1847 'Opening a file named `%s`' % (args,filename))
1835 # Now, make sure we can actually read the source (if it was in
1848 # Now, make sure we can actually read the source (if it was in
1836 # a temp file it's gone by now).
1849 # a temp file it's gone by now).
1837 if datafile:
1850 if datafile:
1838 try:
1851 try:
1839 lineno = inspect.getsourcelines(data)[1]
1852 lineno = inspect.getsourcelines(data)[1]
1840 except IOError:
1853 except IOError:
1841 filename = make_filename(args)
1854 filename = make_filename(args)
1842 if filename is None:
1855 if filename is None:
1843 warn('The file `%s` where `%s` was defined cannot '
1856 warn('The file `%s` where `%s` was defined cannot '
1844 'be read.' % (filename,data))
1857 'be read.' % (filename,data))
1845 return
1858 return
1846 use_temp = 0
1859 use_temp = 0
1847 else:
1860 else:
1848 data = ''
1861 data = ''
1849
1862
1850 if use_temp:
1863 if use_temp:
1851 filename = tempfile.mktemp('.py')
1864 filename = tempfile.mktemp('.py')
1852 self.shell.tempfiles.append(filename)
1865 self.shell.tempfiles.append(filename)
1853
1866
1854 if data and use_temp:
1867 if data and use_temp:
1855 tmp_file = open(filename,'w')
1868 tmp_file = open(filename,'w')
1856 tmp_file.write(data)
1869 tmp_file.write(data)
1857 tmp_file.close()
1870 tmp_file.close()
1858
1871
1859 # do actual editing here
1872 # do actual editing here
1860 print 'Editing...',
1873 print 'Editing...',
1861 sys.stdout.flush()
1874 sys.stdout.flush()
1862 self.shell.hooks.editor(filename,lineno)
1875 self.shell.hooks.editor(filename,lineno)
1863 if opts.has_key('x'): # -x prevents actual execution
1876 if opts.has_key('x'): # -x prevents actual execution
1864 print
1877 print
1865 else:
1878 else:
1866 print 'done. Executing edited code...'
1879 print 'done. Executing edited code...'
1867 try:
1880 try:
1868 self.shell.safe_execfile(filename,self.shell.user_ns)
1881 self.shell.safe_execfile(filename,self.shell.user_ns)
1869 except IOError,msg:
1882 except IOError,msg:
1870 if msg.filename == filename:
1883 if msg.filename == filename:
1871 warn('File not found. Did you forget to save?')
1884 warn('File not found. Did you forget to save?')
1872 return
1885 return
1873 else:
1886 else:
1874 self.shell.showtraceback()
1887 self.shell.showtraceback()
1875 except:
1888 except:
1876 self.shell.showtraceback()
1889 self.shell.showtraceback()
1877 if use_temp:
1890 if use_temp:
1878 contents = open(filename).read()
1891 contents = open(filename).read()
1879 return contents
1892 return contents
1880
1893
1881 def magic_xmode(self,parameter_s = ''):
1894 def magic_xmode(self,parameter_s = ''):
1882 """Switch modes for the exception handlers.
1895 """Switch modes for the exception handlers.
1883
1896
1884 Valid modes: Plain, Context and Verbose.
1897 Valid modes: Plain, Context and Verbose.
1885
1898
1886 If called without arguments, acts as a toggle."""
1899 If called without arguments, acts as a toggle."""
1887
1900
1888 def xmode_switch_err(name):
1901 def xmode_switch_err(name):
1889 warn('Error changing %s exception modes.\n%s' %
1902 warn('Error changing %s exception modes.\n%s' %
1890 (name,sys.exc_info()[1]))
1903 (name,sys.exc_info()[1]))
1891
1904
1892 shell = self.shell
1905 shell = self.shell
1893 new_mode = parameter_s.strip().capitalize()
1906 new_mode = parameter_s.strip().capitalize()
1894 try:
1907 try:
1895 shell.InteractiveTB.set_mode(mode=new_mode)
1908 shell.InteractiveTB.set_mode(mode=new_mode)
1896 print 'Exception reporting mode:',shell.InteractiveTB.mode
1909 print 'Exception reporting mode:',shell.InteractiveTB.mode
1897 except:
1910 except:
1898 xmode_switch_err('user')
1911 xmode_switch_err('user')
1899
1912
1900 # threaded shells use a special handler in sys.excepthook
1913 # threaded shells use a special handler in sys.excepthook
1901 if shell.isthreaded:
1914 if shell.isthreaded:
1902 try:
1915 try:
1903 shell.sys_excepthook.set_mode(mode=new_mode)
1916 shell.sys_excepthook.set_mode(mode=new_mode)
1904 except:
1917 except:
1905 xmode_switch_err('threaded')
1918 xmode_switch_err('threaded')
1906
1919
1907 def magic_colors(self,parameter_s = ''):
1920 def magic_colors(self,parameter_s = ''):
1908 """Switch color scheme for prompts, info system and exception handlers.
1921 """Switch color scheme for prompts, info system and exception handlers.
1909
1922
1910 Currently implemented schemes: NoColor, Linux, LightBG.
1923 Currently implemented schemes: NoColor, Linux, LightBG.
1911
1924
1912 Color scheme names are not case-sensitive."""
1925 Color scheme names are not case-sensitive."""
1913
1926
1914 def color_switch_err(name):
1927 def color_switch_err(name):
1915 warn('Error changing %s color schemes.\n%s' %
1928 warn('Error changing %s color schemes.\n%s' %
1916 (name,sys.exc_info()[1]))
1929 (name,sys.exc_info()[1]))
1917
1930
1918
1931
1919 new_scheme = parameter_s.strip()
1932 new_scheme = parameter_s.strip()
1920 if not new_scheme:
1933 if not new_scheme:
1921 print 'You must specify a color scheme.'
1934 print 'You must specify a color scheme.'
1922 return
1935 return
1923 # Under Windows, check for Gary Bishop's readline, which is necessary
1936 # Under Windows, check for Gary Bishop's readline, which is necessary
1924 # for ANSI coloring
1937 # for ANSI coloring
1925 if os.name in ['nt','dos']:
1938 if os.name in ['nt','dos']:
1926 try:
1939 try:
1927 import readline
1940 import readline
1928 except ImportError:
1941 except ImportError:
1929 has_readline = 0
1942 has_readline = 0
1930 else:
1943 else:
1931 try:
1944 try:
1932 readline.GetOutputFile()
1945 readline.GetOutputFile()
1933 except AttributeError:
1946 except AttributeError:
1934 has_readline = 0
1947 has_readline = 0
1935 else:
1948 else:
1936 has_readline = 1
1949 has_readline = 1
1937 if not has_readline:
1950 if not has_readline:
1938 msg = """\
1951 msg = """\
1939 Proper color support under MS Windows requires Gary Bishop's readline library.
1952 Proper color support under MS Windows requires Gary Bishop's readline library.
1940 You can find it at:
1953 You can find it at:
1941 http://sourceforge.net/projects/uncpythontools
1954 http://sourceforge.net/projects/uncpythontools
1942 Gary's readline needs the ctypes module, from:
1955 Gary's readline needs the ctypes module, from:
1943 http://starship.python.net/crew/theller/ctypes
1956 http://starship.python.net/crew/theller/ctypes
1944
1957
1945 Defaulting color scheme to 'NoColor'"""
1958 Defaulting color scheme to 'NoColor'"""
1946 new_scheme = 'NoColor'
1959 new_scheme = 'NoColor'
1947 warn(msg)
1960 warn(msg)
1948 # local shortcut
1961 # local shortcut
1949 shell = self.shell
1962 shell = self.shell
1950
1963
1951 # Set prompt colors
1964 # Set prompt colors
1952 try:
1965 try:
1953 shell.outputcache.set_colors(new_scheme)
1966 shell.outputcache.set_colors(new_scheme)
1954 except:
1967 except:
1955 color_switch_err('prompt')
1968 color_switch_err('prompt')
1956 else:
1969 else:
1957 shell.rc.colors = \
1970 shell.rc.colors = \
1958 shell.outputcache.color_table.active_scheme_name
1971 shell.outputcache.color_table.active_scheme_name
1959 # Set exception colors
1972 # Set exception colors
1960 try:
1973 try:
1961 shell.InteractiveTB.set_colors(scheme = new_scheme)
1974 shell.InteractiveTB.set_colors(scheme = new_scheme)
1962 shell.SyntaxTB.set_colors(scheme = new_scheme)
1975 shell.SyntaxTB.set_colors(scheme = new_scheme)
1963 except:
1976 except:
1964 color_switch_err('exception')
1977 color_switch_err('exception')
1965
1978
1966 # threaded shells use a verbose traceback in sys.excepthook
1979 # threaded shells use a verbose traceback in sys.excepthook
1967 if shell.isthreaded:
1980 if shell.isthreaded:
1968 try:
1981 try:
1969 shell.sys_excepthook.set_colors(scheme=new_scheme)
1982 shell.sys_excepthook.set_colors(scheme=new_scheme)
1970 except:
1983 except:
1971 color_switch_err('system exception handler')
1984 color_switch_err('system exception handler')
1972
1985
1973 # Set info (for 'object?') colors
1986 # Set info (for 'object?') colors
1974 if shell.rc.color_info:
1987 if shell.rc.color_info:
1975 try:
1988 try:
1976 shell.inspector.set_active_scheme(new_scheme)
1989 shell.inspector.set_active_scheme(new_scheme)
1977 except:
1990 except:
1978 color_switch_err('object inspector')
1991 color_switch_err('object inspector')
1979 else:
1992 else:
1980 shell.inspector.set_active_scheme('NoColor')
1993 shell.inspector.set_active_scheme('NoColor')
1981
1994
1982 def magic_color_info(self,parameter_s = ''):
1995 def magic_color_info(self,parameter_s = ''):
1983 """Toggle color_info.
1996 """Toggle color_info.
1984
1997
1985 The color_info configuration parameter controls whether colors are
1998 The color_info configuration parameter controls whether colors are
1986 used for displaying object details (by things like %psource, %pfile or
1999 used for displaying object details (by things like %psource, %pfile or
1987 the '?' system). This function toggles this value with each call.
2000 the '?' system). This function toggles this value with each call.
1988
2001
1989 Note that unless you have a fairly recent pager (less works better
2002 Note that unless you have a fairly recent pager (less works better
1990 than more) in your system, using colored object information displays
2003 than more) in your system, using colored object information displays
1991 will not work properly. Test it and see."""
2004 will not work properly. Test it and see."""
1992
2005
1993 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2006 self.shell.rc.color_info = 1 - self.shell.rc.color_info
1994 self.magic_colors(self.shell.rc.colors)
2007 self.magic_colors(self.shell.rc.colors)
1995 print 'Object introspection functions have now coloring:',
2008 print 'Object introspection functions have now coloring:',
1996 print ['OFF','ON'][self.shell.rc.color_info]
2009 print ['OFF','ON'][self.shell.rc.color_info]
1997
2010
1998 def magic_Pprint(self, parameter_s=''):
2011 def magic_Pprint(self, parameter_s=''):
1999 """Toggle pretty printing on/off."""
2012 """Toggle pretty printing on/off."""
2000
2013
2001 self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint
2014 self.shell.outputcache.Pprint = 1 - self.shell.outputcache.Pprint
2002 print 'Pretty printing has been turned', \
2015 print 'Pretty printing has been turned', \
2003 ['OFF','ON'][self.shell.outputcache.Pprint]
2016 ['OFF','ON'][self.shell.outputcache.Pprint]
2004
2017
2005 def magic_exit(self, parameter_s=''):
2018 def magic_exit(self, parameter_s=''):
2006 """Exit IPython, confirming if configured to do so.
2019 """Exit IPython, confirming if configured to do so.
2007
2020
2008 You can configure whether IPython asks for confirmation upon exit by
2021 You can configure whether IPython asks for confirmation upon exit by
2009 setting the confirm_exit flag in the ipythonrc file."""
2022 setting the confirm_exit flag in the ipythonrc file."""
2010
2023
2011 self.shell.exit()
2024 self.shell.exit()
2012
2025
2013 def magic_quit(self, parameter_s=''):
2026 def magic_quit(self, parameter_s=''):
2014 """Exit IPython, confirming if configured to do so (like %exit)"""
2027 """Exit IPython, confirming if configured to do so (like %exit)"""
2015
2028
2016 self.shell.exit()
2029 self.shell.exit()
2017
2030
2018 def magic_Exit(self, parameter_s=''):
2031 def magic_Exit(self, parameter_s=''):
2019 """Exit IPython without confirmation."""
2032 """Exit IPython without confirmation."""
2020
2033
2021 self.shell.exit_now = True
2034 self.shell.exit_now = True
2022
2035
2023 def magic_Quit(self, parameter_s=''):
2036 def magic_Quit(self, parameter_s=''):
2024 """Exit IPython without confirmation (like %Exit)."""
2037 """Exit IPython without confirmation (like %Exit)."""
2025
2038
2026 self.shell.exit_now = True
2039 self.shell.exit_now = True
2027
2040
2028 #......................................................................
2041 #......................................................................
2029 # Functions to implement unix shell-type things
2042 # Functions to implement unix shell-type things
2030
2043
2031 def magic_alias(self, parameter_s = ''):
2044 def magic_alias(self, parameter_s = ''):
2032 """Define an alias for a system command.
2045 """Define an alias for a system command.
2033
2046
2034 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2047 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2035
2048
2036 Then, typing 'alias_name params' will execute the system command 'cmd
2049 Then, typing 'alias_name params' will execute the system command 'cmd
2037 params' (from your underlying operating system).
2050 params' (from your underlying operating system).
2038
2051
2039 Aliases have lower precedence than magic functions and Python normal
2052 Aliases have lower precedence than magic functions and Python normal
2040 variables, so if 'foo' is both a Python variable and an alias, the
2053 variables, so if 'foo' is both a Python variable and an alias, the
2041 alias can not be executed until 'del foo' removes the Python variable.
2054 alias can not be executed until 'del foo' removes the Python variable.
2042
2055
2043 You can use the %l specifier in an alias definition to represent the
2056 You can use the %l specifier in an alias definition to represent the
2044 whole line when the alias is called. For example:
2057 whole line when the alias is called. For example:
2045
2058
2046 In [2]: alias all echo "Input in brackets: <%l>"\\
2059 In [2]: alias all echo "Input in brackets: <%l>"\\
2047 In [3]: all hello world\\
2060 In [3]: all hello world\\
2048 Input in brackets: <hello world>
2061 Input in brackets: <hello world>
2049
2062
2050 You can also define aliases with parameters using %s specifiers (one
2063 You can also define aliases with parameters using %s specifiers (one
2051 per parameter):
2064 per parameter):
2052
2065
2053 In [1]: alias parts echo first %s second %s\\
2066 In [1]: alias parts echo first %s second %s\\
2054 In [2]: %parts A B\\
2067 In [2]: %parts A B\\
2055 first A second B\\
2068 first A second B\\
2056 In [3]: %parts A\\
2069 In [3]: %parts A\\
2057 Incorrect number of arguments: 2 expected.\\
2070 Incorrect number of arguments: 2 expected.\\
2058 parts is an alias to: 'echo first %s second %s'
2071 parts is an alias to: 'echo first %s second %s'
2059
2072
2060 Note that %l and %s are mutually exclusive. You can only use one or
2073 Note that %l and %s are mutually exclusive. You can only use one or
2061 the other in your aliases.
2074 the other in your aliases.
2062
2075
2063 Aliases expand Python variables just like system calls using ! or !!
2076 Aliases expand Python variables just like system calls using ! or !!
2064 do: all expressions prefixed with '$' get expanded. For details of
2077 do: all expressions prefixed with '$' get expanded. For details of
2065 the semantic rules, see PEP-215:
2078 the semantic rules, see PEP-215:
2066 http://www.python.org/peps/pep-0215.html. This is the library used by
2079 http://www.python.org/peps/pep-0215.html. This is the library used by
2067 IPython for variable expansion. If you want to access a true shell
2080 IPython for variable expansion. If you want to access a true shell
2068 variable, an extra $ is necessary to prevent its expansion by IPython:
2081 variable, an extra $ is necessary to prevent its expansion by IPython:
2069
2082
2070 In [6]: alias show echo\\
2083 In [6]: alias show echo\\
2071 In [7]: PATH='A Python string'\\
2084 In [7]: PATH='A Python string'\\
2072 In [8]: show $PATH\\
2085 In [8]: show $PATH\\
2073 A Python string\\
2086 A Python string\\
2074 In [9]: show $$PATH\\
2087 In [9]: show $$PATH\\
2075 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2088 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2076
2089
2077 You can use the alias facility to acess all of $PATH. See the %rehash
2090 You can use the alias facility to acess all of $PATH. See the %rehash
2078 and %rehashx functions, which automatically create aliases for the
2091 and %rehashx functions, which automatically create aliases for the
2079 contents of your $PATH.
2092 contents of your $PATH.
2080
2093
2081 If called with no parameters, %alias prints the current alias table."""
2094 If called with no parameters, %alias prints the current alias table."""
2082
2095
2083 par = parameter_s.strip()
2096 par = parameter_s.strip()
2084 if not par:
2097 if not par:
2085 if self.shell.rc.automagic:
2098 if self.shell.rc.automagic:
2086 prechar = ''
2099 prechar = ''
2087 else:
2100 else:
2088 prechar = self.shell.ESC_MAGIC
2101 prechar = self.shell.ESC_MAGIC
2089 print 'Alias\t\tSystem Command\n'+'-'*30
2102 print 'Alias\t\tSystem Command\n'+'-'*30
2090 atab = self.shell.alias_table
2103 atab = self.shell.alias_table
2091 aliases = atab.keys()
2104 aliases = atab.keys()
2092 aliases.sort()
2105 aliases.sort()
2093 for alias in aliases:
2106 for alias in aliases:
2094 print prechar+alias+'\t\t'+atab[alias][1]
2107 print prechar+alias+'\t\t'+atab[alias][1]
2095 print '-'*30+'\nTotal number of aliases:',len(aliases)
2108 print '-'*30+'\nTotal number of aliases:',len(aliases)
2096 return
2109 return
2097 try:
2110 try:
2098 alias,cmd = par.split(None,1)
2111 alias,cmd = par.split(None,1)
2099 except:
2112 except:
2100 print OInspect.getdoc(self.magic_alias)
2113 print OInspect.getdoc(self.magic_alias)
2101 else:
2114 else:
2102 nargs = cmd.count('%s')
2115 nargs = cmd.count('%s')
2103 if nargs>0 and cmd.find('%l')>=0:
2116 if nargs>0 and cmd.find('%l')>=0:
2104 error('The %s and %l specifiers are mutually exclusive '
2117 error('The %s and %l specifiers are mutually exclusive '
2105 'in alias definitions.')
2118 'in alias definitions.')
2106 else: # all looks OK
2119 else: # all looks OK
2107 self.shell.alias_table[alias] = (nargs,cmd)
2120 self.shell.alias_table[alias] = (nargs,cmd)
2108 self.shell.alias_table_validate(verbose=1)
2121 self.shell.alias_table_validate(verbose=1)
2109 # end magic_alias
2122 # end magic_alias
2110
2123
2111 def magic_unalias(self, parameter_s = ''):
2124 def magic_unalias(self, parameter_s = ''):
2112 """Remove an alias"""
2125 """Remove an alias"""
2113
2126
2114 aname = parameter_s.strip()
2127 aname = parameter_s.strip()
2115 if aname in self.shell.alias_table:
2128 if aname in self.shell.alias_table:
2116 del self.shell.alias_table[aname]
2129 del self.shell.alias_table[aname]
2117
2130
2118 def magic_rehash(self, parameter_s = ''):
2131 def magic_rehash(self, parameter_s = ''):
2119 """Update the alias table with all entries in $PATH.
2132 """Update the alias table with all entries in $PATH.
2120
2133
2121 This version does no checks on execute permissions or whether the
2134 This version does no checks on execute permissions or whether the
2122 contents of $PATH are truly files (instead of directories or something
2135 contents of $PATH are truly files (instead of directories or something
2123 else). For such a safer (but slower) version, use %rehashx."""
2136 else). For such a safer (but slower) version, use %rehashx."""
2124
2137
2125 # This function (and rehashx) manipulate the alias_table directly
2138 # This function (and rehashx) manipulate the alias_table directly
2126 # rather than calling magic_alias, for speed reasons. A rehash on a
2139 # rather than calling magic_alias, for speed reasons. A rehash on a
2127 # typical Linux box involves several thousand entries, so efficiency
2140 # typical Linux box involves several thousand entries, so efficiency
2128 # here is a top concern.
2141 # here is a top concern.
2129
2142
2130 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2143 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2131 alias_table = self.shell.alias_table
2144 alias_table = self.shell.alias_table
2132 for pdir in path:
2145 for pdir in path:
2133 for ff in os.listdir(pdir):
2146 for ff in os.listdir(pdir):
2134 # each entry in the alias table must be (N,name), where
2147 # each entry in the alias table must be (N,name), where
2135 # N is the number of positional arguments of the alias.
2148 # N is the number of positional arguments of the alias.
2136 alias_table[ff] = (0,ff)
2149 alias_table[ff] = (0,ff)
2137 # Make sure the alias table doesn't contain keywords or builtins
2150 # Make sure the alias table doesn't contain keywords or builtins
2138 self.shell.alias_table_validate()
2151 self.shell.alias_table_validate()
2139 # Call again init_auto_alias() so we get 'rm -i' and other modified
2152 # Call again init_auto_alias() so we get 'rm -i' and other modified
2140 # aliases since %rehash will probably clobber them
2153 # aliases since %rehash will probably clobber them
2141 self.shell.init_auto_alias()
2154 self.shell.init_auto_alias()
2142
2155
2143 def magic_rehashx(self, parameter_s = ''):
2156 def magic_rehashx(self, parameter_s = ''):
2144 """Update the alias table with all executable files in $PATH.
2157 """Update the alias table with all executable files in $PATH.
2145
2158
2146 This version explicitly checks that every entry in $PATH is a file
2159 This version explicitly checks that every entry in $PATH is a file
2147 with execute access (os.X_OK), so it is much slower than %rehash.
2160 with execute access (os.X_OK), so it is much slower than %rehash.
2148
2161
2149 Under Windows, it checks executability as a match agains a
2162 Under Windows, it checks executability as a match agains a
2150 '|'-separated string of extensions, stored in the IPython config
2163 '|'-separated string of extensions, stored in the IPython config
2151 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2164 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2152
2165
2153 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2166 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2154 alias_table = self.shell.alias_table
2167 alias_table = self.shell.alias_table
2155
2168
2156 if os.name == 'posix':
2169 if os.name == 'posix':
2157 isexec = lambda fname:os.path.isfile(fname) and \
2170 isexec = lambda fname:os.path.isfile(fname) and \
2158 os.access(fname,os.X_OK)
2171 os.access(fname,os.X_OK)
2159 else:
2172 else:
2160
2173
2161 try:
2174 try:
2162 winext = os.environ['pathext'].replace(';','|').replace('.','')
2175 winext = os.environ['pathext'].replace(';','|').replace('.','')
2163 except KeyError:
2176 except KeyError:
2164 winext = 'exe|com|bat'
2177 winext = 'exe|com|bat'
2165
2178
2166 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2179 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2167 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2180 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2168 savedir = os.getcwd()
2181 savedir = os.getcwd()
2169 try:
2182 try:
2170 # write the whole loop for posix/Windows so we don't have an if in
2183 # write the whole loop for posix/Windows so we don't have an if in
2171 # the innermost part
2184 # the innermost part
2172 if os.name == 'posix':
2185 if os.name == 'posix':
2173 for pdir in path:
2186 for pdir in path:
2174 os.chdir(pdir)
2187 os.chdir(pdir)
2175 for ff in os.listdir(pdir):
2188 for ff in os.listdir(pdir):
2176 if isexec(ff):
2189 if isexec(ff):
2177 # each entry in the alias table must be (N,name),
2190 # each entry in the alias table must be (N,name),
2178 # where N is the number of positional arguments of the
2191 # where N is the number of positional arguments of the
2179 # alias.
2192 # alias.
2180 alias_table[ff] = (0,ff)
2193 alias_table[ff] = (0,ff)
2181 else:
2194 else:
2182 for pdir in path:
2195 for pdir in path:
2183 os.chdir(pdir)
2196 os.chdir(pdir)
2184 for ff in os.listdir(pdir):
2197 for ff in os.listdir(pdir):
2185 if isexec(ff):
2198 if isexec(ff):
2186 alias_table[execre.sub(r'\1',ff)] = (0,ff)
2199 alias_table[execre.sub(r'\1',ff)] = (0,ff)
2187 # Make sure the alias table doesn't contain keywords or builtins
2200 # Make sure the alias table doesn't contain keywords or builtins
2188 self.shell.alias_table_validate()
2201 self.shell.alias_table_validate()
2189 # Call again init_auto_alias() so we get 'rm -i' and other
2202 # Call again init_auto_alias() so we get 'rm -i' and other
2190 # modified aliases since %rehashx will probably clobber them
2203 # modified aliases since %rehashx will probably clobber them
2191 self.shell.init_auto_alias()
2204 self.shell.init_auto_alias()
2192 finally:
2205 finally:
2193 os.chdir(savedir)
2206 os.chdir(savedir)
2194
2207
2195 def magic_pwd(self, parameter_s = ''):
2208 def magic_pwd(self, parameter_s = ''):
2196 """Return the current working directory path."""
2209 """Return the current working directory path."""
2197 return os.getcwd()
2210 return os.getcwd()
2198
2211
2199 def magic_cd(self, parameter_s=''):
2212 def magic_cd(self, parameter_s=''):
2200 """Change the current working directory.
2213 """Change the current working directory.
2201
2214
2202 This command automatically maintains an internal list of directories
2215 This command automatically maintains an internal list of directories
2203 you visit during your IPython session, in the variable _dh. The
2216 you visit during your IPython session, in the variable _dh. The
2204 command %dhist shows this history nicely formatted.
2217 command %dhist shows this history nicely formatted.
2205
2218
2206 Usage:
2219 Usage:
2207
2220
2208 cd 'dir': changes to directory 'dir'.
2221 cd 'dir': changes to directory 'dir'.
2209
2222
2210 cd -: changes to the last visited directory.
2223 cd -: changes to the last visited directory.
2211
2224
2212 cd -<n>: changes to the n-th directory in the directory history.
2225 cd -<n>: changes to the n-th directory in the directory history.
2213
2226
2214 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2227 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2215 (note: cd <bookmark_name> is enough if there is no
2228 (note: cd <bookmark_name> is enough if there is no
2216 directory <bookmark_name>, but a bookmark with the name exists.)
2229 directory <bookmark_name>, but a bookmark with the name exists.)
2217
2230
2218 Options:
2231 Options:
2219
2232
2220 -q: quiet. Do not print the working directory after the cd command is
2233 -q: quiet. Do not print the working directory after the cd command is
2221 executed. By default IPython's cd command does print this directory,
2234 executed. By default IPython's cd command does print this directory,
2222 since the default prompts do not display path information.
2235 since the default prompts do not display path information.
2223
2236
2224 Note that !cd doesn't work for this purpose because the shell where
2237 Note that !cd doesn't work for this purpose because the shell where
2225 !command runs is immediately discarded after executing 'command'."""
2238 !command runs is immediately discarded after executing 'command'."""
2226
2239
2227 parameter_s = parameter_s.strip()
2240 parameter_s = parameter_s.strip()
2228 bkms = self.shell.persist.get("bookmarks",{})
2241 bkms = self.shell.persist.get("bookmarks",{})
2229
2242
2230 numcd = re.match(r'(-)(\d+)$',parameter_s)
2243 numcd = re.match(r'(-)(\d+)$',parameter_s)
2231 # jump in directory history by number
2244 # jump in directory history by number
2232 if numcd:
2245 if numcd:
2233 nn = int(numcd.group(2))
2246 nn = int(numcd.group(2))
2234 try:
2247 try:
2235 ps = self.shell.user_ns['_dh'][nn]
2248 ps = self.shell.user_ns['_dh'][nn]
2236 except IndexError:
2249 except IndexError:
2237 print 'The requested directory does not exist in history.'
2250 print 'The requested directory does not exist in history.'
2238 return
2251 return
2239 else:
2252 else:
2240 opts = {}
2253 opts = {}
2241 else:
2254 else:
2242 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2255 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2243 # jump to previous
2256 # jump to previous
2244 if ps == '-':
2257 if ps == '-':
2245 try:
2258 try:
2246 ps = self.shell.user_ns['_dh'][-2]
2259 ps = self.shell.user_ns['_dh'][-2]
2247 except IndexError:
2260 except IndexError:
2248 print 'No previous directory to change to.'
2261 print 'No previous directory to change to.'
2249 return
2262 return
2250 # jump to bookmark
2263 # jump to bookmark
2251 elif opts.has_key('b') or (bkms.has_key(ps) and not os.path.isdir(ps)):
2264 elif opts.has_key('b') or (bkms.has_key(ps) and not os.path.isdir(ps)):
2252 if bkms.has_key(ps):
2265 if bkms.has_key(ps):
2253 target = bkms[ps]
2266 target = bkms[ps]
2254 print '(bookmark:%s) -> %s' % (ps,target)
2267 print '(bookmark:%s) -> %s' % (ps,target)
2255 ps = target
2268 ps = target
2256 else:
2269 else:
2257 if bkms:
2270 if bkms:
2258 error("Bookmark '%s' not found. "
2271 error("Bookmark '%s' not found. "
2259 "Use '%bookmark -l' to see your bookmarks." % ps)
2272 "Use '%bookmark -l' to see your bookmarks." % ps)
2260 else:
2273 else:
2261 print "Bookmarks not set - use %bookmark <bookmarkname>"
2274 print "Bookmarks not set - use %bookmark <bookmarkname>"
2262 return
2275 return
2263
2276
2264 # at this point ps should point to the target dir
2277 # at this point ps should point to the target dir
2265 if ps:
2278 if ps:
2266 try:
2279 try:
2267 os.chdir(os.path.expanduser(ps))
2280 os.chdir(os.path.expanduser(ps))
2268 except OSError:
2281 except OSError:
2269 print sys.exc_info()[1]
2282 print sys.exc_info()[1]
2270 else:
2283 else:
2271 self.shell.user_ns['_dh'].append(os.getcwd())
2284 self.shell.user_ns['_dh'].append(os.getcwd())
2272 else:
2285 else:
2273 os.chdir(self.shell.home_dir)
2286 os.chdir(self.shell.home_dir)
2274 self.shell.user_ns['_dh'].append(os.getcwd())
2287 self.shell.user_ns['_dh'].append(os.getcwd())
2275 if not 'q' in opts:
2288 if not 'q' in opts:
2276 print self.shell.user_ns['_dh'][-1]
2289 print self.shell.user_ns['_dh'][-1]
2277
2290
2278 def magic_dhist(self, parameter_s=''):
2291 def magic_dhist(self, parameter_s=''):
2279 """Print your history of visited directories.
2292 """Print your history of visited directories.
2280
2293
2281 %dhist -> print full history\\
2294 %dhist -> print full history\\
2282 %dhist n -> print last n entries only\\
2295 %dhist n -> print last n entries only\\
2283 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2296 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2284
2297
2285 This history is automatically maintained by the %cd command, and
2298 This history is automatically maintained by the %cd command, and
2286 always available as the global list variable _dh. You can use %cd -<n>
2299 always available as the global list variable _dh. You can use %cd -<n>
2287 to go to directory number <n>."""
2300 to go to directory number <n>."""
2288
2301
2289 dh = self.shell.user_ns['_dh']
2302 dh = self.shell.user_ns['_dh']
2290 if parameter_s:
2303 if parameter_s:
2291 try:
2304 try:
2292 args = map(int,parameter_s.split())
2305 args = map(int,parameter_s.split())
2293 except:
2306 except:
2294 self.arg_err(Magic.magic_dhist)
2307 self.arg_err(Magic.magic_dhist)
2295 return
2308 return
2296 if len(args) == 1:
2309 if len(args) == 1:
2297 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2310 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2298 elif len(args) == 2:
2311 elif len(args) == 2:
2299 ini,fin = args
2312 ini,fin = args
2300 else:
2313 else:
2301 self.arg_err(Magic.magic_dhist)
2314 self.arg_err(Magic.magic_dhist)
2302 return
2315 return
2303 else:
2316 else:
2304 ini,fin = 0,len(dh)
2317 ini,fin = 0,len(dh)
2305 nlprint(dh,
2318 nlprint(dh,
2306 header = 'Directory history (kept in _dh)',
2319 header = 'Directory history (kept in _dh)',
2307 start=ini,stop=fin)
2320 start=ini,stop=fin)
2308
2321
2309 def magic_env(self, parameter_s=''):
2322 def magic_env(self, parameter_s=''):
2310 """List environment variables."""
2323 """List environment variables."""
2311
2324
2312 return os.environ.data
2325 return os.environ.data
2313
2326
2314 def magic_pushd(self, parameter_s=''):
2327 def magic_pushd(self, parameter_s=''):
2315 """Place the current dir on stack and change directory.
2328 """Place the current dir on stack and change directory.
2316
2329
2317 Usage:\\
2330 Usage:\\
2318 %pushd ['dirname']
2331 %pushd ['dirname']
2319
2332
2320 %pushd with no arguments does a %pushd to your home directory.
2333 %pushd with no arguments does a %pushd to your home directory.
2321 """
2334 """
2322 if parameter_s == '': parameter_s = '~'
2335 if parameter_s == '': parameter_s = '~'
2323 dir_s = self.shell.dir_stack
2336 dir_s = self.shell.dir_stack
2324 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2337 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2325 os.path.expanduser(self.shell.dir_stack[0]):
2338 os.path.expanduser(self.shell.dir_stack[0]):
2326 try:
2339 try:
2327 self.magic_cd(parameter_s)
2340 self.magic_cd(parameter_s)
2328 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2341 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2329 self.magic_dirs()
2342 self.magic_dirs()
2330 except:
2343 except:
2331 print 'Invalid directory'
2344 print 'Invalid directory'
2332 else:
2345 else:
2333 print 'You are already there!'
2346 print 'You are already there!'
2334
2347
2335 def magic_popd(self, parameter_s=''):
2348 def magic_popd(self, parameter_s=''):
2336 """Change to directory popped off the top of the stack.
2349 """Change to directory popped off the top of the stack.
2337 """
2350 """
2338 if len (self.shell.dir_stack) > 1:
2351 if len (self.shell.dir_stack) > 1:
2339 self.shell.dir_stack.pop(0)
2352 self.shell.dir_stack.pop(0)
2340 self.magic_cd(self.shell.dir_stack[0])
2353 self.magic_cd(self.shell.dir_stack[0])
2341 print self.shell.dir_stack[0]
2354 print self.shell.dir_stack[0]
2342 else:
2355 else:
2343 print "You can't remove the starting directory from the stack:",\
2356 print "You can't remove the starting directory from the stack:",\
2344 self.shell.dir_stack
2357 self.shell.dir_stack
2345
2358
2346 def magic_dirs(self, parameter_s=''):
2359 def magic_dirs(self, parameter_s=''):
2347 """Return the current directory stack."""
2360 """Return the current directory stack."""
2348
2361
2349 return self.shell.dir_stack[:]
2362 return self.shell.dir_stack[:]
2350
2363
2351 def magic_sc(self, parameter_s=''):
2364 def magic_sc(self, parameter_s=''):
2352 """Shell capture - execute a shell command and capture its output.
2365 """Shell capture - execute a shell command and capture its output.
2353
2366
2354 %sc [options] varname=command
2367 %sc [options] varname=command
2355
2368
2356 IPython will run the given command using commands.getoutput(), and
2369 IPython will run the given command using commands.getoutput(), and
2357 will then update the user's interactive namespace with a variable
2370 will then update the user's interactive namespace with a variable
2358 called varname, containing the value of the call. Your command can
2371 called varname, containing the value of the call. Your command can
2359 contain shell wildcards, pipes, etc.
2372 contain shell wildcards, pipes, etc.
2360
2373
2361 The '=' sign in the syntax is mandatory, and the variable name you
2374 The '=' sign in the syntax is mandatory, and the variable name you
2362 supply must follow Python's standard conventions for valid names.
2375 supply must follow Python's standard conventions for valid names.
2363
2376
2364 Options:
2377 Options:
2365
2378
2366 -l: list output. Split the output on newlines into a list before
2379 -l: list output. Split the output on newlines into a list before
2367 assigning it to the given variable. By default the output is stored
2380 assigning it to the given variable. By default the output is stored
2368 as a single string.
2381 as a single string.
2369
2382
2370 -v: verbose. Print the contents of the variable.
2383 -v: verbose. Print the contents of the variable.
2371
2384
2372 In most cases you should not need to split as a list, because the
2385 In most cases you should not need to split as a list, because the
2373 returned value is a special type of string which can automatically
2386 returned value is a special type of string which can automatically
2374 provide its contents either as a list (split on newlines) or as a
2387 provide its contents either as a list (split on newlines) or as a
2375 space-separated string. These are convenient, respectively, either
2388 space-separated string. These are convenient, respectively, either
2376 for sequential processing or to be passed to a shell command.
2389 for sequential processing or to be passed to a shell command.
2377
2390
2378 For example:
2391 For example:
2379
2392
2380 # Capture into variable a
2393 # Capture into variable a
2381 In [9]: sc a=ls *py
2394 In [9]: sc a=ls *py
2382
2395
2383 # a is a string with embedded newlines
2396 # a is a string with embedded newlines
2384 In [10]: a
2397 In [10]: a
2385 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2398 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2386
2399
2387 # which can be seen as a list:
2400 # which can be seen as a list:
2388 In [11]: a.l
2401 In [11]: a.l
2389 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2402 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2390
2403
2391 # or as a whitespace-separated string:
2404 # or as a whitespace-separated string:
2392 In [12]: a.s
2405 In [12]: a.s
2393 Out[12]: 'setup.py win32_manual_post_install.py'
2406 Out[12]: 'setup.py win32_manual_post_install.py'
2394
2407
2395 # a.s is useful to pass as a single command line:
2408 # a.s is useful to pass as a single command line:
2396 In [13]: !wc -l $a.s
2409 In [13]: !wc -l $a.s
2397 146 setup.py
2410 146 setup.py
2398 130 win32_manual_post_install.py
2411 130 win32_manual_post_install.py
2399 276 total
2412 276 total
2400
2413
2401 # while the list form is useful to loop over:
2414 # while the list form is useful to loop over:
2402 In [14]: for f in a.l:
2415 In [14]: for f in a.l:
2403 ....: !wc -l $f
2416 ....: !wc -l $f
2404 ....:
2417 ....:
2405 146 setup.py
2418 146 setup.py
2406 130 win32_manual_post_install.py
2419 130 win32_manual_post_install.py
2407
2420
2408 Similiarly, the lists returned by the -l option are also special, in
2421 Similiarly, the lists returned by the -l option are also special, in
2409 the sense that you can equally invoke the .s attribute on them to
2422 the sense that you can equally invoke the .s attribute on them to
2410 automatically get a whitespace-separated string from their contents:
2423 automatically get a whitespace-separated string from their contents:
2411
2424
2412 In [1]: sc -l b=ls *py
2425 In [1]: sc -l b=ls *py
2413
2426
2414 In [2]: b
2427 In [2]: b
2415 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2428 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2416
2429
2417 In [3]: b.s
2430 In [3]: b.s
2418 Out[3]: 'setup.py win32_manual_post_install.py'
2431 Out[3]: 'setup.py win32_manual_post_install.py'
2419
2432
2420 In summary, both the lists and strings used for ouptut capture have
2433 In summary, both the lists and strings used for ouptut capture have
2421 the following special attributes:
2434 the following special attributes:
2422
2435
2423 .l (or .list) : value as list.
2436 .l (or .list) : value as list.
2424 .n (or .nlstr): value as newline-separated string.
2437 .n (or .nlstr): value as newline-separated string.
2425 .s (or .spstr): value as space-separated string.
2438 .s (or .spstr): value as space-separated string.
2426 """
2439 """
2427
2440
2428 opts,args = self.parse_options(parameter_s,'lv')
2441 opts,args = self.parse_options(parameter_s,'lv')
2429 # Try to get a variable name and command to run
2442 # Try to get a variable name and command to run
2430 try:
2443 try:
2431 # the variable name must be obtained from the parse_options
2444 # the variable name must be obtained from the parse_options
2432 # output, which uses shlex.split to strip options out.
2445 # output, which uses shlex.split to strip options out.
2433 var,_ = args.split('=',1)
2446 var,_ = args.split('=',1)
2434 var = var.strip()
2447 var = var.strip()
2435 # But the the command has to be extracted from the original input
2448 # But the the command has to be extracted from the original input
2436 # parameter_s, not on what parse_options returns, to avoid the
2449 # parameter_s, not on what parse_options returns, to avoid the
2437 # quote stripping which shlex.split performs on it.
2450 # quote stripping which shlex.split performs on it.
2438 _,cmd = parameter_s.split('=',1)
2451 _,cmd = parameter_s.split('=',1)
2439 except ValueError:
2452 except ValueError:
2440 var,cmd = '',''
2453 var,cmd = '',''
2441 if not var:
2454 if not var:
2442 error('you must specify a variable to assign the command to.')
2455 error('you must specify a variable to assign the command to.')
2443 return
2456 return
2444 # If all looks ok, proceed
2457 # If all looks ok, proceed
2445 out,err = self.shell.getoutputerror(cmd)
2458 out,err = self.shell.getoutputerror(cmd)
2446 if err:
2459 if err:
2447 print >> Term.cerr,err
2460 print >> Term.cerr,err
2448 if opts.has_key('l'):
2461 if opts.has_key('l'):
2449 out = SList(out.split('\n'))
2462 out = SList(out.split('\n'))
2450 else:
2463 else:
2451 out = LSString(out)
2464 out = LSString(out)
2452 if opts.has_key('v'):
2465 if opts.has_key('v'):
2453 print '%s ==\n%s' % (var,pformat(out))
2466 print '%s ==\n%s' % (var,pformat(out))
2454 self.shell.user_ns.update({var:out})
2467 self.shell.user_ns.update({var:out})
2455
2468
2456 def magic_sx(self, parameter_s=''):
2469 def magic_sx(self, parameter_s=''):
2457 """Shell execute - run a shell command and capture its output.
2470 """Shell execute - run a shell command and capture its output.
2458
2471
2459 %sx command
2472 %sx command
2460
2473
2461 IPython will run the given command using commands.getoutput(), and
2474 IPython will run the given command using commands.getoutput(), and
2462 return the result formatted as a list (split on '\\n'). Since the
2475 return the result formatted as a list (split on '\\n'). Since the
2463 output is _returned_, it will be stored in ipython's regular output
2476 output is _returned_, it will be stored in ipython's regular output
2464 cache Out[N] and in the '_N' automatic variables.
2477 cache Out[N] and in the '_N' automatic variables.
2465
2478
2466 Notes:
2479 Notes:
2467
2480
2468 1) If an input line begins with '!!', then %sx is automatically
2481 1) If an input line begins with '!!', then %sx is automatically
2469 invoked. That is, while:
2482 invoked. That is, while:
2470 !ls
2483 !ls
2471 causes ipython to simply issue system('ls'), typing
2484 causes ipython to simply issue system('ls'), typing
2472 !!ls
2485 !!ls
2473 is a shorthand equivalent to:
2486 is a shorthand equivalent to:
2474 %sx ls
2487 %sx ls
2475
2488
2476 2) %sx differs from %sc in that %sx automatically splits into a list,
2489 2) %sx differs from %sc in that %sx automatically splits into a list,
2477 like '%sc -l'. The reason for this is to make it as easy as possible
2490 like '%sc -l'. The reason for this is to make it as easy as possible
2478 to process line-oriented shell output via further python commands.
2491 to process line-oriented shell output via further python commands.
2479 %sc is meant to provide much finer control, but requires more
2492 %sc is meant to provide much finer control, but requires more
2480 typing.
2493 typing.
2481
2494
2482 3) Just like %sc -l, this is a list with special attributes:
2495 3) Just like %sc -l, this is a list with special attributes:
2483
2496
2484 .l (or .list) : value as list.
2497 .l (or .list) : value as list.
2485 .n (or .nlstr): value as newline-separated string.
2498 .n (or .nlstr): value as newline-separated string.
2486 .s (or .spstr): value as whitespace-separated string.
2499 .s (or .spstr): value as whitespace-separated string.
2487
2500
2488 This is very useful when trying to use such lists as arguments to
2501 This is very useful when trying to use such lists as arguments to
2489 system commands."""
2502 system commands."""
2490
2503
2491 if parameter_s:
2504 if parameter_s:
2492 out,err = self.shell.getoutputerror(parameter_s)
2505 out,err = self.shell.getoutputerror(parameter_s)
2493 if err:
2506 if err:
2494 print >> Term.cerr,err
2507 print >> Term.cerr,err
2495 return SList(out.split('\n'))
2508 return SList(out.split('\n'))
2496
2509
2497 def magic_bg(self, parameter_s=''):
2510 def magic_bg(self, parameter_s=''):
2498 """Run a job in the background, in a separate thread.
2511 """Run a job in the background, in a separate thread.
2499
2512
2500 For example,
2513 For example,
2501
2514
2502 %bg myfunc(x,y,z=1)
2515 %bg myfunc(x,y,z=1)
2503
2516
2504 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2517 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2505 execution starts, a message will be printed indicating the job
2518 execution starts, a message will be printed indicating the job
2506 number. If your job number is 5, you can use
2519 number. If your job number is 5, you can use
2507
2520
2508 myvar = jobs.result(5) or myvar = jobs[5].result
2521 myvar = jobs.result(5) or myvar = jobs[5].result
2509
2522
2510 to assign this result to variable 'myvar'.
2523 to assign this result to variable 'myvar'.
2511
2524
2512 IPython has a job manager, accessible via the 'jobs' object. You can
2525 IPython has a job manager, accessible via the 'jobs' object. You can
2513 type jobs? to get more information about it, and use jobs.<TAB> to see
2526 type jobs? to get more information about it, and use jobs.<TAB> to see
2514 its attributes. All attributes not starting with an underscore are
2527 its attributes. All attributes not starting with an underscore are
2515 meant for public use.
2528 meant for public use.
2516
2529
2517 In particular, look at the jobs.new() method, which is used to create
2530 In particular, look at the jobs.new() method, which is used to create
2518 new jobs. This magic %bg function is just a convenience wrapper
2531 new jobs. This magic %bg function is just a convenience wrapper
2519 around jobs.new(), for expression-based jobs. If you want to create a
2532 around jobs.new(), for expression-based jobs. If you want to create a
2520 new job with an explicit function object and arguments, you must call
2533 new job with an explicit function object and arguments, you must call
2521 jobs.new() directly.
2534 jobs.new() directly.
2522
2535
2523 The jobs.new docstring also describes in detail several important
2536 The jobs.new docstring also describes in detail several important
2524 caveats associated with a thread-based model for background job
2537 caveats associated with a thread-based model for background job
2525 execution. Type jobs.new? for details.
2538 execution. Type jobs.new? for details.
2526
2539
2527 You can check the status of all jobs with jobs.status().
2540 You can check the status of all jobs with jobs.status().
2528
2541
2529 The jobs variable is set by IPython into the Python builtin namespace.
2542 The jobs variable is set by IPython into the Python builtin namespace.
2530 If you ever declare a variable named 'jobs', you will shadow this
2543 If you ever declare a variable named 'jobs', you will shadow this
2531 name. You can either delete your global jobs variable to regain
2544 name. You can either delete your global jobs variable to regain
2532 access to the job manager, or make a new name and assign it manually
2545 access to the job manager, or make a new name and assign it manually
2533 to the manager (stored in IPython's namespace). For example, to
2546 to the manager (stored in IPython's namespace). For example, to
2534 assign the job manager to the Jobs name, use:
2547 assign the job manager to the Jobs name, use:
2535
2548
2536 Jobs = __builtins__.jobs"""
2549 Jobs = __builtins__.jobs"""
2537
2550
2538 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2551 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2539
2552
2540 def magic_store(self, parameter_s=''):
2553 def magic_store(self, parameter_s=''):
2541 """Lightweight persistence for python variables.
2554 """Lightweight persistence for python variables.
2542
2555
2543 Example:
2556 Example:
2544
2557
2545 ville@badger[~]|1> A = ['hello',10,'world']\\
2558 ville@badger[~]|1> A = ['hello',10,'world']\\
2546 ville@badger[~]|2> %store A\\
2559 ville@badger[~]|2> %store A\\
2547 ville@badger[~]|3> Exit
2560 ville@badger[~]|3> Exit
2548
2561
2549 (IPython session is closed and started again...)
2562 (IPython session is closed and started again...)
2550
2563
2551 ville@badger:~$ ipython -p pysh\\
2564 ville@badger:~$ ipython -p pysh\\
2552 ville@badger[~]|1> print A
2565 ville@badger[~]|1> print A
2553
2566
2554 ['hello', 10, 'world']
2567 ['hello', 10, 'world']
2555
2568
2556 Usage:
2569 Usage:
2557
2570
2558 %store - Show list of all variables and their current values\\
2571 %store - Show list of all variables and their current values\\
2559 %store <var> - Store the *current* value of the variable to disk\\
2572 %store <var> - Store the *current* value of the variable to disk\\
2560 %store -d - Remove the variable and its value from storage\\
2573 %store -d - Remove the variable and its value from storage\\
2561 %store -r - Remove all variables from storage
2574 %store -r - Remove all variables from storage
2562
2575
2563 It should be noted that if you change the value of a variable, you
2576 It should be noted that if you change the value of a variable, you
2564 need to %store it again if you want to persist the new value.
2577 need to %store it again if you want to persist the new value.
2565
2578
2566 Note also that the variables will need to be pickleable; most basic
2579 Note also that the variables will need to be pickleable; most basic
2567 python types can be safely %stored.
2580 python types can be safely %stored.
2568 """
2581 """
2569
2582
2570 opts,args = self.parse_options(parameter_s,'dr',mode='list')
2583 opts,args = self.parse_options(parameter_s,'dr',mode='list')
2571 # delete
2584 # delete
2572 if opts.has_key('d'):
2585 if opts.has_key('d'):
2573 try:
2586 try:
2574 todel = args[0]
2587 todel = args[0]
2575 except IndexError:
2588 except IndexError:
2576 error('You must provide the variable to forget')
2589 error('You must provide the variable to forget')
2577 else:
2590 else:
2578 try:
2591 try:
2579 del self.shell.persist['S:' + todel]
2592 del self.shell.persist['S:' + todel]
2580 except:
2593 except:
2581 error("Can't delete variable '%s'" % todel)
2594 error("Can't delete variable '%s'" % todel)
2582 # reset
2595 # reset
2583 elif opts.has_key('r'):
2596 elif opts.has_key('r'):
2584 for k in self.shell.persist.keys():
2597 for k in self.shell.persist.keys():
2585 if k.startswith('S:'):
2598 if k.startswith('S:'):
2586 del self.shell.persist[k]
2599 del self.shell.persist[k]
2587
2600
2588 # run without arguments -> list variables & values
2601 # run without arguments -> list variables & values
2589 elif not args:
2602 elif not args:
2590 vars = [v[2:] for v in self.shell.persist.keys()
2603 vars = [v[2:] for v in self.shell.persist.keys()
2591 if v.startswith('S:')]
2604 if v.startswith('S:')]
2592 vars.sort()
2605 vars.sort()
2593 if vars:
2606 if vars:
2594 size = max(map(len,vars))
2607 size = max(map(len,vars))
2595 else:
2608 else:
2596 size = 0
2609 size = 0
2597
2610
2598 print 'Stored variables and their in-memory values:'
2611 print 'Stored variables and their in-memory values:'
2599 fmt = '%-'+str(size)+'s -> %s'
2612 fmt = '%-'+str(size)+'s -> %s'
2600 get = self.shell.user_ns.get
2613 get = self.shell.user_ns.get
2601 for var in vars:
2614 for var in vars:
2602 # print 30 first characters from every var
2615 # print 30 first characters from every var
2603 print fmt % (var,repr(get(var,'<unavailable>'))[:50])
2616 print fmt % (var,repr(get(var,'<unavailable>'))[:50])
2604
2617
2605 # default action - store the variable
2618 # default action - store the variable
2606 else:
2619 else:
2607 pickled = pickle.dumps(self.shell.user_ns[args[0] ])
2620 pickled = pickle.dumps(self.shell.user_ns[args[0] ])
2608 self.shell.persist[ 'S:' + args[0] ] = pickled
2621 self.shell.persist[ 'S:' + args[0] ] = pickled
2609 print "Stored '%s' (%d bytes)" % (args[0], len(pickled))
2622 print "Stored '%s' (%d bytes)" % (args[0], len(pickled))
2610
2623
2611 def magic_bookmark(self, parameter_s=''):
2624 def magic_bookmark(self, parameter_s=''):
2612 """Manage IPython's bookmark system.
2625 """Manage IPython's bookmark system.
2613
2626
2614 %bookmark <name> - set bookmark to current dir
2627 %bookmark <name> - set bookmark to current dir
2615 %bookmark <name> <dir> - set bookmark to <dir>
2628 %bookmark <name> <dir> - set bookmark to <dir>
2616 %bookmark -l - list all bookmarks
2629 %bookmark -l - list all bookmarks
2617 %bookmark -d <name> - remove bookmark
2630 %bookmark -d <name> - remove bookmark
2618 %bookmark -r - remove all bookmarks
2631 %bookmark -r - remove all bookmarks
2619
2632
2620 You can later on access a bookmarked folder with:
2633 You can later on access a bookmarked folder with:
2621 %cd -b <name>
2634 %cd -b <name>
2622 or simply '%cd <name>' if there is no directory called <name> AND
2635 or simply '%cd <name>' if there is no directory called <name> AND
2623 there is such a bookmark defined.
2636 there is such a bookmark defined.
2624
2637
2625 Your bookmarks persist through IPython sessions, but they are
2638 Your bookmarks persist through IPython sessions, but they are
2626 associated with each profile."""
2639 associated with each profile."""
2627
2640
2628 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2641 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2629 if len(args) > 2:
2642 if len(args) > 2:
2630 error('You can only give at most two arguments')
2643 error('You can only give at most two arguments')
2631 return
2644 return
2632
2645
2633 bkms = self.shell.persist.get('bookmarks',{})
2646 bkms = self.shell.persist.get('bookmarks',{})
2634
2647
2635 if opts.has_key('d'):
2648 if opts.has_key('d'):
2636 try:
2649 try:
2637 todel = args[0]
2650 todel = args[0]
2638 except IndexError:
2651 except IndexError:
2639 error('You must provide a bookmark to delete')
2652 error('You must provide a bookmark to delete')
2640 else:
2653 else:
2641 try:
2654 try:
2642 del bkms[todel]
2655 del bkms[todel]
2643 except:
2656 except:
2644 error("Can't delete bookmark '%s'" % todel)
2657 error("Can't delete bookmark '%s'" % todel)
2645 elif opts.has_key('r'):
2658 elif opts.has_key('r'):
2646 bkms = {}
2659 bkms = {}
2647 elif opts.has_key('l'):
2660 elif opts.has_key('l'):
2648 bks = bkms.keys()
2661 bks = bkms.keys()
2649 bks.sort()
2662 bks.sort()
2650 if bks:
2663 if bks:
2651 size = max(map(len,bks))
2664 size = max(map(len,bks))
2652 else:
2665 else:
2653 size = 0
2666 size = 0
2654 fmt = '%-'+str(size)+'s -> %s'
2667 fmt = '%-'+str(size)+'s -> %s'
2655 print 'Current bookmarks:'
2668 print 'Current bookmarks:'
2656 for bk in bks:
2669 for bk in bks:
2657 print fmt % (bk,bkms[bk])
2670 print fmt % (bk,bkms[bk])
2658 else:
2671 else:
2659 if not args:
2672 if not args:
2660 error("You must specify the bookmark name")
2673 error("You must specify the bookmark name")
2661 elif len(args)==1:
2674 elif len(args)==1:
2662 bkms[args[0]] = os.getcwd()
2675 bkms[args[0]] = os.getcwd()
2663 elif len(args)==2:
2676 elif len(args)==2:
2664 bkms[args[0]] = args[1]
2677 bkms[args[0]] = args[1]
2665 self.shell.persist['bookmarks'] = bkms
2678 self.shell.persist['bookmarks'] = bkms
2666
2679
2667 def magic_pycat(self, parameter_s=''):
2680 def magic_pycat(self, parameter_s=''):
2668 """Show a syntax-highlighted file through a pager.
2681 """Show a syntax-highlighted file through a pager.
2669
2682
2670 This magic is similar to the cat utility, but it will assume the file
2683 This magic is similar to the cat utility, but it will assume the file
2671 to be Python source and will show it with syntax highlighting. """
2684 to be Python source and will show it with syntax highlighting. """
2672
2685
2673 filename = get_py_filename(parameter_s)
2686 filename = get_py_filename(parameter_s)
2674 page(self.shell.colorize(file_read(filename)),
2687 page(self.shell.colorize(file_read(filename)),
2675 screen_lines=self.shell.rc.screen_length)
2688 screen_lines=self.shell.rc.screen_length)
2676
2689
2677 # end Magic
2690 # end Magic
@@ -1,76 +1,76 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Release data for the IPython project.
2 """Release data for the IPython project.
3
3
4 $Id: Release.py 984 2005-12-31 08:40:31Z fperez $"""
4 $Id: Release.py 986 2005-12-31 23:07:31Z fperez $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001-2005 Fernando Perez <fperez@colorado.edu>
7 # Copyright (C) 2001-2005 Fernando Perez <fperez@colorado.edu>
8 #
8 #
9 # Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and Nathaniel Gray
9 # Copyright (c) 2001 Janko Hauser <jhauser@zscout.de> and Nathaniel Gray
10 # <n8gray@caltech.edu>
10 # <n8gray@caltech.edu>
11 #
11 #
12 # Distributed under the terms of the BSD License. The full license is in
12 # Distributed under the terms of the BSD License. The full license is in
13 # the file COPYING, distributed as part of this software.
13 # the file COPYING, distributed as part of this software.
14 #*****************************************************************************
14 #*****************************************************************************
15
15
16 # Name of the package for release purposes. This is the name which labels
16 # Name of the package for release purposes. This is the name which labels
17 # the tarballs and RPMs made by distutils, so it's best to lowercase it.
17 # the tarballs and RPMs made by distutils, so it's best to lowercase it.
18 name = 'ipython'
18 name = 'ipython'
19
19
20 # For versions with substrings (like 0.6.16.svn), use an extra . to separate
20 # For versions with substrings (like 0.6.16.svn), use an extra . to separate
21 # the new substring. We have to avoid using either dashes or underscores,
21 # the new substring. We have to avoid using either dashes or underscores,
22 # because bdist_rpm does not accept dashes (an RPM) convention, and
22 # because bdist_rpm does not accept dashes (an RPM) convention, and
23 # bdist_deb does not accept underscores (a Debian convention).
23 # bdist_deb does not accept underscores (a Debian convention).
24
24
25 version = '0.7.0.rc4'
25 version = '0.7.0.rc5'
26
26
27 revision = '$Revision: 984 $'
27 revision = '$Revision: 986 $'
28
28
29 description = "An enhanced interactive Python shell."
29 description = "An enhanced interactive Python shell."
30
30
31 long_description = \
31 long_description = \
32 """
32 """
33 IPython provides a replacement for the interactive Python interpreter with
33 IPython provides a replacement for the interactive Python interpreter with
34 extra functionality.
34 extra functionality.
35
35
36 Main features:
36 Main features:
37
37
38 * Comprehensive object introspection.
38 * Comprehensive object introspection.
39
39
40 * Input history, persistent across sessions.
40 * Input history, persistent across sessions.
41
41
42 * Caching of output results during a session with automatically generated
42 * Caching of output results during a session with automatically generated
43 references.
43 references.
44
44
45 * Readline based name completion.
45 * Readline based name completion.
46
46
47 * Extensible system of 'magic' commands for controlling the environment and
47 * Extensible system of 'magic' commands for controlling the environment and
48 performing many tasks related either to IPython or the operating system.
48 performing many tasks related either to IPython or the operating system.
49
49
50 * Configuration system with easy switching between different setups (simpler
50 * Configuration system with easy switching between different setups (simpler
51 than changing $PYTHONSTARTUP environment variables every time).
51 than changing $PYTHONSTARTUP environment variables every time).
52
52
53 * Session logging and reloading.
53 * Session logging and reloading.
54
54
55 * Extensible syntax processing for special purpose situations.
55 * Extensible syntax processing for special purpose situations.
56
56
57 * Access to the system shell with user-extensible alias system.
57 * Access to the system shell with user-extensible alias system.
58
58
59 * Easily embeddable in other Python programs.
59 * Easily embeddable in other Python programs.
60
60
61 * Integrated access to the pdb debugger and the Python profiler. """
61 * Integrated access to the pdb debugger and the Python profiler. """
62
62
63 license = 'BSD'
63 license = 'BSD'
64
64
65 authors = {'Fernando' : ('Fernando Perez','fperez@colorado.edu'),
65 authors = {'Fernando' : ('Fernando Perez','fperez@colorado.edu'),
66 'Janko' : ('Janko Hauser','jhauser@zscout.de'),
66 'Janko' : ('Janko Hauser','jhauser@zscout.de'),
67 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu')
67 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu')
68 }
68 }
69
69
70 url = 'http://ipython.scipy.org'
70 url = 'http://ipython.scipy.org'
71
71
72 download_url = 'http://ipython.scipy.org/dist'
72 download_url = 'http://ipython.scipy.org/dist'
73
73
74 platforms = ['Linux','Mac OSX','Windows XP/2000/NT','Windows 95/98/ME']
74 platforms = ['Linux','Mac OSX','Windows XP/2000/NT','Windows 95/98/ME']
75
75
76 keywords = ['Interactive','Interpreter','Shell']
76 keywords = ['Interactive','Interpreter','Shell']
@@ -1,534 +1,543 b''
1 """Word completion for IPython.
1 """Word completion for IPython.
2
2
3 This module is a fork of the rlcompleter module in the Python standard
3 This module is a fork of the rlcompleter module in the Python standard
4 library. The original enhancements made to rlcompleter have been sent
4 library. The original enhancements made to rlcompleter have been sent
5 upstream and were accepted as of Python 2.3, but we need a lot more
5 upstream and were accepted as of Python 2.3, but we need a lot more
6 functionality specific to IPython, so this module will continue to live as an
6 functionality specific to IPython, so this module will continue to live as an
7 IPython-specific utility.
7 IPython-specific utility.
8
8
9 ---------------------------------------------------------------------------
9 ---------------------------------------------------------------------------
10 Original rlcompleter documentation:
10 Original rlcompleter documentation:
11
11
12 This requires the latest extension to the readline module (the
12 This requires the latest extension to the readline module (the
13 completes keywords, built-ins and globals in __main__; when completing
13 completes keywords, built-ins and globals in __main__; when completing
14 NAME.NAME..., it evaluates (!) the expression up to the last dot and
14 NAME.NAME..., it evaluates (!) the expression up to the last dot and
15 completes its attributes.
15 completes its attributes.
16
16
17 It's very cool to do "import string" type "string.", hit the
17 It's very cool to do "import string" type "string.", hit the
18 completion key (twice), and see the list of names defined by the
18 completion key (twice), and see the list of names defined by the
19 string module!
19 string module!
20
20
21 Tip: to use the tab key as the completion key, call
21 Tip: to use the tab key as the completion key, call
22
22
23 readline.parse_and_bind("tab: complete")
23 readline.parse_and_bind("tab: complete")
24
24
25 Notes:
25 Notes:
26
26
27 - Exceptions raised by the completer function are *ignored* (and
27 - Exceptions raised by the completer function are *ignored* (and
28 generally cause the completion to fail). This is a feature -- since
28 generally cause the completion to fail). This is a feature -- since
29 readline sets the tty device in raw (or cbreak) mode, printing a
29 readline sets the tty device in raw (or cbreak) mode, printing a
30 traceback wouldn't work well without some complicated hoopla to save,
30 traceback wouldn't work well without some complicated hoopla to save,
31 reset and restore the tty state.
31 reset and restore the tty state.
32
32
33 - The evaluation of the NAME.NAME... form may cause arbitrary
33 - The evaluation of the NAME.NAME... form may cause arbitrary
34 application defined code to be executed if an object with a
34 application defined code to be executed if an object with a
35 __getattr__ hook is found. Since it is the responsibility of the
35 __getattr__ hook is found. Since it is the responsibility of the
36 application (or the user) to enable this feature, I consider this an
36 application (or the user) to enable this feature, I consider this an
37 acceptable risk. More complicated expressions (e.g. function calls or
37 acceptable risk. More complicated expressions (e.g. function calls or
38 indexing operations) are *not* evaluated.
38 indexing operations) are *not* evaluated.
39
39
40 - GNU readline is also used by the built-in functions input() and
40 - GNU readline is also used by the built-in functions input() and
41 raw_input(), and thus these also benefit/suffer from the completer
41 raw_input(), and thus these also benefit/suffer from the completer
42 features. Clearly an interactive application can benefit by
42 features. Clearly an interactive application can benefit by
43 specifying its own completer function and using raw_input() for all
43 specifying its own completer function and using raw_input() for all
44 its input.
44 its input.
45
45
46 - When the original stdin is not a tty device, GNU readline is never
46 - When the original stdin is not a tty device, GNU readline is never
47 used, and this module (and the readline module) are silently inactive.
47 used, and this module (and the readline module) are silently inactive.
48
48
49 """
49 """
50
50
51 #*****************************************************************************
51 #*****************************************************************************
52 #
52 #
53 # Since this file is essentially a minimally modified copy of the rlcompleter
53 # Since this file is essentially a minimally modified copy of the rlcompleter
54 # module which is part of the standard Python distribution, I assume that the
54 # module which is part of the standard Python distribution, I assume that the
55 # proper procedure is to maintain its copyright as belonging to the Python
55 # proper procedure is to maintain its copyright as belonging to the Python
56 # Software Foundation (in addition to my own, for all new code).
56 # Software Foundation (in addition to my own, for all new code).
57 #
57 #
58 # Copyright (C) 2001 Python Software Foundation, www.python.org
58 # Copyright (C) 2001 Python Software Foundation, www.python.org
59 # Copyright (C) 2001-2005 Fernando Perez. <fperez@colorado.edu>
59 # Copyright (C) 2001-2005 Fernando Perez. <fperez@colorado.edu>
60 #
60 #
61 # Distributed under the terms of the BSD License. The full license is in
61 # Distributed under the terms of the BSD License. The full license is in
62 # the file COPYING, distributed as part of this software.
62 # the file COPYING, distributed as part of this software.
63 #
63 #
64 #*****************************************************************************
64 #*****************************************************************************
65
65
66 import __builtin__
66 import __builtin__
67 import __main__
67 import __main__
68 import glob
68 import glob
69 import keyword
69 import keyword
70 import os
70 import os
71 import re
71 import re
72 import readline
72 import readline
73 import sys
73 import sys
74 import types
74 import types
75
75
76 from IPython.genutils import shlex_split
76 from IPython.genutils import shlex_split
77
77
78 __all__ = ['Completer','IPCompleter']
78 __all__ = ['Completer','IPCompleter']
79
79
80 def get_class_members(cls):
80 def get_class_members(cls):
81 ret = dir(cls)
81 ret = dir(cls)
82 if hasattr(cls,'__bases__'):
82 if hasattr(cls,'__bases__'):
83 for base in cls.__bases__:
83 for base in cls.__bases__:
84 ret.extend(get_class_members(base))
84 ret.extend(get_class_members(base))
85 return ret
85 return ret
86
86
87 class Completer:
87 class Completer:
88 def __init__(self,namespace=None,global_namespace=None):
88 def __init__(self,namespace=None,global_namespace=None):
89 """Create a new completer for the command line.
89 """Create a new completer for the command line.
90
90
91 Completer([namespace,global_namespace]) -> completer instance.
91 Completer([namespace,global_namespace]) -> completer instance.
92
92
93 If unspecified, the default namespace where completions are performed
93 If unspecified, the default namespace where completions are performed
94 is __main__ (technically, __main__.__dict__). Namespaces should be
94 is __main__ (technically, __main__.__dict__). Namespaces should be
95 given as dictionaries.
95 given as dictionaries.
96
96
97 An optional second namespace can be given. This allows the completer
97 An optional second namespace can be given. This allows the completer
98 to handle cases where both the local and global scopes need to be
98 to handle cases where both the local and global scopes need to be
99 distinguished.
99 distinguished.
100
100
101 Completer instances should be used as the completion mechanism of
101 Completer instances should be used as the completion mechanism of
102 readline via the set_completer() call:
102 readline via the set_completer() call:
103
103
104 readline.set_completer(Completer(my_namespace).complete)
104 readline.set_completer(Completer(my_namespace).complete)
105 """
105 """
106
106
107 # some minimal strict typechecks. For some core data structures, I
107 # some minimal strict typechecks. For some core data structures, I
108 # want actual basic python types, not just anything that looks like
108 # want actual basic python types, not just anything that looks like
109 # one. This is especially true for namespaces.
109 # one. This is especially true for namespaces.
110 for ns in (namespace,global_namespace):
110 for ns in (namespace,global_namespace):
111 if ns is not None and type(ns) != types.DictType:
111 if ns is not None and type(ns) != types.DictType:
112 raise TypeError,'namespace must be a dictionary'
112 raise TypeError,'namespace must be a dictionary'
113
113
114 # Don't bind to namespace quite yet, but flag whether the user wants a
114 # Don't bind to namespace quite yet, but flag whether the user wants a
115 # specific namespace or to use __main__.__dict__. This will allow us
115 # specific namespace or to use __main__.__dict__. This will allow us
116 # to bind to __main__.__dict__ at completion time, not now.
116 # to bind to __main__.__dict__ at completion time, not now.
117 if namespace is None:
117 if namespace is None:
118 self.use_main_ns = 1
118 self.use_main_ns = 1
119 else:
119 else:
120 self.use_main_ns = 0
120 self.use_main_ns = 0
121 self.namespace = namespace
121 self.namespace = namespace
122
122
123 # The global namespace, if given, can be bound directly
123 # The global namespace, if given, can be bound directly
124 if global_namespace is None:
124 if global_namespace is None:
125 self.global_namespace = {}
125 self.global_namespace = {}
126 else:
126 else:
127 self.global_namespace = global_namespace
127 self.global_namespace = global_namespace
128
128
129 def complete(self, text, state):
129 def complete(self, text, state):
130 """Return the next possible completion for 'text'.
130 """Return the next possible completion for 'text'.
131
131
132 This is called successively with state == 0, 1, 2, ... until it
132 This is called successively with state == 0, 1, 2, ... until it
133 returns None. The completion should begin with 'text'.
133 returns None. The completion should begin with 'text'.
134
134
135 """
135 """
136 if self.use_main_ns:
136 if self.use_main_ns:
137 self.namespace = __main__.__dict__
137 self.namespace = __main__.__dict__
138
138
139 if state == 0:
139 if state == 0:
140 if "." in text:
140 if "." in text:
141 self.matches = self.attr_matches(text)
141 self.matches = self.attr_matches(text)
142 else:
142 else:
143 self.matches = self.global_matches(text)
143 self.matches = self.global_matches(text)
144 try:
144 try:
145 return self.matches[state]
145 return self.matches[state]
146 except IndexError:
146 except IndexError:
147 return None
147 return None
148
148
149 def global_matches(self, text):
149 def global_matches(self, text):
150 """Compute matches when text is a simple name.
150 """Compute matches when text is a simple name.
151
151
152 Return a list of all keywords, built-in functions and names currently
152 Return a list of all keywords, built-in functions and names currently
153 defined in self.namespace or self.global_namespace that match.
153 defined in self.namespace or self.global_namespace that match.
154
154
155 """
155 """
156 matches = []
156 matches = []
157 match_append = matches.append
157 match_append = matches.append
158 n = len(text)
158 n = len(text)
159 for lst in [keyword.kwlist,
159 for lst in [keyword.kwlist,
160 __builtin__.__dict__.keys(),
160 __builtin__.__dict__.keys(),
161 self.namespace.keys(),
161 self.namespace.keys(),
162 self.global_namespace.keys()]:
162 self.global_namespace.keys()]:
163 for word in lst:
163 for word in lst:
164 if word[:n] == text and word != "__builtins__":
164 if word[:n] == text and word != "__builtins__":
165 match_append(word)
165 match_append(word)
166 return matches
166 return matches
167
167
168 def attr_matches(self, text):
168 def attr_matches(self, text):
169 """Compute matches when text contains a dot.
169 """Compute matches when text contains a dot.
170
170
171 Assuming the text is of the form NAME.NAME....[NAME], and is
171 Assuming the text is of the form NAME.NAME....[NAME], and is
172 evaluatable in self.namespace or self.global_namespace, it will be
172 evaluatable in self.namespace or self.global_namespace, it will be
173 evaluated and its attributes (as revealed by dir()) are used as
173 evaluated and its attributes (as revealed by dir()) are used as
174 possible completions. (For class instances, class members are are
174 possible completions. (For class instances, class members are are
175 also considered.)
175 also considered.)
176
176
177 WARNING: this can still invoke arbitrary C code, if an object
177 WARNING: this can still invoke arbitrary C code, if an object
178 with a __getattr__ hook is evaluated.
178 with a __getattr__ hook is evaluated.
179
179
180 """
180 """
181 import re
181 import re
182
182
183 # Another option, seems to work great. Catches things like ''.<tab>
183 # Another option, seems to work great. Catches things like ''.<tab>
184 m = re.match(r"(\S+(\.\w+)*)\.(\w*)$", text)
184 m = re.match(r"(\S+(\.\w+)*)\.(\w*)$", text)
185
185
186 if not m:
186 if not m:
187 return []
187 return []
188
188
189 expr, attr = m.group(1, 3)
189 expr, attr = m.group(1, 3)
190 try:
190 try:
191 object = eval(expr, self.namespace)
191 object = eval(expr, self.namespace)
192 except:
192 except:
193 object = eval(expr, self.global_namespace)
193 object = eval(expr, self.global_namespace)
194
194
195 # for modules which define __all__, complete only on those.
195 # for modules which define __all__, complete only on those.
196 if type(object) == types.ModuleType and hasattr(object, '__all__'):
196 if type(object) == types.ModuleType and hasattr(object, '__all__'):
197 words = getattr(object, '__all__')
197 words = getattr(object, '__all__')
198 else:
198 else:
199 words = dir(object)
199 words = dir(object)
200 if hasattr(object,'__class__'):
200 if hasattr(object,'__class__'):
201 words.append('__class__')
201 words.append('__class__')
202 words.extend(get_class_members(object.__class__))
202 words.extend(get_class_members(object.__class__))
203
203
204 # filter out non-string attributes which may be stuffed by dir() calls
204 # filter out non-string attributes which may be stuffed by dir() calls
205 # and poor coding in third-party modules
205 # and poor coding in third-party modules
206 words = [w for w in words
206 words = [w for w in words
207 if isinstance(w, basestring) and w != "__builtins__"]
207 if isinstance(w, basestring) and w != "__builtins__"]
208 # Build match list to return
208 # Build match list to return
209 n = len(attr)
209 n = len(attr)
210 return ["%s.%s" % (expr, w) for w in words if w[:n] == attr ]
210 return ["%s.%s" % (expr, w) for w in words if w[:n] == attr ]
211
211
212 class IPCompleter(Completer):
212 class IPCompleter(Completer):
213 """Extension of the completer class with IPython-specific features"""
213 """Extension of the completer class with IPython-specific features"""
214
214
215 def __init__(self,shell,namespace=None,global_namespace=None,
215 def __init__(self,shell,namespace=None,global_namespace=None,
216 omit__names=0,alias_table=None):
216 omit__names=0,alias_table=None):
217 """IPCompleter() -> completer
217 """IPCompleter() -> completer
218
218
219 Return a completer object suitable for use by the readline library
219 Return a completer object suitable for use by the readline library
220 via readline.set_completer().
220 via readline.set_completer().
221
221
222 Inputs:
222 Inputs:
223
223
224 - shell: a pointer to the ipython shell itself. This is needed
224 - shell: a pointer to the ipython shell itself. This is needed
225 because this completer knows about magic functions, and those can
225 because this completer knows about magic functions, and those can
226 only be accessed via the ipython instance.
226 only be accessed via the ipython instance.
227
227
228 - namespace: an optional dict where completions are performed.
228 - namespace: an optional dict where completions are performed.
229
229
230 - global_namespace: secondary optional dict for completions, to
230 - global_namespace: secondary optional dict for completions, to
231 handle cases (such as IPython embedded inside functions) where
231 handle cases (such as IPython embedded inside functions) where
232 both Python scopes are visible.
232 both Python scopes are visible.
233
233
234 - The optional omit__names parameter sets the completer to omit the
234 - The optional omit__names parameter sets the completer to omit the
235 'magic' names (__magicname__) for python objects unless the text
235 'magic' names (__magicname__) for python objects unless the text
236 to be completed explicitly starts with one or more underscores.
236 to be completed explicitly starts with one or more underscores.
237
237
238 - If alias_table is supplied, it should be a dictionary of aliases
238 - If alias_table is supplied, it should be a dictionary of aliases
239 to complete. """
239 to complete. """
240
240
241 Completer.__init__(self,namespace,global_namespace)
241 Completer.__init__(self,namespace,global_namespace)
242 self.magic_prefix = shell.name+'.magic_'
242 self.magic_prefix = shell.name+'.magic_'
243 self.magic_escape = shell.ESC_MAGIC
243 self.magic_escape = shell.ESC_MAGIC
244 self.readline = readline
244 self.readline = readline
245 delims = self.readline.get_completer_delims()
245 delims = self.readline.get_completer_delims()
246 delims = delims.replace(self.magic_escape,'')
246 delims = delims.replace(self.magic_escape,'')
247 self.readline.set_completer_delims(delims)
247 self.readline.set_completer_delims(delims)
248 self.get_line_buffer = self.readline.get_line_buffer
248 self.get_line_buffer = self.readline.get_line_buffer
249 self.omit__names = omit__names
249 self.omit__names = omit__names
250 self.merge_completions = shell.rc.readline_merge_completions
250 self.merge_completions = shell.rc.readline_merge_completions
251
251
252 if alias_table is None:
252 if alias_table is None:
253 alias_table = {}
253 alias_table = {}
254 self.alias_table = alias_table
254 self.alias_table = alias_table
255 # Regexp to split filenames with spaces in them
255 # Regexp to split filenames with spaces in them
256 self.space_name_re = re.compile(r'([^\\] )')
256 self.space_name_re = re.compile(r'([^\\] )')
257 # Hold a local ref. to glob.glob for speed
257 # Hold a local ref. to glob.glob for speed
258 self.glob = glob.glob
258 self.glob = glob.glob
259
260 # Determine if we are running on 'dumb' terminals, like (X)Emacs
261 # buffers, to avoid completion problems.
262 term = os.environ.get('TERM','xterm')
263 self.dumb_terminal = term in ['dumb','emacs']
264
259 # Special handling of backslashes needed in win32 platforms
265 # Special handling of backslashes needed in win32 platforms
260 if sys.platform == "win32":
266 if sys.platform == "win32":
261 self.clean_glob = self._clean_glob_win32
267 self.clean_glob = self._clean_glob_win32
262 else:
268 else:
263 self.clean_glob = self._clean_glob
269 self.clean_glob = self._clean_glob
264 self.matchers = [self.python_matches,
270 self.matchers = [self.python_matches,
265 self.file_matches,
271 self.file_matches,
266 self.alias_matches,
272 self.alias_matches,
267 self.python_func_kw_matches]
273 self.python_func_kw_matches]
268
274
269 # Code contributed by Alex Schmolck, for ipython/emacs integration
275 # Code contributed by Alex Schmolck, for ipython/emacs integration
270 def all_completions(self, text):
276 def all_completions(self, text):
271 """Return all possible completions for the benefit of emacs."""
277 """Return all possible completions for the benefit of emacs."""
272
278
273 completions = []
279 completions = []
274 comp_append = completions.append
280 comp_append = completions.append
275 try:
281 try:
276 for i in xrange(sys.maxint):
282 for i in xrange(sys.maxint):
277 res = self.complete(text, i)
283 res = self.complete(text, i)
278
284
279 if not res: break
285 if not res: break
280
286
281 comp_append(res)
287 comp_append(res)
282 #XXX workaround for ``notDefined.<tab>``
288 #XXX workaround for ``notDefined.<tab>``
283 except NameError:
289 except NameError:
284 pass
290 pass
285 return completions
291 return completions
286 # /end Alex Schmolck code.
292 # /end Alex Schmolck code.
287
293
288 def _clean_glob(self,text):
294 def _clean_glob(self,text):
289 return self.glob("%s*" % text)
295 return self.glob("%s*" % text)
290
296
291 def _clean_glob_win32(self,text):
297 def _clean_glob_win32(self,text):
292 return [f.replace("\\","/")
298 return [f.replace("\\","/")
293 for f in self.glob("%s*" % text)]
299 for f in self.glob("%s*" % text)]
294
300
295 def file_matches(self, text):
301 def file_matches(self, text):
296 """Match filneames, expanding ~USER type strings.
302 """Match filneames, expanding ~USER type strings.
297
303
298 Most of the seemingly convoluted logic in this completer is an
304 Most of the seemingly convoluted logic in this completer is an
299 attempt to handle filenames with spaces in them. And yet it's not
305 attempt to handle filenames with spaces in them. And yet it's not
300 quite perfect, because Python's readline doesn't expose all of the
306 quite perfect, because Python's readline doesn't expose all of the
301 GNU readline details needed for this to be done correctly.
307 GNU readline details needed for this to be done correctly.
302
308
303 For a filename with a space in it, the printed completions will be
309 For a filename with a space in it, the printed completions will be
304 only the parts after what's already been typed (instead of the
310 only the parts after what's already been typed (instead of the
305 full completions, as is normally done). I don't think with the
311 full completions, as is normally done). I don't think with the
306 current (as of Python 2.3) Python readline it's possible to do
312 current (as of Python 2.3) Python readline it's possible to do
307 better."""
313 better."""
308
314
309 #print 'Completer->file_matches: <%s>' % text # dbg
315 #print 'Completer->file_matches: <%s>' % text # dbg
310
316
311 # chars that require escaping with backslash - i.e. chars
317 # chars that require escaping with backslash - i.e. chars
312 # that readline treats incorrectly as delimiters, but we
318 # that readline treats incorrectly as delimiters, but we
313 # don't want to treat as delimiters in filename matching
319 # don't want to treat as delimiters in filename matching
314 # when escaped with backslash
320 # when escaped with backslash
315
321
316 protectables = ' ()[]{}'
322 protectables = ' ()[]{}'
317
323
318 def protect_filename(s):
324 def protect_filename(s):
319 return "".join([(ch in protectables and '\\' + ch or ch)
325 return "".join([(ch in protectables and '\\' + ch or ch)
320 for ch in s])
326 for ch in s])
321
327
322 lbuf = self.get_line_buffer()[:self.readline.get_endidx()]
328 lbuf = self.get_line_buffer()[:self.readline.get_endidx()]
323 open_quotes = 0 # track strings with open quotes
329 open_quotes = 0 # track strings with open quotes
324 try:
330 try:
325 lsplit = shlex_split(lbuf)[-1]
331 lsplit = shlex_split(lbuf)[-1]
326 except ValueError:
332 except ValueError:
327 # typically an unmatched ", or backslash without escaped char.
333 # typically an unmatched ", or backslash without escaped char.
328 if lbuf.count('"')==1:
334 if lbuf.count('"')==1:
329 open_quotes = 1
335 open_quotes = 1
330 lsplit = lbuf.split('"')[-1]
336 lsplit = lbuf.split('"')[-1]
331 elif lbuf.count("'")==1:
337 elif lbuf.count("'")==1:
332 open_quotes = 1
338 open_quotes = 1
333 lsplit = lbuf.split("'")[-1]
339 lsplit = lbuf.split("'")[-1]
334 else:
340 else:
335 return None
341 return None
336 except IndexError:
342 except IndexError:
337 # tab pressed on empty line
343 # tab pressed on empty line
338 lsplit = ""
344 lsplit = ""
339
345
340 if lsplit != protect_filename(lsplit):
346 if lsplit != protect_filename(lsplit):
341 # if protectables are found, do matching on the whole escaped
347 # if protectables are found, do matching on the whole escaped
342 # name
348 # name
343 has_protectables = 1
349 has_protectables = 1
344 text0,text = text,lsplit
350 text0,text = text,lsplit
345 else:
351 else:
346 has_protectables = 0
352 has_protectables = 0
347 text = os.path.expanduser(text)
353 text = os.path.expanduser(text)
348
354
349 if text == "":
355 if text == "":
350 return [protect_filename(f) for f in self.glob("*")]
356 return [protect_filename(f) for f in self.glob("*")]
351
357
352 m0 = self.clean_glob(text.replace('\\',''))
358 m0 = self.clean_glob(text.replace('\\',''))
353 if has_protectables:
359 if has_protectables:
354 # If we had protectables, we need to revert our changes to the
360 # If we had protectables, we need to revert our changes to the
355 # beginning of filename so that we don't double-write the part
361 # beginning of filename so that we don't double-write the part
356 # of the filename we have so far
362 # of the filename we have so far
357 len_lsplit = len(lsplit)
363 len_lsplit = len(lsplit)
358 matches = [text0 + protect_filename(f[len_lsplit:]) for f in m0]
364 matches = [text0 + protect_filename(f[len_lsplit:]) for f in m0]
359 else:
365 else:
360 if open_quotes:
366 if open_quotes:
361 # if we have a string with an open quote, we don't need to
367 # if we have a string with an open quote, we don't need to
362 # protect the names at all (and we _shouldn't_, as it
368 # protect the names at all (and we _shouldn't_, as it
363 # would cause bugs when the filesystem call is made).
369 # would cause bugs when the filesystem call is made).
364 matches = m0
370 matches = m0
365 else:
371 else:
366 matches = [protect_filename(f) for f in m0]
372 matches = [protect_filename(f) for f in m0]
367 if len(matches) == 1 and os.path.isdir(matches[0]):
373 if len(matches) == 1 and os.path.isdir(matches[0]):
368 # Takes care of links to directories also. Use '/'
374 # Takes care of links to directories also. Use '/'
369 # explicitly, even under Windows, so that name completions
375 # explicitly, even under Windows, so that name completions
370 # don't end up escaped.
376 # don't end up escaped.
371 matches[0] += '/'
377 matches[0] += '/'
372 return matches
378 return matches
373
379
374 def alias_matches(self, text):
380 def alias_matches(self, text):
375 """Match internal system aliases"""
381 """Match internal system aliases"""
376 #print 'Completer->alias_matches:',text # dbg
382 #print 'Completer->alias_matches:',text # dbg
377 text = os.path.expanduser(text)
383 text = os.path.expanduser(text)
378 aliases = self.alias_table.keys()
384 aliases = self.alias_table.keys()
379 if text == "":
385 if text == "":
380 return aliases
386 return aliases
381 else:
387 else:
382 return [alias for alias in aliases if alias.startswith(text)]
388 return [alias for alias in aliases if alias.startswith(text)]
383
389
384 def python_matches(self,text):
390 def python_matches(self,text):
385 """Match attributes or global python names"""
391 """Match attributes or global python names"""
386 #print 'Completer->python_matches' # dbg
392 #print 'Completer->python_matches' # dbg
387 if "." in text:
393 if "." in text:
388 try:
394 try:
389 matches = self.attr_matches(text)
395 matches = self.attr_matches(text)
390 if text.endswith('.') and self.omit__names:
396 if text.endswith('.') and self.omit__names:
391 if self.omit__names == 1:
397 if self.omit__names == 1:
392 # true if txt is _not_ a __ name, false otherwise:
398 # true if txt is _not_ a __ name, false otherwise:
393 no__name = (lambda txt:
399 no__name = (lambda txt:
394 re.match(r'.*\.__.*?__',txt) is None)
400 re.match(r'.*\.__.*?__',txt) is None)
395 else:
401 else:
396 # true if txt is _not_ a _ name, false otherwise:
402 # true if txt is _not_ a _ name, false otherwise:
397 no__name = (lambda txt:
403 no__name = (lambda txt:
398 re.match(r'.*\._.*?',txt) is None)
404 re.match(r'.*\._.*?',txt) is None)
399 matches = filter(no__name, matches)
405 matches = filter(no__name, matches)
400 except NameError:
406 except NameError:
401 # catches <undefined attributes>.<tab>
407 # catches <undefined attributes>.<tab>
402 matches = []
408 matches = []
403 else:
409 else:
404 matches = self.global_matches(text)
410 matches = self.global_matches(text)
405 # this is so completion finds magics when automagic is on:
411 # this is so completion finds magics when automagic is on:
406 if matches == [] and not text.startswith(os.sep):
412 if matches == [] and not text.startswith(os.sep):
407 matches = self.attr_matches(self.magic_prefix+text)
413 matches = self.attr_matches(self.magic_prefix+text)
408 return matches
414 return matches
409
415
410 def _default_arguments(self, obj):
416 def _default_arguments(self, obj):
411 """Return the list of default arguments of obj if it is callable,
417 """Return the list of default arguments of obj if it is callable,
412 or empty list otherwise."""
418 or empty list otherwise."""
413
419
414 if not (inspect.isfunction(obj) or inspect.ismethod(obj)):
420 if not (inspect.isfunction(obj) or inspect.ismethod(obj)):
415 # for classes, check for __init__,__new__
421 # for classes, check for __init__,__new__
416 if inspect.isclass(obj):
422 if inspect.isclass(obj):
417 obj = (getattr(obj,'__init__',None) or
423 obj = (getattr(obj,'__init__',None) or
418 getattr(obj,'__new__',None))
424 getattr(obj,'__new__',None))
419 # for all others, check if they are __call__able
425 # for all others, check if they are __call__able
420 elif hasattr(obj, '__call__'):
426 elif hasattr(obj, '__call__'):
421 obj = obj.__call__
427 obj = obj.__call__
422 # XXX: is there a way to handle the builtins ?
428 # XXX: is there a way to handle the builtins ?
423 try:
429 try:
424 args,_,_1,defaults = inspect.getargspec(obj)
430 args,_,_1,defaults = inspect.getargspec(obj)
425 if defaults:
431 if defaults:
426 return args[-len(defaults):]
432 return args[-len(defaults):]
427 except TypeError: pass
433 except TypeError: pass
428 return []
434 return []
429
435
430 def python_func_kw_matches(self,text):
436 def python_func_kw_matches(self,text):
431 """Match named parameters (kwargs) of the last open function"""
437 """Match named parameters (kwargs) of the last open function"""
432
438
433 if "." in text: # a parameter cannot be dotted
439 if "." in text: # a parameter cannot be dotted
434 return []
440 return []
435 try: regexp = self.__funcParamsRegex
441 try: regexp = self.__funcParamsRegex
436 except AttributeError:
442 except AttributeError:
437 regexp = self.__funcParamsRegex = re.compile(r'''
443 regexp = self.__funcParamsRegex = re.compile(r'''
438 '.*?' | # single quoted strings or
444 '.*?' | # single quoted strings or
439 ".*?" | # double quoted strings or
445 ".*?" | # double quoted strings or
440 \w+ | # identifier
446 \w+ | # identifier
441 \S # other characters
447 \S # other characters
442 ''', re.VERBOSE | re.DOTALL)
448 ''', re.VERBOSE | re.DOTALL)
443 # 1. find the nearest identifier that comes before an unclosed
449 # 1. find the nearest identifier that comes before an unclosed
444 # parenthesis e.g. for "foo (1+bar(x), pa", the candidate is "foo"
450 # parenthesis e.g. for "foo (1+bar(x), pa", the candidate is "foo"
445 tokens = regexp.findall(self.get_line_buffer())
451 tokens = regexp.findall(self.get_line_buffer())
446 tokens.reverse()
452 tokens.reverse()
447 iterTokens = iter(tokens); openPar = 0
453 iterTokens = iter(tokens); openPar = 0
448 for token in iterTokens:
454 for token in iterTokens:
449 if token == ')':
455 if token == ')':
450 openPar -= 1
456 openPar -= 1
451 elif token == '(':
457 elif token == '(':
452 openPar += 1
458 openPar += 1
453 if openPar > 0:
459 if openPar > 0:
454 # found the last unclosed parenthesis
460 # found the last unclosed parenthesis
455 break
461 break
456 else:
462 else:
457 return []
463 return []
458 # 2. Concatenate dotted names ("foo.bar" for "foo.bar(x, pa" )
464 # 2. Concatenate dotted names ("foo.bar" for "foo.bar(x, pa" )
459 ids = []
465 ids = []
460 isId = re.compile(r'\w+$').match
466 isId = re.compile(r'\w+$').match
461 while True:
467 while True:
462 try:
468 try:
463 ids.append(iterTokens.next())
469 ids.append(iterTokens.next())
464 if not isId(ids[-1]):
470 if not isId(ids[-1]):
465 ids.pop(); break
471 ids.pop(); break
466 if not iterTokens.next() == '.':
472 if not iterTokens.next() == '.':
467 break
473 break
468 except StopIteration:
474 except StopIteration:
469 break
475 break
470 # lookup the candidate callable matches either using global_matches
476 # lookup the candidate callable matches either using global_matches
471 # or attr_matches for dotted names
477 # or attr_matches for dotted names
472 if len(ids) == 1:
478 if len(ids) == 1:
473 callableMatches = self.global_matches(ids[0])
479 callableMatches = self.global_matches(ids[0])
474 else:
480 else:
475 callableMatches = self.attr_matches('.'.join(ids[::-1]))
481 callableMatches = self.attr_matches('.'.join(ids[::-1]))
476 argMatches = []
482 argMatches = []
477 for callableMatch in callableMatches:
483 for callableMatch in callableMatches:
478 try: namedArgs = self._default_arguments(eval(callableMatch,
484 try: namedArgs = self._default_arguments(eval(callableMatch,
479 self.namespace))
485 self.namespace))
480 except: continue
486 except: continue
481 for namedArg in namedArgs:
487 for namedArg in namedArgs:
482 if namedArg.startswith(text):
488 if namedArg.startswith(text):
483 argMatches.append("%s=" %namedArg)
489 argMatches.append("%s=" %namedArg)
484 return argMatches
490 return argMatches
485
491
486 def complete(self, text, state):
492 def complete(self, text, state):
487 """Return the next possible completion for 'text'.
493 """Return the next possible completion for 'text'.
488
494
489 This is called successively with state == 0, 1, 2, ... until it
495 This is called successively with state == 0, 1, 2, ... until it
490 returns None. The completion should begin with 'text'. """
496 returns None. The completion should begin with 'text'. """
491
497
492 #print '\n*** COMPLETE: <%s> (%s)' % (text,state) # dbg
498 #print '\n*** COMPLETE: <%s> (%s)' % (text,state) # dbg
493
499
494 # if there is only a tab on a line with only whitespace, instead
500 # if there is only a tab on a line with only whitespace, instead
495 # of the mostly useless 'do you want to see all million
501 # of the mostly useless 'do you want to see all million
496 # completions' message, just do the right thing and give the user
502 # completions' message, just do the right thing and give the user
497 # his tab! Incidentally, this enables pasting of tabbed text from
503 # his tab! Incidentally, this enables pasting of tabbed text from
498 # an editor (as long as autoindent is off).
504 # an editor (as long as autoindent is off).
499 if not self.get_line_buffer().strip():
505
506 # don't apply this on 'dumb' terminals, such as emacs buffers, so we
507 # don't interfere with their own tab-completion mechanism.
508 if not (self.dumb_terminal or self.get_line_buffer().strip()):
500 self.readline.insert_text('\t')
509 self.readline.insert_text('\t')
501 return None
510 return None
502
511
503 magic_escape = self.magic_escape
512 magic_escape = self.magic_escape
504 magic_prefix = self.magic_prefix
513 magic_prefix = self.magic_prefix
505
514
506 try:
515 try:
507 if text.startswith(magic_escape):
516 if text.startswith(magic_escape):
508 text = text.replace(magic_escape,magic_prefix)
517 text = text.replace(magic_escape,magic_prefix)
509 elif text.startswith('~'):
518 elif text.startswith('~'):
510 text = os.path.expanduser(text)
519 text = os.path.expanduser(text)
511 if state == 0:
520 if state == 0:
512 # Extend the list of completions with the results of each
521 # Extend the list of completions with the results of each
513 # matcher, so we return results to the user from all
522 # matcher, so we return results to the user from all
514 # namespaces.
523 # namespaces.
515 if self.merge_completions:
524 if self.merge_completions:
516 self.matches = []
525 self.matches = []
517 for matcher in self.matchers:
526 for matcher in self.matchers:
518 self.matches.extend(matcher(text))
527 self.matches.extend(matcher(text))
519 else:
528 else:
520 for matcher in self.matchers:
529 for matcher in self.matchers:
521 self.matches = matcher(text)
530 self.matches = matcher(text)
522 if self.matches:
531 if self.matches:
523 break
532 break
524
533
525 try:
534 try:
526 return self.matches[state].replace(magic_prefix,magic_escape)
535 return self.matches[state].replace(magic_prefix,magic_escape)
527 except IndexError:
536 except IndexError:
528 return None
537 return None
529 except:
538 except:
530 #from IPython.ultraTB import AutoFormattedTB; # dbg
539 #from IPython.ultraTB import AutoFormattedTB; # dbg
531 #tb=AutoFormattedTB('Verbose');tb() #dbg
540 #tb=AutoFormattedTB('Verbose');tb() #dbg
532
541
533 # If completion fails, don't annoy the user.
542 # If completion fails, don't annoy the user.
534 return None
543 return None
@@ -1,4713 +1,4721 b''
1 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
1 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
2
2
3 * IPython/completer.py (IPCompleter.complete): small patch to help
4 tab-completion under Emacs, after a suggestion by John Barnard
5 <barnarj-AT-ccf.org>.
6
7 * IPython/Magic.py (Magic.extract_input_slices): added support for
8 the slice notation in magics to use N-M to represent numbers N...M
9 (closed endpoints). This is used by %macro and %save.
10
3 * IPython/completer.py (Completer.attr_matches): for modules which
11 * IPython/completer.py (Completer.attr_matches): for modules which
4 define __all__, complete only on those. After a patch by Jeffrey
12 define __all__, complete only on those. After a patch by Jeffrey
5 Collins <jcollins-AT-boulder.net>. Also, clean up and speed up
13 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
6 this routine.
14 speed up this routine.
7
15
8 * IPython/Logger.py (Logger.log): fix a history handling bug. I
16 * IPython/Logger.py (Logger.log): fix a history handling bug. I
9 don't know if this is the end of it, but the behavior now is
17 don't know if this is the end of it, but the behavior now is
10 certainly much more correct. Note that coupled with macros,
18 certainly much more correct. Note that coupled with macros,
11 slightly surprising (at first) behavior may occur: a macro will in
19 slightly surprising (at first) behavior may occur: a macro will in
12 general expand to multiple lines of input, so upon exiting, the
20 general expand to multiple lines of input, so upon exiting, the
13 in/out counters will both be bumped by the corresponding amount
21 in/out counters will both be bumped by the corresponding amount
14 (as if the macro's contents had been typed interactively). Typing
22 (as if the macro's contents had been typed interactively). Typing
15 %hist will reveal the intermediate (silently processed) lines.
23 %hist will reveal the intermediate (silently processed) lines.
16
24
17 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
25 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
18 pickle to fail (%run was overwriting __main__ and not restoring
26 pickle to fail (%run was overwriting __main__ and not restoring
19 it, but pickle relies on __main__ to operate).
27 it, but pickle relies on __main__ to operate).
20
28
21 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
29 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
22 using properties, but forgot to make the main InteractiveShell
30 using properties, but forgot to make the main InteractiveShell
23 class a new-style class. Properties fail silently, and
31 class a new-style class. Properties fail silently, and
24 misteriously, with old-style class (getters work, but
32 misteriously, with old-style class (getters work, but
25 setters don't do anything).
33 setters don't do anything).
26
34
27 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
35 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
28
36
29 * IPython/Magic.py (magic_history): fix history reporting bug (I
37 * IPython/Magic.py (magic_history): fix history reporting bug (I
30 know some nasties are still there, I just can't seem to find a
38 know some nasties are still there, I just can't seem to find a
31 reproducible test case to track them down; the input history is
39 reproducible test case to track them down; the input history is
32 falling out of sync...)
40 falling out of sync...)
33
41
34 * IPython/iplib.py (handle_shell_escape): fix bug where both
42 * IPython/iplib.py (handle_shell_escape): fix bug where both
35 aliases and system accesses where broken for indented code (such
43 aliases and system accesses where broken for indented code (such
36 as loops).
44 as loops).
37
45
38 * IPython/genutils.py (shell): fix small but critical bug for
46 * IPython/genutils.py (shell): fix small but critical bug for
39 win32 system access.
47 win32 system access.
40
48
41 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
49 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
42
50
43 * IPython/iplib.py (showtraceback): remove use of the
51 * IPython/iplib.py (showtraceback): remove use of the
44 sys.last_{type/value/traceback} structures, which are non
52 sys.last_{type/value/traceback} structures, which are non
45 thread-safe.
53 thread-safe.
46 (_prefilter): change control flow to ensure that we NEVER
54 (_prefilter): change control flow to ensure that we NEVER
47 introspect objects when autocall is off. This will guarantee that
55 introspect objects when autocall is off. This will guarantee that
48 having an input line of the form 'x.y', where access to attribute
56 having an input line of the form 'x.y', where access to attribute
49 'y' has side effects, doesn't trigger the side effect TWICE. It
57 'y' has side effects, doesn't trigger the side effect TWICE. It
50 is important to note that, with autocall on, these side effects
58 is important to note that, with autocall on, these side effects
51 can still happen.
59 can still happen.
52 (ipsystem): new builtin, to complete the ip{magic/alias/system}
60 (ipsystem): new builtin, to complete the ip{magic/alias/system}
53 trio. IPython offers these three kinds of special calls which are
61 trio. IPython offers these three kinds of special calls which are
54 not python code, and it's a good thing to have their call method
62 not python code, and it's a good thing to have their call method
55 be accessible as pure python functions (not just special syntax at
63 be accessible as pure python functions (not just special syntax at
56 the command line). It gives us a better internal implementation
64 the command line). It gives us a better internal implementation
57 structure, as well as exposing these for user scripting more
65 structure, as well as exposing these for user scripting more
58 cleanly.
66 cleanly.
59
67
60 * IPython/macro.py (Macro.__init__): moved macros to a standalone
68 * IPython/macro.py (Macro.__init__): moved macros to a standalone
61 file. Now that they'll be more likely to be used with the
69 file. Now that they'll be more likely to be used with the
62 persistance system (%store), I want to make sure their module path
70 persistance system (%store), I want to make sure their module path
63 doesn't change in the future, so that we don't break things for
71 doesn't change in the future, so that we don't break things for
64 users' persisted data.
72 users' persisted data.
65
73
66 * IPython/iplib.py (autoindent_update): move indentation
74 * IPython/iplib.py (autoindent_update): move indentation
67 management into the _text_ processing loop, not the keyboard
75 management into the _text_ processing loop, not the keyboard
68 interactive one. This is necessary to correctly process non-typed
76 interactive one. This is necessary to correctly process non-typed
69 multiline input (such as macros).
77 multiline input (such as macros).
70
78
71 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
79 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
72 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
80 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
73 which was producing problems in the resulting manual.
81 which was producing problems in the resulting manual.
74 (magic_whos): improve reporting of instances (show their class,
82 (magic_whos): improve reporting of instances (show their class,
75 instead of simply printing 'instance' which isn't terribly
83 instead of simply printing 'instance' which isn't terribly
76 informative).
84 informative).
77
85
78 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
86 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
79 (minor mods) to support network shares under win32.
87 (minor mods) to support network shares under win32.
80
88
81 * IPython/winconsole.py (get_console_size): add new winconsole
89 * IPython/winconsole.py (get_console_size): add new winconsole
82 module and fixes to page_dumb() to improve its behavior under
90 module and fixes to page_dumb() to improve its behavior under
83 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
91 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
84
92
85 * IPython/Magic.py (Macro): simplified Macro class to just
93 * IPython/Magic.py (Macro): simplified Macro class to just
86 subclass list. We've had only 2.2 compatibility for a very long
94 subclass list. We've had only 2.2 compatibility for a very long
87 time, yet I was still avoiding subclassing the builtin types. No
95 time, yet I was still avoiding subclassing the builtin types. No
88 more (I'm also starting to use properties, though I won't shift to
96 more (I'm also starting to use properties, though I won't shift to
89 2.3-specific features quite yet).
97 2.3-specific features quite yet).
90 (magic_store): added Ville's patch for lightweight variable
98 (magic_store): added Ville's patch for lightweight variable
91 persistence, after a request on the user list by Matt Wilkie
99 persistence, after a request on the user list by Matt Wilkie
92 <maphew-AT-gmail.com>. The new %store magic's docstring has full
100 <maphew-AT-gmail.com>. The new %store magic's docstring has full
93 details.
101 details.
94
102
95 * IPython/iplib.py (InteractiveShell.post_config_initialization):
103 * IPython/iplib.py (InteractiveShell.post_config_initialization):
96 changed the default logfile name from 'ipython.log' to
104 changed the default logfile name from 'ipython.log' to
97 'ipython_log.py'. These logs are real python files, and now that
105 'ipython_log.py'. These logs are real python files, and now that
98 we have much better multiline support, people are more likely to
106 we have much better multiline support, people are more likely to
99 want to use them as such. Might as well name them correctly.
107 want to use them as such. Might as well name them correctly.
100
108
101 * IPython/Magic.py: substantial cleanup. While we can't stop
109 * IPython/Magic.py: substantial cleanup. While we can't stop
102 using magics as mixins, due to the existing customizations 'out
110 using magics as mixins, due to the existing customizations 'out
103 there' which rely on the mixin naming conventions, at least I
111 there' which rely on the mixin naming conventions, at least I
104 cleaned out all cross-class name usage. So once we are OK with
112 cleaned out all cross-class name usage. So once we are OK with
105 breaking compatibility, the two systems can be separated.
113 breaking compatibility, the two systems can be separated.
106
114
107 * IPython/Logger.py: major cleanup. This one is NOT a mixin
115 * IPython/Logger.py: major cleanup. This one is NOT a mixin
108 anymore, and the class is a fair bit less hideous as well. New
116 anymore, and the class is a fair bit less hideous as well. New
109 features were also introduced: timestamping of input, and logging
117 features were also introduced: timestamping of input, and logging
110 of output results. These are user-visible with the -t and -o
118 of output results. These are user-visible with the -t and -o
111 options to %logstart. Closes
119 options to %logstart. Closes
112 http://www.scipy.net/roundup/ipython/issue11 and a request by
120 http://www.scipy.net/roundup/ipython/issue11 and a request by
113 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
121 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
114
122
115 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
123 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
116
124
117 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
125 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
118 better hadnle backslashes in paths. See the thread 'More Windows
126 better hadnle backslashes in paths. See the thread 'More Windows
119 questions part 2 - \/ characters revisited' on the iypthon user
127 questions part 2 - \/ characters revisited' on the iypthon user
120 list:
128 list:
121 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
129 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
122
130
123 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
131 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
124
132
125 (InteractiveShell.__init__): change threaded shells to not use the
133 (InteractiveShell.__init__): change threaded shells to not use the
126 ipython crash handler. This was causing more problems than not,
134 ipython crash handler. This was causing more problems than not,
127 as exceptions in the main thread (GUI code, typically) would
135 as exceptions in the main thread (GUI code, typically) would
128 always show up as a 'crash', when they really weren't.
136 always show up as a 'crash', when they really weren't.
129
137
130 The colors and exception mode commands (%colors/%xmode) have been
138 The colors and exception mode commands (%colors/%xmode) have been
131 synchronized to also take this into account, so users can get
139 synchronized to also take this into account, so users can get
132 verbose exceptions for their threaded code as well. I also added
140 verbose exceptions for their threaded code as well. I also added
133 support for activating pdb inside this exception handler as well,
141 support for activating pdb inside this exception handler as well,
134 so now GUI authors can use IPython's enhanced pdb at runtime.
142 so now GUI authors can use IPython's enhanced pdb at runtime.
135
143
136 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
144 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
137 true by default, and add it to the shipped ipythonrc file. Since
145 true by default, and add it to the shipped ipythonrc file. Since
138 this asks the user before proceeding, I think it's OK to make it
146 this asks the user before proceeding, I think it's OK to make it
139 true by default.
147 true by default.
140
148
141 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
149 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
142 of the previous special-casing of input in the eval loop. I think
150 of the previous special-casing of input in the eval loop. I think
143 this is cleaner, as they really are commands and shouldn't have
151 this is cleaner, as they really are commands and shouldn't have
144 a special role in the middle of the core code.
152 a special role in the middle of the core code.
145
153
146 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
154 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
147
155
148 * IPython/iplib.py (edit_syntax_error): added support for
156 * IPython/iplib.py (edit_syntax_error): added support for
149 automatically reopening the editor if the file had a syntax error
157 automatically reopening the editor if the file had a syntax error
150 in it. Thanks to scottt who provided the patch at:
158 in it. Thanks to scottt who provided the patch at:
151 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
159 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
152 version committed).
160 version committed).
153
161
154 * IPython/iplib.py (handle_normal): add suport for multi-line
162 * IPython/iplib.py (handle_normal): add suport for multi-line
155 input with emtpy lines. This fixes
163 input with emtpy lines. This fixes
156 http://www.scipy.net/roundup/ipython/issue43 and a similar
164 http://www.scipy.net/roundup/ipython/issue43 and a similar
157 discussion on the user list.
165 discussion on the user list.
158
166
159 WARNING: a behavior change is necessarily introduced to support
167 WARNING: a behavior change is necessarily introduced to support
160 blank lines: now a single blank line with whitespace does NOT
168 blank lines: now a single blank line with whitespace does NOT
161 break the input loop, which means that when autoindent is on, by
169 break the input loop, which means that when autoindent is on, by
162 default hitting return on the next (indented) line does NOT exit.
170 default hitting return on the next (indented) line does NOT exit.
163
171
164 Instead, to exit a multiline input you can either have:
172 Instead, to exit a multiline input you can either have:
165
173
166 - TWO whitespace lines (just hit return again), or
174 - TWO whitespace lines (just hit return again), or
167 - a single whitespace line of a different length than provided
175 - a single whitespace line of a different length than provided
168 by the autoindent (add or remove a space).
176 by the autoindent (add or remove a space).
169
177
170 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
178 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
171 module to better organize all readline-related functionality.
179 module to better organize all readline-related functionality.
172 I've deleted FlexCompleter and put all completion clases here.
180 I've deleted FlexCompleter and put all completion clases here.
173
181
174 * IPython/iplib.py (raw_input): improve indentation management.
182 * IPython/iplib.py (raw_input): improve indentation management.
175 It is now possible to paste indented code with autoindent on, and
183 It is now possible to paste indented code with autoindent on, and
176 the code is interpreted correctly (though it still looks bad on
184 the code is interpreted correctly (though it still looks bad on
177 screen, due to the line-oriented nature of ipython).
185 screen, due to the line-oriented nature of ipython).
178 (MagicCompleter.complete): change behavior so that a TAB key on an
186 (MagicCompleter.complete): change behavior so that a TAB key on an
179 otherwise empty line actually inserts a tab, instead of completing
187 otherwise empty line actually inserts a tab, instead of completing
180 on the entire global namespace. This makes it easier to use the
188 on the entire global namespace. This makes it easier to use the
181 TAB key for indentation. After a request by Hans Meine
189 TAB key for indentation. After a request by Hans Meine
182 <hans_meine-AT-gmx.net>
190 <hans_meine-AT-gmx.net>
183 (_prefilter): add support so that typing plain 'exit' or 'quit'
191 (_prefilter): add support so that typing plain 'exit' or 'quit'
184 does a sensible thing. Originally I tried to deviate as little as
192 does a sensible thing. Originally I tried to deviate as little as
185 possible from the default python behavior, but even that one may
193 possible from the default python behavior, but even that one may
186 change in this direction (thread on python-dev to that effect).
194 change in this direction (thread on python-dev to that effect).
187 Regardless, ipython should do the right thing even if CPython's
195 Regardless, ipython should do the right thing even if CPython's
188 '>>>' prompt doesn't.
196 '>>>' prompt doesn't.
189 (InteractiveShell): removed subclassing code.InteractiveConsole
197 (InteractiveShell): removed subclassing code.InteractiveConsole
190 class. By now we'd overridden just about all of its methods: I've
198 class. By now we'd overridden just about all of its methods: I've
191 copied the remaining two over, and now ipython is a standalone
199 copied the remaining two over, and now ipython is a standalone
192 class. This will provide a clearer picture for the chainsaw
200 class. This will provide a clearer picture for the chainsaw
193 branch refactoring.
201 branch refactoring.
194
202
195 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
203 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
196
204
197 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
205 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
198 failures for objects which break when dir() is called on them.
206 failures for objects which break when dir() is called on them.
199
207
200 * IPython/FlexCompleter.py (Completer.__init__): Added support for
208 * IPython/FlexCompleter.py (Completer.__init__): Added support for
201 distinct local and global namespaces in the completer API. This
209 distinct local and global namespaces in the completer API. This
202 change allows us top properly handle completion with distinct
210 change allows us top properly handle completion with distinct
203 scopes, including in embedded instances (this had never really
211 scopes, including in embedded instances (this had never really
204 worked correctly).
212 worked correctly).
205
213
206 Note: this introduces a change in the constructor for
214 Note: this introduces a change in the constructor for
207 MagicCompleter, as a new global_namespace parameter is now the
215 MagicCompleter, as a new global_namespace parameter is now the
208 second argument (the others were bumped one position).
216 second argument (the others were bumped one position).
209
217
210 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
218 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
211
219
212 * IPython/iplib.py (embed_mainloop): fix tab-completion in
220 * IPython/iplib.py (embed_mainloop): fix tab-completion in
213 embedded instances (which can be done now thanks to Vivian's
221 embedded instances (which can be done now thanks to Vivian's
214 frame-handling fixes for pdb).
222 frame-handling fixes for pdb).
215 (InteractiveShell.__init__): Fix namespace handling problem in
223 (InteractiveShell.__init__): Fix namespace handling problem in
216 embedded instances. We were overwriting __main__ unconditionally,
224 embedded instances. We were overwriting __main__ unconditionally,
217 and this should only be done for 'full' (non-embedded) IPython;
225 and this should only be done for 'full' (non-embedded) IPython;
218 embedded instances must respect the caller's __main__. Thanks to
226 embedded instances must respect the caller's __main__. Thanks to
219 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
227 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
220
228
221 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
229 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
222
230
223 * setup.py: added download_url to setup(). This registers the
231 * setup.py: added download_url to setup(). This registers the
224 download address at PyPI, which is not only useful to humans
232 download address at PyPI, which is not only useful to humans
225 browsing the site, but is also picked up by setuptools (the Eggs
233 browsing the site, but is also picked up by setuptools (the Eggs
226 machinery). Thanks to Ville and R. Kern for the info/discussion
234 machinery). Thanks to Ville and R. Kern for the info/discussion
227 on this.
235 on this.
228
236
229 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
237 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
230
238
231 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
239 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
232 This brings a lot of nice functionality to the pdb mode, which now
240 This brings a lot of nice functionality to the pdb mode, which now
233 has tab-completion, syntax highlighting, and better stack handling
241 has tab-completion, syntax highlighting, and better stack handling
234 than before. Many thanks to Vivian De Smedt
242 than before. Many thanks to Vivian De Smedt
235 <vivian-AT-vdesmedt.com> for the original patches.
243 <vivian-AT-vdesmedt.com> for the original patches.
236
244
237 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
245 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
238
246
239 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
247 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
240 sequence to consistently accept the banner argument. The
248 sequence to consistently accept the banner argument. The
241 inconsistency was tripping SAGE, thanks to Gary Zablackis
249 inconsistency was tripping SAGE, thanks to Gary Zablackis
242 <gzabl-AT-yahoo.com> for the report.
250 <gzabl-AT-yahoo.com> for the report.
243
251
244 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
252 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
245
253
246 * IPython/iplib.py (InteractiveShell.post_config_initialization):
254 * IPython/iplib.py (InteractiveShell.post_config_initialization):
247 Fix bug where a naked 'alias' call in the ipythonrc file would
255 Fix bug where a naked 'alias' call in the ipythonrc file would
248 cause a crash. Bug reported by Jorgen Stenarson.
256 cause a crash. Bug reported by Jorgen Stenarson.
249
257
250 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
258 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
251
259
252 * IPython/ipmaker.py (make_IPython): cleanups which should improve
260 * IPython/ipmaker.py (make_IPython): cleanups which should improve
253 startup time.
261 startup time.
254
262
255 * IPython/iplib.py (runcode): my globals 'fix' for embedded
263 * IPython/iplib.py (runcode): my globals 'fix' for embedded
256 instances had introduced a bug with globals in normal code. Now
264 instances had introduced a bug with globals in normal code. Now
257 it's working in all cases.
265 it's working in all cases.
258
266
259 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
267 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
260 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
268 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
261 has been introduced to set the default case sensitivity of the
269 has been introduced to set the default case sensitivity of the
262 searches. Users can still select either mode at runtime on a
270 searches. Users can still select either mode at runtime on a
263 per-search basis.
271 per-search basis.
264
272
265 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
273 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
266
274
267 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
275 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
268 attributes in wildcard searches for subclasses. Modified version
276 attributes in wildcard searches for subclasses. Modified version
269 of a patch by Jorgen.
277 of a patch by Jorgen.
270
278
271 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
279 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
272
280
273 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
281 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
274 embedded instances. I added a user_global_ns attribute to the
282 embedded instances. I added a user_global_ns attribute to the
275 InteractiveShell class to handle this.
283 InteractiveShell class to handle this.
276
284
277 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
285 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
278
286
279 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
287 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
280 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
288 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
281 (reported under win32, but may happen also in other platforms).
289 (reported under win32, but may happen also in other platforms).
282 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
290 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
283
291
284 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
292 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
285
293
286 * IPython/Magic.py (magic_psearch): new support for wildcard
294 * IPython/Magic.py (magic_psearch): new support for wildcard
287 patterns. Now, typing ?a*b will list all names which begin with a
295 patterns. Now, typing ?a*b will list all names which begin with a
288 and end in b, for example. The %psearch magic has full
296 and end in b, for example. The %psearch magic has full
289 docstrings. Many thanks to JΓΆrgen Stenarson
297 docstrings. Many thanks to JΓΆrgen Stenarson
290 <jorgen.stenarson-AT-bostream.nu>, author of the patches
298 <jorgen.stenarson-AT-bostream.nu>, author of the patches
291 implementing this functionality.
299 implementing this functionality.
292
300
293 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
301 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
294
302
295 * Manual: fixed long-standing annoyance of double-dashes (as in
303 * Manual: fixed long-standing annoyance of double-dashes (as in
296 --prefix=~, for example) being stripped in the HTML version. This
304 --prefix=~, for example) being stripped in the HTML version. This
297 is a latex2html bug, but a workaround was provided. Many thanks
305 is a latex2html bug, but a workaround was provided. Many thanks
298 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
306 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
299 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
307 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
300 rolling. This seemingly small issue had tripped a number of users
308 rolling. This seemingly small issue had tripped a number of users
301 when first installing, so I'm glad to see it gone.
309 when first installing, so I'm glad to see it gone.
302
310
303 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
311 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
304
312
305 * IPython/Extensions/numeric_formats.py: fix missing import,
313 * IPython/Extensions/numeric_formats.py: fix missing import,
306 reported by Stephen Walton.
314 reported by Stephen Walton.
307
315
308 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
316 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
309
317
310 * IPython/demo.py: finish demo module, fully documented now.
318 * IPython/demo.py: finish demo module, fully documented now.
311
319
312 * IPython/genutils.py (file_read): simple little utility to read a
320 * IPython/genutils.py (file_read): simple little utility to read a
313 file and ensure it's closed afterwards.
321 file and ensure it's closed afterwards.
314
322
315 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
323 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
316
324
317 * IPython/demo.py (Demo.__init__): added support for individually
325 * IPython/demo.py (Demo.__init__): added support for individually
318 tagging blocks for automatic execution.
326 tagging blocks for automatic execution.
319
327
320 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
328 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
321 syntax-highlighted python sources, requested by John.
329 syntax-highlighted python sources, requested by John.
322
330
323 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
331 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
324
332
325 * IPython/demo.py (Demo.again): fix bug where again() blocks after
333 * IPython/demo.py (Demo.again): fix bug where again() blocks after
326 finishing.
334 finishing.
327
335
328 * IPython/genutils.py (shlex_split): moved from Magic to here,
336 * IPython/genutils.py (shlex_split): moved from Magic to here,
329 where all 2.2 compatibility stuff lives. I needed it for demo.py.
337 where all 2.2 compatibility stuff lives. I needed it for demo.py.
330
338
331 * IPython/demo.py (Demo.__init__): added support for silent
339 * IPython/demo.py (Demo.__init__): added support for silent
332 blocks, improved marks as regexps, docstrings written.
340 blocks, improved marks as regexps, docstrings written.
333 (Demo.__init__): better docstring, added support for sys.argv.
341 (Demo.__init__): better docstring, added support for sys.argv.
334
342
335 * IPython/genutils.py (marquee): little utility used by the demo
343 * IPython/genutils.py (marquee): little utility used by the demo
336 code, handy in general.
344 code, handy in general.
337
345
338 * IPython/demo.py (Demo.__init__): new class for interactive
346 * IPython/demo.py (Demo.__init__): new class for interactive
339 demos. Not documented yet, I just wrote it in a hurry for
347 demos. Not documented yet, I just wrote it in a hurry for
340 scipy'05. Will docstring later.
348 scipy'05. Will docstring later.
341
349
342 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
350 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
343
351
344 * IPython/Shell.py (sigint_handler): Drastic simplification which
352 * IPython/Shell.py (sigint_handler): Drastic simplification which
345 also seems to make Ctrl-C work correctly across threads! This is
353 also seems to make Ctrl-C work correctly across threads! This is
346 so simple, that I can't beleive I'd missed it before. Needs more
354 so simple, that I can't beleive I'd missed it before. Needs more
347 testing, though.
355 testing, though.
348 (KBINT): Never mind, revert changes. I'm sure I'd tried something
356 (KBINT): Never mind, revert changes. I'm sure I'd tried something
349 like this before...
357 like this before...
350
358
351 * IPython/genutils.py (get_home_dir): add protection against
359 * IPython/genutils.py (get_home_dir): add protection against
352 non-dirs in win32 registry.
360 non-dirs in win32 registry.
353
361
354 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
362 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
355 bug where dict was mutated while iterating (pysh crash).
363 bug where dict was mutated while iterating (pysh crash).
356
364
357 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
365 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
358
366
359 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
367 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
360 spurious newlines added by this routine. After a report by
368 spurious newlines added by this routine. After a report by
361 F. Mantegazza.
369 F. Mantegazza.
362
370
363 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
371 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
364
372
365 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
373 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
366 calls. These were a leftover from the GTK 1.x days, and can cause
374 calls. These were a leftover from the GTK 1.x days, and can cause
367 problems in certain cases (after a report by John Hunter).
375 problems in certain cases (after a report by John Hunter).
368
376
369 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
377 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
370 os.getcwd() fails at init time. Thanks to patch from David Remahl
378 os.getcwd() fails at init time. Thanks to patch from David Remahl
371 <chmod007-AT-mac.com>.
379 <chmod007-AT-mac.com>.
372 (InteractiveShell.__init__): prevent certain special magics from
380 (InteractiveShell.__init__): prevent certain special magics from
373 being shadowed by aliases. Closes
381 being shadowed by aliases. Closes
374 http://www.scipy.net/roundup/ipython/issue41.
382 http://www.scipy.net/roundup/ipython/issue41.
375
383
376 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
384 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
377
385
378 * IPython/iplib.py (InteractiveShell.complete): Added new
386 * IPython/iplib.py (InteractiveShell.complete): Added new
379 top-level completion method to expose the completion mechanism
387 top-level completion method to expose the completion mechanism
380 beyond readline-based environments.
388 beyond readline-based environments.
381
389
382 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
390 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
383
391
384 * tools/ipsvnc (svnversion): fix svnversion capture.
392 * tools/ipsvnc (svnversion): fix svnversion capture.
385
393
386 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
394 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
387 attribute to self, which was missing. Before, it was set by a
395 attribute to self, which was missing. Before, it was set by a
388 routine which in certain cases wasn't being called, so the
396 routine which in certain cases wasn't being called, so the
389 instance could end up missing the attribute. This caused a crash.
397 instance could end up missing the attribute. This caused a crash.
390 Closes http://www.scipy.net/roundup/ipython/issue40.
398 Closes http://www.scipy.net/roundup/ipython/issue40.
391
399
392 2005-08-16 Fernando Perez <fperez@colorado.edu>
400 2005-08-16 Fernando Perez <fperez@colorado.edu>
393
401
394 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
402 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
395 contains non-string attribute. Closes
403 contains non-string attribute. Closes
396 http://www.scipy.net/roundup/ipython/issue38.
404 http://www.scipy.net/roundup/ipython/issue38.
397
405
398 2005-08-14 Fernando Perez <fperez@colorado.edu>
406 2005-08-14 Fernando Perez <fperez@colorado.edu>
399
407
400 * tools/ipsvnc: Minor improvements, to add changeset info.
408 * tools/ipsvnc: Minor improvements, to add changeset info.
401
409
402 2005-08-12 Fernando Perez <fperez@colorado.edu>
410 2005-08-12 Fernando Perez <fperez@colorado.edu>
403
411
404 * IPython/iplib.py (runsource): remove self.code_to_run_src
412 * IPython/iplib.py (runsource): remove self.code_to_run_src
405 attribute. I realized this is nothing more than
413 attribute. I realized this is nothing more than
406 '\n'.join(self.buffer), and having the same data in two different
414 '\n'.join(self.buffer), and having the same data in two different
407 places is just asking for synchronization bugs. This may impact
415 places is just asking for synchronization bugs. This may impact
408 people who have custom exception handlers, so I need to warn
416 people who have custom exception handlers, so I need to warn
409 ipython-dev about it (F. Mantegazza may use them).
417 ipython-dev about it (F. Mantegazza may use them).
410
418
411 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
419 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
412
420
413 * IPython/genutils.py: fix 2.2 compatibility (generators)
421 * IPython/genutils.py: fix 2.2 compatibility (generators)
414
422
415 2005-07-18 Fernando Perez <fperez@colorado.edu>
423 2005-07-18 Fernando Perez <fperez@colorado.edu>
416
424
417 * IPython/genutils.py (get_home_dir): fix to help users with
425 * IPython/genutils.py (get_home_dir): fix to help users with
418 invalid $HOME under win32.
426 invalid $HOME under win32.
419
427
420 2005-07-17 Fernando Perez <fperez@colorado.edu>
428 2005-07-17 Fernando Perez <fperez@colorado.edu>
421
429
422 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
430 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
423 some old hacks and clean up a bit other routines; code should be
431 some old hacks and clean up a bit other routines; code should be
424 simpler and a bit faster.
432 simpler and a bit faster.
425
433
426 * IPython/iplib.py (interact): removed some last-resort attempts
434 * IPython/iplib.py (interact): removed some last-resort attempts
427 to survive broken stdout/stderr. That code was only making it
435 to survive broken stdout/stderr. That code was only making it
428 harder to abstract out the i/o (necessary for gui integration),
436 harder to abstract out the i/o (necessary for gui integration),
429 and the crashes it could prevent were extremely rare in practice
437 and the crashes it could prevent were extremely rare in practice
430 (besides being fully user-induced in a pretty violent manner).
438 (besides being fully user-induced in a pretty violent manner).
431
439
432 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
440 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
433 Nothing major yet, but the code is simpler to read; this should
441 Nothing major yet, but the code is simpler to read; this should
434 make it easier to do more serious modifications in the future.
442 make it easier to do more serious modifications in the future.
435
443
436 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
444 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
437 which broke in .15 (thanks to a report by Ville).
445 which broke in .15 (thanks to a report by Ville).
438
446
439 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
447 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
440 be quite correct, I know next to nothing about unicode). This
448 be quite correct, I know next to nothing about unicode). This
441 will allow unicode strings to be used in prompts, amongst other
449 will allow unicode strings to be used in prompts, amongst other
442 cases. It also will prevent ipython from crashing when unicode
450 cases. It also will prevent ipython from crashing when unicode
443 shows up unexpectedly in many places. If ascii encoding fails, we
451 shows up unexpectedly in many places. If ascii encoding fails, we
444 assume utf_8. Currently the encoding is not a user-visible
452 assume utf_8. Currently the encoding is not a user-visible
445 setting, though it could be made so if there is demand for it.
453 setting, though it could be made so if there is demand for it.
446
454
447 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
455 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
448
456
449 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
457 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
450
458
451 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
459 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
452
460
453 * IPython/genutils.py: Add 2.2 compatibility here, so all other
461 * IPython/genutils.py: Add 2.2 compatibility here, so all other
454 code can work transparently for 2.2/2.3.
462 code can work transparently for 2.2/2.3.
455
463
456 2005-07-16 Fernando Perez <fperez@colorado.edu>
464 2005-07-16 Fernando Perez <fperez@colorado.edu>
457
465
458 * IPython/ultraTB.py (ExceptionColors): Make a global variable
466 * IPython/ultraTB.py (ExceptionColors): Make a global variable
459 out of the color scheme table used for coloring exception
467 out of the color scheme table used for coloring exception
460 tracebacks. This allows user code to add new schemes at runtime.
468 tracebacks. This allows user code to add new schemes at runtime.
461 This is a minimally modified version of the patch at
469 This is a minimally modified version of the patch at
462 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
470 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
463 for the contribution.
471 for the contribution.
464
472
465 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
473 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
466 slightly modified version of the patch in
474 slightly modified version of the patch in
467 http://www.scipy.net/roundup/ipython/issue34, which also allows me
475 http://www.scipy.net/roundup/ipython/issue34, which also allows me
468 to remove the previous try/except solution (which was costlier).
476 to remove the previous try/except solution (which was costlier).
469 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
477 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
470
478
471 2005-06-08 Fernando Perez <fperez@colorado.edu>
479 2005-06-08 Fernando Perez <fperez@colorado.edu>
472
480
473 * IPython/iplib.py (write/write_err): Add methods to abstract all
481 * IPython/iplib.py (write/write_err): Add methods to abstract all
474 I/O a bit more.
482 I/O a bit more.
475
483
476 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
484 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
477 warning, reported by Aric Hagberg, fix by JD Hunter.
485 warning, reported by Aric Hagberg, fix by JD Hunter.
478
486
479 2005-06-02 *** Released version 0.6.15
487 2005-06-02 *** Released version 0.6.15
480
488
481 2005-06-01 Fernando Perez <fperez@colorado.edu>
489 2005-06-01 Fernando Perez <fperez@colorado.edu>
482
490
483 * IPython/iplib.py (MagicCompleter.file_matches): Fix
491 * IPython/iplib.py (MagicCompleter.file_matches): Fix
484 tab-completion of filenames within open-quoted strings. Note that
492 tab-completion of filenames within open-quoted strings. Note that
485 this requires that in ~/.ipython/ipythonrc, users change the
493 this requires that in ~/.ipython/ipythonrc, users change the
486 readline delimiters configuration to read:
494 readline delimiters configuration to read:
487
495
488 readline_remove_delims -/~
496 readline_remove_delims -/~
489
497
490
498
491 2005-05-31 *** Released version 0.6.14
499 2005-05-31 *** Released version 0.6.14
492
500
493 2005-05-29 Fernando Perez <fperez@colorado.edu>
501 2005-05-29 Fernando Perez <fperez@colorado.edu>
494
502
495 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
503 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
496 with files not on the filesystem. Reported by Eliyahu Sandler
504 with files not on the filesystem. Reported by Eliyahu Sandler
497 <eli@gondolin.net>
505 <eli@gondolin.net>
498
506
499 2005-05-22 Fernando Perez <fperez@colorado.edu>
507 2005-05-22 Fernando Perez <fperez@colorado.edu>
500
508
501 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
509 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
502 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
510 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
503
511
504 2005-05-19 Fernando Perez <fperez@colorado.edu>
512 2005-05-19 Fernando Perez <fperez@colorado.edu>
505
513
506 * IPython/iplib.py (safe_execfile): close a file which could be
514 * IPython/iplib.py (safe_execfile): close a file which could be
507 left open (causing problems in win32, which locks open files).
515 left open (causing problems in win32, which locks open files).
508 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
516 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
509
517
510 2005-05-18 Fernando Perez <fperez@colorado.edu>
518 2005-05-18 Fernando Perez <fperez@colorado.edu>
511
519
512 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
520 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
513 keyword arguments correctly to safe_execfile().
521 keyword arguments correctly to safe_execfile().
514
522
515 2005-05-13 Fernando Perez <fperez@colorado.edu>
523 2005-05-13 Fernando Perez <fperez@colorado.edu>
516
524
517 * ipython.1: Added info about Qt to manpage, and threads warning
525 * ipython.1: Added info about Qt to manpage, and threads warning
518 to usage page (invoked with --help).
526 to usage page (invoked with --help).
519
527
520 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
528 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
521 new matcher (it goes at the end of the priority list) to do
529 new matcher (it goes at the end of the priority list) to do
522 tab-completion on named function arguments. Submitted by George
530 tab-completion on named function arguments. Submitted by George
523 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
531 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
524 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
532 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
525 for more details.
533 for more details.
526
534
527 * IPython/Magic.py (magic_run): Added new -e flag to ignore
535 * IPython/Magic.py (magic_run): Added new -e flag to ignore
528 SystemExit exceptions in the script being run. Thanks to a report
536 SystemExit exceptions in the script being run. Thanks to a report
529 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
537 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
530 producing very annoying behavior when running unit tests.
538 producing very annoying behavior when running unit tests.
531
539
532 2005-05-12 Fernando Perez <fperez@colorado.edu>
540 2005-05-12 Fernando Perez <fperez@colorado.edu>
533
541
534 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
542 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
535 which I'd broken (again) due to a changed regexp. In the process,
543 which I'd broken (again) due to a changed regexp. In the process,
536 added ';' as an escape to auto-quote the whole line without
544 added ';' as an escape to auto-quote the whole line without
537 splitting its arguments. Thanks to a report by Jerry McRae
545 splitting its arguments. Thanks to a report by Jerry McRae
538 <qrs0xyc02-AT-sneakemail.com>.
546 <qrs0xyc02-AT-sneakemail.com>.
539
547
540 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
548 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
541 possible crashes caused by a TokenError. Reported by Ed Schofield
549 possible crashes caused by a TokenError. Reported by Ed Schofield
542 <schofield-AT-ftw.at>.
550 <schofield-AT-ftw.at>.
543
551
544 2005-05-06 Fernando Perez <fperez@colorado.edu>
552 2005-05-06 Fernando Perez <fperez@colorado.edu>
545
553
546 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
554 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
547
555
548 2005-04-29 Fernando Perez <fperez@colorado.edu>
556 2005-04-29 Fernando Perez <fperez@colorado.edu>
549
557
550 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
558 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
551 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
559 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
552 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
560 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
553 which provides support for Qt interactive usage (similar to the
561 which provides support for Qt interactive usage (similar to the
554 existing one for WX and GTK). This had been often requested.
562 existing one for WX and GTK). This had been often requested.
555
563
556 2005-04-14 *** Released version 0.6.13
564 2005-04-14 *** Released version 0.6.13
557
565
558 2005-04-08 Fernando Perez <fperez@colorado.edu>
566 2005-04-08 Fernando Perez <fperez@colorado.edu>
559
567
560 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
568 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
561 from _ofind, which gets called on almost every input line. Now,
569 from _ofind, which gets called on almost every input line. Now,
562 we only try to get docstrings if they are actually going to be
570 we only try to get docstrings if they are actually going to be
563 used (the overhead of fetching unnecessary docstrings can be
571 used (the overhead of fetching unnecessary docstrings can be
564 noticeable for certain objects, such as Pyro proxies).
572 noticeable for certain objects, such as Pyro proxies).
565
573
566 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
574 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
567 for completers. For some reason I had been passing them the state
575 for completers. For some reason I had been passing them the state
568 variable, which completers never actually need, and was in
576 variable, which completers never actually need, and was in
569 conflict with the rlcompleter API. Custom completers ONLY need to
577 conflict with the rlcompleter API. Custom completers ONLY need to
570 take the text parameter.
578 take the text parameter.
571
579
572 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
580 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
573 work correctly in pysh. I've also moved all the logic which used
581 work correctly in pysh. I've also moved all the logic which used
574 to be in pysh.py here, which will prevent problems with future
582 to be in pysh.py here, which will prevent problems with future
575 upgrades. However, this time I must warn users to update their
583 upgrades. However, this time I must warn users to update their
576 pysh profile to include the line
584 pysh profile to include the line
577
585
578 import_all IPython.Extensions.InterpreterExec
586 import_all IPython.Extensions.InterpreterExec
579
587
580 because otherwise things won't work for them. They MUST also
588 because otherwise things won't work for them. They MUST also
581 delete pysh.py and the line
589 delete pysh.py and the line
582
590
583 execfile pysh.py
591 execfile pysh.py
584
592
585 from their ipythonrc-pysh.
593 from their ipythonrc-pysh.
586
594
587 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
595 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
588 robust in the face of objects whose dir() returns non-strings
596 robust in the face of objects whose dir() returns non-strings
589 (which it shouldn't, but some broken libs like ITK do). Thanks to
597 (which it shouldn't, but some broken libs like ITK do). Thanks to
590 a patch by John Hunter (implemented differently, though). Also
598 a patch by John Hunter (implemented differently, though). Also
591 minor improvements by using .extend instead of + on lists.
599 minor improvements by using .extend instead of + on lists.
592
600
593 * pysh.py:
601 * pysh.py:
594
602
595 2005-04-06 Fernando Perez <fperez@colorado.edu>
603 2005-04-06 Fernando Perez <fperez@colorado.edu>
596
604
597 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
605 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
598 by default, so that all users benefit from it. Those who don't
606 by default, so that all users benefit from it. Those who don't
599 want it can still turn it off.
607 want it can still turn it off.
600
608
601 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
609 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
602 config file, I'd forgotten about this, so users were getting it
610 config file, I'd forgotten about this, so users were getting it
603 off by default.
611 off by default.
604
612
605 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
613 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
606 consistency. Now magics can be called in multiline statements,
614 consistency. Now magics can be called in multiline statements,
607 and python variables can be expanded in magic calls via $var.
615 and python variables can be expanded in magic calls via $var.
608 This makes the magic system behave just like aliases or !system
616 This makes the magic system behave just like aliases or !system
609 calls.
617 calls.
610
618
611 2005-03-28 Fernando Perez <fperez@colorado.edu>
619 2005-03-28 Fernando Perez <fperez@colorado.edu>
612
620
613 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
621 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
614 expensive string additions for building command. Add support for
622 expensive string additions for building command. Add support for
615 trailing ';' when autocall is used.
623 trailing ';' when autocall is used.
616
624
617 2005-03-26 Fernando Perez <fperez@colorado.edu>
625 2005-03-26 Fernando Perez <fperez@colorado.edu>
618
626
619 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
627 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
620 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
628 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
621 ipython.el robust against prompts with any number of spaces
629 ipython.el robust against prompts with any number of spaces
622 (including 0) after the ':' character.
630 (including 0) after the ':' character.
623
631
624 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
632 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
625 continuation prompt, which misled users to think the line was
633 continuation prompt, which misled users to think the line was
626 already indented. Closes debian Bug#300847, reported to me by
634 already indented. Closes debian Bug#300847, reported to me by
627 Norbert Tretkowski <tretkowski-AT-inittab.de>.
635 Norbert Tretkowski <tretkowski-AT-inittab.de>.
628
636
629 2005-03-23 Fernando Perez <fperez@colorado.edu>
637 2005-03-23 Fernando Perez <fperez@colorado.edu>
630
638
631 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
639 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
632 properly aligned if they have embedded newlines.
640 properly aligned if they have embedded newlines.
633
641
634 * IPython/iplib.py (runlines): Add a public method to expose
642 * IPython/iplib.py (runlines): Add a public method to expose
635 IPython's code execution machinery, so that users can run strings
643 IPython's code execution machinery, so that users can run strings
636 as if they had been typed at the prompt interactively.
644 as if they had been typed at the prompt interactively.
637 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
645 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
638 methods which can call the system shell, but with python variable
646 methods which can call the system shell, but with python variable
639 expansion. The three such methods are: __IPYTHON__.system,
647 expansion. The three such methods are: __IPYTHON__.system,
640 .getoutput and .getoutputerror. These need to be documented in a
648 .getoutput and .getoutputerror. These need to be documented in a
641 'public API' section (to be written) of the manual.
649 'public API' section (to be written) of the manual.
642
650
643 2005-03-20 Fernando Perez <fperez@colorado.edu>
651 2005-03-20 Fernando Perez <fperez@colorado.edu>
644
652
645 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
653 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
646 for custom exception handling. This is quite powerful, and it
654 for custom exception handling. This is quite powerful, and it
647 allows for user-installable exception handlers which can trap
655 allows for user-installable exception handlers which can trap
648 custom exceptions at runtime and treat them separately from
656 custom exceptions at runtime and treat them separately from
649 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
657 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
650 Mantegazza <mantegazza-AT-ill.fr>.
658 Mantegazza <mantegazza-AT-ill.fr>.
651 (InteractiveShell.set_custom_completer): public API function to
659 (InteractiveShell.set_custom_completer): public API function to
652 add new completers at runtime.
660 add new completers at runtime.
653
661
654 2005-03-19 Fernando Perez <fperez@colorado.edu>
662 2005-03-19 Fernando Perez <fperez@colorado.edu>
655
663
656 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
664 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
657 allow objects which provide their docstrings via non-standard
665 allow objects which provide their docstrings via non-standard
658 mechanisms (like Pyro proxies) to still be inspected by ipython's
666 mechanisms (like Pyro proxies) to still be inspected by ipython's
659 ? system.
667 ? system.
660
668
661 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
669 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
662 automatic capture system. I tried quite hard to make it work
670 automatic capture system. I tried quite hard to make it work
663 reliably, and simply failed. I tried many combinations with the
671 reliably, and simply failed. I tried many combinations with the
664 subprocess module, but eventually nothing worked in all needed
672 subprocess module, but eventually nothing worked in all needed
665 cases (not blocking stdin for the child, duplicating stdout
673 cases (not blocking stdin for the child, duplicating stdout
666 without blocking, etc). The new %sc/%sx still do capture to these
674 without blocking, etc). The new %sc/%sx still do capture to these
667 magical list/string objects which make shell use much more
675 magical list/string objects which make shell use much more
668 conveninent, so not all is lost.
676 conveninent, so not all is lost.
669
677
670 XXX - FIX MANUAL for the change above!
678 XXX - FIX MANUAL for the change above!
671
679
672 (runsource): I copied code.py's runsource() into ipython to modify
680 (runsource): I copied code.py's runsource() into ipython to modify
673 it a bit. Now the code object and source to be executed are
681 it a bit. Now the code object and source to be executed are
674 stored in ipython. This makes this info accessible to third-party
682 stored in ipython. This makes this info accessible to third-party
675 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
683 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
676 Mantegazza <mantegazza-AT-ill.fr>.
684 Mantegazza <mantegazza-AT-ill.fr>.
677
685
678 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
686 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
679 history-search via readline (like C-p/C-n). I'd wanted this for a
687 history-search via readline (like C-p/C-n). I'd wanted this for a
680 long time, but only recently found out how to do it. For users
688 long time, but only recently found out how to do it. For users
681 who already have their ipythonrc files made and want this, just
689 who already have their ipythonrc files made and want this, just
682 add:
690 add:
683
691
684 readline_parse_and_bind "\e[A": history-search-backward
692 readline_parse_and_bind "\e[A": history-search-backward
685 readline_parse_and_bind "\e[B": history-search-forward
693 readline_parse_and_bind "\e[B": history-search-forward
686
694
687 2005-03-18 Fernando Perez <fperez@colorado.edu>
695 2005-03-18 Fernando Perez <fperez@colorado.edu>
688
696
689 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
697 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
690 LSString and SList classes which allow transparent conversions
698 LSString and SList classes which allow transparent conversions
691 between list mode and whitespace-separated string.
699 between list mode and whitespace-separated string.
692 (magic_r): Fix recursion problem in %r.
700 (magic_r): Fix recursion problem in %r.
693
701
694 * IPython/genutils.py (LSString): New class to be used for
702 * IPython/genutils.py (LSString): New class to be used for
695 automatic storage of the results of all alias/system calls in _o
703 automatic storage of the results of all alias/system calls in _o
696 and _e (stdout/err). These provide a .l/.list attribute which
704 and _e (stdout/err). These provide a .l/.list attribute which
697 does automatic splitting on newlines. This means that for most
705 does automatic splitting on newlines. This means that for most
698 uses, you'll never need to do capturing of output with %sc/%sx
706 uses, you'll never need to do capturing of output with %sc/%sx
699 anymore, since ipython keeps this always done for you. Note that
707 anymore, since ipython keeps this always done for you. Note that
700 only the LAST results are stored, the _o/e variables are
708 only the LAST results are stored, the _o/e variables are
701 overwritten on each call. If you need to save their contents
709 overwritten on each call. If you need to save their contents
702 further, simply bind them to any other name.
710 further, simply bind them to any other name.
703
711
704 2005-03-17 Fernando Perez <fperez@colorado.edu>
712 2005-03-17 Fernando Perez <fperez@colorado.edu>
705
713
706 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
714 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
707 prompt namespace handling.
715 prompt namespace handling.
708
716
709 2005-03-16 Fernando Perez <fperez@colorado.edu>
717 2005-03-16 Fernando Perez <fperez@colorado.edu>
710
718
711 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
719 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
712 classic prompts to be '>>> ' (final space was missing, and it
720 classic prompts to be '>>> ' (final space was missing, and it
713 trips the emacs python mode).
721 trips the emacs python mode).
714 (BasePrompt.__str__): Added safe support for dynamic prompt
722 (BasePrompt.__str__): Added safe support for dynamic prompt
715 strings. Now you can set your prompt string to be '$x', and the
723 strings. Now you can set your prompt string to be '$x', and the
716 value of x will be printed from your interactive namespace. The
724 value of x will be printed from your interactive namespace. The
717 interpolation syntax includes the full Itpl support, so
725 interpolation syntax includes the full Itpl support, so
718 ${foo()+x+bar()} is a valid prompt string now, and the function
726 ${foo()+x+bar()} is a valid prompt string now, and the function
719 calls will be made at runtime.
727 calls will be made at runtime.
720
728
721 2005-03-15 Fernando Perez <fperez@colorado.edu>
729 2005-03-15 Fernando Perez <fperez@colorado.edu>
722
730
723 * IPython/Magic.py (magic_history): renamed %hist to %history, to
731 * IPython/Magic.py (magic_history): renamed %hist to %history, to
724 avoid name clashes in pylab. %hist still works, it just forwards
732 avoid name clashes in pylab. %hist still works, it just forwards
725 the call to %history.
733 the call to %history.
726
734
727 2005-03-02 *** Released version 0.6.12
735 2005-03-02 *** Released version 0.6.12
728
736
729 2005-03-02 Fernando Perez <fperez@colorado.edu>
737 2005-03-02 Fernando Perez <fperez@colorado.edu>
730
738
731 * IPython/iplib.py (handle_magic): log magic calls properly as
739 * IPython/iplib.py (handle_magic): log magic calls properly as
732 ipmagic() function calls.
740 ipmagic() function calls.
733
741
734 * IPython/Magic.py (magic_time): Improved %time to support
742 * IPython/Magic.py (magic_time): Improved %time to support
735 statements and provide wall-clock as well as CPU time.
743 statements and provide wall-clock as well as CPU time.
736
744
737 2005-02-27 Fernando Perez <fperez@colorado.edu>
745 2005-02-27 Fernando Perez <fperez@colorado.edu>
738
746
739 * IPython/hooks.py: New hooks module, to expose user-modifiable
747 * IPython/hooks.py: New hooks module, to expose user-modifiable
740 IPython functionality in a clean manner. For now only the editor
748 IPython functionality in a clean manner. For now only the editor
741 hook is actually written, and other thigns which I intend to turn
749 hook is actually written, and other thigns which I intend to turn
742 into proper hooks aren't yet there. The display and prefilter
750 into proper hooks aren't yet there. The display and prefilter
743 stuff, for example, should be hooks. But at least now the
751 stuff, for example, should be hooks. But at least now the
744 framework is in place, and the rest can be moved here with more
752 framework is in place, and the rest can be moved here with more
745 time later. IPython had had a .hooks variable for a long time for
753 time later. IPython had had a .hooks variable for a long time for
746 this purpose, but I'd never actually used it for anything.
754 this purpose, but I'd never actually used it for anything.
747
755
748 2005-02-26 Fernando Perez <fperez@colorado.edu>
756 2005-02-26 Fernando Perez <fperez@colorado.edu>
749
757
750 * IPython/ipmaker.py (make_IPython): make the default ipython
758 * IPython/ipmaker.py (make_IPython): make the default ipython
751 directory be called _ipython under win32, to follow more the
759 directory be called _ipython under win32, to follow more the
752 naming peculiarities of that platform (where buggy software like
760 naming peculiarities of that platform (where buggy software like
753 Visual Sourcesafe breaks with .named directories). Reported by
761 Visual Sourcesafe breaks with .named directories). Reported by
754 Ville Vainio.
762 Ville Vainio.
755
763
756 2005-02-23 Fernando Perez <fperez@colorado.edu>
764 2005-02-23 Fernando Perez <fperez@colorado.edu>
757
765
758 * IPython/iplib.py (InteractiveShell.__init__): removed a few
766 * IPython/iplib.py (InteractiveShell.__init__): removed a few
759 auto_aliases for win32 which were causing problems. Users can
767 auto_aliases for win32 which were causing problems. Users can
760 define the ones they personally like.
768 define the ones they personally like.
761
769
762 2005-02-21 Fernando Perez <fperez@colorado.edu>
770 2005-02-21 Fernando Perez <fperez@colorado.edu>
763
771
764 * IPython/Magic.py (magic_time): new magic to time execution of
772 * IPython/Magic.py (magic_time): new magic to time execution of
765 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
773 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
766
774
767 2005-02-19 Fernando Perez <fperez@colorado.edu>
775 2005-02-19 Fernando Perez <fperez@colorado.edu>
768
776
769 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
777 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
770 into keys (for prompts, for example).
778 into keys (for prompts, for example).
771
779
772 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
780 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
773 prompts in case users want them. This introduces a small behavior
781 prompts in case users want them. This introduces a small behavior
774 change: ipython does not automatically add a space to all prompts
782 change: ipython does not automatically add a space to all prompts
775 anymore. To get the old prompts with a space, users should add it
783 anymore. To get the old prompts with a space, users should add it
776 manually to their ipythonrc file, so for example prompt_in1 should
784 manually to their ipythonrc file, so for example prompt_in1 should
777 now read 'In [\#]: ' instead of 'In [\#]:'.
785 now read 'In [\#]: ' instead of 'In [\#]:'.
778 (BasePrompt.__init__): New option prompts_pad_left (only in rc
786 (BasePrompt.__init__): New option prompts_pad_left (only in rc
779 file) to control left-padding of secondary prompts.
787 file) to control left-padding of secondary prompts.
780
788
781 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
789 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
782 the profiler can't be imported. Fix for Debian, which removed
790 the profiler can't be imported. Fix for Debian, which removed
783 profile.py because of License issues. I applied a slightly
791 profile.py because of License issues. I applied a slightly
784 modified version of the original Debian patch at
792 modified version of the original Debian patch at
785 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
793 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
786
794
787 2005-02-17 Fernando Perez <fperez@colorado.edu>
795 2005-02-17 Fernando Perez <fperez@colorado.edu>
788
796
789 * IPython/genutils.py (native_line_ends): Fix bug which would
797 * IPython/genutils.py (native_line_ends): Fix bug which would
790 cause improper line-ends under win32 b/c I was not opening files
798 cause improper line-ends under win32 b/c I was not opening files
791 in binary mode. Bug report and fix thanks to Ville.
799 in binary mode. Bug report and fix thanks to Ville.
792
800
793 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
801 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
794 trying to catch spurious foo[1] autocalls. My fix actually broke
802 trying to catch spurious foo[1] autocalls. My fix actually broke
795 ',/' autoquote/call with explicit escape (bad regexp).
803 ',/' autoquote/call with explicit escape (bad regexp).
796
804
797 2005-02-15 *** Released version 0.6.11
805 2005-02-15 *** Released version 0.6.11
798
806
799 2005-02-14 Fernando Perez <fperez@colorado.edu>
807 2005-02-14 Fernando Perez <fperez@colorado.edu>
800
808
801 * IPython/background_jobs.py: New background job management
809 * IPython/background_jobs.py: New background job management
802 subsystem. This is implemented via a new set of classes, and
810 subsystem. This is implemented via a new set of classes, and
803 IPython now provides a builtin 'jobs' object for background job
811 IPython now provides a builtin 'jobs' object for background job
804 execution. A convenience %bg magic serves as a lightweight
812 execution. A convenience %bg magic serves as a lightweight
805 frontend for starting the more common type of calls. This was
813 frontend for starting the more common type of calls. This was
806 inspired by discussions with B. Granger and the BackgroundCommand
814 inspired by discussions with B. Granger and the BackgroundCommand
807 class described in the book Python Scripting for Computational
815 class described in the book Python Scripting for Computational
808 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
816 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
809 (although ultimately no code from this text was used, as IPython's
817 (although ultimately no code from this text was used, as IPython's
810 system is a separate implementation).
818 system is a separate implementation).
811
819
812 * IPython/iplib.py (MagicCompleter.python_matches): add new option
820 * IPython/iplib.py (MagicCompleter.python_matches): add new option
813 to control the completion of single/double underscore names
821 to control the completion of single/double underscore names
814 separately. As documented in the example ipytonrc file, the
822 separately. As documented in the example ipytonrc file, the
815 readline_omit__names variable can now be set to 2, to omit even
823 readline_omit__names variable can now be set to 2, to omit even
816 single underscore names. Thanks to a patch by Brian Wong
824 single underscore names. Thanks to a patch by Brian Wong
817 <BrianWong-AT-AirgoNetworks.Com>.
825 <BrianWong-AT-AirgoNetworks.Com>.
818 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
826 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
819 be autocalled as foo([1]) if foo were callable. A problem for
827 be autocalled as foo([1]) if foo were callable. A problem for
820 things which are both callable and implement __getitem__.
828 things which are both callable and implement __getitem__.
821 (init_readline): Fix autoindentation for win32. Thanks to a patch
829 (init_readline): Fix autoindentation for win32. Thanks to a patch
822 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
830 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
823
831
824 2005-02-12 Fernando Perez <fperez@colorado.edu>
832 2005-02-12 Fernando Perez <fperez@colorado.edu>
825
833
826 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
834 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
827 which I had written long ago to sort out user error messages which
835 which I had written long ago to sort out user error messages which
828 may occur during startup. This seemed like a good idea initially,
836 may occur during startup. This seemed like a good idea initially,
829 but it has proven a disaster in retrospect. I don't want to
837 but it has proven a disaster in retrospect. I don't want to
830 change much code for now, so my fix is to set the internal 'debug'
838 change much code for now, so my fix is to set the internal 'debug'
831 flag to true everywhere, whose only job was precisely to control
839 flag to true everywhere, whose only job was precisely to control
832 this subsystem. This closes issue 28 (as well as avoiding all
840 this subsystem. This closes issue 28 (as well as avoiding all
833 sorts of strange hangups which occur from time to time).
841 sorts of strange hangups which occur from time to time).
834
842
835 2005-02-07 Fernando Perez <fperez@colorado.edu>
843 2005-02-07 Fernando Perez <fperez@colorado.edu>
836
844
837 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
845 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
838 previous call produced a syntax error.
846 previous call produced a syntax error.
839
847
840 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
848 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
841 classes without constructor.
849 classes without constructor.
842
850
843 2005-02-06 Fernando Perez <fperez@colorado.edu>
851 2005-02-06 Fernando Perez <fperez@colorado.edu>
844
852
845 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
853 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
846 completions with the results of each matcher, so we return results
854 completions with the results of each matcher, so we return results
847 to the user from all namespaces. This breaks with ipython
855 to the user from all namespaces. This breaks with ipython
848 tradition, but I think it's a nicer behavior. Now you get all
856 tradition, but I think it's a nicer behavior. Now you get all
849 possible completions listed, from all possible namespaces (python,
857 possible completions listed, from all possible namespaces (python,
850 filesystem, magics...) After a request by John Hunter
858 filesystem, magics...) After a request by John Hunter
851 <jdhunter-AT-nitace.bsd.uchicago.edu>.
859 <jdhunter-AT-nitace.bsd.uchicago.edu>.
852
860
853 2005-02-05 Fernando Perez <fperez@colorado.edu>
861 2005-02-05 Fernando Perez <fperez@colorado.edu>
854
862
855 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
863 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
856 the call had quote characters in it (the quotes were stripped).
864 the call had quote characters in it (the quotes were stripped).
857
865
858 2005-01-31 Fernando Perez <fperez@colorado.edu>
866 2005-01-31 Fernando Perez <fperez@colorado.edu>
859
867
860 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
868 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
861 Itpl.itpl() to make the code more robust against psyco
869 Itpl.itpl() to make the code more robust against psyco
862 optimizations.
870 optimizations.
863
871
864 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
872 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
865 of causing an exception. Quicker, cleaner.
873 of causing an exception. Quicker, cleaner.
866
874
867 2005-01-28 Fernando Perez <fperez@colorado.edu>
875 2005-01-28 Fernando Perez <fperez@colorado.edu>
868
876
869 * scripts/ipython_win_post_install.py (install): hardcode
877 * scripts/ipython_win_post_install.py (install): hardcode
870 sys.prefix+'python.exe' as the executable path. It turns out that
878 sys.prefix+'python.exe' as the executable path. It turns out that
871 during the post-installation run, sys.executable resolves to the
879 during the post-installation run, sys.executable resolves to the
872 name of the binary installer! I should report this as a distutils
880 name of the binary installer! I should report this as a distutils
873 bug, I think. I updated the .10 release with this tiny fix, to
881 bug, I think. I updated the .10 release with this tiny fix, to
874 avoid annoying the lists further.
882 avoid annoying the lists further.
875
883
876 2005-01-27 *** Released version 0.6.10
884 2005-01-27 *** Released version 0.6.10
877
885
878 2005-01-27 Fernando Perez <fperez@colorado.edu>
886 2005-01-27 Fernando Perez <fperez@colorado.edu>
879
887
880 * IPython/numutils.py (norm): Added 'inf' as optional name for
888 * IPython/numutils.py (norm): Added 'inf' as optional name for
881 L-infinity norm, included references to mathworld.com for vector
889 L-infinity norm, included references to mathworld.com for vector
882 norm definitions.
890 norm definitions.
883 (amin/amax): added amin/amax for array min/max. Similar to what
891 (amin/amax): added amin/amax for array min/max. Similar to what
884 pylab ships with after the recent reorganization of names.
892 pylab ships with after the recent reorganization of names.
885 (spike/spike_odd): removed deprecated spike/spike_odd functions.
893 (spike/spike_odd): removed deprecated spike/spike_odd functions.
886
894
887 * ipython.el: committed Alex's recent fixes and improvements.
895 * ipython.el: committed Alex's recent fixes and improvements.
888 Tested with python-mode from CVS, and it looks excellent. Since
896 Tested with python-mode from CVS, and it looks excellent. Since
889 python-mode hasn't released anything in a while, I'm temporarily
897 python-mode hasn't released anything in a while, I'm temporarily
890 putting a copy of today's CVS (v 4.70) of python-mode in:
898 putting a copy of today's CVS (v 4.70) of python-mode in:
891 http://ipython.scipy.org/tmp/python-mode.el
899 http://ipython.scipy.org/tmp/python-mode.el
892
900
893 * scripts/ipython_win_post_install.py (install): Win32 fix to use
901 * scripts/ipython_win_post_install.py (install): Win32 fix to use
894 sys.executable for the executable name, instead of assuming it's
902 sys.executable for the executable name, instead of assuming it's
895 called 'python.exe' (the post-installer would have produced broken
903 called 'python.exe' (the post-installer would have produced broken
896 setups on systems with a differently named python binary).
904 setups on systems with a differently named python binary).
897
905
898 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
906 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
899 references to os.linesep, to make the code more
907 references to os.linesep, to make the code more
900 platform-independent. This is also part of the win32 coloring
908 platform-independent. This is also part of the win32 coloring
901 fixes.
909 fixes.
902
910
903 * IPython/genutils.py (page_dumb): Remove attempts to chop long
911 * IPython/genutils.py (page_dumb): Remove attempts to chop long
904 lines, which actually cause coloring bugs because the length of
912 lines, which actually cause coloring bugs because the length of
905 the line is very difficult to correctly compute with embedded
913 the line is very difficult to correctly compute with embedded
906 escapes. This was the source of all the coloring problems under
914 escapes. This was the source of all the coloring problems under
907 Win32. I think that _finally_, Win32 users have a properly
915 Win32. I think that _finally_, Win32 users have a properly
908 working ipython in all respects. This would never have happened
916 working ipython in all respects. This would never have happened
909 if not for Gary Bishop and Viktor Ransmayr's great help and work.
917 if not for Gary Bishop and Viktor Ransmayr's great help and work.
910
918
911 2005-01-26 *** Released version 0.6.9
919 2005-01-26 *** Released version 0.6.9
912
920
913 2005-01-25 Fernando Perez <fperez@colorado.edu>
921 2005-01-25 Fernando Perez <fperez@colorado.edu>
914
922
915 * setup.py: finally, we have a true Windows installer, thanks to
923 * setup.py: finally, we have a true Windows installer, thanks to
916 the excellent work of Viktor Ransmayr
924 the excellent work of Viktor Ransmayr
917 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
925 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
918 Windows users. The setup routine is quite a bit cleaner thanks to
926 Windows users. The setup routine is quite a bit cleaner thanks to
919 this, and the post-install script uses the proper functions to
927 this, and the post-install script uses the proper functions to
920 allow a clean de-installation using the standard Windows Control
928 allow a clean de-installation using the standard Windows Control
921 Panel.
929 Panel.
922
930
923 * IPython/genutils.py (get_home_dir): changed to use the $HOME
931 * IPython/genutils.py (get_home_dir): changed to use the $HOME
924 environment variable under all OSes (including win32) if
932 environment variable under all OSes (including win32) if
925 available. This will give consistency to win32 users who have set
933 available. This will give consistency to win32 users who have set
926 this variable for any reason. If os.environ['HOME'] fails, the
934 this variable for any reason. If os.environ['HOME'] fails, the
927 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
935 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
928
936
929 2005-01-24 Fernando Perez <fperez@colorado.edu>
937 2005-01-24 Fernando Perez <fperez@colorado.edu>
930
938
931 * IPython/numutils.py (empty_like): add empty_like(), similar to
939 * IPython/numutils.py (empty_like): add empty_like(), similar to
932 zeros_like() but taking advantage of the new empty() Numeric routine.
940 zeros_like() but taking advantage of the new empty() Numeric routine.
933
941
934 2005-01-23 *** Released version 0.6.8
942 2005-01-23 *** Released version 0.6.8
935
943
936 2005-01-22 Fernando Perez <fperez@colorado.edu>
944 2005-01-22 Fernando Perez <fperez@colorado.edu>
937
945
938 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
946 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
939 automatic show() calls. After discussing things with JDH, it
947 automatic show() calls. After discussing things with JDH, it
940 turns out there are too many corner cases where this can go wrong.
948 turns out there are too many corner cases where this can go wrong.
941 It's best not to try to be 'too smart', and simply have ipython
949 It's best not to try to be 'too smart', and simply have ipython
942 reproduce as much as possible the default behavior of a normal
950 reproduce as much as possible the default behavior of a normal
943 python shell.
951 python shell.
944
952
945 * IPython/iplib.py (InteractiveShell.__init__): Modified the
953 * IPython/iplib.py (InteractiveShell.__init__): Modified the
946 line-splitting regexp and _prefilter() to avoid calling getattr()
954 line-splitting regexp and _prefilter() to avoid calling getattr()
947 on assignments. This closes
955 on assignments. This closes
948 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
956 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
949 readline uses getattr(), so a simple <TAB> keypress is still
957 readline uses getattr(), so a simple <TAB> keypress is still
950 enough to trigger getattr() calls on an object.
958 enough to trigger getattr() calls on an object.
951
959
952 2005-01-21 Fernando Perez <fperez@colorado.edu>
960 2005-01-21 Fernando Perez <fperez@colorado.edu>
953
961
954 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
962 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
955 docstring under pylab so it doesn't mask the original.
963 docstring under pylab so it doesn't mask the original.
956
964
957 2005-01-21 *** Released version 0.6.7
965 2005-01-21 *** Released version 0.6.7
958
966
959 2005-01-21 Fernando Perez <fperez@colorado.edu>
967 2005-01-21 Fernando Perez <fperez@colorado.edu>
960
968
961 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
969 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
962 signal handling for win32 users in multithreaded mode.
970 signal handling for win32 users in multithreaded mode.
963
971
964 2005-01-17 Fernando Perez <fperez@colorado.edu>
972 2005-01-17 Fernando Perez <fperez@colorado.edu>
965
973
966 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
974 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
967 instances with no __init__. After a crash report by Norbert Nemec
975 instances with no __init__. After a crash report by Norbert Nemec
968 <Norbert-AT-nemec-online.de>.
976 <Norbert-AT-nemec-online.de>.
969
977
970 2005-01-14 Fernando Perez <fperez@colorado.edu>
978 2005-01-14 Fernando Perez <fperez@colorado.edu>
971
979
972 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
980 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
973 names for verbose exceptions, when multiple dotted names and the
981 names for verbose exceptions, when multiple dotted names and the
974 'parent' object were present on the same line.
982 'parent' object were present on the same line.
975
983
976 2005-01-11 Fernando Perez <fperez@colorado.edu>
984 2005-01-11 Fernando Perez <fperez@colorado.edu>
977
985
978 * IPython/genutils.py (flag_calls): new utility to trap and flag
986 * IPython/genutils.py (flag_calls): new utility to trap and flag
979 calls in functions. I need it to clean up matplotlib support.
987 calls in functions. I need it to clean up matplotlib support.
980 Also removed some deprecated code in genutils.
988 Also removed some deprecated code in genutils.
981
989
982 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
990 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
983 that matplotlib scripts called with %run, which don't call show()
991 that matplotlib scripts called with %run, which don't call show()
984 themselves, still have their plotting windows open.
992 themselves, still have their plotting windows open.
985
993
986 2005-01-05 Fernando Perez <fperez@colorado.edu>
994 2005-01-05 Fernando Perez <fperez@colorado.edu>
987
995
988 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
996 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
989 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
997 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
990
998
991 2004-12-19 Fernando Perez <fperez@colorado.edu>
999 2004-12-19 Fernando Perez <fperez@colorado.edu>
992
1000
993 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
1001 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
994 parent_runcode, which was an eyesore. The same result can be
1002 parent_runcode, which was an eyesore. The same result can be
995 obtained with Python's regular superclass mechanisms.
1003 obtained with Python's regular superclass mechanisms.
996
1004
997 2004-12-17 Fernando Perez <fperez@colorado.edu>
1005 2004-12-17 Fernando Perez <fperez@colorado.edu>
998
1006
999 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
1007 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
1000 reported by Prabhu.
1008 reported by Prabhu.
1001 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
1009 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
1002 sys.stderr) instead of explicitly calling sys.stderr. This helps
1010 sys.stderr) instead of explicitly calling sys.stderr. This helps
1003 maintain our I/O abstractions clean, for future GUI embeddings.
1011 maintain our I/O abstractions clean, for future GUI embeddings.
1004
1012
1005 * IPython/genutils.py (info): added new utility for sys.stderr
1013 * IPython/genutils.py (info): added new utility for sys.stderr
1006 unified info message handling (thin wrapper around warn()).
1014 unified info message handling (thin wrapper around warn()).
1007
1015
1008 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
1016 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
1009 composite (dotted) names on verbose exceptions.
1017 composite (dotted) names on verbose exceptions.
1010 (VerboseTB.nullrepr): harden against another kind of errors which
1018 (VerboseTB.nullrepr): harden against another kind of errors which
1011 Python's inspect module can trigger, and which were crashing
1019 Python's inspect module can trigger, and which were crashing
1012 IPython. Thanks to a report by Marco Lombardi
1020 IPython. Thanks to a report by Marco Lombardi
1013 <mlombard-AT-ma010192.hq.eso.org>.
1021 <mlombard-AT-ma010192.hq.eso.org>.
1014
1022
1015 2004-12-13 *** Released version 0.6.6
1023 2004-12-13 *** Released version 0.6.6
1016
1024
1017 2004-12-12 Fernando Perez <fperez@colorado.edu>
1025 2004-12-12 Fernando Perez <fperez@colorado.edu>
1018
1026
1019 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
1027 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
1020 generated by pygtk upon initialization if it was built without
1028 generated by pygtk upon initialization if it was built without
1021 threads (for matplotlib users). After a crash reported by
1029 threads (for matplotlib users). After a crash reported by
1022 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
1030 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
1023
1031
1024 * IPython/ipmaker.py (make_IPython): fix small bug in the
1032 * IPython/ipmaker.py (make_IPython): fix small bug in the
1025 import_some parameter for multiple imports.
1033 import_some parameter for multiple imports.
1026
1034
1027 * IPython/iplib.py (ipmagic): simplified the interface of
1035 * IPython/iplib.py (ipmagic): simplified the interface of
1028 ipmagic() to take a single string argument, just as it would be
1036 ipmagic() to take a single string argument, just as it would be
1029 typed at the IPython cmd line.
1037 typed at the IPython cmd line.
1030 (ipalias): Added new ipalias() with an interface identical to
1038 (ipalias): Added new ipalias() with an interface identical to
1031 ipmagic(). This completes exposing a pure python interface to the
1039 ipmagic(). This completes exposing a pure python interface to the
1032 alias and magic system, which can be used in loops or more complex
1040 alias and magic system, which can be used in loops or more complex
1033 code where IPython's automatic line mangling is not active.
1041 code where IPython's automatic line mangling is not active.
1034
1042
1035 * IPython/genutils.py (timing): changed interface of timing to
1043 * IPython/genutils.py (timing): changed interface of timing to
1036 simply run code once, which is the most common case. timings()
1044 simply run code once, which is the most common case. timings()
1037 remains unchanged, for the cases where you want multiple runs.
1045 remains unchanged, for the cases where you want multiple runs.
1038
1046
1039 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
1047 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
1040 bug where Python2.2 crashes with exec'ing code which does not end
1048 bug where Python2.2 crashes with exec'ing code which does not end
1041 in a single newline. Python 2.3 is OK, so I hadn't noticed this
1049 in a single newline. Python 2.3 is OK, so I hadn't noticed this
1042 before.
1050 before.
1043
1051
1044 2004-12-10 Fernando Perez <fperez@colorado.edu>
1052 2004-12-10 Fernando Perez <fperez@colorado.edu>
1045
1053
1046 * IPython/Magic.py (Magic.magic_prun): changed name of option from
1054 * IPython/Magic.py (Magic.magic_prun): changed name of option from
1047 -t to -T, to accomodate the new -t flag in %run (the %run and
1055 -t to -T, to accomodate the new -t flag in %run (the %run and
1048 %prun options are kind of intermixed, and it's not easy to change
1056 %prun options are kind of intermixed, and it's not easy to change
1049 this with the limitations of python's getopt).
1057 this with the limitations of python's getopt).
1050
1058
1051 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
1059 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
1052 the execution of scripts. It's not as fine-tuned as timeit.py,
1060 the execution of scripts. It's not as fine-tuned as timeit.py,
1053 but it works from inside ipython (and under 2.2, which lacks
1061 but it works from inside ipython (and under 2.2, which lacks
1054 timeit.py). Optionally a number of runs > 1 can be given for
1062 timeit.py). Optionally a number of runs > 1 can be given for
1055 timing very short-running code.
1063 timing very short-running code.
1056
1064
1057 * IPython/genutils.py (uniq_stable): new routine which returns a
1065 * IPython/genutils.py (uniq_stable): new routine which returns a
1058 list of unique elements in any iterable, but in stable order of
1066 list of unique elements in any iterable, but in stable order of
1059 appearance. I needed this for the ultraTB fixes, and it's a handy
1067 appearance. I needed this for the ultraTB fixes, and it's a handy
1060 utility.
1068 utility.
1061
1069
1062 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
1070 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
1063 dotted names in Verbose exceptions. This had been broken since
1071 dotted names in Verbose exceptions. This had been broken since
1064 the very start, now x.y will properly be printed in a Verbose
1072 the very start, now x.y will properly be printed in a Verbose
1065 traceback, instead of x being shown and y appearing always as an
1073 traceback, instead of x being shown and y appearing always as an
1066 'undefined global'. Getting this to work was a bit tricky,
1074 'undefined global'. Getting this to work was a bit tricky,
1067 because by default python tokenizers are stateless. Saved by
1075 because by default python tokenizers are stateless. Saved by
1068 python's ability to easily add a bit of state to an arbitrary
1076 python's ability to easily add a bit of state to an arbitrary
1069 function (without needing to build a full-blown callable object).
1077 function (without needing to build a full-blown callable object).
1070
1078
1071 Also big cleanup of this code, which had horrendous runtime
1079 Also big cleanup of this code, which had horrendous runtime
1072 lookups of zillions of attributes for colorization. Moved all
1080 lookups of zillions of attributes for colorization. Moved all
1073 this code into a few templates, which make it cleaner and quicker.
1081 this code into a few templates, which make it cleaner and quicker.
1074
1082
1075 Printout quality was also improved for Verbose exceptions: one
1083 Printout quality was also improved for Verbose exceptions: one
1076 variable per line, and memory addresses are printed (this can be
1084 variable per line, and memory addresses are printed (this can be
1077 quite handy in nasty debugging situations, which is what Verbose
1085 quite handy in nasty debugging situations, which is what Verbose
1078 is for).
1086 is for).
1079
1087
1080 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
1088 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
1081 the command line as scripts to be loaded by embedded instances.
1089 the command line as scripts to be loaded by embedded instances.
1082 Doing so has the potential for an infinite recursion if there are
1090 Doing so has the potential for an infinite recursion if there are
1083 exceptions thrown in the process. This fixes a strange crash
1091 exceptions thrown in the process. This fixes a strange crash
1084 reported by Philippe MULLER <muller-AT-irit.fr>.
1092 reported by Philippe MULLER <muller-AT-irit.fr>.
1085
1093
1086 2004-12-09 Fernando Perez <fperez@colorado.edu>
1094 2004-12-09 Fernando Perez <fperez@colorado.edu>
1087
1095
1088 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
1096 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
1089 to reflect new names in matplotlib, which now expose the
1097 to reflect new names in matplotlib, which now expose the
1090 matlab-compatible interface via a pylab module instead of the
1098 matlab-compatible interface via a pylab module instead of the
1091 'matlab' name. The new code is backwards compatible, so users of
1099 'matlab' name. The new code is backwards compatible, so users of
1092 all matplotlib versions are OK. Patch by J. Hunter.
1100 all matplotlib versions are OK. Patch by J. Hunter.
1093
1101
1094 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
1102 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
1095 of __init__ docstrings for instances (class docstrings are already
1103 of __init__ docstrings for instances (class docstrings are already
1096 automatically printed). Instances with customized docstrings
1104 automatically printed). Instances with customized docstrings
1097 (indep. of the class) are also recognized and all 3 separate
1105 (indep. of the class) are also recognized and all 3 separate
1098 docstrings are printed (instance, class, constructor). After some
1106 docstrings are printed (instance, class, constructor). After some
1099 comments/suggestions by J. Hunter.
1107 comments/suggestions by J. Hunter.
1100
1108
1101 2004-12-05 Fernando Perez <fperez@colorado.edu>
1109 2004-12-05 Fernando Perez <fperez@colorado.edu>
1102
1110
1103 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
1111 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
1104 warnings when tab-completion fails and triggers an exception.
1112 warnings when tab-completion fails and triggers an exception.
1105
1113
1106 2004-12-03 Fernando Perez <fperez@colorado.edu>
1114 2004-12-03 Fernando Perez <fperez@colorado.edu>
1107
1115
1108 * IPython/Magic.py (magic_prun): Fix bug where an exception would
1116 * IPython/Magic.py (magic_prun): Fix bug where an exception would
1109 be triggered when using 'run -p'. An incorrect option flag was
1117 be triggered when using 'run -p'. An incorrect option flag was
1110 being set ('d' instead of 'D').
1118 being set ('d' instead of 'D').
1111 (manpage): fix missing escaped \- sign.
1119 (manpage): fix missing escaped \- sign.
1112
1120
1113 2004-11-30 *** Released version 0.6.5
1121 2004-11-30 *** Released version 0.6.5
1114
1122
1115 2004-11-30 Fernando Perez <fperez@colorado.edu>
1123 2004-11-30 Fernando Perez <fperez@colorado.edu>
1116
1124
1117 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1125 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
1118 setting with -d option.
1126 setting with -d option.
1119
1127
1120 * setup.py (docfiles): Fix problem where the doc glob I was using
1128 * setup.py (docfiles): Fix problem where the doc glob I was using
1121 was COMPLETELY BROKEN. It was giving the right files by pure
1129 was COMPLETELY BROKEN. It was giving the right files by pure
1122 accident, but failed once I tried to include ipython.el. Note:
1130 accident, but failed once I tried to include ipython.el. Note:
1123 glob() does NOT allow you to do exclusion on multiple endings!
1131 glob() does NOT allow you to do exclusion on multiple endings!
1124
1132
1125 2004-11-29 Fernando Perez <fperez@colorado.edu>
1133 2004-11-29 Fernando Perez <fperez@colorado.edu>
1126
1134
1127 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1135 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
1128 the manpage as the source. Better formatting & consistency.
1136 the manpage as the source. Better formatting & consistency.
1129
1137
1130 * IPython/Magic.py (magic_run): Added new -d option, to run
1138 * IPython/Magic.py (magic_run): Added new -d option, to run
1131 scripts under the control of the python pdb debugger. Note that
1139 scripts under the control of the python pdb debugger. Note that
1132 this required changing the %prun option -d to -D, to avoid a clash
1140 this required changing the %prun option -d to -D, to avoid a clash
1133 (since %run must pass options to %prun, and getopt is too dumb to
1141 (since %run must pass options to %prun, and getopt is too dumb to
1134 handle options with string values with embedded spaces). Thanks
1142 handle options with string values with embedded spaces). Thanks
1135 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1143 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
1136 (magic_who_ls): added type matching to %who and %whos, so that one
1144 (magic_who_ls): added type matching to %who and %whos, so that one
1137 can filter their output to only include variables of certain
1145 can filter their output to only include variables of certain
1138 types. Another suggestion by Matthew.
1146 types. Another suggestion by Matthew.
1139 (magic_whos): Added memory summaries in kb and Mb for arrays.
1147 (magic_whos): Added memory summaries in kb and Mb for arrays.
1140 (magic_who): Improve formatting (break lines every 9 vars).
1148 (magic_who): Improve formatting (break lines every 9 vars).
1141
1149
1142 2004-11-28 Fernando Perez <fperez@colorado.edu>
1150 2004-11-28 Fernando Perez <fperez@colorado.edu>
1143
1151
1144 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1152 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
1145 cache when empty lines were present.
1153 cache when empty lines were present.
1146
1154
1147 2004-11-24 Fernando Perez <fperez@colorado.edu>
1155 2004-11-24 Fernando Perez <fperez@colorado.edu>
1148
1156
1149 * IPython/usage.py (__doc__): document the re-activated threading
1157 * IPython/usage.py (__doc__): document the re-activated threading
1150 options for WX and GTK.
1158 options for WX and GTK.
1151
1159
1152 2004-11-23 Fernando Perez <fperez@colorado.edu>
1160 2004-11-23 Fernando Perez <fperez@colorado.edu>
1153
1161
1154 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1162 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
1155 the -wthread and -gthread options, along with a new -tk one to try
1163 the -wthread and -gthread options, along with a new -tk one to try
1156 and coordinate Tk threading with wx/gtk. The tk support is very
1164 and coordinate Tk threading with wx/gtk. The tk support is very
1157 platform dependent, since it seems to require Tcl and Tk to be
1165 platform dependent, since it seems to require Tcl and Tk to be
1158 built with threads (Fedora1/2 appears NOT to have it, but in
1166 built with threads (Fedora1/2 appears NOT to have it, but in
1159 Prabhu's Debian boxes it works OK). But even with some Tk
1167 Prabhu's Debian boxes it works OK). But even with some Tk
1160 limitations, this is a great improvement.
1168 limitations, this is a great improvement.
1161
1169
1162 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1170 * IPython/Prompts.py (prompt_specials_color): Added \t for time
1163 info in user prompts. Patch by Prabhu.
1171 info in user prompts. Patch by Prabhu.
1164
1172
1165 2004-11-18 Fernando Perez <fperez@colorado.edu>
1173 2004-11-18 Fernando Perez <fperez@colorado.edu>
1166
1174
1167 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1175 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
1168 EOFErrors and bail, to avoid infinite loops if a non-terminating
1176 EOFErrors and bail, to avoid infinite loops if a non-terminating
1169 file is fed into ipython. Patch submitted in issue 19 by user,
1177 file is fed into ipython. Patch submitted in issue 19 by user,
1170 many thanks.
1178 many thanks.
1171
1179
1172 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1180 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
1173 autoquote/parens in continuation prompts, which can cause lots of
1181 autoquote/parens in continuation prompts, which can cause lots of
1174 problems. Closes roundup issue 20.
1182 problems. Closes roundup issue 20.
1175
1183
1176 2004-11-17 Fernando Perez <fperez@colorado.edu>
1184 2004-11-17 Fernando Perez <fperez@colorado.edu>
1177
1185
1178 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1186 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
1179 reported as debian bug #280505. I'm not sure my local changelog
1187 reported as debian bug #280505. I'm not sure my local changelog
1180 entry has the proper debian format (Jack?).
1188 entry has the proper debian format (Jack?).
1181
1189
1182 2004-11-08 *** Released version 0.6.4
1190 2004-11-08 *** Released version 0.6.4
1183
1191
1184 2004-11-08 Fernando Perez <fperez@colorado.edu>
1192 2004-11-08 Fernando Perez <fperez@colorado.edu>
1185
1193
1186 * IPython/iplib.py (init_readline): Fix exit message for Windows
1194 * IPython/iplib.py (init_readline): Fix exit message for Windows
1187 when readline is active. Thanks to a report by Eric Jones
1195 when readline is active. Thanks to a report by Eric Jones
1188 <eric-AT-enthought.com>.
1196 <eric-AT-enthought.com>.
1189
1197
1190 2004-11-07 Fernando Perez <fperez@colorado.edu>
1198 2004-11-07 Fernando Perez <fperez@colorado.edu>
1191
1199
1192 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1200 * IPython/genutils.py (page): Add a trap for OSError exceptions,
1193 sometimes seen by win2k/cygwin users.
1201 sometimes seen by win2k/cygwin users.
1194
1202
1195 2004-11-06 Fernando Perez <fperez@colorado.edu>
1203 2004-11-06 Fernando Perez <fperez@colorado.edu>
1196
1204
1197 * IPython/iplib.py (interact): Change the handling of %Exit from
1205 * IPython/iplib.py (interact): Change the handling of %Exit from
1198 trying to propagate a SystemExit to an internal ipython flag.
1206 trying to propagate a SystemExit to an internal ipython flag.
1199 This is less elegant than using Python's exception mechanism, but
1207 This is less elegant than using Python's exception mechanism, but
1200 I can't get that to work reliably with threads, so under -pylab
1208 I can't get that to work reliably with threads, so under -pylab
1201 %Exit was hanging IPython. Cross-thread exception handling is
1209 %Exit was hanging IPython. Cross-thread exception handling is
1202 really a bitch. Thaks to a bug report by Stephen Walton
1210 really a bitch. Thaks to a bug report by Stephen Walton
1203 <stephen.walton-AT-csun.edu>.
1211 <stephen.walton-AT-csun.edu>.
1204
1212
1205 2004-11-04 Fernando Perez <fperez@colorado.edu>
1213 2004-11-04 Fernando Perez <fperez@colorado.edu>
1206
1214
1207 * IPython/iplib.py (raw_input_original): store a pointer to the
1215 * IPython/iplib.py (raw_input_original): store a pointer to the
1208 true raw_input to harden against code which can modify it
1216 true raw_input to harden against code which can modify it
1209 (wx.py.PyShell does this and would otherwise crash ipython).
1217 (wx.py.PyShell does this and would otherwise crash ipython).
1210 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1218 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
1211
1219
1212 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1220 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
1213 Ctrl-C problem, which does not mess up the input line.
1221 Ctrl-C problem, which does not mess up the input line.
1214
1222
1215 2004-11-03 Fernando Perez <fperez@colorado.edu>
1223 2004-11-03 Fernando Perez <fperez@colorado.edu>
1216
1224
1217 * IPython/Release.py: Changed licensing to BSD, in all files.
1225 * IPython/Release.py: Changed licensing to BSD, in all files.
1218 (name): lowercase name for tarball/RPM release.
1226 (name): lowercase name for tarball/RPM release.
1219
1227
1220 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1228 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
1221 use throughout ipython.
1229 use throughout ipython.
1222
1230
1223 * IPython/Magic.py (Magic._ofind): Switch to using the new
1231 * IPython/Magic.py (Magic._ofind): Switch to using the new
1224 OInspect.getdoc() function.
1232 OInspect.getdoc() function.
1225
1233
1226 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1234 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
1227 of the line currently being canceled via Ctrl-C. It's extremely
1235 of the line currently being canceled via Ctrl-C. It's extremely
1228 ugly, but I don't know how to do it better (the problem is one of
1236 ugly, but I don't know how to do it better (the problem is one of
1229 handling cross-thread exceptions).
1237 handling cross-thread exceptions).
1230
1238
1231 2004-10-28 Fernando Perez <fperez@colorado.edu>
1239 2004-10-28 Fernando Perez <fperez@colorado.edu>
1232
1240
1233 * IPython/Shell.py (signal_handler): add signal handlers to trap
1241 * IPython/Shell.py (signal_handler): add signal handlers to trap
1234 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1242 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
1235 report by Francesc Alted.
1243 report by Francesc Alted.
1236
1244
1237 2004-10-21 Fernando Perez <fperez@colorado.edu>
1245 2004-10-21 Fernando Perez <fperez@colorado.edu>
1238
1246
1239 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1247 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
1240 to % for pysh syntax extensions.
1248 to % for pysh syntax extensions.
1241
1249
1242 2004-10-09 Fernando Perez <fperez@colorado.edu>
1250 2004-10-09 Fernando Perez <fperez@colorado.edu>
1243
1251
1244 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1252 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
1245 arrays to print a more useful summary, without calling str(arr).
1253 arrays to print a more useful summary, without calling str(arr).
1246 This avoids the problem of extremely lengthy computations which
1254 This avoids the problem of extremely lengthy computations which
1247 occur if arr is large, and appear to the user as a system lockup
1255 occur if arr is large, and appear to the user as a system lockup
1248 with 100% cpu activity. After a suggestion by Kristian Sandberg
1256 with 100% cpu activity. After a suggestion by Kristian Sandberg
1249 <Kristian.Sandberg@colorado.edu>.
1257 <Kristian.Sandberg@colorado.edu>.
1250 (Magic.__init__): fix bug in global magic escapes not being
1258 (Magic.__init__): fix bug in global magic escapes not being
1251 correctly set.
1259 correctly set.
1252
1260
1253 2004-10-08 Fernando Perez <fperez@colorado.edu>
1261 2004-10-08 Fernando Perez <fperez@colorado.edu>
1254
1262
1255 * IPython/Magic.py (__license__): change to absolute imports of
1263 * IPython/Magic.py (__license__): change to absolute imports of
1256 ipython's own internal packages, to start adapting to the absolute
1264 ipython's own internal packages, to start adapting to the absolute
1257 import requirement of PEP-328.
1265 import requirement of PEP-328.
1258
1266
1259 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1267 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
1260 files, and standardize author/license marks through the Release
1268 files, and standardize author/license marks through the Release
1261 module instead of having per/file stuff (except for files with
1269 module instead of having per/file stuff (except for files with
1262 particular licenses, like the MIT/PSF-licensed codes).
1270 particular licenses, like the MIT/PSF-licensed codes).
1263
1271
1264 * IPython/Debugger.py: remove dead code for python 2.1
1272 * IPython/Debugger.py: remove dead code for python 2.1
1265
1273
1266 2004-10-04 Fernando Perez <fperez@colorado.edu>
1274 2004-10-04 Fernando Perez <fperez@colorado.edu>
1267
1275
1268 * IPython/iplib.py (ipmagic): New function for accessing magics
1276 * IPython/iplib.py (ipmagic): New function for accessing magics
1269 via a normal python function call.
1277 via a normal python function call.
1270
1278
1271 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1279 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
1272 from '@' to '%', to accomodate the new @decorator syntax of python
1280 from '@' to '%', to accomodate the new @decorator syntax of python
1273 2.4.
1281 2.4.
1274
1282
1275 2004-09-29 Fernando Perez <fperez@colorado.edu>
1283 2004-09-29 Fernando Perez <fperez@colorado.edu>
1276
1284
1277 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1285 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
1278 matplotlib.use to prevent running scripts which try to switch
1286 matplotlib.use to prevent running scripts which try to switch
1279 interactive backends from within ipython. This will just crash
1287 interactive backends from within ipython. This will just crash
1280 the python interpreter, so we can't allow it (but a detailed error
1288 the python interpreter, so we can't allow it (but a detailed error
1281 is given to the user).
1289 is given to the user).
1282
1290
1283 2004-09-28 Fernando Perez <fperez@colorado.edu>
1291 2004-09-28 Fernando Perez <fperez@colorado.edu>
1284
1292
1285 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1293 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
1286 matplotlib-related fixes so that using @run with non-matplotlib
1294 matplotlib-related fixes so that using @run with non-matplotlib
1287 scripts doesn't pop up spurious plot windows. This requires
1295 scripts doesn't pop up spurious plot windows. This requires
1288 matplotlib >= 0.63, where I had to make some changes as well.
1296 matplotlib >= 0.63, where I had to make some changes as well.
1289
1297
1290 * IPython/ipmaker.py (make_IPython): update version requirement to
1298 * IPython/ipmaker.py (make_IPython): update version requirement to
1291 python 2.2.
1299 python 2.2.
1292
1300
1293 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1301 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
1294 banner arg for embedded customization.
1302 banner arg for embedded customization.
1295
1303
1296 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1304 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
1297 explicit uses of __IP as the IPython's instance name. Now things
1305 explicit uses of __IP as the IPython's instance name. Now things
1298 are properly handled via the shell.name value. The actual code
1306 are properly handled via the shell.name value. The actual code
1299 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1307 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
1300 is much better than before. I'll clean things completely when the
1308 is much better than before. I'll clean things completely when the
1301 magic stuff gets a real overhaul.
1309 magic stuff gets a real overhaul.
1302
1310
1303 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1311 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
1304 minor changes to debian dir.
1312 minor changes to debian dir.
1305
1313
1306 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1314 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
1307 pointer to the shell itself in the interactive namespace even when
1315 pointer to the shell itself in the interactive namespace even when
1308 a user-supplied dict is provided. This is needed for embedding
1316 a user-supplied dict is provided. This is needed for embedding
1309 purposes (found by tests with Michel Sanner).
1317 purposes (found by tests with Michel Sanner).
1310
1318
1311 2004-09-27 Fernando Perez <fperez@colorado.edu>
1319 2004-09-27 Fernando Perez <fperez@colorado.edu>
1312
1320
1313 * IPython/UserConfig/ipythonrc: remove []{} from
1321 * IPython/UserConfig/ipythonrc: remove []{} from
1314 readline_remove_delims, so that things like [modname.<TAB> do
1322 readline_remove_delims, so that things like [modname.<TAB> do
1315 proper completion. This disables [].TAB, but that's a less common
1323 proper completion. This disables [].TAB, but that's a less common
1316 case than module names in list comprehensions, for example.
1324 case than module names in list comprehensions, for example.
1317 Thanks to a report by Andrea Riciputi.
1325 Thanks to a report by Andrea Riciputi.
1318
1326
1319 2004-09-09 Fernando Perez <fperez@colorado.edu>
1327 2004-09-09 Fernando Perez <fperez@colorado.edu>
1320
1328
1321 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1329 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
1322 blocking problems in win32 and osx. Fix by John.
1330 blocking problems in win32 and osx. Fix by John.
1323
1331
1324 2004-09-08 Fernando Perez <fperez@colorado.edu>
1332 2004-09-08 Fernando Perez <fperez@colorado.edu>
1325
1333
1326 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1334 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
1327 for Win32 and OSX. Fix by John Hunter.
1335 for Win32 and OSX. Fix by John Hunter.
1328
1336
1329 2004-08-30 *** Released version 0.6.3
1337 2004-08-30 *** Released version 0.6.3
1330
1338
1331 2004-08-30 Fernando Perez <fperez@colorado.edu>
1339 2004-08-30 Fernando Perez <fperez@colorado.edu>
1332
1340
1333 * setup.py (isfile): Add manpages to list of dependent files to be
1341 * setup.py (isfile): Add manpages to list of dependent files to be
1334 updated.
1342 updated.
1335
1343
1336 2004-08-27 Fernando Perez <fperez@colorado.edu>
1344 2004-08-27 Fernando Perez <fperez@colorado.edu>
1337
1345
1338 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1346 * IPython/Shell.py (start): I've disabled -wthread and -gthread
1339 for now. They don't really work with standalone WX/GTK code
1347 for now. They don't really work with standalone WX/GTK code
1340 (though matplotlib IS working fine with both of those backends).
1348 (though matplotlib IS working fine with both of those backends).
1341 This will neeed much more testing. I disabled most things with
1349 This will neeed much more testing. I disabled most things with
1342 comments, so turning it back on later should be pretty easy.
1350 comments, so turning it back on later should be pretty easy.
1343
1351
1344 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1352 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
1345 autocalling of expressions like r'foo', by modifying the line
1353 autocalling of expressions like r'foo', by modifying the line
1346 split regexp. Closes
1354 split regexp. Closes
1347 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1355 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
1348 Riley <ipythonbugs-AT-sabi.net>.
1356 Riley <ipythonbugs-AT-sabi.net>.
1349 (InteractiveShell.mainloop): honor --nobanner with banner
1357 (InteractiveShell.mainloop): honor --nobanner with banner
1350 extensions.
1358 extensions.
1351
1359
1352 * IPython/Shell.py: Significant refactoring of all classes, so
1360 * IPython/Shell.py: Significant refactoring of all classes, so
1353 that we can really support ALL matplotlib backends and threading
1361 that we can really support ALL matplotlib backends and threading
1354 models (John spotted a bug with Tk which required this). Now we
1362 models (John spotted a bug with Tk which required this). Now we
1355 should support single-threaded, WX-threads and GTK-threads, both
1363 should support single-threaded, WX-threads and GTK-threads, both
1356 for generic code and for matplotlib.
1364 for generic code and for matplotlib.
1357
1365
1358 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1366 * IPython/ipmaker.py (__call__): Changed -mpthread option to
1359 -pylab, to simplify things for users. Will also remove the pylab
1367 -pylab, to simplify things for users. Will also remove the pylab
1360 profile, since now all of matplotlib configuration is directly
1368 profile, since now all of matplotlib configuration is directly
1361 handled here. This also reduces startup time.
1369 handled here. This also reduces startup time.
1362
1370
1363 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1371 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
1364 shell wasn't being correctly called. Also in IPShellWX.
1372 shell wasn't being correctly called. Also in IPShellWX.
1365
1373
1366 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1374 * IPython/iplib.py (InteractiveShell.__init__): Added option to
1367 fine-tune banner.
1375 fine-tune banner.
1368
1376
1369 * IPython/numutils.py (spike): Deprecate these spike functions,
1377 * IPython/numutils.py (spike): Deprecate these spike functions,
1370 delete (long deprecated) gnuplot_exec handler.
1378 delete (long deprecated) gnuplot_exec handler.
1371
1379
1372 2004-08-26 Fernando Perez <fperez@colorado.edu>
1380 2004-08-26 Fernando Perez <fperez@colorado.edu>
1373
1381
1374 * ipython.1: Update for threading options, plus some others which
1382 * ipython.1: Update for threading options, plus some others which
1375 were missing.
1383 were missing.
1376
1384
1377 * IPython/ipmaker.py (__call__): Added -wthread option for
1385 * IPython/ipmaker.py (__call__): Added -wthread option for
1378 wxpython thread handling. Make sure threading options are only
1386 wxpython thread handling. Make sure threading options are only
1379 valid at the command line.
1387 valid at the command line.
1380
1388
1381 * scripts/ipython: moved shell selection into a factory function
1389 * scripts/ipython: moved shell selection into a factory function
1382 in Shell.py, to keep the starter script to a minimum.
1390 in Shell.py, to keep the starter script to a minimum.
1383
1391
1384 2004-08-25 Fernando Perez <fperez@colorado.edu>
1392 2004-08-25 Fernando Perez <fperez@colorado.edu>
1385
1393
1386 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1394 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
1387 John. Along with some recent changes he made to matplotlib, the
1395 John. Along with some recent changes he made to matplotlib, the
1388 next versions of both systems should work very well together.
1396 next versions of both systems should work very well together.
1389
1397
1390 2004-08-24 Fernando Perez <fperez@colorado.edu>
1398 2004-08-24 Fernando Perez <fperez@colorado.edu>
1391
1399
1392 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1400 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
1393 tried to switch the profiling to using hotshot, but I'm getting
1401 tried to switch the profiling to using hotshot, but I'm getting
1394 strange errors from prof.runctx() there. I may be misreading the
1402 strange errors from prof.runctx() there. I may be misreading the
1395 docs, but it looks weird. For now the profiling code will
1403 docs, but it looks weird. For now the profiling code will
1396 continue to use the standard profiler.
1404 continue to use the standard profiler.
1397
1405
1398 2004-08-23 Fernando Perez <fperez@colorado.edu>
1406 2004-08-23 Fernando Perez <fperez@colorado.edu>
1399
1407
1400 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1408 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
1401 threaded shell, by John Hunter. It's not quite ready yet, but
1409 threaded shell, by John Hunter. It's not quite ready yet, but
1402 close.
1410 close.
1403
1411
1404 2004-08-22 Fernando Perez <fperez@colorado.edu>
1412 2004-08-22 Fernando Perez <fperez@colorado.edu>
1405
1413
1406 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1414 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
1407 in Magic and ultraTB.
1415 in Magic and ultraTB.
1408
1416
1409 * ipython.1: document threading options in manpage.
1417 * ipython.1: document threading options in manpage.
1410
1418
1411 * scripts/ipython: Changed name of -thread option to -gthread,
1419 * scripts/ipython: Changed name of -thread option to -gthread,
1412 since this is GTK specific. I want to leave the door open for a
1420 since this is GTK specific. I want to leave the door open for a
1413 -wthread option for WX, which will most likely be necessary. This
1421 -wthread option for WX, which will most likely be necessary. This
1414 change affects usage and ipmaker as well.
1422 change affects usage and ipmaker as well.
1415
1423
1416 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1424 * IPython/Shell.py (matplotlib_shell): Add a factory function to
1417 handle the matplotlib shell issues. Code by John Hunter
1425 handle the matplotlib shell issues. Code by John Hunter
1418 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1426 <jdhunter-AT-nitace.bsd.uchicago.edu>.
1419 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1427 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
1420 broken (and disabled for end users) for now, but it puts the
1428 broken (and disabled for end users) for now, but it puts the
1421 infrastructure in place.
1429 infrastructure in place.
1422
1430
1423 2004-08-21 Fernando Perez <fperez@colorado.edu>
1431 2004-08-21 Fernando Perez <fperez@colorado.edu>
1424
1432
1425 * ipythonrc-pylab: Add matplotlib support.
1433 * ipythonrc-pylab: Add matplotlib support.
1426
1434
1427 * matplotlib_config.py: new files for matplotlib support, part of
1435 * matplotlib_config.py: new files for matplotlib support, part of
1428 the pylab profile.
1436 the pylab profile.
1429
1437
1430 * IPython/usage.py (__doc__): documented the threading options.
1438 * IPython/usage.py (__doc__): documented the threading options.
1431
1439
1432 2004-08-20 Fernando Perez <fperez@colorado.edu>
1440 2004-08-20 Fernando Perez <fperez@colorado.edu>
1433
1441
1434 * ipython: Modified the main calling routine to handle the -thread
1442 * ipython: Modified the main calling routine to handle the -thread
1435 and -mpthread options. This needs to be done as a top-level hack,
1443 and -mpthread options. This needs to be done as a top-level hack,
1436 because it determines which class to instantiate for IPython
1444 because it determines which class to instantiate for IPython
1437 itself.
1445 itself.
1438
1446
1439 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1447 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
1440 classes to support multithreaded GTK operation without blocking,
1448 classes to support multithreaded GTK operation without blocking,
1441 and matplotlib with all backends. This is a lot of still very
1449 and matplotlib with all backends. This is a lot of still very
1442 experimental code, and threads are tricky. So it may still have a
1450 experimental code, and threads are tricky. So it may still have a
1443 few rough edges... This code owes a lot to
1451 few rough edges... This code owes a lot to
1444 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1452 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
1445 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1453 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
1446 to John Hunter for all the matplotlib work.
1454 to John Hunter for all the matplotlib work.
1447
1455
1448 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1456 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
1449 options for gtk thread and matplotlib support.
1457 options for gtk thread and matplotlib support.
1450
1458
1451 2004-08-16 Fernando Perez <fperez@colorado.edu>
1459 2004-08-16 Fernando Perez <fperez@colorado.edu>
1452
1460
1453 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1461 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
1454 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1462 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
1455 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1463 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
1456
1464
1457 2004-08-11 Fernando Perez <fperez@colorado.edu>
1465 2004-08-11 Fernando Perez <fperez@colorado.edu>
1458
1466
1459 * setup.py (isfile): Fix build so documentation gets updated for
1467 * setup.py (isfile): Fix build so documentation gets updated for
1460 rpms (it was only done for .tgz builds).
1468 rpms (it was only done for .tgz builds).
1461
1469
1462 2004-08-10 Fernando Perez <fperez@colorado.edu>
1470 2004-08-10 Fernando Perez <fperez@colorado.edu>
1463
1471
1464 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1472 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
1465
1473
1466 * iplib.py : Silence syntax error exceptions in tab-completion.
1474 * iplib.py : Silence syntax error exceptions in tab-completion.
1467
1475
1468 2004-08-05 Fernando Perez <fperez@colorado.edu>
1476 2004-08-05 Fernando Perez <fperez@colorado.edu>
1469
1477
1470 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1478 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
1471 'color off' mark for continuation prompts. This was causing long
1479 'color off' mark for continuation prompts. This was causing long
1472 continuation lines to mis-wrap.
1480 continuation lines to mis-wrap.
1473
1481
1474 2004-08-01 Fernando Perez <fperez@colorado.edu>
1482 2004-08-01 Fernando Perez <fperez@colorado.edu>
1475
1483
1476 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1484 * IPython/ipmaker.py (make_IPython): Allow the shell class used
1477 for building ipython to be a parameter. All this is necessary
1485 for building ipython to be a parameter. All this is necessary
1478 right now to have a multithreaded version, but this insane
1486 right now to have a multithreaded version, but this insane
1479 non-design will be cleaned up soon. For now, it's a hack that
1487 non-design will be cleaned up soon. For now, it's a hack that
1480 works.
1488 works.
1481
1489
1482 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1490 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
1483 args in various places. No bugs so far, but it's a dangerous
1491 args in various places. No bugs so far, but it's a dangerous
1484 practice.
1492 practice.
1485
1493
1486 2004-07-31 Fernando Perez <fperez@colorado.edu>
1494 2004-07-31 Fernando Perez <fperez@colorado.edu>
1487
1495
1488 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1496 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
1489 fix completion of files with dots in their names under most
1497 fix completion of files with dots in their names under most
1490 profiles (pysh was OK because the completion order is different).
1498 profiles (pysh was OK because the completion order is different).
1491
1499
1492 2004-07-27 Fernando Perez <fperez@colorado.edu>
1500 2004-07-27 Fernando Perez <fperez@colorado.edu>
1493
1501
1494 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1502 * IPython/iplib.py (InteractiveShell.__init__): build dict of
1495 keywords manually, b/c the one in keyword.py was removed in python
1503 keywords manually, b/c the one in keyword.py was removed in python
1496 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1504 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
1497 This is NOT a bug under python 2.3 and earlier.
1505 This is NOT a bug under python 2.3 and earlier.
1498
1506
1499 2004-07-26 Fernando Perez <fperez@colorado.edu>
1507 2004-07-26 Fernando Perez <fperez@colorado.edu>
1500
1508
1501 * IPython/ultraTB.py (VerboseTB.text): Add another
1509 * IPython/ultraTB.py (VerboseTB.text): Add another
1502 linecache.checkcache() call to try to prevent inspect.py from
1510 linecache.checkcache() call to try to prevent inspect.py from
1503 crashing under python 2.3. I think this fixes
1511 crashing under python 2.3. I think this fixes
1504 http://www.scipy.net/roundup/ipython/issue17.
1512 http://www.scipy.net/roundup/ipython/issue17.
1505
1513
1506 2004-07-26 *** Released version 0.6.2
1514 2004-07-26 *** Released version 0.6.2
1507
1515
1508 2004-07-26 Fernando Perez <fperez@colorado.edu>
1516 2004-07-26 Fernando Perez <fperez@colorado.edu>
1509
1517
1510 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1518 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
1511 fail for any number.
1519 fail for any number.
1512 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1520 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
1513 empty bookmarks.
1521 empty bookmarks.
1514
1522
1515 2004-07-26 *** Released version 0.6.1
1523 2004-07-26 *** Released version 0.6.1
1516
1524
1517 2004-07-26 Fernando Perez <fperez@colorado.edu>
1525 2004-07-26 Fernando Perez <fperez@colorado.edu>
1518
1526
1519 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1527 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
1520
1528
1521 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1529 * IPython/iplib.py (protect_filename): Applied Ville's patch for
1522 escaping '()[]{}' in filenames.
1530 escaping '()[]{}' in filenames.
1523
1531
1524 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1532 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
1525 Python 2.2 users who lack a proper shlex.split.
1533 Python 2.2 users who lack a proper shlex.split.
1526
1534
1527 2004-07-19 Fernando Perez <fperez@colorado.edu>
1535 2004-07-19 Fernando Perez <fperez@colorado.edu>
1528
1536
1529 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1537 * IPython/iplib.py (InteractiveShell.init_readline): Add support
1530 for reading readline's init file. I follow the normal chain:
1538 for reading readline's init file. I follow the normal chain:
1531 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1539 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
1532 report by Mike Heeter. This closes
1540 report by Mike Heeter. This closes
1533 http://www.scipy.net/roundup/ipython/issue16.
1541 http://www.scipy.net/roundup/ipython/issue16.
1534
1542
1535 2004-07-18 Fernando Perez <fperez@colorado.edu>
1543 2004-07-18 Fernando Perez <fperez@colorado.edu>
1536
1544
1537 * IPython/iplib.py (__init__): Add better handling of '\' under
1545 * IPython/iplib.py (__init__): Add better handling of '\' under
1538 Win32 for filenames. After a patch by Ville.
1546 Win32 for filenames. After a patch by Ville.
1539
1547
1540 2004-07-17 Fernando Perez <fperez@colorado.edu>
1548 2004-07-17 Fernando Perez <fperez@colorado.edu>
1541
1549
1542 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1550 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
1543 autocalling would be triggered for 'foo is bar' if foo is
1551 autocalling would be triggered for 'foo is bar' if foo is
1544 callable. I also cleaned up the autocall detection code to use a
1552 callable. I also cleaned up the autocall detection code to use a
1545 regexp, which is faster. Bug reported by Alexander Schmolck.
1553 regexp, which is faster. Bug reported by Alexander Schmolck.
1546
1554
1547 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1555 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
1548 '?' in them would confuse the help system. Reported by Alex
1556 '?' in them would confuse the help system. Reported by Alex
1549 Schmolck.
1557 Schmolck.
1550
1558
1551 2004-07-16 Fernando Perez <fperez@colorado.edu>
1559 2004-07-16 Fernando Perez <fperez@colorado.edu>
1552
1560
1553 * IPython/GnuplotInteractive.py (__all__): added plot2.
1561 * IPython/GnuplotInteractive.py (__all__): added plot2.
1554
1562
1555 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1563 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
1556 plotting dictionaries, lists or tuples of 1d arrays.
1564 plotting dictionaries, lists or tuples of 1d arrays.
1557
1565
1558 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1566 * IPython/Magic.py (Magic.magic_hist): small clenaups and
1559 optimizations.
1567 optimizations.
1560
1568
1561 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1569 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
1562 the information which was there from Janko's original IPP code:
1570 the information which was there from Janko's original IPP code:
1563
1571
1564 03.05.99 20:53 porto.ifm.uni-kiel.de
1572 03.05.99 20:53 porto.ifm.uni-kiel.de
1565 --Started changelog.
1573 --Started changelog.
1566 --make clear do what it say it does
1574 --make clear do what it say it does
1567 --added pretty output of lines from inputcache
1575 --added pretty output of lines from inputcache
1568 --Made Logger a mixin class, simplifies handling of switches
1576 --Made Logger a mixin class, simplifies handling of switches
1569 --Added own completer class. .string<TAB> expands to last history
1577 --Added own completer class. .string<TAB> expands to last history
1570 line which starts with string. The new expansion is also present
1578 line which starts with string. The new expansion is also present
1571 with Ctrl-r from the readline library. But this shows, who this
1579 with Ctrl-r from the readline library. But this shows, who this
1572 can be done for other cases.
1580 can be done for other cases.
1573 --Added convention that all shell functions should accept a
1581 --Added convention that all shell functions should accept a
1574 parameter_string This opens the door for different behaviour for
1582 parameter_string This opens the door for different behaviour for
1575 each function. @cd is a good example of this.
1583 each function. @cd is a good example of this.
1576
1584
1577 04.05.99 12:12 porto.ifm.uni-kiel.de
1585 04.05.99 12:12 porto.ifm.uni-kiel.de
1578 --added logfile rotation
1586 --added logfile rotation
1579 --added new mainloop method which freezes first the namespace
1587 --added new mainloop method which freezes first the namespace
1580
1588
1581 07.05.99 21:24 porto.ifm.uni-kiel.de
1589 07.05.99 21:24 porto.ifm.uni-kiel.de
1582 --added the docreader classes. Now there is a help system.
1590 --added the docreader classes. Now there is a help system.
1583 -This is only a first try. Currently it's not easy to put new
1591 -This is only a first try. Currently it's not easy to put new
1584 stuff in the indices. But this is the way to go. Info would be
1592 stuff in the indices. But this is the way to go. Info would be
1585 better, but HTML is every where and not everybody has an info
1593 better, but HTML is every where and not everybody has an info
1586 system installed and it's not so easy to change html-docs to info.
1594 system installed and it's not so easy to change html-docs to info.
1587 --added global logfile option
1595 --added global logfile option
1588 --there is now a hook for object inspection method pinfo needs to
1596 --there is now a hook for object inspection method pinfo needs to
1589 be provided for this. Can be reached by two '??'.
1597 be provided for this. Can be reached by two '??'.
1590
1598
1591 08.05.99 20:51 porto.ifm.uni-kiel.de
1599 08.05.99 20:51 porto.ifm.uni-kiel.de
1592 --added a README
1600 --added a README
1593 --bug in rc file. Something has changed so functions in the rc
1601 --bug in rc file. Something has changed so functions in the rc
1594 file need to reference the shell and not self. Not clear if it's a
1602 file need to reference the shell and not self. Not clear if it's a
1595 bug or feature.
1603 bug or feature.
1596 --changed rc file for new behavior
1604 --changed rc file for new behavior
1597
1605
1598 2004-07-15 Fernando Perez <fperez@colorado.edu>
1606 2004-07-15 Fernando Perez <fperez@colorado.edu>
1599
1607
1600 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1608 * IPython/Logger.py (Logger.log): fixed recent bug where the input
1601 cache was falling out of sync in bizarre manners when multi-line
1609 cache was falling out of sync in bizarre manners when multi-line
1602 input was present. Minor optimizations and cleanup.
1610 input was present. Minor optimizations and cleanup.
1603
1611
1604 (Logger): Remove old Changelog info for cleanup. This is the
1612 (Logger): Remove old Changelog info for cleanup. This is the
1605 information which was there from Janko's original code:
1613 information which was there from Janko's original code:
1606
1614
1607 Changes to Logger: - made the default log filename a parameter
1615 Changes to Logger: - made the default log filename a parameter
1608
1616
1609 - put a check for lines beginning with !@? in log(). Needed
1617 - put a check for lines beginning with !@? in log(). Needed
1610 (even if the handlers properly log their lines) for mid-session
1618 (even if the handlers properly log their lines) for mid-session
1611 logging activation to work properly. Without this, lines logged
1619 logging activation to work properly. Without this, lines logged
1612 in mid session, which get read from the cache, would end up
1620 in mid session, which get read from the cache, would end up
1613 'bare' (with !@? in the open) in the log. Now they are caught
1621 'bare' (with !@? in the open) in the log. Now they are caught
1614 and prepended with a #.
1622 and prepended with a #.
1615
1623
1616 * IPython/iplib.py (InteractiveShell.init_readline): added check
1624 * IPython/iplib.py (InteractiveShell.init_readline): added check
1617 in case MagicCompleter fails to be defined, so we don't crash.
1625 in case MagicCompleter fails to be defined, so we don't crash.
1618
1626
1619 2004-07-13 Fernando Perez <fperez@colorado.edu>
1627 2004-07-13 Fernando Perez <fperez@colorado.edu>
1620
1628
1621 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1629 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
1622 of EPS if the requested filename ends in '.eps'.
1630 of EPS if the requested filename ends in '.eps'.
1623
1631
1624 2004-07-04 Fernando Perez <fperez@colorado.edu>
1632 2004-07-04 Fernando Perez <fperez@colorado.edu>
1625
1633
1626 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1634 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
1627 escaping of quotes when calling the shell.
1635 escaping of quotes when calling the shell.
1628
1636
1629 2004-07-02 Fernando Perez <fperez@colorado.edu>
1637 2004-07-02 Fernando Perez <fperez@colorado.edu>
1630
1638
1631 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1639 * IPython/Prompts.py (CachedOutput.update): Fix problem with
1632 gettext not working because we were clobbering '_'. Fixes
1640 gettext not working because we were clobbering '_'. Fixes
1633 http://www.scipy.net/roundup/ipython/issue6.
1641 http://www.scipy.net/roundup/ipython/issue6.
1634
1642
1635 2004-07-01 Fernando Perez <fperez@colorado.edu>
1643 2004-07-01 Fernando Perez <fperez@colorado.edu>
1636
1644
1637 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1645 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
1638 into @cd. Patch by Ville.
1646 into @cd. Patch by Ville.
1639
1647
1640 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1648 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1641 new function to store things after ipmaker runs. Patch by Ville.
1649 new function to store things after ipmaker runs. Patch by Ville.
1642 Eventually this will go away once ipmaker is removed and the class
1650 Eventually this will go away once ipmaker is removed and the class
1643 gets cleaned up, but for now it's ok. Key functionality here is
1651 gets cleaned up, but for now it's ok. Key functionality here is
1644 the addition of the persistent storage mechanism, a dict for
1652 the addition of the persistent storage mechanism, a dict for
1645 keeping data across sessions (for now just bookmarks, but more can
1653 keeping data across sessions (for now just bookmarks, but more can
1646 be implemented later).
1654 be implemented later).
1647
1655
1648 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1656 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
1649 persistent across sections. Patch by Ville, I modified it
1657 persistent across sections. Patch by Ville, I modified it
1650 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1658 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
1651 added a '-l' option to list all bookmarks.
1659 added a '-l' option to list all bookmarks.
1652
1660
1653 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1661 * IPython/iplib.py (InteractiveShell.atexit_operations): new
1654 center for cleanup. Registered with atexit.register(). I moved
1662 center for cleanup. Registered with atexit.register(). I moved
1655 here the old exit_cleanup(). After a patch by Ville.
1663 here the old exit_cleanup(). After a patch by Ville.
1656
1664
1657 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1665 * IPython/Magic.py (get_py_filename): added '~' to the accepted
1658 characters in the hacked shlex_split for python 2.2.
1666 characters in the hacked shlex_split for python 2.2.
1659
1667
1660 * IPython/iplib.py (file_matches): more fixes to filenames with
1668 * IPython/iplib.py (file_matches): more fixes to filenames with
1661 whitespace in them. It's not perfect, but limitations in python's
1669 whitespace in them. It's not perfect, but limitations in python's
1662 readline make it impossible to go further.
1670 readline make it impossible to go further.
1663
1671
1664 2004-06-29 Fernando Perez <fperez@colorado.edu>
1672 2004-06-29 Fernando Perez <fperez@colorado.edu>
1665
1673
1666 * IPython/iplib.py (file_matches): escape whitespace correctly in
1674 * IPython/iplib.py (file_matches): escape whitespace correctly in
1667 filename completions. Bug reported by Ville.
1675 filename completions. Bug reported by Ville.
1668
1676
1669 2004-06-28 Fernando Perez <fperez@colorado.edu>
1677 2004-06-28 Fernando Perez <fperez@colorado.edu>
1670
1678
1671 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1679 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
1672 the history file will be called 'history-PROFNAME' (or just
1680 the history file will be called 'history-PROFNAME' (or just
1673 'history' if no profile is loaded). I was getting annoyed at
1681 'history' if no profile is loaded). I was getting annoyed at
1674 getting my Numerical work history clobbered by pysh sessions.
1682 getting my Numerical work history clobbered by pysh sessions.
1675
1683
1676 * IPython/iplib.py (InteractiveShell.__init__): Internal
1684 * IPython/iplib.py (InteractiveShell.__init__): Internal
1677 getoutputerror() function so that we can honor the system_verbose
1685 getoutputerror() function so that we can honor the system_verbose
1678 flag for _all_ system calls. I also added escaping of #
1686 flag for _all_ system calls. I also added escaping of #
1679 characters here to avoid confusing Itpl.
1687 characters here to avoid confusing Itpl.
1680
1688
1681 * IPython/Magic.py (shlex_split): removed call to shell in
1689 * IPython/Magic.py (shlex_split): removed call to shell in
1682 parse_options and replaced it with shlex.split(). The annoying
1690 parse_options and replaced it with shlex.split(). The annoying
1683 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1691 part was that in Python 2.2, shlex.split() doesn't exist, so I had
1684 to backport it from 2.3, with several frail hacks (the shlex
1692 to backport it from 2.3, with several frail hacks (the shlex
1685 module is rather limited in 2.2). Thanks to a suggestion by Ville
1693 module is rather limited in 2.2). Thanks to a suggestion by Ville
1686 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1694 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
1687 problem.
1695 problem.
1688
1696
1689 (Magic.magic_system_verbose): new toggle to print the actual
1697 (Magic.magic_system_verbose): new toggle to print the actual
1690 system calls made by ipython. Mainly for debugging purposes.
1698 system calls made by ipython. Mainly for debugging purposes.
1691
1699
1692 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1700 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
1693 doesn't support persistence. Reported (and fix suggested) by
1701 doesn't support persistence. Reported (and fix suggested) by
1694 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1702 Travis Caldwell <travis_caldwell2000@yahoo.com>.
1695
1703
1696 2004-06-26 Fernando Perez <fperez@colorado.edu>
1704 2004-06-26 Fernando Perez <fperez@colorado.edu>
1697
1705
1698 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1706 * IPython/Logger.py (Logger.log): fix to handle correctly empty
1699 continue prompts.
1707 continue prompts.
1700
1708
1701 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1709 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
1702 function (basically a big docstring) and a few more things here to
1710 function (basically a big docstring) and a few more things here to
1703 speedup startup. pysh.py is now very lightweight. We want because
1711 speedup startup. pysh.py is now very lightweight. We want because
1704 it gets execfile'd, while InterpreterExec gets imported, so
1712 it gets execfile'd, while InterpreterExec gets imported, so
1705 byte-compilation saves time.
1713 byte-compilation saves time.
1706
1714
1707 2004-06-25 Fernando Perez <fperez@colorado.edu>
1715 2004-06-25 Fernando Perez <fperez@colorado.edu>
1708
1716
1709 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1717 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
1710 -NUM', which was recently broken.
1718 -NUM', which was recently broken.
1711
1719
1712 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1720 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
1713 in multi-line input (but not !!, which doesn't make sense there).
1721 in multi-line input (but not !!, which doesn't make sense there).
1714
1722
1715 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1723 * IPython/UserConfig/ipythonrc: made autoindent on by default.
1716 It's just too useful, and people can turn it off in the less
1724 It's just too useful, and people can turn it off in the less
1717 common cases where it's a problem.
1725 common cases where it's a problem.
1718
1726
1719 2004-06-24 Fernando Perez <fperez@colorado.edu>
1727 2004-06-24 Fernando Perez <fperez@colorado.edu>
1720
1728
1721 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1729 * IPython/iplib.py (InteractiveShell._prefilter): big change -
1722 special syntaxes (like alias calling) is now allied in multi-line
1730 special syntaxes (like alias calling) is now allied in multi-line
1723 input. This is still _very_ experimental, but it's necessary for
1731 input. This is still _very_ experimental, but it's necessary for
1724 efficient shell usage combining python looping syntax with system
1732 efficient shell usage combining python looping syntax with system
1725 calls. For now it's restricted to aliases, I don't think it
1733 calls. For now it's restricted to aliases, I don't think it
1726 really even makes sense to have this for magics.
1734 really even makes sense to have this for magics.
1727
1735
1728 2004-06-23 Fernando Perez <fperez@colorado.edu>
1736 2004-06-23 Fernando Perez <fperez@colorado.edu>
1729
1737
1730 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1738 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
1731 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1739 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
1732
1740
1733 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1741 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
1734 extensions under Windows (after code sent by Gary Bishop). The
1742 extensions under Windows (after code sent by Gary Bishop). The
1735 extensions considered 'executable' are stored in IPython's rc
1743 extensions considered 'executable' are stored in IPython's rc
1736 structure as win_exec_ext.
1744 structure as win_exec_ext.
1737
1745
1738 * IPython/genutils.py (shell): new function, like system() but
1746 * IPython/genutils.py (shell): new function, like system() but
1739 without return value. Very useful for interactive shell work.
1747 without return value. Very useful for interactive shell work.
1740
1748
1741 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1749 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
1742 delete aliases.
1750 delete aliases.
1743
1751
1744 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1752 * IPython/iplib.py (InteractiveShell.alias_table_update): make
1745 sure that the alias table doesn't contain python keywords.
1753 sure that the alias table doesn't contain python keywords.
1746
1754
1747 2004-06-21 Fernando Perez <fperez@colorado.edu>
1755 2004-06-21 Fernando Perez <fperez@colorado.edu>
1748
1756
1749 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1757 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
1750 non-existent items are found in $PATH. Reported by Thorsten.
1758 non-existent items are found in $PATH. Reported by Thorsten.
1751
1759
1752 2004-06-20 Fernando Perez <fperez@colorado.edu>
1760 2004-06-20 Fernando Perez <fperez@colorado.edu>
1753
1761
1754 * IPython/iplib.py (complete): modified the completer so that the
1762 * IPython/iplib.py (complete): modified the completer so that the
1755 order of priorities can be easily changed at runtime.
1763 order of priorities can be easily changed at runtime.
1756
1764
1757 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1765 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
1758 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1766 Modified to auto-execute all lines beginning with '~', '/' or '.'.
1759
1767
1760 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1768 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
1761 expand Python variables prepended with $ in all system calls. The
1769 expand Python variables prepended with $ in all system calls. The
1762 same was done to InteractiveShell.handle_shell_escape. Now all
1770 same was done to InteractiveShell.handle_shell_escape. Now all
1763 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1771 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
1764 expansion of python variables and expressions according to the
1772 expansion of python variables and expressions according to the
1765 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1773 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
1766
1774
1767 Though PEP-215 has been rejected, a similar (but simpler) one
1775 Though PEP-215 has been rejected, a similar (but simpler) one
1768 seems like it will go into Python 2.4, PEP-292 -
1776 seems like it will go into Python 2.4, PEP-292 -
1769 http://www.python.org/peps/pep-0292.html.
1777 http://www.python.org/peps/pep-0292.html.
1770
1778
1771 I'll keep the full syntax of PEP-215, since IPython has since the
1779 I'll keep the full syntax of PEP-215, since IPython has since the
1772 start used Ka-Ping Yee's reference implementation discussed there
1780 start used Ka-Ping Yee's reference implementation discussed there
1773 (Itpl), and I actually like the powerful semantics it offers.
1781 (Itpl), and I actually like the powerful semantics it offers.
1774
1782
1775 In order to access normal shell variables, the $ has to be escaped
1783 In order to access normal shell variables, the $ has to be escaped
1776 via an extra $. For example:
1784 via an extra $. For example:
1777
1785
1778 In [7]: PATH='a python variable'
1786 In [7]: PATH='a python variable'
1779
1787
1780 In [8]: !echo $PATH
1788 In [8]: !echo $PATH
1781 a python variable
1789 a python variable
1782
1790
1783 In [9]: !echo $$PATH
1791 In [9]: !echo $$PATH
1784 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1792 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
1785
1793
1786 (Magic.parse_options): escape $ so the shell doesn't evaluate
1794 (Magic.parse_options): escape $ so the shell doesn't evaluate
1787 things prematurely.
1795 things prematurely.
1788
1796
1789 * IPython/iplib.py (InteractiveShell.call_alias): added the
1797 * IPython/iplib.py (InteractiveShell.call_alias): added the
1790 ability for aliases to expand python variables via $.
1798 ability for aliases to expand python variables via $.
1791
1799
1792 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1800 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
1793 system, now there's a @rehash/@rehashx pair of magics. These work
1801 system, now there's a @rehash/@rehashx pair of magics. These work
1794 like the csh rehash command, and can be invoked at any time. They
1802 like the csh rehash command, and can be invoked at any time. They
1795 build a table of aliases to everything in the user's $PATH
1803 build a table of aliases to everything in the user's $PATH
1796 (@rehash uses everything, @rehashx is slower but only adds
1804 (@rehash uses everything, @rehashx is slower but only adds
1797 executable files). With this, the pysh.py-based shell profile can
1805 executable files). With this, the pysh.py-based shell profile can
1798 now simply call rehash upon startup, and full access to all
1806 now simply call rehash upon startup, and full access to all
1799 programs in the user's path is obtained.
1807 programs in the user's path is obtained.
1800
1808
1801 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1809 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
1802 functionality is now fully in place. I removed the old dynamic
1810 functionality is now fully in place. I removed the old dynamic
1803 code generation based approach, in favor of a much lighter one
1811 code generation based approach, in favor of a much lighter one
1804 based on a simple dict. The advantage is that this allows me to
1812 based on a simple dict. The advantage is that this allows me to
1805 now have thousands of aliases with negligible cost (unthinkable
1813 now have thousands of aliases with negligible cost (unthinkable
1806 with the old system).
1814 with the old system).
1807
1815
1808 2004-06-19 Fernando Perez <fperez@colorado.edu>
1816 2004-06-19 Fernando Perez <fperez@colorado.edu>
1809
1817
1810 * IPython/iplib.py (__init__): extended MagicCompleter class to
1818 * IPython/iplib.py (__init__): extended MagicCompleter class to
1811 also complete (last in priority) on user aliases.
1819 also complete (last in priority) on user aliases.
1812
1820
1813 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1821 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
1814 call to eval.
1822 call to eval.
1815 (ItplNS.__init__): Added a new class which functions like Itpl,
1823 (ItplNS.__init__): Added a new class which functions like Itpl,
1816 but allows configuring the namespace for the evaluation to occur
1824 but allows configuring the namespace for the evaluation to occur
1817 in.
1825 in.
1818
1826
1819 2004-06-18 Fernando Perez <fperez@colorado.edu>
1827 2004-06-18 Fernando Perez <fperez@colorado.edu>
1820
1828
1821 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1829 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
1822 better message when 'exit' or 'quit' are typed (a common newbie
1830 better message when 'exit' or 'quit' are typed (a common newbie
1823 confusion).
1831 confusion).
1824
1832
1825 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1833 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
1826 check for Windows users.
1834 check for Windows users.
1827
1835
1828 * IPython/iplib.py (InteractiveShell.user_setup): removed
1836 * IPython/iplib.py (InteractiveShell.user_setup): removed
1829 disabling of colors for Windows. I'll test at runtime and issue a
1837 disabling of colors for Windows. I'll test at runtime and issue a
1830 warning if Gary's readline isn't found, as to nudge users to
1838 warning if Gary's readline isn't found, as to nudge users to
1831 download it.
1839 download it.
1832
1840
1833 2004-06-16 Fernando Perez <fperez@colorado.edu>
1841 2004-06-16 Fernando Perez <fperez@colorado.edu>
1834
1842
1835 * IPython/genutils.py (Stream.__init__): changed to print errors
1843 * IPython/genutils.py (Stream.__init__): changed to print errors
1836 to sys.stderr. I had a circular dependency here. Now it's
1844 to sys.stderr. I had a circular dependency here. Now it's
1837 possible to run ipython as IDLE's shell (consider this pre-alpha,
1845 possible to run ipython as IDLE's shell (consider this pre-alpha,
1838 since true stdout things end up in the starting terminal instead
1846 since true stdout things end up in the starting terminal instead
1839 of IDLE's out).
1847 of IDLE's out).
1840
1848
1841 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1849 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
1842 users who haven't # updated their prompt_in2 definitions. Remove
1850 users who haven't # updated their prompt_in2 definitions. Remove
1843 eventually.
1851 eventually.
1844 (multiple_replace): added credit to original ASPN recipe.
1852 (multiple_replace): added credit to original ASPN recipe.
1845
1853
1846 2004-06-15 Fernando Perez <fperez@colorado.edu>
1854 2004-06-15 Fernando Perez <fperez@colorado.edu>
1847
1855
1848 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1856 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
1849 list of auto-defined aliases.
1857 list of auto-defined aliases.
1850
1858
1851 2004-06-13 Fernando Perez <fperez@colorado.edu>
1859 2004-06-13 Fernando Perez <fperez@colorado.edu>
1852
1860
1853 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1861 * setup.py (scriptfiles): Don't trigger win_post_install unless an
1854 install was really requested (so setup.py can be used for other
1862 install was really requested (so setup.py can be used for other
1855 things under Windows).
1863 things under Windows).
1856
1864
1857 2004-06-10 Fernando Perez <fperez@colorado.edu>
1865 2004-06-10 Fernando Perez <fperez@colorado.edu>
1858
1866
1859 * IPython/Logger.py (Logger.create_log): Manually remove any old
1867 * IPython/Logger.py (Logger.create_log): Manually remove any old
1860 backup, since os.remove may fail under Windows. Fixes bug
1868 backup, since os.remove may fail under Windows. Fixes bug
1861 reported by Thorsten.
1869 reported by Thorsten.
1862
1870
1863 2004-06-09 Fernando Perez <fperez@colorado.edu>
1871 2004-06-09 Fernando Perez <fperez@colorado.edu>
1864
1872
1865 * examples/example-embed.py: fixed all references to %n (replaced
1873 * examples/example-embed.py: fixed all references to %n (replaced
1866 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1874 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
1867 for all examples and the manual as well.
1875 for all examples and the manual as well.
1868
1876
1869 2004-06-08 Fernando Perez <fperez@colorado.edu>
1877 2004-06-08 Fernando Perez <fperez@colorado.edu>
1870
1878
1871 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1879 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
1872 alignment and color management. All 3 prompt subsystems now
1880 alignment and color management. All 3 prompt subsystems now
1873 inherit from BasePrompt.
1881 inherit from BasePrompt.
1874
1882
1875 * tools/release: updates for windows installer build and tag rpms
1883 * tools/release: updates for windows installer build and tag rpms
1876 with python version (since paths are fixed).
1884 with python version (since paths are fixed).
1877
1885
1878 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1886 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
1879 which will become eventually obsolete. Also fixed the default
1887 which will become eventually obsolete. Also fixed the default
1880 prompt_in2 to use \D, so at least new users start with the correct
1888 prompt_in2 to use \D, so at least new users start with the correct
1881 defaults.
1889 defaults.
1882 WARNING: Users with existing ipythonrc files will need to apply
1890 WARNING: Users with existing ipythonrc files will need to apply
1883 this fix manually!
1891 this fix manually!
1884
1892
1885 * setup.py: make windows installer (.exe). This is finally the
1893 * setup.py: make windows installer (.exe). This is finally the
1886 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1894 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
1887 which I hadn't included because it required Python 2.3 (or recent
1895 which I hadn't included because it required Python 2.3 (or recent
1888 distutils).
1896 distutils).
1889
1897
1890 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1898 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
1891 usage of new '\D' escape.
1899 usage of new '\D' escape.
1892
1900
1893 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
1901 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
1894 lacks os.getuid())
1902 lacks os.getuid())
1895 (CachedOutput.set_colors): Added the ability to turn coloring
1903 (CachedOutput.set_colors): Added the ability to turn coloring
1896 on/off with @colors even for manually defined prompt colors. It
1904 on/off with @colors even for manually defined prompt colors. It
1897 uses a nasty global, but it works safely and via the generic color
1905 uses a nasty global, but it works safely and via the generic color
1898 handling mechanism.
1906 handling mechanism.
1899 (Prompt2.__init__): Introduced new escape '\D' for continuation
1907 (Prompt2.__init__): Introduced new escape '\D' for continuation
1900 prompts. It represents the counter ('\#') as dots.
1908 prompts. It represents the counter ('\#') as dots.
1901 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
1909 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
1902 need to update their ipythonrc files and replace '%n' with '\D' in
1910 need to update their ipythonrc files and replace '%n' with '\D' in
1903 their prompt_in2 settings everywhere. Sorry, but there's
1911 their prompt_in2 settings everywhere. Sorry, but there's
1904 otherwise no clean way to get all prompts to properly align. The
1912 otherwise no clean way to get all prompts to properly align. The
1905 ipythonrc shipped with IPython has been updated.
1913 ipythonrc shipped with IPython has been updated.
1906
1914
1907 2004-06-07 Fernando Perez <fperez@colorado.edu>
1915 2004-06-07 Fernando Perez <fperez@colorado.edu>
1908
1916
1909 * setup.py (isfile): Pass local_icons option to latex2html, so the
1917 * setup.py (isfile): Pass local_icons option to latex2html, so the
1910 resulting HTML file is self-contained. Thanks to
1918 resulting HTML file is self-contained. Thanks to
1911 dryice-AT-liu.com.cn for the tip.
1919 dryice-AT-liu.com.cn for the tip.
1912
1920
1913 * pysh.py: I created a new profile 'shell', which implements a
1921 * pysh.py: I created a new profile 'shell', which implements a
1914 _rudimentary_ IPython-based shell. This is in NO WAY a realy
1922 _rudimentary_ IPython-based shell. This is in NO WAY a realy
1915 system shell, nor will it become one anytime soon. It's mainly
1923 system shell, nor will it become one anytime soon. It's mainly
1916 meant to illustrate the use of the new flexible bash-like prompts.
1924 meant to illustrate the use of the new flexible bash-like prompts.
1917 I guess it could be used by hardy souls for true shell management,
1925 I guess it could be used by hardy souls for true shell management,
1918 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
1926 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
1919 profile. This uses the InterpreterExec extension provided by
1927 profile. This uses the InterpreterExec extension provided by
1920 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
1928 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
1921
1929
1922 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
1930 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
1923 auto-align itself with the length of the previous input prompt
1931 auto-align itself with the length of the previous input prompt
1924 (taking into account the invisible color escapes).
1932 (taking into account the invisible color escapes).
1925 (CachedOutput.__init__): Large restructuring of this class. Now
1933 (CachedOutput.__init__): Large restructuring of this class. Now
1926 all three prompts (primary1, primary2, output) are proper objects,
1934 all three prompts (primary1, primary2, output) are proper objects,
1927 managed by the 'parent' CachedOutput class. The code is still a
1935 managed by the 'parent' CachedOutput class. The code is still a
1928 bit hackish (all prompts share state via a pointer to the cache),
1936 bit hackish (all prompts share state via a pointer to the cache),
1929 but it's overall far cleaner than before.
1937 but it's overall far cleaner than before.
1930
1938
1931 * IPython/genutils.py (getoutputerror): modified to add verbose,
1939 * IPython/genutils.py (getoutputerror): modified to add verbose,
1932 debug and header options. This makes the interface of all getout*
1940 debug and header options. This makes the interface of all getout*
1933 functions uniform.
1941 functions uniform.
1934 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
1942 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
1935
1943
1936 * IPython/Magic.py (Magic.default_option): added a function to
1944 * IPython/Magic.py (Magic.default_option): added a function to
1937 allow registering default options for any magic command. This
1945 allow registering default options for any magic command. This
1938 makes it easy to have profiles which customize the magics globally
1946 makes it easy to have profiles which customize the magics globally
1939 for a certain use. The values set through this function are
1947 for a certain use. The values set through this function are
1940 picked up by the parse_options() method, which all magics should
1948 picked up by the parse_options() method, which all magics should
1941 use to parse their options.
1949 use to parse their options.
1942
1950
1943 * IPython/genutils.py (warn): modified the warnings framework to
1951 * IPython/genutils.py (warn): modified the warnings framework to
1944 use the Term I/O class. I'm trying to slowly unify all of
1952 use the Term I/O class. I'm trying to slowly unify all of
1945 IPython's I/O operations to pass through Term.
1953 IPython's I/O operations to pass through Term.
1946
1954
1947 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
1955 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
1948 the secondary prompt to correctly match the length of the primary
1956 the secondary prompt to correctly match the length of the primary
1949 one for any prompt. Now multi-line code will properly line up
1957 one for any prompt. Now multi-line code will properly line up
1950 even for path dependent prompts, such as the new ones available
1958 even for path dependent prompts, such as the new ones available
1951 via the prompt_specials.
1959 via the prompt_specials.
1952
1960
1953 2004-06-06 Fernando Perez <fperez@colorado.edu>
1961 2004-06-06 Fernando Perez <fperez@colorado.edu>
1954
1962
1955 * IPython/Prompts.py (prompt_specials): Added the ability to have
1963 * IPython/Prompts.py (prompt_specials): Added the ability to have
1956 bash-like special sequences in the prompts, which get
1964 bash-like special sequences in the prompts, which get
1957 automatically expanded. Things like hostname, current working
1965 automatically expanded. Things like hostname, current working
1958 directory and username are implemented already, but it's easy to
1966 directory and username are implemented already, but it's easy to
1959 add more in the future. Thanks to a patch by W.J. van der Laan
1967 add more in the future. Thanks to a patch by W.J. van der Laan
1960 <gnufnork-AT-hetdigitalegat.nl>
1968 <gnufnork-AT-hetdigitalegat.nl>
1961 (prompt_specials): Added color support for prompt strings, so
1969 (prompt_specials): Added color support for prompt strings, so
1962 users can define arbitrary color setups for their prompts.
1970 users can define arbitrary color setups for their prompts.
1963
1971
1964 2004-06-05 Fernando Perez <fperez@colorado.edu>
1972 2004-06-05 Fernando Perez <fperez@colorado.edu>
1965
1973
1966 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
1974 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
1967 code to load Gary Bishop's readline and configure it
1975 code to load Gary Bishop's readline and configure it
1968 automatically. Thanks to Gary for help on this.
1976 automatically. Thanks to Gary for help on this.
1969
1977
1970 2004-06-01 Fernando Perez <fperez@colorado.edu>
1978 2004-06-01 Fernando Perez <fperez@colorado.edu>
1971
1979
1972 * IPython/Logger.py (Logger.create_log): fix bug for logging
1980 * IPython/Logger.py (Logger.create_log): fix bug for logging
1973 with no filename (previous fix was incomplete).
1981 with no filename (previous fix was incomplete).
1974
1982
1975 2004-05-25 Fernando Perez <fperez@colorado.edu>
1983 2004-05-25 Fernando Perez <fperez@colorado.edu>
1976
1984
1977 * IPython/Magic.py (Magic.parse_options): fix bug where naked
1985 * IPython/Magic.py (Magic.parse_options): fix bug where naked
1978 parens would get passed to the shell.
1986 parens would get passed to the shell.
1979
1987
1980 2004-05-20 Fernando Perez <fperez@colorado.edu>
1988 2004-05-20 Fernando Perez <fperez@colorado.edu>
1981
1989
1982 * IPython/Magic.py (Magic.magic_prun): changed default profile
1990 * IPython/Magic.py (Magic.magic_prun): changed default profile
1983 sort order to 'time' (the more common profiling need).
1991 sort order to 'time' (the more common profiling need).
1984
1992
1985 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
1993 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
1986 so that source code shown is guaranteed in sync with the file on
1994 so that source code shown is guaranteed in sync with the file on
1987 disk (also changed in psource). Similar fix to the one for
1995 disk (also changed in psource). Similar fix to the one for
1988 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
1996 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
1989 <yann.ledu-AT-noos.fr>.
1997 <yann.ledu-AT-noos.fr>.
1990
1998
1991 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
1999 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
1992 with a single option would not be correctly parsed. Closes
2000 with a single option would not be correctly parsed. Closes
1993 http://www.scipy.net/roundup/ipython/issue14. This bug had been
2001 http://www.scipy.net/roundup/ipython/issue14. This bug had been
1994 introduced in 0.6.0 (on 2004-05-06).
2002 introduced in 0.6.0 (on 2004-05-06).
1995
2003
1996 2004-05-13 *** Released version 0.6.0
2004 2004-05-13 *** Released version 0.6.0
1997
2005
1998 2004-05-13 Fernando Perez <fperez@colorado.edu>
2006 2004-05-13 Fernando Perez <fperez@colorado.edu>
1999
2007
2000 * debian/: Added debian/ directory to CVS, so that debian support
2008 * debian/: Added debian/ directory to CVS, so that debian support
2001 is publicly accessible. The debian package is maintained by Jack
2009 is publicly accessible. The debian package is maintained by Jack
2002 Moffit <jack-AT-xiph.org>.
2010 Moffit <jack-AT-xiph.org>.
2003
2011
2004 * Documentation: included the notes about an ipython-based system
2012 * Documentation: included the notes about an ipython-based system
2005 shell (the hypothetical 'pysh') into the new_design.pdf document,
2013 shell (the hypothetical 'pysh') into the new_design.pdf document,
2006 so that these ideas get distributed to users along with the
2014 so that these ideas get distributed to users along with the
2007 official documentation.
2015 official documentation.
2008
2016
2009 2004-05-10 Fernando Perez <fperez@colorado.edu>
2017 2004-05-10 Fernando Perez <fperez@colorado.edu>
2010
2018
2011 * IPython/Logger.py (Logger.create_log): fix recently introduced
2019 * IPython/Logger.py (Logger.create_log): fix recently introduced
2012 bug (misindented line) where logstart would fail when not given an
2020 bug (misindented line) where logstart would fail when not given an
2013 explicit filename.
2021 explicit filename.
2014
2022
2015 2004-05-09 Fernando Perez <fperez@colorado.edu>
2023 2004-05-09 Fernando Perez <fperez@colorado.edu>
2016
2024
2017 * IPython/Magic.py (Magic.parse_options): skip system call when
2025 * IPython/Magic.py (Magic.parse_options): skip system call when
2018 there are no options to look for. Faster, cleaner for the common
2026 there are no options to look for. Faster, cleaner for the common
2019 case.
2027 case.
2020
2028
2021 * Documentation: many updates to the manual: describing Windows
2029 * Documentation: many updates to the manual: describing Windows
2022 support better, Gnuplot updates, credits, misc small stuff. Also
2030 support better, Gnuplot updates, credits, misc small stuff. Also
2023 updated the new_design doc a bit.
2031 updated the new_design doc a bit.
2024
2032
2025 2004-05-06 *** Released version 0.6.0.rc1
2033 2004-05-06 *** Released version 0.6.0.rc1
2026
2034
2027 2004-05-06 Fernando Perez <fperez@colorado.edu>
2035 2004-05-06 Fernando Perez <fperez@colorado.edu>
2028
2036
2029 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
2037 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
2030 operations to use the vastly more efficient list/''.join() method.
2038 operations to use the vastly more efficient list/''.join() method.
2031 (FormattedTB.text): Fix
2039 (FormattedTB.text): Fix
2032 http://www.scipy.net/roundup/ipython/issue12 - exception source
2040 http://www.scipy.net/roundup/ipython/issue12 - exception source
2033 extract not updated after reload. Thanks to Mike Salib
2041 extract not updated after reload. Thanks to Mike Salib
2034 <msalib-AT-mit.edu> for pinning the source of the problem.
2042 <msalib-AT-mit.edu> for pinning the source of the problem.
2035 Fortunately, the solution works inside ipython and doesn't require
2043 Fortunately, the solution works inside ipython and doesn't require
2036 any changes to python proper.
2044 any changes to python proper.
2037
2045
2038 * IPython/Magic.py (Magic.parse_options): Improved to process the
2046 * IPython/Magic.py (Magic.parse_options): Improved to process the
2039 argument list as a true shell would (by actually using the
2047 argument list as a true shell would (by actually using the
2040 underlying system shell). This way, all @magics automatically get
2048 underlying system shell). This way, all @magics automatically get
2041 shell expansion for variables. Thanks to a comment by Alex
2049 shell expansion for variables. Thanks to a comment by Alex
2042 Schmolck.
2050 Schmolck.
2043
2051
2044 2004-04-04 Fernando Perez <fperez@colorado.edu>
2052 2004-04-04 Fernando Perez <fperez@colorado.edu>
2045
2053
2046 * IPython/iplib.py (InteractiveShell.interact): Added a special
2054 * IPython/iplib.py (InteractiveShell.interact): Added a special
2047 trap for a debugger quit exception, which is basically impossible
2055 trap for a debugger quit exception, which is basically impossible
2048 to handle by normal mechanisms, given what pdb does to the stack.
2056 to handle by normal mechanisms, given what pdb does to the stack.
2049 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
2057 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
2050
2058
2051 2004-04-03 Fernando Perez <fperez@colorado.edu>
2059 2004-04-03 Fernando Perez <fperez@colorado.edu>
2052
2060
2053 * IPython/genutils.py (Term): Standardized the names of the Term
2061 * IPython/genutils.py (Term): Standardized the names of the Term
2054 class streams to cin/cout/cerr, following C++ naming conventions
2062 class streams to cin/cout/cerr, following C++ naming conventions
2055 (I can't use in/out/err because 'in' is not a valid attribute
2063 (I can't use in/out/err because 'in' is not a valid attribute
2056 name).
2064 name).
2057
2065
2058 * IPython/iplib.py (InteractiveShell.interact): don't increment
2066 * IPython/iplib.py (InteractiveShell.interact): don't increment
2059 the prompt if there's no user input. By Daniel 'Dang' Griffith
2067 the prompt if there's no user input. By Daniel 'Dang' Griffith
2060 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
2068 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
2061 Francois Pinard.
2069 Francois Pinard.
2062
2070
2063 2004-04-02 Fernando Perez <fperez@colorado.edu>
2071 2004-04-02 Fernando Perez <fperez@colorado.edu>
2064
2072
2065 * IPython/genutils.py (Stream.__init__): Modified to survive at
2073 * IPython/genutils.py (Stream.__init__): Modified to survive at
2066 least importing in contexts where stdin/out/err aren't true file
2074 least importing in contexts where stdin/out/err aren't true file
2067 objects, such as PyCrust (they lack fileno() and mode). However,
2075 objects, such as PyCrust (they lack fileno() and mode). However,
2068 the recovery facilities which rely on these things existing will
2076 the recovery facilities which rely on these things existing will
2069 not work.
2077 not work.
2070
2078
2071 2004-04-01 Fernando Perez <fperez@colorado.edu>
2079 2004-04-01 Fernando Perez <fperez@colorado.edu>
2072
2080
2073 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
2081 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
2074 use the new getoutputerror() function, so it properly
2082 use the new getoutputerror() function, so it properly
2075 distinguishes stdout/err.
2083 distinguishes stdout/err.
2076
2084
2077 * IPython/genutils.py (getoutputerror): added a function to
2085 * IPython/genutils.py (getoutputerror): added a function to
2078 capture separately the standard output and error of a command.
2086 capture separately the standard output and error of a command.
2079 After a comment from dang on the mailing lists. This code is
2087 After a comment from dang on the mailing lists. This code is
2080 basically a modified version of commands.getstatusoutput(), from
2088 basically a modified version of commands.getstatusoutput(), from
2081 the standard library.
2089 the standard library.
2082
2090
2083 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
2091 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
2084 '!!' as a special syntax (shorthand) to access @sx.
2092 '!!' as a special syntax (shorthand) to access @sx.
2085
2093
2086 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
2094 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
2087 command and return its output as a list split on '\n'.
2095 command and return its output as a list split on '\n'.
2088
2096
2089 2004-03-31 Fernando Perez <fperez@colorado.edu>
2097 2004-03-31 Fernando Perez <fperez@colorado.edu>
2090
2098
2091 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
2099 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
2092 method to dictionaries used as FakeModule instances if they lack
2100 method to dictionaries used as FakeModule instances if they lack
2093 it. At least pydoc in python2.3 breaks for runtime-defined
2101 it. At least pydoc in python2.3 breaks for runtime-defined
2094 functions without this hack. At some point I need to _really_
2102 functions without this hack. At some point I need to _really_
2095 understand what FakeModule is doing, because it's a gross hack.
2103 understand what FakeModule is doing, because it's a gross hack.
2096 But it solves Arnd's problem for now...
2104 But it solves Arnd's problem for now...
2097
2105
2098 2004-02-27 Fernando Perez <fperez@colorado.edu>
2106 2004-02-27 Fernando Perez <fperez@colorado.edu>
2099
2107
2100 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
2108 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
2101 mode would behave erratically. Also increased the number of
2109 mode would behave erratically. Also increased the number of
2102 possible logs in rotate mod to 999. Thanks to Rod Holland
2110 possible logs in rotate mod to 999. Thanks to Rod Holland
2103 <rhh@StructureLABS.com> for the report and fixes.
2111 <rhh@StructureLABS.com> for the report and fixes.
2104
2112
2105 2004-02-26 Fernando Perez <fperez@colorado.edu>
2113 2004-02-26 Fernando Perez <fperez@colorado.edu>
2106
2114
2107 * IPython/genutils.py (page): Check that the curses module really
2115 * IPython/genutils.py (page): Check that the curses module really
2108 has the initscr attribute before trying to use it. For some
2116 has the initscr attribute before trying to use it. For some
2109 reason, the Solaris curses module is missing this. I think this
2117 reason, the Solaris curses module is missing this. I think this
2110 should be considered a Solaris python bug, but I'm not sure.
2118 should be considered a Solaris python bug, but I'm not sure.
2111
2119
2112 2004-01-17 Fernando Perez <fperez@colorado.edu>
2120 2004-01-17 Fernando Perez <fperez@colorado.edu>
2113
2121
2114 * IPython/genutils.py (Stream.__init__): Changes to try to make
2122 * IPython/genutils.py (Stream.__init__): Changes to try to make
2115 ipython robust against stdin/out/err being closed by the user.
2123 ipython robust against stdin/out/err being closed by the user.
2116 This is 'user error' (and blocks a normal python session, at least
2124 This is 'user error' (and blocks a normal python session, at least
2117 the stdout case). However, Ipython should be able to survive such
2125 the stdout case). However, Ipython should be able to survive such
2118 instances of abuse as gracefully as possible. To simplify the
2126 instances of abuse as gracefully as possible. To simplify the
2119 coding and maintain compatibility with Gary Bishop's Term
2127 coding and maintain compatibility with Gary Bishop's Term
2120 contributions, I've made use of classmethods for this. I think
2128 contributions, I've made use of classmethods for this. I think
2121 this introduces a dependency on python 2.2.
2129 this introduces a dependency on python 2.2.
2122
2130
2123 2004-01-13 Fernando Perez <fperez@colorado.edu>
2131 2004-01-13 Fernando Perez <fperez@colorado.edu>
2124
2132
2125 * IPython/numutils.py (exp_safe): simplified the code a bit and
2133 * IPython/numutils.py (exp_safe): simplified the code a bit and
2126 removed the need for importing the kinds module altogether.
2134 removed the need for importing the kinds module altogether.
2127
2135
2128 2004-01-06 Fernando Perez <fperez@colorado.edu>
2136 2004-01-06 Fernando Perez <fperez@colorado.edu>
2129
2137
2130 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2138 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
2131 a magic function instead, after some community feedback. No
2139 a magic function instead, after some community feedback. No
2132 special syntax will exist for it, but its name is deliberately
2140 special syntax will exist for it, but its name is deliberately
2133 very short.
2141 very short.
2134
2142
2135 2003-12-20 Fernando Perez <fperez@colorado.edu>
2143 2003-12-20 Fernando Perez <fperez@colorado.edu>
2136
2144
2137 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2145 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
2138 new functionality, to automagically assign the result of a shell
2146 new functionality, to automagically assign the result of a shell
2139 command to a variable. I'll solicit some community feedback on
2147 command to a variable. I'll solicit some community feedback on
2140 this before making it permanent.
2148 this before making it permanent.
2141
2149
2142 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2150 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
2143 requested about callables for which inspect couldn't obtain a
2151 requested about callables for which inspect couldn't obtain a
2144 proper argspec. Thanks to a crash report sent by Etienne
2152 proper argspec. Thanks to a crash report sent by Etienne
2145 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2153 Posthumus <etienne-AT-apple01.cs.vu.nl>.
2146
2154
2147 2003-12-09 Fernando Perez <fperez@colorado.edu>
2155 2003-12-09 Fernando Perez <fperez@colorado.edu>
2148
2156
2149 * IPython/genutils.py (page): patch for the pager to work across
2157 * IPython/genutils.py (page): patch for the pager to work across
2150 various versions of Windows. By Gary Bishop.
2158 various versions of Windows. By Gary Bishop.
2151
2159
2152 2003-12-04 Fernando Perez <fperez@colorado.edu>
2160 2003-12-04 Fernando Perez <fperez@colorado.edu>
2153
2161
2154 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2162 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
2155 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2163 Gnuplot.py version 1.7, whose internal names changed quite a bit.
2156 While I tested this and it looks ok, there may still be corner
2164 While I tested this and it looks ok, there may still be corner
2157 cases I've missed.
2165 cases I've missed.
2158
2166
2159 2003-12-01 Fernando Perez <fperez@colorado.edu>
2167 2003-12-01 Fernando Perez <fperez@colorado.edu>
2160
2168
2161 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2169 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
2162 where a line like 'p,q=1,2' would fail because the automagic
2170 where a line like 'p,q=1,2' would fail because the automagic
2163 system would be triggered for @p.
2171 system would be triggered for @p.
2164
2172
2165 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2173 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
2166 cleanups, code unmodified.
2174 cleanups, code unmodified.
2167
2175
2168 * IPython/genutils.py (Term): added a class for IPython to handle
2176 * IPython/genutils.py (Term): added a class for IPython to handle
2169 output. In most cases it will just be a proxy for stdout/err, but
2177 output. In most cases it will just be a proxy for stdout/err, but
2170 having this allows modifications to be made for some platforms,
2178 having this allows modifications to be made for some platforms,
2171 such as handling color escapes under Windows. All of this code
2179 such as handling color escapes under Windows. All of this code
2172 was contributed by Gary Bishop, with minor modifications by me.
2180 was contributed by Gary Bishop, with minor modifications by me.
2173 The actual changes affect many files.
2181 The actual changes affect many files.
2174
2182
2175 2003-11-30 Fernando Perez <fperez@colorado.edu>
2183 2003-11-30 Fernando Perez <fperez@colorado.edu>
2176
2184
2177 * IPython/iplib.py (file_matches): new completion code, courtesy
2185 * IPython/iplib.py (file_matches): new completion code, courtesy
2178 of Jeff Collins. This enables filename completion again under
2186 of Jeff Collins. This enables filename completion again under
2179 python 2.3, which disabled it at the C level.
2187 python 2.3, which disabled it at the C level.
2180
2188
2181 2003-11-11 Fernando Perez <fperez@colorado.edu>
2189 2003-11-11 Fernando Perez <fperez@colorado.edu>
2182
2190
2183 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2191 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
2184 for Numeric.array(map(...)), but often convenient.
2192 for Numeric.array(map(...)), but often convenient.
2185
2193
2186 2003-11-05 Fernando Perez <fperez@colorado.edu>
2194 2003-11-05 Fernando Perez <fperez@colorado.edu>
2187
2195
2188 * IPython/numutils.py (frange): Changed a call from int() to
2196 * IPython/numutils.py (frange): Changed a call from int() to
2189 int(round()) to prevent a problem reported with arange() in the
2197 int(round()) to prevent a problem reported with arange() in the
2190 numpy list.
2198 numpy list.
2191
2199
2192 2003-10-06 Fernando Perez <fperez@colorado.edu>
2200 2003-10-06 Fernando Perez <fperez@colorado.edu>
2193
2201
2194 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2202 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
2195 prevent crashes if sys lacks an argv attribute (it happens with
2203 prevent crashes if sys lacks an argv attribute (it happens with
2196 embedded interpreters which build a bare-bones sys module).
2204 embedded interpreters which build a bare-bones sys module).
2197 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2205 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
2198
2206
2199 2003-09-24 Fernando Perez <fperez@colorado.edu>
2207 2003-09-24 Fernando Perez <fperez@colorado.edu>
2200
2208
2201 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2209 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
2202 to protect against poorly written user objects where __getattr__
2210 to protect against poorly written user objects where __getattr__
2203 raises exceptions other than AttributeError. Thanks to a bug
2211 raises exceptions other than AttributeError. Thanks to a bug
2204 report by Oliver Sander <osander-AT-gmx.de>.
2212 report by Oliver Sander <osander-AT-gmx.de>.
2205
2213
2206 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2214 * IPython/FakeModule.py (FakeModule.__repr__): this method was
2207 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2215 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
2208
2216
2209 2003-09-09 Fernando Perez <fperez@colorado.edu>
2217 2003-09-09 Fernando Perez <fperez@colorado.edu>
2210
2218
2211 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2219 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2212 unpacking a list whith a callable as first element would
2220 unpacking a list whith a callable as first element would
2213 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2221 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
2214 Collins.
2222 Collins.
2215
2223
2216 2003-08-25 *** Released version 0.5.0
2224 2003-08-25 *** Released version 0.5.0
2217
2225
2218 2003-08-22 Fernando Perez <fperez@colorado.edu>
2226 2003-08-22 Fernando Perez <fperez@colorado.edu>
2219
2227
2220 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2228 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
2221 improperly defined user exceptions. Thanks to feedback from Mark
2229 improperly defined user exceptions. Thanks to feedback from Mark
2222 Russell <mrussell-AT-verio.net>.
2230 Russell <mrussell-AT-verio.net>.
2223
2231
2224 2003-08-20 Fernando Perez <fperez@colorado.edu>
2232 2003-08-20 Fernando Perez <fperez@colorado.edu>
2225
2233
2226 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2234 * IPython/OInspect.py (Inspector.pinfo): changed String Form
2227 printing so that it would print multi-line string forms starting
2235 printing so that it would print multi-line string forms starting
2228 with a new line. This way the formatting is better respected for
2236 with a new line. This way the formatting is better respected for
2229 objects which work hard to make nice string forms.
2237 objects which work hard to make nice string forms.
2230
2238
2231 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2239 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
2232 autocall would overtake data access for objects with both
2240 autocall would overtake data access for objects with both
2233 __getitem__ and __call__.
2241 __getitem__ and __call__.
2234
2242
2235 2003-08-19 *** Released version 0.5.0-rc1
2243 2003-08-19 *** Released version 0.5.0-rc1
2236
2244
2237 2003-08-19 Fernando Perez <fperez@colorado.edu>
2245 2003-08-19 Fernando Perez <fperez@colorado.edu>
2238
2246
2239 * IPython/deep_reload.py (load_tail): single tiny change here
2247 * IPython/deep_reload.py (load_tail): single tiny change here
2240 seems to fix the long-standing bug of dreload() failing to work
2248 seems to fix the long-standing bug of dreload() failing to work
2241 for dotted names. But this module is pretty tricky, so I may have
2249 for dotted names. But this module is pretty tricky, so I may have
2242 missed some subtlety. Needs more testing!.
2250 missed some subtlety. Needs more testing!.
2243
2251
2244 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2252 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
2245 exceptions which have badly implemented __str__ methods.
2253 exceptions which have badly implemented __str__ methods.
2246 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2254 (VerboseTB.text): harden against inspect.getinnerframes crashing,
2247 which I've been getting reports about from Python 2.3 users. I
2255 which I've been getting reports about from Python 2.3 users. I
2248 wish I had a simple test case to reproduce the problem, so I could
2256 wish I had a simple test case to reproduce the problem, so I could
2249 either write a cleaner workaround or file a bug report if
2257 either write a cleaner workaround or file a bug report if
2250 necessary.
2258 necessary.
2251
2259
2252 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2260 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
2253 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2261 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
2254 a bug report by Tjabo Kloppenburg.
2262 a bug report by Tjabo Kloppenburg.
2255
2263
2256 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2264 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
2257 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2265 crashes. Wrapped the pdb call in a blanket try/except, since pdb
2258 seems rather unstable. Thanks to a bug report by Tjabo
2266 seems rather unstable. Thanks to a bug report by Tjabo
2259 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2267 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
2260
2268
2261 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2269 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
2262 this out soon because of the critical fixes in the inner loop for
2270 this out soon because of the critical fixes in the inner loop for
2263 generators.
2271 generators.
2264
2272
2265 * IPython/Magic.py (Magic.getargspec): removed. This (and
2273 * IPython/Magic.py (Magic.getargspec): removed. This (and
2266 _get_def) have been obsoleted by OInspect for a long time, I
2274 _get_def) have been obsoleted by OInspect for a long time, I
2267 hadn't noticed that they were dead code.
2275 hadn't noticed that they were dead code.
2268 (Magic._ofind): restored _ofind functionality for a few literals
2276 (Magic._ofind): restored _ofind functionality for a few literals
2269 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2277 (those in ["''",'""','[]','{}','()']). But it won't work anymore
2270 for things like "hello".capitalize?, since that would require a
2278 for things like "hello".capitalize?, since that would require a
2271 potentially dangerous eval() again.
2279 potentially dangerous eval() again.
2272
2280
2273 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2281 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
2274 logic a bit more to clean up the escapes handling and minimize the
2282 logic a bit more to clean up the escapes handling and minimize the
2275 use of _ofind to only necessary cases. The interactive 'feel' of
2283 use of _ofind to only necessary cases. The interactive 'feel' of
2276 IPython should have improved quite a bit with the changes in
2284 IPython should have improved quite a bit with the changes in
2277 _prefilter and _ofind (besides being far safer than before).
2285 _prefilter and _ofind (besides being far safer than before).
2278
2286
2279 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2287 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
2280 obscure, never reported). Edit would fail to find the object to
2288 obscure, never reported). Edit would fail to find the object to
2281 edit under some circumstances.
2289 edit under some circumstances.
2282 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2290 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
2283 which were causing double-calling of generators. Those eval calls
2291 which were causing double-calling of generators. Those eval calls
2284 were _very_ dangerous, since code with side effects could be
2292 were _very_ dangerous, since code with side effects could be
2285 triggered. As they say, 'eval is evil'... These were the
2293 triggered. As they say, 'eval is evil'... These were the
2286 nastiest evals in IPython. Besides, _ofind is now far simpler,
2294 nastiest evals in IPython. Besides, _ofind is now far simpler,
2287 and it should also be quite a bit faster. Its use of inspect is
2295 and it should also be quite a bit faster. Its use of inspect is
2288 also safer, so perhaps some of the inspect-related crashes I've
2296 also safer, so perhaps some of the inspect-related crashes I've
2289 seen lately with Python 2.3 might be taken care of. That will
2297 seen lately with Python 2.3 might be taken care of. That will
2290 need more testing.
2298 need more testing.
2291
2299
2292 2003-08-17 Fernando Perez <fperez@colorado.edu>
2300 2003-08-17 Fernando Perez <fperez@colorado.edu>
2293
2301
2294 * IPython/iplib.py (InteractiveShell._prefilter): significant
2302 * IPython/iplib.py (InteractiveShell._prefilter): significant
2295 simplifications to the logic for handling user escapes. Faster
2303 simplifications to the logic for handling user escapes. Faster
2296 and simpler code.
2304 and simpler code.
2297
2305
2298 2003-08-14 Fernando Perez <fperez@colorado.edu>
2306 2003-08-14 Fernando Perez <fperez@colorado.edu>
2299
2307
2300 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2308 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
2301 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2309 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
2302 but it should be quite a bit faster. And the recursive version
2310 but it should be quite a bit faster. And the recursive version
2303 generated O(log N) intermediate storage for all rank>1 arrays,
2311 generated O(log N) intermediate storage for all rank>1 arrays,
2304 even if they were contiguous.
2312 even if they were contiguous.
2305 (l1norm): Added this function.
2313 (l1norm): Added this function.
2306 (norm): Added this function for arbitrary norms (including
2314 (norm): Added this function for arbitrary norms (including
2307 l-infinity). l1 and l2 are still special cases for convenience
2315 l-infinity). l1 and l2 are still special cases for convenience
2308 and speed.
2316 and speed.
2309
2317
2310 2003-08-03 Fernando Perez <fperez@colorado.edu>
2318 2003-08-03 Fernando Perez <fperez@colorado.edu>
2311
2319
2312 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2320 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
2313 exceptions, which now raise PendingDeprecationWarnings in Python
2321 exceptions, which now raise PendingDeprecationWarnings in Python
2314 2.3. There were some in Magic and some in Gnuplot2.
2322 2.3. There were some in Magic and some in Gnuplot2.
2315
2323
2316 2003-06-30 Fernando Perez <fperez@colorado.edu>
2324 2003-06-30 Fernando Perez <fperez@colorado.edu>
2317
2325
2318 * IPython/genutils.py (page): modified to call curses only for
2326 * IPython/genutils.py (page): modified to call curses only for
2319 terminals where TERM=='xterm'. After problems under many other
2327 terminals where TERM=='xterm'. After problems under many other
2320 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2328 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
2321
2329
2322 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2330 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
2323 would be triggered when readline was absent. This was just an old
2331 would be triggered when readline was absent. This was just an old
2324 debugging statement I'd forgotten to take out.
2332 debugging statement I'd forgotten to take out.
2325
2333
2326 2003-06-20 Fernando Perez <fperez@colorado.edu>
2334 2003-06-20 Fernando Perez <fperez@colorado.edu>
2327
2335
2328 * IPython/genutils.py (clock): modified to return only user time
2336 * IPython/genutils.py (clock): modified to return only user time
2329 (not counting system time), after a discussion on scipy. While
2337 (not counting system time), after a discussion on scipy. While
2330 system time may be a useful quantity occasionally, it may much
2338 system time may be a useful quantity occasionally, it may much
2331 more easily be skewed by occasional swapping or other similar
2339 more easily be skewed by occasional swapping or other similar
2332 activity.
2340 activity.
2333
2341
2334 2003-06-05 Fernando Perez <fperez@colorado.edu>
2342 2003-06-05 Fernando Perez <fperez@colorado.edu>
2335
2343
2336 * IPython/numutils.py (identity): new function, for building
2344 * IPython/numutils.py (identity): new function, for building
2337 arbitrary rank Kronecker deltas (mostly backwards compatible with
2345 arbitrary rank Kronecker deltas (mostly backwards compatible with
2338 Numeric.identity)
2346 Numeric.identity)
2339
2347
2340 2003-06-03 Fernando Perez <fperez@colorado.edu>
2348 2003-06-03 Fernando Perez <fperez@colorado.edu>
2341
2349
2342 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2350 * IPython/iplib.py (InteractiveShell.handle_magic): protect
2343 arguments passed to magics with spaces, to allow trailing '\' to
2351 arguments passed to magics with spaces, to allow trailing '\' to
2344 work normally (mainly for Windows users).
2352 work normally (mainly for Windows users).
2345
2353
2346 2003-05-29 Fernando Perez <fperez@colorado.edu>
2354 2003-05-29 Fernando Perez <fperez@colorado.edu>
2347
2355
2348 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2356 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
2349 instead of pydoc.help. This fixes a bizarre behavior where
2357 instead of pydoc.help. This fixes a bizarre behavior where
2350 printing '%s' % locals() would trigger the help system. Now
2358 printing '%s' % locals() would trigger the help system. Now
2351 ipython behaves like normal python does.
2359 ipython behaves like normal python does.
2352
2360
2353 Note that if one does 'from pydoc import help', the bizarre
2361 Note that if one does 'from pydoc import help', the bizarre
2354 behavior returns, but this will also happen in normal python, so
2362 behavior returns, but this will also happen in normal python, so
2355 it's not an ipython bug anymore (it has to do with how pydoc.help
2363 it's not an ipython bug anymore (it has to do with how pydoc.help
2356 is implemented).
2364 is implemented).
2357
2365
2358 2003-05-22 Fernando Perez <fperez@colorado.edu>
2366 2003-05-22 Fernando Perez <fperez@colorado.edu>
2359
2367
2360 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2368 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
2361 return [] instead of None when nothing matches, also match to end
2369 return [] instead of None when nothing matches, also match to end
2362 of line. Patch by Gary Bishop.
2370 of line. Patch by Gary Bishop.
2363
2371
2364 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2372 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
2365 protection as before, for files passed on the command line. This
2373 protection as before, for files passed on the command line. This
2366 prevents the CrashHandler from kicking in if user files call into
2374 prevents the CrashHandler from kicking in if user files call into
2367 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2375 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
2368 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2376 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
2369
2377
2370 2003-05-20 *** Released version 0.4.0
2378 2003-05-20 *** Released version 0.4.0
2371
2379
2372 2003-05-20 Fernando Perez <fperez@colorado.edu>
2380 2003-05-20 Fernando Perez <fperez@colorado.edu>
2373
2381
2374 * setup.py: added support for manpages. It's a bit hackish b/c of
2382 * setup.py: added support for manpages. It's a bit hackish b/c of
2375 a bug in the way the bdist_rpm distutils target handles gzipped
2383 a bug in the way the bdist_rpm distutils target handles gzipped
2376 manpages, but it works. After a patch by Jack.
2384 manpages, but it works. After a patch by Jack.
2377
2385
2378 2003-05-19 Fernando Perez <fperez@colorado.edu>
2386 2003-05-19 Fernando Perez <fperez@colorado.edu>
2379
2387
2380 * IPython/numutils.py: added a mockup of the kinds module, since
2388 * IPython/numutils.py: added a mockup of the kinds module, since
2381 it was recently removed from Numeric. This way, numutils will
2389 it was recently removed from Numeric. This way, numutils will
2382 work for all users even if they are missing kinds.
2390 work for all users even if they are missing kinds.
2383
2391
2384 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2392 * IPython/Magic.py (Magic._ofind): Harden against an inspect
2385 failure, which can occur with SWIG-wrapped extensions. After a
2393 failure, which can occur with SWIG-wrapped extensions. After a
2386 crash report from Prabhu.
2394 crash report from Prabhu.
2387
2395
2388 2003-05-16 Fernando Perez <fperez@colorado.edu>
2396 2003-05-16 Fernando Perez <fperez@colorado.edu>
2389
2397
2390 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2398 * IPython/iplib.py (InteractiveShell.excepthook): New method to
2391 protect ipython from user code which may call directly
2399 protect ipython from user code which may call directly
2392 sys.excepthook (this looks like an ipython crash to the user, even
2400 sys.excepthook (this looks like an ipython crash to the user, even
2393 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2401 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2394 This is especially important to help users of WxWindows, but may
2402 This is especially important to help users of WxWindows, but may
2395 also be useful in other cases.
2403 also be useful in other cases.
2396
2404
2397 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2405 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
2398 an optional tb_offset to be specified, and to preserve exception
2406 an optional tb_offset to be specified, and to preserve exception
2399 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2407 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
2400
2408
2401 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2409 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
2402
2410
2403 2003-05-15 Fernando Perez <fperez@colorado.edu>
2411 2003-05-15 Fernando Perez <fperez@colorado.edu>
2404
2412
2405 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2413 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
2406 installing for a new user under Windows.
2414 installing for a new user under Windows.
2407
2415
2408 2003-05-12 Fernando Perez <fperez@colorado.edu>
2416 2003-05-12 Fernando Perez <fperez@colorado.edu>
2409
2417
2410 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2418 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
2411 handler for Emacs comint-based lines. Currently it doesn't do
2419 handler for Emacs comint-based lines. Currently it doesn't do
2412 much (but importantly, it doesn't update the history cache). In
2420 much (but importantly, it doesn't update the history cache). In
2413 the future it may be expanded if Alex needs more functionality
2421 the future it may be expanded if Alex needs more functionality
2414 there.
2422 there.
2415
2423
2416 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2424 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
2417 info to crash reports.
2425 info to crash reports.
2418
2426
2419 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2427 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
2420 just like Python's -c. Also fixed crash with invalid -color
2428 just like Python's -c. Also fixed crash with invalid -color
2421 option value at startup. Thanks to Will French
2429 option value at startup. Thanks to Will French
2422 <wfrench-AT-bestweb.net> for the bug report.
2430 <wfrench-AT-bestweb.net> for the bug report.
2423
2431
2424 2003-05-09 Fernando Perez <fperez@colorado.edu>
2432 2003-05-09 Fernando Perez <fperez@colorado.edu>
2425
2433
2426 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2434 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
2427 to EvalDict (it's a mapping, after all) and simplified its code
2435 to EvalDict (it's a mapping, after all) and simplified its code
2428 quite a bit, after a nice discussion on c.l.py where Gustavo
2436 quite a bit, after a nice discussion on c.l.py where Gustavo
2429 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
2437 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
2430
2438
2431 2003-04-30 Fernando Perez <fperez@colorado.edu>
2439 2003-04-30 Fernando Perez <fperez@colorado.edu>
2432
2440
2433 * IPython/genutils.py (timings_out): modified it to reduce its
2441 * IPython/genutils.py (timings_out): modified it to reduce its
2434 overhead in the common reps==1 case.
2442 overhead in the common reps==1 case.
2435
2443
2436 2003-04-29 Fernando Perez <fperez@colorado.edu>
2444 2003-04-29 Fernando Perez <fperez@colorado.edu>
2437
2445
2438 * IPython/genutils.py (timings_out): Modified to use the resource
2446 * IPython/genutils.py (timings_out): Modified to use the resource
2439 module, which avoids the wraparound problems of time.clock().
2447 module, which avoids the wraparound problems of time.clock().
2440
2448
2441 2003-04-17 *** Released version 0.2.15pre4
2449 2003-04-17 *** Released version 0.2.15pre4
2442
2450
2443 2003-04-17 Fernando Perez <fperez@colorado.edu>
2451 2003-04-17 Fernando Perez <fperez@colorado.edu>
2444
2452
2445 * setup.py (scriptfiles): Split windows-specific stuff over to a
2453 * setup.py (scriptfiles): Split windows-specific stuff over to a
2446 separate file, in an attempt to have a Windows GUI installer.
2454 separate file, in an attempt to have a Windows GUI installer.
2447 That didn't work, but part of the groundwork is done.
2455 That didn't work, but part of the groundwork is done.
2448
2456
2449 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2457 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
2450 indent/unindent with 4 spaces. Particularly useful in combination
2458 indent/unindent with 4 spaces. Particularly useful in combination
2451 with the new auto-indent option.
2459 with the new auto-indent option.
2452
2460
2453 2003-04-16 Fernando Perez <fperez@colorado.edu>
2461 2003-04-16 Fernando Perez <fperez@colorado.edu>
2454
2462
2455 * IPython/Magic.py: various replacements of self.rc for
2463 * IPython/Magic.py: various replacements of self.rc for
2456 self.shell.rc. A lot more remains to be done to fully disentangle
2464 self.shell.rc. A lot more remains to be done to fully disentangle
2457 this class from the main Shell class.
2465 this class from the main Shell class.
2458
2466
2459 * IPython/GnuplotRuntime.py: added checks for mouse support so
2467 * IPython/GnuplotRuntime.py: added checks for mouse support so
2460 that we don't try to enable it if the current gnuplot doesn't
2468 that we don't try to enable it if the current gnuplot doesn't
2461 really support it. Also added checks so that we don't try to
2469 really support it. Also added checks so that we don't try to
2462 enable persist under Windows (where Gnuplot doesn't recognize the
2470 enable persist under Windows (where Gnuplot doesn't recognize the
2463 option).
2471 option).
2464
2472
2465 * IPython/iplib.py (InteractiveShell.interact): Added optional
2473 * IPython/iplib.py (InteractiveShell.interact): Added optional
2466 auto-indenting code, after a patch by King C. Shu
2474 auto-indenting code, after a patch by King C. Shu
2467 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2475 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
2468 get along well with pasting indented code. If I ever figure out
2476 get along well with pasting indented code. If I ever figure out
2469 how to make that part go well, it will become on by default.
2477 how to make that part go well, it will become on by default.
2470
2478
2471 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2479 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
2472 crash ipython if there was an unmatched '%' in the user's prompt
2480 crash ipython if there was an unmatched '%' in the user's prompt
2473 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2481 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2474
2482
2475 * IPython/iplib.py (InteractiveShell.interact): removed the
2483 * IPython/iplib.py (InteractiveShell.interact): removed the
2476 ability to ask the user whether he wants to crash or not at the
2484 ability to ask the user whether he wants to crash or not at the
2477 'last line' exception handler. Calling functions at that point
2485 'last line' exception handler. Calling functions at that point
2478 changes the stack, and the error reports would have incorrect
2486 changes the stack, and the error reports would have incorrect
2479 tracebacks.
2487 tracebacks.
2480
2488
2481 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2489 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
2482 pass through a peger a pretty-printed form of any object. After a
2490 pass through a peger a pretty-printed form of any object. After a
2483 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2491 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
2484
2492
2485 2003-04-14 Fernando Perez <fperez@colorado.edu>
2493 2003-04-14 Fernando Perez <fperez@colorado.edu>
2486
2494
2487 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2495 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
2488 all files in ~ would be modified at first install (instead of
2496 all files in ~ would be modified at first install (instead of
2489 ~/.ipython). This could be potentially disastrous, as the
2497 ~/.ipython). This could be potentially disastrous, as the
2490 modification (make line-endings native) could damage binary files.
2498 modification (make line-endings native) could damage binary files.
2491
2499
2492 2003-04-10 Fernando Perez <fperez@colorado.edu>
2500 2003-04-10 Fernando Perez <fperez@colorado.edu>
2493
2501
2494 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2502 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
2495 handle only lines which are invalid python. This now means that
2503 handle only lines which are invalid python. This now means that
2496 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2504 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
2497 for the bug report.
2505 for the bug report.
2498
2506
2499 2003-04-01 Fernando Perez <fperez@colorado.edu>
2507 2003-04-01 Fernando Perez <fperez@colorado.edu>
2500
2508
2501 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2509 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
2502 where failing to set sys.last_traceback would crash pdb.pm().
2510 where failing to set sys.last_traceback would crash pdb.pm().
2503 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2511 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
2504 report.
2512 report.
2505
2513
2506 2003-03-25 Fernando Perez <fperez@colorado.edu>
2514 2003-03-25 Fernando Perez <fperez@colorado.edu>
2507
2515
2508 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2516 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
2509 before printing it (it had a lot of spurious blank lines at the
2517 before printing it (it had a lot of spurious blank lines at the
2510 end).
2518 end).
2511
2519
2512 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2520 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
2513 output would be sent 21 times! Obviously people don't use this
2521 output would be sent 21 times! Obviously people don't use this
2514 too often, or I would have heard about it.
2522 too often, or I would have heard about it.
2515
2523
2516 2003-03-24 Fernando Perez <fperez@colorado.edu>
2524 2003-03-24 Fernando Perez <fperez@colorado.edu>
2517
2525
2518 * setup.py (scriptfiles): renamed the data_files parameter from
2526 * setup.py (scriptfiles): renamed the data_files parameter from
2519 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2527 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
2520 for the patch.
2528 for the patch.
2521
2529
2522 2003-03-20 Fernando Perez <fperez@colorado.edu>
2530 2003-03-20 Fernando Perez <fperez@colorado.edu>
2523
2531
2524 * IPython/genutils.py (error): added error() and fatal()
2532 * IPython/genutils.py (error): added error() and fatal()
2525 functions.
2533 functions.
2526
2534
2527 2003-03-18 *** Released version 0.2.15pre3
2535 2003-03-18 *** Released version 0.2.15pre3
2528
2536
2529 2003-03-18 Fernando Perez <fperez@colorado.edu>
2537 2003-03-18 Fernando Perez <fperez@colorado.edu>
2530
2538
2531 * setupext/install_data_ext.py
2539 * setupext/install_data_ext.py
2532 (install_data_ext.initialize_options): Class contributed by Jack
2540 (install_data_ext.initialize_options): Class contributed by Jack
2533 Moffit for fixing the old distutils hack. He is sending this to
2541 Moffit for fixing the old distutils hack. He is sending this to
2534 the distutils folks so in the future we may not need it as a
2542 the distutils folks so in the future we may not need it as a
2535 private fix.
2543 private fix.
2536
2544
2537 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2545 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
2538 changes for Debian packaging. See his patch for full details.
2546 changes for Debian packaging. See his patch for full details.
2539 The old distutils hack of making the ipythonrc* files carry a
2547 The old distutils hack of making the ipythonrc* files carry a
2540 bogus .py extension is gone, at last. Examples were moved to a
2548 bogus .py extension is gone, at last. Examples were moved to a
2541 separate subdir under doc/, and the separate executable scripts
2549 separate subdir under doc/, and the separate executable scripts
2542 now live in their own directory. Overall a great cleanup. The
2550 now live in their own directory. Overall a great cleanup. The
2543 manual was updated to use the new files, and setup.py has been
2551 manual was updated to use the new files, and setup.py has been
2544 fixed for this setup.
2552 fixed for this setup.
2545
2553
2546 * IPython/PyColorize.py (Parser.usage): made non-executable and
2554 * IPython/PyColorize.py (Parser.usage): made non-executable and
2547 created a pycolor wrapper around it to be included as a script.
2555 created a pycolor wrapper around it to be included as a script.
2548
2556
2549 2003-03-12 *** Released version 0.2.15pre2
2557 2003-03-12 *** Released version 0.2.15pre2
2550
2558
2551 2003-03-12 Fernando Perez <fperez@colorado.edu>
2559 2003-03-12 Fernando Perez <fperez@colorado.edu>
2552
2560
2553 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2561 * IPython/ColorANSI.py (make_color_table): Finally fixed the
2554 long-standing problem with garbage characters in some terminals.
2562 long-standing problem with garbage characters in some terminals.
2555 The issue was really that the \001 and \002 escapes must _only_ be
2563 The issue was really that the \001 and \002 escapes must _only_ be
2556 passed to input prompts (which call readline), but _never_ to
2564 passed to input prompts (which call readline), but _never_ to
2557 normal text to be printed on screen. I changed ColorANSI to have
2565 normal text to be printed on screen. I changed ColorANSI to have
2558 two classes: TermColors and InputTermColors, each with the
2566 two classes: TermColors and InputTermColors, each with the
2559 appropriate escapes for input prompts or normal text. The code in
2567 appropriate escapes for input prompts or normal text. The code in
2560 Prompts.py got slightly more complicated, but this very old and
2568 Prompts.py got slightly more complicated, but this very old and
2561 annoying bug is finally fixed.
2569 annoying bug is finally fixed.
2562
2570
2563 All the credit for nailing down the real origin of this problem
2571 All the credit for nailing down the real origin of this problem
2564 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2572 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
2565 *Many* thanks to him for spending quite a bit of effort on this.
2573 *Many* thanks to him for spending quite a bit of effort on this.
2566
2574
2567 2003-03-05 *** Released version 0.2.15pre1
2575 2003-03-05 *** Released version 0.2.15pre1
2568
2576
2569 2003-03-03 Fernando Perez <fperez@colorado.edu>
2577 2003-03-03 Fernando Perez <fperez@colorado.edu>
2570
2578
2571 * IPython/FakeModule.py: Moved the former _FakeModule to a
2579 * IPython/FakeModule.py: Moved the former _FakeModule to a
2572 separate file, because it's also needed by Magic (to fix a similar
2580 separate file, because it's also needed by Magic (to fix a similar
2573 pickle-related issue in @run).
2581 pickle-related issue in @run).
2574
2582
2575 2003-03-02 Fernando Perez <fperez@colorado.edu>
2583 2003-03-02 Fernando Perez <fperez@colorado.edu>
2576
2584
2577 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2585 * IPython/Magic.py (Magic.magic_autocall): new magic to control
2578 the autocall option at runtime.
2586 the autocall option at runtime.
2579 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2587 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
2580 across Magic.py to start separating Magic from InteractiveShell.
2588 across Magic.py to start separating Magic from InteractiveShell.
2581 (Magic._ofind): Fixed to return proper namespace for dotted
2589 (Magic._ofind): Fixed to return proper namespace for dotted
2582 names. Before, a dotted name would always return 'not currently
2590 names. Before, a dotted name would always return 'not currently
2583 defined', because it would find the 'parent'. s.x would be found,
2591 defined', because it would find the 'parent'. s.x would be found,
2584 but since 'x' isn't defined by itself, it would get confused.
2592 but since 'x' isn't defined by itself, it would get confused.
2585 (Magic.magic_run): Fixed pickling problems reported by Ralf
2593 (Magic.magic_run): Fixed pickling problems reported by Ralf
2586 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2594 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
2587 that I'd used when Mike Heeter reported similar issues at the
2595 that I'd used when Mike Heeter reported similar issues at the
2588 top-level, but now for @run. It boils down to injecting the
2596 top-level, but now for @run. It boils down to injecting the
2589 namespace where code is being executed with something that looks
2597 namespace where code is being executed with something that looks
2590 enough like a module to fool pickle.dump(). Since a pickle stores
2598 enough like a module to fool pickle.dump(). Since a pickle stores
2591 a named reference to the importing module, we need this for
2599 a named reference to the importing module, we need this for
2592 pickles to save something sensible.
2600 pickles to save something sensible.
2593
2601
2594 * IPython/ipmaker.py (make_IPython): added an autocall option.
2602 * IPython/ipmaker.py (make_IPython): added an autocall option.
2595
2603
2596 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2604 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
2597 the auto-eval code. Now autocalling is an option, and the code is
2605 the auto-eval code. Now autocalling is an option, and the code is
2598 also vastly safer. There is no more eval() involved at all.
2606 also vastly safer. There is no more eval() involved at all.
2599
2607
2600 2003-03-01 Fernando Perez <fperez@colorado.edu>
2608 2003-03-01 Fernando Perez <fperez@colorado.edu>
2601
2609
2602 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2610 * IPython/Magic.py (Magic._ofind): Changed interface to return a
2603 dict with named keys instead of a tuple.
2611 dict with named keys instead of a tuple.
2604
2612
2605 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2613 * IPython: Started using CVS for IPython as of 0.2.15pre1.
2606
2614
2607 * setup.py (make_shortcut): Fixed message about directories
2615 * setup.py (make_shortcut): Fixed message about directories
2608 created during Windows installation (the directories were ok, just
2616 created during Windows installation (the directories were ok, just
2609 the printed message was misleading). Thanks to Chris Liechti
2617 the printed message was misleading). Thanks to Chris Liechti
2610 <cliechti-AT-gmx.net> for the heads up.
2618 <cliechti-AT-gmx.net> for the heads up.
2611
2619
2612 2003-02-21 Fernando Perez <fperez@colorado.edu>
2620 2003-02-21 Fernando Perez <fperez@colorado.edu>
2613
2621
2614 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2622 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
2615 of ValueError exception when checking for auto-execution. This
2623 of ValueError exception when checking for auto-execution. This
2616 one is raised by things like Numeric arrays arr.flat when the
2624 one is raised by things like Numeric arrays arr.flat when the
2617 array is non-contiguous.
2625 array is non-contiguous.
2618
2626
2619 2003-01-31 Fernando Perez <fperez@colorado.edu>
2627 2003-01-31 Fernando Perez <fperez@colorado.edu>
2620
2628
2621 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2629 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
2622 not return any value at all (even though the command would get
2630 not return any value at all (even though the command would get
2623 executed).
2631 executed).
2624 (xsys): Flush stdout right after printing the command to ensure
2632 (xsys): Flush stdout right after printing the command to ensure
2625 proper ordering of commands and command output in the total
2633 proper ordering of commands and command output in the total
2626 output.
2634 output.
2627 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2635 (SystemExec/xsys/bq): Switched the names of xsys/bq and
2628 system/getoutput as defaults. The old ones are kept for
2636 system/getoutput as defaults. The old ones are kept for
2629 compatibility reasons, so no code which uses this library needs
2637 compatibility reasons, so no code which uses this library needs
2630 changing.
2638 changing.
2631
2639
2632 2003-01-27 *** Released version 0.2.14
2640 2003-01-27 *** Released version 0.2.14
2633
2641
2634 2003-01-25 Fernando Perez <fperez@colorado.edu>
2642 2003-01-25 Fernando Perez <fperez@colorado.edu>
2635
2643
2636 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2644 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
2637 functions defined in previous edit sessions could not be re-edited
2645 functions defined in previous edit sessions could not be re-edited
2638 (because the temp files were immediately removed). Now temp files
2646 (because the temp files were immediately removed). Now temp files
2639 are removed only at IPython's exit.
2647 are removed only at IPython's exit.
2640 (Magic.magic_run): Improved @run to perform shell-like expansions
2648 (Magic.magic_run): Improved @run to perform shell-like expansions
2641 on its arguments (~users and $VARS). With this, @run becomes more
2649 on its arguments (~users and $VARS). With this, @run becomes more
2642 like a normal command-line.
2650 like a normal command-line.
2643
2651
2644 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2652 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
2645 bugs related to embedding and cleaned up that code. A fairly
2653 bugs related to embedding and cleaned up that code. A fairly
2646 important one was the impossibility to access the global namespace
2654 important one was the impossibility to access the global namespace
2647 through the embedded IPython (only local variables were visible).
2655 through the embedded IPython (only local variables were visible).
2648
2656
2649 2003-01-14 Fernando Perez <fperez@colorado.edu>
2657 2003-01-14 Fernando Perez <fperez@colorado.edu>
2650
2658
2651 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2659 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
2652 auto-calling to be a bit more conservative. Now it doesn't get
2660 auto-calling to be a bit more conservative. Now it doesn't get
2653 triggered if any of '!=()<>' are in the rest of the input line, to
2661 triggered if any of '!=()<>' are in the rest of the input line, to
2654 allow comparing callables. Thanks to Alex for the heads up.
2662 allow comparing callables. Thanks to Alex for the heads up.
2655
2663
2656 2003-01-07 Fernando Perez <fperez@colorado.edu>
2664 2003-01-07 Fernando Perez <fperez@colorado.edu>
2657
2665
2658 * IPython/genutils.py (page): fixed estimation of the number of
2666 * IPython/genutils.py (page): fixed estimation of the number of
2659 lines in a string to be paged to simply count newlines. This
2667 lines in a string to be paged to simply count newlines. This
2660 prevents over-guessing due to embedded escape sequences. A better
2668 prevents over-guessing due to embedded escape sequences. A better
2661 long-term solution would involve stripping out the control chars
2669 long-term solution would involve stripping out the control chars
2662 for the count, but it's potentially so expensive I just don't
2670 for the count, but it's potentially so expensive I just don't
2663 think it's worth doing.
2671 think it's worth doing.
2664
2672
2665 2002-12-19 *** Released version 0.2.14pre50
2673 2002-12-19 *** Released version 0.2.14pre50
2666
2674
2667 2002-12-19 Fernando Perez <fperez@colorado.edu>
2675 2002-12-19 Fernando Perez <fperez@colorado.edu>
2668
2676
2669 * tools/release (version): Changed release scripts to inform
2677 * tools/release (version): Changed release scripts to inform
2670 Andrea and build a NEWS file with a list of recent changes.
2678 Andrea and build a NEWS file with a list of recent changes.
2671
2679
2672 * IPython/ColorANSI.py (__all__): changed terminal detection
2680 * IPython/ColorANSI.py (__all__): changed terminal detection
2673 code. Seems to work better for xterms without breaking
2681 code. Seems to work better for xterms without breaking
2674 konsole. Will need more testing to determine if WinXP and Mac OSX
2682 konsole. Will need more testing to determine if WinXP and Mac OSX
2675 also work ok.
2683 also work ok.
2676
2684
2677 2002-12-18 *** Released version 0.2.14pre49
2685 2002-12-18 *** Released version 0.2.14pre49
2678
2686
2679 2002-12-18 Fernando Perez <fperez@colorado.edu>
2687 2002-12-18 Fernando Perez <fperez@colorado.edu>
2680
2688
2681 * Docs: added new info about Mac OSX, from Andrea.
2689 * Docs: added new info about Mac OSX, from Andrea.
2682
2690
2683 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2691 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
2684 allow direct plotting of python strings whose format is the same
2692 allow direct plotting of python strings whose format is the same
2685 of gnuplot data files.
2693 of gnuplot data files.
2686
2694
2687 2002-12-16 Fernando Perez <fperez@colorado.edu>
2695 2002-12-16 Fernando Perez <fperez@colorado.edu>
2688
2696
2689 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2697 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
2690 value of exit question to be acknowledged.
2698 value of exit question to be acknowledged.
2691
2699
2692 2002-12-03 Fernando Perez <fperez@colorado.edu>
2700 2002-12-03 Fernando Perez <fperez@colorado.edu>
2693
2701
2694 * IPython/ipmaker.py: removed generators, which had been added
2702 * IPython/ipmaker.py: removed generators, which had been added
2695 by mistake in an earlier debugging run. This was causing trouble
2703 by mistake in an earlier debugging run. This was causing trouble
2696 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2704 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
2697 for pointing this out.
2705 for pointing this out.
2698
2706
2699 2002-11-17 Fernando Perez <fperez@colorado.edu>
2707 2002-11-17 Fernando Perez <fperez@colorado.edu>
2700
2708
2701 * Manual: updated the Gnuplot section.
2709 * Manual: updated the Gnuplot section.
2702
2710
2703 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2711 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
2704 a much better split of what goes in Runtime and what goes in
2712 a much better split of what goes in Runtime and what goes in
2705 Interactive.
2713 Interactive.
2706
2714
2707 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2715 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
2708 being imported from iplib.
2716 being imported from iplib.
2709
2717
2710 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2718 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
2711 for command-passing. Now the global Gnuplot instance is called
2719 for command-passing. Now the global Gnuplot instance is called
2712 'gp' instead of 'g', which was really a far too fragile and
2720 'gp' instead of 'g', which was really a far too fragile and
2713 common name.
2721 common name.
2714
2722
2715 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2723 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
2716 bounding boxes generated by Gnuplot for square plots.
2724 bounding boxes generated by Gnuplot for square plots.
2717
2725
2718 * IPython/genutils.py (popkey): new function added. I should
2726 * IPython/genutils.py (popkey): new function added. I should
2719 suggest this on c.l.py as a dict method, it seems useful.
2727 suggest this on c.l.py as a dict method, it seems useful.
2720
2728
2721 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2729 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
2722 to transparently handle PostScript generation. MUCH better than
2730 to transparently handle PostScript generation. MUCH better than
2723 the previous plot_eps/replot_eps (which I removed now). The code
2731 the previous plot_eps/replot_eps (which I removed now). The code
2724 is also fairly clean and well documented now (including
2732 is also fairly clean and well documented now (including
2725 docstrings).
2733 docstrings).
2726
2734
2727 2002-11-13 Fernando Perez <fperez@colorado.edu>
2735 2002-11-13 Fernando Perez <fperez@colorado.edu>
2728
2736
2729 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2737 * IPython/Magic.py (Magic.magic_edit): fixed docstring
2730 (inconsistent with options).
2738 (inconsistent with options).
2731
2739
2732 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2740 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
2733 manually disabled, I don't know why. Fixed it.
2741 manually disabled, I don't know why. Fixed it.
2734 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2742 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
2735 eps output.
2743 eps output.
2736
2744
2737 2002-11-12 Fernando Perez <fperez@colorado.edu>
2745 2002-11-12 Fernando Perez <fperez@colorado.edu>
2738
2746
2739 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2747 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
2740 don't propagate up to caller. Fixes crash reported by François
2748 don't propagate up to caller. Fixes crash reported by François
2741 Pinard.
2749 Pinard.
2742
2750
2743 2002-11-09 Fernando Perez <fperez@colorado.edu>
2751 2002-11-09 Fernando Perez <fperez@colorado.edu>
2744
2752
2745 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2753 * IPython/ipmaker.py (make_IPython): fixed problem with writing
2746 history file for new users.
2754 history file for new users.
2747 (make_IPython): fixed bug where initial install would leave the
2755 (make_IPython): fixed bug where initial install would leave the
2748 user running in the .ipython dir.
2756 user running in the .ipython dir.
2749 (make_IPython): fixed bug where config dir .ipython would be
2757 (make_IPython): fixed bug where config dir .ipython would be
2750 created regardless of the given -ipythondir option. Thanks to Cory
2758 created regardless of the given -ipythondir option. Thanks to Cory
2751 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2759 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
2752
2760
2753 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2761 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
2754 type confirmations. Will need to use it in all of IPython's code
2762 type confirmations. Will need to use it in all of IPython's code
2755 consistently.
2763 consistently.
2756
2764
2757 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2765 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
2758 context to print 31 lines instead of the default 5. This will make
2766 context to print 31 lines instead of the default 5. This will make
2759 the crash reports extremely detailed in case the problem is in
2767 the crash reports extremely detailed in case the problem is in
2760 libraries I don't have access to.
2768 libraries I don't have access to.
2761
2769
2762 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2770 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
2763 line of defense' code to still crash, but giving users fair
2771 line of defense' code to still crash, but giving users fair
2764 warning. I don't want internal errors to go unreported: if there's
2772 warning. I don't want internal errors to go unreported: if there's
2765 an internal problem, IPython should crash and generate a full
2773 an internal problem, IPython should crash and generate a full
2766 report.
2774 report.
2767
2775
2768 2002-11-08 Fernando Perez <fperez@colorado.edu>
2776 2002-11-08 Fernando Perez <fperez@colorado.edu>
2769
2777
2770 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2778 * IPython/iplib.py (InteractiveShell.interact): added code to trap
2771 otherwise uncaught exceptions which can appear if people set
2779 otherwise uncaught exceptions which can appear if people set
2772 sys.stdout to something badly broken. Thanks to a crash report
2780 sys.stdout to something badly broken. Thanks to a crash report
2773 from henni-AT-mail.brainbot.com.
2781 from henni-AT-mail.brainbot.com.
2774
2782
2775 2002-11-04 Fernando Perez <fperez@colorado.edu>
2783 2002-11-04 Fernando Perez <fperez@colorado.edu>
2776
2784
2777 * IPython/iplib.py (InteractiveShell.interact): added
2785 * IPython/iplib.py (InteractiveShell.interact): added
2778 __IPYTHON__active to the builtins. It's a flag which goes on when
2786 __IPYTHON__active to the builtins. It's a flag which goes on when
2779 the interaction starts and goes off again when it stops. This
2787 the interaction starts and goes off again when it stops. This
2780 allows embedding code to detect being inside IPython. Before this
2788 allows embedding code to detect being inside IPython. Before this
2781 was done via __IPYTHON__, but that only shows that an IPython
2789 was done via __IPYTHON__, but that only shows that an IPython
2782 instance has been created.
2790 instance has been created.
2783
2791
2784 * IPython/Magic.py (Magic.magic_env): I realized that in a
2792 * IPython/Magic.py (Magic.magic_env): I realized that in a
2785 UserDict, instance.data holds the data as a normal dict. So I
2793 UserDict, instance.data holds the data as a normal dict. So I
2786 modified @env to return os.environ.data instead of rebuilding a
2794 modified @env to return os.environ.data instead of rebuilding a
2787 dict by hand.
2795 dict by hand.
2788
2796
2789 2002-11-02 Fernando Perez <fperez@colorado.edu>
2797 2002-11-02 Fernando Perez <fperez@colorado.edu>
2790
2798
2791 * IPython/genutils.py (warn): changed so that level 1 prints no
2799 * IPython/genutils.py (warn): changed so that level 1 prints no
2792 header. Level 2 is now the default (with 'WARNING' header, as
2800 header. Level 2 is now the default (with 'WARNING' header, as
2793 before). I think I tracked all places where changes were needed in
2801 before). I think I tracked all places where changes were needed in
2794 IPython, but outside code using the old level numbering may have
2802 IPython, but outside code using the old level numbering may have
2795 broken.
2803 broken.
2796
2804
2797 * IPython/iplib.py (InteractiveShell.runcode): added this to
2805 * IPython/iplib.py (InteractiveShell.runcode): added this to
2798 handle the tracebacks in SystemExit traps correctly. The previous
2806 handle the tracebacks in SystemExit traps correctly. The previous
2799 code (through interact) was printing more of the stack than
2807 code (through interact) was printing more of the stack than
2800 necessary, showing IPython internal code to the user.
2808 necessary, showing IPython internal code to the user.
2801
2809
2802 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2810 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
2803 default. Now that the default at the confirmation prompt is yes,
2811 default. Now that the default at the confirmation prompt is yes,
2804 it's not so intrusive. François' argument that ipython sessions
2812 it's not so intrusive. François' argument that ipython sessions
2805 tend to be complex enough not to lose them from an accidental C-d,
2813 tend to be complex enough not to lose them from an accidental C-d,
2806 is a valid one.
2814 is a valid one.
2807
2815
2808 * IPython/iplib.py (InteractiveShell.interact): added a
2816 * IPython/iplib.py (InteractiveShell.interact): added a
2809 showtraceback() call to the SystemExit trap, and modified the exit
2817 showtraceback() call to the SystemExit trap, and modified the exit
2810 confirmation to have yes as the default.
2818 confirmation to have yes as the default.
2811
2819
2812 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2820 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
2813 this file. It's been gone from the code for a long time, this was
2821 this file. It's been gone from the code for a long time, this was
2814 simply leftover junk.
2822 simply leftover junk.
2815
2823
2816 2002-11-01 Fernando Perez <fperez@colorado.edu>
2824 2002-11-01 Fernando Perez <fperez@colorado.edu>
2817
2825
2818 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2826 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
2819 added. If set, IPython now traps EOF and asks for
2827 added. If set, IPython now traps EOF and asks for
2820 confirmation. After a request by François Pinard.
2828 confirmation. After a request by François Pinard.
2821
2829
2822 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2830 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
2823 of @abort, and with a new (better) mechanism for handling the
2831 of @abort, and with a new (better) mechanism for handling the
2824 exceptions.
2832 exceptions.
2825
2833
2826 2002-10-27 Fernando Perez <fperez@colorado.edu>
2834 2002-10-27 Fernando Perez <fperez@colorado.edu>
2827
2835
2828 * IPython/usage.py (__doc__): updated the --help information and
2836 * IPython/usage.py (__doc__): updated the --help information and
2829 the ipythonrc file to indicate that -log generates
2837 the ipythonrc file to indicate that -log generates
2830 ./ipython.log. Also fixed the corresponding info in @logstart.
2838 ./ipython.log. Also fixed the corresponding info in @logstart.
2831 This and several other fixes in the manuals thanks to reports by
2839 This and several other fixes in the manuals thanks to reports by
2832 François Pinard <pinard-AT-iro.umontreal.ca>.
2840 François Pinard <pinard-AT-iro.umontreal.ca>.
2833
2841
2834 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2842 * IPython/Logger.py (Logger.switch_log): Fixed error message to
2835 refer to @logstart (instead of @log, which doesn't exist).
2843 refer to @logstart (instead of @log, which doesn't exist).
2836
2844
2837 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2845 * IPython/iplib.py (InteractiveShell._prefilter): fixed
2838 AttributeError crash. Thanks to Christopher Armstrong
2846 AttributeError crash. Thanks to Christopher Armstrong
2839 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2847 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
2840 introduced recently (in 0.2.14pre37) with the fix to the eval
2848 introduced recently (in 0.2.14pre37) with the fix to the eval
2841 problem mentioned below.
2849 problem mentioned below.
2842
2850
2843 2002-10-17 Fernando Perez <fperez@colorado.edu>
2851 2002-10-17 Fernando Perez <fperez@colorado.edu>
2844
2852
2845 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2853 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
2846 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2854 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
2847
2855
2848 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2856 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
2849 this function to fix a problem reported by Alex Schmolck. He saw
2857 this function to fix a problem reported by Alex Schmolck. He saw
2850 it with list comprehensions and generators, which were getting
2858 it with list comprehensions and generators, which were getting
2851 called twice. The real problem was an 'eval' call in testing for
2859 called twice. The real problem was an 'eval' call in testing for
2852 automagic which was evaluating the input line silently.
2860 automagic which was evaluating the input line silently.
2853
2861
2854 This is a potentially very nasty bug, if the input has side
2862 This is a potentially very nasty bug, if the input has side
2855 effects which must not be repeated. The code is much cleaner now,
2863 effects which must not be repeated. The code is much cleaner now,
2856 without any blanket 'except' left and with a regexp test for
2864 without any blanket 'except' left and with a regexp test for
2857 actual function names.
2865 actual function names.
2858
2866
2859 But an eval remains, which I'm not fully comfortable with. I just
2867 But an eval remains, which I'm not fully comfortable with. I just
2860 don't know how to find out if an expression could be a callable in
2868 don't know how to find out if an expression could be a callable in
2861 the user's namespace without doing an eval on the string. However
2869 the user's namespace without doing an eval on the string. However
2862 that string is now much more strictly checked so that no code
2870 that string is now much more strictly checked so that no code
2863 slips by, so the eval should only happen for things that can
2871 slips by, so the eval should only happen for things that can
2864 really be only function/method names.
2872 really be only function/method names.
2865
2873
2866 2002-10-15 Fernando Perez <fperez@colorado.edu>
2874 2002-10-15 Fernando Perez <fperez@colorado.edu>
2867
2875
2868 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2876 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
2869 OSX information to main manual, removed README_Mac_OSX file from
2877 OSX information to main manual, removed README_Mac_OSX file from
2870 distribution. Also updated credits for recent additions.
2878 distribution. Also updated credits for recent additions.
2871
2879
2872 2002-10-10 Fernando Perez <fperez@colorado.edu>
2880 2002-10-10 Fernando Perez <fperez@colorado.edu>
2873
2881
2874 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2882 * README_Mac_OSX: Added a README for Mac OSX users for fixing
2875 terminal-related issues. Many thanks to Andrea Riciputi
2883 terminal-related issues. Many thanks to Andrea Riciputi
2876 <andrea.riciputi-AT-libero.it> for writing it.
2884 <andrea.riciputi-AT-libero.it> for writing it.
2877
2885
2878 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2886 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
2879 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2887 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
2880
2888
2881 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2889 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
2882 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2890 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
2883 <syver-en-AT-online.no> who both submitted patches for this problem.
2891 <syver-en-AT-online.no> who both submitted patches for this problem.
2884
2892
2885 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2893 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
2886 global embedding to make sure that things don't overwrite user
2894 global embedding to make sure that things don't overwrite user
2887 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2895 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
2888
2896
2889 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2897 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
2890 compatibility. Thanks to Hayden Callow
2898 compatibility. Thanks to Hayden Callow
2891 <h.callow-AT-elec.canterbury.ac.nz>
2899 <h.callow-AT-elec.canterbury.ac.nz>
2892
2900
2893 2002-10-04 Fernando Perez <fperez@colorado.edu>
2901 2002-10-04 Fernando Perez <fperez@colorado.edu>
2894
2902
2895 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
2903 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
2896 Gnuplot.File objects.
2904 Gnuplot.File objects.
2897
2905
2898 2002-07-23 Fernando Perez <fperez@colorado.edu>
2906 2002-07-23 Fernando Perez <fperez@colorado.edu>
2899
2907
2900 * IPython/genutils.py (timing): Added timings() and timing() for
2908 * IPython/genutils.py (timing): Added timings() and timing() for
2901 quick access to the most commonly needed data, the execution
2909 quick access to the most commonly needed data, the execution
2902 times. Old timing() renamed to timings_out().
2910 times. Old timing() renamed to timings_out().
2903
2911
2904 2002-07-18 Fernando Perez <fperez@colorado.edu>
2912 2002-07-18 Fernando Perez <fperez@colorado.edu>
2905
2913
2906 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
2914 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
2907 bug with nested instances disrupting the parent's tab completion.
2915 bug with nested instances disrupting the parent's tab completion.
2908
2916
2909 * IPython/iplib.py (all_completions): Added Alex Schmolck's
2917 * IPython/iplib.py (all_completions): Added Alex Schmolck's
2910 all_completions code to begin the emacs integration.
2918 all_completions code to begin the emacs integration.
2911
2919
2912 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
2920 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
2913 argument to allow titling individual arrays when plotting.
2921 argument to allow titling individual arrays when plotting.
2914
2922
2915 2002-07-15 Fernando Perez <fperez@colorado.edu>
2923 2002-07-15 Fernando Perez <fperez@colorado.edu>
2916
2924
2917 * setup.py (make_shortcut): changed to retrieve the value of
2925 * setup.py (make_shortcut): changed to retrieve the value of
2918 'Program Files' directory from the registry (this value changes in
2926 'Program Files' directory from the registry (this value changes in
2919 non-english versions of Windows). Thanks to Thomas Fanslau
2927 non-english versions of Windows). Thanks to Thomas Fanslau
2920 <tfanslau-AT-gmx.de> for the report.
2928 <tfanslau-AT-gmx.de> for the report.
2921
2929
2922 2002-07-10 Fernando Perez <fperez@colorado.edu>
2930 2002-07-10 Fernando Perez <fperez@colorado.edu>
2923
2931
2924 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
2932 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
2925 a bug in pdb, which crashes if a line with only whitespace is
2933 a bug in pdb, which crashes if a line with only whitespace is
2926 entered. Bug report submitted to sourceforge.
2934 entered. Bug report submitted to sourceforge.
2927
2935
2928 2002-07-09 Fernando Perez <fperez@colorado.edu>
2936 2002-07-09 Fernando Perez <fperez@colorado.edu>
2929
2937
2930 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
2938 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
2931 reporting exceptions (it's a bug in inspect.py, I just set a
2939 reporting exceptions (it's a bug in inspect.py, I just set a
2932 workaround).
2940 workaround).
2933
2941
2934 2002-07-08 Fernando Perez <fperez@colorado.edu>
2942 2002-07-08 Fernando Perez <fperez@colorado.edu>
2935
2943
2936 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
2944 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
2937 __IPYTHON__ in __builtins__ to show up in user_ns.
2945 __IPYTHON__ in __builtins__ to show up in user_ns.
2938
2946
2939 2002-07-03 Fernando Perez <fperez@colorado.edu>
2947 2002-07-03 Fernando Perez <fperez@colorado.edu>
2940
2948
2941 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
2949 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
2942 name from @gp_set_instance to @gp_set_default.
2950 name from @gp_set_instance to @gp_set_default.
2943
2951
2944 * IPython/ipmaker.py (make_IPython): default editor value set to
2952 * IPython/ipmaker.py (make_IPython): default editor value set to
2945 '0' (a string), to match the rc file. Otherwise will crash when
2953 '0' (a string), to match the rc file. Otherwise will crash when
2946 .strip() is called on it.
2954 .strip() is called on it.
2947
2955
2948
2956
2949 2002-06-28 Fernando Perez <fperez@colorado.edu>
2957 2002-06-28 Fernando Perez <fperez@colorado.edu>
2950
2958
2951 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
2959 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
2952 of files in current directory when a file is executed via
2960 of files in current directory when a file is executed via
2953 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
2961 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
2954
2962
2955 * setup.py (manfiles): fix for rpm builds, submitted by RA
2963 * setup.py (manfiles): fix for rpm builds, submitted by RA
2956 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
2964 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
2957
2965
2958 * IPython/ipmaker.py (make_IPython): fixed lookup of default
2966 * IPython/ipmaker.py (make_IPython): fixed lookup of default
2959 editor when set to '0'. Problem was, '0' evaluates to True (it's a
2967 editor when set to '0'. Problem was, '0' evaluates to True (it's a
2960 string!). A. Schmolck caught this one.
2968 string!). A. Schmolck caught this one.
2961
2969
2962 2002-06-27 Fernando Perez <fperez@colorado.edu>
2970 2002-06-27 Fernando Perez <fperez@colorado.edu>
2963
2971
2964 * IPython/ipmaker.py (make_IPython): fixed bug when running user
2972 * IPython/ipmaker.py (make_IPython): fixed bug when running user
2965 defined files at the cmd line. __name__ wasn't being set to
2973 defined files at the cmd line. __name__ wasn't being set to
2966 __main__.
2974 __main__.
2967
2975
2968 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
2976 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
2969 regular lists and tuples besides Numeric arrays.
2977 regular lists and tuples besides Numeric arrays.
2970
2978
2971 * IPython/Prompts.py (CachedOutput.__call__): Added output
2979 * IPython/Prompts.py (CachedOutput.__call__): Added output
2972 supression for input ending with ';'. Similar to Mathematica and
2980 supression for input ending with ';'. Similar to Mathematica and
2973 Matlab. The _* vars and Out[] list are still updated, just like
2981 Matlab. The _* vars and Out[] list are still updated, just like
2974 Mathematica behaves.
2982 Mathematica behaves.
2975
2983
2976 2002-06-25 Fernando Perez <fperez@colorado.edu>
2984 2002-06-25 Fernando Perez <fperez@colorado.edu>
2977
2985
2978 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
2986 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
2979 .ini extensions for profiels under Windows.
2987 .ini extensions for profiels under Windows.
2980
2988
2981 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
2989 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
2982 string form. Fix contributed by Alexander Schmolck
2990 string form. Fix contributed by Alexander Schmolck
2983 <a.schmolck-AT-gmx.net>
2991 <a.schmolck-AT-gmx.net>
2984
2992
2985 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
2993 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
2986 pre-configured Gnuplot instance.
2994 pre-configured Gnuplot instance.
2987
2995
2988 2002-06-21 Fernando Perez <fperez@colorado.edu>
2996 2002-06-21 Fernando Perez <fperez@colorado.edu>
2989
2997
2990 * IPython/numutils.py (exp_safe): new function, works around the
2998 * IPython/numutils.py (exp_safe): new function, works around the
2991 underflow problems in Numeric.
2999 underflow problems in Numeric.
2992 (log2): New fn. Safe log in base 2: returns exact integer answer
3000 (log2): New fn. Safe log in base 2: returns exact integer answer
2993 for exact integer powers of 2.
3001 for exact integer powers of 2.
2994
3002
2995 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
3003 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
2996 properly.
3004 properly.
2997
3005
2998 2002-06-20 Fernando Perez <fperez@colorado.edu>
3006 2002-06-20 Fernando Perez <fperez@colorado.edu>
2999
3007
3000 * IPython/genutils.py (timing): new function like
3008 * IPython/genutils.py (timing): new function like
3001 Mathematica's. Similar to time_test, but returns more info.
3009 Mathematica's. Similar to time_test, but returns more info.
3002
3010
3003 2002-06-18 Fernando Perez <fperez@colorado.edu>
3011 2002-06-18 Fernando Perez <fperez@colorado.edu>
3004
3012
3005 * IPython/Magic.py (Magic.magic_save): modified @save and @r
3013 * IPython/Magic.py (Magic.magic_save): modified @save and @r
3006 according to Mike Heeter's suggestions.
3014 according to Mike Heeter's suggestions.
3007
3015
3008 2002-06-16 Fernando Perez <fperez@colorado.edu>
3016 2002-06-16 Fernando Perez <fperez@colorado.edu>
3009
3017
3010 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
3018 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
3011 system. GnuplotMagic is gone as a user-directory option. New files
3019 system. GnuplotMagic is gone as a user-directory option. New files
3012 make it easier to use all the gnuplot stuff both from external
3020 make it easier to use all the gnuplot stuff both from external
3013 programs as well as from IPython. Had to rewrite part of
3021 programs as well as from IPython. Had to rewrite part of
3014 hardcopy() b/c of a strange bug: often the ps files simply don't
3022 hardcopy() b/c of a strange bug: often the ps files simply don't
3015 get created, and require a repeat of the command (often several
3023 get created, and require a repeat of the command (often several
3016 times).
3024 times).
3017
3025
3018 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
3026 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
3019 resolve output channel at call time, so that if sys.stderr has
3027 resolve output channel at call time, so that if sys.stderr has
3020 been redirected by user this gets honored.
3028 been redirected by user this gets honored.
3021
3029
3022 2002-06-13 Fernando Perez <fperez@colorado.edu>
3030 2002-06-13 Fernando Perez <fperez@colorado.edu>
3023
3031
3024 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
3032 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
3025 IPShell. Kept a copy with the old names to avoid breaking people's
3033 IPShell. Kept a copy with the old names to avoid breaking people's
3026 embedded code.
3034 embedded code.
3027
3035
3028 * IPython/ipython: simplified it to the bare minimum after
3036 * IPython/ipython: simplified it to the bare minimum after
3029 Holger's suggestions. Added info about how to use it in
3037 Holger's suggestions. Added info about how to use it in
3030 PYTHONSTARTUP.
3038 PYTHONSTARTUP.
3031
3039
3032 * IPython/Shell.py (IPythonShell): changed the options passing
3040 * IPython/Shell.py (IPythonShell): changed the options passing
3033 from a string with funky %s replacements to a straight list. Maybe
3041 from a string with funky %s replacements to a straight list. Maybe
3034 a bit more typing, but it follows sys.argv conventions, so there's
3042 a bit more typing, but it follows sys.argv conventions, so there's
3035 less special-casing to remember.
3043 less special-casing to remember.
3036
3044
3037 2002-06-12 Fernando Perez <fperez@colorado.edu>
3045 2002-06-12 Fernando Perez <fperez@colorado.edu>
3038
3046
3039 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
3047 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
3040 command. Thanks to a suggestion by Mike Heeter.
3048 command. Thanks to a suggestion by Mike Heeter.
3041 (Magic.magic_pfile): added behavior to look at filenames if given
3049 (Magic.magic_pfile): added behavior to look at filenames if given
3042 arg is not a defined object.
3050 arg is not a defined object.
3043 (Magic.magic_save): New @save function to save code snippets. Also
3051 (Magic.magic_save): New @save function to save code snippets. Also
3044 a Mike Heeter idea.
3052 a Mike Heeter idea.
3045
3053
3046 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
3054 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
3047 plot() and replot(). Much more convenient now, especially for
3055 plot() and replot(). Much more convenient now, especially for
3048 interactive use.
3056 interactive use.
3049
3057
3050 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
3058 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
3051 filenames.
3059 filenames.
3052
3060
3053 2002-06-02 Fernando Perez <fperez@colorado.edu>
3061 2002-06-02 Fernando Perez <fperez@colorado.edu>
3054
3062
3055 * IPython/Struct.py (Struct.__init__): modified to admit
3063 * IPython/Struct.py (Struct.__init__): modified to admit
3056 initialization via another struct.
3064 initialization via another struct.
3057
3065
3058 * IPython/genutils.py (SystemExec.__init__): New stateful
3066 * IPython/genutils.py (SystemExec.__init__): New stateful
3059 interface to xsys and bq. Useful for writing system scripts.
3067 interface to xsys and bq. Useful for writing system scripts.
3060
3068
3061 2002-05-30 Fernando Perez <fperez@colorado.edu>
3069 2002-05-30 Fernando Perez <fperez@colorado.edu>
3062
3070
3063 * MANIFEST.in: Changed docfile selection to exclude all the lyx
3071 * MANIFEST.in: Changed docfile selection to exclude all the lyx
3064 documents. This will make the user download smaller (it's getting
3072 documents. This will make the user download smaller (it's getting
3065 too big).
3073 too big).
3066
3074
3067 2002-05-29 Fernando Perez <fperez@colorado.edu>
3075 2002-05-29 Fernando Perez <fperez@colorado.edu>
3068
3076
3069 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
3077 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
3070 fix problems with shelve and pickle. Seems to work, but I don't
3078 fix problems with shelve and pickle. Seems to work, but I don't
3071 know if corner cases break it. Thanks to Mike Heeter
3079 know if corner cases break it. Thanks to Mike Heeter
3072 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
3080 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
3073
3081
3074 2002-05-24 Fernando Perez <fperez@colorado.edu>
3082 2002-05-24 Fernando Perez <fperez@colorado.edu>
3075
3083
3076 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
3084 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
3077 macros having broken.
3085 macros having broken.
3078
3086
3079 2002-05-21 Fernando Perez <fperez@colorado.edu>
3087 2002-05-21 Fernando Perez <fperez@colorado.edu>
3080
3088
3081 * IPython/Magic.py (Magic.magic_logstart): fixed recently
3089 * IPython/Magic.py (Magic.magic_logstart): fixed recently
3082 introduced logging bug: all history before logging started was
3090 introduced logging bug: all history before logging started was
3083 being written one character per line! This came from the redesign
3091 being written one character per line! This came from the redesign
3084 of the input history as a special list which slices to strings,
3092 of the input history as a special list which slices to strings,
3085 not to lists.
3093 not to lists.
3086
3094
3087 2002-05-20 Fernando Perez <fperez@colorado.edu>
3095 2002-05-20 Fernando Perez <fperez@colorado.edu>
3088
3096
3089 * IPython/Prompts.py (CachedOutput.__init__): made the color table
3097 * IPython/Prompts.py (CachedOutput.__init__): made the color table
3090 be an attribute of all classes in this module. The design of these
3098 be an attribute of all classes in this module. The design of these
3091 classes needs some serious overhauling.
3099 classes needs some serious overhauling.
3092
3100
3093 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
3101 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
3094 which was ignoring '_' in option names.
3102 which was ignoring '_' in option names.
3095
3103
3096 * IPython/ultraTB.py (FormattedTB.__init__): Changed
3104 * IPython/ultraTB.py (FormattedTB.__init__): Changed
3097 'Verbose_novars' to 'Context' and made it the new default. It's a
3105 'Verbose_novars' to 'Context' and made it the new default. It's a
3098 bit more readable and also safer than verbose.
3106 bit more readable and also safer than verbose.
3099
3107
3100 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
3108 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
3101 triple-quoted strings.
3109 triple-quoted strings.
3102
3110
3103 * IPython/OInspect.py (__all__): new module exposing the object
3111 * IPython/OInspect.py (__all__): new module exposing the object
3104 introspection facilities. Now the corresponding magics are dummy
3112 introspection facilities. Now the corresponding magics are dummy
3105 wrappers around this. Having this module will make it much easier
3113 wrappers around this. Having this module will make it much easier
3106 to put these functions into our modified pdb.
3114 to put these functions into our modified pdb.
3107 This new object inspector system uses the new colorizing module,
3115 This new object inspector system uses the new colorizing module,
3108 so source code and other things are nicely syntax highlighted.
3116 so source code and other things are nicely syntax highlighted.
3109
3117
3110 2002-05-18 Fernando Perez <fperez@colorado.edu>
3118 2002-05-18 Fernando Perez <fperez@colorado.edu>
3111
3119
3112 * IPython/ColorANSI.py: Split the coloring tools into a separate
3120 * IPython/ColorANSI.py: Split the coloring tools into a separate
3113 module so I can use them in other code easier (they were part of
3121 module so I can use them in other code easier (they were part of
3114 ultraTB).
3122 ultraTB).
3115
3123
3116 2002-05-17 Fernando Perez <fperez@colorado.edu>
3124 2002-05-17 Fernando Perez <fperez@colorado.edu>
3117
3125
3118 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3126 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3119 fixed it to set the global 'g' also to the called instance, as
3127 fixed it to set the global 'g' also to the called instance, as
3120 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3128 long as 'g' was still a gnuplot instance (so it doesn't overwrite
3121 user's 'g' variables).
3129 user's 'g' variables).
3122
3130
3123 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3131 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
3124 global variables (aliases to _ih,_oh) so that users which expect
3132 global variables (aliases to _ih,_oh) so that users which expect
3125 In[5] or Out[7] to work aren't unpleasantly surprised.
3133 In[5] or Out[7] to work aren't unpleasantly surprised.
3126 (InputList.__getslice__): new class to allow executing slices of
3134 (InputList.__getslice__): new class to allow executing slices of
3127 input history directly. Very simple class, complements the use of
3135 input history directly. Very simple class, complements the use of
3128 macros.
3136 macros.
3129
3137
3130 2002-05-16 Fernando Perez <fperez@colorado.edu>
3138 2002-05-16 Fernando Perez <fperez@colorado.edu>
3131
3139
3132 * setup.py (docdirbase): make doc directory be just doc/IPython
3140 * setup.py (docdirbase): make doc directory be just doc/IPython
3133 without version numbers, it will reduce clutter for users.
3141 without version numbers, it will reduce clutter for users.
3134
3142
3135 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3143 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
3136 execfile call to prevent possible memory leak. See for details:
3144 execfile call to prevent possible memory leak. See for details:
3137 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3145 http://mail.python.org/pipermail/python-list/2002-February/088476.html
3138
3146
3139 2002-05-15 Fernando Perez <fperez@colorado.edu>
3147 2002-05-15 Fernando Perez <fperez@colorado.edu>
3140
3148
3141 * IPython/Magic.py (Magic.magic_psource): made the object
3149 * IPython/Magic.py (Magic.magic_psource): made the object
3142 introspection names be more standard: pdoc, pdef, pfile and
3150 introspection names be more standard: pdoc, pdef, pfile and
3143 psource. They all print/page their output, and it makes
3151 psource. They all print/page their output, and it makes
3144 remembering them easier. Kept old names for compatibility as
3152 remembering them easier. Kept old names for compatibility as
3145 aliases.
3153 aliases.
3146
3154
3147 2002-05-14 Fernando Perez <fperez@colorado.edu>
3155 2002-05-14 Fernando Perez <fperez@colorado.edu>
3148
3156
3149 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3157 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
3150 what the mouse problem was. The trick is to use gnuplot with temp
3158 what the mouse problem was. The trick is to use gnuplot with temp
3151 files and NOT with pipes (for data communication), because having
3159 files and NOT with pipes (for data communication), because having
3152 both pipes and the mouse on is bad news.
3160 both pipes and the mouse on is bad news.
3153
3161
3154 2002-05-13 Fernando Perez <fperez@colorado.edu>
3162 2002-05-13 Fernando Perez <fperez@colorado.edu>
3155
3163
3156 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3164 * IPython/Magic.py (Magic._ofind): fixed namespace order search
3157 bug. Information would be reported about builtins even when
3165 bug. Information would be reported about builtins even when
3158 user-defined functions overrode them.
3166 user-defined functions overrode them.
3159
3167
3160 2002-05-11 Fernando Perez <fperez@colorado.edu>
3168 2002-05-11 Fernando Perez <fperez@colorado.edu>
3161
3169
3162 * IPython/__init__.py (__all__): removed FlexCompleter from
3170 * IPython/__init__.py (__all__): removed FlexCompleter from
3163 __all__ so that things don't fail in platforms without readline.
3171 __all__ so that things don't fail in platforms without readline.
3164
3172
3165 2002-05-10 Fernando Perez <fperez@colorado.edu>
3173 2002-05-10 Fernando Perez <fperez@colorado.edu>
3166
3174
3167 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3175 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
3168 it requires Numeric, effectively making Numeric a dependency for
3176 it requires Numeric, effectively making Numeric a dependency for
3169 IPython.
3177 IPython.
3170
3178
3171 * Released 0.2.13
3179 * Released 0.2.13
3172
3180
3173 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3181 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
3174 profiler interface. Now all the major options from the profiler
3182 profiler interface. Now all the major options from the profiler
3175 module are directly supported in IPython, both for single
3183 module are directly supported in IPython, both for single
3176 expressions (@prun) and for full programs (@run -p).
3184 expressions (@prun) and for full programs (@run -p).
3177
3185
3178 2002-05-09 Fernando Perez <fperez@colorado.edu>
3186 2002-05-09 Fernando Perez <fperez@colorado.edu>
3179
3187
3180 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3188 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
3181 magic properly formatted for screen.
3189 magic properly formatted for screen.
3182
3190
3183 * setup.py (make_shortcut): Changed things to put pdf version in
3191 * setup.py (make_shortcut): Changed things to put pdf version in
3184 doc/ instead of doc/manual (had to change lyxport a bit).
3192 doc/ instead of doc/manual (had to change lyxport a bit).
3185
3193
3186 * IPython/Magic.py (Profile.string_stats): made profile runs go
3194 * IPython/Magic.py (Profile.string_stats): made profile runs go
3187 through pager (they are long and a pager allows searching, saving,
3195 through pager (they are long and a pager allows searching, saving,
3188 etc.)
3196 etc.)
3189
3197
3190 2002-05-08 Fernando Perez <fperez@colorado.edu>
3198 2002-05-08 Fernando Perez <fperez@colorado.edu>
3191
3199
3192 * Released 0.2.12
3200 * Released 0.2.12
3193
3201
3194 2002-05-06 Fernando Perez <fperez@colorado.edu>
3202 2002-05-06 Fernando Perez <fperez@colorado.edu>
3195
3203
3196 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3204 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
3197 introduced); 'hist n1 n2' was broken.
3205 introduced); 'hist n1 n2' was broken.
3198 (Magic.magic_pdb): added optional on/off arguments to @pdb
3206 (Magic.magic_pdb): added optional on/off arguments to @pdb
3199 (Magic.magic_run): added option -i to @run, which executes code in
3207 (Magic.magic_run): added option -i to @run, which executes code in
3200 the IPython namespace instead of a clean one. Also added @irun as
3208 the IPython namespace instead of a clean one. Also added @irun as
3201 an alias to @run -i.
3209 an alias to @run -i.
3202
3210
3203 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3211 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
3204 fixed (it didn't really do anything, the namespaces were wrong).
3212 fixed (it didn't really do anything, the namespaces were wrong).
3205
3213
3206 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3214 * IPython/Debugger.py (__init__): Added workaround for python 2.1
3207
3215
3208 * IPython/__init__.py (__all__): Fixed package namespace, now
3216 * IPython/__init__.py (__all__): Fixed package namespace, now
3209 'import IPython' does give access to IPython.<all> as
3217 'import IPython' does give access to IPython.<all> as
3210 expected. Also renamed __release__ to Release.
3218 expected. Also renamed __release__ to Release.
3211
3219
3212 * IPython/Debugger.py (__license__): created new Pdb class which
3220 * IPython/Debugger.py (__license__): created new Pdb class which
3213 functions like a drop-in for the normal pdb.Pdb but does NOT
3221 functions like a drop-in for the normal pdb.Pdb but does NOT
3214 import readline by default. This way it doesn't muck up IPython's
3222 import readline by default. This way it doesn't muck up IPython's
3215 readline handling, and now tab-completion finally works in the
3223 readline handling, and now tab-completion finally works in the
3216 debugger -- sort of. It completes things globally visible, but the
3224 debugger -- sort of. It completes things globally visible, but the
3217 completer doesn't track the stack as pdb walks it. That's a bit
3225 completer doesn't track the stack as pdb walks it. That's a bit
3218 tricky, and I'll have to implement it later.
3226 tricky, and I'll have to implement it later.
3219
3227
3220 2002-05-05 Fernando Perez <fperez@colorado.edu>
3228 2002-05-05 Fernando Perez <fperez@colorado.edu>
3221
3229
3222 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3230 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
3223 magic docstrings when printed via ? (explicit \'s were being
3231 magic docstrings when printed via ? (explicit \'s were being
3224 printed).
3232 printed).
3225
3233
3226 * IPython/ipmaker.py (make_IPython): fixed namespace
3234 * IPython/ipmaker.py (make_IPython): fixed namespace
3227 identification bug. Now variables loaded via logs or command-line
3235 identification bug. Now variables loaded via logs or command-line
3228 files are recognized in the interactive namespace by @who.
3236 files are recognized in the interactive namespace by @who.
3229
3237
3230 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3238 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
3231 log replay system stemming from the string form of Structs.
3239 log replay system stemming from the string form of Structs.
3232
3240
3233 * IPython/Magic.py (Macro.__init__): improved macros to properly
3241 * IPython/Magic.py (Macro.__init__): improved macros to properly
3234 handle magic commands in them.
3242 handle magic commands in them.
3235 (Magic.magic_logstart): usernames are now expanded so 'logstart
3243 (Magic.magic_logstart): usernames are now expanded so 'logstart
3236 ~/mylog' now works.
3244 ~/mylog' now works.
3237
3245
3238 * IPython/iplib.py (complete): fixed bug where paths starting with
3246 * IPython/iplib.py (complete): fixed bug where paths starting with
3239 '/' would be completed as magic names.
3247 '/' would be completed as magic names.
3240
3248
3241 2002-05-04 Fernando Perez <fperez@colorado.edu>
3249 2002-05-04 Fernando Perez <fperez@colorado.edu>
3242
3250
3243 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3251 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
3244 allow running full programs under the profiler's control.
3252 allow running full programs under the profiler's control.
3245
3253
3246 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3254 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
3247 mode to report exceptions verbosely but without formatting
3255 mode to report exceptions verbosely but without formatting
3248 variables. This addresses the issue of ipython 'freezing' (it's
3256 variables. This addresses the issue of ipython 'freezing' (it's
3249 not frozen, but caught in an expensive formatting loop) when huge
3257 not frozen, but caught in an expensive formatting loop) when huge
3250 variables are in the context of an exception.
3258 variables are in the context of an exception.
3251 (VerboseTB.text): Added '--->' markers at line where exception was
3259 (VerboseTB.text): Added '--->' markers at line where exception was
3252 triggered. Much clearer to read, especially in NoColor modes.
3260 triggered. Much clearer to read, especially in NoColor modes.
3253
3261
3254 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3262 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
3255 implemented in reverse when changing to the new parse_options().
3263 implemented in reverse when changing to the new parse_options().
3256
3264
3257 2002-05-03 Fernando Perez <fperez@colorado.edu>
3265 2002-05-03 Fernando Perez <fperez@colorado.edu>
3258
3266
3259 * IPython/Magic.py (Magic.parse_options): new function so that
3267 * IPython/Magic.py (Magic.parse_options): new function so that
3260 magics can parse options easier.
3268 magics can parse options easier.
3261 (Magic.magic_prun): new function similar to profile.run(),
3269 (Magic.magic_prun): new function similar to profile.run(),
3262 suggested by Chris Hart.
3270 suggested by Chris Hart.
3263 (Magic.magic_cd): fixed behavior so that it only changes if
3271 (Magic.magic_cd): fixed behavior so that it only changes if
3264 directory actually is in history.
3272 directory actually is in history.
3265
3273
3266 * IPython/usage.py (__doc__): added information about potential
3274 * IPython/usage.py (__doc__): added information about potential
3267 slowness of Verbose exception mode when there are huge data
3275 slowness of Verbose exception mode when there are huge data
3268 structures to be formatted (thanks to Archie Paulson).
3276 structures to be formatted (thanks to Archie Paulson).
3269
3277
3270 * IPython/ipmaker.py (make_IPython): Changed default logging
3278 * IPython/ipmaker.py (make_IPython): Changed default logging
3271 (when simply called with -log) to use curr_dir/ipython.log in
3279 (when simply called with -log) to use curr_dir/ipython.log in
3272 rotate mode. Fixed crash which was occuring with -log before
3280 rotate mode. Fixed crash which was occuring with -log before
3273 (thanks to Jim Boyle).
3281 (thanks to Jim Boyle).
3274
3282
3275 2002-05-01 Fernando Perez <fperez@colorado.edu>
3283 2002-05-01 Fernando Perez <fperez@colorado.edu>
3276
3284
3277 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3285 * Released 0.2.11 for these fixes (mainly the ultraTB one which
3278 was nasty -- though somewhat of a corner case).
3286 was nasty -- though somewhat of a corner case).
3279
3287
3280 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3288 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
3281 text (was a bug).
3289 text (was a bug).
3282
3290
3283 2002-04-30 Fernando Perez <fperez@colorado.edu>
3291 2002-04-30 Fernando Perez <fperez@colorado.edu>
3284
3292
3285 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3293 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
3286 a print after ^D or ^C from the user so that the In[] prompt
3294 a print after ^D or ^C from the user so that the In[] prompt
3287 doesn't over-run the gnuplot one.
3295 doesn't over-run the gnuplot one.
3288
3296
3289 2002-04-29 Fernando Perez <fperez@colorado.edu>
3297 2002-04-29 Fernando Perez <fperez@colorado.edu>
3290
3298
3291 * Released 0.2.10
3299 * Released 0.2.10
3292
3300
3293 * IPython/__release__.py (version): get date dynamically.
3301 * IPython/__release__.py (version): get date dynamically.
3294
3302
3295 * Misc. documentation updates thanks to Arnd's comments. Also ran
3303 * Misc. documentation updates thanks to Arnd's comments. Also ran
3296 a full spellcheck on the manual (hadn't been done in a while).
3304 a full spellcheck on the manual (hadn't been done in a while).
3297
3305
3298 2002-04-27 Fernando Perez <fperez@colorado.edu>
3306 2002-04-27 Fernando Perez <fperez@colorado.edu>
3299
3307
3300 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3308 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
3301 starting a log in mid-session would reset the input history list.
3309 starting a log in mid-session would reset the input history list.
3302
3310
3303 2002-04-26 Fernando Perez <fperez@colorado.edu>
3311 2002-04-26 Fernando Perez <fperez@colorado.edu>
3304
3312
3305 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3313 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
3306 all files were being included in an update. Now anything in
3314 all files were being included in an update. Now anything in
3307 UserConfig that matches [A-Za-z]*.py will go (this excludes
3315 UserConfig that matches [A-Za-z]*.py will go (this excludes
3308 __init__.py)
3316 __init__.py)
3309
3317
3310 2002-04-25 Fernando Perez <fperez@colorado.edu>
3318 2002-04-25 Fernando Perez <fperez@colorado.edu>
3311
3319
3312 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3320 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
3313 to __builtins__ so that any form of embedded or imported code can
3321 to __builtins__ so that any form of embedded or imported code can
3314 test for being inside IPython.
3322 test for being inside IPython.
3315
3323
3316 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3324 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
3317 changed to GnuplotMagic because it's now an importable module,
3325 changed to GnuplotMagic because it's now an importable module,
3318 this makes the name follow that of the standard Gnuplot module.
3326 this makes the name follow that of the standard Gnuplot module.
3319 GnuplotMagic can now be loaded at any time in mid-session.
3327 GnuplotMagic can now be loaded at any time in mid-session.
3320
3328
3321 2002-04-24 Fernando Perez <fperez@colorado.edu>
3329 2002-04-24 Fernando Perez <fperez@colorado.edu>
3322
3330
3323 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3331 * IPython/numutils.py: removed SIUnits. It doesn't properly set
3324 the globals (IPython has its own namespace) and the
3332 the globals (IPython has its own namespace) and the
3325 PhysicalQuantity stuff is much better anyway.
3333 PhysicalQuantity stuff is much better anyway.
3326
3334
3327 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3335 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
3328 embedding example to standard user directory for
3336 embedding example to standard user directory for
3329 distribution. Also put it in the manual.
3337 distribution. Also put it in the manual.
3330
3338
3331 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3339 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
3332 instance as first argument (so it doesn't rely on some obscure
3340 instance as first argument (so it doesn't rely on some obscure
3333 hidden global).
3341 hidden global).
3334
3342
3335 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3343 * IPython/UserConfig/ipythonrc.py: put () back in accepted
3336 delimiters. While it prevents ().TAB from working, it allows
3344 delimiters. While it prevents ().TAB from working, it allows
3337 completions in open (... expressions. This is by far a more common
3345 completions in open (... expressions. This is by far a more common
3338 case.
3346 case.
3339
3347
3340 2002-04-23 Fernando Perez <fperez@colorado.edu>
3348 2002-04-23 Fernando Perez <fperez@colorado.edu>
3341
3349
3342 * IPython/Extensions/InterpreterPasteInput.py: new
3350 * IPython/Extensions/InterpreterPasteInput.py: new
3343 syntax-processing module for pasting lines with >>> or ... at the
3351 syntax-processing module for pasting lines with >>> or ... at the
3344 start.
3352 start.
3345
3353
3346 * IPython/Extensions/PhysicalQ_Interactive.py
3354 * IPython/Extensions/PhysicalQ_Interactive.py
3347 (PhysicalQuantityInteractive.__int__): fixed to work with either
3355 (PhysicalQuantityInteractive.__int__): fixed to work with either
3348 Numeric or math.
3356 Numeric or math.
3349
3357
3350 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3358 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
3351 provided profiles. Now we have:
3359 provided profiles. Now we have:
3352 -math -> math module as * and cmath with its own namespace.
3360 -math -> math module as * and cmath with its own namespace.
3353 -numeric -> Numeric as *, plus gnuplot & grace
3361 -numeric -> Numeric as *, plus gnuplot & grace
3354 -physics -> same as before
3362 -physics -> same as before
3355
3363
3356 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3364 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
3357 user-defined magics wouldn't be found by @magic if they were
3365 user-defined magics wouldn't be found by @magic if they were
3358 defined as class methods. Also cleaned up the namespace search
3366 defined as class methods. Also cleaned up the namespace search
3359 logic and the string building (to use %s instead of many repeated
3367 logic and the string building (to use %s instead of many repeated
3360 string adds).
3368 string adds).
3361
3369
3362 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3370 * IPython/UserConfig/example-magic.py (magic_foo): updated example
3363 of user-defined magics to operate with class methods (cleaner, in
3371 of user-defined magics to operate with class methods (cleaner, in
3364 line with the gnuplot code).
3372 line with the gnuplot code).
3365
3373
3366 2002-04-22 Fernando Perez <fperez@colorado.edu>
3374 2002-04-22 Fernando Perez <fperez@colorado.edu>
3367
3375
3368 * setup.py: updated dependency list so that manual is updated when
3376 * setup.py: updated dependency list so that manual is updated when
3369 all included files change.
3377 all included files change.
3370
3378
3371 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3379 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
3372 the delimiter removal option (the fix is ugly right now).
3380 the delimiter removal option (the fix is ugly right now).
3373
3381
3374 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3382 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
3375 all of the math profile (quicker loading, no conflict between
3383 all of the math profile (quicker loading, no conflict between
3376 g-9.8 and g-gnuplot).
3384 g-9.8 and g-gnuplot).
3377
3385
3378 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3386 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
3379 name of post-mortem files to IPython_crash_report.txt.
3387 name of post-mortem files to IPython_crash_report.txt.
3380
3388
3381 * Cleanup/update of the docs. Added all the new readline info and
3389 * Cleanup/update of the docs. Added all the new readline info and
3382 formatted all lists as 'real lists'.
3390 formatted all lists as 'real lists'.
3383
3391
3384 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3392 * IPython/ipmaker.py (make_IPython): removed now-obsolete
3385 tab-completion options, since the full readline parse_and_bind is
3393 tab-completion options, since the full readline parse_and_bind is
3386 now accessible.
3394 now accessible.
3387
3395
3388 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3396 * IPython/iplib.py (InteractiveShell.init_readline): Changed
3389 handling of readline options. Now users can specify any string to
3397 handling of readline options. Now users can specify any string to
3390 be passed to parse_and_bind(), as well as the delimiters to be
3398 be passed to parse_and_bind(), as well as the delimiters to be
3391 removed.
3399 removed.
3392 (InteractiveShell.__init__): Added __name__ to the global
3400 (InteractiveShell.__init__): Added __name__ to the global
3393 namespace so that things like Itpl which rely on its existence
3401 namespace so that things like Itpl which rely on its existence
3394 don't crash.
3402 don't crash.
3395 (InteractiveShell._prefilter): Defined the default with a _ so
3403 (InteractiveShell._prefilter): Defined the default with a _ so
3396 that prefilter() is easier to override, while the default one
3404 that prefilter() is easier to override, while the default one
3397 remains available.
3405 remains available.
3398
3406
3399 2002-04-18 Fernando Perez <fperez@colorado.edu>
3407 2002-04-18 Fernando Perez <fperez@colorado.edu>
3400
3408
3401 * Added information about pdb in the docs.
3409 * Added information about pdb in the docs.
3402
3410
3403 2002-04-17 Fernando Perez <fperez@colorado.edu>
3411 2002-04-17 Fernando Perez <fperez@colorado.edu>
3404
3412
3405 * IPython/ipmaker.py (make_IPython): added rc_override option to
3413 * IPython/ipmaker.py (make_IPython): added rc_override option to
3406 allow passing config options at creation time which may override
3414 allow passing config options at creation time which may override
3407 anything set in the config files or command line. This is
3415 anything set in the config files or command line. This is
3408 particularly useful for configuring embedded instances.
3416 particularly useful for configuring embedded instances.
3409
3417
3410 2002-04-15 Fernando Perez <fperez@colorado.edu>
3418 2002-04-15 Fernando Perez <fperez@colorado.edu>
3411
3419
3412 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3420 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
3413 crash embedded instances because of the input cache falling out of
3421 crash embedded instances because of the input cache falling out of
3414 sync with the output counter.
3422 sync with the output counter.
3415
3423
3416 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3424 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
3417 mode which calls pdb after an uncaught exception in IPython itself.
3425 mode which calls pdb after an uncaught exception in IPython itself.
3418
3426
3419 2002-04-14 Fernando Perez <fperez@colorado.edu>
3427 2002-04-14 Fernando Perez <fperez@colorado.edu>
3420
3428
3421 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3429 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
3422 readline, fix it back after each call.
3430 readline, fix it back after each call.
3423
3431
3424 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3432 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
3425 method to force all access via __call__(), which guarantees that
3433 method to force all access via __call__(), which guarantees that
3426 traceback references are properly deleted.
3434 traceback references are properly deleted.
3427
3435
3428 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3436 * IPython/Prompts.py (CachedOutput._display): minor fixes to
3429 improve printing when pprint is in use.
3437 improve printing when pprint is in use.
3430
3438
3431 2002-04-13 Fernando Perez <fperez@colorado.edu>
3439 2002-04-13 Fernando Perez <fperez@colorado.edu>
3432
3440
3433 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3441 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
3434 exceptions aren't caught anymore. If the user triggers one, he
3442 exceptions aren't caught anymore. If the user triggers one, he
3435 should know why he's doing it and it should go all the way up,
3443 should know why he's doing it and it should go all the way up,
3436 just like any other exception. So now @abort will fully kill the
3444 just like any other exception. So now @abort will fully kill the
3437 embedded interpreter and the embedding code (unless that happens
3445 embedded interpreter and the embedding code (unless that happens
3438 to catch SystemExit).
3446 to catch SystemExit).
3439
3447
3440 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3448 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
3441 and a debugger() method to invoke the interactive pdb debugger
3449 and a debugger() method to invoke the interactive pdb debugger
3442 after printing exception information. Also added the corresponding
3450 after printing exception information. Also added the corresponding
3443 -pdb option and @pdb magic to control this feature, and updated
3451 -pdb option and @pdb magic to control this feature, and updated
3444 the docs. After a suggestion from Christopher Hart
3452 the docs. After a suggestion from Christopher Hart
3445 (hart-AT-caltech.edu).
3453 (hart-AT-caltech.edu).
3446
3454
3447 2002-04-12 Fernando Perez <fperez@colorado.edu>
3455 2002-04-12 Fernando Perez <fperez@colorado.edu>
3448
3456
3449 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3457 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
3450 the exception handlers defined by the user (not the CrashHandler)
3458 the exception handlers defined by the user (not the CrashHandler)
3451 so that user exceptions don't trigger an ipython bug report.
3459 so that user exceptions don't trigger an ipython bug report.
3452
3460
3453 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3461 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
3454 configurable (it should have always been so).
3462 configurable (it should have always been so).
3455
3463
3456 2002-03-26 Fernando Perez <fperez@colorado.edu>
3464 2002-03-26 Fernando Perez <fperez@colorado.edu>
3457
3465
3458 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3466 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
3459 and there to fix embedding namespace issues. This should all be
3467 and there to fix embedding namespace issues. This should all be
3460 done in a more elegant way.
3468 done in a more elegant way.
3461
3469
3462 2002-03-25 Fernando Perez <fperez@colorado.edu>
3470 2002-03-25 Fernando Perez <fperez@colorado.edu>
3463
3471
3464 * IPython/genutils.py (get_home_dir): Try to make it work under
3472 * IPython/genutils.py (get_home_dir): Try to make it work under
3465 win9x also.
3473 win9x also.
3466
3474
3467 2002-03-20 Fernando Perez <fperez@colorado.edu>
3475 2002-03-20 Fernando Perez <fperez@colorado.edu>
3468
3476
3469 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3477 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
3470 sys.displayhook untouched upon __init__.
3478 sys.displayhook untouched upon __init__.
3471
3479
3472 2002-03-19 Fernando Perez <fperez@colorado.edu>
3480 2002-03-19 Fernando Perez <fperez@colorado.edu>
3473
3481
3474 * Released 0.2.9 (for embedding bug, basically).
3482 * Released 0.2.9 (for embedding bug, basically).
3475
3483
3476 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3484 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
3477 exceptions so that enclosing shell's state can be restored.
3485 exceptions so that enclosing shell's state can be restored.
3478
3486
3479 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3487 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
3480 naming conventions in the .ipython/ dir.
3488 naming conventions in the .ipython/ dir.
3481
3489
3482 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3490 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
3483 from delimiters list so filenames with - in them get expanded.
3491 from delimiters list so filenames with - in them get expanded.
3484
3492
3485 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3493 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
3486 sys.displayhook not being properly restored after an embedded call.
3494 sys.displayhook not being properly restored after an embedded call.
3487
3495
3488 2002-03-18 Fernando Perez <fperez@colorado.edu>
3496 2002-03-18 Fernando Perez <fperez@colorado.edu>
3489
3497
3490 * Released 0.2.8
3498 * Released 0.2.8
3491
3499
3492 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3500 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
3493 some files weren't being included in a -upgrade.
3501 some files weren't being included in a -upgrade.
3494 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3502 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
3495 on' so that the first tab completes.
3503 on' so that the first tab completes.
3496 (InteractiveShell.handle_magic): fixed bug with spaces around
3504 (InteractiveShell.handle_magic): fixed bug with spaces around
3497 quotes breaking many magic commands.
3505 quotes breaking many magic commands.
3498
3506
3499 * setup.py: added note about ignoring the syntax error messages at
3507 * setup.py: added note about ignoring the syntax error messages at
3500 installation.
3508 installation.
3501
3509
3502 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3510 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
3503 streamlining the gnuplot interface, now there's only one magic @gp.
3511 streamlining the gnuplot interface, now there's only one magic @gp.
3504
3512
3505 2002-03-17 Fernando Perez <fperez@colorado.edu>
3513 2002-03-17 Fernando Perez <fperez@colorado.edu>
3506
3514
3507 * IPython/UserConfig/magic_gnuplot.py: new name for the
3515 * IPython/UserConfig/magic_gnuplot.py: new name for the
3508 example-magic_pm.py file. Much enhanced system, now with a shell
3516 example-magic_pm.py file. Much enhanced system, now with a shell
3509 for communicating directly with gnuplot, one command at a time.
3517 for communicating directly with gnuplot, one command at a time.
3510
3518
3511 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3519 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
3512 setting __name__=='__main__'.
3520 setting __name__=='__main__'.
3513
3521
3514 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3522 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
3515 mini-shell for accessing gnuplot from inside ipython. Should
3523 mini-shell for accessing gnuplot from inside ipython. Should
3516 extend it later for grace access too. Inspired by Arnd's
3524 extend it later for grace access too. Inspired by Arnd's
3517 suggestion.
3525 suggestion.
3518
3526
3519 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3527 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
3520 calling magic functions with () in their arguments. Thanks to Arnd
3528 calling magic functions with () in their arguments. Thanks to Arnd
3521 Baecker for pointing this to me.
3529 Baecker for pointing this to me.
3522
3530
3523 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3531 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
3524 infinitely for integer or complex arrays (only worked with floats).
3532 infinitely for integer or complex arrays (only worked with floats).
3525
3533
3526 2002-03-16 Fernando Perez <fperez@colorado.edu>
3534 2002-03-16 Fernando Perez <fperez@colorado.edu>
3527
3535
3528 * setup.py: Merged setup and setup_windows into a single script
3536 * setup.py: Merged setup and setup_windows into a single script
3529 which properly handles things for windows users.
3537 which properly handles things for windows users.
3530
3538
3531 2002-03-15 Fernando Perez <fperez@colorado.edu>
3539 2002-03-15 Fernando Perez <fperez@colorado.edu>
3532
3540
3533 * Big change to the manual: now the magics are all automatically
3541 * Big change to the manual: now the magics are all automatically
3534 documented. This information is generated from their docstrings
3542 documented. This information is generated from their docstrings
3535 and put in a latex file included by the manual lyx file. This way
3543 and put in a latex file included by the manual lyx file. This way
3536 we get always up to date information for the magics. The manual
3544 we get always up to date information for the magics. The manual
3537 now also has proper version information, also auto-synced.
3545 now also has proper version information, also auto-synced.
3538
3546
3539 For this to work, an undocumented --magic_docstrings option was added.
3547 For this to work, an undocumented --magic_docstrings option was added.
3540
3548
3541 2002-03-13 Fernando Perez <fperez@colorado.edu>
3549 2002-03-13 Fernando Perez <fperez@colorado.edu>
3542
3550
3543 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3551 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
3544 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3552 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
3545
3553
3546 2002-03-12 Fernando Perez <fperez@colorado.edu>
3554 2002-03-12 Fernando Perez <fperez@colorado.edu>
3547
3555
3548 * IPython/ultraTB.py (TermColors): changed color escapes again to
3556 * IPython/ultraTB.py (TermColors): changed color escapes again to
3549 fix the (old, reintroduced) line-wrapping bug. Basically, if
3557 fix the (old, reintroduced) line-wrapping bug. Basically, if
3550 \001..\002 aren't given in the color escapes, lines get wrapped
3558 \001..\002 aren't given in the color escapes, lines get wrapped
3551 weirdly. But giving those screws up old xterms and emacs terms. So
3559 weirdly. But giving those screws up old xterms and emacs terms. So
3552 I added some logic for emacs terms to be ok, but I can't identify old
3560 I added some logic for emacs terms to be ok, but I can't identify old
3553 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3561 xterms separately ($TERM=='xterm' for many terminals, like konsole).
3554
3562
3555 2002-03-10 Fernando Perez <fperez@colorado.edu>
3563 2002-03-10 Fernando Perez <fperez@colorado.edu>
3556
3564
3557 * IPython/usage.py (__doc__): Various documentation cleanups and
3565 * IPython/usage.py (__doc__): Various documentation cleanups and
3558 updates, both in usage docstrings and in the manual.
3566 updates, both in usage docstrings and in the manual.
3559
3567
3560 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3568 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
3561 handling of caching. Set minimum acceptabe value for having a
3569 handling of caching. Set minimum acceptabe value for having a
3562 cache at 20 values.
3570 cache at 20 values.
3563
3571
3564 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3572 * IPython/iplib.py (InteractiveShell.user_setup): moved the
3565 install_first_time function to a method, renamed it and added an
3573 install_first_time function to a method, renamed it and added an
3566 'upgrade' mode. Now people can update their config directory with
3574 'upgrade' mode. Now people can update their config directory with
3567 a simple command line switch (-upgrade, also new).
3575 a simple command line switch (-upgrade, also new).
3568
3576
3569 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3577 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
3570 @file (convenient for automagic users under Python >= 2.2).
3578 @file (convenient for automagic users under Python >= 2.2).
3571 Removed @files (it seemed more like a plural than an abbrev. of
3579 Removed @files (it seemed more like a plural than an abbrev. of
3572 'file show').
3580 'file show').
3573
3581
3574 * IPython/iplib.py (install_first_time): Fixed crash if there were
3582 * IPython/iplib.py (install_first_time): Fixed crash if there were
3575 backup files ('~') in .ipython/ install directory.
3583 backup files ('~') in .ipython/ install directory.
3576
3584
3577 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3585 * IPython/ipmaker.py (make_IPython): fixes for new prompt
3578 system. Things look fine, but these changes are fairly
3586 system. Things look fine, but these changes are fairly
3579 intrusive. Test them for a few days.
3587 intrusive. Test them for a few days.
3580
3588
3581 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3589 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
3582 the prompts system. Now all in/out prompt strings are user
3590 the prompts system. Now all in/out prompt strings are user
3583 controllable. This is particularly useful for embedding, as one
3591 controllable. This is particularly useful for embedding, as one
3584 can tag embedded instances with particular prompts.
3592 can tag embedded instances with particular prompts.
3585
3593
3586 Also removed global use of sys.ps1/2, which now allows nested
3594 Also removed global use of sys.ps1/2, which now allows nested
3587 embeddings without any problems. Added command-line options for
3595 embeddings without any problems. Added command-line options for
3588 the prompt strings.
3596 the prompt strings.
3589
3597
3590 2002-03-08 Fernando Perez <fperez@colorado.edu>
3598 2002-03-08 Fernando Perez <fperez@colorado.edu>
3591
3599
3592 * IPython/UserConfig/example-embed-short.py (ipshell): added
3600 * IPython/UserConfig/example-embed-short.py (ipshell): added
3593 example file with the bare minimum code for embedding.
3601 example file with the bare minimum code for embedding.
3594
3602
3595 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3603 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
3596 functionality for the embeddable shell to be activated/deactivated
3604 functionality for the embeddable shell to be activated/deactivated
3597 either globally or at each call.
3605 either globally or at each call.
3598
3606
3599 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3607 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
3600 rewriting the prompt with '--->' for auto-inputs with proper
3608 rewriting the prompt with '--->' for auto-inputs with proper
3601 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3609 coloring. Now the previous UGLY hack in handle_auto() is gone, and
3602 this is handled by the prompts class itself, as it should.
3610 this is handled by the prompts class itself, as it should.
3603
3611
3604 2002-03-05 Fernando Perez <fperez@colorado.edu>
3612 2002-03-05 Fernando Perez <fperez@colorado.edu>
3605
3613
3606 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3614 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
3607 @logstart to avoid name clashes with the math log function.
3615 @logstart to avoid name clashes with the math log function.
3608
3616
3609 * Big updates to X/Emacs section of the manual.
3617 * Big updates to X/Emacs section of the manual.
3610
3618
3611 * Removed ipython_emacs. Milan explained to me how to pass
3619 * Removed ipython_emacs. Milan explained to me how to pass
3612 arguments to ipython through Emacs. Some day I'm going to end up
3620 arguments to ipython through Emacs. Some day I'm going to end up
3613 learning some lisp...
3621 learning some lisp...
3614
3622
3615 2002-03-04 Fernando Perez <fperez@colorado.edu>
3623 2002-03-04 Fernando Perez <fperez@colorado.edu>
3616
3624
3617 * IPython/ipython_emacs: Created script to be used as the
3625 * IPython/ipython_emacs: Created script to be used as the
3618 py-python-command Emacs variable so we can pass IPython
3626 py-python-command Emacs variable so we can pass IPython
3619 parameters. I can't figure out how to tell Emacs directly to pass
3627 parameters. I can't figure out how to tell Emacs directly to pass
3620 parameters to IPython, so a dummy shell script will do it.
3628 parameters to IPython, so a dummy shell script will do it.
3621
3629
3622 Other enhancements made for things to work better under Emacs'
3630 Other enhancements made for things to work better under Emacs'
3623 various types of terminals. Many thanks to Milan Zamazal
3631 various types of terminals. Many thanks to Milan Zamazal
3624 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3632 <pdm-AT-zamazal.org> for all the suggestions and pointers.
3625
3633
3626 2002-03-01 Fernando Perez <fperez@colorado.edu>
3634 2002-03-01 Fernando Perez <fperez@colorado.edu>
3627
3635
3628 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3636 * IPython/ipmaker.py (make_IPython): added a --readline! option so
3629 that loading of readline is now optional. This gives better
3637 that loading of readline is now optional. This gives better
3630 control to emacs users.
3638 control to emacs users.
3631
3639
3632 * IPython/ultraTB.py (__date__): Modified color escape sequences
3640 * IPython/ultraTB.py (__date__): Modified color escape sequences
3633 and now things work fine under xterm and in Emacs' term buffers
3641 and now things work fine under xterm and in Emacs' term buffers
3634 (though not shell ones). Well, in emacs you get colors, but all
3642 (though not shell ones). Well, in emacs you get colors, but all
3635 seem to be 'light' colors (no difference between dark and light
3643 seem to be 'light' colors (no difference between dark and light
3636 ones). But the garbage chars are gone, and also in xterms. It
3644 ones). But the garbage chars are gone, and also in xterms. It
3637 seems that now I'm using 'cleaner' ansi sequences.
3645 seems that now I'm using 'cleaner' ansi sequences.
3638
3646
3639 2002-02-21 Fernando Perez <fperez@colorado.edu>
3647 2002-02-21 Fernando Perez <fperez@colorado.edu>
3640
3648
3641 * Released 0.2.7 (mainly to publish the scoping fix).
3649 * Released 0.2.7 (mainly to publish the scoping fix).
3642
3650
3643 * IPython/Logger.py (Logger.logstate): added. A corresponding
3651 * IPython/Logger.py (Logger.logstate): added. A corresponding
3644 @logstate magic was created.
3652 @logstate magic was created.
3645
3653
3646 * IPython/Magic.py: fixed nested scoping problem under Python
3654 * IPython/Magic.py: fixed nested scoping problem under Python
3647 2.1.x (automagic wasn't working).
3655 2.1.x (automagic wasn't working).
3648
3656
3649 2002-02-20 Fernando Perez <fperez@colorado.edu>
3657 2002-02-20 Fernando Perez <fperez@colorado.edu>
3650
3658
3651 * Released 0.2.6.
3659 * Released 0.2.6.
3652
3660
3653 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3661 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
3654 option so that logs can come out without any headers at all.
3662 option so that logs can come out without any headers at all.
3655
3663
3656 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3664 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
3657 SciPy.
3665 SciPy.
3658
3666
3659 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3667 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
3660 that embedded IPython calls don't require vars() to be explicitly
3668 that embedded IPython calls don't require vars() to be explicitly
3661 passed. Now they are extracted from the caller's frame (code
3669 passed. Now they are extracted from the caller's frame (code
3662 snatched from Eric Jones' weave). Added better documentation to
3670 snatched from Eric Jones' weave). Added better documentation to
3663 the section on embedding and the example file.
3671 the section on embedding and the example file.
3664
3672
3665 * IPython/genutils.py (page): Changed so that under emacs, it just
3673 * IPython/genutils.py (page): Changed so that under emacs, it just
3666 prints the string. You can then page up and down in the emacs
3674 prints the string. You can then page up and down in the emacs
3667 buffer itself. This is how the builtin help() works.
3675 buffer itself. This is how the builtin help() works.
3668
3676
3669 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3677 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
3670 macro scoping: macros need to be executed in the user's namespace
3678 macro scoping: macros need to be executed in the user's namespace
3671 to work as if they had been typed by the user.
3679 to work as if they had been typed by the user.
3672
3680
3673 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3681 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
3674 execute automatically (no need to type 'exec...'). They then
3682 execute automatically (no need to type 'exec...'). They then
3675 behave like 'true macros'. The printing system was also modified
3683 behave like 'true macros'. The printing system was also modified
3676 for this to work.
3684 for this to work.
3677
3685
3678 2002-02-19 Fernando Perez <fperez@colorado.edu>
3686 2002-02-19 Fernando Perez <fperez@colorado.edu>
3679
3687
3680 * IPython/genutils.py (page_file): new function for paging files
3688 * IPython/genutils.py (page_file): new function for paging files
3681 in an OS-independent way. Also necessary for file viewing to work
3689 in an OS-independent way. Also necessary for file viewing to work
3682 well inside Emacs buffers.
3690 well inside Emacs buffers.
3683 (page): Added checks for being in an emacs buffer.
3691 (page): Added checks for being in an emacs buffer.
3684 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3692 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
3685 same bug in iplib.
3693 same bug in iplib.
3686
3694
3687 2002-02-18 Fernando Perez <fperez@colorado.edu>
3695 2002-02-18 Fernando Perez <fperez@colorado.edu>
3688
3696
3689 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3697 * IPython/iplib.py (InteractiveShell.init_readline): modified use
3690 of readline so that IPython can work inside an Emacs buffer.
3698 of readline so that IPython can work inside an Emacs buffer.
3691
3699
3692 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3700 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
3693 method signatures (they weren't really bugs, but it looks cleaner
3701 method signatures (they weren't really bugs, but it looks cleaner
3694 and keeps PyChecker happy).
3702 and keeps PyChecker happy).
3695
3703
3696 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3704 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
3697 for implementing various user-defined hooks. Currently only
3705 for implementing various user-defined hooks. Currently only
3698 display is done.
3706 display is done.
3699
3707
3700 * IPython/Prompts.py (CachedOutput._display): changed display
3708 * IPython/Prompts.py (CachedOutput._display): changed display
3701 functions so that they can be dynamically changed by users easily.
3709 functions so that they can be dynamically changed by users easily.
3702
3710
3703 * IPython/Extensions/numeric_formats.py (num_display): added an
3711 * IPython/Extensions/numeric_formats.py (num_display): added an
3704 extension for printing NumPy arrays in flexible manners. It
3712 extension for printing NumPy arrays in flexible manners. It
3705 doesn't do anything yet, but all the structure is in
3713 doesn't do anything yet, but all the structure is in
3706 place. Ultimately the plan is to implement output format control
3714 place. Ultimately the plan is to implement output format control
3707 like in Octave.
3715 like in Octave.
3708
3716
3709 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3717 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
3710 methods are found at run-time by all the automatic machinery.
3718 methods are found at run-time by all the automatic machinery.
3711
3719
3712 2002-02-17 Fernando Perez <fperez@colorado.edu>
3720 2002-02-17 Fernando Perez <fperez@colorado.edu>
3713
3721
3714 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3722 * setup_Windows.py (make_shortcut): documented. Cleaned up the
3715 whole file a little.
3723 whole file a little.
3716
3724
3717 * ToDo: closed this document. Now there's a new_design.lyx
3725 * ToDo: closed this document. Now there's a new_design.lyx
3718 document for all new ideas. Added making a pdf of it for the
3726 document for all new ideas. Added making a pdf of it for the
3719 end-user distro.
3727 end-user distro.
3720
3728
3721 * IPython/Logger.py (Logger.switch_log): Created this to replace
3729 * IPython/Logger.py (Logger.switch_log): Created this to replace
3722 logon() and logoff(). It also fixes a nasty crash reported by
3730 logon() and logoff(). It also fixes a nasty crash reported by
3723 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3731 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
3724
3732
3725 * IPython/iplib.py (complete): got auto-completion to work with
3733 * IPython/iplib.py (complete): got auto-completion to work with
3726 automagic (I had wanted this for a long time).
3734 automagic (I had wanted this for a long time).
3727
3735
3728 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3736 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
3729 to @file, since file() is now a builtin and clashes with automagic
3737 to @file, since file() is now a builtin and clashes with automagic
3730 for @file.
3738 for @file.
3731
3739
3732 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3740 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
3733 of this was previously in iplib, which had grown to more than 2000
3741 of this was previously in iplib, which had grown to more than 2000
3734 lines, way too long. No new functionality, but it makes managing
3742 lines, way too long. No new functionality, but it makes managing
3735 the code a bit easier.
3743 the code a bit easier.
3736
3744
3737 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3745 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
3738 information to crash reports.
3746 information to crash reports.
3739
3747
3740 2002-02-12 Fernando Perez <fperez@colorado.edu>
3748 2002-02-12 Fernando Perez <fperez@colorado.edu>
3741
3749
3742 * Released 0.2.5.
3750 * Released 0.2.5.
3743
3751
3744 2002-02-11 Fernando Perez <fperez@colorado.edu>
3752 2002-02-11 Fernando Perez <fperez@colorado.edu>
3745
3753
3746 * Wrote a relatively complete Windows installer. It puts
3754 * Wrote a relatively complete Windows installer. It puts
3747 everything in place, creates Start Menu entries and fixes the
3755 everything in place, creates Start Menu entries and fixes the
3748 color issues. Nothing fancy, but it works.
3756 color issues. Nothing fancy, but it works.
3749
3757
3750 2002-02-10 Fernando Perez <fperez@colorado.edu>
3758 2002-02-10 Fernando Perez <fperez@colorado.edu>
3751
3759
3752 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3760 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
3753 os.path.expanduser() call so that we can type @run ~/myfile.py and
3761 os.path.expanduser() call so that we can type @run ~/myfile.py and
3754 have thigs work as expected.
3762 have thigs work as expected.
3755
3763
3756 * IPython/genutils.py (page): fixed exception handling so things
3764 * IPython/genutils.py (page): fixed exception handling so things
3757 work both in Unix and Windows correctly. Quitting a pager triggers
3765 work both in Unix and Windows correctly. Quitting a pager triggers
3758 an IOError/broken pipe in Unix, and in windows not finding a pager
3766 an IOError/broken pipe in Unix, and in windows not finding a pager
3759 is also an IOError, so I had to actually look at the return value
3767 is also an IOError, so I had to actually look at the return value
3760 of the exception, not just the exception itself. Should be ok now.
3768 of the exception, not just the exception itself. Should be ok now.
3761
3769
3762 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3770 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
3763 modified to allow case-insensitive color scheme changes.
3771 modified to allow case-insensitive color scheme changes.
3764
3772
3765 2002-02-09 Fernando Perez <fperez@colorado.edu>
3773 2002-02-09 Fernando Perez <fperez@colorado.edu>
3766
3774
3767 * IPython/genutils.py (native_line_ends): new function to leave
3775 * IPython/genutils.py (native_line_ends): new function to leave
3768 user config files with os-native line-endings.
3776 user config files with os-native line-endings.
3769
3777
3770 * README and manual updates.
3778 * README and manual updates.
3771
3779
3772 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3780 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
3773 instead of StringType to catch Unicode strings.
3781 instead of StringType to catch Unicode strings.
3774
3782
3775 * IPython/genutils.py (filefind): fixed bug for paths with
3783 * IPython/genutils.py (filefind): fixed bug for paths with
3776 embedded spaces (very common in Windows).
3784 embedded spaces (very common in Windows).
3777
3785
3778 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3786 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
3779 files under Windows, so that they get automatically associated
3787 files under Windows, so that they get automatically associated
3780 with a text editor. Windows makes it a pain to handle
3788 with a text editor. Windows makes it a pain to handle
3781 extension-less files.
3789 extension-less files.
3782
3790
3783 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3791 * IPython/iplib.py (InteractiveShell.init_readline): Made the
3784 warning about readline only occur for Posix. In Windows there's no
3792 warning about readline only occur for Posix. In Windows there's no
3785 way to get readline, so why bother with the warning.
3793 way to get readline, so why bother with the warning.
3786
3794
3787 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3795 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
3788 for __str__ instead of dir(self), since dir() changed in 2.2.
3796 for __str__ instead of dir(self), since dir() changed in 2.2.
3789
3797
3790 * Ported to Windows! Tested on XP, I suspect it should work fine
3798 * Ported to Windows! Tested on XP, I suspect it should work fine
3791 on NT/2000, but I don't think it will work on 98 et al. That
3799 on NT/2000, but I don't think it will work on 98 et al. That
3792 series of Windows is such a piece of junk anyway that I won't try
3800 series of Windows is such a piece of junk anyway that I won't try
3793 porting it there. The XP port was straightforward, showed a few
3801 porting it there. The XP port was straightforward, showed a few
3794 bugs here and there (fixed all), in particular some string
3802 bugs here and there (fixed all), in particular some string
3795 handling stuff which required considering Unicode strings (which
3803 handling stuff which required considering Unicode strings (which
3796 Windows uses). This is good, but hasn't been too tested :) No
3804 Windows uses). This is good, but hasn't been too tested :) No
3797 fancy installer yet, I'll put a note in the manual so people at
3805 fancy installer yet, I'll put a note in the manual so people at
3798 least make manually a shortcut.
3806 least make manually a shortcut.
3799
3807
3800 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3808 * IPython/iplib.py (Magic.magic_colors): Unified the color options
3801 into a single one, "colors". This now controls both prompt and
3809 into a single one, "colors". This now controls both prompt and
3802 exception color schemes, and can be changed both at startup
3810 exception color schemes, and can be changed both at startup
3803 (either via command-line switches or via ipythonrc files) and at
3811 (either via command-line switches or via ipythonrc files) and at
3804 runtime, with @colors.
3812 runtime, with @colors.
3805 (Magic.magic_run): renamed @prun to @run and removed the old
3813 (Magic.magic_run): renamed @prun to @run and removed the old
3806 @run. The two were too similar to warrant keeping both.
3814 @run. The two were too similar to warrant keeping both.
3807
3815
3808 2002-02-03 Fernando Perez <fperez@colorado.edu>
3816 2002-02-03 Fernando Perez <fperez@colorado.edu>
3809
3817
3810 * IPython/iplib.py (install_first_time): Added comment on how to
3818 * IPython/iplib.py (install_first_time): Added comment on how to
3811 configure the color options for first-time users. Put a <return>
3819 configure the color options for first-time users. Put a <return>
3812 request at the end so that small-terminal users get a chance to
3820 request at the end so that small-terminal users get a chance to
3813 read the startup info.
3821 read the startup info.
3814
3822
3815 2002-01-23 Fernando Perez <fperez@colorado.edu>
3823 2002-01-23 Fernando Perez <fperez@colorado.edu>
3816
3824
3817 * IPython/iplib.py (CachedOutput.update): Changed output memory
3825 * IPython/iplib.py (CachedOutput.update): Changed output memory
3818 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3826 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
3819 input history we still use _i. Did this b/c these variable are
3827 input history we still use _i. Did this b/c these variable are
3820 very commonly used in interactive work, so the less we need to
3828 very commonly used in interactive work, so the less we need to
3821 type the better off we are.
3829 type the better off we are.
3822 (Magic.magic_prun): updated @prun to better handle the namespaces
3830 (Magic.magic_prun): updated @prun to better handle the namespaces
3823 the file will run in, including a fix for __name__ not being set
3831 the file will run in, including a fix for __name__ not being set
3824 before.
3832 before.
3825
3833
3826 2002-01-20 Fernando Perez <fperez@colorado.edu>
3834 2002-01-20 Fernando Perez <fperez@colorado.edu>
3827
3835
3828 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3836 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
3829 extra garbage for Python 2.2. Need to look more carefully into
3837 extra garbage for Python 2.2. Need to look more carefully into
3830 this later.
3838 this later.
3831
3839
3832 2002-01-19 Fernando Perez <fperez@colorado.edu>
3840 2002-01-19 Fernando Perez <fperez@colorado.edu>
3833
3841
3834 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3842 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
3835 display SyntaxError exceptions properly formatted when they occur
3843 display SyntaxError exceptions properly formatted when they occur
3836 (they can be triggered by imported code).
3844 (they can be triggered by imported code).
3837
3845
3838 2002-01-18 Fernando Perez <fperez@colorado.edu>
3846 2002-01-18 Fernando Perez <fperez@colorado.edu>
3839
3847
3840 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3848 * IPython/iplib.py (InteractiveShell.safe_execfile): now
3841 SyntaxError exceptions are reported nicely formatted, instead of
3849 SyntaxError exceptions are reported nicely formatted, instead of
3842 spitting out only offset information as before.
3850 spitting out only offset information as before.
3843 (Magic.magic_prun): Added the @prun function for executing
3851 (Magic.magic_prun): Added the @prun function for executing
3844 programs with command line args inside IPython.
3852 programs with command line args inside IPython.
3845
3853
3846 2002-01-16 Fernando Perez <fperez@colorado.edu>
3854 2002-01-16 Fernando Perez <fperez@colorado.edu>
3847
3855
3848 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3856 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
3849 to *not* include the last item given in a range. This brings their
3857 to *not* include the last item given in a range. This brings their
3850 behavior in line with Python's slicing:
3858 behavior in line with Python's slicing:
3851 a[n1:n2] -> a[n1]...a[n2-1]
3859 a[n1:n2] -> a[n1]...a[n2-1]
3852 It may be a bit less convenient, but I prefer to stick to Python's
3860 It may be a bit less convenient, but I prefer to stick to Python's
3853 conventions *everywhere*, so users never have to wonder.
3861 conventions *everywhere*, so users never have to wonder.
3854 (Magic.magic_macro): Added @macro function to ease the creation of
3862 (Magic.magic_macro): Added @macro function to ease the creation of
3855 macros.
3863 macros.
3856
3864
3857 2002-01-05 Fernando Perez <fperez@colorado.edu>
3865 2002-01-05 Fernando Perez <fperez@colorado.edu>
3858
3866
3859 * Released 0.2.4.
3867 * Released 0.2.4.
3860
3868
3861 * IPython/iplib.py (Magic.magic_pdef):
3869 * IPython/iplib.py (Magic.magic_pdef):
3862 (InteractiveShell.safe_execfile): report magic lines and error
3870 (InteractiveShell.safe_execfile): report magic lines and error
3863 lines without line numbers so one can easily copy/paste them for
3871 lines without line numbers so one can easily copy/paste them for
3864 re-execution.
3872 re-execution.
3865
3873
3866 * Updated manual with recent changes.
3874 * Updated manual with recent changes.
3867
3875
3868 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3876 * IPython/iplib.py (Magic.magic_oinfo): added constructor
3869 docstring printing when class? is called. Very handy for knowing
3877 docstring printing when class? is called. Very handy for knowing
3870 how to create class instances (as long as __init__ is well
3878 how to create class instances (as long as __init__ is well
3871 documented, of course :)
3879 documented, of course :)
3872 (Magic.magic_doc): print both class and constructor docstrings.
3880 (Magic.magic_doc): print both class and constructor docstrings.
3873 (Magic.magic_pdef): give constructor info if passed a class and
3881 (Magic.magic_pdef): give constructor info if passed a class and
3874 __call__ info for callable object instances.
3882 __call__ info for callable object instances.
3875
3883
3876 2002-01-04 Fernando Perez <fperez@colorado.edu>
3884 2002-01-04 Fernando Perez <fperez@colorado.edu>
3877
3885
3878 * Made deep_reload() off by default. It doesn't always work
3886 * Made deep_reload() off by default. It doesn't always work
3879 exactly as intended, so it's probably safer to have it off. It's
3887 exactly as intended, so it's probably safer to have it off. It's
3880 still available as dreload() anyway, so nothing is lost.
3888 still available as dreload() anyway, so nothing is lost.
3881
3889
3882 2002-01-02 Fernando Perez <fperez@colorado.edu>
3890 2002-01-02 Fernando Perez <fperez@colorado.edu>
3883
3891
3884 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3892 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
3885 so I wanted an updated release).
3893 so I wanted an updated release).
3886
3894
3887 2001-12-27 Fernando Perez <fperez@colorado.edu>
3895 2001-12-27 Fernando Perez <fperez@colorado.edu>
3888
3896
3889 * IPython/iplib.py (InteractiveShell.interact): Added the original
3897 * IPython/iplib.py (InteractiveShell.interact): Added the original
3890 code from 'code.py' for this module in order to change the
3898 code from 'code.py' for this module in order to change the
3891 handling of a KeyboardInterrupt. This was necessary b/c otherwise
3899 handling of a KeyboardInterrupt. This was necessary b/c otherwise
3892 the history cache would break when the user hit Ctrl-C, and
3900 the history cache would break when the user hit Ctrl-C, and
3893 interact() offers no way to add any hooks to it.
3901 interact() offers no way to add any hooks to it.
3894
3902
3895 2001-12-23 Fernando Perez <fperez@colorado.edu>
3903 2001-12-23 Fernando Perez <fperez@colorado.edu>
3896
3904
3897 * setup.py: added check for 'MANIFEST' before trying to remove
3905 * setup.py: added check for 'MANIFEST' before trying to remove
3898 it. Thanks to Sean Reifschneider.
3906 it. Thanks to Sean Reifschneider.
3899
3907
3900 2001-12-22 Fernando Perez <fperez@colorado.edu>
3908 2001-12-22 Fernando Perez <fperez@colorado.edu>
3901
3909
3902 * Released 0.2.2.
3910 * Released 0.2.2.
3903
3911
3904 * Finished (reasonably) writing the manual. Later will add the
3912 * Finished (reasonably) writing the manual. Later will add the
3905 python-standard navigation stylesheets, but for the time being
3913 python-standard navigation stylesheets, but for the time being
3906 it's fairly complete. Distribution will include html and pdf
3914 it's fairly complete. Distribution will include html and pdf
3907 versions.
3915 versions.
3908
3916
3909 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
3917 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
3910 (MayaVi author).
3918 (MayaVi author).
3911
3919
3912 2001-12-21 Fernando Perez <fperez@colorado.edu>
3920 2001-12-21 Fernando Perez <fperez@colorado.edu>
3913
3921
3914 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
3922 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
3915 good public release, I think (with the manual and the distutils
3923 good public release, I think (with the manual and the distutils
3916 installer). The manual can use some work, but that can go
3924 installer). The manual can use some work, but that can go
3917 slowly. Otherwise I think it's quite nice for end users. Next
3925 slowly. Otherwise I think it's quite nice for end users. Next
3918 summer, rewrite the guts of it...
3926 summer, rewrite the guts of it...
3919
3927
3920 * Changed format of ipythonrc files to use whitespace as the
3928 * Changed format of ipythonrc files to use whitespace as the
3921 separator instead of an explicit '='. Cleaner.
3929 separator instead of an explicit '='. Cleaner.
3922
3930
3923 2001-12-20 Fernando Perez <fperez@colorado.edu>
3931 2001-12-20 Fernando Perez <fperez@colorado.edu>
3924
3932
3925 * Started a manual in LyX. For now it's just a quick merge of the
3933 * Started a manual in LyX. For now it's just a quick merge of the
3926 various internal docstrings and READMEs. Later it may grow into a
3934 various internal docstrings and READMEs. Later it may grow into a
3927 nice, full-blown manual.
3935 nice, full-blown manual.
3928
3936
3929 * Set up a distutils based installer. Installation should now be
3937 * Set up a distutils based installer. Installation should now be
3930 trivially simple for end-users.
3938 trivially simple for end-users.
3931
3939
3932 2001-12-11 Fernando Perez <fperez@colorado.edu>
3940 2001-12-11 Fernando Perez <fperez@colorado.edu>
3933
3941
3934 * Released 0.2.0. First public release, announced it at
3942 * Released 0.2.0. First public release, announced it at
3935 comp.lang.python. From now on, just bugfixes...
3943 comp.lang.python. From now on, just bugfixes...
3936
3944
3937 * Went through all the files, set copyright/license notices and
3945 * Went through all the files, set copyright/license notices and
3938 cleaned up things. Ready for release.
3946 cleaned up things. Ready for release.
3939
3947
3940 2001-12-10 Fernando Perez <fperez@colorado.edu>
3948 2001-12-10 Fernando Perez <fperez@colorado.edu>
3941
3949
3942 * Changed the first-time installer not to use tarfiles. It's more
3950 * Changed the first-time installer not to use tarfiles. It's more
3943 robust now and less unix-dependent. Also makes it easier for
3951 robust now and less unix-dependent. Also makes it easier for
3944 people to later upgrade versions.
3952 people to later upgrade versions.
3945
3953
3946 * Changed @exit to @abort to reflect the fact that it's pretty
3954 * Changed @exit to @abort to reflect the fact that it's pretty
3947 brutal (a sys.exit()). The difference between @abort and Ctrl-D
3955 brutal (a sys.exit()). The difference between @abort and Ctrl-D
3948 becomes significant only when IPyhton is embedded: in that case,
3956 becomes significant only when IPyhton is embedded: in that case,
3949 C-D closes IPython only, but @abort kills the enclosing program
3957 C-D closes IPython only, but @abort kills the enclosing program
3950 too (unless it had called IPython inside a try catching
3958 too (unless it had called IPython inside a try catching
3951 SystemExit).
3959 SystemExit).
3952
3960
3953 * Created Shell module which exposes the actuall IPython Shell
3961 * Created Shell module which exposes the actuall IPython Shell
3954 classes, currently the normal and the embeddable one. This at
3962 classes, currently the normal and the embeddable one. This at
3955 least offers a stable interface we won't need to change when
3963 least offers a stable interface we won't need to change when
3956 (later) the internals are rewritten. That rewrite will be confined
3964 (later) the internals are rewritten. That rewrite will be confined
3957 to iplib and ipmaker, but the Shell interface should remain as is.
3965 to iplib and ipmaker, but the Shell interface should remain as is.
3958
3966
3959 * Added embed module which offers an embeddable IPShell object,
3967 * Added embed module which offers an embeddable IPShell object,
3960 useful to fire up IPython *inside* a running program. Great for
3968 useful to fire up IPython *inside* a running program. Great for
3961 debugging or dynamical data analysis.
3969 debugging or dynamical data analysis.
3962
3970
3963 2001-12-08 Fernando Perez <fperez@colorado.edu>
3971 2001-12-08 Fernando Perez <fperez@colorado.edu>
3964
3972
3965 * Fixed small bug preventing seeing info from methods of defined
3973 * Fixed small bug preventing seeing info from methods of defined
3966 objects (incorrect namespace in _ofind()).
3974 objects (incorrect namespace in _ofind()).
3967
3975
3968 * Documentation cleanup. Moved the main usage docstrings to a
3976 * Documentation cleanup. Moved the main usage docstrings to a
3969 separate file, usage.py (cleaner to maintain, and hopefully in the
3977 separate file, usage.py (cleaner to maintain, and hopefully in the
3970 future some perlpod-like way of producing interactive, man and
3978 future some perlpod-like way of producing interactive, man and
3971 html docs out of it will be found).
3979 html docs out of it will be found).
3972
3980
3973 * Added @profile to see your profile at any time.
3981 * Added @profile to see your profile at any time.
3974
3982
3975 * Added @p as an alias for 'print'. It's especially convenient if
3983 * Added @p as an alias for 'print'. It's especially convenient if
3976 using automagic ('p x' prints x).
3984 using automagic ('p x' prints x).
3977
3985
3978 * Small cleanups and fixes after a pychecker run.
3986 * Small cleanups and fixes after a pychecker run.
3979
3987
3980 * Changed the @cd command to handle @cd - and @cd -<n> for
3988 * Changed the @cd command to handle @cd - and @cd -<n> for
3981 visiting any directory in _dh.
3989 visiting any directory in _dh.
3982
3990
3983 * Introduced _dh, a history of visited directories. @dhist prints
3991 * Introduced _dh, a history of visited directories. @dhist prints
3984 it out with numbers.
3992 it out with numbers.
3985
3993
3986 2001-12-07 Fernando Perez <fperez@colorado.edu>
3994 2001-12-07 Fernando Perez <fperez@colorado.edu>
3987
3995
3988 * Released 0.1.22
3996 * Released 0.1.22
3989
3997
3990 * Made initialization a bit more robust against invalid color
3998 * Made initialization a bit more robust against invalid color
3991 options in user input (exit, not traceback-crash).
3999 options in user input (exit, not traceback-crash).
3992
4000
3993 * Changed the bug crash reporter to write the report only in the
4001 * Changed the bug crash reporter to write the report only in the
3994 user's .ipython directory. That way IPython won't litter people's
4002 user's .ipython directory. That way IPython won't litter people's
3995 hard disks with crash files all over the place. Also print on
4003 hard disks with crash files all over the place. Also print on
3996 screen the necessary mail command.
4004 screen the necessary mail command.
3997
4005
3998 * With the new ultraTB, implemented LightBG color scheme for light
4006 * With the new ultraTB, implemented LightBG color scheme for light
3999 background terminals. A lot of people like white backgrounds, so I
4007 background terminals. A lot of people like white backgrounds, so I
4000 guess we should at least give them something readable.
4008 guess we should at least give them something readable.
4001
4009
4002 2001-12-06 Fernando Perez <fperez@colorado.edu>
4010 2001-12-06 Fernando Perez <fperez@colorado.edu>
4003
4011
4004 * Modified the structure of ultraTB. Now there's a proper class
4012 * Modified the structure of ultraTB. Now there's a proper class
4005 for tables of color schemes which allow adding schemes easily and
4013 for tables of color schemes which allow adding schemes easily and
4006 switching the active scheme without creating a new instance every
4014 switching the active scheme without creating a new instance every
4007 time (which was ridiculous). The syntax for creating new schemes
4015 time (which was ridiculous). The syntax for creating new schemes
4008 is also cleaner. I think ultraTB is finally done, with a clean
4016 is also cleaner. I think ultraTB is finally done, with a clean
4009 class structure. Names are also much cleaner (now there's proper
4017 class structure. Names are also much cleaner (now there's proper
4010 color tables, no need for every variable to also have 'color' in
4018 color tables, no need for every variable to also have 'color' in
4011 its name).
4019 its name).
4012
4020
4013 * Broke down genutils into separate files. Now genutils only
4021 * Broke down genutils into separate files. Now genutils only
4014 contains utility functions, and classes have been moved to their
4022 contains utility functions, and classes have been moved to their
4015 own files (they had enough independent functionality to warrant
4023 own files (they had enough independent functionality to warrant
4016 it): ConfigLoader, OutputTrap, Struct.
4024 it): ConfigLoader, OutputTrap, Struct.
4017
4025
4018 2001-12-05 Fernando Perez <fperez@colorado.edu>
4026 2001-12-05 Fernando Perez <fperez@colorado.edu>
4019
4027
4020 * IPython turns 21! Released version 0.1.21, as a candidate for
4028 * IPython turns 21! Released version 0.1.21, as a candidate for
4021 public consumption. If all goes well, release in a few days.
4029 public consumption. If all goes well, release in a few days.
4022
4030
4023 * Fixed path bug (files in Extensions/ directory wouldn't be found
4031 * Fixed path bug (files in Extensions/ directory wouldn't be found
4024 unless IPython/ was explicitly in sys.path).
4032 unless IPython/ was explicitly in sys.path).
4025
4033
4026 * Extended the FlexCompleter class as MagicCompleter to allow
4034 * Extended the FlexCompleter class as MagicCompleter to allow
4027 completion of @-starting lines.
4035 completion of @-starting lines.
4028
4036
4029 * Created __release__.py file as a central repository for release
4037 * Created __release__.py file as a central repository for release
4030 info that other files can read from.
4038 info that other files can read from.
4031
4039
4032 * Fixed small bug in logging: when logging was turned on in
4040 * Fixed small bug in logging: when logging was turned on in
4033 mid-session, old lines with special meanings (!@?) were being
4041 mid-session, old lines with special meanings (!@?) were being
4034 logged without the prepended comment, which is necessary since
4042 logged without the prepended comment, which is necessary since
4035 they are not truly valid python syntax. This should make session
4043 they are not truly valid python syntax. This should make session
4036 restores produce less errors.
4044 restores produce less errors.
4037
4045
4038 * The namespace cleanup forced me to make a FlexCompleter class
4046 * The namespace cleanup forced me to make a FlexCompleter class
4039 which is nothing but a ripoff of rlcompleter, but with selectable
4047 which is nothing but a ripoff of rlcompleter, but with selectable
4040 namespace (rlcompleter only works in __main__.__dict__). I'll try
4048 namespace (rlcompleter only works in __main__.__dict__). I'll try
4041 to submit a note to the authors to see if this change can be
4049 to submit a note to the authors to see if this change can be
4042 incorporated in future rlcompleter releases (Dec.6: done)
4050 incorporated in future rlcompleter releases (Dec.6: done)
4043
4051
4044 * More fixes to namespace handling. It was a mess! Now all
4052 * More fixes to namespace handling. It was a mess! Now all
4045 explicit references to __main__.__dict__ are gone (except when
4053 explicit references to __main__.__dict__ are gone (except when
4046 really needed) and everything is handled through the namespace
4054 really needed) and everything is handled through the namespace
4047 dicts in the IPython instance. We seem to be getting somewhere
4055 dicts in the IPython instance. We seem to be getting somewhere
4048 with this, finally...
4056 with this, finally...
4049
4057
4050 * Small documentation updates.
4058 * Small documentation updates.
4051
4059
4052 * Created the Extensions directory under IPython (with an
4060 * Created the Extensions directory under IPython (with an
4053 __init__.py). Put the PhysicalQ stuff there. This directory should
4061 __init__.py). Put the PhysicalQ stuff there. This directory should
4054 be used for all special-purpose extensions.
4062 be used for all special-purpose extensions.
4055
4063
4056 * File renaming:
4064 * File renaming:
4057 ipythonlib --> ipmaker
4065 ipythonlib --> ipmaker
4058 ipplib --> iplib
4066 ipplib --> iplib
4059 This makes a bit more sense in terms of what these files actually do.
4067 This makes a bit more sense in terms of what these files actually do.
4060
4068
4061 * Moved all the classes and functions in ipythonlib to ipplib, so
4069 * Moved all the classes and functions in ipythonlib to ipplib, so
4062 now ipythonlib only has make_IPython(). This will ease up its
4070 now ipythonlib only has make_IPython(). This will ease up its
4063 splitting in smaller functional chunks later.
4071 splitting in smaller functional chunks later.
4064
4072
4065 * Cleaned up (done, I think) output of @whos. Better column
4073 * Cleaned up (done, I think) output of @whos. Better column
4066 formatting, and now shows str(var) for as much as it can, which is
4074 formatting, and now shows str(var) for as much as it can, which is
4067 typically what one gets with a 'print var'.
4075 typically what one gets with a 'print var'.
4068
4076
4069 2001-12-04 Fernando Perez <fperez@colorado.edu>
4077 2001-12-04 Fernando Perez <fperez@colorado.edu>
4070
4078
4071 * Fixed namespace problems. Now builtin/IPyhton/user names get
4079 * Fixed namespace problems. Now builtin/IPyhton/user names get
4072 properly reported in their namespace. Internal namespace handling
4080 properly reported in their namespace. Internal namespace handling
4073 is finally getting decent (not perfect yet, but much better than
4081 is finally getting decent (not perfect yet, but much better than
4074 the ad-hoc mess we had).
4082 the ad-hoc mess we had).
4075
4083
4076 * Removed -exit option. If people just want to run a python
4084 * Removed -exit option. If people just want to run a python
4077 script, that's what the normal interpreter is for. Less
4085 script, that's what the normal interpreter is for. Less
4078 unnecessary options, less chances for bugs.
4086 unnecessary options, less chances for bugs.
4079
4087
4080 * Added a crash handler which generates a complete post-mortem if
4088 * Added a crash handler which generates a complete post-mortem if
4081 IPython crashes. This will help a lot in tracking bugs down the
4089 IPython crashes. This will help a lot in tracking bugs down the
4082 road.
4090 road.
4083
4091
4084 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
4092 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
4085 which were boud to functions being reassigned would bypass the
4093 which were boud to functions being reassigned would bypass the
4086 logger, breaking the sync of _il with the prompt counter. This
4094 logger, breaking the sync of _il with the prompt counter. This
4087 would then crash IPython later when a new line was logged.
4095 would then crash IPython later when a new line was logged.
4088
4096
4089 2001-12-02 Fernando Perez <fperez@colorado.edu>
4097 2001-12-02 Fernando Perez <fperez@colorado.edu>
4090
4098
4091 * Made IPython a package. This means people don't have to clutter
4099 * Made IPython a package. This means people don't have to clutter
4092 their sys.path with yet another directory. Changed the INSTALL
4100 their sys.path with yet another directory. Changed the INSTALL
4093 file accordingly.
4101 file accordingly.
4094
4102
4095 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
4103 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
4096 sorts its output (so @who shows it sorted) and @whos formats the
4104 sorts its output (so @who shows it sorted) and @whos formats the
4097 table according to the width of the first column. Nicer, easier to
4105 table according to the width of the first column. Nicer, easier to
4098 read. Todo: write a generic table_format() which takes a list of
4106 read. Todo: write a generic table_format() which takes a list of
4099 lists and prints it nicely formatted, with optional row/column
4107 lists and prints it nicely formatted, with optional row/column
4100 separators and proper padding and justification.
4108 separators and proper padding and justification.
4101
4109
4102 * Released 0.1.20
4110 * Released 0.1.20
4103
4111
4104 * Fixed bug in @log which would reverse the inputcache list (a
4112 * Fixed bug in @log which would reverse the inputcache list (a
4105 copy operation was missing).
4113 copy operation was missing).
4106
4114
4107 * Code cleanup. @config was changed to use page(). Better, since
4115 * Code cleanup. @config was changed to use page(). Better, since
4108 its output is always quite long.
4116 its output is always quite long.
4109
4117
4110 * Itpl is back as a dependency. I was having too many problems
4118 * Itpl is back as a dependency. I was having too many problems
4111 getting the parametric aliases to work reliably, and it's just
4119 getting the parametric aliases to work reliably, and it's just
4112 easier to code weird string operations with it than playing %()s
4120 easier to code weird string operations with it than playing %()s
4113 games. It's only ~6k, so I don't think it's too big a deal.
4121 games. It's only ~6k, so I don't think it's too big a deal.
4114
4122
4115 * Found (and fixed) a very nasty bug with history. !lines weren't
4123 * Found (and fixed) a very nasty bug with history. !lines weren't
4116 getting cached, and the out of sync caches would crash
4124 getting cached, and the out of sync caches would crash
4117 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4125 IPython. Fixed it by reorganizing the prefilter/handlers/logger
4118 division of labor a bit better. Bug fixed, cleaner structure.
4126 division of labor a bit better. Bug fixed, cleaner structure.
4119
4127
4120 2001-12-01 Fernando Perez <fperez@colorado.edu>
4128 2001-12-01 Fernando Perez <fperez@colorado.edu>
4121
4129
4122 * Released 0.1.19
4130 * Released 0.1.19
4123
4131
4124 * Added option -n to @hist to prevent line number printing. Much
4132 * Added option -n to @hist to prevent line number printing. Much
4125 easier to copy/paste code this way.
4133 easier to copy/paste code this way.
4126
4134
4127 * Created global _il to hold the input list. Allows easy
4135 * Created global _il to hold the input list. Allows easy
4128 re-execution of blocks of code by slicing it (inspired by Janko's
4136 re-execution of blocks of code by slicing it (inspired by Janko's
4129 comment on 'macros').
4137 comment on 'macros').
4130
4138
4131 * Small fixes and doc updates.
4139 * Small fixes and doc updates.
4132
4140
4133 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4141 * Rewrote @history function (was @h). Renamed it to @hist, @h is
4134 much too fragile with automagic. Handles properly multi-line
4142 much too fragile with automagic. Handles properly multi-line
4135 statements and takes parameters.
4143 statements and takes parameters.
4136
4144
4137 2001-11-30 Fernando Perez <fperez@colorado.edu>
4145 2001-11-30 Fernando Perez <fperez@colorado.edu>
4138
4146
4139 * Version 0.1.18 released.
4147 * Version 0.1.18 released.
4140
4148
4141 * Fixed nasty namespace bug in initial module imports.
4149 * Fixed nasty namespace bug in initial module imports.
4142
4150
4143 * Added copyright/license notes to all code files (except
4151 * Added copyright/license notes to all code files (except
4144 DPyGetOpt). For the time being, LGPL. That could change.
4152 DPyGetOpt). For the time being, LGPL. That could change.
4145
4153
4146 * Rewrote a much nicer README, updated INSTALL, cleaned up
4154 * Rewrote a much nicer README, updated INSTALL, cleaned up
4147 ipythonrc-* samples.
4155 ipythonrc-* samples.
4148
4156
4149 * Overall code/documentation cleanup. Basically ready for
4157 * Overall code/documentation cleanup. Basically ready for
4150 release. Only remaining thing: licence decision (LGPL?).
4158 release. Only remaining thing: licence decision (LGPL?).
4151
4159
4152 * Converted load_config to a class, ConfigLoader. Now recursion
4160 * Converted load_config to a class, ConfigLoader. Now recursion
4153 control is better organized. Doesn't include the same file twice.
4161 control is better organized. Doesn't include the same file twice.
4154
4162
4155 2001-11-29 Fernando Perez <fperez@colorado.edu>
4163 2001-11-29 Fernando Perez <fperez@colorado.edu>
4156
4164
4157 * Got input history working. Changed output history variables from
4165 * Got input history working. Changed output history variables from
4158 _p to _o so that _i is for input and _o for output. Just cleaner
4166 _p to _o so that _i is for input and _o for output. Just cleaner
4159 convention.
4167 convention.
4160
4168
4161 * Implemented parametric aliases. This pretty much allows the
4169 * Implemented parametric aliases. This pretty much allows the
4162 alias system to offer full-blown shell convenience, I think.
4170 alias system to offer full-blown shell convenience, I think.
4163
4171
4164 * Version 0.1.17 released, 0.1.18 opened.
4172 * Version 0.1.17 released, 0.1.18 opened.
4165
4173
4166 * dot_ipython/ipythonrc (alias): added documentation.
4174 * dot_ipython/ipythonrc (alias): added documentation.
4167 (xcolor): Fixed small bug (xcolors -> xcolor)
4175 (xcolor): Fixed small bug (xcolors -> xcolor)
4168
4176
4169 * Changed the alias system. Now alias is a magic command to define
4177 * Changed the alias system. Now alias is a magic command to define
4170 aliases just like the shell. Rationale: the builtin magics should
4178 aliases just like the shell. Rationale: the builtin magics should
4171 be there for things deeply connected to IPython's
4179 be there for things deeply connected to IPython's
4172 architecture. And this is a much lighter system for what I think
4180 architecture. And this is a much lighter system for what I think
4173 is the really important feature: allowing users to define quickly
4181 is the really important feature: allowing users to define quickly
4174 magics that will do shell things for them, so they can customize
4182 magics that will do shell things for them, so they can customize
4175 IPython easily to match their work habits. If someone is really
4183 IPython easily to match their work habits. If someone is really
4176 desperate to have another name for a builtin alias, they can
4184 desperate to have another name for a builtin alias, they can
4177 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4185 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
4178 works.
4186 works.
4179
4187
4180 2001-11-28 Fernando Perez <fperez@colorado.edu>
4188 2001-11-28 Fernando Perez <fperez@colorado.edu>
4181
4189
4182 * Changed @file so that it opens the source file at the proper
4190 * Changed @file so that it opens the source file at the proper
4183 line. Since it uses less, if your EDITOR environment is
4191 line. Since it uses less, if your EDITOR environment is
4184 configured, typing v will immediately open your editor of choice
4192 configured, typing v will immediately open your editor of choice
4185 right at the line where the object is defined. Not as quick as
4193 right at the line where the object is defined. Not as quick as
4186 having a direct @edit command, but for all intents and purposes it
4194 having a direct @edit command, but for all intents and purposes it
4187 works. And I don't have to worry about writing @edit to deal with
4195 works. And I don't have to worry about writing @edit to deal with
4188 all the editors, less does that.
4196 all the editors, less does that.
4189
4197
4190 * Version 0.1.16 released, 0.1.17 opened.
4198 * Version 0.1.16 released, 0.1.17 opened.
4191
4199
4192 * Fixed some nasty bugs in the page/page_dumb combo that could
4200 * Fixed some nasty bugs in the page/page_dumb combo that could
4193 crash IPython.
4201 crash IPython.
4194
4202
4195 2001-11-27 Fernando Perez <fperez@colorado.edu>
4203 2001-11-27 Fernando Perez <fperez@colorado.edu>
4196
4204
4197 * Version 0.1.15 released, 0.1.16 opened.
4205 * Version 0.1.15 released, 0.1.16 opened.
4198
4206
4199 * Finally got ? and ?? to work for undefined things: now it's
4207 * Finally got ? and ?? to work for undefined things: now it's
4200 possible to type {}.get? and get information about the get method
4208 possible to type {}.get? and get information about the get method
4201 of dicts, or os.path? even if only os is defined (so technically
4209 of dicts, or os.path? even if only os is defined (so technically
4202 os.path isn't). Works at any level. For example, after import os,
4210 os.path isn't). Works at any level. For example, after import os,
4203 os?, os.path?, os.path.abspath? all work. This is great, took some
4211 os?, os.path?, os.path.abspath? all work. This is great, took some
4204 work in _ofind.
4212 work in _ofind.
4205
4213
4206 * Fixed more bugs with logging. The sanest way to do it was to add
4214 * Fixed more bugs with logging. The sanest way to do it was to add
4207 to @log a 'mode' parameter. Killed two in one shot (this mode
4215 to @log a 'mode' parameter. Killed two in one shot (this mode
4208 option was a request of Janko's). I think it's finally clean
4216 option was a request of Janko's). I think it's finally clean
4209 (famous last words).
4217 (famous last words).
4210
4218
4211 * Added a page_dumb() pager which does a decent job of paging on
4219 * Added a page_dumb() pager which does a decent job of paging on
4212 screen, if better things (like less) aren't available. One less
4220 screen, if better things (like less) aren't available. One less
4213 unix dependency (someday maybe somebody will port this to
4221 unix dependency (someday maybe somebody will port this to
4214 windows).
4222 windows).
4215
4223
4216 * Fixed problem in magic_log: would lock of logging out if log
4224 * Fixed problem in magic_log: would lock of logging out if log
4217 creation failed (because it would still think it had succeeded).
4225 creation failed (because it would still think it had succeeded).
4218
4226
4219 * Improved the page() function using curses to auto-detect screen
4227 * Improved the page() function using curses to auto-detect screen
4220 size. Now it can make a much better decision on whether to print
4228 size. Now it can make a much better decision on whether to print
4221 or page a string. Option screen_length was modified: a value 0
4229 or page a string. Option screen_length was modified: a value 0
4222 means auto-detect, and that's the default now.
4230 means auto-detect, and that's the default now.
4223
4231
4224 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4232 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
4225 go out. I'll test it for a few days, then talk to Janko about
4233 go out. I'll test it for a few days, then talk to Janko about
4226 licences and announce it.
4234 licences and announce it.
4227
4235
4228 * Fixed the length of the auto-generated ---> prompt which appears
4236 * Fixed the length of the auto-generated ---> prompt which appears
4229 for auto-parens and auto-quotes. Getting this right isn't trivial,
4237 for auto-parens and auto-quotes. Getting this right isn't trivial,
4230 with all the color escapes, different prompt types and optional
4238 with all the color escapes, different prompt types and optional
4231 separators. But it seems to be working in all the combinations.
4239 separators. But it seems to be working in all the combinations.
4232
4240
4233 2001-11-26 Fernando Perez <fperez@colorado.edu>
4241 2001-11-26 Fernando Perez <fperez@colorado.edu>
4234
4242
4235 * Wrote a regexp filter to get option types from the option names
4243 * Wrote a regexp filter to get option types from the option names
4236 string. This eliminates the need to manually keep two duplicate
4244 string. This eliminates the need to manually keep two duplicate
4237 lists.
4245 lists.
4238
4246
4239 * Removed the unneeded check_option_names. Now options are handled
4247 * Removed the unneeded check_option_names. Now options are handled
4240 in a much saner manner and it's easy to visually check that things
4248 in a much saner manner and it's easy to visually check that things
4241 are ok.
4249 are ok.
4242
4250
4243 * Updated version numbers on all files I modified to carry a
4251 * Updated version numbers on all files I modified to carry a
4244 notice so Janko and Nathan have clear version markers.
4252 notice so Janko and Nathan have clear version markers.
4245
4253
4246 * Updated docstring for ultraTB with my changes. I should send
4254 * Updated docstring for ultraTB with my changes. I should send
4247 this to Nathan.
4255 this to Nathan.
4248
4256
4249 * Lots of small fixes. Ran everything through pychecker again.
4257 * Lots of small fixes. Ran everything through pychecker again.
4250
4258
4251 * Made loading of deep_reload an cmd line option. If it's not too
4259 * Made loading of deep_reload an cmd line option. If it's not too
4252 kosher, now people can just disable it. With -nodeep_reload it's
4260 kosher, now people can just disable it. With -nodeep_reload it's
4253 still available as dreload(), it just won't overwrite reload().
4261 still available as dreload(), it just won't overwrite reload().
4254
4262
4255 * Moved many options to the no| form (-opt and -noopt
4263 * Moved many options to the no| form (-opt and -noopt
4256 accepted). Cleaner.
4264 accepted). Cleaner.
4257
4265
4258 * Changed magic_log so that if called with no parameters, it uses
4266 * Changed magic_log so that if called with no parameters, it uses
4259 'rotate' mode. That way auto-generated logs aren't automatically
4267 'rotate' mode. That way auto-generated logs aren't automatically
4260 over-written. For normal logs, now a backup is made if it exists
4268 over-written. For normal logs, now a backup is made if it exists
4261 (only 1 level of backups). A new 'backup' mode was added to the
4269 (only 1 level of backups). A new 'backup' mode was added to the
4262 Logger class to support this. This was a request by Janko.
4270 Logger class to support this. This was a request by Janko.
4263
4271
4264 * Added @logoff/@logon to stop/restart an active log.
4272 * Added @logoff/@logon to stop/restart an active log.
4265
4273
4266 * Fixed a lot of bugs in log saving/replay. It was pretty
4274 * Fixed a lot of bugs in log saving/replay. It was pretty
4267 broken. Now special lines (!@,/) appear properly in the command
4275 broken. Now special lines (!@,/) appear properly in the command
4268 history after a log replay.
4276 history after a log replay.
4269
4277
4270 * Tried and failed to implement full session saving via pickle. My
4278 * Tried and failed to implement full session saving via pickle. My
4271 idea was to pickle __main__.__dict__, but modules can't be
4279 idea was to pickle __main__.__dict__, but modules can't be
4272 pickled. This would be a better alternative to replaying logs, but
4280 pickled. This would be a better alternative to replaying logs, but
4273 seems quite tricky to get to work. Changed -session to be called
4281 seems quite tricky to get to work. Changed -session to be called
4274 -logplay, which more accurately reflects what it does. And if we
4282 -logplay, which more accurately reflects what it does. And if we
4275 ever get real session saving working, -session is now available.
4283 ever get real session saving working, -session is now available.
4276
4284
4277 * Implemented color schemes for prompts also. As for tracebacks,
4285 * Implemented color schemes for prompts also. As for tracebacks,
4278 currently only NoColor and Linux are supported. But now the
4286 currently only NoColor and Linux are supported. But now the
4279 infrastructure is in place, based on a generic ColorScheme
4287 infrastructure is in place, based on a generic ColorScheme
4280 class. So writing and activating new schemes both for the prompts
4288 class. So writing and activating new schemes both for the prompts
4281 and the tracebacks should be straightforward.
4289 and the tracebacks should be straightforward.
4282
4290
4283 * Version 0.1.13 released, 0.1.14 opened.
4291 * Version 0.1.13 released, 0.1.14 opened.
4284
4292
4285 * Changed handling of options for output cache. Now counter is
4293 * Changed handling of options for output cache. Now counter is
4286 hardwired starting at 1 and one specifies the maximum number of
4294 hardwired starting at 1 and one specifies the maximum number of
4287 entries *in the outcache* (not the max prompt counter). This is
4295 entries *in the outcache* (not the max prompt counter). This is
4288 much better, since many statements won't increase the cache
4296 much better, since many statements won't increase the cache
4289 count. It also eliminated some confusing options, now there's only
4297 count. It also eliminated some confusing options, now there's only
4290 one: cache_size.
4298 one: cache_size.
4291
4299
4292 * Added 'alias' magic function and magic_alias option in the
4300 * Added 'alias' magic function and magic_alias option in the
4293 ipythonrc file. Now the user can easily define whatever names he
4301 ipythonrc file. Now the user can easily define whatever names he
4294 wants for the magic functions without having to play weird
4302 wants for the magic functions without having to play weird
4295 namespace games. This gives IPython a real shell-like feel.
4303 namespace games. This gives IPython a real shell-like feel.
4296
4304
4297 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4305 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
4298 @ or not).
4306 @ or not).
4299
4307
4300 This was one of the last remaining 'visible' bugs (that I know
4308 This was one of the last remaining 'visible' bugs (that I know
4301 of). I think if I can clean up the session loading so it works
4309 of). I think if I can clean up the session loading so it works
4302 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4310 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
4303 about licensing).
4311 about licensing).
4304
4312
4305 2001-11-25 Fernando Perez <fperez@colorado.edu>
4313 2001-11-25 Fernando Perez <fperez@colorado.edu>
4306
4314
4307 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4315 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
4308 there's a cleaner distinction between what ? and ?? show.
4316 there's a cleaner distinction between what ? and ?? show.
4309
4317
4310 * Added screen_length option. Now the user can define his own
4318 * Added screen_length option. Now the user can define his own
4311 screen size for page() operations.
4319 screen size for page() operations.
4312
4320
4313 * Implemented magic shell-like functions with automatic code
4321 * Implemented magic shell-like functions with automatic code
4314 generation. Now adding another function is just a matter of adding
4322 generation. Now adding another function is just a matter of adding
4315 an entry to a dict, and the function is dynamically generated at
4323 an entry to a dict, and the function is dynamically generated at
4316 run-time. Python has some really cool features!
4324 run-time. Python has some really cool features!
4317
4325
4318 * Renamed many options to cleanup conventions a little. Now all
4326 * Renamed many options to cleanup conventions a little. Now all
4319 are lowercase, and only underscores where needed. Also in the code
4327 are lowercase, and only underscores where needed. Also in the code
4320 option name tables are clearer.
4328 option name tables are clearer.
4321
4329
4322 * Changed prompts a little. Now input is 'In [n]:' instead of
4330 * Changed prompts a little. Now input is 'In [n]:' instead of
4323 'In[n]:='. This allows it the numbers to be aligned with the
4331 'In[n]:='. This allows it the numbers to be aligned with the
4324 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4332 Out[n] numbers, and removes usage of ':=' which doesn't exist in
4325 Python (it was a Mathematica thing). The '...' continuation prompt
4333 Python (it was a Mathematica thing). The '...' continuation prompt
4326 was also changed a little to align better.
4334 was also changed a little to align better.
4327
4335
4328 * Fixed bug when flushing output cache. Not all _p<n> variables
4336 * Fixed bug when flushing output cache. Not all _p<n> variables
4329 exist, so their deletion needs to be wrapped in a try:
4337 exist, so their deletion needs to be wrapped in a try:
4330
4338
4331 * Figured out how to properly use inspect.formatargspec() (it
4339 * Figured out how to properly use inspect.formatargspec() (it
4332 requires the args preceded by *). So I removed all the code from
4340 requires the args preceded by *). So I removed all the code from
4333 _get_pdef in Magic, which was just replicating that.
4341 _get_pdef in Magic, which was just replicating that.
4334
4342
4335 * Added test to prefilter to allow redefining magic function names
4343 * Added test to prefilter to allow redefining magic function names
4336 as variables. This is ok, since the @ form is always available,
4344 as variables. This is ok, since the @ form is always available,
4337 but whe should allow the user to define a variable called 'ls' if
4345 but whe should allow the user to define a variable called 'ls' if
4338 he needs it.
4346 he needs it.
4339
4347
4340 * Moved the ToDo information from README into a separate ToDo.
4348 * Moved the ToDo information from README into a separate ToDo.
4341
4349
4342 * General code cleanup and small bugfixes. I think it's close to a
4350 * General code cleanup and small bugfixes. I think it's close to a
4343 state where it can be released, obviously with a big 'beta'
4351 state where it can be released, obviously with a big 'beta'
4344 warning on it.
4352 warning on it.
4345
4353
4346 * Got the magic function split to work. Now all magics are defined
4354 * Got the magic function split to work. Now all magics are defined
4347 in a separate class. It just organizes things a bit, and now
4355 in a separate class. It just organizes things a bit, and now
4348 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4356 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
4349 was too long).
4357 was too long).
4350
4358
4351 * Changed @clear to @reset to avoid potential confusions with
4359 * Changed @clear to @reset to avoid potential confusions with
4352 the shell command clear. Also renamed @cl to @clear, which does
4360 the shell command clear. Also renamed @cl to @clear, which does
4353 exactly what people expect it to from their shell experience.
4361 exactly what people expect it to from their shell experience.
4354
4362
4355 Added a check to the @reset command (since it's so
4363 Added a check to the @reset command (since it's so
4356 destructive, it's probably a good idea to ask for confirmation).
4364 destructive, it's probably a good idea to ask for confirmation).
4357 But now reset only works for full namespace resetting. Since the
4365 But now reset only works for full namespace resetting. Since the
4358 del keyword is already there for deleting a few specific
4366 del keyword is already there for deleting a few specific
4359 variables, I don't see the point of having a redundant magic
4367 variables, I don't see the point of having a redundant magic
4360 function for the same task.
4368 function for the same task.
4361
4369
4362 2001-11-24 Fernando Perez <fperez@colorado.edu>
4370 2001-11-24 Fernando Perez <fperez@colorado.edu>
4363
4371
4364 * Updated the builtin docs (esp. the ? ones).
4372 * Updated the builtin docs (esp. the ? ones).
4365
4373
4366 * Ran all the code through pychecker. Not terribly impressed with
4374 * Ran all the code through pychecker. Not terribly impressed with
4367 it: lots of spurious warnings and didn't really find anything of
4375 it: lots of spurious warnings and didn't really find anything of
4368 substance (just a few modules being imported and not used).
4376 substance (just a few modules being imported and not used).
4369
4377
4370 * Implemented the new ultraTB functionality into IPython. New
4378 * Implemented the new ultraTB functionality into IPython. New
4371 option: xcolors. This chooses color scheme. xmode now only selects
4379 option: xcolors. This chooses color scheme. xmode now only selects
4372 between Plain and Verbose. Better orthogonality.
4380 between Plain and Verbose. Better orthogonality.
4373
4381
4374 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4382 * Large rewrite of ultraTB. Much cleaner now, with a separation of
4375 mode and color scheme for the exception handlers. Now it's
4383 mode and color scheme for the exception handlers. Now it's
4376 possible to have the verbose traceback with no coloring.
4384 possible to have the verbose traceback with no coloring.
4377
4385
4378 2001-11-23 Fernando Perez <fperez@colorado.edu>
4386 2001-11-23 Fernando Perez <fperez@colorado.edu>
4379
4387
4380 * Version 0.1.12 released, 0.1.13 opened.
4388 * Version 0.1.12 released, 0.1.13 opened.
4381
4389
4382 * Removed option to set auto-quote and auto-paren escapes by
4390 * Removed option to set auto-quote and auto-paren escapes by
4383 user. The chances of breaking valid syntax are just too high. If
4391 user. The chances of breaking valid syntax are just too high. If
4384 someone *really* wants, they can always dig into the code.
4392 someone *really* wants, they can always dig into the code.
4385
4393
4386 * Made prompt separators configurable.
4394 * Made prompt separators configurable.
4387
4395
4388 2001-11-22 Fernando Perez <fperez@colorado.edu>
4396 2001-11-22 Fernando Perez <fperez@colorado.edu>
4389
4397
4390 * Small bugfixes in many places.
4398 * Small bugfixes in many places.
4391
4399
4392 * Removed the MyCompleter class from ipplib. It seemed redundant
4400 * Removed the MyCompleter class from ipplib. It seemed redundant
4393 with the C-p,C-n history search functionality. Less code to
4401 with the C-p,C-n history search functionality. Less code to
4394 maintain.
4402 maintain.
4395
4403
4396 * Moved all the original ipython.py code into ipythonlib.py. Right
4404 * Moved all the original ipython.py code into ipythonlib.py. Right
4397 now it's just one big dump into a function called make_IPython, so
4405 now it's just one big dump into a function called make_IPython, so
4398 no real modularity has been gained. But at least it makes the
4406 no real modularity has been gained. But at least it makes the
4399 wrapper script tiny, and since ipythonlib is a module, it gets
4407 wrapper script tiny, and since ipythonlib is a module, it gets
4400 compiled and startup is much faster.
4408 compiled and startup is much faster.
4401
4409
4402 This is a reasobably 'deep' change, so we should test it for a
4410 This is a reasobably 'deep' change, so we should test it for a
4403 while without messing too much more with the code.
4411 while without messing too much more with the code.
4404
4412
4405 2001-11-21 Fernando Perez <fperez@colorado.edu>
4413 2001-11-21 Fernando Perez <fperez@colorado.edu>
4406
4414
4407 * Version 0.1.11 released, 0.1.12 opened for further work.
4415 * Version 0.1.11 released, 0.1.12 opened for further work.
4408
4416
4409 * Removed dependency on Itpl. It was only needed in one place. It
4417 * Removed dependency on Itpl. It was only needed in one place. It
4410 would be nice if this became part of python, though. It makes life
4418 would be nice if this became part of python, though. It makes life
4411 *a lot* easier in some cases.
4419 *a lot* easier in some cases.
4412
4420
4413 * Simplified the prefilter code a bit. Now all handlers are
4421 * Simplified the prefilter code a bit. Now all handlers are
4414 expected to explicitly return a value (at least a blank string).
4422 expected to explicitly return a value (at least a blank string).
4415
4423
4416 * Heavy edits in ipplib. Removed the help system altogether. Now
4424 * Heavy edits in ipplib. Removed the help system altogether. Now
4417 obj?/?? is used for inspecting objects, a magic @doc prints
4425 obj?/?? is used for inspecting objects, a magic @doc prints
4418 docstrings, and full-blown Python help is accessed via the 'help'
4426 docstrings, and full-blown Python help is accessed via the 'help'
4419 keyword. This cleans up a lot of code (less to maintain) and does
4427 keyword. This cleans up a lot of code (less to maintain) and does
4420 the job. Since 'help' is now a standard Python component, might as
4428 the job. Since 'help' is now a standard Python component, might as
4421 well use it and remove duplicate functionality.
4429 well use it and remove duplicate functionality.
4422
4430
4423 Also removed the option to use ipplib as a standalone program. By
4431 Also removed the option to use ipplib as a standalone program. By
4424 now it's too dependent on other parts of IPython to function alone.
4432 now it's too dependent on other parts of IPython to function alone.
4425
4433
4426 * Fixed bug in genutils.pager. It would crash if the pager was
4434 * Fixed bug in genutils.pager. It would crash if the pager was
4427 exited immediately after opening (broken pipe).
4435 exited immediately after opening (broken pipe).
4428
4436
4429 * Trimmed down the VerboseTB reporting a little. The header is
4437 * Trimmed down the VerboseTB reporting a little. The header is
4430 much shorter now and the repeated exception arguments at the end
4438 much shorter now and the repeated exception arguments at the end
4431 have been removed. For interactive use the old header seemed a bit
4439 have been removed. For interactive use the old header seemed a bit
4432 excessive.
4440 excessive.
4433
4441
4434 * Fixed small bug in output of @whos for variables with multi-word
4442 * Fixed small bug in output of @whos for variables with multi-word
4435 types (only first word was displayed).
4443 types (only first word was displayed).
4436
4444
4437 2001-11-17 Fernando Perez <fperez@colorado.edu>
4445 2001-11-17 Fernando Perez <fperez@colorado.edu>
4438
4446
4439 * Version 0.1.10 released, 0.1.11 opened for further work.
4447 * Version 0.1.10 released, 0.1.11 opened for further work.
4440
4448
4441 * Modified dirs and friends. dirs now *returns* the stack (not
4449 * Modified dirs and friends. dirs now *returns* the stack (not
4442 prints), so one can manipulate it as a variable. Convenient to
4450 prints), so one can manipulate it as a variable. Convenient to
4443 travel along many directories.
4451 travel along many directories.
4444
4452
4445 * Fixed bug in magic_pdef: would only work with functions with
4453 * Fixed bug in magic_pdef: would only work with functions with
4446 arguments with default values.
4454 arguments with default values.
4447
4455
4448 2001-11-14 Fernando Perez <fperez@colorado.edu>
4456 2001-11-14 Fernando Perez <fperez@colorado.edu>
4449
4457
4450 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4458 * Added the PhysicsInput stuff to dot_ipython so it ships as an
4451 example with IPython. Various other minor fixes and cleanups.
4459 example with IPython. Various other minor fixes and cleanups.
4452
4460
4453 * Version 0.1.9 released, 0.1.10 opened for further work.
4461 * Version 0.1.9 released, 0.1.10 opened for further work.
4454
4462
4455 * Added sys.path to the list of directories searched in the
4463 * Added sys.path to the list of directories searched in the
4456 execfile= option. It used to be the current directory and the
4464 execfile= option. It used to be the current directory and the
4457 user's IPYTHONDIR only.
4465 user's IPYTHONDIR only.
4458
4466
4459 2001-11-13 Fernando Perez <fperez@colorado.edu>
4467 2001-11-13 Fernando Perez <fperez@colorado.edu>
4460
4468
4461 * Reinstated the raw_input/prefilter separation that Janko had
4469 * Reinstated the raw_input/prefilter separation that Janko had
4462 initially. This gives a more convenient setup for extending the
4470 initially. This gives a more convenient setup for extending the
4463 pre-processor from the outside: raw_input always gets a string,
4471 pre-processor from the outside: raw_input always gets a string,
4464 and prefilter has to process it. We can then redefine prefilter
4472 and prefilter has to process it. We can then redefine prefilter
4465 from the outside and implement extensions for special
4473 from the outside and implement extensions for special
4466 purposes.
4474 purposes.
4467
4475
4468 Today I got one for inputting PhysicalQuantity objects
4476 Today I got one for inputting PhysicalQuantity objects
4469 (from Scientific) without needing any function calls at
4477 (from Scientific) without needing any function calls at
4470 all. Extremely convenient, and it's all done as a user-level
4478 all. Extremely convenient, and it's all done as a user-level
4471 extension (no IPython code was touched). Now instead of:
4479 extension (no IPython code was touched). Now instead of:
4472 a = PhysicalQuantity(4.2,'m/s**2')
4480 a = PhysicalQuantity(4.2,'m/s**2')
4473 one can simply say
4481 one can simply say
4474 a = 4.2 m/s**2
4482 a = 4.2 m/s**2
4475 or even
4483 or even
4476 a = 4.2 m/s^2
4484 a = 4.2 m/s^2
4477
4485
4478 I use this, but it's also a proof of concept: IPython really is
4486 I use this, but it's also a proof of concept: IPython really is
4479 fully user-extensible, even at the level of the parsing of the
4487 fully user-extensible, even at the level of the parsing of the
4480 command line. It's not trivial, but it's perfectly doable.
4488 command line. It's not trivial, but it's perfectly doable.
4481
4489
4482 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4490 * Added 'add_flip' method to inclusion conflict resolver. Fixes
4483 the problem of modules being loaded in the inverse order in which
4491 the problem of modules being loaded in the inverse order in which
4484 they were defined in
4492 they were defined in
4485
4493
4486 * Version 0.1.8 released, 0.1.9 opened for further work.
4494 * Version 0.1.8 released, 0.1.9 opened for further work.
4487
4495
4488 * Added magics pdef, source and file. They respectively show the
4496 * Added magics pdef, source and file. They respectively show the
4489 definition line ('prototype' in C), source code and full python
4497 definition line ('prototype' in C), source code and full python
4490 file for any callable object. The object inspector oinfo uses
4498 file for any callable object. The object inspector oinfo uses
4491 these to show the same information.
4499 these to show the same information.
4492
4500
4493 * Version 0.1.7 released, 0.1.8 opened for further work.
4501 * Version 0.1.7 released, 0.1.8 opened for further work.
4494
4502
4495 * Separated all the magic functions into a class called Magic. The
4503 * Separated all the magic functions into a class called Magic. The
4496 InteractiveShell class was becoming too big for Xemacs to handle
4504 InteractiveShell class was becoming too big for Xemacs to handle
4497 (de-indenting a line would lock it up for 10 seconds while it
4505 (de-indenting a line would lock it up for 10 seconds while it
4498 backtracked on the whole class!)
4506 backtracked on the whole class!)
4499
4507
4500 FIXME: didn't work. It can be done, but right now namespaces are
4508 FIXME: didn't work. It can be done, but right now namespaces are
4501 all messed up. Do it later (reverted it for now, so at least
4509 all messed up. Do it later (reverted it for now, so at least
4502 everything works as before).
4510 everything works as before).
4503
4511
4504 * Got the object introspection system (magic_oinfo) working! I
4512 * Got the object introspection system (magic_oinfo) working! I
4505 think this is pretty much ready for release to Janko, so he can
4513 think this is pretty much ready for release to Janko, so he can
4506 test it for a while and then announce it. Pretty much 100% of what
4514 test it for a while and then announce it. Pretty much 100% of what
4507 I wanted for the 'phase 1' release is ready. Happy, tired.
4515 I wanted for the 'phase 1' release is ready. Happy, tired.
4508
4516
4509 2001-11-12 Fernando Perez <fperez@colorado.edu>
4517 2001-11-12 Fernando Perez <fperez@colorado.edu>
4510
4518
4511 * Version 0.1.6 released, 0.1.7 opened for further work.
4519 * Version 0.1.6 released, 0.1.7 opened for further work.
4512
4520
4513 * Fixed bug in printing: it used to test for truth before
4521 * Fixed bug in printing: it used to test for truth before
4514 printing, so 0 wouldn't print. Now checks for None.
4522 printing, so 0 wouldn't print. Now checks for None.
4515
4523
4516 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4524 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
4517 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4525 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
4518 reaches by hand into the outputcache. Think of a better way to do
4526 reaches by hand into the outputcache. Think of a better way to do
4519 this later.
4527 this later.
4520
4528
4521 * Various small fixes thanks to Nathan's comments.
4529 * Various small fixes thanks to Nathan's comments.
4522
4530
4523 * Changed magic_pprint to magic_Pprint. This way it doesn't
4531 * Changed magic_pprint to magic_Pprint. This way it doesn't
4524 collide with pprint() and the name is consistent with the command
4532 collide with pprint() and the name is consistent with the command
4525 line option.
4533 line option.
4526
4534
4527 * Changed prompt counter behavior to be fully like
4535 * Changed prompt counter behavior to be fully like
4528 Mathematica's. That is, even input that doesn't return a result
4536 Mathematica's. That is, even input that doesn't return a result
4529 raises the prompt counter. The old behavior was kind of confusing
4537 raises the prompt counter. The old behavior was kind of confusing
4530 (getting the same prompt number several times if the operation
4538 (getting the same prompt number several times if the operation
4531 didn't return a result).
4539 didn't return a result).
4532
4540
4533 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4541 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
4534
4542
4535 * Fixed -Classic mode (wasn't working anymore).
4543 * Fixed -Classic mode (wasn't working anymore).
4536
4544
4537 * Added colored prompts using Nathan's new code. Colors are
4545 * Added colored prompts using Nathan's new code. Colors are
4538 currently hardwired, they can be user-configurable. For
4546 currently hardwired, they can be user-configurable. For
4539 developers, they can be chosen in file ipythonlib.py, at the
4547 developers, they can be chosen in file ipythonlib.py, at the
4540 beginning of the CachedOutput class def.
4548 beginning of the CachedOutput class def.
4541
4549
4542 2001-11-11 Fernando Perez <fperez@colorado.edu>
4550 2001-11-11 Fernando Perez <fperez@colorado.edu>
4543
4551
4544 * Version 0.1.5 released, 0.1.6 opened for further work.
4552 * Version 0.1.5 released, 0.1.6 opened for further work.
4545
4553
4546 * Changed magic_env to *return* the environment as a dict (not to
4554 * Changed magic_env to *return* the environment as a dict (not to
4547 print it). This way it prints, but it can also be processed.
4555 print it). This way it prints, but it can also be processed.
4548
4556
4549 * Added Verbose exception reporting to interactive
4557 * Added Verbose exception reporting to interactive
4550 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4558 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
4551 traceback. Had to make some changes to the ultraTB file. This is
4559 traceback. Had to make some changes to the ultraTB file. This is
4552 probably the last 'big' thing in my mental todo list. This ties
4560 probably the last 'big' thing in my mental todo list. This ties
4553 in with the next entry:
4561 in with the next entry:
4554
4562
4555 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4563 * Changed -Xi and -Xf to a single -xmode option. Now all the user
4556 has to specify is Plain, Color or Verbose for all exception
4564 has to specify is Plain, Color or Verbose for all exception
4557 handling.
4565 handling.
4558
4566
4559 * Removed ShellServices option. All this can really be done via
4567 * Removed ShellServices option. All this can really be done via
4560 the magic system. It's easier to extend, cleaner and has automatic
4568 the magic system. It's easier to extend, cleaner and has automatic
4561 namespace protection and documentation.
4569 namespace protection and documentation.
4562
4570
4563 2001-11-09 Fernando Perez <fperez@colorado.edu>
4571 2001-11-09 Fernando Perez <fperez@colorado.edu>
4564
4572
4565 * Fixed bug in output cache flushing (missing parameter to
4573 * Fixed bug in output cache flushing (missing parameter to
4566 __init__). Other small bugs fixed (found using pychecker).
4574 __init__). Other small bugs fixed (found using pychecker).
4567
4575
4568 * Version 0.1.4 opened for bugfixing.
4576 * Version 0.1.4 opened for bugfixing.
4569
4577
4570 2001-11-07 Fernando Perez <fperez@colorado.edu>
4578 2001-11-07 Fernando Perez <fperez@colorado.edu>
4571
4579
4572 * Version 0.1.3 released, mainly because of the raw_input bug.
4580 * Version 0.1.3 released, mainly because of the raw_input bug.
4573
4581
4574 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4582 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
4575 and when testing for whether things were callable, a call could
4583 and when testing for whether things were callable, a call could
4576 actually be made to certain functions. They would get called again
4584 actually be made to certain functions. They would get called again
4577 once 'really' executed, with a resulting double call. A disaster
4585 once 'really' executed, with a resulting double call. A disaster
4578 in many cases (list.reverse() would never work!).
4586 in many cases (list.reverse() would never work!).
4579
4587
4580 * Removed prefilter() function, moved its code to raw_input (which
4588 * Removed prefilter() function, moved its code to raw_input (which
4581 after all was just a near-empty caller for prefilter). This saves
4589 after all was just a near-empty caller for prefilter). This saves
4582 a function call on every prompt, and simplifies the class a tiny bit.
4590 a function call on every prompt, and simplifies the class a tiny bit.
4583
4591
4584 * Fix _ip to __ip name in magic example file.
4592 * Fix _ip to __ip name in magic example file.
4585
4593
4586 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4594 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
4587 work with non-gnu versions of tar.
4595 work with non-gnu versions of tar.
4588
4596
4589 2001-11-06 Fernando Perez <fperez@colorado.edu>
4597 2001-11-06 Fernando Perez <fperez@colorado.edu>
4590
4598
4591 * Version 0.1.2. Just to keep track of the recent changes.
4599 * Version 0.1.2. Just to keep track of the recent changes.
4592
4600
4593 * Fixed nasty bug in output prompt routine. It used to check 'if
4601 * Fixed nasty bug in output prompt routine. It used to check 'if
4594 arg != None...'. Problem is, this fails if arg implements a
4602 arg != None...'. Problem is, this fails if arg implements a
4595 special comparison (__cmp__) which disallows comparing to
4603 special comparison (__cmp__) which disallows comparing to
4596 None. Found it when trying to use the PhysicalQuantity module from
4604 None. Found it when trying to use the PhysicalQuantity module from
4597 ScientificPython.
4605 ScientificPython.
4598
4606
4599 2001-11-05 Fernando Perez <fperez@colorado.edu>
4607 2001-11-05 Fernando Perez <fperez@colorado.edu>
4600
4608
4601 * Also added dirs. Now the pushd/popd/dirs family functions
4609 * Also added dirs. Now the pushd/popd/dirs family functions
4602 basically like the shell, with the added convenience of going home
4610 basically like the shell, with the added convenience of going home
4603 when called with no args.
4611 when called with no args.
4604
4612
4605 * pushd/popd slightly modified to mimic shell behavior more
4613 * pushd/popd slightly modified to mimic shell behavior more
4606 closely.
4614 closely.
4607
4615
4608 * Added env,pushd,popd from ShellServices as magic functions. I
4616 * Added env,pushd,popd from ShellServices as magic functions. I
4609 think the cleanest will be to port all desired functions from
4617 think the cleanest will be to port all desired functions from
4610 ShellServices as magics and remove ShellServices altogether. This
4618 ShellServices as magics and remove ShellServices altogether. This
4611 will provide a single, clean way of adding functionality
4619 will provide a single, clean way of adding functionality
4612 (shell-type or otherwise) to IP.
4620 (shell-type or otherwise) to IP.
4613
4621
4614 2001-11-04 Fernando Perez <fperez@colorado.edu>
4622 2001-11-04 Fernando Perez <fperez@colorado.edu>
4615
4623
4616 * Added .ipython/ directory to sys.path. This way users can keep
4624 * Added .ipython/ directory to sys.path. This way users can keep
4617 customizations there and access them via import.
4625 customizations there and access them via import.
4618
4626
4619 2001-11-03 Fernando Perez <fperez@colorado.edu>
4627 2001-11-03 Fernando Perez <fperez@colorado.edu>
4620
4628
4621 * Opened version 0.1.1 for new changes.
4629 * Opened version 0.1.1 for new changes.
4622
4630
4623 * Changed version number to 0.1.0: first 'public' release, sent to
4631 * Changed version number to 0.1.0: first 'public' release, sent to
4624 Nathan and Janko.
4632 Nathan and Janko.
4625
4633
4626 * Lots of small fixes and tweaks.
4634 * Lots of small fixes and tweaks.
4627
4635
4628 * Minor changes to whos format. Now strings are shown, snipped if
4636 * Minor changes to whos format. Now strings are shown, snipped if
4629 too long.
4637 too long.
4630
4638
4631 * Changed ShellServices to work on __main__ so they show up in @who
4639 * Changed ShellServices to work on __main__ so they show up in @who
4632
4640
4633 * Help also works with ? at the end of a line:
4641 * Help also works with ? at the end of a line:
4634 ?sin and sin?
4642 ?sin and sin?
4635 both produce the same effect. This is nice, as often I use the
4643 both produce the same effect. This is nice, as often I use the
4636 tab-complete to find the name of a method, but I used to then have
4644 tab-complete to find the name of a method, but I used to then have
4637 to go to the beginning of the line to put a ? if I wanted more
4645 to go to the beginning of the line to put a ? if I wanted more
4638 info. Now I can just add the ? and hit return. Convenient.
4646 info. Now I can just add the ? and hit return. Convenient.
4639
4647
4640 2001-11-02 Fernando Perez <fperez@colorado.edu>
4648 2001-11-02 Fernando Perez <fperez@colorado.edu>
4641
4649
4642 * Python version check (>=2.1) added.
4650 * Python version check (>=2.1) added.
4643
4651
4644 * Added LazyPython documentation. At this point the docs are quite
4652 * Added LazyPython documentation. At this point the docs are quite
4645 a mess. A cleanup is in order.
4653 a mess. A cleanup is in order.
4646
4654
4647 * Auto-installer created. For some bizarre reason, the zipfiles
4655 * Auto-installer created. For some bizarre reason, the zipfiles
4648 module isn't working on my system. So I made a tar version
4656 module isn't working on my system. So I made a tar version
4649 (hopefully the command line options in various systems won't kill
4657 (hopefully the command line options in various systems won't kill
4650 me).
4658 me).
4651
4659
4652 * Fixes to Struct in genutils. Now all dictionary-like methods are
4660 * Fixes to Struct in genutils. Now all dictionary-like methods are
4653 protected (reasonably).
4661 protected (reasonably).
4654
4662
4655 * Added pager function to genutils and changed ? to print usage
4663 * Added pager function to genutils and changed ? to print usage
4656 note through it (it was too long).
4664 note through it (it was too long).
4657
4665
4658 * Added the LazyPython functionality. Works great! I changed the
4666 * Added the LazyPython functionality. Works great! I changed the
4659 auto-quote escape to ';', it's on home row and next to '. But
4667 auto-quote escape to ';', it's on home row and next to '. But
4660 both auto-quote and auto-paren (still /) escapes are command-line
4668 both auto-quote and auto-paren (still /) escapes are command-line
4661 parameters.
4669 parameters.
4662
4670
4663
4671
4664 2001-11-01 Fernando Perez <fperez@colorado.edu>
4672 2001-11-01 Fernando Perez <fperez@colorado.edu>
4665
4673
4666 * Version changed to 0.0.7. Fairly large change: configuration now
4674 * Version changed to 0.0.7. Fairly large change: configuration now
4667 is all stored in a directory, by default .ipython. There, all
4675 is all stored in a directory, by default .ipython. There, all
4668 config files have normal looking names (not .names)
4676 config files have normal looking names (not .names)
4669
4677
4670 * Version 0.0.6 Released first to Lucas and Archie as a test
4678 * Version 0.0.6 Released first to Lucas and Archie as a test
4671 run. Since it's the first 'semi-public' release, change version to
4679 run. Since it's the first 'semi-public' release, change version to
4672 > 0.0.6 for any changes now.
4680 > 0.0.6 for any changes now.
4673
4681
4674 * Stuff I had put in the ipplib.py changelog:
4682 * Stuff I had put in the ipplib.py changelog:
4675
4683
4676 Changes to InteractiveShell:
4684 Changes to InteractiveShell:
4677
4685
4678 - Made the usage message a parameter.
4686 - Made the usage message a parameter.
4679
4687
4680 - Require the name of the shell variable to be given. It's a bit
4688 - Require the name of the shell variable to be given. It's a bit
4681 of a hack, but allows the name 'shell' not to be hardwire in the
4689 of a hack, but allows the name 'shell' not to be hardwire in the
4682 magic (@) handler, which is problematic b/c it requires
4690 magic (@) handler, which is problematic b/c it requires
4683 polluting the global namespace with 'shell'. This in turn is
4691 polluting the global namespace with 'shell'. This in turn is
4684 fragile: if a user redefines a variable called shell, things
4692 fragile: if a user redefines a variable called shell, things
4685 break.
4693 break.
4686
4694
4687 - magic @: all functions available through @ need to be defined
4695 - magic @: all functions available through @ need to be defined
4688 as magic_<name>, even though they can be called simply as
4696 as magic_<name>, even though they can be called simply as
4689 @<name>. This allows the special command @magic to gather
4697 @<name>. This allows the special command @magic to gather
4690 information automatically about all existing magic functions,
4698 information automatically about all existing magic functions,
4691 even if they are run-time user extensions, by parsing the shell
4699 even if they are run-time user extensions, by parsing the shell
4692 instance __dict__ looking for special magic_ names.
4700 instance __dict__ looking for special magic_ names.
4693
4701
4694 - mainloop: added *two* local namespace parameters. This allows
4702 - mainloop: added *two* local namespace parameters. This allows
4695 the class to differentiate between parameters which were there
4703 the class to differentiate between parameters which were there
4696 before and after command line initialization was processed. This
4704 before and after command line initialization was processed. This
4697 way, later @who can show things loaded at startup by the
4705 way, later @who can show things loaded at startup by the
4698 user. This trick was necessary to make session saving/reloading
4706 user. This trick was necessary to make session saving/reloading
4699 really work: ideally after saving/exiting/reloading a session,
4707 really work: ideally after saving/exiting/reloading a session,
4700 *everythin* should look the same, including the output of @who. I
4708 *everythin* should look the same, including the output of @who. I
4701 was only able to make this work with this double namespace
4709 was only able to make this work with this double namespace
4702 trick.
4710 trick.
4703
4711
4704 - added a header to the logfile which allows (almost) full
4712 - added a header to the logfile which allows (almost) full
4705 session restoring.
4713 session restoring.
4706
4714
4707 - prepend lines beginning with @ or !, with a and log
4715 - prepend lines beginning with @ or !, with a and log
4708 them. Why? !lines: may be useful to know what you did @lines:
4716 them. Why? !lines: may be useful to know what you did @lines:
4709 they may affect session state. So when restoring a session, at
4717 they may affect session state. So when restoring a session, at
4710 least inform the user of their presence. I couldn't quite get
4718 least inform the user of their presence. I couldn't quite get
4711 them to properly re-execute, but at least the user is warned.
4719 them to properly re-execute, but at least the user is warned.
4712
4720
4713 * Started ChangeLog.
4721 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now