##// END OF EJS Templates
rocky's pydb patch \#4
vivainio -
Show More
@@ -1,414 +1,416 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 Pdb debugger class.
3 Pdb debugger class.
4
4
5 Modified from the standard pdb.Pdb class to avoid including readline, so that
5 Modified from the standard pdb.Pdb class to avoid including readline, so that
6 the command line completion of other programs which include this isn't
6 the command line completion of other programs which include this isn't
7 damaged.
7 damaged.
8
8
9 In the future, this class will be expanded with improvements over the standard
9 In the future, this class will be expanded with improvements over the standard
10 pdb.
10 pdb.
11
11
12 The code in this file is mainly lifted out of cmd.py in Python 2.2, with minor
12 The code in this file is mainly lifted out of cmd.py in Python 2.2, with minor
13 changes. Licensing should therefore be under the standard Python terms. For
13 changes. Licensing should therefore be under the standard Python terms. For
14 details on the PSF (Python Software Foundation) standard license, see:
14 details on the PSF (Python Software Foundation) standard license, see:
15
15
16 http://www.python.org/2.2.3/license.html
16 http://www.python.org/2.2.3/license.html
17
17
18 $Id: Debugger.py 1955 2006-11-29 09:44:32Z vivainio $"""
18 $Id: Debugger.py 1961 2006-12-05 21:02:40Z vivainio $"""
19
19
20 #*****************************************************************************
20 #*****************************************************************************
21 #
21 #
22 # Since this file is essentially a modified copy of the pdb module which is
22 # Since this file is essentially a modified copy of the pdb module which is
23 # part of the standard Python distribution, I assume that the proper procedure
23 # part of the standard Python distribution, I assume that the proper procedure
24 # is to maintain its copyright as belonging to the Python Software Foundation
24 # is to maintain its copyright as belonging to the Python Software Foundation
25 # (in addition to my own, for all new code).
25 # (in addition to my own, for all new code).
26 #
26 #
27 # Copyright (C) 2001 Python Software Foundation, www.python.org
27 # Copyright (C) 2001 Python Software Foundation, www.python.org
28 # Copyright (C) 2005-2006 Fernando Perez. <fperez@colorado.edu>
28 # Copyright (C) 2005-2006 Fernando Perez. <fperez@colorado.edu>
29 #
29 #
30 # Distributed under the terms of the BSD License. The full license is in
30 # Distributed under the terms of the BSD License. The full license is in
31 # the file COPYING, distributed as part of this software.
31 # the file COPYING, distributed as part of this software.
32 #
32 #
33 #*****************************************************************************
33 #*****************************************************************************
34
34
35 from IPython import Release
35 from IPython import Release
36 __author__ = '%s <%s>' % Release.authors['Fernando']
36 __author__ = '%s <%s>' % Release.authors['Fernando']
37 __license__ = 'Python'
37 __license__ = 'Python'
38
38
39 import bdb
39 import bdb
40 import cmd
40 import cmd
41 import linecache
41 import linecache
42 import os
42 import os
43 import sys
43 import sys
44
44
45 from IPython import PyColorize, ColorANSI
45 from IPython import PyColorize, ColorANSI
46 from IPython.genutils import Term
46 from IPython.genutils import Term
47 from IPython.excolors import ExceptionColors
47 from IPython.excolors import ExceptionColors
48
48
49 # See if we can use pydb.
49 # See if we can use pydb.
50 has_pydb = False
50 has_pydb = False
51 prompt = 'ipdb>'
51 prompt = 'ipdb>'
52 try:
52 try:
53 import pydb
53 import pydb
54 if hasattr(pydb.pydb, "runl"):
54 if hasattr(pydb.pydb, "runl"):
55 has_pydb = True
55 has_pydb = True
56 from pydb import Pdb as OldPdb
56 from pydb import Pdb as OldPdb
57 prompt = 'ipydb>'
57 prompt = 'ipydb>'
58 except ImportError:
58 except ImportError:
59 pass
59 pass
60
60
61 if has_pydb:
61 if has_pydb:
62 from pydb import Pdb as OldPdb
62 from pydb import Pdb as OldPdb
63 else:
63 else:
64 from pdb import Pdb as OldPdb
64 from pdb import Pdb as OldPdb
65
65
66 def decorate_fn_with_doc(new_fn, old_fn, additional_text=""):
66 def decorate_fn_with_doc(new_fn, old_fn, additional_text=""):
67 """Make new_fn have old_fn's doc string. This is particularly useful
67 """Make new_fn have old_fn's doc string. This is particularly useful
68 for the do_... commands that hook into the help system.
68 for the do_... commands that hook into the help system.
69 Adapted from from a comp.lang.python posting
69 Adapted from from a comp.lang.python posting
70 by Duncan Booth."""
70 by Duncan Booth."""
71 def wrapper(*args, **kw):
71 def wrapper(*args, **kw):
72 return new_fn(*args, **kw)
72 return new_fn(*args, **kw)
73 if old_fn.__doc__:
73 if old_fn.__doc__:
74 wrapper.__doc__ = old_fn.__doc__ + additional_text
74 wrapper.__doc__ = old_fn.__doc__ + additional_text
75 return wrapper
75 return wrapper
76
76
77 def _file_lines(fname):
77 def _file_lines(fname):
78 """Return the contents of a named file as a list of lines.
78 """Return the contents of a named file as a list of lines.
79
79
80 This function never raises an IOError exception: if the file can't be
80 This function never raises an IOError exception: if the file can't be
81 read, it simply returns an empty list."""
81 read, it simply returns an empty list."""
82
82
83 try:
83 try:
84 outfile = open(fname)
84 outfile = open(fname)
85 except IOError:
85 except IOError:
86 return []
86 return []
87 else:
87 else:
88 out = outfile.readlines()
88 out = outfile.readlines()
89 outfile.close()
89 outfile.close()
90 return out
90 return out
91
91
92 class Pdb(OldPdb):
92 class Pdb(OldPdb):
93 """Modified Pdb class, does not load readline."""
93 """Modified Pdb class, does not load readline."""
94
94
95 if sys.version[:3] >= '2.5' or has_pydb:
95 if sys.version[:3] >= '2.5' or has_pydb:
96 def __init__(self,color_scheme='NoColor',completekey=None,
96 def __init__(self,color_scheme='NoColor',completekey=None,
97 stdin=None, stdout=None):
97 stdin=None, stdout=None):
98
98
99 # Parent constructor:
99 # Parent constructor:
100 OldPdb.__init__(self,completekey,stdin,stdout)
100 if has_pydb and completekey is None:
101 OldPdb.__init__(self,stdin=stdin,stdout=stdout)
102 else:
103 OldPdb.__init__(self,completekey,stdin,stdout)
104 self.prompt = prompt # The default prompt is '(Pdb)'
101
105
102 # IPython changes...
106 # IPython changes...
103 self.prompt = prompt # The default prompt is '(Pdb)'
107 self.is_pydb = has_pydb
104 self.is_pydb = prompt == 'ipydb>'
105
108
106 if self.is_pydb:
109 if self.is_pydb:
107
110
108 # iplib.py's ipalias seems to want pdb's checkline
111 # iplib.py's ipalias seems to want pdb's checkline
109 # which located in pydb.fn
112 # which located in pydb.fn
110 import pydb.fns
113 import pydb.fns
111 self.checkline = lambda filename, lineno: \
114 self.checkline = lambda filename, lineno: \
112 pydb.fns.checkline(self, filename, lineno)
115 pydb.fns.checkline(self, filename, lineno)
113
116
114 self.curframe = None
117 self.curframe = None
115 self.do_restart = self.new_do_restart
118 self.do_restart = self.new_do_restart
116
119
117 self.old_all_completions = __IPYTHON__.Completer.all_completions
120 self.old_all_completions = __IPYTHON__.Completer.all_completions
118 __IPYTHON__.Completer.all_completions=self.all_completions
121 __IPYTHON__.Completer.all_completions=self.all_completions
119
122
120 # Do we have access to pydb's list command parser?
121 self.do_list = decorate_fn_with_doc(self.list_command_pydb,
123 self.do_list = decorate_fn_with_doc(self.list_command_pydb,
122 OldPdb.do_list)
124 OldPdb.do_list)
123 self.do_l = self.do_list
125 self.do_l = self.do_list
124 self.do_frame = decorate_fn_with_doc(self.new_do_frame,
126 self.do_frame = decorate_fn_with_doc(self.new_do_frame,
125 OldPdb.do_frame)
127 OldPdb.do_frame)
126
128
127 self.aliases = {}
129 self.aliases = {}
128
130
129 # Create color table: we copy the default one from the traceback
131 # Create color table: we copy the default one from the traceback
130 # module and add a few attributes needed for debugging
132 # module and add a few attributes needed for debugging
131 self.color_scheme_table = ExceptionColors.copy()
133 self.color_scheme_table = ExceptionColors.copy()
132
134
133 # shorthands
135 # shorthands
134 C = ColorANSI.TermColors
136 C = ColorANSI.TermColors
135 cst = self.color_scheme_table
137 cst = self.color_scheme_table
136
138
137 cst['NoColor'].colors.breakpoint_enabled = C.NoColor
139 cst['NoColor'].colors.breakpoint_enabled = C.NoColor
138 cst['NoColor'].colors.breakpoint_disabled = C.NoColor
140 cst['NoColor'].colors.breakpoint_disabled = C.NoColor
139
141
140 cst['Linux'].colors.breakpoint_enabled = C.LightRed
142 cst['Linux'].colors.breakpoint_enabled = C.LightRed
141 cst['Linux'].colors.breakpoint_disabled = C.Red
143 cst['Linux'].colors.breakpoint_disabled = C.Red
142
144
143 cst['LightBG'].colors.breakpoint_enabled = C.LightRed
145 cst['LightBG'].colors.breakpoint_enabled = C.LightRed
144 cst['LightBG'].colors.breakpoint_disabled = C.Red
146 cst['LightBG'].colors.breakpoint_disabled = C.Red
145
147
146 self.set_colors(color_scheme)
148 self.set_colors(color_scheme)
147
149
148 else:
150 else:
149 # Ugly hack: for Python 2.3-2.4, we can't call the parent constructor,
151 # Ugly hack: for Python 2.3-2.4, we can't call the parent constructor,
150 # because it binds readline and breaks tab-completion. This means we
152 # because it binds readline and breaks tab-completion. This means we
151 # have to COPY the constructor here.
153 # have to COPY the constructor here.
152 def __init__(self,color_scheme='NoColor'):
154 def __init__(self,color_scheme='NoColor'):
153 bdb.Bdb.__init__(self)
155 bdb.Bdb.__init__(self)
154 cmd.Cmd.__init__(self,completekey=None) # don't load readline
156 cmd.Cmd.__init__(self,completekey=None) # don't load readline
155 self.prompt = 'ipdb> ' # The default prompt is '(Pdb)'
157 self.prompt = 'ipdb> ' # The default prompt is '(Pdb)'
156 self.aliases = {}
158 self.aliases = {}
157
159
158 # These two lines are part of the py2.4 constructor, let's put them
160 # These two lines are part of the py2.4 constructor, let's put them
159 # unconditionally here as they won't cause any problems in 2.3.
161 # unconditionally here as they won't cause any problems in 2.3.
160 self.mainpyfile = ''
162 self.mainpyfile = ''
161 self._wait_for_mainpyfile = 0
163 self._wait_for_mainpyfile = 0
162
164
163 # Read $HOME/.pdbrc and ./.pdbrc
165 # Read $HOME/.pdbrc and ./.pdbrc
164 try:
166 try:
165 self.rcLines = _file_lines(os.path.join(os.environ['HOME'],
167 self.rcLines = _file_lines(os.path.join(os.environ['HOME'],
166 ".pdbrc"))
168 ".pdbrc"))
167 except KeyError:
169 except KeyError:
168 self.rcLines = []
170 self.rcLines = []
169 self.rcLines.extend(_file_lines(".pdbrc"))
171 self.rcLines.extend(_file_lines(".pdbrc"))
170
172
171 # Create color table: we copy the default one from the traceback
173 # Create color table: we copy the default one from the traceback
172 # module and add a few attributes needed for debugging
174 # module and add a few attributes needed for debugging
173 self.color_scheme_table = ExceptionColors.copy()
175 self.color_scheme_table = ExceptionColors.copy()
174
176
175 # shorthands
177 # shorthands
176 C = ColorANSI.TermColors
178 C = ColorANSI.TermColors
177 cst = self.color_scheme_table
179 cst = self.color_scheme_table
178
180
179 cst['NoColor'].colors.breakpoint_enabled = C.NoColor
181 cst['NoColor'].colors.breakpoint_enabled = C.NoColor
180 cst['NoColor'].colors.breakpoint_disabled = C.NoColor
182 cst['NoColor'].colors.breakpoint_disabled = C.NoColor
181
183
182 cst['Linux'].colors.breakpoint_enabled = C.LightRed
184 cst['Linux'].colors.breakpoint_enabled = C.LightRed
183 cst['Linux'].colors.breakpoint_disabled = C.Red
185 cst['Linux'].colors.breakpoint_disabled = C.Red
184
186
185 cst['LightBG'].colors.breakpoint_enabled = C.LightRed
187 cst['LightBG'].colors.breakpoint_enabled = C.LightRed
186 cst['LightBG'].colors.breakpoint_disabled = C.Red
188 cst['LightBG'].colors.breakpoint_disabled = C.Red
187
189
188 self.set_colors(color_scheme)
190 self.set_colors(color_scheme)
189
191
190 def set_colors(self, scheme):
192 def set_colors(self, scheme):
191 """Shorthand access to the color table scheme selector method."""
193 """Shorthand access to the color table scheme selector method."""
192 self.color_scheme_table.set_active_scheme(scheme)
194 self.color_scheme_table.set_active_scheme(scheme)
193
195
194 def interaction(self, frame, traceback):
196 def interaction(self, frame, traceback):
195 __IPYTHON__.set_completer_frame(frame)
197 __IPYTHON__.set_completer_frame(frame)
196 OldPdb.interaction(self, frame, traceback)
198 OldPdb.interaction(self, frame, traceback)
197
199
198 def new_do_up(self, arg):
200 def new_do_up(self, arg):
199 OldPdb.do_up(self, arg)
201 OldPdb.do_up(self, arg)
200 __IPYTHON__.set_completer_frame(self.curframe)
202 __IPYTHON__.set_completer_frame(self.curframe)
201 do_u = do_up = decorate_fn_with_doc(new_do_up, OldPdb.do_up)
203 do_u = do_up = decorate_fn_with_doc(new_do_up, OldPdb.do_up)
202
204
203 def new_do_down(self, arg):
205 def new_do_down(self, arg):
204 OldPdb.do_down(self, arg)
206 OldPdb.do_down(self, arg)
205 __IPYTHON__.set_completer_frame(self.curframe)
207 __IPYTHON__.set_completer_frame(self.curframe)
206
208
207 do_d = do_down = decorate_fn_with_doc(new_do_down, OldPdb.do_down)
209 do_d = do_down = decorate_fn_with_doc(new_do_down, OldPdb.do_down)
208
210
209 def new_do_frame(self, arg):
211 def new_do_frame(self, arg):
210 OldPdb.do_frame(self, arg)
212 OldPdb.do_frame(self, arg)
211 __IPYTHON__.set_completer_frame(self.curframe)
213 __IPYTHON__.set_completer_frame(self.curframe)
212
214
213 def new_do_quit(self, arg):
215 def new_do_quit(self, arg):
214
216
215 if hasattr(self, 'old_all_completions'):
217 if hasattr(self, 'old_all_completions'):
216 __IPYTHON__.Completer.all_completions=self.old_all_completions
218 __IPYTHON__.Completer.all_completions=self.old_all_completions
217
219
218
220
219 return OldPdb.do_quit(self, arg)
221 return OldPdb.do_quit(self, arg)
220
222
221 do_q = do_quit = decorate_fn_with_doc(new_do_quit, OldPdb.do_quit)
223 do_q = do_quit = decorate_fn_with_doc(new_do_quit, OldPdb.do_quit)
222
224
223 def new_do_restart(self, arg):
225 def new_do_restart(self, arg):
224 """Restart command. In the context of ipython this is exactly the same
226 """Restart command. In the context of ipython this is exactly the same
225 thing as 'quit'."""
227 thing as 'quit'."""
226 self.msg("Restart doesn't make sense here. Using 'quit' instead.")
228 self.msg("Restart doesn't make sense here. Using 'quit' instead.")
227 return self.do_quit(arg)
229 return self.do_quit(arg)
228
230
229 def postloop(self):
231 def postloop(self):
230 __IPYTHON__.set_completer_frame(None)
232 __IPYTHON__.set_completer_frame(None)
231
233
232 def print_stack_trace(self):
234 def print_stack_trace(self):
233 try:
235 try:
234 for frame_lineno in self.stack:
236 for frame_lineno in self.stack:
235 self.print_stack_entry(frame_lineno, context = 5)
237 self.print_stack_entry(frame_lineno, context = 5)
236 except KeyboardInterrupt:
238 except KeyboardInterrupt:
237 pass
239 pass
238
240
239 def print_stack_entry(self,frame_lineno,prompt_prefix='\n-> ',
241 def print_stack_entry(self,frame_lineno,prompt_prefix='\n-> ',
240 context = 3):
242 context = 3):
241 frame, lineno = frame_lineno
243 frame, lineno = frame_lineno
242 print >>Term.cout, self.format_stack_entry(frame_lineno, '', context)
244 print >>Term.cout, self.format_stack_entry(frame_lineno, '', context)
243
245
244 def format_stack_entry(self, frame_lineno, lprefix=': ', context = 3):
246 def format_stack_entry(self, frame_lineno, lprefix=': ', context = 3):
245 import linecache, repr
247 import linecache, repr
246
248
247 ret = []
249 ret = []
248
250
249 Colors = self.color_scheme_table.active_colors
251 Colors = self.color_scheme_table.active_colors
250 ColorsNormal = Colors.Normal
252 ColorsNormal = Colors.Normal
251 tpl_link = '%s%%s%s' % (Colors.filenameEm, ColorsNormal)
253 tpl_link = '%s%%s%s' % (Colors.filenameEm, ColorsNormal)
252 tpl_call = '%s%%s%s%%s%s' % (Colors.vName, Colors.valEm, ColorsNormal)
254 tpl_call = '%s%%s%s%%s%s' % (Colors.vName, Colors.valEm, ColorsNormal)
253 tpl_line = '%%s%s%%s %s%%s' % (Colors.lineno, ColorsNormal)
255 tpl_line = '%%s%s%%s %s%%s' % (Colors.lineno, ColorsNormal)
254 tpl_line_em = '%%s%s%%s %s%%s%s' % (Colors.linenoEm, Colors.line,
256 tpl_line_em = '%%s%s%%s %s%%s%s' % (Colors.linenoEm, Colors.line,
255 ColorsNormal)
257 ColorsNormal)
256
258
257 frame, lineno = frame_lineno
259 frame, lineno = frame_lineno
258
260
259 return_value = ''
261 return_value = ''
260 if '__return__' in frame.f_locals:
262 if '__return__' in frame.f_locals:
261 rv = frame.f_locals['__return__']
263 rv = frame.f_locals['__return__']
262 #return_value += '->'
264 #return_value += '->'
263 return_value += repr.repr(rv) + '\n'
265 return_value += repr.repr(rv) + '\n'
264 ret.append(return_value)
266 ret.append(return_value)
265
267
266 #s = filename + '(' + `lineno` + ')'
268 #s = filename + '(' + `lineno` + ')'
267 filename = self.canonic(frame.f_code.co_filename)
269 filename = self.canonic(frame.f_code.co_filename)
268 link = tpl_link % filename
270 link = tpl_link % filename
269
271
270 if frame.f_code.co_name:
272 if frame.f_code.co_name:
271 func = frame.f_code.co_name
273 func = frame.f_code.co_name
272 else:
274 else:
273 func = "<lambda>"
275 func = "<lambda>"
274
276
275 call = ''
277 call = ''
276 if func != '?':
278 if func != '?':
277 if '__args__' in frame.f_locals:
279 if '__args__' in frame.f_locals:
278 args = repr.repr(frame.f_locals['__args__'])
280 args = repr.repr(frame.f_locals['__args__'])
279 else:
281 else:
280 args = '()'
282 args = '()'
281 call = tpl_call % (func, args)
283 call = tpl_call % (func, args)
282
284
283 # The level info should be generated in the same format pdb uses, to
285 # The level info should be generated in the same format pdb uses, to
284 # avoid breaking the pdbtrack functionality of python-mode in *emacs.
286 # avoid breaking the pdbtrack functionality of python-mode in *emacs.
285 ret.append('> %s(%s)%s\n' % (link,lineno,call))
287 ret.append('> %s(%s)%s\n' % (link,lineno,call))
286
288
287 start = lineno - 1 - context//2
289 start = lineno - 1 - context//2
288 lines = linecache.getlines(filename)
290 lines = linecache.getlines(filename)
289 start = max(start, 0)
291 start = max(start, 0)
290 start = min(start, len(lines) - context)
292 start = min(start, len(lines) - context)
291 lines = lines[start : start + context]
293 lines = lines[start : start + context]
292
294
293 for i,line in enumerate(lines):
295 for i,line in enumerate(lines):
294 show_arrow = (start + 1 + i == lineno)
296 show_arrow = (start + 1 + i == lineno)
295 ret.append(self.__format_line(tpl_line_em, filename,
297 ret.append(self.__format_line(tpl_line_em, filename,
296 start + 1 + i, line,
298 start + 1 + i, line,
297 arrow = show_arrow) )
299 arrow = show_arrow) )
298
300
299 return ''.join(ret)
301 return ''.join(ret)
300
302
301 def __format_line(self, tpl_line, filename, lineno, line, arrow = False):
303 def __format_line(self, tpl_line, filename, lineno, line, arrow = False):
302 bp_mark = ""
304 bp_mark = ""
303 bp_mark_color = ""
305 bp_mark_color = ""
304
306
305 bp = None
307 bp = None
306 if lineno in self.get_file_breaks(filename):
308 if lineno in self.get_file_breaks(filename):
307 bps = self.get_breaks(filename, lineno)
309 bps = self.get_breaks(filename, lineno)
308 bp = bps[-1]
310 bp = bps[-1]
309
311
310 if bp:
312 if bp:
311 Colors = self.color_scheme_table.active_colors
313 Colors = self.color_scheme_table.active_colors
312 bp_mark = str(bp.number)
314 bp_mark = str(bp.number)
313 bp_mark_color = Colors.breakpoint_enabled
315 bp_mark_color = Colors.breakpoint_enabled
314 if not bp.enabled:
316 if not bp.enabled:
315 bp_mark_color = Colors.breakpoint_disabled
317 bp_mark_color = Colors.breakpoint_disabled
316
318
317 numbers_width = 7
319 numbers_width = 7
318 if arrow:
320 if arrow:
319 # This is the line with the error
321 # This is the line with the error
320 pad = numbers_width - len(str(lineno)) - len(bp_mark)
322 pad = numbers_width - len(str(lineno)) - len(bp_mark)
321 if pad >= 3:
323 if pad >= 3:
322 marker = '-'*(pad-3) + '-> '
324 marker = '-'*(pad-3) + '-> '
323 elif pad == 2:
325 elif pad == 2:
324 marker = '> '
326 marker = '> '
325 elif pad == 1:
327 elif pad == 1:
326 marker = '>'
328 marker = '>'
327 else:
329 else:
328 marker = ''
330 marker = ''
329 num = '%s%s' % (marker, str(lineno))
331 num = '%s%s' % (marker, str(lineno))
330 line = tpl_line % (bp_mark_color + bp_mark, num, line)
332 line = tpl_line % (bp_mark_color + bp_mark, num, line)
331 else:
333 else:
332 num = '%*s' % (numbers_width - len(bp_mark), str(lineno))
334 num = '%*s' % (numbers_width - len(bp_mark), str(lineno))
333 line = tpl_line % (bp_mark_color + bp_mark, num, line)
335 line = tpl_line % (bp_mark_color + bp_mark, num, line)
334
336
335 return line
337 return line
336
338
337 def list_command_pydb(self, arg):
339 def list_command_pydb(self, arg):
338 """List command to use if we have a newer pydb installed"""
340 """List command to use if we have a newer pydb installed"""
339 filename, first, last = OldPdb.parse_list_cmd(self, arg)
341 filename, first, last = OldPdb.parse_list_cmd(self, arg)
340 if filename is not None:
342 if filename is not None:
341 self.print_list_lines(filename, first, last)
343 self.print_list_lines(filename, first, last)
342
344
343 def print_list_lines(self, filename, first, last):
345 def print_list_lines(self, filename, first, last):
344 """The printing (as opposed to the parsing part of a 'list'
346 """The printing (as opposed to the parsing part of a 'list'
345 command."""
347 command."""
346 try:
348 try:
347 Colors = self.color_scheme_table.active_colors
349 Colors = self.color_scheme_table.active_colors
348 ColorsNormal = Colors.Normal
350 ColorsNormal = Colors.Normal
349 tpl_line = '%%s%s%%s %s%%s' % (Colors.lineno, ColorsNormal)
351 tpl_line = '%%s%s%%s %s%%s' % (Colors.lineno, ColorsNormal)
350 tpl_line_em = '%%s%s%%s %s%%s%s' % (Colors.linenoEm, Colors.line, ColorsNormal)
352 tpl_line_em = '%%s%s%%s %s%%s%s' % (Colors.linenoEm, Colors.line, ColorsNormal)
351 src = []
353 src = []
352 for lineno in range(first, last+1):
354 for lineno in range(first, last+1):
353 line = linecache.getline(filename, lineno)
355 line = linecache.getline(filename, lineno)
354 if not line:
356 if not line:
355 break
357 break
356
358
357 if lineno == self.curframe.f_lineno:
359 if lineno == self.curframe.f_lineno:
358 line = self.__format_line(tpl_line_em, filename, lineno, line, arrow = True)
360 line = self.__format_line(tpl_line_em, filename, lineno, line, arrow = True)
359 else:
361 else:
360 line = self.__format_line(tpl_line, filename, lineno, line, arrow = False)
362 line = self.__format_line(tpl_line, filename, lineno, line, arrow = False)
361
363
362 src.append(line)
364 src.append(line)
363 self.lineno = lineno
365 self.lineno = lineno
364
366
365 print >>Term.cout, ''.join(src)
367 print >>Term.cout, ''.join(src)
366
368
367 except KeyboardInterrupt:
369 except KeyboardInterrupt:
368 pass
370 pass
369
371
370 def do_list(self, arg):
372 def do_list(self, arg):
371 self.lastcmd = 'list'
373 self.lastcmd = 'list'
372 last = None
374 last = None
373 if arg:
375 if arg:
374 try:
376 try:
375 x = eval(arg, {}, {})
377 x = eval(arg, {}, {})
376 if type(x) == type(()):
378 if type(x) == type(()):
377 first, last = x
379 first, last = x
378 first = int(first)
380 first = int(first)
379 last = int(last)
381 last = int(last)
380 if last < first:
382 if last < first:
381 # Assume it's a count
383 # Assume it's a count
382 last = first + last
384 last = first + last
383 else:
385 else:
384 first = max(1, int(x) - 5)
386 first = max(1, int(x) - 5)
385 except:
387 except:
386 print '*** Error in argument:', `arg`
388 print '*** Error in argument:', `arg`
387 return
389 return
388 elif self.lineno is None:
390 elif self.lineno is None:
389 first = max(1, self.curframe.f_lineno - 5)
391 first = max(1, self.curframe.f_lineno - 5)
390 else:
392 else:
391 first = self.lineno + 1
393 first = self.lineno + 1
392 if last is None:
394 if last is None:
393 last = first + 10
395 last = first + 10
394 self.print_list_lines(self.curframe.f_code.co_filename, first, last)
396 self.print_list_lines(self.curframe.f_code.co_filename, first, last)
395
397
396 do_l = do_list
398 do_l = do_list
397
399
398 def do_pdef(self, arg):
400 def do_pdef(self, arg):
399 """The debugger interface to magic_pdef"""
401 """The debugger interface to magic_pdef"""
400 namespaces = [('Locals', self.curframe.f_locals),
402 namespaces = [('Locals', self.curframe.f_locals),
401 ('Globals', self.curframe.f_globals)]
403 ('Globals', self.curframe.f_globals)]
402 __IPYTHON__.magic_pdef(arg, namespaces=namespaces)
404 __IPYTHON__.magic_pdef(arg, namespaces=namespaces)
403
405
404 def do_pdoc(self, arg):
406 def do_pdoc(self, arg):
405 """The debugger interface to magic_pdoc"""
407 """The debugger interface to magic_pdoc"""
406 namespaces = [('Locals', self.curframe.f_locals),
408 namespaces = [('Locals', self.curframe.f_locals),
407 ('Globals', self.curframe.f_globals)]
409 ('Globals', self.curframe.f_globals)]
408 __IPYTHON__.magic_pdoc(arg, namespaces=namespaces)
410 __IPYTHON__.magic_pdoc(arg, namespaces=namespaces)
409
411
410 def do_pinfo(self, arg):
412 def do_pinfo(self, arg):
411 """The debugger equivalant of ?obj"""
413 """The debugger equivalant of ?obj"""
412 namespaces = [('Locals', self.curframe.f_locals),
414 namespaces = [('Locals', self.curframe.f_locals),
413 ('Globals', self.curframe.f_globals)]
415 ('Globals', self.curframe.f_globals)]
414 __IPYTHON__.magic_pinfo("pinfo %s" % arg, namespaces=namespaces)
416 __IPYTHON__.magic_pinfo("pinfo %s" % arg, namespaces=namespaces)
@@ -1,3058 +1,3057 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 1956 2006-11-30 05:22:31Z fperez $"""
4 $Id: Magic.py 1961 2006-12-05 21:02:40Z vivainio $"""
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-2006 Fernando Perez <fperez@colorado.edu>
8 # Copyright (C) 2001-2006 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 import textwrap
34 import textwrap
35 from cStringIO import StringIO
35 from cStringIO import StringIO
36 from getopt import getopt,GetoptError
36 from getopt import getopt,GetoptError
37 from pprint import pprint, pformat
37 from pprint import pprint, pformat
38
38
39 # cProfile was added in Python2.5
39 # cProfile was added in Python2.5
40 try:
40 try:
41 import cProfile as profile
41 import cProfile as profile
42 import pstats
42 import pstats
43 except ImportError:
43 except ImportError:
44 # profile isn't bundled by default in Debian for license reasons
44 # profile isn't bundled by default in Debian for license reasons
45 try:
45 try:
46 import profile,pstats
46 import profile,pstats
47 except ImportError:
47 except ImportError:
48 profile = pstats = None
48 profile = pstats = None
49
49
50 # Homebrewed
50 # Homebrewed
51 import IPython
51 import IPython
52 from IPython import Debugger, OInspect, wildcard
52 from IPython import Debugger, OInspect, wildcard
53 from IPython.FakeModule import FakeModule
53 from IPython.FakeModule import FakeModule
54 from IPython.Itpl import Itpl, itpl, printpl,itplns
54 from IPython.Itpl import Itpl, itpl, printpl,itplns
55 from IPython.PyColorize import Parser
55 from IPython.PyColorize import Parser
56 from IPython.ipstruct import Struct
56 from IPython.ipstruct import Struct
57 from IPython.macro import Macro
57 from IPython.macro import Macro
58 from IPython.genutils import *
58 from IPython.genutils import *
59 from IPython import platutils
59 from IPython import platutils
60
60
61 #***************************************************************************
61 #***************************************************************************
62 # Utility functions
62 # Utility functions
63 def on_off(tag):
63 def on_off(tag):
64 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
64 """Return an ON/OFF string for a 1/0 input. Simple utility function."""
65 return ['OFF','ON'][tag]
65 return ['OFF','ON'][tag]
66
66
67 class Bunch: pass
67 class Bunch: pass
68
68
69 #***************************************************************************
69 #***************************************************************************
70 # Main class implementing Magic functionality
70 # Main class implementing Magic functionality
71 class Magic:
71 class Magic:
72 """Magic functions for InteractiveShell.
72 """Magic functions for InteractiveShell.
73
73
74 Shell functions which can be reached as %function_name. All magic
74 Shell functions which can be reached as %function_name. All magic
75 functions should accept a string, which they can parse for their own
75 functions should accept a string, which they can parse for their own
76 needs. This can make some functions easier to type, eg `%cd ../`
76 needs. This can make some functions easier to type, eg `%cd ../`
77 vs. `%cd("../")`
77 vs. `%cd("../")`
78
78
79 ALL definitions MUST begin with the prefix magic_. The user won't need it
79 ALL definitions MUST begin with the prefix magic_. The user won't need it
80 at the command line, but it is is needed in the definition. """
80 at the command line, but it is is needed in the definition. """
81
81
82 # class globals
82 # class globals
83 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
83 auto_status = ['Automagic is OFF, % prefix IS needed for magic functions.',
84 'Automagic is ON, % prefix NOT needed for magic functions.']
84 'Automagic is ON, % prefix NOT needed for magic functions.']
85
85
86 #......................................................................
86 #......................................................................
87 # some utility functions
87 # some utility functions
88
88
89 def __init__(self,shell):
89 def __init__(self,shell):
90
90
91 self.options_table = {}
91 self.options_table = {}
92 if profile is None:
92 if profile is None:
93 self.magic_prun = self.profile_missing_notice
93 self.magic_prun = self.profile_missing_notice
94 self.shell = shell
94 self.shell = shell
95
95
96 # namespace for holding state we may need
96 # namespace for holding state we may need
97 self._magic_state = Bunch()
97 self._magic_state = Bunch()
98
98
99 def profile_missing_notice(self, *args, **kwargs):
99 def profile_missing_notice(self, *args, **kwargs):
100 error("""\
100 error("""\
101 The profile module could not be found. If you are a Debian user,
101 The profile module could not be found. If you are a Debian user,
102 it has been removed from the standard Debian package because of its non-free
102 it has been removed from the standard Debian package because of its non-free
103 license. To use profiling, please install"python2.3-profiler" from non-free.""")
103 license. To use profiling, please install"python2.3-profiler" from non-free.""")
104
104
105 def default_option(self,fn,optstr):
105 def default_option(self,fn,optstr):
106 """Make an entry in the options_table for fn, with value optstr"""
106 """Make an entry in the options_table for fn, with value optstr"""
107
107
108 if fn not in self.lsmagic():
108 if fn not in self.lsmagic():
109 error("%s is not a magic function" % fn)
109 error("%s is not a magic function" % fn)
110 self.options_table[fn] = optstr
110 self.options_table[fn] = optstr
111
111
112 def lsmagic(self):
112 def lsmagic(self):
113 """Return a list of currently available magic functions.
113 """Return a list of currently available magic functions.
114
114
115 Gives a list of the bare names after mangling (['ls','cd', ...], not
115 Gives a list of the bare names after mangling (['ls','cd', ...], not
116 ['magic_ls','magic_cd',...]"""
116 ['magic_ls','magic_cd',...]"""
117
117
118 # FIXME. This needs a cleanup, in the way the magics list is built.
118 # FIXME. This needs a cleanup, in the way the magics list is built.
119
119
120 # magics in class definition
120 # magics in class definition
121 class_magic = lambda fn: fn.startswith('magic_') and \
121 class_magic = lambda fn: fn.startswith('magic_') and \
122 callable(Magic.__dict__[fn])
122 callable(Magic.__dict__[fn])
123 # in instance namespace (run-time user additions)
123 # in instance namespace (run-time user additions)
124 inst_magic = lambda fn: fn.startswith('magic_') and \
124 inst_magic = lambda fn: fn.startswith('magic_') and \
125 callable(self.__dict__[fn])
125 callable(self.__dict__[fn])
126 # and bound magics by user (so they can access self):
126 # and bound magics by user (so they can access self):
127 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
127 inst_bound_magic = lambda fn: fn.startswith('magic_') and \
128 callable(self.__class__.__dict__[fn])
128 callable(self.__class__.__dict__[fn])
129 magics = filter(class_magic,Magic.__dict__.keys()) + \
129 magics = filter(class_magic,Magic.__dict__.keys()) + \
130 filter(inst_magic,self.__dict__.keys()) + \
130 filter(inst_magic,self.__dict__.keys()) + \
131 filter(inst_bound_magic,self.__class__.__dict__.keys())
131 filter(inst_bound_magic,self.__class__.__dict__.keys())
132 out = []
132 out = []
133 for fn in magics:
133 for fn in magics:
134 out.append(fn.replace('magic_','',1))
134 out.append(fn.replace('magic_','',1))
135 out.sort()
135 out.sort()
136 return out
136 return out
137
137
138 def extract_input_slices(self,slices,raw=False):
138 def extract_input_slices(self,slices,raw=False):
139 """Return as a string a set of input history slices.
139 """Return as a string a set of input history slices.
140
140
141 Inputs:
141 Inputs:
142
142
143 - slices: the set of slices is given as a list of strings (like
143 - slices: the set of slices is given as a list of strings (like
144 ['1','4:8','9'], since this function is for use by magic functions
144 ['1','4:8','9'], since this function is for use by magic functions
145 which get their arguments as strings.
145 which get their arguments as strings.
146
146
147 Optional inputs:
147 Optional inputs:
148
148
149 - raw(False): by default, the processed input is used. If this is
149 - raw(False): by default, the processed input is used. If this is
150 true, the raw input history is used instead.
150 true, the raw input history is used instead.
151
151
152 Note that slices can be called with two notations:
152 Note that slices can be called with two notations:
153
153
154 N:M -> standard python form, means including items N...(M-1).
154 N:M -> standard python form, means including items N...(M-1).
155
155
156 N-M -> include items N..M (closed endpoint)."""
156 N-M -> include items N..M (closed endpoint)."""
157
157
158 if raw:
158 if raw:
159 hist = self.shell.input_hist_raw
159 hist = self.shell.input_hist_raw
160 else:
160 else:
161 hist = self.shell.input_hist
161 hist = self.shell.input_hist
162
162
163 cmds = []
163 cmds = []
164 for chunk in slices:
164 for chunk in slices:
165 if ':' in chunk:
165 if ':' in chunk:
166 ini,fin = map(int,chunk.split(':'))
166 ini,fin = map(int,chunk.split(':'))
167 elif '-' in chunk:
167 elif '-' in chunk:
168 ini,fin = map(int,chunk.split('-'))
168 ini,fin = map(int,chunk.split('-'))
169 fin += 1
169 fin += 1
170 else:
170 else:
171 ini = int(chunk)
171 ini = int(chunk)
172 fin = ini+1
172 fin = ini+1
173 cmds.append(hist[ini:fin])
173 cmds.append(hist[ini:fin])
174 return cmds
174 return cmds
175
175
176 def _ofind(self, oname, namespaces=None):
176 def _ofind(self, oname, namespaces=None):
177 """Find an object in the available namespaces.
177 """Find an object in the available namespaces.
178
178
179 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
179 self._ofind(oname) -> dict with keys: found,obj,ospace,ismagic
180
180
181 Has special code to detect magic functions.
181 Has special code to detect magic functions.
182 """
182 """
183
183
184 oname = oname.strip()
184 oname = oname.strip()
185
185
186 alias_ns = None
186 alias_ns = None
187 if namespaces is None:
187 if namespaces is None:
188 # Namespaces to search in:
188 # Namespaces to search in:
189 # Put them in a list. The order is important so that we
189 # Put them in a list. The order is important so that we
190 # find things in the same order that Python finds them.
190 # find things in the same order that Python finds them.
191 namespaces = [ ('Interactive', self.shell.user_ns),
191 namespaces = [ ('Interactive', self.shell.user_ns),
192 ('IPython internal', self.shell.internal_ns),
192 ('IPython internal', self.shell.internal_ns),
193 ('Python builtin', __builtin__.__dict__),
193 ('Python builtin', __builtin__.__dict__),
194 ('Alias', self.shell.alias_table),
194 ('Alias', self.shell.alias_table),
195 ]
195 ]
196 alias_ns = self.shell.alias_table
196 alias_ns = self.shell.alias_table
197
197
198 # initialize results to 'null'
198 # initialize results to 'null'
199 found = 0; obj = None; ospace = None; ds = None;
199 found = 0; obj = None; ospace = None; ds = None;
200 ismagic = 0; isalias = 0; parent = None
200 ismagic = 0; isalias = 0; parent = None
201
201
202 # Look for the given name by splitting it in parts. If the head is
202 # Look for the given name by splitting it in parts. If the head is
203 # found, then we look for all the remaining parts as members, and only
203 # found, then we look for all the remaining parts as members, and only
204 # declare success if we can find them all.
204 # declare success if we can find them all.
205 oname_parts = oname.split('.')
205 oname_parts = oname.split('.')
206 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
206 oname_head, oname_rest = oname_parts[0],oname_parts[1:]
207 for nsname,ns in namespaces:
207 for nsname,ns in namespaces:
208 try:
208 try:
209 obj = ns[oname_head]
209 obj = ns[oname_head]
210 except KeyError:
210 except KeyError:
211 continue
211 continue
212 else:
212 else:
213 for part in oname_rest:
213 for part in oname_rest:
214 try:
214 try:
215 parent = obj
215 parent = obj
216 obj = getattr(obj,part)
216 obj = getattr(obj,part)
217 except:
217 except:
218 # Blanket except b/c some badly implemented objects
218 # Blanket except b/c some badly implemented objects
219 # allow __getattr__ to raise exceptions other than
219 # allow __getattr__ to raise exceptions other than
220 # AttributeError, which then crashes IPython.
220 # AttributeError, which then crashes IPython.
221 break
221 break
222 else:
222 else:
223 # If we finish the for loop (no break), we got all members
223 # If we finish the for loop (no break), we got all members
224 found = 1
224 found = 1
225 ospace = nsname
225 ospace = nsname
226 if ns == alias_ns:
226 if ns == alias_ns:
227 isalias = 1
227 isalias = 1
228 break # namespace loop
228 break # namespace loop
229
229
230 # Try to see if it's magic
230 # Try to see if it's magic
231 if not found:
231 if not found:
232 if oname.startswith(self.shell.ESC_MAGIC):
232 if oname.startswith(self.shell.ESC_MAGIC):
233 oname = oname[1:]
233 oname = oname[1:]
234 obj = getattr(self,'magic_'+oname,None)
234 obj = getattr(self,'magic_'+oname,None)
235 if obj is not None:
235 if obj is not None:
236 found = 1
236 found = 1
237 ospace = 'IPython internal'
237 ospace = 'IPython internal'
238 ismagic = 1
238 ismagic = 1
239
239
240 # Last try: special-case some literals like '', [], {}, etc:
240 # Last try: special-case some literals like '', [], {}, etc:
241 if not found and oname_head in ["''",'""','[]','{}','()']:
241 if not found and oname_head in ["''",'""','[]','{}','()']:
242 obj = eval(oname_head)
242 obj = eval(oname_head)
243 found = 1
243 found = 1
244 ospace = 'Interactive'
244 ospace = 'Interactive'
245
245
246 return {'found':found, 'obj':obj, 'namespace':ospace,
246 return {'found':found, 'obj':obj, 'namespace':ospace,
247 'ismagic':ismagic, 'isalias':isalias, 'parent':parent}
247 'ismagic':ismagic, 'isalias':isalias, 'parent':parent}
248
248
249 def arg_err(self,func):
249 def arg_err(self,func):
250 """Print docstring if incorrect arguments were passed"""
250 """Print docstring if incorrect arguments were passed"""
251 print 'Error in arguments:'
251 print 'Error in arguments:'
252 print OInspect.getdoc(func)
252 print OInspect.getdoc(func)
253
253
254 def format_latex(self,strng):
254 def format_latex(self,strng):
255 """Format a string for latex inclusion."""
255 """Format a string for latex inclusion."""
256
256
257 # Characters that need to be escaped for latex:
257 # Characters that need to be escaped for latex:
258 escape_re = re.compile(r'(%|_|\$|#|&)',re.MULTILINE)
258 escape_re = re.compile(r'(%|_|\$|#|&)',re.MULTILINE)
259 # Magic command names as headers:
259 # Magic command names as headers:
260 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
260 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
261 re.MULTILINE)
261 re.MULTILINE)
262 # Magic commands
262 # Magic commands
263 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
263 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
264 re.MULTILINE)
264 re.MULTILINE)
265 # Paragraph continue
265 # Paragraph continue
266 par_re = re.compile(r'\\$',re.MULTILINE)
266 par_re = re.compile(r'\\$',re.MULTILINE)
267
267
268 # The "\n" symbol
268 # The "\n" symbol
269 newline_re = re.compile(r'\\n')
269 newline_re = re.compile(r'\\n')
270
270
271 # Now build the string for output:
271 # Now build the string for output:
272 #strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng)
272 #strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng)
273 strng = cmd_name_re.sub(r'\n\\bigskip\n\\texttt{\\textbf{ \1}}:',
273 strng = cmd_name_re.sub(r'\n\\bigskip\n\\texttt{\\textbf{ \1}}:',
274 strng)
274 strng)
275 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
275 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
276 strng = par_re.sub(r'\\\\',strng)
276 strng = par_re.sub(r'\\\\',strng)
277 strng = escape_re.sub(r'\\\1',strng)
277 strng = escape_re.sub(r'\\\1',strng)
278 strng = newline_re.sub(r'\\textbackslash{}n',strng)
278 strng = newline_re.sub(r'\\textbackslash{}n',strng)
279 return strng
279 return strng
280
280
281 def format_screen(self,strng):
281 def format_screen(self,strng):
282 """Format a string for screen printing.
282 """Format a string for screen printing.
283
283
284 This removes some latex-type format codes."""
284 This removes some latex-type format codes."""
285 # Paragraph continue
285 # Paragraph continue
286 par_re = re.compile(r'\\$',re.MULTILINE)
286 par_re = re.compile(r'\\$',re.MULTILINE)
287 strng = par_re.sub('',strng)
287 strng = par_re.sub('',strng)
288 return strng
288 return strng
289
289
290 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
290 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
291 """Parse options passed to an argument string.
291 """Parse options passed to an argument string.
292
292
293 The interface is similar to that of getopt(), but it returns back a
293 The interface is similar to that of getopt(), but it returns back a
294 Struct with the options as keys and the stripped argument string still
294 Struct with the options as keys and the stripped argument string still
295 as a string.
295 as a string.
296
296
297 arg_str is quoted as a true sys.argv vector by using shlex.split.
297 arg_str is quoted as a true sys.argv vector by using shlex.split.
298 This allows us to easily expand variables, glob files, quote
298 This allows us to easily expand variables, glob files, quote
299 arguments, etc.
299 arguments, etc.
300
300
301 Options:
301 Options:
302 -mode: default 'string'. If given as 'list', the argument string is
302 -mode: default 'string'. If given as 'list', the argument string is
303 returned as a list (split on whitespace) instead of a string.
303 returned as a list (split on whitespace) instead of a string.
304
304
305 -list_all: put all option values in lists. Normally only options
305 -list_all: put all option values in lists. Normally only options
306 appearing more than once are put in a list.
306 appearing more than once are put in a list.
307
307
308 -posix (True): whether to split the input line in POSIX mode or not,
308 -posix (True): whether to split the input line in POSIX mode or not,
309 as per the conventions outlined in the shlex module from the
309 as per the conventions outlined in the shlex module from the
310 standard library."""
310 standard library."""
311
311
312 # inject default options at the beginning of the input line
312 # inject default options at the beginning of the input line
313 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
313 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
314 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
314 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
315
315
316 mode = kw.get('mode','string')
316 mode = kw.get('mode','string')
317 if mode not in ['string','list']:
317 if mode not in ['string','list']:
318 raise ValueError,'incorrect mode given: %s' % mode
318 raise ValueError,'incorrect mode given: %s' % mode
319 # Get options
319 # Get options
320 list_all = kw.get('list_all',0)
320 list_all = kw.get('list_all',0)
321 posix = kw.get('posix',True)
321 posix = kw.get('posix',True)
322
322
323 # Check if we have more than one argument to warrant extra processing:
323 # Check if we have more than one argument to warrant extra processing:
324 odict = {} # Dictionary with options
324 odict = {} # Dictionary with options
325 args = arg_str.split()
325 args = arg_str.split()
326 if len(args) >= 1:
326 if len(args) >= 1:
327 # If the list of inputs only has 0 or 1 thing in it, there's no
327 # If the list of inputs only has 0 or 1 thing in it, there's no
328 # need to look for options
328 # need to look for options
329 argv = arg_split(arg_str,posix)
329 argv = arg_split(arg_str,posix)
330 # Do regular option processing
330 # Do regular option processing
331 try:
331 try:
332 opts,args = getopt(argv,opt_str,*long_opts)
332 opts,args = getopt(argv,opt_str,*long_opts)
333 except GetoptError,e:
333 except GetoptError,e:
334 raise GetoptError('%s ( allowed: "%s" %s)' % (e.msg,opt_str,
334 raise GetoptError('%s ( allowed: "%s" %s)' % (e.msg,opt_str,
335 " ".join(long_opts)))
335 " ".join(long_opts)))
336 for o,a in opts:
336 for o,a in opts:
337 if o.startswith('--'):
337 if o.startswith('--'):
338 o = o[2:]
338 o = o[2:]
339 else:
339 else:
340 o = o[1:]
340 o = o[1:]
341 try:
341 try:
342 odict[o].append(a)
342 odict[o].append(a)
343 except AttributeError:
343 except AttributeError:
344 odict[o] = [odict[o],a]
344 odict[o] = [odict[o],a]
345 except KeyError:
345 except KeyError:
346 if list_all:
346 if list_all:
347 odict[o] = [a]
347 odict[o] = [a]
348 else:
348 else:
349 odict[o] = a
349 odict[o] = a
350
350
351 # Prepare opts,args for return
351 # Prepare opts,args for return
352 opts = Struct(odict)
352 opts = Struct(odict)
353 if mode == 'string':
353 if mode == 'string':
354 args = ' '.join(args)
354 args = ' '.join(args)
355
355
356 return opts,args
356 return opts,args
357
357
358 #......................................................................
358 #......................................................................
359 # And now the actual magic functions
359 # And now the actual magic functions
360
360
361 # Functions for IPython shell work (vars,funcs, config, etc)
361 # Functions for IPython shell work (vars,funcs, config, etc)
362 def magic_lsmagic(self, parameter_s = ''):
362 def magic_lsmagic(self, parameter_s = ''):
363 """List currently available magic functions."""
363 """List currently available magic functions."""
364 mesc = self.shell.ESC_MAGIC
364 mesc = self.shell.ESC_MAGIC
365 print 'Available magic functions:\n'+mesc+\
365 print 'Available magic functions:\n'+mesc+\
366 (' '+mesc).join(self.lsmagic())
366 (' '+mesc).join(self.lsmagic())
367 print '\n' + Magic.auto_status[self.shell.rc.automagic]
367 print '\n' + Magic.auto_status[self.shell.rc.automagic]
368 return None
368 return None
369
369
370 def magic_magic(self, parameter_s = ''):
370 def magic_magic(self, parameter_s = ''):
371 """Print information about the magic function system."""
371 """Print information about the magic function system."""
372
372
373 mode = ''
373 mode = ''
374 try:
374 try:
375 if parameter_s.split()[0] == '-latex':
375 if parameter_s.split()[0] == '-latex':
376 mode = 'latex'
376 mode = 'latex'
377 if parameter_s.split()[0] == '-brief':
377 if parameter_s.split()[0] == '-brief':
378 mode = 'brief'
378 mode = 'brief'
379 except:
379 except:
380 pass
380 pass
381
381
382 magic_docs = []
382 magic_docs = []
383 for fname in self.lsmagic():
383 for fname in self.lsmagic():
384 mname = 'magic_' + fname
384 mname = 'magic_' + fname
385 for space in (Magic,self,self.__class__):
385 for space in (Magic,self,self.__class__):
386 try:
386 try:
387 fn = space.__dict__[mname]
387 fn = space.__dict__[mname]
388 except KeyError:
388 except KeyError:
389 pass
389 pass
390 else:
390 else:
391 break
391 break
392 if mode == 'brief':
392 if mode == 'brief':
393 # only first line
393 # only first line
394 fndoc = fn.__doc__.split('\n',1)[0]
394 fndoc = fn.__doc__.split('\n',1)[0]
395 else:
395 else:
396 fndoc = fn.__doc__
396 fndoc = fn.__doc__
397
397
398 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
398 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
399 fname,fndoc))
399 fname,fndoc))
400 magic_docs = ''.join(magic_docs)
400 magic_docs = ''.join(magic_docs)
401
401
402 if mode == 'latex':
402 if mode == 'latex':
403 print self.format_latex(magic_docs)
403 print self.format_latex(magic_docs)
404 return
404 return
405 else:
405 else:
406 magic_docs = self.format_screen(magic_docs)
406 magic_docs = self.format_screen(magic_docs)
407 if mode == 'brief':
407 if mode == 'brief':
408 return magic_docs
408 return magic_docs
409
409
410 outmsg = """
410 outmsg = """
411 IPython's 'magic' functions
411 IPython's 'magic' functions
412 ===========================
412 ===========================
413
413
414 The magic function system provides a series of functions which allow you to
414 The magic function system provides a series of functions which allow you to
415 control the behavior of IPython itself, plus a lot of system-type
415 control the behavior of IPython itself, plus a lot of system-type
416 features. All these functions are prefixed with a % character, but parameters
416 features. All these functions are prefixed with a % character, but parameters
417 are given without parentheses or quotes.
417 are given without parentheses or quotes.
418
418
419 NOTE: If you have 'automagic' enabled (via the command line option or with the
419 NOTE: If you have 'automagic' enabled (via the command line option or with the
420 %automagic function), you don't need to type in the % explicitly. By default,
420 %automagic function), you don't need to type in the % explicitly. By default,
421 IPython ships with automagic on, so you should only rarely need the % escape.
421 IPython ships with automagic on, so you should only rarely need the % escape.
422
422
423 Example: typing '%cd mydir' (without the quotes) changes you working directory
423 Example: typing '%cd mydir' (without the quotes) changes you working directory
424 to 'mydir', if it exists.
424 to 'mydir', if it exists.
425
425
426 You can define your own magic functions to extend the system. See the supplied
426 You can define your own magic functions to extend the system. See the supplied
427 ipythonrc and example-magic.py files for details (in your ipython
427 ipythonrc and example-magic.py files for details (in your ipython
428 configuration directory, typically $HOME/.ipython/).
428 configuration directory, typically $HOME/.ipython/).
429
429
430 You can also define your own aliased names for magic functions. In your
430 You can also define your own aliased names for magic functions. In your
431 ipythonrc file, placing a line like:
431 ipythonrc file, placing a line like:
432
432
433 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
433 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
434
434
435 will define %pf as a new name for %profile.
435 will define %pf as a new name for %profile.
436
436
437 You can also call magics in code using the ipmagic() function, which IPython
437 You can also call magics in code using the ipmagic() function, which IPython
438 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
438 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
439
439
440 For a list of the available magic functions, use %lsmagic. For a description
440 For a list of the available magic functions, use %lsmagic. For a description
441 of any of them, type %magic_name?, e.g. '%cd?'.
441 of any of them, type %magic_name?, e.g. '%cd?'.
442
442
443 Currently the magic system has the following functions:\n"""
443 Currently the magic system has the following functions:\n"""
444
444
445 mesc = self.shell.ESC_MAGIC
445 mesc = self.shell.ESC_MAGIC
446 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
446 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
447 "\n\n%s%s\n\n%s" % (outmsg,
447 "\n\n%s%s\n\n%s" % (outmsg,
448 magic_docs,mesc,mesc,
448 magic_docs,mesc,mesc,
449 (' '+mesc).join(self.lsmagic()),
449 (' '+mesc).join(self.lsmagic()),
450 Magic.auto_status[self.shell.rc.automagic] ) )
450 Magic.auto_status[self.shell.rc.automagic] ) )
451
451
452 page(outmsg,screen_lines=self.shell.rc.screen_length)
452 page(outmsg,screen_lines=self.shell.rc.screen_length)
453
453
454 def magic_automagic(self, parameter_s = ''):
454 def magic_automagic(self, parameter_s = ''):
455 """Make magic functions callable without having to type the initial %.
455 """Make magic functions callable without having to type the initial %.
456
456
457 Toggles on/off (when off, you must call it as %automagic, of
457 Toggles on/off (when off, you must call it as %automagic, of
458 course). Note that magic functions have lowest priority, so if there's
458 course). Note that magic functions have lowest priority, so if there's
459 a variable whose name collides with that of a magic fn, automagic
459 a variable whose name collides with that of a magic fn, automagic
460 won't work for that function (you get the variable instead). However,
460 won't work for that function (you get the variable instead). However,
461 if you delete the variable (del var), the previously shadowed magic
461 if you delete the variable (del var), the previously shadowed magic
462 function becomes visible to automagic again."""
462 function becomes visible to automagic again."""
463
463
464 rc = self.shell.rc
464 rc = self.shell.rc
465 rc.automagic = not rc.automagic
465 rc.automagic = not rc.automagic
466 print '\n' + Magic.auto_status[rc.automagic]
466 print '\n' + Magic.auto_status[rc.automagic]
467
467
468 def magic_autocall(self, parameter_s = ''):
468 def magic_autocall(self, parameter_s = ''):
469 """Make functions callable without having to type parentheses.
469 """Make functions callable without having to type parentheses.
470
470
471 Usage:
471 Usage:
472
472
473 %autocall [mode]
473 %autocall [mode]
474
474
475 The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the
475 The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the
476 value is toggled on and off (remembering the previous state)."""
476 value is toggled on and off (remembering the previous state)."""
477
477
478 rc = self.shell.rc
478 rc = self.shell.rc
479
479
480 if parameter_s:
480 if parameter_s:
481 arg = int(parameter_s)
481 arg = int(parameter_s)
482 else:
482 else:
483 arg = 'toggle'
483 arg = 'toggle'
484
484
485 if not arg in (0,1,2,'toggle'):
485 if not arg in (0,1,2,'toggle'):
486 error('Valid modes: (0->Off, 1->Smart, 2->Full')
486 error('Valid modes: (0->Off, 1->Smart, 2->Full')
487 return
487 return
488
488
489 if arg in (0,1,2):
489 if arg in (0,1,2):
490 rc.autocall = arg
490 rc.autocall = arg
491 else: # toggle
491 else: # toggle
492 if rc.autocall:
492 if rc.autocall:
493 self._magic_state.autocall_save = rc.autocall
493 self._magic_state.autocall_save = rc.autocall
494 rc.autocall = 0
494 rc.autocall = 0
495 else:
495 else:
496 try:
496 try:
497 rc.autocall = self._magic_state.autocall_save
497 rc.autocall = self._magic_state.autocall_save
498 except AttributeError:
498 except AttributeError:
499 rc.autocall = self._magic_state.autocall_save = 1
499 rc.autocall = self._magic_state.autocall_save = 1
500
500
501 print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall]
501 print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall]
502
502
503 def magic_autoindent(self, parameter_s = ''):
503 def magic_autoindent(self, parameter_s = ''):
504 """Toggle autoindent on/off (if available)."""
504 """Toggle autoindent on/off (if available)."""
505
505
506 self.shell.set_autoindent()
506 self.shell.set_autoindent()
507 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
507 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
508
508
509 def magic_system_verbose(self, parameter_s = ''):
509 def magic_system_verbose(self, parameter_s = ''):
510 """Set verbose printing of system calls.
510 """Set verbose printing of system calls.
511
511
512 If called without an argument, act as a toggle"""
512 If called without an argument, act as a toggle"""
513
513
514 if parameter_s:
514 if parameter_s:
515 val = bool(eval(parameter_s))
515 val = bool(eval(parameter_s))
516 else:
516 else:
517 val = None
517 val = None
518
518
519 self.shell.rc_set_toggle('system_verbose',val)
519 self.shell.rc_set_toggle('system_verbose',val)
520 print "System verbose printing is:",\
520 print "System verbose printing is:",\
521 ['OFF','ON'][self.shell.rc.system_verbose]
521 ['OFF','ON'][self.shell.rc.system_verbose]
522
522
523 def magic_history(self, parameter_s = ''):
523 def magic_history(self, parameter_s = ''):
524 """Print input history (_i<n> variables), with most recent last.
524 """Print input history (_i<n> variables), with most recent last.
525
525
526 %history -> print at most 40 inputs (some may be multi-line)\\
526 %history -> print at most 40 inputs (some may be multi-line)\\
527 %history n -> print at most n inputs\\
527 %history n -> print at most n inputs\\
528 %history n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
528 %history n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
529
529
530 Each input's number <n> is shown, and is accessible as the
530 Each input's number <n> is shown, and is accessible as the
531 automatically generated variable _i<n>. Multi-line statements are
531 automatically generated variable _i<n>. Multi-line statements are
532 printed starting at a new line for easy copy/paste.
532 printed starting at a new line for easy copy/paste.
533
533
534
534
535 Options:
535 Options:
536
536
537 -n: do NOT print line numbers. This is useful if you want to get a
537 -n: do NOT print line numbers. This is useful if you want to get a
538 printout of many lines which can be directly pasted into a text
538 printout of many lines which can be directly pasted into a text
539 editor.
539 editor.
540
540
541 This feature is only available if numbered prompts are in use.
541 This feature is only available if numbered prompts are in use.
542
542
543 -r: print the 'raw' history. IPython filters your input and
543 -r: print the 'raw' history. IPython filters your input and
544 converts it all into valid Python source before executing it (things
544 converts it all into valid Python source before executing it (things
545 like magics or aliases are turned into function calls, for
545 like magics or aliases are turned into function calls, for
546 example). With this option, you'll see the unfiltered history
546 example). With this option, you'll see the unfiltered history
547 instead of the filtered version: '%cd /' will be seen as '%cd /'
547 instead of the filtered version: '%cd /' will be seen as '%cd /'
548 instead of '_ip.magic("%cd /")'.
548 instead of '_ip.magic("%cd /")'.
549 """
549 """
550
550
551 shell = self.shell
551 shell = self.shell
552 if not shell.outputcache.do_full_cache:
552 if not shell.outputcache.do_full_cache:
553 print 'This feature is only available if numbered prompts are in use.'
553 print 'This feature is only available if numbered prompts are in use.'
554 return
554 return
555 opts,args = self.parse_options(parameter_s,'nr',mode='list')
555 opts,args = self.parse_options(parameter_s,'nr',mode='list')
556
556
557 if opts.has_key('r'):
557 if opts.has_key('r'):
558 input_hist = shell.input_hist_raw
558 input_hist = shell.input_hist_raw
559 else:
559 else:
560 input_hist = shell.input_hist
560 input_hist = shell.input_hist
561
561
562 default_length = 40
562 default_length = 40
563 if len(args) == 0:
563 if len(args) == 0:
564 final = len(input_hist)
564 final = len(input_hist)
565 init = max(1,final-default_length)
565 init = max(1,final-default_length)
566 elif len(args) == 1:
566 elif len(args) == 1:
567 final = len(input_hist)
567 final = len(input_hist)
568 init = max(1,final-int(args[0]))
568 init = max(1,final-int(args[0]))
569 elif len(args) == 2:
569 elif len(args) == 2:
570 init,final = map(int,args)
570 init,final = map(int,args)
571 else:
571 else:
572 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
572 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
573 print self.magic_hist.__doc__
573 print self.magic_hist.__doc__
574 return
574 return
575 width = len(str(final))
575 width = len(str(final))
576 line_sep = ['','\n']
576 line_sep = ['','\n']
577 print_nums = not opts.has_key('n')
577 print_nums = not opts.has_key('n')
578 for in_num in range(init,final):
578 for in_num in range(init,final):
579 inline = input_hist[in_num]
579 inline = input_hist[in_num]
580 multiline = int(inline.count('\n') > 1)
580 multiline = int(inline.count('\n') > 1)
581 if print_nums:
581 if print_nums:
582 print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]),
582 print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]),
583 print inline,
583 print inline,
584
584
585 def magic_hist(self, parameter_s=''):
585 def magic_hist(self, parameter_s=''):
586 """Alternate name for %history."""
586 """Alternate name for %history."""
587 return self.magic_history(parameter_s)
587 return self.magic_history(parameter_s)
588
588
589 def magic_p(self, parameter_s=''):
589 def magic_p(self, parameter_s=''):
590 """Just a short alias for Python's 'print'."""
590 """Just a short alias for Python's 'print'."""
591 exec 'print ' + parameter_s in self.shell.user_ns
591 exec 'print ' + parameter_s in self.shell.user_ns
592
592
593 def magic_r(self, parameter_s=''):
593 def magic_r(self, parameter_s=''):
594 """Repeat previous input.
594 """Repeat previous input.
595
595
596 If given an argument, repeats the previous command which starts with
596 If given an argument, repeats the previous command which starts with
597 the same string, otherwise it just repeats the previous input.
597 the same string, otherwise it just repeats the previous input.
598
598
599 Shell escaped commands (with ! as first character) are not recognized
599 Shell escaped commands (with ! as first character) are not recognized
600 by this system, only pure python code and magic commands.
600 by this system, only pure python code and magic commands.
601 """
601 """
602
602
603 start = parameter_s.strip()
603 start = parameter_s.strip()
604 esc_magic = self.shell.ESC_MAGIC
604 esc_magic = self.shell.ESC_MAGIC
605 # Identify magic commands even if automagic is on (which means
605 # Identify magic commands even if automagic is on (which means
606 # the in-memory version is different from that typed by the user).
606 # the in-memory version is different from that typed by the user).
607 if self.shell.rc.automagic:
607 if self.shell.rc.automagic:
608 start_magic = esc_magic+start
608 start_magic = esc_magic+start
609 else:
609 else:
610 start_magic = start
610 start_magic = start
611 # Look through the input history in reverse
611 # Look through the input history in reverse
612 for n in range(len(self.shell.input_hist)-2,0,-1):
612 for n in range(len(self.shell.input_hist)-2,0,-1):
613 input = self.shell.input_hist[n]
613 input = self.shell.input_hist[n]
614 # skip plain 'r' lines so we don't recurse to infinity
614 # skip plain 'r' lines so we don't recurse to infinity
615 if input != '_ip.magic("r")\n' and \
615 if input != '_ip.magic("r")\n' and \
616 (input.startswith(start) or input.startswith(start_magic)):
616 (input.startswith(start) or input.startswith(start_magic)):
617 #print 'match',`input` # dbg
617 #print 'match',`input` # dbg
618 print 'Executing:',input,
618 print 'Executing:',input,
619 self.shell.runlines(input)
619 self.shell.runlines(input)
620 return
620 return
621 print 'No previous input matching `%s` found.' % start
621 print 'No previous input matching `%s` found.' % start
622
622
623 def magic_page(self, parameter_s=''):
623 def magic_page(self, parameter_s=''):
624 """Pretty print the object and display it through a pager.
624 """Pretty print the object and display it through a pager.
625
625
626 %page [options] OBJECT
626 %page [options] OBJECT
627
627
628 If no object is given, use _ (last output).
628 If no object is given, use _ (last output).
629
629
630 Options:
630 Options:
631
631
632 -r: page str(object), don't pretty-print it."""
632 -r: page str(object), don't pretty-print it."""
633
633
634 # After a function contributed by Olivier Aubert, slightly modified.
634 # After a function contributed by Olivier Aubert, slightly modified.
635
635
636 # Process options/args
636 # Process options/args
637 opts,args = self.parse_options(parameter_s,'r')
637 opts,args = self.parse_options(parameter_s,'r')
638 raw = 'r' in opts
638 raw = 'r' in opts
639
639
640 oname = args and args or '_'
640 oname = args and args or '_'
641 info = self._ofind(oname)
641 info = self._ofind(oname)
642 if info['found']:
642 if info['found']:
643 txt = (raw and str or pformat)( info['obj'] )
643 txt = (raw and str or pformat)( info['obj'] )
644 page(txt)
644 page(txt)
645 else:
645 else:
646 print 'Object `%s` not found' % oname
646 print 'Object `%s` not found' % oname
647
647
648 def magic_profile(self, parameter_s=''):
648 def magic_profile(self, parameter_s=''):
649 """Print your currently active IPyhton profile."""
649 """Print your currently active IPyhton profile."""
650 if self.shell.rc.profile:
650 if self.shell.rc.profile:
651 printpl('Current IPython profile: $self.shell.rc.profile.')
651 printpl('Current IPython profile: $self.shell.rc.profile.')
652 else:
652 else:
653 print 'No profile active.'
653 print 'No profile active.'
654
654
655 def _inspect(self,meth,oname,namespaces=None,**kw):
655 def _inspect(self,meth,oname,namespaces=None,**kw):
656 """Generic interface to the inspector system.
656 """Generic interface to the inspector system.
657
657
658 This function is meant to be called by pdef, pdoc & friends."""
658 This function is meant to be called by pdef, pdoc & friends."""
659
659
660 oname = oname.strip()
660 oname = oname.strip()
661 info = Struct(self._ofind(oname, namespaces))
661 info = Struct(self._ofind(oname, namespaces))
662
662
663 if info.found:
663 if info.found:
664 # Get the docstring of the class property if it exists.
664 # Get the docstring of the class property if it exists.
665 path = oname.split('.')
665 path = oname.split('.')
666 root = '.'.join(path[:-1])
666 root = '.'.join(path[:-1])
667 if info.parent is not None:
667 if info.parent is not None:
668 try:
668 try:
669 target = getattr(info.parent, '__class__')
669 target = getattr(info.parent, '__class__')
670 # The object belongs to a class instance.
670 # The object belongs to a class instance.
671 try:
671 try:
672 target = getattr(target, path[-1])
672 target = getattr(target, path[-1])
673 # The class defines the object.
673 # The class defines the object.
674 if isinstance(target, property):
674 if isinstance(target, property):
675 oname = root + '.__class__.' + path[-1]
675 oname = root + '.__class__.' + path[-1]
676 info = Struct(self._ofind(oname))
676 info = Struct(self._ofind(oname))
677 except AttributeError: pass
677 except AttributeError: pass
678 except AttributeError: pass
678 except AttributeError: pass
679
679
680 pmethod = getattr(self.shell.inspector,meth)
680 pmethod = getattr(self.shell.inspector,meth)
681 formatter = info.ismagic and self.format_screen or None
681 formatter = info.ismagic and self.format_screen or None
682 if meth == 'pdoc':
682 if meth == 'pdoc':
683 pmethod(info.obj,oname,formatter)
683 pmethod(info.obj,oname,formatter)
684 elif meth == 'pinfo':
684 elif meth == 'pinfo':
685 pmethod(info.obj,oname,formatter,info,**kw)
685 pmethod(info.obj,oname,formatter,info,**kw)
686 else:
686 else:
687 pmethod(info.obj,oname)
687 pmethod(info.obj,oname)
688 else:
688 else:
689 print 'Object `%s` not found.' % oname
689 print 'Object `%s` not found.' % oname
690 return 'not found' # so callers can take other action
690 return 'not found' # so callers can take other action
691
691
692 def magic_pdef(self, parameter_s='', namespaces=None):
692 def magic_pdef(self, parameter_s='', namespaces=None):
693 """Print the definition header for any callable object.
693 """Print the definition header for any callable object.
694
694
695 If the object is a class, print the constructor information."""
695 If the object is a class, print the constructor information."""
696 print "+++"
697 self._inspect('pdef',parameter_s, namespaces)
696 self._inspect('pdef',parameter_s, namespaces)
698
697
699 def magic_pdoc(self, parameter_s='', namespaces=None):
698 def magic_pdoc(self, parameter_s='', namespaces=None):
700 """Print the docstring for an object.
699 """Print the docstring for an object.
701
700
702 If the given object is a class, it will print both the class and the
701 If the given object is a class, it will print both the class and the
703 constructor docstrings."""
702 constructor docstrings."""
704 self._inspect('pdoc',parameter_s, namespaces)
703 self._inspect('pdoc',parameter_s, namespaces)
705
704
706 def magic_psource(self, parameter_s='', namespaces=None):
705 def magic_psource(self, parameter_s='', namespaces=None):
707 """Print (or run through pager) the source code for an object."""
706 """Print (or run through pager) the source code for an object."""
708 self._inspect('psource',parameter_s, namespaces)
707 self._inspect('psource',parameter_s, namespaces)
709
708
710 def magic_pfile(self, parameter_s=''):
709 def magic_pfile(self, parameter_s=''):
711 """Print (or run through pager) the file where an object is defined.
710 """Print (or run through pager) the file where an object is defined.
712
711
713 The file opens at the line where the object definition begins. IPython
712 The file opens at the line where the object definition begins. IPython
714 will honor the environment variable PAGER if set, and otherwise will
713 will honor the environment variable PAGER if set, and otherwise will
715 do its best to print the file in a convenient form.
714 do its best to print the file in a convenient form.
716
715
717 If the given argument is not an object currently defined, IPython will
716 If the given argument is not an object currently defined, IPython will
718 try to interpret it as a filename (automatically adding a .py extension
717 try to interpret it as a filename (automatically adding a .py extension
719 if needed). You can thus use %pfile as a syntax highlighting code
718 if needed). You can thus use %pfile as a syntax highlighting code
720 viewer."""
719 viewer."""
721
720
722 # first interpret argument as an object name
721 # first interpret argument as an object name
723 out = self._inspect('pfile',parameter_s)
722 out = self._inspect('pfile',parameter_s)
724 # if not, try the input as a filename
723 # if not, try the input as a filename
725 if out == 'not found':
724 if out == 'not found':
726 try:
725 try:
727 filename = get_py_filename(parameter_s)
726 filename = get_py_filename(parameter_s)
728 except IOError,msg:
727 except IOError,msg:
729 print msg
728 print msg
730 return
729 return
731 page(self.shell.inspector.format(file(filename).read()))
730 page(self.shell.inspector.format(file(filename).read()))
732
731
733 def magic_pinfo(self, parameter_s='', namespaces=None):
732 def magic_pinfo(self, parameter_s='', namespaces=None):
734 """Provide detailed information about an object.
733 """Provide detailed information about an object.
735
734
736 '%pinfo object' is just a synonym for object? or ?object."""
735 '%pinfo object' is just a synonym for object? or ?object."""
737
736
738 #print 'pinfo par: <%s>' % parameter_s # dbg
737 #print 'pinfo par: <%s>' % parameter_s # dbg
739
738
740 # detail_level: 0 -> obj? , 1 -> obj??
739 # detail_level: 0 -> obj? , 1 -> obj??
741 detail_level = 0
740 detail_level = 0
742 # We need to detect if we got called as 'pinfo pinfo foo', which can
741 # We need to detect if we got called as 'pinfo pinfo foo', which can
743 # happen if the user types 'pinfo foo?' at the cmd line.
742 # happen if the user types 'pinfo foo?' at the cmd line.
744 pinfo,qmark1,oname,qmark2 = \
743 pinfo,qmark1,oname,qmark2 = \
745 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
744 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
746 if pinfo or qmark1 or qmark2:
745 if pinfo or qmark1 or qmark2:
747 detail_level = 1
746 detail_level = 1
748 if "*" in oname:
747 if "*" in oname:
749 self.magic_psearch(oname)
748 self.magic_psearch(oname)
750 else:
749 else:
751 self._inspect('pinfo', oname, detail_level=detail_level,
750 self._inspect('pinfo', oname, detail_level=detail_level,
752 namespaces=namespaces)
751 namespaces=namespaces)
753
752
754 def magic_psearch(self, parameter_s=''):
753 def magic_psearch(self, parameter_s=''):
755 """Search for object in namespaces by wildcard.
754 """Search for object in namespaces by wildcard.
756
755
757 %psearch [options] PATTERN [OBJECT TYPE]
756 %psearch [options] PATTERN [OBJECT TYPE]
758
757
759 Note: ? can be used as a synonym for %psearch, at the beginning or at
758 Note: ? can be used as a synonym for %psearch, at the beginning or at
760 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
759 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
761 rest of the command line must be unchanged (options come first), so
760 rest of the command line must be unchanged (options come first), so
762 for example the following forms are equivalent
761 for example the following forms are equivalent
763
762
764 %psearch -i a* function
763 %psearch -i a* function
765 -i a* function?
764 -i a* function?
766 ?-i a* function
765 ?-i a* function
767
766
768 Arguments:
767 Arguments:
769
768
770 PATTERN
769 PATTERN
771
770
772 where PATTERN is a string containing * as a wildcard similar to its
771 where PATTERN is a string containing * as a wildcard similar to its
773 use in a shell. The pattern is matched in all namespaces on the
772 use in a shell. The pattern is matched in all namespaces on the
774 search path. By default objects starting with a single _ are not
773 search path. By default objects starting with a single _ are not
775 matched, many IPython generated objects have a single
774 matched, many IPython generated objects have a single
776 underscore. The default is case insensitive matching. Matching is
775 underscore. The default is case insensitive matching. Matching is
777 also done on the attributes of objects and not only on the objects
776 also done on the attributes of objects and not only on the objects
778 in a module.
777 in a module.
779
778
780 [OBJECT TYPE]
779 [OBJECT TYPE]
781
780
782 Is the name of a python type from the types module. The name is
781 Is the name of a python type from the types module. The name is
783 given in lowercase without the ending type, ex. StringType is
782 given in lowercase without the ending type, ex. StringType is
784 written string. By adding a type here only objects matching the
783 written string. By adding a type here only objects matching the
785 given type are matched. Using all here makes the pattern match all
784 given type are matched. Using all here makes the pattern match all
786 types (this is the default).
785 types (this is the default).
787
786
788 Options:
787 Options:
789
788
790 -a: makes the pattern match even objects whose names start with a
789 -a: makes the pattern match even objects whose names start with a
791 single underscore. These names are normally ommitted from the
790 single underscore. These names are normally ommitted from the
792 search.
791 search.
793
792
794 -i/-c: make the pattern case insensitive/sensitive. If neither of
793 -i/-c: make the pattern case insensitive/sensitive. If neither of
795 these options is given, the default is read from your ipythonrc
794 these options is given, the default is read from your ipythonrc
796 file. The option name which sets this value is
795 file. The option name which sets this value is
797 'wildcards_case_sensitive'. If this option is not specified in your
796 'wildcards_case_sensitive'. If this option is not specified in your
798 ipythonrc file, IPython's internal default is to do a case sensitive
797 ipythonrc file, IPython's internal default is to do a case sensitive
799 search.
798 search.
800
799
801 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
800 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
802 specifiy can be searched in any of the following namespaces:
801 specifiy can be searched in any of the following namespaces:
803 'builtin', 'user', 'user_global','internal', 'alias', where
802 'builtin', 'user', 'user_global','internal', 'alias', where
804 'builtin' and 'user' are the search defaults. Note that you should
803 'builtin' and 'user' are the search defaults. Note that you should
805 not use quotes when specifying namespaces.
804 not use quotes when specifying namespaces.
806
805
807 'Builtin' contains the python module builtin, 'user' contains all
806 'Builtin' contains the python module builtin, 'user' contains all
808 user data, 'alias' only contain the shell aliases and no python
807 user data, 'alias' only contain the shell aliases and no python
809 objects, 'internal' contains objects used by IPython. The
808 objects, 'internal' contains objects used by IPython. The
810 'user_global' namespace is only used by embedded IPython instances,
809 'user_global' namespace is only used by embedded IPython instances,
811 and it contains module-level globals. You can add namespaces to the
810 and it contains module-level globals. You can add namespaces to the
812 search with -s or exclude them with -e (these options can be given
811 search with -s or exclude them with -e (these options can be given
813 more than once).
812 more than once).
814
813
815 Examples:
814 Examples:
816
815
817 %psearch a* -> objects beginning with an a
816 %psearch a* -> objects beginning with an a
818 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
817 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
819 %psearch a* function -> all functions beginning with an a
818 %psearch a* function -> all functions beginning with an a
820 %psearch re.e* -> objects beginning with an e in module re
819 %psearch re.e* -> objects beginning with an e in module re
821 %psearch r*.e* -> objects that start with e in modules starting in r
820 %psearch r*.e* -> objects that start with e in modules starting in r
822 %psearch r*.* string -> all strings in modules beginning with r
821 %psearch r*.* string -> all strings in modules beginning with r
823
822
824 Case sensitve search:
823 Case sensitve search:
825
824
826 %psearch -c a* list all object beginning with lower case a
825 %psearch -c a* list all object beginning with lower case a
827
826
828 Show objects beginning with a single _:
827 Show objects beginning with a single _:
829
828
830 %psearch -a _* list objects beginning with a single underscore"""
829 %psearch -a _* list objects beginning with a single underscore"""
831
830
832 # default namespaces to be searched
831 # default namespaces to be searched
833 def_search = ['user','builtin']
832 def_search = ['user','builtin']
834
833
835 # Process options/args
834 # Process options/args
836 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
835 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
837 opt = opts.get
836 opt = opts.get
838 shell = self.shell
837 shell = self.shell
839 psearch = shell.inspector.psearch
838 psearch = shell.inspector.psearch
840
839
841 # select case options
840 # select case options
842 if opts.has_key('i'):
841 if opts.has_key('i'):
843 ignore_case = True
842 ignore_case = True
844 elif opts.has_key('c'):
843 elif opts.has_key('c'):
845 ignore_case = False
844 ignore_case = False
846 else:
845 else:
847 ignore_case = not shell.rc.wildcards_case_sensitive
846 ignore_case = not shell.rc.wildcards_case_sensitive
848
847
849 # Build list of namespaces to search from user options
848 # Build list of namespaces to search from user options
850 def_search.extend(opt('s',[]))
849 def_search.extend(opt('s',[]))
851 ns_exclude = ns_exclude=opt('e',[])
850 ns_exclude = ns_exclude=opt('e',[])
852 ns_search = [nm for nm in def_search if nm not in ns_exclude]
851 ns_search = [nm for nm in def_search if nm not in ns_exclude]
853
852
854 # Call the actual search
853 # Call the actual search
855 try:
854 try:
856 psearch(args,shell.ns_table,ns_search,
855 psearch(args,shell.ns_table,ns_search,
857 show_all=opt('a'),ignore_case=ignore_case)
856 show_all=opt('a'),ignore_case=ignore_case)
858 except:
857 except:
859 shell.showtraceback()
858 shell.showtraceback()
860
859
861 def magic_who_ls(self, parameter_s=''):
860 def magic_who_ls(self, parameter_s=''):
862 """Return a sorted list of all interactive variables.
861 """Return a sorted list of all interactive variables.
863
862
864 If arguments are given, only variables of types matching these
863 If arguments are given, only variables of types matching these
865 arguments are returned."""
864 arguments are returned."""
866
865
867 user_ns = self.shell.user_ns
866 user_ns = self.shell.user_ns
868 internal_ns = self.shell.internal_ns
867 internal_ns = self.shell.internal_ns
869 user_config_ns = self.shell.user_config_ns
868 user_config_ns = self.shell.user_config_ns
870 out = []
869 out = []
871 typelist = parameter_s.split()
870 typelist = parameter_s.split()
872
871
873 for i in user_ns:
872 for i in user_ns:
874 if not (i.startswith('_') or i.startswith('_i')) \
873 if not (i.startswith('_') or i.startswith('_i')) \
875 and not (i in internal_ns or i in user_config_ns):
874 and not (i in internal_ns or i in user_config_ns):
876 if typelist:
875 if typelist:
877 if type(user_ns[i]).__name__ in typelist:
876 if type(user_ns[i]).__name__ in typelist:
878 out.append(i)
877 out.append(i)
879 else:
878 else:
880 out.append(i)
879 out.append(i)
881 out.sort()
880 out.sort()
882 return out
881 return out
883
882
884 def magic_who(self, parameter_s=''):
883 def magic_who(self, parameter_s=''):
885 """Print all interactive variables, with some minimal formatting.
884 """Print all interactive variables, with some minimal formatting.
886
885
887 If any arguments are given, only variables whose type matches one of
886 If any arguments are given, only variables whose type matches one of
888 these are printed. For example:
887 these are printed. For example:
889
888
890 %who function str
889 %who function str
891
890
892 will only list functions and strings, excluding all other types of
891 will only list functions and strings, excluding all other types of
893 variables. To find the proper type names, simply use type(var) at a
892 variables. To find the proper type names, simply use type(var) at a
894 command line to see how python prints type names. For example:
893 command line to see how python prints type names. For example:
895
894
896 In [1]: type('hello')\\
895 In [1]: type('hello')\\
897 Out[1]: <type 'str'>
896 Out[1]: <type 'str'>
898
897
899 indicates that the type name for strings is 'str'.
898 indicates that the type name for strings is 'str'.
900
899
901 %who always excludes executed names loaded through your configuration
900 %who always excludes executed names loaded through your configuration
902 file and things which are internal to IPython.
901 file and things which are internal to IPython.
903
902
904 This is deliberate, as typically you may load many modules and the
903 This is deliberate, as typically you may load many modules and the
905 purpose of %who is to show you only what you've manually defined."""
904 purpose of %who is to show you only what you've manually defined."""
906
905
907 varlist = self.magic_who_ls(parameter_s)
906 varlist = self.magic_who_ls(parameter_s)
908 if not varlist:
907 if not varlist:
909 print 'Interactive namespace is empty.'
908 print 'Interactive namespace is empty.'
910 return
909 return
911
910
912 # if we have variables, move on...
911 # if we have variables, move on...
913
912
914 # stupid flushing problem: when prompts have no separators, stdout is
913 # stupid flushing problem: when prompts have no separators, stdout is
915 # getting lost. I'm starting to think this is a python bug. I'm having
914 # getting lost. I'm starting to think this is a python bug. I'm having
916 # to force a flush with a print because even a sys.stdout.flush
915 # to force a flush with a print because even a sys.stdout.flush
917 # doesn't seem to do anything!
916 # doesn't seem to do anything!
918
917
919 count = 0
918 count = 0
920 for i in varlist:
919 for i in varlist:
921 print i+'\t',
920 print i+'\t',
922 count += 1
921 count += 1
923 if count > 8:
922 if count > 8:
924 count = 0
923 count = 0
925 print
924 print
926 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
925 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
927
926
928 print # well, this does force a flush at the expense of an extra \n
927 print # well, this does force a flush at the expense of an extra \n
929
928
930 def magic_whos(self, parameter_s=''):
929 def magic_whos(self, parameter_s=''):
931 """Like %who, but gives some extra information about each variable.
930 """Like %who, but gives some extra information about each variable.
932
931
933 The same type filtering of %who can be applied here.
932 The same type filtering of %who can be applied here.
934
933
935 For all variables, the type is printed. Additionally it prints:
934 For all variables, the type is printed. Additionally it prints:
936
935
937 - For {},[],(): their length.
936 - For {},[],(): their length.
938
937
939 - For Numeric arrays, a summary with shape, number of elements,
938 - For Numeric arrays, a summary with shape, number of elements,
940 typecode and size in memory.
939 typecode and size in memory.
941
940
942 - Everything else: a string representation, snipping their middle if
941 - Everything else: a string representation, snipping their middle if
943 too long."""
942 too long."""
944
943
945 varnames = self.magic_who_ls(parameter_s)
944 varnames = self.magic_who_ls(parameter_s)
946 if not varnames:
945 if not varnames:
947 print 'Interactive namespace is empty.'
946 print 'Interactive namespace is empty.'
948 return
947 return
949
948
950 # if we have variables, move on...
949 # if we have variables, move on...
951
950
952 # for these types, show len() instead of data:
951 # for these types, show len() instead of data:
953 seq_types = [types.DictType,types.ListType,types.TupleType]
952 seq_types = [types.DictType,types.ListType,types.TupleType]
954
953
955 # for Numeric arrays, display summary info
954 # for Numeric arrays, display summary info
956 try:
955 try:
957 import Numeric
956 import Numeric
958 except ImportError:
957 except ImportError:
959 array_type = None
958 array_type = None
960 else:
959 else:
961 array_type = Numeric.ArrayType.__name__
960 array_type = Numeric.ArrayType.__name__
962
961
963 # Find all variable names and types so we can figure out column sizes
962 # Find all variable names and types so we can figure out column sizes
964
963
965 def get_vars(i):
964 def get_vars(i):
966 return self.shell.user_ns[i]
965 return self.shell.user_ns[i]
967
966
968 # some types are well known and can be shorter
967 # some types are well known and can be shorter
969 abbrevs = {'IPython.macro.Macro' : 'Macro'}
968 abbrevs = {'IPython.macro.Macro' : 'Macro'}
970 def type_name(v):
969 def type_name(v):
971 tn = type(v).__name__
970 tn = type(v).__name__
972 return abbrevs.get(tn,tn)
971 return abbrevs.get(tn,tn)
973
972
974 varlist = map(get_vars,varnames)
973 varlist = map(get_vars,varnames)
975
974
976 typelist = []
975 typelist = []
977 for vv in varlist:
976 for vv in varlist:
978 tt = type_name(vv)
977 tt = type_name(vv)
979
978
980 if tt=='instance':
979 if tt=='instance':
981 typelist.append( abbrevs.get(str(vv.__class__),str(vv.__class__)))
980 typelist.append( abbrevs.get(str(vv.__class__),str(vv.__class__)))
982 else:
981 else:
983 typelist.append(tt)
982 typelist.append(tt)
984
983
985 # column labels and # of spaces as separator
984 # column labels and # of spaces as separator
986 varlabel = 'Variable'
985 varlabel = 'Variable'
987 typelabel = 'Type'
986 typelabel = 'Type'
988 datalabel = 'Data/Info'
987 datalabel = 'Data/Info'
989 colsep = 3
988 colsep = 3
990 # variable format strings
989 # variable format strings
991 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
990 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
992 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
991 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
993 aformat = "%s: %s elems, type `%s`, %s bytes"
992 aformat = "%s: %s elems, type `%s`, %s bytes"
994 # find the size of the columns to format the output nicely
993 # find the size of the columns to format the output nicely
995 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
994 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
996 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
995 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
997 # table header
996 # table header
998 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
997 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
999 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
998 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
1000 # and the table itself
999 # and the table itself
1001 kb = 1024
1000 kb = 1024
1002 Mb = 1048576 # kb**2
1001 Mb = 1048576 # kb**2
1003 for vname,var,vtype in zip(varnames,varlist,typelist):
1002 for vname,var,vtype in zip(varnames,varlist,typelist):
1004 print itpl(vformat),
1003 print itpl(vformat),
1005 if vtype in seq_types:
1004 if vtype in seq_types:
1006 print len(var)
1005 print len(var)
1007 elif vtype==array_type:
1006 elif vtype==array_type:
1008 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
1007 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
1009 vsize = Numeric.size(var)
1008 vsize = Numeric.size(var)
1010 vbytes = vsize*var.itemsize()
1009 vbytes = vsize*var.itemsize()
1011 if vbytes < 100000:
1010 if vbytes < 100000:
1012 print aformat % (vshape,vsize,var.typecode(),vbytes)
1011 print aformat % (vshape,vsize,var.typecode(),vbytes)
1013 else:
1012 else:
1014 print aformat % (vshape,vsize,var.typecode(),vbytes),
1013 print aformat % (vshape,vsize,var.typecode(),vbytes),
1015 if vbytes < Mb:
1014 if vbytes < Mb:
1016 print '(%s kb)' % (vbytes/kb,)
1015 print '(%s kb)' % (vbytes/kb,)
1017 else:
1016 else:
1018 print '(%s Mb)' % (vbytes/Mb,)
1017 print '(%s Mb)' % (vbytes/Mb,)
1019 else:
1018 else:
1020 vstr = str(var).replace('\n','\\n')
1019 vstr = str(var).replace('\n','\\n')
1021 if len(vstr) < 50:
1020 if len(vstr) < 50:
1022 print vstr
1021 print vstr
1023 else:
1022 else:
1024 printpl(vfmt_short)
1023 printpl(vfmt_short)
1025
1024
1026 def magic_reset(self, parameter_s=''):
1025 def magic_reset(self, parameter_s=''):
1027 """Resets the namespace by removing all names defined by the user.
1026 """Resets the namespace by removing all names defined by the user.
1028
1027
1029 Input/Output history are left around in case you need them."""
1028 Input/Output history are left around in case you need them."""
1030
1029
1031 ans = self.shell.ask_yes_no(
1030 ans = self.shell.ask_yes_no(
1032 "Once deleted, variables cannot be recovered. Proceed (y/[n])? ")
1031 "Once deleted, variables cannot be recovered. Proceed (y/[n])? ")
1033 if not ans:
1032 if not ans:
1034 print 'Nothing done.'
1033 print 'Nothing done.'
1035 return
1034 return
1036 user_ns = self.shell.user_ns
1035 user_ns = self.shell.user_ns
1037 for i in self.magic_who_ls():
1036 for i in self.magic_who_ls():
1038 del(user_ns[i])
1037 del(user_ns[i])
1039
1038
1040 def magic_logstart(self,parameter_s=''):
1039 def magic_logstart(self,parameter_s=''):
1041 """Start logging anywhere in a session.
1040 """Start logging anywhere in a session.
1042
1041
1043 %logstart [-o|-r|-t] [log_name [log_mode]]
1042 %logstart [-o|-r|-t] [log_name [log_mode]]
1044
1043
1045 If no name is given, it defaults to a file named 'ipython_log.py' in your
1044 If no name is given, it defaults to a file named 'ipython_log.py' in your
1046 current directory, in 'rotate' mode (see below).
1045 current directory, in 'rotate' mode (see below).
1047
1046
1048 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
1047 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
1049 history up to that point and then continues logging.
1048 history up to that point and then continues logging.
1050
1049
1051 %logstart takes a second optional parameter: logging mode. This can be one
1050 %logstart takes a second optional parameter: logging mode. This can be one
1052 of (note that the modes are given unquoted):\\
1051 of (note that the modes are given unquoted):\\
1053 append: well, that says it.\\
1052 append: well, that says it.\\
1054 backup: rename (if exists) to name~ and start name.\\
1053 backup: rename (if exists) to name~ and start name.\\
1055 global: single logfile in your home dir, appended to.\\
1054 global: single logfile in your home dir, appended to.\\
1056 over : overwrite existing log.\\
1055 over : overwrite existing log.\\
1057 rotate: create rotating logs name.1~, name.2~, etc.
1056 rotate: create rotating logs name.1~, name.2~, etc.
1058
1057
1059 Options:
1058 Options:
1060
1059
1061 -o: log also IPython's output. In this mode, all commands which
1060 -o: log also IPython's output. In this mode, all commands which
1062 generate an Out[NN] prompt are recorded to the logfile, right after
1061 generate an Out[NN] prompt are recorded to the logfile, right after
1063 their corresponding input line. The output lines are always
1062 their corresponding input line. The output lines are always
1064 prepended with a '#[Out]# ' marker, so that the log remains valid
1063 prepended with a '#[Out]# ' marker, so that the log remains valid
1065 Python code.
1064 Python code.
1066
1065
1067 Since this marker is always the same, filtering only the output from
1066 Since this marker is always the same, filtering only the output from
1068 a log is very easy, using for example a simple awk call:
1067 a log is very easy, using for example a simple awk call:
1069
1068
1070 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
1069 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
1071
1070
1072 -r: log 'raw' input. Normally, IPython's logs contain the processed
1071 -r: log 'raw' input. Normally, IPython's logs contain the processed
1073 input, so that user lines are logged in their final form, converted
1072 input, so that user lines are logged in their final form, converted
1074 into valid Python. For example, %Exit is logged as
1073 into valid Python. For example, %Exit is logged as
1075 '_ip.magic("Exit"). If the -r flag is given, all input is logged
1074 '_ip.magic("Exit"). If the -r flag is given, all input is logged
1076 exactly as typed, with no transformations applied.
1075 exactly as typed, with no transformations applied.
1077
1076
1078 -t: put timestamps before each input line logged (these are put in
1077 -t: put timestamps before each input line logged (these are put in
1079 comments)."""
1078 comments)."""
1080
1079
1081 opts,par = self.parse_options(parameter_s,'ort')
1080 opts,par = self.parse_options(parameter_s,'ort')
1082 log_output = 'o' in opts
1081 log_output = 'o' in opts
1083 log_raw_input = 'r' in opts
1082 log_raw_input = 'r' in opts
1084 timestamp = 't' in opts
1083 timestamp = 't' in opts
1085
1084
1086 rc = self.shell.rc
1085 rc = self.shell.rc
1087 logger = self.shell.logger
1086 logger = self.shell.logger
1088
1087
1089 # if no args are given, the defaults set in the logger constructor by
1088 # if no args are given, the defaults set in the logger constructor by
1090 # ipytohn remain valid
1089 # ipytohn remain valid
1091 if par:
1090 if par:
1092 try:
1091 try:
1093 logfname,logmode = par.split()
1092 logfname,logmode = par.split()
1094 except:
1093 except:
1095 logfname = par
1094 logfname = par
1096 logmode = 'backup'
1095 logmode = 'backup'
1097 else:
1096 else:
1098 logfname = logger.logfname
1097 logfname = logger.logfname
1099 logmode = logger.logmode
1098 logmode = logger.logmode
1100 # put logfname into rc struct as if it had been called on the command
1099 # put logfname into rc struct as if it had been called on the command
1101 # line, so it ends up saved in the log header Save it in case we need
1100 # line, so it ends up saved in the log header Save it in case we need
1102 # to restore it...
1101 # to restore it...
1103 old_logfile = rc.opts.get('logfile','')
1102 old_logfile = rc.opts.get('logfile','')
1104 if logfname:
1103 if logfname:
1105 logfname = os.path.expanduser(logfname)
1104 logfname = os.path.expanduser(logfname)
1106 rc.opts.logfile = logfname
1105 rc.opts.logfile = logfname
1107 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
1106 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
1108 try:
1107 try:
1109 started = logger.logstart(logfname,loghead,logmode,
1108 started = logger.logstart(logfname,loghead,logmode,
1110 log_output,timestamp,log_raw_input)
1109 log_output,timestamp,log_raw_input)
1111 except:
1110 except:
1112 rc.opts.logfile = old_logfile
1111 rc.opts.logfile = old_logfile
1113 warn("Couldn't start log: %s" % sys.exc_info()[1])
1112 warn("Couldn't start log: %s" % sys.exc_info()[1])
1114 else:
1113 else:
1115 # log input history up to this point, optionally interleaving
1114 # log input history up to this point, optionally interleaving
1116 # output if requested
1115 # output if requested
1117
1116
1118 if timestamp:
1117 if timestamp:
1119 # disable timestamping for the previous history, since we've
1118 # disable timestamping for the previous history, since we've
1120 # lost those already (no time machine here).
1119 # lost those already (no time machine here).
1121 logger.timestamp = False
1120 logger.timestamp = False
1122
1121
1123 if log_raw_input:
1122 if log_raw_input:
1124 input_hist = self.shell.input_hist_raw
1123 input_hist = self.shell.input_hist_raw
1125 else:
1124 else:
1126 input_hist = self.shell.input_hist
1125 input_hist = self.shell.input_hist
1127
1126
1128 if log_output:
1127 if log_output:
1129 log_write = logger.log_write
1128 log_write = logger.log_write
1130 output_hist = self.shell.output_hist
1129 output_hist = self.shell.output_hist
1131 for n in range(1,len(input_hist)-1):
1130 for n in range(1,len(input_hist)-1):
1132 log_write(input_hist[n].rstrip())
1131 log_write(input_hist[n].rstrip())
1133 if n in output_hist:
1132 if n in output_hist:
1134 log_write(repr(output_hist[n]),'output')
1133 log_write(repr(output_hist[n]),'output')
1135 else:
1134 else:
1136 logger.log_write(input_hist[1:])
1135 logger.log_write(input_hist[1:])
1137 if timestamp:
1136 if timestamp:
1138 # re-enable timestamping
1137 # re-enable timestamping
1139 logger.timestamp = True
1138 logger.timestamp = True
1140
1139
1141 print ('Activating auto-logging. '
1140 print ('Activating auto-logging. '
1142 'Current session state plus future input saved.')
1141 'Current session state plus future input saved.')
1143 logger.logstate()
1142 logger.logstate()
1144
1143
1145 def magic_logoff(self,parameter_s=''):
1144 def magic_logoff(self,parameter_s=''):
1146 """Temporarily stop logging.
1145 """Temporarily stop logging.
1147
1146
1148 You must have previously started logging."""
1147 You must have previously started logging."""
1149 self.shell.logger.switch_log(0)
1148 self.shell.logger.switch_log(0)
1150
1149
1151 def magic_logon(self,parameter_s=''):
1150 def magic_logon(self,parameter_s=''):
1152 """Restart logging.
1151 """Restart logging.
1153
1152
1154 This function is for restarting logging which you've temporarily
1153 This function is for restarting logging which you've temporarily
1155 stopped with %logoff. For starting logging for the first time, you
1154 stopped with %logoff. For starting logging for the first time, you
1156 must use the %logstart function, which allows you to specify an
1155 must use the %logstart function, which allows you to specify an
1157 optional log filename."""
1156 optional log filename."""
1158
1157
1159 self.shell.logger.switch_log(1)
1158 self.shell.logger.switch_log(1)
1160
1159
1161 def magic_logstate(self,parameter_s=''):
1160 def magic_logstate(self,parameter_s=''):
1162 """Print the status of the logging system."""
1161 """Print the status of the logging system."""
1163
1162
1164 self.shell.logger.logstate()
1163 self.shell.logger.logstate()
1165
1164
1166 def magic_pdb(self, parameter_s=''):
1165 def magic_pdb(self, parameter_s=''):
1167 """Control the automatic calling of the pdb interactive debugger.
1166 """Control the automatic calling of the pdb interactive debugger.
1168
1167
1169 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1168 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1170 argument it works as a toggle.
1169 argument it works as a toggle.
1171
1170
1172 When an exception is triggered, IPython can optionally call the
1171 When an exception is triggered, IPython can optionally call the
1173 interactive pdb debugger after the traceback printout. %pdb toggles
1172 interactive pdb debugger after the traceback printout. %pdb toggles
1174 this feature on and off.
1173 this feature on and off.
1175
1174
1176 The initial state of this feature is set in your ipythonrc
1175 The initial state of this feature is set in your ipythonrc
1177 configuration file (the variable is called 'pdb').
1176 configuration file (the variable is called 'pdb').
1178
1177
1179 If you want to just activate the debugger AFTER an exception has fired,
1178 If you want to just activate the debugger AFTER an exception has fired,
1180 without having to type '%pdb on' and rerunning your code, you can use
1179 without having to type '%pdb on' and rerunning your code, you can use
1181 the %debug magic."""
1180 the %debug magic."""
1182
1181
1183 par = parameter_s.strip().lower()
1182 par = parameter_s.strip().lower()
1184
1183
1185 if par:
1184 if par:
1186 try:
1185 try:
1187 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1186 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1188 except KeyError:
1187 except KeyError:
1189 print ('Incorrect argument. Use on/1, off/0, '
1188 print ('Incorrect argument. Use on/1, off/0, '
1190 'or nothing for a toggle.')
1189 'or nothing for a toggle.')
1191 return
1190 return
1192 else:
1191 else:
1193 # toggle
1192 # toggle
1194 new_pdb = not self.shell.call_pdb
1193 new_pdb = not self.shell.call_pdb
1195
1194
1196 # set on the shell
1195 # set on the shell
1197 self.shell.call_pdb = new_pdb
1196 self.shell.call_pdb = new_pdb
1198 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1197 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1199
1198
1200 def magic_debug(self, parameter_s=''):
1199 def magic_debug(self, parameter_s=''):
1201 """Activate the interactive debugger in post-mortem mode.
1200 """Activate the interactive debugger in post-mortem mode.
1202
1201
1203 If an exception has just occurred, this lets you inspect its stack
1202 If an exception has just occurred, this lets you inspect its stack
1204 frames interactively. Note that this will always work only on the last
1203 frames interactively. Note that this will always work only on the last
1205 traceback that occurred, so you must call this quickly after an
1204 traceback that occurred, so you must call this quickly after an
1206 exception that you wish to inspect has fired, because if another one
1205 exception that you wish to inspect has fired, because if another one
1207 occurs, it clobbers the previous one.
1206 occurs, it clobbers the previous one.
1208
1207
1209 If you want IPython to automatically do this on every exception, see
1208 If you want IPython to automatically do this on every exception, see
1210 the %pdb magic for more details.
1209 the %pdb magic for more details.
1211 """
1210 """
1212
1211
1213 self.shell.debugger(force=True)
1212 self.shell.debugger(force=True)
1214
1213
1215 def magic_prun(self, parameter_s ='',user_mode=1,
1214 def magic_prun(self, parameter_s ='',user_mode=1,
1216 opts=None,arg_lst=None,prog_ns=None):
1215 opts=None,arg_lst=None,prog_ns=None):
1217
1216
1218 """Run a statement through the python code profiler.
1217 """Run a statement through the python code profiler.
1219
1218
1220 Usage:\\
1219 Usage:\\
1221 %prun [options] statement
1220 %prun [options] statement
1222
1221
1223 The given statement (which doesn't require quote marks) is run via the
1222 The given statement (which doesn't require quote marks) is run via the
1224 python profiler in a manner similar to the profile.run() function.
1223 python profiler in a manner similar to the profile.run() function.
1225 Namespaces are internally managed to work correctly; profile.run
1224 Namespaces are internally managed to work correctly; profile.run
1226 cannot be used in IPython because it makes certain assumptions about
1225 cannot be used in IPython because it makes certain assumptions about
1227 namespaces which do not hold under IPython.
1226 namespaces which do not hold under IPython.
1228
1227
1229 Options:
1228 Options:
1230
1229
1231 -l <limit>: you can place restrictions on what or how much of the
1230 -l <limit>: you can place restrictions on what or how much of the
1232 profile gets printed. The limit value can be:
1231 profile gets printed. The limit value can be:
1233
1232
1234 * A string: only information for function names containing this string
1233 * A string: only information for function names containing this string
1235 is printed.
1234 is printed.
1236
1235
1237 * An integer: only these many lines are printed.
1236 * An integer: only these many lines are printed.
1238
1237
1239 * A float (between 0 and 1): this fraction of the report is printed
1238 * A float (between 0 and 1): this fraction of the report is printed
1240 (for example, use a limit of 0.4 to see the topmost 40% only).
1239 (for example, use a limit of 0.4 to see the topmost 40% only).
1241
1240
1242 You can combine several limits with repeated use of the option. For
1241 You can combine several limits with repeated use of the option. For
1243 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1242 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1244 information about class constructors.
1243 information about class constructors.
1245
1244
1246 -r: return the pstats.Stats object generated by the profiling. This
1245 -r: return the pstats.Stats object generated by the profiling. This
1247 object has all the information about the profile in it, and you can
1246 object has all the information about the profile in it, and you can
1248 later use it for further analysis or in other functions.
1247 later use it for further analysis or in other functions.
1249
1248
1250 -s <key>: sort profile by given key. You can provide more than one key
1249 -s <key>: sort profile by given key. You can provide more than one key
1251 by using the option several times: '-s key1 -s key2 -s key3...'. The
1250 by using the option several times: '-s key1 -s key2 -s key3...'. The
1252 default sorting key is 'time'.
1251 default sorting key is 'time'.
1253
1252
1254 The following is copied verbatim from the profile documentation
1253 The following is copied verbatim from the profile documentation
1255 referenced below:
1254 referenced below:
1256
1255
1257 When more than one key is provided, additional keys are used as
1256 When more than one key is provided, additional keys are used as
1258 secondary criteria when the there is equality in all keys selected
1257 secondary criteria when the there is equality in all keys selected
1259 before them.
1258 before them.
1260
1259
1261 Abbreviations can be used for any key names, as long as the
1260 Abbreviations can be used for any key names, as long as the
1262 abbreviation is unambiguous. The following are the keys currently
1261 abbreviation is unambiguous. The following are the keys currently
1263 defined:
1262 defined:
1264
1263
1265 Valid Arg Meaning\\
1264 Valid Arg Meaning\\
1266 "calls" call count\\
1265 "calls" call count\\
1267 "cumulative" cumulative time\\
1266 "cumulative" cumulative time\\
1268 "file" file name\\
1267 "file" file name\\
1269 "module" file name\\
1268 "module" file name\\
1270 "pcalls" primitive call count\\
1269 "pcalls" primitive call count\\
1271 "line" line number\\
1270 "line" line number\\
1272 "name" function name\\
1271 "name" function name\\
1273 "nfl" name/file/line\\
1272 "nfl" name/file/line\\
1274 "stdname" standard name\\
1273 "stdname" standard name\\
1275 "time" internal time
1274 "time" internal time
1276
1275
1277 Note that all sorts on statistics are in descending order (placing
1276 Note that all sorts on statistics are in descending order (placing
1278 most time consuming items first), where as name, file, and line number
1277 most time consuming items first), where as name, file, and line number
1279 searches are in ascending order (i.e., alphabetical). The subtle
1278 searches are in ascending order (i.e., alphabetical). The subtle
1280 distinction between "nfl" and "stdname" is that the standard name is a
1279 distinction between "nfl" and "stdname" is that the standard name is a
1281 sort of the name as printed, which means that the embedded line
1280 sort of the name as printed, which means that the embedded line
1282 numbers get compared in an odd way. For example, lines 3, 20, and 40
1281 numbers get compared in an odd way. For example, lines 3, 20, and 40
1283 would (if the file names were the same) appear in the string order
1282 would (if the file names were the same) appear in the string order
1284 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1283 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1285 line numbers. In fact, sort_stats("nfl") is the same as
1284 line numbers. In fact, sort_stats("nfl") is the same as
1286 sort_stats("name", "file", "line").
1285 sort_stats("name", "file", "line").
1287
1286
1288 -T <filename>: save profile results as shown on screen to a text
1287 -T <filename>: save profile results as shown on screen to a text
1289 file. The profile is still shown on screen.
1288 file. The profile is still shown on screen.
1290
1289
1291 -D <filename>: save (via dump_stats) profile statistics to given
1290 -D <filename>: save (via dump_stats) profile statistics to given
1292 filename. This data is in a format understod by the pstats module, and
1291 filename. This data is in a format understod by the pstats module, and
1293 is generated by a call to the dump_stats() method of profile
1292 is generated by a call to the dump_stats() method of profile
1294 objects. The profile is still shown on screen.
1293 objects. The profile is still shown on screen.
1295
1294
1296 If you want to run complete programs under the profiler's control, use
1295 If you want to run complete programs under the profiler's control, use
1297 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1296 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1298 contains profiler specific options as described here.
1297 contains profiler specific options as described here.
1299
1298
1300 You can read the complete documentation for the profile module with:\\
1299 You can read the complete documentation for the profile module with:\\
1301 In [1]: import profile; profile.help() """
1300 In [1]: import profile; profile.help() """
1302
1301
1303 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1302 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1304 # protect user quote marks
1303 # protect user quote marks
1305 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1304 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1306
1305
1307 if user_mode: # regular user call
1306 if user_mode: # regular user call
1308 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1307 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1309 list_all=1)
1308 list_all=1)
1310 namespace = self.shell.user_ns
1309 namespace = self.shell.user_ns
1311 else: # called to run a program by %run -p
1310 else: # called to run a program by %run -p
1312 try:
1311 try:
1313 filename = get_py_filename(arg_lst[0])
1312 filename = get_py_filename(arg_lst[0])
1314 except IOError,msg:
1313 except IOError,msg:
1315 error(msg)
1314 error(msg)
1316 return
1315 return
1317
1316
1318 arg_str = 'execfile(filename,prog_ns)'
1317 arg_str = 'execfile(filename,prog_ns)'
1319 namespace = locals()
1318 namespace = locals()
1320
1319
1321 opts.merge(opts_def)
1320 opts.merge(opts_def)
1322
1321
1323 prof = profile.Profile()
1322 prof = profile.Profile()
1324 try:
1323 try:
1325 prof = prof.runctx(arg_str,namespace,namespace)
1324 prof = prof.runctx(arg_str,namespace,namespace)
1326 sys_exit = ''
1325 sys_exit = ''
1327 except SystemExit:
1326 except SystemExit:
1328 sys_exit = """*** SystemExit exception caught in code being profiled."""
1327 sys_exit = """*** SystemExit exception caught in code being profiled."""
1329
1328
1330 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1329 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1331
1330
1332 lims = opts.l
1331 lims = opts.l
1333 if lims:
1332 if lims:
1334 lims = [] # rebuild lims with ints/floats/strings
1333 lims = [] # rebuild lims with ints/floats/strings
1335 for lim in opts.l:
1334 for lim in opts.l:
1336 try:
1335 try:
1337 lims.append(int(lim))
1336 lims.append(int(lim))
1338 except ValueError:
1337 except ValueError:
1339 try:
1338 try:
1340 lims.append(float(lim))
1339 lims.append(float(lim))
1341 except ValueError:
1340 except ValueError:
1342 lims.append(lim)
1341 lims.append(lim)
1343
1342
1344 # trap output
1343 # trap output
1345 sys_stdout = sys.stdout
1344 sys_stdout = sys.stdout
1346 stdout_trap = StringIO()
1345 stdout_trap = StringIO()
1347 try:
1346 try:
1348 sys.stdout = stdout_trap
1347 sys.stdout = stdout_trap
1349 stats.print_stats(*lims)
1348 stats.print_stats(*lims)
1350 finally:
1349 finally:
1351 sys.stdout = sys_stdout
1350 sys.stdout = sys_stdout
1352 output = stdout_trap.getvalue()
1351 output = stdout_trap.getvalue()
1353 output = output.rstrip()
1352 output = output.rstrip()
1354
1353
1355 page(output,screen_lines=self.shell.rc.screen_length)
1354 page(output,screen_lines=self.shell.rc.screen_length)
1356 print sys_exit,
1355 print sys_exit,
1357
1356
1358 dump_file = opts.D[0]
1357 dump_file = opts.D[0]
1359 text_file = opts.T[0]
1358 text_file = opts.T[0]
1360 if dump_file:
1359 if dump_file:
1361 prof.dump_stats(dump_file)
1360 prof.dump_stats(dump_file)
1362 print '\n*** Profile stats marshalled to file',\
1361 print '\n*** Profile stats marshalled to file',\
1363 `dump_file`+'.',sys_exit
1362 `dump_file`+'.',sys_exit
1364 if text_file:
1363 if text_file:
1365 file(text_file,'w').write(output)
1364 file(text_file,'w').write(output)
1366 print '\n*** Profile printout saved to text file',\
1365 print '\n*** Profile printout saved to text file',\
1367 `text_file`+'.',sys_exit
1366 `text_file`+'.',sys_exit
1368
1367
1369 if opts.has_key('r'):
1368 if opts.has_key('r'):
1370 return stats
1369 return stats
1371 else:
1370 else:
1372 return None
1371 return None
1373
1372
1374 def magic_run(self, parameter_s ='',runner=None):
1373 def magic_run(self, parameter_s ='',runner=None):
1375 """Run the named file inside IPython as a program.
1374 """Run the named file inside IPython as a program.
1376
1375
1377 Usage:\\
1376 Usage:\\
1378 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1377 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1379
1378
1380 Parameters after the filename are passed as command-line arguments to
1379 Parameters after the filename are passed as command-line arguments to
1381 the program (put in sys.argv). Then, control returns to IPython's
1380 the program (put in sys.argv). Then, control returns to IPython's
1382 prompt.
1381 prompt.
1383
1382
1384 This is similar to running at a system prompt:\\
1383 This is similar to running at a system prompt:\\
1385 $ python file args\\
1384 $ python file args\\
1386 but with the advantage of giving you IPython's tracebacks, and of
1385 but with the advantage of giving you IPython's tracebacks, and of
1387 loading all variables into your interactive namespace for further use
1386 loading all variables into your interactive namespace for further use
1388 (unless -p is used, see below).
1387 (unless -p is used, see below).
1389
1388
1390 The file is executed in a namespace initially consisting only of
1389 The file is executed in a namespace initially consisting only of
1391 __name__=='__main__' and sys.argv constructed as indicated. It thus
1390 __name__=='__main__' and sys.argv constructed as indicated. It thus
1392 sees its environment as if it were being run as a stand-alone
1391 sees its environment as if it were being run as a stand-alone
1393 program. But after execution, the IPython interactive namespace gets
1392 program. But after execution, the IPython interactive namespace gets
1394 updated with all variables defined in the program (except for __name__
1393 updated with all variables defined in the program (except for __name__
1395 and sys.argv). This allows for very convenient loading of code for
1394 and sys.argv). This allows for very convenient loading of code for
1396 interactive work, while giving each program a 'clean sheet' to run in.
1395 interactive work, while giving each program a 'clean sheet' to run in.
1397
1396
1398 Options:
1397 Options:
1399
1398
1400 -n: __name__ is NOT set to '__main__', but to the running file's name
1399 -n: __name__ is NOT set to '__main__', but to the running file's name
1401 without extension (as python does under import). This allows running
1400 without extension (as python does under import). This allows running
1402 scripts and reloading the definitions in them without calling code
1401 scripts and reloading the definitions in them without calling code
1403 protected by an ' if __name__ == "__main__" ' clause.
1402 protected by an ' if __name__ == "__main__" ' clause.
1404
1403
1405 -i: run the file in IPython's namespace instead of an empty one. This
1404 -i: run the file in IPython's namespace instead of an empty one. This
1406 is useful if you are experimenting with code written in a text editor
1405 is useful if you are experimenting with code written in a text editor
1407 which depends on variables defined interactively.
1406 which depends on variables defined interactively.
1408
1407
1409 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1408 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1410 being run. This is particularly useful if IPython is being used to
1409 being run. This is particularly useful if IPython is being used to
1411 run unittests, which always exit with a sys.exit() call. In such
1410 run unittests, which always exit with a sys.exit() call. In such
1412 cases you are interested in the output of the test results, not in
1411 cases you are interested in the output of the test results, not in
1413 seeing a traceback of the unittest module.
1412 seeing a traceback of the unittest module.
1414
1413
1415 -t: print timing information at the end of the run. IPython will give
1414 -t: print timing information at the end of the run. IPython will give
1416 you an estimated CPU time consumption for your script, which under
1415 you an estimated CPU time consumption for your script, which under
1417 Unix uses the resource module to avoid the wraparound problems of
1416 Unix uses the resource module to avoid the wraparound problems of
1418 time.clock(). Under Unix, an estimate of time spent on system tasks
1417 time.clock(). Under Unix, an estimate of time spent on system tasks
1419 is also given (for Windows platforms this is reported as 0.0).
1418 is also given (for Windows platforms this is reported as 0.0).
1420
1419
1421 If -t is given, an additional -N<N> option can be given, where <N>
1420 If -t is given, an additional -N<N> option can be given, where <N>
1422 must be an integer indicating how many times you want the script to
1421 must be an integer indicating how many times you want the script to
1423 run. The final timing report will include total and per run results.
1422 run. The final timing report will include total and per run results.
1424
1423
1425 For example (testing the script uniq_stable.py):
1424 For example (testing the script uniq_stable.py):
1426
1425
1427 In [1]: run -t uniq_stable
1426 In [1]: run -t uniq_stable
1428
1427
1429 IPython CPU timings (estimated):\\
1428 IPython CPU timings (estimated):\\
1430 User : 0.19597 s.\\
1429 User : 0.19597 s.\\
1431 System: 0.0 s.\\
1430 System: 0.0 s.\\
1432
1431
1433 In [2]: run -t -N5 uniq_stable
1432 In [2]: run -t -N5 uniq_stable
1434
1433
1435 IPython CPU timings (estimated):\\
1434 IPython CPU timings (estimated):\\
1436 Total runs performed: 5\\
1435 Total runs performed: 5\\
1437 Times : Total Per run\\
1436 Times : Total Per run\\
1438 User : 0.910862 s, 0.1821724 s.\\
1437 User : 0.910862 s, 0.1821724 s.\\
1439 System: 0.0 s, 0.0 s.
1438 System: 0.0 s, 0.0 s.
1440
1439
1441 -d: run your program under the control of pdb, the Python debugger.
1440 -d: run your program under the control of pdb, the Python debugger.
1442 This allows you to execute your program step by step, watch variables,
1441 This allows you to execute your program step by step, watch variables,
1443 etc. Internally, what IPython does is similar to calling:
1442 etc. Internally, what IPython does is similar to calling:
1444
1443
1445 pdb.run('execfile("YOURFILENAME")')
1444 pdb.run('execfile("YOURFILENAME")')
1446
1445
1447 with a breakpoint set on line 1 of your file. You can change the line
1446 with a breakpoint set on line 1 of your file. You can change the line
1448 number for this automatic breakpoint to be <N> by using the -bN option
1447 number for this automatic breakpoint to be <N> by using the -bN option
1449 (where N must be an integer). For example:
1448 (where N must be an integer). For example:
1450
1449
1451 %run -d -b40 myscript
1450 %run -d -b40 myscript
1452
1451
1453 will set the first breakpoint at line 40 in myscript.py. Note that
1452 will set the first breakpoint at line 40 in myscript.py. Note that
1454 the first breakpoint must be set on a line which actually does
1453 the first breakpoint must be set on a line which actually does
1455 something (not a comment or docstring) for it to stop execution.
1454 something (not a comment or docstring) for it to stop execution.
1456
1455
1457 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1456 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1458 first enter 'c' (without qoutes) to start execution up to the first
1457 first enter 'c' (without qoutes) to start execution up to the first
1459 breakpoint.
1458 breakpoint.
1460
1459
1461 Entering 'help' gives information about the use of the debugger. You
1460 Entering 'help' gives information about the use of the debugger. You
1462 can easily see pdb's full documentation with "import pdb;pdb.help()"
1461 can easily see pdb's full documentation with "import pdb;pdb.help()"
1463 at a prompt.
1462 at a prompt.
1464
1463
1465 -p: run program under the control of the Python profiler module (which
1464 -p: run program under the control of the Python profiler module (which
1466 prints a detailed report of execution times, function calls, etc).
1465 prints a detailed report of execution times, function calls, etc).
1467
1466
1468 You can pass other options after -p which affect the behavior of the
1467 You can pass other options after -p which affect the behavior of the
1469 profiler itself. See the docs for %prun for details.
1468 profiler itself. See the docs for %prun for details.
1470
1469
1471 In this mode, the program's variables do NOT propagate back to the
1470 In this mode, the program's variables do NOT propagate back to the
1472 IPython interactive namespace (because they remain in the namespace
1471 IPython interactive namespace (because they remain in the namespace
1473 where the profiler executes them).
1472 where the profiler executes them).
1474
1473
1475 Internally this triggers a call to %prun, see its documentation for
1474 Internally this triggers a call to %prun, see its documentation for
1476 details on the options available specifically for profiling."""
1475 details on the options available specifically for profiling."""
1477
1476
1478 # get arguments and set sys.argv for program to be run.
1477 # get arguments and set sys.argv for program to be run.
1479 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1478 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1480 mode='list',list_all=1)
1479 mode='list',list_all=1)
1481
1480
1482 try:
1481 try:
1483 filename = get_py_filename(arg_lst[0])
1482 filename = get_py_filename(arg_lst[0])
1484 except IndexError:
1483 except IndexError:
1485 warn('you must provide at least a filename.')
1484 warn('you must provide at least a filename.')
1486 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1485 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1487 return
1486 return
1488 except IOError,msg:
1487 except IOError,msg:
1489 error(msg)
1488 error(msg)
1490 return
1489 return
1491
1490
1492 # Control the response to exit() calls made by the script being run
1491 # Control the response to exit() calls made by the script being run
1493 exit_ignore = opts.has_key('e')
1492 exit_ignore = opts.has_key('e')
1494
1493
1495 # Make sure that the running script gets a proper sys.argv as if it
1494 # Make sure that the running script gets a proper sys.argv as if it
1496 # were run from a system shell.
1495 # were run from a system shell.
1497 save_argv = sys.argv # save it for later restoring
1496 save_argv = sys.argv # save it for later restoring
1498 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1497 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1499
1498
1500 if opts.has_key('i'):
1499 if opts.has_key('i'):
1501 prog_ns = self.shell.user_ns
1500 prog_ns = self.shell.user_ns
1502 __name__save = self.shell.user_ns['__name__']
1501 __name__save = self.shell.user_ns['__name__']
1503 prog_ns['__name__'] = '__main__'
1502 prog_ns['__name__'] = '__main__'
1504 else:
1503 else:
1505 if opts.has_key('n'):
1504 if opts.has_key('n'):
1506 name = os.path.splitext(os.path.basename(filename))[0]
1505 name = os.path.splitext(os.path.basename(filename))[0]
1507 else:
1506 else:
1508 name = '__main__'
1507 name = '__main__'
1509 prog_ns = {'__name__':name}
1508 prog_ns = {'__name__':name}
1510
1509
1511 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
1510 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
1512 # set the __file__ global in the script's namespace
1511 # set the __file__ global in the script's namespace
1513 prog_ns['__file__'] = filename
1512 prog_ns['__file__'] = filename
1514
1513
1515 # pickle fix. See iplib for an explanation. But we need to make sure
1514 # pickle fix. See iplib for an explanation. But we need to make sure
1516 # that, if we overwrite __main__, we replace it at the end
1515 # that, if we overwrite __main__, we replace it at the end
1517 if prog_ns['__name__'] == '__main__':
1516 if prog_ns['__name__'] == '__main__':
1518 restore_main = sys.modules['__main__']
1517 restore_main = sys.modules['__main__']
1519 else:
1518 else:
1520 restore_main = False
1519 restore_main = False
1521
1520
1522 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1521 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1523
1522
1524 stats = None
1523 stats = None
1525 try:
1524 try:
1526 if self.shell.has_readline:
1525 if self.shell.has_readline:
1527 self.shell.savehist()
1526 self.shell.savehist()
1528
1527
1529 if opts.has_key('p'):
1528 if opts.has_key('p'):
1530 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1529 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1531 else:
1530 else:
1532 if opts.has_key('d'):
1531 if opts.has_key('d'):
1533 deb = Debugger.Pdb(self.shell.rc.colors)
1532 deb = Debugger.Pdb(self.shell.rc.colors)
1534 # reset Breakpoint state, which is moronically kept
1533 # reset Breakpoint state, which is moronically kept
1535 # in a class
1534 # in a class
1536 bdb.Breakpoint.next = 1
1535 bdb.Breakpoint.next = 1
1537 bdb.Breakpoint.bplist = {}
1536 bdb.Breakpoint.bplist = {}
1538 bdb.Breakpoint.bpbynumber = [None]
1537 bdb.Breakpoint.bpbynumber = [None]
1539 # Set an initial breakpoint to stop execution
1538 # Set an initial breakpoint to stop execution
1540 maxtries = 10
1539 maxtries = 10
1541 bp = int(opts.get('b',[1])[0])
1540 bp = int(opts.get('b',[1])[0])
1542 checkline = deb.checkline(filename,bp)
1541 checkline = deb.checkline(filename,bp)
1543 if not checkline:
1542 if not checkline:
1544 for bp in range(bp+1,bp+maxtries+1):
1543 for bp in range(bp+1,bp+maxtries+1):
1545 if deb.checkline(filename,bp):
1544 if deb.checkline(filename,bp):
1546 break
1545 break
1547 else:
1546 else:
1548 msg = ("\nI failed to find a valid line to set "
1547 msg = ("\nI failed to find a valid line to set "
1549 "a breakpoint\n"
1548 "a breakpoint\n"
1550 "after trying up to line: %s.\n"
1549 "after trying up to line: %s.\n"
1551 "Please set a valid breakpoint manually "
1550 "Please set a valid breakpoint manually "
1552 "with the -b option." % bp)
1551 "with the -b option." % bp)
1553 error(msg)
1552 error(msg)
1554 return
1553 return
1555 # if we find a good linenumber, set the breakpoint
1554 # if we find a good linenumber, set the breakpoint
1556 deb.do_break('%s:%s' % (filename,bp))
1555 deb.do_break('%s:%s' % (filename,bp))
1557 # Start file run
1556 # Start file run
1558 print "NOTE: Enter 'c' at the",
1557 print "NOTE: Enter 'c' at the",
1559 print "%s prompt to start your script." % deb.prompt
1558 print "%s prompt to start your script." % deb.prompt
1560 try:
1559 try:
1561 deb.run('execfile("%s")' % filename,prog_ns)
1560 deb.run('execfile("%s")' % filename,prog_ns)
1562
1561
1563 except:
1562 except:
1564 etype, value, tb = sys.exc_info()
1563 etype, value, tb = sys.exc_info()
1565 # Skip three frames in the traceback: the %run one,
1564 # Skip three frames in the traceback: the %run one,
1566 # one inside bdb.py, and the command-line typed by the
1565 # one inside bdb.py, and the command-line typed by the
1567 # user (run by exec in pdb itself).
1566 # user (run by exec in pdb itself).
1568 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1567 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1569 else:
1568 else:
1570 if runner is None:
1569 if runner is None:
1571 runner = self.shell.safe_execfile
1570 runner = self.shell.safe_execfile
1572 if opts.has_key('t'):
1571 if opts.has_key('t'):
1573 try:
1572 try:
1574 nruns = int(opts['N'][0])
1573 nruns = int(opts['N'][0])
1575 if nruns < 1:
1574 if nruns < 1:
1576 error('Number of runs must be >=1')
1575 error('Number of runs must be >=1')
1577 return
1576 return
1578 except (KeyError):
1577 except (KeyError):
1579 nruns = 1
1578 nruns = 1
1580 if nruns == 1:
1579 if nruns == 1:
1581 t0 = clock2()
1580 t0 = clock2()
1582 runner(filename,prog_ns,prog_ns,
1581 runner(filename,prog_ns,prog_ns,
1583 exit_ignore=exit_ignore)
1582 exit_ignore=exit_ignore)
1584 t1 = clock2()
1583 t1 = clock2()
1585 t_usr = t1[0]-t0[0]
1584 t_usr = t1[0]-t0[0]
1586 t_sys = t1[1]-t1[1]
1585 t_sys = t1[1]-t1[1]
1587 print "\nIPython CPU timings (estimated):"
1586 print "\nIPython CPU timings (estimated):"
1588 print " User : %10s s." % t_usr
1587 print " User : %10s s." % t_usr
1589 print " System: %10s s." % t_sys
1588 print " System: %10s s." % t_sys
1590 else:
1589 else:
1591 runs = range(nruns)
1590 runs = range(nruns)
1592 t0 = clock2()
1591 t0 = clock2()
1593 for nr in runs:
1592 for nr in runs:
1594 runner(filename,prog_ns,prog_ns,
1593 runner(filename,prog_ns,prog_ns,
1595 exit_ignore=exit_ignore)
1594 exit_ignore=exit_ignore)
1596 t1 = clock2()
1595 t1 = clock2()
1597 t_usr = t1[0]-t0[0]
1596 t_usr = t1[0]-t0[0]
1598 t_sys = t1[1]-t1[1]
1597 t_sys = t1[1]-t1[1]
1599 print "\nIPython CPU timings (estimated):"
1598 print "\nIPython CPU timings (estimated):"
1600 print "Total runs performed:",nruns
1599 print "Total runs performed:",nruns
1601 print " Times : %10s %10s" % ('Total','Per run')
1600 print " Times : %10s %10s" % ('Total','Per run')
1602 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1601 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1603 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1602 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1604
1603
1605 else:
1604 else:
1606 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1605 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1607 if opts.has_key('i'):
1606 if opts.has_key('i'):
1608 self.shell.user_ns['__name__'] = __name__save
1607 self.shell.user_ns['__name__'] = __name__save
1609 else:
1608 else:
1610 # update IPython interactive namespace
1609 # update IPython interactive namespace
1611 del prog_ns['__name__']
1610 del prog_ns['__name__']
1612 self.shell.user_ns.update(prog_ns)
1611 self.shell.user_ns.update(prog_ns)
1613 finally:
1612 finally:
1614 sys.argv = save_argv
1613 sys.argv = save_argv
1615 if restore_main:
1614 if restore_main:
1616 sys.modules['__main__'] = restore_main
1615 sys.modules['__main__'] = restore_main
1617 if self.shell.has_readline:
1616 if self.shell.has_readline:
1618 self.shell.readline.read_history_file(self.shell.histfile)
1617 self.shell.readline.read_history_file(self.shell.histfile)
1619
1618
1620 return stats
1619 return stats
1621
1620
1622 def magic_runlog(self, parameter_s =''):
1621 def magic_runlog(self, parameter_s =''):
1623 """Run files as logs.
1622 """Run files as logs.
1624
1623
1625 Usage:\\
1624 Usage:\\
1626 %runlog file1 file2 ...
1625 %runlog file1 file2 ...
1627
1626
1628 Run the named files (treating them as log files) in sequence inside
1627 Run the named files (treating them as log files) in sequence inside
1629 the interpreter, and return to the prompt. This is much slower than
1628 the interpreter, and return to the prompt. This is much slower than
1630 %run because each line is executed in a try/except block, but it
1629 %run because each line is executed in a try/except block, but it
1631 allows running files with syntax errors in them.
1630 allows running files with syntax errors in them.
1632
1631
1633 Normally IPython will guess when a file is one of its own logfiles, so
1632 Normally IPython will guess when a file is one of its own logfiles, so
1634 you can typically use %run even for logs. This shorthand allows you to
1633 you can typically use %run even for logs. This shorthand allows you to
1635 force any file to be treated as a log file."""
1634 force any file to be treated as a log file."""
1636
1635
1637 for f in parameter_s.split():
1636 for f in parameter_s.split():
1638 self.shell.safe_execfile(f,self.shell.user_ns,
1637 self.shell.safe_execfile(f,self.shell.user_ns,
1639 self.shell.user_ns,islog=1)
1638 self.shell.user_ns,islog=1)
1640
1639
1641 def magic_timeit(self, parameter_s =''):
1640 def magic_timeit(self, parameter_s =''):
1642 """Time execution of a Python statement or expression
1641 """Time execution of a Python statement or expression
1643
1642
1644 Usage:\\
1643 Usage:\\
1645 %timeit [-n<N> -r<R> [-t|-c]] statement
1644 %timeit [-n<N> -r<R> [-t|-c]] statement
1646
1645
1647 Time execution of a Python statement or expression using the timeit
1646 Time execution of a Python statement or expression using the timeit
1648 module.
1647 module.
1649
1648
1650 Options:
1649 Options:
1651 -n<N>: execute the given statement <N> times in a loop. If this value
1650 -n<N>: execute the given statement <N> times in a loop. If this value
1652 is not given, a fitting value is chosen.
1651 is not given, a fitting value is chosen.
1653
1652
1654 -r<R>: repeat the loop iteration <R> times and take the best result.
1653 -r<R>: repeat the loop iteration <R> times and take the best result.
1655 Default: 3
1654 Default: 3
1656
1655
1657 -t: use time.time to measure the time, which is the default on Unix.
1656 -t: use time.time to measure the time, which is the default on Unix.
1658 This function measures wall time.
1657 This function measures wall time.
1659
1658
1660 -c: use time.clock to measure the time, which is the default on
1659 -c: use time.clock to measure the time, which is the default on
1661 Windows and measures wall time. On Unix, resource.getrusage is used
1660 Windows and measures wall time. On Unix, resource.getrusage is used
1662 instead and returns the CPU user time.
1661 instead and returns the CPU user time.
1663
1662
1664 -p<P>: use a precision of <P> digits to display the timing result.
1663 -p<P>: use a precision of <P> digits to display the timing result.
1665 Default: 3
1664 Default: 3
1666
1665
1667
1666
1668 Examples:\\
1667 Examples:\\
1669 In [1]: %timeit pass
1668 In [1]: %timeit pass
1670 10000000 loops, best of 3: 53.3 ns per loop
1669 10000000 loops, best of 3: 53.3 ns per loop
1671
1670
1672 In [2]: u = None
1671 In [2]: u = None
1673
1672
1674 In [3]: %timeit u is None
1673 In [3]: %timeit u is None
1675 10000000 loops, best of 3: 184 ns per loop
1674 10000000 loops, best of 3: 184 ns per loop
1676
1675
1677 In [4]: %timeit -r 4 u == None
1676 In [4]: %timeit -r 4 u == None
1678 1000000 loops, best of 4: 242 ns per loop
1677 1000000 loops, best of 4: 242 ns per loop
1679
1678
1680 In [5]: import time
1679 In [5]: import time
1681
1680
1682 In [6]: %timeit -n1 time.sleep(2)
1681 In [6]: %timeit -n1 time.sleep(2)
1683 1 loops, best of 3: 2 s per loop
1682 1 loops, best of 3: 2 s per loop
1684
1683
1685
1684
1686 The times reported by %timeit will be slightly higher than those
1685 The times reported by %timeit will be slightly higher than those
1687 reported by the timeit.py script when variables are accessed. This is
1686 reported by the timeit.py script when variables are accessed. This is
1688 due to the fact that %timeit executes the statement in the namespace
1687 due to the fact that %timeit executes the statement in the namespace
1689 of the shell, compared with timeit.py, which uses a single setup
1688 of the shell, compared with timeit.py, which uses a single setup
1690 statement to import function or create variables. Generally, the bias
1689 statement to import function or create variables. Generally, the bias
1691 does not matter as long as results from timeit.py are not mixed with
1690 does not matter as long as results from timeit.py are not mixed with
1692 those from %timeit."""
1691 those from %timeit."""
1693
1692
1694 import timeit
1693 import timeit
1695 import math
1694 import math
1696
1695
1697 units = ["s", "ms", "\xc2\xb5s", "ns"]
1696 units = ["s", "ms", "\xc2\xb5s", "ns"]
1698 scaling = [1, 1e3, 1e6, 1e9]
1697 scaling = [1, 1e3, 1e6, 1e9]
1699
1698
1700 opts, stmt = self.parse_options(parameter_s,'n:r:tcp:',
1699 opts, stmt = self.parse_options(parameter_s,'n:r:tcp:',
1701 posix=False)
1700 posix=False)
1702 if stmt == "":
1701 if stmt == "":
1703 return
1702 return
1704 timefunc = timeit.default_timer
1703 timefunc = timeit.default_timer
1705 number = int(getattr(opts, "n", 0))
1704 number = int(getattr(opts, "n", 0))
1706 repeat = int(getattr(opts, "r", timeit.default_repeat))
1705 repeat = int(getattr(opts, "r", timeit.default_repeat))
1707 precision = int(getattr(opts, "p", 3))
1706 precision = int(getattr(opts, "p", 3))
1708 if hasattr(opts, "t"):
1707 if hasattr(opts, "t"):
1709 timefunc = time.time
1708 timefunc = time.time
1710 if hasattr(opts, "c"):
1709 if hasattr(opts, "c"):
1711 timefunc = clock
1710 timefunc = clock
1712
1711
1713 timer = timeit.Timer(timer=timefunc)
1712 timer = timeit.Timer(timer=timefunc)
1714 # this code has tight coupling to the inner workings of timeit.Timer,
1713 # this code has tight coupling to the inner workings of timeit.Timer,
1715 # but is there a better way to achieve that the code stmt has access
1714 # but is there a better way to achieve that the code stmt has access
1716 # to the shell namespace?
1715 # to the shell namespace?
1717
1716
1718 src = timeit.template % {'stmt': timeit.reindent(stmt, 8),
1717 src = timeit.template % {'stmt': timeit.reindent(stmt, 8),
1719 'setup': "pass"}
1718 'setup': "pass"}
1720 code = compile(src, "<magic-timeit>", "exec")
1719 code = compile(src, "<magic-timeit>", "exec")
1721 ns = {}
1720 ns = {}
1722 exec code in self.shell.user_ns, ns
1721 exec code in self.shell.user_ns, ns
1723 timer.inner = ns["inner"]
1722 timer.inner = ns["inner"]
1724
1723
1725 if number == 0:
1724 if number == 0:
1726 # determine number so that 0.2 <= total time < 2.0
1725 # determine number so that 0.2 <= total time < 2.0
1727 number = 1
1726 number = 1
1728 for i in range(1, 10):
1727 for i in range(1, 10):
1729 number *= 10
1728 number *= 10
1730 if timer.timeit(number) >= 0.2:
1729 if timer.timeit(number) >= 0.2:
1731 break
1730 break
1732
1731
1733 best = min(timer.repeat(repeat, number)) / number
1732 best = min(timer.repeat(repeat, number)) / number
1734
1733
1735 if best > 0.0:
1734 if best > 0.0:
1736 order = min(-int(math.floor(math.log10(best)) // 3), 3)
1735 order = min(-int(math.floor(math.log10(best)) // 3), 3)
1737 else:
1736 else:
1738 order = 3
1737 order = 3
1739 print "%d loops, best of %d: %.*g %s per loop" % (number, repeat,
1738 print "%d loops, best of %d: %.*g %s per loop" % (number, repeat,
1740 precision,
1739 precision,
1741 best * scaling[order],
1740 best * scaling[order],
1742 units[order])
1741 units[order])
1743
1742
1744 def magic_time(self,parameter_s = ''):
1743 def magic_time(self,parameter_s = ''):
1745 """Time execution of a Python statement or expression.
1744 """Time execution of a Python statement or expression.
1746
1745
1747 The CPU and wall clock times are printed, and the value of the
1746 The CPU and wall clock times are printed, and the value of the
1748 expression (if any) is returned. Note that under Win32, system time
1747 expression (if any) is returned. Note that under Win32, system time
1749 is always reported as 0, since it can not be measured.
1748 is always reported as 0, since it can not be measured.
1750
1749
1751 This function provides very basic timing functionality. In Python
1750 This function provides very basic timing functionality. In Python
1752 2.3, the timeit module offers more control and sophistication, so this
1751 2.3, the timeit module offers more control and sophistication, so this
1753 could be rewritten to use it (patches welcome).
1752 could be rewritten to use it (patches welcome).
1754
1753
1755 Some examples:
1754 Some examples:
1756
1755
1757 In [1]: time 2**128
1756 In [1]: time 2**128
1758 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1757 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1759 Wall time: 0.00
1758 Wall time: 0.00
1760 Out[1]: 340282366920938463463374607431768211456L
1759 Out[1]: 340282366920938463463374607431768211456L
1761
1760
1762 In [2]: n = 1000000
1761 In [2]: n = 1000000
1763
1762
1764 In [3]: time sum(range(n))
1763 In [3]: time sum(range(n))
1765 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1764 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1766 Wall time: 1.37
1765 Wall time: 1.37
1767 Out[3]: 499999500000L
1766 Out[3]: 499999500000L
1768
1767
1769 In [4]: time print 'hello world'
1768 In [4]: time print 'hello world'
1770 hello world
1769 hello world
1771 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1770 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1772 Wall time: 0.00
1771 Wall time: 0.00
1773 """
1772 """
1774
1773
1775 # fail immediately if the given expression can't be compiled
1774 # fail immediately if the given expression can't be compiled
1776 try:
1775 try:
1777 mode = 'eval'
1776 mode = 'eval'
1778 code = compile(parameter_s,'<timed eval>',mode)
1777 code = compile(parameter_s,'<timed eval>',mode)
1779 except SyntaxError:
1778 except SyntaxError:
1780 mode = 'exec'
1779 mode = 'exec'
1781 code = compile(parameter_s,'<timed exec>',mode)
1780 code = compile(parameter_s,'<timed exec>',mode)
1782 # skew measurement as little as possible
1781 # skew measurement as little as possible
1783 glob = self.shell.user_ns
1782 glob = self.shell.user_ns
1784 clk = clock2
1783 clk = clock2
1785 wtime = time.time
1784 wtime = time.time
1786 # time execution
1785 # time execution
1787 wall_st = wtime()
1786 wall_st = wtime()
1788 if mode=='eval':
1787 if mode=='eval':
1789 st = clk()
1788 st = clk()
1790 out = eval(code,glob)
1789 out = eval(code,glob)
1791 end = clk()
1790 end = clk()
1792 else:
1791 else:
1793 st = clk()
1792 st = clk()
1794 exec code in glob
1793 exec code in glob
1795 end = clk()
1794 end = clk()
1796 out = None
1795 out = None
1797 wall_end = wtime()
1796 wall_end = wtime()
1798 # Compute actual times and report
1797 # Compute actual times and report
1799 wall_time = wall_end-wall_st
1798 wall_time = wall_end-wall_st
1800 cpu_user = end[0]-st[0]
1799 cpu_user = end[0]-st[0]
1801 cpu_sys = end[1]-st[1]
1800 cpu_sys = end[1]-st[1]
1802 cpu_tot = cpu_user+cpu_sys
1801 cpu_tot = cpu_user+cpu_sys
1803 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1802 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1804 (cpu_user,cpu_sys,cpu_tot)
1803 (cpu_user,cpu_sys,cpu_tot)
1805 print "Wall time: %.2f" % wall_time
1804 print "Wall time: %.2f" % wall_time
1806 return out
1805 return out
1807
1806
1808 def magic_macro(self,parameter_s = ''):
1807 def magic_macro(self,parameter_s = ''):
1809 """Define a set of input lines as a macro for future re-execution.
1808 """Define a set of input lines as a macro for future re-execution.
1810
1809
1811 Usage:\\
1810 Usage:\\
1812 %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...
1811 %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...
1813
1812
1814 Options:
1813 Options:
1815
1814
1816 -r: use 'raw' input. By default, the 'processed' history is used,
1815 -r: use 'raw' input. By default, the 'processed' history is used,
1817 so that magics are loaded in their transformed version to valid
1816 so that magics are loaded in their transformed version to valid
1818 Python. If this option is given, the raw input as typed as the
1817 Python. If this option is given, the raw input as typed as the
1819 command line is used instead.
1818 command line is used instead.
1820
1819
1821 This will define a global variable called `name` which is a string
1820 This will define a global variable called `name` which is a string
1822 made of joining the slices and lines you specify (n1,n2,... numbers
1821 made of joining the slices and lines you specify (n1,n2,... numbers
1823 above) from your input history into a single string. This variable
1822 above) from your input history into a single string. This variable
1824 acts like an automatic function which re-executes those lines as if
1823 acts like an automatic function which re-executes those lines as if
1825 you had typed them. You just type 'name' at the prompt and the code
1824 you had typed them. You just type 'name' at the prompt and the code
1826 executes.
1825 executes.
1827
1826
1828 The notation for indicating number ranges is: n1-n2 means 'use line
1827 The notation for indicating number ranges is: n1-n2 means 'use line
1829 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1828 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1830 using the lines numbered 5,6 and 7.
1829 using the lines numbered 5,6 and 7.
1831
1830
1832 Note: as a 'hidden' feature, you can also use traditional python slice
1831 Note: as a 'hidden' feature, you can also use traditional python slice
1833 notation, where N:M means numbers N through M-1.
1832 notation, where N:M means numbers N through M-1.
1834
1833
1835 For example, if your history contains (%hist prints it):
1834 For example, if your history contains (%hist prints it):
1836
1835
1837 44: x=1\\
1836 44: x=1\\
1838 45: y=3\\
1837 45: y=3\\
1839 46: z=x+y\\
1838 46: z=x+y\\
1840 47: print x\\
1839 47: print x\\
1841 48: a=5\\
1840 48: a=5\\
1842 49: print 'x',x,'y',y\\
1841 49: print 'x',x,'y',y\\
1843
1842
1844 you can create a macro with lines 44 through 47 (included) and line 49
1843 you can create a macro with lines 44 through 47 (included) and line 49
1845 called my_macro with:
1844 called my_macro with:
1846
1845
1847 In [51]: %macro my_macro 44-47 49
1846 In [51]: %macro my_macro 44-47 49
1848
1847
1849 Now, typing `my_macro` (without quotes) will re-execute all this code
1848 Now, typing `my_macro` (without quotes) will re-execute all this code
1850 in one pass.
1849 in one pass.
1851
1850
1852 You don't need to give the line-numbers in order, and any given line
1851 You don't need to give the line-numbers in order, and any given line
1853 number can appear multiple times. You can assemble macros with any
1852 number can appear multiple times. You can assemble macros with any
1854 lines from your input history in any order.
1853 lines from your input history in any order.
1855
1854
1856 The macro is a simple object which holds its value in an attribute,
1855 The macro is a simple object which holds its value in an attribute,
1857 but IPython's display system checks for macros and executes them as
1856 but IPython's display system checks for macros and executes them as
1858 code instead of printing them when you type their name.
1857 code instead of printing them when you type their name.
1859
1858
1860 You can view a macro's contents by explicitly printing it with:
1859 You can view a macro's contents by explicitly printing it with:
1861
1860
1862 'print macro_name'.
1861 'print macro_name'.
1863
1862
1864 For one-off cases which DON'T contain magic function calls in them you
1863 For one-off cases which DON'T contain magic function calls in them you
1865 can obtain similar results by explicitly executing slices from your
1864 can obtain similar results by explicitly executing slices from your
1866 input history with:
1865 input history with:
1867
1866
1868 In [60]: exec In[44:48]+In[49]"""
1867 In [60]: exec In[44:48]+In[49]"""
1869
1868
1870 opts,args = self.parse_options(parameter_s,'r',mode='list')
1869 opts,args = self.parse_options(parameter_s,'r',mode='list')
1871 name,ranges = args[0], args[1:]
1870 name,ranges = args[0], args[1:]
1872 #print 'rng',ranges # dbg
1871 #print 'rng',ranges # dbg
1873 lines = self.extract_input_slices(ranges,opts.has_key('r'))
1872 lines = self.extract_input_slices(ranges,opts.has_key('r'))
1874 macro = Macro(lines)
1873 macro = Macro(lines)
1875 self.shell.user_ns.update({name:macro})
1874 self.shell.user_ns.update({name:macro})
1876 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1875 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1877 print 'Macro contents:'
1876 print 'Macro contents:'
1878 print macro,
1877 print macro,
1879
1878
1880 def magic_save(self,parameter_s = ''):
1879 def magic_save(self,parameter_s = ''):
1881 """Save a set of lines to a given filename.
1880 """Save a set of lines to a given filename.
1882
1881
1883 Usage:\\
1882 Usage:\\
1884 %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...
1883 %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...
1885
1884
1886 Options:
1885 Options:
1887
1886
1888 -r: use 'raw' input. By default, the 'processed' history is used,
1887 -r: use 'raw' input. By default, the 'processed' history is used,
1889 so that magics are loaded in their transformed version to valid
1888 so that magics are loaded in their transformed version to valid
1890 Python. If this option is given, the raw input as typed as the
1889 Python. If this option is given, the raw input as typed as the
1891 command line is used instead.
1890 command line is used instead.
1892
1891
1893 This function uses the same syntax as %macro for line extraction, but
1892 This function uses the same syntax as %macro for line extraction, but
1894 instead of creating a macro it saves the resulting string to the
1893 instead of creating a macro it saves the resulting string to the
1895 filename you specify.
1894 filename you specify.
1896
1895
1897 It adds a '.py' extension to the file if you don't do so yourself, and
1896 It adds a '.py' extension to the file if you don't do so yourself, and
1898 it asks for confirmation before overwriting existing files."""
1897 it asks for confirmation before overwriting existing files."""
1899
1898
1900 opts,args = self.parse_options(parameter_s,'r',mode='list')
1899 opts,args = self.parse_options(parameter_s,'r',mode='list')
1901 fname,ranges = args[0], args[1:]
1900 fname,ranges = args[0], args[1:]
1902 if not fname.endswith('.py'):
1901 if not fname.endswith('.py'):
1903 fname += '.py'
1902 fname += '.py'
1904 if os.path.isfile(fname):
1903 if os.path.isfile(fname):
1905 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1904 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1906 if ans.lower() not in ['y','yes']:
1905 if ans.lower() not in ['y','yes']:
1907 print 'Operation cancelled.'
1906 print 'Operation cancelled.'
1908 return
1907 return
1909 cmds = ''.join(self.extract_input_slices(ranges,opts.has_key('r')))
1908 cmds = ''.join(self.extract_input_slices(ranges,opts.has_key('r')))
1910 f = file(fname,'w')
1909 f = file(fname,'w')
1911 f.write(cmds)
1910 f.write(cmds)
1912 f.close()
1911 f.close()
1913 print 'The following commands were written to file `%s`:' % fname
1912 print 'The following commands were written to file `%s`:' % fname
1914 print cmds
1913 print cmds
1915
1914
1916 def _edit_macro(self,mname,macro):
1915 def _edit_macro(self,mname,macro):
1917 """open an editor with the macro data in a file"""
1916 """open an editor with the macro data in a file"""
1918 filename = self.shell.mktempfile(macro.value)
1917 filename = self.shell.mktempfile(macro.value)
1919 self.shell.hooks.editor(filename)
1918 self.shell.hooks.editor(filename)
1920
1919
1921 # and make a new macro object, to replace the old one
1920 # and make a new macro object, to replace the old one
1922 mfile = open(filename)
1921 mfile = open(filename)
1923 mvalue = mfile.read()
1922 mvalue = mfile.read()
1924 mfile.close()
1923 mfile.close()
1925 self.shell.user_ns[mname] = Macro(mvalue)
1924 self.shell.user_ns[mname] = Macro(mvalue)
1926
1925
1927 def magic_ed(self,parameter_s=''):
1926 def magic_ed(self,parameter_s=''):
1928 """Alias to %edit."""
1927 """Alias to %edit."""
1929 return self.magic_edit(parameter_s)
1928 return self.magic_edit(parameter_s)
1930
1929
1931 def magic_edit(self,parameter_s='',last_call=['','']):
1930 def magic_edit(self,parameter_s='',last_call=['','']):
1932 """Bring up an editor and execute the resulting code.
1931 """Bring up an editor and execute the resulting code.
1933
1932
1934 Usage:
1933 Usage:
1935 %edit [options] [args]
1934 %edit [options] [args]
1936
1935
1937 %edit runs IPython's editor hook. The default version of this hook is
1936 %edit runs IPython's editor hook. The default version of this hook is
1938 set to call the __IPYTHON__.rc.editor command. This is read from your
1937 set to call the __IPYTHON__.rc.editor command. This is read from your
1939 environment variable $EDITOR. If this isn't found, it will default to
1938 environment variable $EDITOR. If this isn't found, it will default to
1940 vi under Linux/Unix and to notepad under Windows. See the end of this
1939 vi under Linux/Unix and to notepad under Windows. See the end of this
1941 docstring for how to change the editor hook.
1940 docstring for how to change the editor hook.
1942
1941
1943 You can also set the value of this editor via the command line option
1942 You can also set the value of this editor via the command line option
1944 '-editor' or in your ipythonrc file. This is useful if you wish to use
1943 '-editor' or in your ipythonrc file. This is useful if you wish to use
1945 specifically for IPython an editor different from your typical default
1944 specifically for IPython an editor different from your typical default
1946 (and for Windows users who typically don't set environment variables).
1945 (and for Windows users who typically don't set environment variables).
1947
1946
1948 This command allows you to conveniently edit multi-line code right in
1947 This command allows you to conveniently edit multi-line code right in
1949 your IPython session.
1948 your IPython session.
1950
1949
1951 If called without arguments, %edit opens up an empty editor with a
1950 If called without arguments, %edit opens up an empty editor with a
1952 temporary file and will execute the contents of this file when you
1951 temporary file and will execute the contents of this file when you
1953 close it (don't forget to save it!).
1952 close it (don't forget to save it!).
1954
1953
1955
1954
1956 Options:
1955 Options:
1957
1956
1958 -n <number>: open the editor at a specified line number. By default,
1957 -n <number>: open the editor at a specified line number. By default,
1959 the IPython editor hook uses the unix syntax 'editor +N filename', but
1958 the IPython editor hook uses the unix syntax 'editor +N filename', but
1960 you can configure this by providing your own modified hook if your
1959 you can configure this by providing your own modified hook if your
1961 favorite editor supports line-number specifications with a different
1960 favorite editor supports line-number specifications with a different
1962 syntax.
1961 syntax.
1963
1962
1964 -p: this will call the editor with the same data as the previous time
1963 -p: this will call the editor with the same data as the previous time
1965 it was used, regardless of how long ago (in your current session) it
1964 it was used, regardless of how long ago (in your current session) it
1966 was.
1965 was.
1967
1966
1968 -r: use 'raw' input. This option only applies to input taken from the
1967 -r: use 'raw' input. This option only applies to input taken from the
1969 user's history. By default, the 'processed' history is used, so that
1968 user's history. By default, the 'processed' history is used, so that
1970 magics are loaded in their transformed version to valid Python. If
1969 magics are loaded in their transformed version to valid Python. If
1971 this option is given, the raw input as typed as the command line is
1970 this option is given, the raw input as typed as the command line is
1972 used instead. When you exit the editor, it will be executed by
1971 used instead. When you exit the editor, it will be executed by
1973 IPython's own processor.
1972 IPython's own processor.
1974
1973
1975 -x: do not execute the edited code immediately upon exit. This is
1974 -x: do not execute the edited code immediately upon exit. This is
1976 mainly useful if you are editing programs which need to be called with
1975 mainly useful if you are editing programs which need to be called with
1977 command line arguments, which you can then do using %run.
1976 command line arguments, which you can then do using %run.
1978
1977
1979
1978
1980 Arguments:
1979 Arguments:
1981
1980
1982 If arguments are given, the following possibilites exist:
1981 If arguments are given, the following possibilites exist:
1983
1982
1984 - The arguments are numbers or pairs of colon-separated numbers (like
1983 - The arguments are numbers or pairs of colon-separated numbers (like
1985 1 4:8 9). These are interpreted as lines of previous input to be
1984 1 4:8 9). These are interpreted as lines of previous input to be
1986 loaded into the editor. The syntax is the same of the %macro command.
1985 loaded into the editor. The syntax is the same of the %macro command.
1987
1986
1988 - If the argument doesn't start with a number, it is evaluated as a
1987 - If the argument doesn't start with a number, it is evaluated as a
1989 variable and its contents loaded into the editor. You can thus edit
1988 variable and its contents loaded into the editor. You can thus edit
1990 any string which contains python code (including the result of
1989 any string which contains python code (including the result of
1991 previous edits).
1990 previous edits).
1992
1991
1993 - If the argument is the name of an object (other than a string),
1992 - If the argument is the name of an object (other than a string),
1994 IPython will try to locate the file where it was defined and open the
1993 IPython will try to locate the file where it was defined and open the
1995 editor at the point where it is defined. You can use `%edit function`
1994 editor at the point where it is defined. You can use `%edit function`
1996 to load an editor exactly at the point where 'function' is defined,
1995 to load an editor exactly at the point where 'function' is defined,
1997 edit it and have the file be executed automatically.
1996 edit it and have the file be executed automatically.
1998
1997
1999 If the object is a macro (see %macro for details), this opens up your
1998 If the object is a macro (see %macro for details), this opens up your
2000 specified editor with a temporary file containing the macro's data.
1999 specified editor with a temporary file containing the macro's data.
2001 Upon exit, the macro is reloaded with the contents of the file.
2000 Upon exit, the macro is reloaded with the contents of the file.
2002
2001
2003 Note: opening at an exact line is only supported under Unix, and some
2002 Note: opening at an exact line is only supported under Unix, and some
2004 editors (like kedit and gedit up to Gnome 2.8) do not understand the
2003 editors (like kedit and gedit up to Gnome 2.8) do not understand the
2005 '+NUMBER' parameter necessary for this feature. Good editors like
2004 '+NUMBER' parameter necessary for this feature. Good editors like
2006 (X)Emacs, vi, jed, pico and joe all do.
2005 (X)Emacs, vi, jed, pico and joe all do.
2007
2006
2008 - If the argument is not found as a variable, IPython will look for a
2007 - If the argument is not found as a variable, IPython will look for a
2009 file with that name (adding .py if necessary) and load it into the
2008 file with that name (adding .py if necessary) and load it into the
2010 editor. It will execute its contents with execfile() when you exit,
2009 editor. It will execute its contents with execfile() when you exit,
2011 loading any code in the file into your interactive namespace.
2010 loading any code in the file into your interactive namespace.
2012
2011
2013 After executing your code, %edit will return as output the code you
2012 After executing your code, %edit will return as output the code you
2014 typed in the editor (except when it was an existing file). This way
2013 typed in the editor (except when it was an existing file). This way
2015 you can reload the code in further invocations of %edit as a variable,
2014 you can reload the code in further invocations of %edit as a variable,
2016 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
2015 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
2017 the output.
2016 the output.
2018
2017
2019 Note that %edit is also available through the alias %ed.
2018 Note that %edit is also available through the alias %ed.
2020
2019
2021 This is an example of creating a simple function inside the editor and
2020 This is an example of creating a simple function inside the editor and
2022 then modifying it. First, start up the editor:
2021 then modifying it. First, start up the editor:
2023
2022
2024 In [1]: ed\\
2023 In [1]: ed\\
2025 Editing... done. Executing edited code...\\
2024 Editing... done. Executing edited code...\\
2026 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
2025 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
2027
2026
2028 We can then call the function foo():
2027 We can then call the function foo():
2029
2028
2030 In [2]: foo()\\
2029 In [2]: foo()\\
2031 foo() was defined in an editing session
2030 foo() was defined in an editing session
2032
2031
2033 Now we edit foo. IPython automatically loads the editor with the
2032 Now we edit foo. IPython automatically loads the editor with the
2034 (temporary) file where foo() was previously defined:
2033 (temporary) file where foo() was previously defined:
2035
2034
2036 In [3]: ed foo\\
2035 In [3]: ed foo\\
2037 Editing... done. Executing edited code...
2036 Editing... done. Executing edited code...
2038
2037
2039 And if we call foo() again we get the modified version:
2038 And if we call foo() again we get the modified version:
2040
2039
2041 In [4]: foo()\\
2040 In [4]: foo()\\
2042 foo() has now been changed!
2041 foo() has now been changed!
2043
2042
2044 Here is an example of how to edit a code snippet successive
2043 Here is an example of how to edit a code snippet successive
2045 times. First we call the editor:
2044 times. First we call the editor:
2046
2045
2047 In [8]: ed\\
2046 In [8]: ed\\
2048 Editing... done. Executing edited code...\\
2047 Editing... done. Executing edited code...\\
2049 hello\\
2048 hello\\
2050 Out[8]: "print 'hello'\\n"
2049 Out[8]: "print 'hello'\\n"
2051
2050
2052 Now we call it again with the previous output (stored in _):
2051 Now we call it again with the previous output (stored in _):
2053
2052
2054 In [9]: ed _\\
2053 In [9]: ed _\\
2055 Editing... done. Executing edited code...\\
2054 Editing... done. Executing edited code...\\
2056 hello world\\
2055 hello world\\
2057 Out[9]: "print 'hello world'\\n"
2056 Out[9]: "print 'hello world'\\n"
2058
2057
2059 Now we call it with the output #8 (stored in _8, also as Out[8]):
2058 Now we call it with the output #8 (stored in _8, also as Out[8]):
2060
2059
2061 In [10]: ed _8\\
2060 In [10]: ed _8\\
2062 Editing... done. Executing edited code...\\
2061 Editing... done. Executing edited code...\\
2063 hello again\\
2062 hello again\\
2064 Out[10]: "print 'hello again'\\n"
2063 Out[10]: "print 'hello again'\\n"
2065
2064
2066
2065
2067 Changing the default editor hook:
2066 Changing the default editor hook:
2068
2067
2069 If you wish to write your own editor hook, you can put it in a
2068 If you wish to write your own editor hook, you can put it in a
2070 configuration file which you load at startup time. The default hook
2069 configuration file which you load at startup time. The default hook
2071 is defined in the IPython.hooks module, and you can use that as a
2070 is defined in the IPython.hooks module, and you can use that as a
2072 starting example for further modifications. That file also has
2071 starting example for further modifications. That file also has
2073 general instructions on how to set a new hook for use once you've
2072 general instructions on how to set a new hook for use once you've
2074 defined it."""
2073 defined it."""
2075
2074
2076 # FIXME: This function has become a convoluted mess. It needs a
2075 # FIXME: This function has become a convoluted mess. It needs a
2077 # ground-up rewrite with clean, simple logic.
2076 # ground-up rewrite with clean, simple logic.
2078
2077
2079 def make_filename(arg):
2078 def make_filename(arg):
2080 "Make a filename from the given args"
2079 "Make a filename from the given args"
2081 try:
2080 try:
2082 filename = get_py_filename(arg)
2081 filename = get_py_filename(arg)
2083 except IOError:
2082 except IOError:
2084 if args.endswith('.py'):
2083 if args.endswith('.py'):
2085 filename = arg
2084 filename = arg
2086 else:
2085 else:
2087 filename = None
2086 filename = None
2088 return filename
2087 return filename
2089
2088
2090 # custom exceptions
2089 # custom exceptions
2091 class DataIsObject(Exception): pass
2090 class DataIsObject(Exception): pass
2092
2091
2093 opts,args = self.parse_options(parameter_s,'prxn:')
2092 opts,args = self.parse_options(parameter_s,'prxn:')
2094 # Set a few locals from the options for convenience:
2093 # Set a few locals from the options for convenience:
2095 opts_p = opts.has_key('p')
2094 opts_p = opts.has_key('p')
2096 opts_r = opts.has_key('r')
2095 opts_r = opts.has_key('r')
2097
2096
2098 # Default line number value
2097 # Default line number value
2099 lineno = opts.get('n',None)
2098 lineno = opts.get('n',None)
2100
2099
2101 if opts_p:
2100 if opts_p:
2102 args = '_%s' % last_call[0]
2101 args = '_%s' % last_call[0]
2103 if not self.shell.user_ns.has_key(args):
2102 if not self.shell.user_ns.has_key(args):
2104 args = last_call[1]
2103 args = last_call[1]
2105
2104
2106 # use last_call to remember the state of the previous call, but don't
2105 # use last_call to remember the state of the previous call, but don't
2107 # let it be clobbered by successive '-p' calls.
2106 # let it be clobbered by successive '-p' calls.
2108 try:
2107 try:
2109 last_call[0] = self.shell.outputcache.prompt_count
2108 last_call[0] = self.shell.outputcache.prompt_count
2110 if not opts_p:
2109 if not opts_p:
2111 last_call[1] = parameter_s
2110 last_call[1] = parameter_s
2112 except:
2111 except:
2113 pass
2112 pass
2114
2113
2115 # by default this is done with temp files, except when the given
2114 # by default this is done with temp files, except when the given
2116 # arg is a filename
2115 # arg is a filename
2117 use_temp = 1
2116 use_temp = 1
2118
2117
2119 if re.match(r'\d',args):
2118 if re.match(r'\d',args):
2120 # Mode where user specifies ranges of lines, like in %macro.
2119 # Mode where user specifies ranges of lines, like in %macro.
2121 # This means that you can't edit files whose names begin with
2120 # This means that you can't edit files whose names begin with
2122 # numbers this way. Tough.
2121 # numbers this way. Tough.
2123 ranges = args.split()
2122 ranges = args.split()
2124 data = ''.join(self.extract_input_slices(ranges,opts_r))
2123 data = ''.join(self.extract_input_slices(ranges,opts_r))
2125 elif args.endswith('.py'):
2124 elif args.endswith('.py'):
2126 filename = make_filename(args)
2125 filename = make_filename(args)
2127 data = ''
2126 data = ''
2128 use_temp = 0
2127 use_temp = 0
2129 elif args:
2128 elif args:
2130 try:
2129 try:
2131 # Load the parameter given as a variable. If not a string,
2130 # Load the parameter given as a variable. If not a string,
2132 # process it as an object instead (below)
2131 # process it as an object instead (below)
2133
2132
2134 #print '*** args',args,'type',type(args) # dbg
2133 #print '*** args',args,'type',type(args) # dbg
2135 data = eval(args,self.shell.user_ns)
2134 data = eval(args,self.shell.user_ns)
2136 if not type(data) in StringTypes:
2135 if not type(data) in StringTypes:
2137 raise DataIsObject
2136 raise DataIsObject
2138
2137
2139 except (NameError,SyntaxError):
2138 except (NameError,SyntaxError):
2140 # given argument is not a variable, try as a filename
2139 # given argument is not a variable, try as a filename
2141 filename = make_filename(args)
2140 filename = make_filename(args)
2142 if filename is None:
2141 if filename is None:
2143 warn("Argument given (%s) can't be found as a variable "
2142 warn("Argument given (%s) can't be found as a variable "
2144 "or as a filename." % args)
2143 "or as a filename." % args)
2145 return
2144 return
2146
2145
2147 data = ''
2146 data = ''
2148 use_temp = 0
2147 use_temp = 0
2149 except DataIsObject:
2148 except DataIsObject:
2150
2149
2151 # macros have a special edit function
2150 # macros have a special edit function
2152 if isinstance(data,Macro):
2151 if isinstance(data,Macro):
2153 self._edit_macro(args,data)
2152 self._edit_macro(args,data)
2154 return
2153 return
2155
2154
2156 # For objects, try to edit the file where they are defined
2155 # For objects, try to edit the file where they are defined
2157 try:
2156 try:
2158 filename = inspect.getabsfile(data)
2157 filename = inspect.getabsfile(data)
2159 datafile = 1
2158 datafile = 1
2160 except TypeError:
2159 except TypeError:
2161 filename = make_filename(args)
2160 filename = make_filename(args)
2162 datafile = 1
2161 datafile = 1
2163 warn('Could not find file where `%s` is defined.\n'
2162 warn('Could not find file where `%s` is defined.\n'
2164 'Opening a file named `%s`' % (args,filename))
2163 'Opening a file named `%s`' % (args,filename))
2165 # Now, make sure we can actually read the source (if it was in
2164 # Now, make sure we can actually read the source (if it was in
2166 # a temp file it's gone by now).
2165 # a temp file it's gone by now).
2167 if datafile:
2166 if datafile:
2168 try:
2167 try:
2169 if lineno is None:
2168 if lineno is None:
2170 lineno = inspect.getsourcelines(data)[1]
2169 lineno = inspect.getsourcelines(data)[1]
2171 except IOError:
2170 except IOError:
2172 filename = make_filename(args)
2171 filename = make_filename(args)
2173 if filename is None:
2172 if filename is None:
2174 warn('The file `%s` where `%s` was defined cannot '
2173 warn('The file `%s` where `%s` was defined cannot '
2175 'be read.' % (filename,data))
2174 'be read.' % (filename,data))
2176 return
2175 return
2177 use_temp = 0
2176 use_temp = 0
2178 else:
2177 else:
2179 data = ''
2178 data = ''
2180
2179
2181 if use_temp:
2180 if use_temp:
2182 filename = self.shell.mktempfile(data)
2181 filename = self.shell.mktempfile(data)
2183 print 'IPython will make a temporary file named:',filename
2182 print 'IPython will make a temporary file named:',filename
2184
2183
2185 # do actual editing here
2184 # do actual editing here
2186 print 'Editing...',
2185 print 'Editing...',
2187 sys.stdout.flush()
2186 sys.stdout.flush()
2188 self.shell.hooks.editor(filename,lineno)
2187 self.shell.hooks.editor(filename,lineno)
2189 if opts.has_key('x'): # -x prevents actual execution
2188 if opts.has_key('x'): # -x prevents actual execution
2190 print
2189 print
2191 else:
2190 else:
2192 print 'done. Executing edited code...'
2191 print 'done. Executing edited code...'
2193 if opts_r:
2192 if opts_r:
2194 self.shell.runlines(file_read(filename))
2193 self.shell.runlines(file_read(filename))
2195 else:
2194 else:
2196 self.shell.safe_execfile(filename,self.shell.user_ns)
2195 self.shell.safe_execfile(filename,self.shell.user_ns)
2197 if use_temp:
2196 if use_temp:
2198 try:
2197 try:
2199 return open(filename).read()
2198 return open(filename).read()
2200 except IOError,msg:
2199 except IOError,msg:
2201 if msg.filename == filename:
2200 if msg.filename == filename:
2202 warn('File not found. Did you forget to save?')
2201 warn('File not found. Did you forget to save?')
2203 return
2202 return
2204 else:
2203 else:
2205 self.shell.showtraceback()
2204 self.shell.showtraceback()
2206
2205
2207 def magic_xmode(self,parameter_s = ''):
2206 def magic_xmode(self,parameter_s = ''):
2208 """Switch modes for the exception handlers.
2207 """Switch modes for the exception handlers.
2209
2208
2210 Valid modes: Plain, Context and Verbose.
2209 Valid modes: Plain, Context and Verbose.
2211
2210
2212 If called without arguments, acts as a toggle."""
2211 If called without arguments, acts as a toggle."""
2213
2212
2214 def xmode_switch_err(name):
2213 def xmode_switch_err(name):
2215 warn('Error changing %s exception modes.\n%s' %
2214 warn('Error changing %s exception modes.\n%s' %
2216 (name,sys.exc_info()[1]))
2215 (name,sys.exc_info()[1]))
2217
2216
2218 shell = self.shell
2217 shell = self.shell
2219 new_mode = parameter_s.strip().capitalize()
2218 new_mode = parameter_s.strip().capitalize()
2220 try:
2219 try:
2221 shell.InteractiveTB.set_mode(mode=new_mode)
2220 shell.InteractiveTB.set_mode(mode=new_mode)
2222 print 'Exception reporting mode:',shell.InteractiveTB.mode
2221 print 'Exception reporting mode:',shell.InteractiveTB.mode
2223 except:
2222 except:
2224 xmode_switch_err('user')
2223 xmode_switch_err('user')
2225
2224
2226 # threaded shells use a special handler in sys.excepthook
2225 # threaded shells use a special handler in sys.excepthook
2227 if shell.isthreaded:
2226 if shell.isthreaded:
2228 try:
2227 try:
2229 shell.sys_excepthook.set_mode(mode=new_mode)
2228 shell.sys_excepthook.set_mode(mode=new_mode)
2230 except:
2229 except:
2231 xmode_switch_err('threaded')
2230 xmode_switch_err('threaded')
2232
2231
2233 def magic_colors(self,parameter_s = ''):
2232 def magic_colors(self,parameter_s = ''):
2234 """Switch color scheme for prompts, info system and exception handlers.
2233 """Switch color scheme for prompts, info system and exception handlers.
2235
2234
2236 Currently implemented schemes: NoColor, Linux, LightBG.
2235 Currently implemented schemes: NoColor, Linux, LightBG.
2237
2236
2238 Color scheme names are not case-sensitive."""
2237 Color scheme names are not case-sensitive."""
2239
2238
2240 def color_switch_err(name):
2239 def color_switch_err(name):
2241 warn('Error changing %s color schemes.\n%s' %
2240 warn('Error changing %s color schemes.\n%s' %
2242 (name,sys.exc_info()[1]))
2241 (name,sys.exc_info()[1]))
2243
2242
2244
2243
2245 new_scheme = parameter_s.strip()
2244 new_scheme = parameter_s.strip()
2246 if not new_scheme:
2245 if not new_scheme:
2247 print 'You must specify a color scheme.'
2246 print 'You must specify a color scheme.'
2248 return
2247 return
2249 import IPython.rlineimpl as readline
2248 import IPython.rlineimpl as readline
2250 if not readline.have_readline:
2249 if not readline.have_readline:
2251 msg = """\
2250 msg = """\
2252 Proper color support under MS Windows requires the pyreadline library.
2251 Proper color support under MS Windows requires the pyreadline library.
2253 You can find it at:
2252 You can find it at:
2254 http://ipython.scipy.org/moin/PyReadline/Intro
2253 http://ipython.scipy.org/moin/PyReadline/Intro
2255 Gary's readline needs the ctypes module, from:
2254 Gary's readline needs the ctypes module, from:
2256 http://starship.python.net/crew/theller/ctypes
2255 http://starship.python.net/crew/theller/ctypes
2257 (Note that ctypes is already part of Python versions 2.5 and newer).
2256 (Note that ctypes is already part of Python versions 2.5 and newer).
2258
2257
2259 Defaulting color scheme to 'NoColor'"""
2258 Defaulting color scheme to 'NoColor'"""
2260 new_scheme = 'NoColor'
2259 new_scheme = 'NoColor'
2261 warn(msg)
2260 warn(msg)
2262 # local shortcut
2261 # local shortcut
2263 shell = self.shell
2262 shell = self.shell
2264
2263
2265 # Set prompt colors
2264 # Set prompt colors
2266 try:
2265 try:
2267 shell.outputcache.set_colors(new_scheme)
2266 shell.outputcache.set_colors(new_scheme)
2268 except:
2267 except:
2269 color_switch_err('prompt')
2268 color_switch_err('prompt')
2270 else:
2269 else:
2271 shell.rc.colors = \
2270 shell.rc.colors = \
2272 shell.outputcache.color_table.active_scheme_name
2271 shell.outputcache.color_table.active_scheme_name
2273 # Set exception colors
2272 # Set exception colors
2274 try:
2273 try:
2275 shell.InteractiveTB.set_colors(scheme = new_scheme)
2274 shell.InteractiveTB.set_colors(scheme = new_scheme)
2276 shell.SyntaxTB.set_colors(scheme = new_scheme)
2275 shell.SyntaxTB.set_colors(scheme = new_scheme)
2277 except:
2276 except:
2278 color_switch_err('exception')
2277 color_switch_err('exception')
2279
2278
2280 # threaded shells use a verbose traceback in sys.excepthook
2279 # threaded shells use a verbose traceback in sys.excepthook
2281 if shell.isthreaded:
2280 if shell.isthreaded:
2282 try:
2281 try:
2283 shell.sys_excepthook.set_colors(scheme=new_scheme)
2282 shell.sys_excepthook.set_colors(scheme=new_scheme)
2284 except:
2283 except:
2285 color_switch_err('system exception handler')
2284 color_switch_err('system exception handler')
2286
2285
2287 # Set info (for 'object?') colors
2286 # Set info (for 'object?') colors
2288 if shell.rc.color_info:
2287 if shell.rc.color_info:
2289 try:
2288 try:
2290 shell.inspector.set_active_scheme(new_scheme)
2289 shell.inspector.set_active_scheme(new_scheme)
2291 except:
2290 except:
2292 color_switch_err('object inspector')
2291 color_switch_err('object inspector')
2293 else:
2292 else:
2294 shell.inspector.set_active_scheme('NoColor')
2293 shell.inspector.set_active_scheme('NoColor')
2295
2294
2296 def magic_color_info(self,parameter_s = ''):
2295 def magic_color_info(self,parameter_s = ''):
2297 """Toggle color_info.
2296 """Toggle color_info.
2298
2297
2299 The color_info configuration parameter controls whether colors are
2298 The color_info configuration parameter controls whether colors are
2300 used for displaying object details (by things like %psource, %pfile or
2299 used for displaying object details (by things like %psource, %pfile or
2301 the '?' system). This function toggles this value with each call.
2300 the '?' system). This function toggles this value with each call.
2302
2301
2303 Note that unless you have a fairly recent pager (less works better
2302 Note that unless you have a fairly recent pager (less works better
2304 than more) in your system, using colored object information displays
2303 than more) in your system, using colored object information displays
2305 will not work properly. Test it and see."""
2304 will not work properly. Test it and see."""
2306
2305
2307 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2306 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2308 self.magic_colors(self.shell.rc.colors)
2307 self.magic_colors(self.shell.rc.colors)
2309 print 'Object introspection functions have now coloring:',
2308 print 'Object introspection functions have now coloring:',
2310 print ['OFF','ON'][self.shell.rc.color_info]
2309 print ['OFF','ON'][self.shell.rc.color_info]
2311
2310
2312 def magic_Pprint(self, parameter_s=''):
2311 def magic_Pprint(self, parameter_s=''):
2313 """Toggle pretty printing on/off."""
2312 """Toggle pretty printing on/off."""
2314
2313
2315 self.shell.rc.pprint = 1 - self.shell.rc.pprint
2314 self.shell.rc.pprint = 1 - self.shell.rc.pprint
2316 print 'Pretty printing has been turned', \
2315 print 'Pretty printing has been turned', \
2317 ['OFF','ON'][self.shell.rc.pprint]
2316 ['OFF','ON'][self.shell.rc.pprint]
2318
2317
2319 def magic_exit(self, parameter_s=''):
2318 def magic_exit(self, parameter_s=''):
2320 """Exit IPython, confirming if configured to do so.
2319 """Exit IPython, confirming if configured to do so.
2321
2320
2322 You can configure whether IPython asks for confirmation upon exit by
2321 You can configure whether IPython asks for confirmation upon exit by
2323 setting the confirm_exit flag in the ipythonrc file."""
2322 setting the confirm_exit flag in the ipythonrc file."""
2324
2323
2325 self.shell.exit()
2324 self.shell.exit()
2326
2325
2327 def magic_quit(self, parameter_s=''):
2326 def magic_quit(self, parameter_s=''):
2328 """Exit IPython, confirming if configured to do so (like %exit)"""
2327 """Exit IPython, confirming if configured to do so (like %exit)"""
2329
2328
2330 self.shell.exit()
2329 self.shell.exit()
2331
2330
2332 def magic_Exit(self, parameter_s=''):
2331 def magic_Exit(self, parameter_s=''):
2333 """Exit IPython without confirmation."""
2332 """Exit IPython without confirmation."""
2334
2333
2335 self.shell.exit_now = True
2334 self.shell.exit_now = True
2336
2335
2337 def magic_Quit(self, parameter_s=''):
2336 def magic_Quit(self, parameter_s=''):
2338 """Exit IPython without confirmation (like %Exit)."""
2337 """Exit IPython without confirmation (like %Exit)."""
2339
2338
2340 self.shell.exit_now = True
2339 self.shell.exit_now = True
2341
2340
2342 #......................................................................
2341 #......................................................................
2343 # Functions to implement unix shell-type things
2342 # Functions to implement unix shell-type things
2344
2343
2345 def magic_alias(self, parameter_s = ''):
2344 def magic_alias(self, parameter_s = ''):
2346 """Define an alias for a system command.
2345 """Define an alias for a system command.
2347
2346
2348 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2347 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2349
2348
2350 Then, typing 'alias_name params' will execute the system command 'cmd
2349 Then, typing 'alias_name params' will execute the system command 'cmd
2351 params' (from your underlying operating system).
2350 params' (from your underlying operating system).
2352
2351
2353 Aliases have lower precedence than magic functions and Python normal
2352 Aliases have lower precedence than magic functions and Python normal
2354 variables, so if 'foo' is both a Python variable and an alias, the
2353 variables, so if 'foo' is both a Python variable and an alias, the
2355 alias can not be executed until 'del foo' removes the Python variable.
2354 alias can not be executed until 'del foo' removes the Python variable.
2356
2355
2357 You can use the %l specifier in an alias definition to represent the
2356 You can use the %l specifier in an alias definition to represent the
2358 whole line when the alias is called. For example:
2357 whole line when the alias is called. For example:
2359
2358
2360 In [2]: alias all echo "Input in brackets: <%l>"\\
2359 In [2]: alias all echo "Input in brackets: <%l>"\\
2361 In [3]: all hello world\\
2360 In [3]: all hello world\\
2362 Input in brackets: <hello world>
2361 Input in brackets: <hello world>
2363
2362
2364 You can also define aliases with parameters using %s specifiers (one
2363 You can also define aliases with parameters using %s specifiers (one
2365 per parameter):
2364 per parameter):
2366
2365
2367 In [1]: alias parts echo first %s second %s\\
2366 In [1]: alias parts echo first %s second %s\\
2368 In [2]: %parts A B\\
2367 In [2]: %parts A B\\
2369 first A second B\\
2368 first A second B\\
2370 In [3]: %parts A\\
2369 In [3]: %parts A\\
2371 Incorrect number of arguments: 2 expected.\\
2370 Incorrect number of arguments: 2 expected.\\
2372 parts is an alias to: 'echo first %s second %s'
2371 parts is an alias to: 'echo first %s second %s'
2373
2372
2374 Note that %l and %s are mutually exclusive. You can only use one or
2373 Note that %l and %s are mutually exclusive. You can only use one or
2375 the other in your aliases.
2374 the other in your aliases.
2376
2375
2377 Aliases expand Python variables just like system calls using ! or !!
2376 Aliases expand Python variables just like system calls using ! or !!
2378 do: all expressions prefixed with '$' get expanded. For details of
2377 do: all expressions prefixed with '$' get expanded. For details of
2379 the semantic rules, see PEP-215:
2378 the semantic rules, see PEP-215:
2380 http://www.python.org/peps/pep-0215.html. This is the library used by
2379 http://www.python.org/peps/pep-0215.html. This is the library used by
2381 IPython for variable expansion. If you want to access a true shell
2380 IPython for variable expansion. If you want to access a true shell
2382 variable, an extra $ is necessary to prevent its expansion by IPython:
2381 variable, an extra $ is necessary to prevent its expansion by IPython:
2383
2382
2384 In [6]: alias show echo\\
2383 In [6]: alias show echo\\
2385 In [7]: PATH='A Python string'\\
2384 In [7]: PATH='A Python string'\\
2386 In [8]: show $PATH\\
2385 In [8]: show $PATH\\
2387 A Python string\\
2386 A Python string\\
2388 In [9]: show $$PATH\\
2387 In [9]: show $$PATH\\
2389 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2388 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2390
2389
2391 You can use the alias facility to acess all of $PATH. See the %rehash
2390 You can use the alias facility to acess all of $PATH. See the %rehash
2392 and %rehashx functions, which automatically create aliases for the
2391 and %rehashx functions, which automatically create aliases for the
2393 contents of your $PATH.
2392 contents of your $PATH.
2394
2393
2395 If called with no parameters, %alias prints the current alias table."""
2394 If called with no parameters, %alias prints the current alias table."""
2396
2395
2397 par = parameter_s.strip()
2396 par = parameter_s.strip()
2398 if not par:
2397 if not par:
2399 stored = self.db.get('stored_aliases', {} )
2398 stored = self.db.get('stored_aliases', {} )
2400 atab = self.shell.alias_table
2399 atab = self.shell.alias_table
2401 aliases = atab.keys()
2400 aliases = atab.keys()
2402 aliases.sort()
2401 aliases.sort()
2403 res = []
2402 res = []
2404 showlast = []
2403 showlast = []
2405 for alias in aliases:
2404 for alias in aliases:
2406 tgt = atab[alias][1]
2405 tgt = atab[alias][1]
2407 # 'interesting' aliases
2406 # 'interesting' aliases
2408 if (alias in stored or
2407 if (alias in stored or
2409 alias != os.path.splitext(tgt)[0] or
2408 alias != os.path.splitext(tgt)[0] or
2410 ' ' in tgt):
2409 ' ' in tgt):
2411 showlast.append((alias, tgt))
2410 showlast.append((alias, tgt))
2412 else:
2411 else:
2413 res.append((alias, tgt ))
2412 res.append((alias, tgt ))
2414
2413
2415 # show most interesting aliases last
2414 # show most interesting aliases last
2416 res.extend(showlast)
2415 res.extend(showlast)
2417 print "Total number of aliases:",len(aliases)
2416 print "Total number of aliases:",len(aliases)
2418 return res
2417 return res
2419 try:
2418 try:
2420 alias,cmd = par.split(None,1)
2419 alias,cmd = par.split(None,1)
2421 except:
2420 except:
2422 print OInspect.getdoc(self.magic_alias)
2421 print OInspect.getdoc(self.magic_alias)
2423 else:
2422 else:
2424 nargs = cmd.count('%s')
2423 nargs = cmd.count('%s')
2425 if nargs>0 and cmd.find('%l')>=0:
2424 if nargs>0 and cmd.find('%l')>=0:
2426 error('The %s and %l specifiers are mutually exclusive '
2425 error('The %s and %l specifiers are mutually exclusive '
2427 'in alias definitions.')
2426 'in alias definitions.')
2428 else: # all looks OK
2427 else: # all looks OK
2429 self.shell.alias_table[alias] = (nargs,cmd)
2428 self.shell.alias_table[alias] = (nargs,cmd)
2430 self.shell.alias_table_validate(verbose=0)
2429 self.shell.alias_table_validate(verbose=0)
2431 # end magic_alias
2430 # end magic_alias
2432
2431
2433 def magic_unalias(self, parameter_s = ''):
2432 def magic_unalias(self, parameter_s = ''):
2434 """Remove an alias"""
2433 """Remove an alias"""
2435
2434
2436 aname = parameter_s.strip()
2435 aname = parameter_s.strip()
2437 if aname in self.shell.alias_table:
2436 if aname in self.shell.alias_table:
2438 del self.shell.alias_table[aname]
2437 del self.shell.alias_table[aname]
2439 stored = self.db.get('stored_aliases', {} )
2438 stored = self.db.get('stored_aliases', {} )
2440 if aname in stored:
2439 if aname in stored:
2441 print "Removing %stored alias",aname
2440 print "Removing %stored alias",aname
2442 del stored[aname]
2441 del stored[aname]
2443 self.db['stored_aliases'] = stored
2442 self.db['stored_aliases'] = stored
2444
2443
2445 def magic_rehash(self, parameter_s = ''):
2444 def magic_rehash(self, parameter_s = ''):
2446 """Update the alias table with all entries in $PATH.
2445 """Update the alias table with all entries in $PATH.
2447
2446
2448 This version does no checks on execute permissions or whether the
2447 This version does no checks on execute permissions or whether the
2449 contents of $PATH are truly files (instead of directories or something
2448 contents of $PATH are truly files (instead of directories or something
2450 else). For such a safer (but slower) version, use %rehashx."""
2449 else). For such a safer (but slower) version, use %rehashx."""
2451
2450
2452 # This function (and rehashx) manipulate the alias_table directly
2451 # This function (and rehashx) manipulate the alias_table directly
2453 # rather than calling magic_alias, for speed reasons. A rehash on a
2452 # rather than calling magic_alias, for speed reasons. A rehash on a
2454 # typical Linux box involves several thousand entries, so efficiency
2453 # typical Linux box involves several thousand entries, so efficiency
2455 # here is a top concern.
2454 # here is a top concern.
2456
2455
2457 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2456 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2458 alias_table = self.shell.alias_table
2457 alias_table = self.shell.alias_table
2459 for pdir in path:
2458 for pdir in path:
2460 for ff in os.listdir(pdir):
2459 for ff in os.listdir(pdir):
2461 # each entry in the alias table must be (N,name), where
2460 # each entry in the alias table must be (N,name), where
2462 # N is the number of positional arguments of the alias.
2461 # N is the number of positional arguments of the alias.
2463 alias_table[ff] = (0,ff)
2462 alias_table[ff] = (0,ff)
2464 # Make sure the alias table doesn't contain keywords or builtins
2463 # Make sure the alias table doesn't contain keywords or builtins
2465 self.shell.alias_table_validate()
2464 self.shell.alias_table_validate()
2466 # Call again init_auto_alias() so we get 'rm -i' and other modified
2465 # Call again init_auto_alias() so we get 'rm -i' and other modified
2467 # aliases since %rehash will probably clobber them
2466 # aliases since %rehash will probably clobber them
2468 self.shell.init_auto_alias()
2467 self.shell.init_auto_alias()
2469
2468
2470 def magic_rehashx(self, parameter_s = ''):
2469 def magic_rehashx(self, parameter_s = ''):
2471 """Update the alias table with all executable files in $PATH.
2470 """Update the alias table with all executable files in $PATH.
2472
2471
2473 This version explicitly checks that every entry in $PATH is a file
2472 This version explicitly checks that every entry in $PATH is a file
2474 with execute access (os.X_OK), so it is much slower than %rehash.
2473 with execute access (os.X_OK), so it is much slower than %rehash.
2475
2474
2476 Under Windows, it checks executability as a match agains a
2475 Under Windows, it checks executability as a match agains a
2477 '|'-separated string of extensions, stored in the IPython config
2476 '|'-separated string of extensions, stored in the IPython config
2478 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2477 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2479
2478
2480 path = [os.path.abspath(os.path.expanduser(p)) for p in
2479 path = [os.path.abspath(os.path.expanduser(p)) for p in
2481 os.environ['PATH'].split(os.pathsep)]
2480 os.environ['PATH'].split(os.pathsep)]
2482 path = filter(os.path.isdir,path)
2481 path = filter(os.path.isdir,path)
2483
2482
2484 alias_table = self.shell.alias_table
2483 alias_table = self.shell.alias_table
2485 syscmdlist = []
2484 syscmdlist = []
2486 if os.name == 'posix':
2485 if os.name == 'posix':
2487 isexec = lambda fname:os.path.isfile(fname) and \
2486 isexec = lambda fname:os.path.isfile(fname) and \
2488 os.access(fname,os.X_OK)
2487 os.access(fname,os.X_OK)
2489 else:
2488 else:
2490
2489
2491 try:
2490 try:
2492 winext = os.environ['pathext'].replace(';','|').replace('.','')
2491 winext = os.environ['pathext'].replace(';','|').replace('.','')
2493 except KeyError:
2492 except KeyError:
2494 winext = 'exe|com|bat|py'
2493 winext = 'exe|com|bat|py'
2495 if 'py' not in winext:
2494 if 'py' not in winext:
2496 winext += '|py'
2495 winext += '|py'
2497 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2496 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2498 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2497 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2499 savedir = os.getcwd()
2498 savedir = os.getcwd()
2500 try:
2499 try:
2501 # write the whole loop for posix/Windows so we don't have an if in
2500 # write the whole loop for posix/Windows so we don't have an if in
2502 # the innermost part
2501 # the innermost part
2503 if os.name == 'posix':
2502 if os.name == 'posix':
2504 for pdir in path:
2503 for pdir in path:
2505 os.chdir(pdir)
2504 os.chdir(pdir)
2506 for ff in os.listdir(pdir):
2505 for ff in os.listdir(pdir):
2507 if isexec(ff) and ff not in self.shell.no_alias:
2506 if isexec(ff) and ff not in self.shell.no_alias:
2508 # each entry in the alias table must be (N,name),
2507 # each entry in the alias table must be (N,name),
2509 # where N is the number of positional arguments of the
2508 # where N is the number of positional arguments of the
2510 # alias.
2509 # alias.
2511 alias_table[ff] = (0,ff)
2510 alias_table[ff] = (0,ff)
2512 syscmdlist.append(ff)
2511 syscmdlist.append(ff)
2513 else:
2512 else:
2514 for pdir in path:
2513 for pdir in path:
2515 os.chdir(pdir)
2514 os.chdir(pdir)
2516 for ff in os.listdir(pdir):
2515 for ff in os.listdir(pdir):
2517 base, ext = os.path.splitext(ff)
2516 base, ext = os.path.splitext(ff)
2518 if isexec(ff) and base not in self.shell.no_alias:
2517 if isexec(ff) and base not in self.shell.no_alias:
2519 if ext.lower() == '.exe':
2518 if ext.lower() == '.exe':
2520 ff = base
2519 ff = base
2521 alias_table[base] = (0,ff)
2520 alias_table[base] = (0,ff)
2522 syscmdlist.append(ff)
2521 syscmdlist.append(ff)
2523 # Make sure the alias table doesn't contain keywords or builtins
2522 # Make sure the alias table doesn't contain keywords or builtins
2524 self.shell.alias_table_validate()
2523 self.shell.alias_table_validate()
2525 # Call again init_auto_alias() so we get 'rm -i' and other
2524 # Call again init_auto_alias() so we get 'rm -i' and other
2526 # modified aliases since %rehashx will probably clobber them
2525 # modified aliases since %rehashx will probably clobber them
2527 self.shell.init_auto_alias()
2526 self.shell.init_auto_alias()
2528 db = self.getapi().db
2527 db = self.getapi().db
2529 db['syscmdlist'] = syscmdlist
2528 db['syscmdlist'] = syscmdlist
2530 finally:
2529 finally:
2531 os.chdir(savedir)
2530 os.chdir(savedir)
2532
2531
2533 def magic_pwd(self, parameter_s = ''):
2532 def magic_pwd(self, parameter_s = ''):
2534 """Return the current working directory path."""
2533 """Return the current working directory path."""
2535 return os.getcwd()
2534 return os.getcwd()
2536
2535
2537 def magic_cd(self, parameter_s=''):
2536 def magic_cd(self, parameter_s=''):
2538 """Change the current working directory.
2537 """Change the current working directory.
2539
2538
2540 This command automatically maintains an internal list of directories
2539 This command automatically maintains an internal list of directories
2541 you visit during your IPython session, in the variable _dh. The
2540 you visit during your IPython session, in the variable _dh. The
2542 command %dhist shows this history nicely formatted.
2541 command %dhist shows this history nicely formatted.
2543
2542
2544 Usage:
2543 Usage:
2545
2544
2546 cd 'dir': changes to directory 'dir'.
2545 cd 'dir': changes to directory 'dir'.
2547
2546
2548 cd -: changes to the last visited directory.
2547 cd -: changes to the last visited directory.
2549
2548
2550 cd -<n>: changes to the n-th directory in the directory history.
2549 cd -<n>: changes to the n-th directory in the directory history.
2551
2550
2552 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2551 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2553 (note: cd <bookmark_name> is enough if there is no
2552 (note: cd <bookmark_name> is enough if there is no
2554 directory <bookmark_name>, but a bookmark with the name exists.)
2553 directory <bookmark_name>, but a bookmark with the name exists.)
2555
2554
2556 Options:
2555 Options:
2557
2556
2558 -q: quiet. Do not print the working directory after the cd command is
2557 -q: quiet. Do not print the working directory after the cd command is
2559 executed. By default IPython's cd command does print this directory,
2558 executed. By default IPython's cd command does print this directory,
2560 since the default prompts do not display path information.
2559 since the default prompts do not display path information.
2561
2560
2562 Note that !cd doesn't work for this purpose because the shell where
2561 Note that !cd doesn't work for this purpose because the shell where
2563 !command runs is immediately discarded after executing 'command'."""
2562 !command runs is immediately discarded after executing 'command'."""
2564
2563
2565 parameter_s = parameter_s.strip()
2564 parameter_s = parameter_s.strip()
2566 #bkms = self.shell.persist.get("bookmarks",{})
2565 #bkms = self.shell.persist.get("bookmarks",{})
2567
2566
2568 numcd = re.match(r'(-)(\d+)$',parameter_s)
2567 numcd = re.match(r'(-)(\d+)$',parameter_s)
2569 # jump in directory history by number
2568 # jump in directory history by number
2570 if numcd:
2569 if numcd:
2571 nn = int(numcd.group(2))
2570 nn = int(numcd.group(2))
2572 try:
2571 try:
2573 ps = self.shell.user_ns['_dh'][nn]
2572 ps = self.shell.user_ns['_dh'][nn]
2574 except IndexError:
2573 except IndexError:
2575 print 'The requested directory does not exist in history.'
2574 print 'The requested directory does not exist in history.'
2576 return
2575 return
2577 else:
2576 else:
2578 opts = {}
2577 opts = {}
2579 else:
2578 else:
2580 #turn all non-space-escaping backslashes to slashes,
2579 #turn all non-space-escaping backslashes to slashes,
2581 # for c:\windows\directory\names\
2580 # for c:\windows\directory\names\
2582 parameter_s = re.sub(r'\\(?! )','/', parameter_s)
2581 parameter_s = re.sub(r'\\(?! )','/', parameter_s)
2583 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2582 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2584 # jump to previous
2583 # jump to previous
2585 if ps == '-':
2584 if ps == '-':
2586 try:
2585 try:
2587 ps = self.shell.user_ns['_dh'][-2]
2586 ps = self.shell.user_ns['_dh'][-2]
2588 except IndexError:
2587 except IndexError:
2589 print 'No previous directory to change to.'
2588 print 'No previous directory to change to.'
2590 return
2589 return
2591 # jump to bookmark if needed
2590 # jump to bookmark if needed
2592 else:
2591 else:
2593 if not os.path.isdir(ps) or opts.has_key('b'):
2592 if not os.path.isdir(ps) or opts.has_key('b'):
2594 bkms = self.db.get('bookmarks', {})
2593 bkms = self.db.get('bookmarks', {})
2595
2594
2596 if bkms.has_key(ps):
2595 if bkms.has_key(ps):
2597 target = bkms[ps]
2596 target = bkms[ps]
2598 print '(bookmark:%s) -> %s' % (ps,target)
2597 print '(bookmark:%s) -> %s' % (ps,target)
2599 ps = target
2598 ps = target
2600 else:
2599 else:
2601 if opts.has_key('b'):
2600 if opts.has_key('b'):
2602 error("Bookmark '%s' not found. "
2601 error("Bookmark '%s' not found. "
2603 "Use '%%bookmark -l' to see your bookmarks." % ps)
2602 "Use '%%bookmark -l' to see your bookmarks." % ps)
2604 return
2603 return
2605
2604
2606 # at this point ps should point to the target dir
2605 # at this point ps should point to the target dir
2607 if ps:
2606 if ps:
2608 try:
2607 try:
2609 os.chdir(os.path.expanduser(ps))
2608 os.chdir(os.path.expanduser(ps))
2610 ttitle = ("IPy:" + (
2609 ttitle = ("IPy:" + (
2611 os.getcwd() == '/' and '/' or os.path.basename(os.getcwd())))
2610 os.getcwd() == '/' and '/' or os.path.basename(os.getcwd())))
2612 platutils.set_term_title(ttitle)
2611 platutils.set_term_title(ttitle)
2613 except OSError:
2612 except OSError:
2614 print sys.exc_info()[1]
2613 print sys.exc_info()[1]
2615 else:
2614 else:
2616 self.shell.user_ns['_dh'].append(os.getcwd())
2615 self.shell.user_ns['_dh'].append(os.getcwd())
2617 else:
2616 else:
2618 os.chdir(self.shell.home_dir)
2617 os.chdir(self.shell.home_dir)
2619 platutils.set_term_title("IPy:~")
2618 platutils.set_term_title("IPy:~")
2620 self.shell.user_ns['_dh'].append(os.getcwd())
2619 self.shell.user_ns['_dh'].append(os.getcwd())
2621 if not 'q' in opts:
2620 if not 'q' in opts:
2622 print self.shell.user_ns['_dh'][-1]
2621 print self.shell.user_ns['_dh'][-1]
2623
2622
2624 def magic_dhist(self, parameter_s=''):
2623 def magic_dhist(self, parameter_s=''):
2625 """Print your history of visited directories.
2624 """Print your history of visited directories.
2626
2625
2627 %dhist -> print full history\\
2626 %dhist -> print full history\\
2628 %dhist n -> print last n entries only\\
2627 %dhist n -> print last n entries only\\
2629 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2628 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2630
2629
2631 This history is automatically maintained by the %cd command, and
2630 This history is automatically maintained by the %cd command, and
2632 always available as the global list variable _dh. You can use %cd -<n>
2631 always available as the global list variable _dh. You can use %cd -<n>
2633 to go to directory number <n>."""
2632 to go to directory number <n>."""
2634
2633
2635 dh = self.shell.user_ns['_dh']
2634 dh = self.shell.user_ns['_dh']
2636 if parameter_s:
2635 if parameter_s:
2637 try:
2636 try:
2638 args = map(int,parameter_s.split())
2637 args = map(int,parameter_s.split())
2639 except:
2638 except:
2640 self.arg_err(Magic.magic_dhist)
2639 self.arg_err(Magic.magic_dhist)
2641 return
2640 return
2642 if len(args) == 1:
2641 if len(args) == 1:
2643 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2642 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2644 elif len(args) == 2:
2643 elif len(args) == 2:
2645 ini,fin = args
2644 ini,fin = args
2646 else:
2645 else:
2647 self.arg_err(Magic.magic_dhist)
2646 self.arg_err(Magic.magic_dhist)
2648 return
2647 return
2649 else:
2648 else:
2650 ini,fin = 0,len(dh)
2649 ini,fin = 0,len(dh)
2651 nlprint(dh,
2650 nlprint(dh,
2652 header = 'Directory history (kept in _dh)',
2651 header = 'Directory history (kept in _dh)',
2653 start=ini,stop=fin)
2652 start=ini,stop=fin)
2654
2653
2655 def magic_env(self, parameter_s=''):
2654 def magic_env(self, parameter_s=''):
2656 """List environment variables."""
2655 """List environment variables."""
2657
2656
2658 return os.environ.data
2657 return os.environ.data
2659
2658
2660 def magic_pushd(self, parameter_s=''):
2659 def magic_pushd(self, parameter_s=''):
2661 """Place the current dir on stack and change directory.
2660 """Place the current dir on stack and change directory.
2662
2661
2663 Usage:\\
2662 Usage:\\
2664 %pushd ['dirname']
2663 %pushd ['dirname']
2665
2664
2666 %pushd with no arguments does a %pushd to your home directory.
2665 %pushd with no arguments does a %pushd to your home directory.
2667 """
2666 """
2668 if parameter_s == '': parameter_s = '~'
2667 if parameter_s == '': parameter_s = '~'
2669 dir_s = self.shell.dir_stack
2668 dir_s = self.shell.dir_stack
2670 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2669 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2671 os.path.expanduser(self.shell.dir_stack[0]):
2670 os.path.expanduser(self.shell.dir_stack[0]):
2672 try:
2671 try:
2673 self.magic_cd(parameter_s)
2672 self.magic_cd(parameter_s)
2674 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2673 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2675 self.magic_dirs()
2674 self.magic_dirs()
2676 except:
2675 except:
2677 print 'Invalid directory'
2676 print 'Invalid directory'
2678 else:
2677 else:
2679 print 'You are already there!'
2678 print 'You are already there!'
2680
2679
2681 def magic_popd(self, parameter_s=''):
2680 def magic_popd(self, parameter_s=''):
2682 """Change to directory popped off the top of the stack.
2681 """Change to directory popped off the top of the stack.
2683 """
2682 """
2684 if len (self.shell.dir_stack) > 1:
2683 if len (self.shell.dir_stack) > 1:
2685 self.shell.dir_stack.pop(0)
2684 self.shell.dir_stack.pop(0)
2686 self.magic_cd(self.shell.dir_stack[0])
2685 self.magic_cd(self.shell.dir_stack[0])
2687 print self.shell.dir_stack[0]
2686 print self.shell.dir_stack[0]
2688 else:
2687 else:
2689 print "You can't remove the starting directory from the stack:",\
2688 print "You can't remove the starting directory from the stack:",\
2690 self.shell.dir_stack
2689 self.shell.dir_stack
2691
2690
2692 def magic_dirs(self, parameter_s=''):
2691 def magic_dirs(self, parameter_s=''):
2693 """Return the current directory stack."""
2692 """Return the current directory stack."""
2694
2693
2695 return self.shell.dir_stack[:]
2694 return self.shell.dir_stack[:]
2696
2695
2697 def magic_sc(self, parameter_s=''):
2696 def magic_sc(self, parameter_s=''):
2698 """Shell capture - execute a shell command and capture its output.
2697 """Shell capture - execute a shell command and capture its output.
2699
2698
2700 DEPRECATED. Suboptimal, retained for backwards compatibility.
2699 DEPRECATED. Suboptimal, retained for backwards compatibility.
2701
2700
2702 You should use the form 'var = !command' instead. Example:
2701 You should use the form 'var = !command' instead. Example:
2703
2702
2704 "%sc -l myfiles = ls ~" should now be written as
2703 "%sc -l myfiles = ls ~" should now be written as
2705
2704
2706 "myfiles = !ls ~"
2705 "myfiles = !ls ~"
2707
2706
2708 myfiles.s, myfiles.l and myfiles.n still apply as documented
2707 myfiles.s, myfiles.l and myfiles.n still apply as documented
2709 below.
2708 below.
2710
2709
2711 --
2710 --
2712 %sc [options] varname=command
2711 %sc [options] varname=command
2713
2712
2714 IPython will run the given command using commands.getoutput(), and
2713 IPython will run the given command using commands.getoutput(), and
2715 will then update the user's interactive namespace with a variable
2714 will then update the user's interactive namespace with a variable
2716 called varname, containing the value of the call. Your command can
2715 called varname, containing the value of the call. Your command can
2717 contain shell wildcards, pipes, etc.
2716 contain shell wildcards, pipes, etc.
2718
2717
2719 The '=' sign in the syntax is mandatory, and the variable name you
2718 The '=' sign in the syntax is mandatory, and the variable name you
2720 supply must follow Python's standard conventions for valid names.
2719 supply must follow Python's standard conventions for valid names.
2721
2720
2722 (A special format without variable name exists for internal use)
2721 (A special format without variable name exists for internal use)
2723
2722
2724 Options:
2723 Options:
2725
2724
2726 -l: list output. Split the output on newlines into a list before
2725 -l: list output. Split the output on newlines into a list before
2727 assigning it to the given variable. By default the output is stored
2726 assigning it to the given variable. By default the output is stored
2728 as a single string.
2727 as a single string.
2729
2728
2730 -v: verbose. Print the contents of the variable.
2729 -v: verbose. Print the contents of the variable.
2731
2730
2732 In most cases you should not need to split as a list, because the
2731 In most cases you should not need to split as a list, because the
2733 returned value is a special type of string which can automatically
2732 returned value is a special type of string which can automatically
2734 provide its contents either as a list (split on newlines) or as a
2733 provide its contents either as a list (split on newlines) or as a
2735 space-separated string. These are convenient, respectively, either
2734 space-separated string. These are convenient, respectively, either
2736 for sequential processing or to be passed to a shell command.
2735 for sequential processing or to be passed to a shell command.
2737
2736
2738 For example:
2737 For example:
2739
2738
2740 # Capture into variable a
2739 # Capture into variable a
2741 In [9]: sc a=ls *py
2740 In [9]: sc a=ls *py
2742
2741
2743 # a is a string with embedded newlines
2742 # a is a string with embedded newlines
2744 In [10]: a
2743 In [10]: a
2745 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2744 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2746
2745
2747 # which can be seen as a list:
2746 # which can be seen as a list:
2748 In [11]: a.l
2747 In [11]: a.l
2749 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2748 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2750
2749
2751 # or as a whitespace-separated string:
2750 # or as a whitespace-separated string:
2752 In [12]: a.s
2751 In [12]: a.s
2753 Out[12]: 'setup.py win32_manual_post_install.py'
2752 Out[12]: 'setup.py win32_manual_post_install.py'
2754
2753
2755 # a.s is useful to pass as a single command line:
2754 # a.s is useful to pass as a single command line:
2756 In [13]: !wc -l $a.s
2755 In [13]: !wc -l $a.s
2757 146 setup.py
2756 146 setup.py
2758 130 win32_manual_post_install.py
2757 130 win32_manual_post_install.py
2759 276 total
2758 276 total
2760
2759
2761 # while the list form is useful to loop over:
2760 # while the list form is useful to loop over:
2762 In [14]: for f in a.l:
2761 In [14]: for f in a.l:
2763 ....: !wc -l $f
2762 ....: !wc -l $f
2764 ....:
2763 ....:
2765 146 setup.py
2764 146 setup.py
2766 130 win32_manual_post_install.py
2765 130 win32_manual_post_install.py
2767
2766
2768 Similiarly, the lists returned by the -l option are also special, in
2767 Similiarly, the lists returned by the -l option are also special, in
2769 the sense that you can equally invoke the .s attribute on them to
2768 the sense that you can equally invoke the .s attribute on them to
2770 automatically get a whitespace-separated string from their contents:
2769 automatically get a whitespace-separated string from their contents:
2771
2770
2772 In [1]: sc -l b=ls *py
2771 In [1]: sc -l b=ls *py
2773
2772
2774 In [2]: b
2773 In [2]: b
2775 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2774 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2776
2775
2777 In [3]: b.s
2776 In [3]: b.s
2778 Out[3]: 'setup.py win32_manual_post_install.py'
2777 Out[3]: 'setup.py win32_manual_post_install.py'
2779
2778
2780 In summary, both the lists and strings used for ouptut capture have
2779 In summary, both the lists and strings used for ouptut capture have
2781 the following special attributes:
2780 the following special attributes:
2782
2781
2783 .l (or .list) : value as list.
2782 .l (or .list) : value as list.
2784 .n (or .nlstr): value as newline-separated string.
2783 .n (or .nlstr): value as newline-separated string.
2785 .s (or .spstr): value as space-separated string.
2784 .s (or .spstr): value as space-separated string.
2786 """
2785 """
2787
2786
2788 opts,args = self.parse_options(parameter_s,'lv')
2787 opts,args = self.parse_options(parameter_s,'lv')
2789 # Try to get a variable name and command to run
2788 # Try to get a variable name and command to run
2790 try:
2789 try:
2791 # the variable name must be obtained from the parse_options
2790 # the variable name must be obtained from the parse_options
2792 # output, which uses shlex.split to strip options out.
2791 # output, which uses shlex.split to strip options out.
2793 var,_ = args.split('=',1)
2792 var,_ = args.split('=',1)
2794 var = var.strip()
2793 var = var.strip()
2795 # But the the command has to be extracted from the original input
2794 # But the the command has to be extracted from the original input
2796 # parameter_s, not on what parse_options returns, to avoid the
2795 # parameter_s, not on what parse_options returns, to avoid the
2797 # quote stripping which shlex.split performs on it.
2796 # quote stripping which shlex.split performs on it.
2798 _,cmd = parameter_s.split('=',1)
2797 _,cmd = parameter_s.split('=',1)
2799 except ValueError:
2798 except ValueError:
2800 var,cmd = '',''
2799 var,cmd = '',''
2801 # If all looks ok, proceed
2800 # If all looks ok, proceed
2802 out,err = self.shell.getoutputerror(cmd)
2801 out,err = self.shell.getoutputerror(cmd)
2803 if err:
2802 if err:
2804 print >> Term.cerr,err
2803 print >> Term.cerr,err
2805 if opts.has_key('l'):
2804 if opts.has_key('l'):
2806 out = SList(out.split('\n'))
2805 out = SList(out.split('\n'))
2807 else:
2806 else:
2808 out = LSString(out)
2807 out = LSString(out)
2809 if opts.has_key('v'):
2808 if opts.has_key('v'):
2810 print '%s ==\n%s' % (var,pformat(out))
2809 print '%s ==\n%s' % (var,pformat(out))
2811 if var:
2810 if var:
2812 self.shell.user_ns.update({var:out})
2811 self.shell.user_ns.update({var:out})
2813 else:
2812 else:
2814 return out
2813 return out
2815
2814
2816 def magic_sx(self, parameter_s=''):
2815 def magic_sx(self, parameter_s=''):
2817 """Shell execute - run a shell command and capture its output.
2816 """Shell execute - run a shell command and capture its output.
2818
2817
2819 %sx command
2818 %sx command
2820
2819
2821 IPython will run the given command using commands.getoutput(), and
2820 IPython will run the given command using commands.getoutput(), and
2822 return the result formatted as a list (split on '\\n'). Since the
2821 return the result formatted as a list (split on '\\n'). Since the
2823 output is _returned_, it will be stored in ipython's regular output
2822 output is _returned_, it will be stored in ipython's regular output
2824 cache Out[N] and in the '_N' automatic variables.
2823 cache Out[N] and in the '_N' automatic variables.
2825
2824
2826 Notes:
2825 Notes:
2827
2826
2828 1) If an input line begins with '!!', then %sx is automatically
2827 1) If an input line begins with '!!', then %sx is automatically
2829 invoked. That is, while:
2828 invoked. That is, while:
2830 !ls
2829 !ls
2831 causes ipython to simply issue system('ls'), typing
2830 causes ipython to simply issue system('ls'), typing
2832 !!ls
2831 !!ls
2833 is a shorthand equivalent to:
2832 is a shorthand equivalent to:
2834 %sx ls
2833 %sx ls
2835
2834
2836 2) %sx differs from %sc in that %sx automatically splits into a list,
2835 2) %sx differs from %sc in that %sx automatically splits into a list,
2837 like '%sc -l'. The reason for this is to make it as easy as possible
2836 like '%sc -l'. The reason for this is to make it as easy as possible
2838 to process line-oriented shell output via further python commands.
2837 to process line-oriented shell output via further python commands.
2839 %sc is meant to provide much finer control, but requires more
2838 %sc is meant to provide much finer control, but requires more
2840 typing.
2839 typing.
2841
2840
2842 3) Just like %sc -l, this is a list with special attributes:
2841 3) Just like %sc -l, this is a list with special attributes:
2843
2842
2844 .l (or .list) : value as list.
2843 .l (or .list) : value as list.
2845 .n (or .nlstr): value as newline-separated string.
2844 .n (or .nlstr): value as newline-separated string.
2846 .s (or .spstr): value as whitespace-separated string.
2845 .s (or .spstr): value as whitespace-separated string.
2847
2846
2848 This is very useful when trying to use such lists as arguments to
2847 This is very useful when trying to use such lists as arguments to
2849 system commands."""
2848 system commands."""
2850
2849
2851 if parameter_s:
2850 if parameter_s:
2852 out,err = self.shell.getoutputerror(parameter_s)
2851 out,err = self.shell.getoutputerror(parameter_s)
2853 if err:
2852 if err:
2854 print >> Term.cerr,err
2853 print >> Term.cerr,err
2855 return SList(out.split('\n'))
2854 return SList(out.split('\n'))
2856
2855
2857 def magic_bg(self, parameter_s=''):
2856 def magic_bg(self, parameter_s=''):
2858 """Run a job in the background, in a separate thread.
2857 """Run a job in the background, in a separate thread.
2859
2858
2860 For example,
2859 For example,
2861
2860
2862 %bg myfunc(x,y,z=1)
2861 %bg myfunc(x,y,z=1)
2863
2862
2864 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2863 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2865 execution starts, a message will be printed indicating the job
2864 execution starts, a message will be printed indicating the job
2866 number. If your job number is 5, you can use
2865 number. If your job number is 5, you can use
2867
2866
2868 myvar = jobs.result(5) or myvar = jobs[5].result
2867 myvar = jobs.result(5) or myvar = jobs[5].result
2869
2868
2870 to assign this result to variable 'myvar'.
2869 to assign this result to variable 'myvar'.
2871
2870
2872 IPython has a job manager, accessible via the 'jobs' object. You can
2871 IPython has a job manager, accessible via the 'jobs' object. You can
2873 type jobs? to get more information about it, and use jobs.<TAB> to see
2872 type jobs? to get more information about it, and use jobs.<TAB> to see
2874 its attributes. All attributes not starting with an underscore are
2873 its attributes. All attributes not starting with an underscore are
2875 meant for public use.
2874 meant for public use.
2876
2875
2877 In particular, look at the jobs.new() method, which is used to create
2876 In particular, look at the jobs.new() method, which is used to create
2878 new jobs. This magic %bg function is just a convenience wrapper
2877 new jobs. This magic %bg function is just a convenience wrapper
2879 around jobs.new(), for expression-based jobs. If you want to create a
2878 around jobs.new(), for expression-based jobs. If you want to create a
2880 new job with an explicit function object and arguments, you must call
2879 new job with an explicit function object and arguments, you must call
2881 jobs.new() directly.
2880 jobs.new() directly.
2882
2881
2883 The jobs.new docstring also describes in detail several important
2882 The jobs.new docstring also describes in detail several important
2884 caveats associated with a thread-based model for background job
2883 caveats associated with a thread-based model for background job
2885 execution. Type jobs.new? for details.
2884 execution. Type jobs.new? for details.
2886
2885
2887 You can check the status of all jobs with jobs.status().
2886 You can check the status of all jobs with jobs.status().
2888
2887
2889 The jobs variable is set by IPython into the Python builtin namespace.
2888 The jobs variable is set by IPython into the Python builtin namespace.
2890 If you ever declare a variable named 'jobs', you will shadow this
2889 If you ever declare a variable named 'jobs', you will shadow this
2891 name. You can either delete your global jobs variable to regain
2890 name. You can either delete your global jobs variable to regain
2892 access to the job manager, or make a new name and assign it manually
2891 access to the job manager, or make a new name and assign it manually
2893 to the manager (stored in IPython's namespace). For example, to
2892 to the manager (stored in IPython's namespace). For example, to
2894 assign the job manager to the Jobs name, use:
2893 assign the job manager to the Jobs name, use:
2895
2894
2896 Jobs = __builtins__.jobs"""
2895 Jobs = __builtins__.jobs"""
2897
2896
2898 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2897 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2899
2898
2900
2899
2901 def magic_bookmark(self, parameter_s=''):
2900 def magic_bookmark(self, parameter_s=''):
2902 """Manage IPython's bookmark system.
2901 """Manage IPython's bookmark system.
2903
2902
2904 %bookmark <name> - set bookmark to current dir
2903 %bookmark <name> - set bookmark to current dir
2905 %bookmark <name> <dir> - set bookmark to <dir>
2904 %bookmark <name> <dir> - set bookmark to <dir>
2906 %bookmark -l - list all bookmarks
2905 %bookmark -l - list all bookmarks
2907 %bookmark -d <name> - remove bookmark
2906 %bookmark -d <name> - remove bookmark
2908 %bookmark -r - remove all bookmarks
2907 %bookmark -r - remove all bookmarks
2909
2908
2910 You can later on access a bookmarked folder with:
2909 You can later on access a bookmarked folder with:
2911 %cd -b <name>
2910 %cd -b <name>
2912 or simply '%cd <name>' if there is no directory called <name> AND
2911 or simply '%cd <name>' if there is no directory called <name> AND
2913 there is such a bookmark defined.
2912 there is such a bookmark defined.
2914
2913
2915 Your bookmarks persist through IPython sessions, but they are
2914 Your bookmarks persist through IPython sessions, but they are
2916 associated with each profile."""
2915 associated with each profile."""
2917
2916
2918 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2917 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2919 if len(args) > 2:
2918 if len(args) > 2:
2920 error('You can only give at most two arguments')
2919 error('You can only give at most two arguments')
2921 return
2920 return
2922
2921
2923 bkms = self.db.get('bookmarks',{})
2922 bkms = self.db.get('bookmarks',{})
2924
2923
2925 if opts.has_key('d'):
2924 if opts.has_key('d'):
2926 try:
2925 try:
2927 todel = args[0]
2926 todel = args[0]
2928 except IndexError:
2927 except IndexError:
2929 error('You must provide a bookmark to delete')
2928 error('You must provide a bookmark to delete')
2930 else:
2929 else:
2931 try:
2930 try:
2932 del bkms[todel]
2931 del bkms[todel]
2933 except:
2932 except:
2934 error("Can't delete bookmark '%s'" % todel)
2933 error("Can't delete bookmark '%s'" % todel)
2935 elif opts.has_key('r'):
2934 elif opts.has_key('r'):
2936 bkms = {}
2935 bkms = {}
2937 elif opts.has_key('l'):
2936 elif opts.has_key('l'):
2938 bks = bkms.keys()
2937 bks = bkms.keys()
2939 bks.sort()
2938 bks.sort()
2940 if bks:
2939 if bks:
2941 size = max(map(len,bks))
2940 size = max(map(len,bks))
2942 else:
2941 else:
2943 size = 0
2942 size = 0
2944 fmt = '%-'+str(size)+'s -> %s'
2943 fmt = '%-'+str(size)+'s -> %s'
2945 print 'Current bookmarks:'
2944 print 'Current bookmarks:'
2946 for bk in bks:
2945 for bk in bks:
2947 print fmt % (bk,bkms[bk])
2946 print fmt % (bk,bkms[bk])
2948 else:
2947 else:
2949 if not args:
2948 if not args:
2950 error("You must specify the bookmark name")
2949 error("You must specify the bookmark name")
2951 elif len(args)==1:
2950 elif len(args)==1:
2952 bkms[args[0]] = os.getcwd()
2951 bkms[args[0]] = os.getcwd()
2953 elif len(args)==2:
2952 elif len(args)==2:
2954 bkms[args[0]] = args[1]
2953 bkms[args[0]] = args[1]
2955 self.db['bookmarks'] = bkms
2954 self.db['bookmarks'] = bkms
2956
2955
2957 def magic_pycat(self, parameter_s=''):
2956 def magic_pycat(self, parameter_s=''):
2958 """Show a syntax-highlighted file through a pager.
2957 """Show a syntax-highlighted file through a pager.
2959
2958
2960 This magic is similar to the cat utility, but it will assume the file
2959 This magic is similar to the cat utility, but it will assume the file
2961 to be Python source and will show it with syntax highlighting. """
2960 to be Python source and will show it with syntax highlighting. """
2962
2961
2963 try:
2962 try:
2964 filename = get_py_filename(parameter_s)
2963 filename = get_py_filename(parameter_s)
2965 cont = file_read(filename)
2964 cont = file_read(filename)
2966 except IOError:
2965 except IOError:
2967 try:
2966 try:
2968 cont = eval(parameter_s,self.user_ns)
2967 cont = eval(parameter_s,self.user_ns)
2969 except NameError:
2968 except NameError:
2970 cont = None
2969 cont = None
2971 if cont is None:
2970 if cont is None:
2972 print "Error: no such file or variable"
2971 print "Error: no such file or variable"
2973 return
2972 return
2974
2973
2975 page(self.shell.pycolorize(cont),
2974 page(self.shell.pycolorize(cont),
2976 screen_lines=self.shell.rc.screen_length)
2975 screen_lines=self.shell.rc.screen_length)
2977
2976
2978 def magic_cpaste(self, parameter_s=''):
2977 def magic_cpaste(self, parameter_s=''):
2979 """Allows you to paste & execute a pre-formatted code block from clipboard
2978 """Allows you to paste & execute a pre-formatted code block from clipboard
2980
2979
2981 You must terminate the block with '--' (two minus-signs) alone on the
2980 You must terminate the block with '--' (two minus-signs) alone on the
2982 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
2981 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
2983 is the new sentinel for this operation)
2982 is the new sentinel for this operation)
2984
2983
2985 The block is dedented prior to execution to enable execution of
2984 The block is dedented prior to execution to enable execution of
2986 method definitions. '>' characters at the beginning of a line is
2985 method definitions. '>' characters at the beginning of a line is
2987 ignored, to allow pasting directly from e-mails. The executed block
2986 ignored, to allow pasting directly from e-mails. The executed block
2988 is also assigned to variable named 'pasted_block' for later editing
2987 is also assigned to variable named 'pasted_block' for later editing
2989 with '%edit pasted_block'.
2988 with '%edit pasted_block'.
2990
2989
2991 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
2990 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
2992 This assigns the pasted block to variable 'foo' as string, without
2991 This assigns the pasted block to variable 'foo' as string, without
2993 dedenting or executing it.
2992 dedenting or executing it.
2994
2993
2995 Do not be alarmed by garbled output on Windows (it's a readline bug).
2994 Do not be alarmed by garbled output on Windows (it's a readline bug).
2996 Just press enter and type -- (and press enter again) and the block
2995 Just press enter and type -- (and press enter again) and the block
2997 will be what was just pasted.
2996 will be what was just pasted.
2998
2997
2999 IPython statements (magics, shell escapes) are not supported (yet).
2998 IPython statements (magics, shell escapes) are not supported (yet).
3000 """
2999 """
3001 opts,args = self.parse_options(parameter_s,'s:',mode='string')
3000 opts,args = self.parse_options(parameter_s,'s:',mode='string')
3002 par = args.strip()
3001 par = args.strip()
3003 sentinel = opts.get('s','--')
3002 sentinel = opts.get('s','--')
3004
3003
3005 from IPython import iplib
3004 from IPython import iplib
3006 lines = []
3005 lines = []
3007 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
3006 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
3008 while 1:
3007 while 1:
3009 l = iplib.raw_input_original(':')
3008 l = iplib.raw_input_original(':')
3010 if l ==sentinel:
3009 if l ==sentinel:
3011 break
3010 break
3012 lines.append(l.lstrip('>'))
3011 lines.append(l.lstrip('>'))
3013 block = "\n".join(lines) + '\n'
3012 block = "\n".join(lines) + '\n'
3014 #print "block:\n",block
3013 #print "block:\n",block
3015 if not par:
3014 if not par:
3016 b = textwrap.dedent(block)
3015 b = textwrap.dedent(block)
3017 exec b in self.user_ns
3016 exec b in self.user_ns
3018 self.user_ns['pasted_block'] = b
3017 self.user_ns['pasted_block'] = b
3019 else:
3018 else:
3020 self.user_ns[par] = block
3019 self.user_ns[par] = block
3021 print "Block assigned to '%s'" % par
3020 print "Block assigned to '%s'" % par
3022
3021
3023 def magic_quickref(self,arg):
3022 def magic_quickref(self,arg):
3024 """ Show a quick reference sheet """
3023 """ Show a quick reference sheet """
3025 import IPython.usage
3024 import IPython.usage
3026 qr = IPython.usage.quick_reference + self.magic_magic('-brief')
3025 qr = IPython.usage.quick_reference + self.magic_magic('-brief')
3027
3026
3028 page(qr)
3027 page(qr)
3029
3028
3030 def magic_upgrade(self,arg):
3029 def magic_upgrade(self,arg):
3031 """ Upgrade your IPython installation
3030 """ Upgrade your IPython installation
3032
3031
3033 This will copy the config files that don't yet exist in your
3032 This will copy the config files that don't yet exist in your
3034 ipython dir from the system config dir. Use this after upgrading
3033 ipython dir from the system config dir. Use this after upgrading
3035 IPython if you don't wish to delete your .ipython dir.
3034 IPython if you don't wish to delete your .ipython dir.
3036
3035
3037 Call with -nolegacy to get rid of ipythonrc* files (recommended for
3036 Call with -nolegacy to get rid of ipythonrc* files (recommended for
3038 new users)
3037 new users)
3039
3038
3040 """
3039 """
3041 ip = self.getapi()
3040 ip = self.getapi()
3042 ipinstallation = path(IPython.__file__).dirname()
3041 ipinstallation = path(IPython.__file__).dirname()
3043 upgrade_script = '%s "%s"' % (sys.executable,ipinstallation / 'upgrade_dir.py')
3042 upgrade_script = '%s "%s"' % (sys.executable,ipinstallation / 'upgrade_dir.py')
3044 src_config = ipinstallation / 'UserConfig'
3043 src_config = ipinstallation / 'UserConfig'
3045 userdir = path(ip.options.ipythondir)
3044 userdir = path(ip.options.ipythondir)
3046 cmd = '%s "%s" "%s"' % (upgrade_script, src_config, userdir)
3045 cmd = '%s "%s" "%s"' % (upgrade_script, src_config, userdir)
3047 print ">",cmd
3046 print ">",cmd
3048 shell(cmd)
3047 shell(cmd)
3049 if arg == '-nolegacy':
3048 if arg == '-nolegacy':
3050 legacy = userdir.files('ipythonrc*')
3049 legacy = userdir.files('ipythonrc*')
3051 print "Nuking legacy files:",legacy
3050 print "Nuking legacy files:",legacy
3052
3051
3053 [p.remove() for p in legacy]
3052 [p.remove() for p in legacy]
3054 suffix = (sys.platform == 'win32' and '.ini' or '')
3053 suffix = (sys.platform == 'win32' and '.ini' or '')
3055 (userdir / ('ipythonrc' + suffix)).write_text('# Empty, see ipy_user_conf.py\n')
3054 (userdir / ('ipythonrc' + suffix)).write_text('# Empty, see ipy_user_conf.py\n')
3056
3055
3057
3056
3058 # end Magic
3057 # end Magic
@@ -1,86 +1,86 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 1955 2006-11-29 09:44:32Z vivainio $"""
4 $Id: Release.py 1961 2006-12-05 21:02:40Z vivainio $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001-2006 Fernando Perez <fperez@colorado.edu>
7 # Copyright (C) 2001-2006 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 revision = '1954'
25 revision = '1955'
26
26
27 #version = '0.7.3.svn'
27 #version = '0.7.3.svn'
28
28
29 version = '0.7.3.svn.r' + revision.rstrip('M')
29 version = '0.7.3.svn.r' + revision.rstrip('M')
30
30
31
31
32 description = "An enhanced interactive Python shell."
32 description = "An enhanced interactive Python shell."
33
33
34 long_description = \
34 long_description = \
35 """
35 """
36 IPython provides a replacement for the interactive Python interpreter with
36 IPython provides a replacement for the interactive Python interpreter with
37 extra functionality.
37 extra functionality.
38
38
39 Main features:
39 Main features:
40
40
41 * Comprehensive object introspection.
41 * Comprehensive object introspection.
42
42
43 * Input history, persistent across sessions.
43 * Input history, persistent across sessions.
44
44
45 * Caching of output results during a session with automatically generated
45 * Caching of output results during a session with automatically generated
46 references.
46 references.
47
47
48 * Readline based name completion.
48 * Readline based name completion.
49
49
50 * Extensible system of 'magic' commands for controlling the environment and
50 * Extensible system of 'magic' commands for controlling the environment and
51 performing many tasks related either to IPython or the operating system.
51 performing many tasks related either to IPython or the operating system.
52
52
53 * Configuration system with easy switching between different setups (simpler
53 * Configuration system with easy switching between different setups (simpler
54 than changing $PYTHONSTARTUP environment variables every time).
54 than changing $PYTHONSTARTUP environment variables every time).
55
55
56 * Session logging and reloading.
56 * Session logging and reloading.
57
57
58 * Extensible syntax processing for special purpose situations.
58 * Extensible syntax processing for special purpose situations.
59
59
60 * Access to the system shell with user-extensible alias system.
60 * Access to the system shell with user-extensible alias system.
61
61
62 * Easily embeddable in other Python programs.
62 * Easily embeddable in other Python programs.
63
63
64 * Integrated access to the pdb debugger and the Python profiler.
64 * Integrated access to the pdb debugger and the Python profiler.
65
65
66 The latest development version is always available at the IPython subversion
66 The latest development version is always available at the IPython subversion
67 repository_.
67 repository_.
68
68
69 .. _repository: http://ipython.scipy.org/svn/ipython/ipython/trunk#egg=ipython-dev
69 .. _repository: http://ipython.scipy.org/svn/ipython/ipython/trunk#egg=ipython-dev
70 """
70 """
71
71
72 license = 'BSD'
72 license = 'BSD'
73
73
74 authors = {'Fernando' : ('Fernando Perez','fperez@colorado.edu'),
74 authors = {'Fernando' : ('Fernando Perez','fperez@colorado.edu'),
75 'Janko' : ('Janko Hauser','jhauser@zscout.de'),
75 'Janko' : ('Janko Hauser','jhauser@zscout.de'),
76 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu'),
76 'Nathan' : ('Nathaniel Gray','n8gray@caltech.edu'),
77 'Ville' : ('Ville Vainio','vivainio@gmail.com')
77 'Ville' : ('Ville Vainio','vivainio@gmail.com')
78 }
78 }
79
79
80 url = 'http://ipython.scipy.org'
80 url = 'http://ipython.scipy.org'
81
81
82 download_url = 'http://ipython.scipy.org/dist'
82 download_url = 'http://ipython.scipy.org/dist'
83
83
84 platforms = ['Linux','Mac OSX','Windows XP/2000/NT','Windows 95/98/ME']
84 platforms = ['Linux','Mac OSX','Windows XP/2000/NT','Windows 95/98/ME']
85
85
86 keywords = ['Interactive','Interpreter','Shell']
86 keywords = ['Interactive','Interpreter','Shell']
@@ -1,2535 +1,2534 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 IPython -- An enhanced Interactive Python
3 IPython -- An enhanced Interactive Python
4
4
5 Requires Python 2.3 or newer.
5 Requires Python 2.3 or newer.
6
6
7 This file contains all the classes and helper functions specific to IPython.
7 This file contains all the classes and helper functions specific to IPython.
8
8
9 $Id: iplib.py 1956 2006-11-30 05:22:31Z fperez $
9 $Id: iplib.py 1961 2006-12-05 21:02:40Z vivainio $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
13 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
14 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
14 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
15 #
15 #
16 # Distributed under the terms of the BSD License. The full license is in
16 # Distributed under the terms of the BSD License. The full license is in
17 # the file COPYING, distributed as part of this software.
17 # the file COPYING, distributed as part of this software.
18 #
18 #
19 # Note: this code originally subclassed code.InteractiveConsole from the
19 # Note: this code originally subclassed code.InteractiveConsole from the
20 # Python standard library. Over time, all of that class has been copied
20 # Python standard library. Over time, all of that class has been copied
21 # verbatim here for modifications which could not be accomplished by
21 # verbatim here for modifications which could not be accomplished by
22 # subclassing. At this point, there are no dependencies at all on the code
22 # subclassing. At this point, there are no dependencies at all on the code
23 # module anymore (it is not even imported). The Python License (sec. 2)
23 # module anymore (it is not even imported). The Python License (sec. 2)
24 # allows for this, but it's always nice to acknowledge credit where credit is
24 # allows for this, but it's always nice to acknowledge credit where credit is
25 # due.
25 # due.
26 #*****************************************************************************
26 #*****************************************************************************
27
27
28 #****************************************************************************
28 #****************************************************************************
29 # Modules and globals
29 # Modules and globals
30
30
31 from IPython import Release
31 from IPython import Release
32 __author__ = '%s <%s>\n%s <%s>' % \
32 __author__ = '%s <%s>\n%s <%s>' % \
33 ( Release.authors['Janko'] + Release.authors['Fernando'] )
33 ( Release.authors['Janko'] + Release.authors['Fernando'] )
34 __license__ = Release.license
34 __license__ = Release.license
35 __version__ = Release.version
35 __version__ = Release.version
36
36
37 # Python standard modules
37 # Python standard modules
38 import __main__
38 import __main__
39 import __builtin__
39 import __builtin__
40 import StringIO
40 import StringIO
41 import bdb
41 import bdb
42 import cPickle as pickle
42 import cPickle as pickle
43 import codeop
43 import codeop
44 import exceptions
44 import exceptions
45 import glob
45 import glob
46 import inspect
46 import inspect
47 import keyword
47 import keyword
48 import new
48 import new
49 import os
49 import os
50 import pydoc
50 import pydoc
51 import re
51 import re
52 import shutil
52 import shutil
53 import string
53 import string
54 import sys
54 import sys
55 import tempfile
55 import tempfile
56 import traceback
56 import traceback
57 import types
57 import types
58 import pickleshare
58 import pickleshare
59 from sets import Set
59 from sets import Set
60 from pprint import pprint, pformat
60 from pprint import pprint, pformat
61
61
62 # IPython's own modules
62 # IPython's own modules
63 import IPython
63 import IPython
64 from IPython import OInspect,PyColorize,ultraTB
64 from IPython import OInspect,PyColorize,ultraTB
65 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
65 from IPython.ColorANSI import ColorScheme,ColorSchemeTable # too long names
66 from IPython.FakeModule import FakeModule
66 from IPython.FakeModule import FakeModule
67 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
67 from IPython.Itpl import Itpl,itpl,printpl,ItplNS,itplns
68 from IPython.Logger import Logger
68 from IPython.Logger import Logger
69 from IPython.Magic import Magic
69 from IPython.Magic import Magic
70 from IPython.Prompts import CachedOutput
70 from IPython.Prompts import CachedOutput
71 from IPython.ipstruct import Struct
71 from IPython.ipstruct import Struct
72 from IPython.background_jobs import BackgroundJobManager
72 from IPython.background_jobs import BackgroundJobManager
73 from IPython.usage import cmd_line_usage,interactive_usage
73 from IPython.usage import cmd_line_usage,interactive_usage
74 from IPython.genutils import *
74 from IPython.genutils import *
75 from IPython.strdispatch import StrDispatch
75 from IPython.strdispatch import StrDispatch
76 import IPython.ipapi
76 import IPython.ipapi
77
77
78 # Globals
78 # Globals
79
79
80 # store the builtin raw_input globally, and use this always, in case user code
80 # store the builtin raw_input globally, and use this always, in case user code
81 # overwrites it (like wx.py.PyShell does)
81 # overwrites it (like wx.py.PyShell does)
82 raw_input_original = raw_input
82 raw_input_original = raw_input
83
83
84 # compiled regexps for autoindent management
84 # compiled regexps for autoindent management
85 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
85 dedent_re = re.compile(r'^\s+raise|^\s+return|^\s+pass')
86
86
87
87
88 #****************************************************************************
88 #****************************************************************************
89 # Some utility function definitions
89 # Some utility function definitions
90
90
91 ini_spaces_re = re.compile(r'^(\s+)')
91 ini_spaces_re = re.compile(r'^(\s+)')
92
92
93 def num_ini_spaces(strng):
93 def num_ini_spaces(strng):
94 """Return the number of initial spaces in a string"""
94 """Return the number of initial spaces in a string"""
95
95
96 ini_spaces = ini_spaces_re.match(strng)
96 ini_spaces = ini_spaces_re.match(strng)
97 if ini_spaces:
97 if ini_spaces:
98 return ini_spaces.end()
98 return ini_spaces.end()
99 else:
99 else:
100 return 0
100 return 0
101
101
102 def softspace(file, newvalue):
102 def softspace(file, newvalue):
103 """Copied from code.py, to remove the dependency"""
103 """Copied from code.py, to remove the dependency"""
104
104
105 oldvalue = 0
105 oldvalue = 0
106 try:
106 try:
107 oldvalue = file.softspace
107 oldvalue = file.softspace
108 except AttributeError:
108 except AttributeError:
109 pass
109 pass
110 try:
110 try:
111 file.softspace = newvalue
111 file.softspace = newvalue
112 except (AttributeError, TypeError):
112 except (AttributeError, TypeError):
113 # "attribute-less object" or "read-only attributes"
113 # "attribute-less object" or "read-only attributes"
114 pass
114 pass
115 return oldvalue
115 return oldvalue
116
116
117
117
118 #****************************************************************************
118 #****************************************************************************
119 # Local use exceptions
119 # Local use exceptions
120 class SpaceInInput(exceptions.Exception): pass
120 class SpaceInInput(exceptions.Exception): pass
121
121
122
122
123 #****************************************************************************
123 #****************************************************************************
124 # Local use classes
124 # Local use classes
125 class Bunch: pass
125 class Bunch: pass
126
126
127 class Undefined: pass
127 class Undefined: pass
128
128
129 class Quitter(object):
129 class Quitter(object):
130 """Simple class to handle exit, similar to Python 2.5's.
130 """Simple class to handle exit, similar to Python 2.5's.
131
131
132 It handles exiting in an ipython-safe manner, which the one in Python 2.5
132 It handles exiting in an ipython-safe manner, which the one in Python 2.5
133 doesn't do (obviously, since it doesn't know about ipython)."""
133 doesn't do (obviously, since it doesn't know about ipython)."""
134
134
135 def __init__(self,shell,name):
135 def __init__(self,shell,name):
136 self.shell = shell
136 self.shell = shell
137 self.name = name
137 self.name = name
138
138
139 def __repr__(self):
139 def __repr__(self):
140 return 'Type %s() to exit.' % self.name
140 return 'Type %s() to exit.' % self.name
141 __str__ = __repr__
141 __str__ = __repr__
142
142
143 def __call__(self):
143 def __call__(self):
144 self.shell.exit()
144 self.shell.exit()
145
145
146 class InputList(list):
146 class InputList(list):
147 """Class to store user input.
147 """Class to store user input.
148
148
149 It's basically a list, but slices return a string instead of a list, thus
149 It's basically a list, but slices return a string instead of a list, thus
150 allowing things like (assuming 'In' is an instance):
150 allowing things like (assuming 'In' is an instance):
151
151
152 exec In[4:7]
152 exec In[4:7]
153
153
154 or
154 or
155
155
156 exec In[5:9] + In[14] + In[21:25]"""
156 exec In[5:9] + In[14] + In[21:25]"""
157
157
158 def __getslice__(self,i,j):
158 def __getslice__(self,i,j):
159 return ''.join(list.__getslice__(self,i,j))
159 return ''.join(list.__getslice__(self,i,j))
160
160
161 class SyntaxTB(ultraTB.ListTB):
161 class SyntaxTB(ultraTB.ListTB):
162 """Extension which holds some state: the last exception value"""
162 """Extension which holds some state: the last exception value"""
163
163
164 def __init__(self,color_scheme = 'NoColor'):
164 def __init__(self,color_scheme = 'NoColor'):
165 ultraTB.ListTB.__init__(self,color_scheme)
165 ultraTB.ListTB.__init__(self,color_scheme)
166 self.last_syntax_error = None
166 self.last_syntax_error = None
167
167
168 def __call__(self, etype, value, elist):
168 def __call__(self, etype, value, elist):
169 self.last_syntax_error = value
169 self.last_syntax_error = value
170 ultraTB.ListTB.__call__(self,etype,value,elist)
170 ultraTB.ListTB.__call__(self,etype,value,elist)
171
171
172 def clear_err_state(self):
172 def clear_err_state(self):
173 """Return the current error state and clear it"""
173 """Return the current error state and clear it"""
174 e = self.last_syntax_error
174 e = self.last_syntax_error
175 self.last_syntax_error = None
175 self.last_syntax_error = None
176 return e
176 return e
177
177
178 #****************************************************************************
178 #****************************************************************************
179 # Main IPython class
179 # Main IPython class
180
180
181 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
181 # FIXME: the Magic class is a mixin for now, and will unfortunately remain so
182 # until a full rewrite is made. I've cleaned all cross-class uses of
182 # until a full rewrite is made. I've cleaned all cross-class uses of
183 # attributes and methods, but too much user code out there relies on the
183 # attributes and methods, but too much user code out there relies on the
184 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
184 # equlity %foo == __IP.magic_foo, so I can't actually remove the mixin usage.
185 #
185 #
186 # But at least now, all the pieces have been separated and we could, in
186 # But at least now, all the pieces have been separated and we could, in
187 # principle, stop using the mixin. This will ease the transition to the
187 # principle, stop using the mixin. This will ease the transition to the
188 # chainsaw branch.
188 # chainsaw branch.
189
189
190 # For reference, the following is the list of 'self.foo' uses in the Magic
190 # For reference, the following is the list of 'self.foo' uses in the Magic
191 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
191 # class as of 2005-12-28. These are names we CAN'T use in the main ipython
192 # class, to prevent clashes.
192 # class, to prevent clashes.
193
193
194 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
194 # ['self.__class__', 'self.__dict__', 'self._inspect', 'self._ofind',
195 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
195 # 'self.arg_err', 'self.extract_input', 'self.format_', 'self.lsmagic',
196 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
196 # 'self.magic_', 'self.options_table', 'self.parse', 'self.shell',
197 # 'self.value']
197 # 'self.value']
198
198
199 class InteractiveShell(object,Magic):
199 class InteractiveShell(object,Magic):
200 """An enhanced console for Python."""
200 """An enhanced console for Python."""
201
201
202 # class attribute to indicate whether the class supports threads or not.
202 # class attribute to indicate whether the class supports threads or not.
203 # Subclasses with thread support should override this as needed.
203 # Subclasses with thread support should override this as needed.
204 isthreaded = False
204 isthreaded = False
205
205
206 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
206 def __init__(self,name,usage=None,rc=Struct(opts=None,args=None),
207 user_ns = None,user_global_ns=None,banner2='',
207 user_ns = None,user_global_ns=None,banner2='',
208 custom_exceptions=((),None),embedded=False):
208 custom_exceptions=((),None),embedded=False):
209
209
210 # log system
210 # log system
211 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
211 self.logger = Logger(self,logfname='ipython_log.py',logmode='rotate')
212
212
213 # some minimal strict typechecks. For some core data structures, I
213 # some minimal strict typechecks. For some core data structures, I
214 # want actual basic python types, not just anything that looks like
214 # want actual basic python types, not just anything that looks like
215 # one. This is especially true for namespaces.
215 # one. This is especially true for namespaces.
216 for ns in (user_ns,user_global_ns):
216 for ns in (user_ns,user_global_ns):
217 if ns is not None and type(ns) != types.DictType:
217 if ns is not None and type(ns) != types.DictType:
218 raise TypeError,'namespace must be a dictionary'
218 raise TypeError,'namespace must be a dictionary'
219
219
220 # Job manager (for jobs run as background threads)
220 # Job manager (for jobs run as background threads)
221 self.jobs = BackgroundJobManager()
221 self.jobs = BackgroundJobManager()
222
222
223 # Store the actual shell's name
223 # Store the actual shell's name
224 self.name = name
224 self.name = name
225
225
226 # We need to know whether the instance is meant for embedding, since
226 # We need to know whether the instance is meant for embedding, since
227 # global/local namespaces need to be handled differently in that case
227 # global/local namespaces need to be handled differently in that case
228 self.embedded = embedded
228 self.embedded = embedded
229
229
230 # command compiler
230 # command compiler
231 self.compile = codeop.CommandCompiler()
231 self.compile = codeop.CommandCompiler()
232
232
233 # User input buffer
233 # User input buffer
234 self.buffer = []
234 self.buffer = []
235
235
236 # Default name given in compilation of code
236 # Default name given in compilation of code
237 self.filename = '<ipython console>'
237 self.filename = '<ipython console>'
238
238
239 # Install our own quitter instead of the builtins. For python2.3-2.4,
239 # Install our own quitter instead of the builtins. For python2.3-2.4,
240 # this brings in behavior like 2.5, and for 2.5 it's identical.
240 # this brings in behavior like 2.5, and for 2.5 it's identical.
241 __builtin__.exit = Quitter(self,'exit')
241 __builtin__.exit = Quitter(self,'exit')
242 __builtin__.quit = Quitter(self,'quit')
242 __builtin__.quit = Quitter(self,'quit')
243
243
244 # Make an empty namespace, which extension writers can rely on both
244 # Make an empty namespace, which extension writers can rely on both
245 # existing and NEVER being used by ipython itself. This gives them a
245 # existing and NEVER being used by ipython itself. This gives them a
246 # convenient location for storing additional information and state
246 # convenient location for storing additional information and state
247 # their extensions may require, without fear of collisions with other
247 # their extensions may require, without fear of collisions with other
248 # ipython names that may develop later.
248 # ipython names that may develop later.
249 self.meta = Struct()
249 self.meta = Struct()
250
250
251 # Create the namespace where the user will operate. user_ns is
251 # Create the namespace where the user will operate. user_ns is
252 # normally the only one used, and it is passed to the exec calls as
252 # normally the only one used, and it is passed to the exec calls as
253 # the locals argument. But we do carry a user_global_ns namespace
253 # the locals argument. But we do carry a user_global_ns namespace
254 # given as the exec 'globals' argument, This is useful in embedding
254 # given as the exec 'globals' argument, This is useful in embedding
255 # situations where the ipython shell opens in a context where the
255 # situations where the ipython shell opens in a context where the
256 # distinction between locals and globals is meaningful.
256 # distinction between locals and globals is meaningful.
257
257
258 # FIXME. For some strange reason, __builtins__ is showing up at user
258 # FIXME. For some strange reason, __builtins__ is showing up at user
259 # level as a dict instead of a module. This is a manual fix, but I
259 # level as a dict instead of a module. This is a manual fix, but I
260 # should really track down where the problem is coming from. Alex
260 # should really track down where the problem is coming from. Alex
261 # Schmolck reported this problem first.
261 # Schmolck reported this problem first.
262
262
263 # A useful post by Alex Martelli on this topic:
263 # A useful post by Alex Martelli on this topic:
264 # Re: inconsistent value from __builtins__
264 # Re: inconsistent value from __builtins__
265 # Von: Alex Martelli <aleaxit@yahoo.com>
265 # Von: Alex Martelli <aleaxit@yahoo.com>
266 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
266 # Datum: Freitag 01 Oktober 2004 04:45:34 nachmittags/abends
267 # Gruppen: comp.lang.python
267 # Gruppen: comp.lang.python
268
268
269 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
269 # Michael Hohn <hohn@hooknose.lbl.gov> wrote:
270 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
270 # > >>> print type(builtin_check.get_global_binding('__builtins__'))
271 # > <type 'dict'>
271 # > <type 'dict'>
272 # > >>> print type(__builtins__)
272 # > >>> print type(__builtins__)
273 # > <type 'module'>
273 # > <type 'module'>
274 # > Is this difference in return value intentional?
274 # > Is this difference in return value intentional?
275
275
276 # Well, it's documented that '__builtins__' can be either a dictionary
276 # Well, it's documented that '__builtins__' can be either a dictionary
277 # or a module, and it's been that way for a long time. Whether it's
277 # or a module, and it's been that way for a long time. Whether it's
278 # intentional (or sensible), I don't know. In any case, the idea is
278 # intentional (or sensible), I don't know. In any case, the idea is
279 # that if you need to access the built-in namespace directly, you
279 # that if you need to access the built-in namespace directly, you
280 # should start with "import __builtin__" (note, no 's') which will
280 # should start with "import __builtin__" (note, no 's') which will
281 # definitely give you a module. Yeah, it's somewhat confusing:-(.
281 # definitely give you a module. Yeah, it's somewhat confusing:-(.
282
282
283 # These routines return properly built dicts as needed by the rest of
283 # These routines return properly built dicts as needed by the rest of
284 # the code, and can also be used by extension writers to generate
284 # the code, and can also be used by extension writers to generate
285 # properly initialized namespaces.
285 # properly initialized namespaces.
286 user_ns = IPython.ipapi.make_user_ns(user_ns)
286 user_ns = IPython.ipapi.make_user_ns(user_ns)
287 user_global_ns = IPython.ipapi.make_user_global_ns(user_global_ns)
287 user_global_ns = IPython.ipapi.make_user_global_ns(user_global_ns)
288
288
289 # Assign namespaces
289 # Assign namespaces
290 # This is the namespace where all normal user variables live
290 # This is the namespace where all normal user variables live
291 self.user_ns = user_ns
291 self.user_ns = user_ns
292 # Embedded instances require a separate namespace for globals.
292 # Embedded instances require a separate namespace for globals.
293 # Normally this one is unused by non-embedded instances.
293 # Normally this one is unused by non-embedded instances.
294 self.user_global_ns = user_global_ns
294 self.user_global_ns = user_global_ns
295 # A namespace to keep track of internal data structures to prevent
295 # A namespace to keep track of internal data structures to prevent
296 # them from cluttering user-visible stuff. Will be updated later
296 # them from cluttering user-visible stuff. Will be updated later
297 self.internal_ns = {}
297 self.internal_ns = {}
298
298
299 # Namespace of system aliases. Each entry in the alias
299 # Namespace of system aliases. Each entry in the alias
300 # table must be a 2-tuple of the form (N,name), where N is the number
300 # table must be a 2-tuple of the form (N,name), where N is the number
301 # of positional arguments of the alias.
301 # of positional arguments of the alias.
302 self.alias_table = {}
302 self.alias_table = {}
303
303
304 # A table holding all the namespaces IPython deals with, so that
304 # A table holding all the namespaces IPython deals with, so that
305 # introspection facilities can search easily.
305 # introspection facilities can search easily.
306 self.ns_table = {'user':user_ns,
306 self.ns_table = {'user':user_ns,
307 'user_global':user_global_ns,
307 'user_global':user_global_ns,
308 'alias':self.alias_table,
308 'alias':self.alias_table,
309 'internal':self.internal_ns,
309 'internal':self.internal_ns,
310 'builtin':__builtin__.__dict__
310 'builtin':__builtin__.__dict__
311 }
311 }
312
312
313 # The user namespace MUST have a pointer to the shell itself.
313 # The user namespace MUST have a pointer to the shell itself.
314 self.user_ns[name] = self
314 self.user_ns[name] = self
315
315
316 # We need to insert into sys.modules something that looks like a
316 # We need to insert into sys.modules something that looks like a
317 # module but which accesses the IPython namespace, for shelve and
317 # module but which accesses the IPython namespace, for shelve and
318 # pickle to work interactively. Normally they rely on getting
318 # pickle to work interactively. Normally they rely on getting
319 # everything out of __main__, but for embedding purposes each IPython
319 # everything out of __main__, but for embedding purposes each IPython
320 # instance has its own private namespace, so we can't go shoving
320 # instance has its own private namespace, so we can't go shoving
321 # everything into __main__.
321 # everything into __main__.
322
322
323 # note, however, that we should only do this for non-embedded
323 # note, however, that we should only do this for non-embedded
324 # ipythons, which really mimic the __main__.__dict__ with their own
324 # ipythons, which really mimic the __main__.__dict__ with their own
325 # namespace. Embedded instances, on the other hand, should not do
325 # namespace. Embedded instances, on the other hand, should not do
326 # this because they need to manage the user local/global namespaces
326 # this because they need to manage the user local/global namespaces
327 # only, but they live within a 'normal' __main__ (meaning, they
327 # only, but they live within a 'normal' __main__ (meaning, they
328 # shouldn't overtake the execution environment of the script they're
328 # shouldn't overtake the execution environment of the script they're
329 # embedded in).
329 # embedded in).
330
330
331 if not embedded:
331 if not embedded:
332 try:
332 try:
333 main_name = self.user_ns['__name__']
333 main_name = self.user_ns['__name__']
334 except KeyError:
334 except KeyError:
335 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
335 raise KeyError,'user_ns dictionary MUST have a "__name__" key'
336 else:
336 else:
337 #print "pickle hack in place" # dbg
337 #print "pickle hack in place" # dbg
338 #print 'main_name:',main_name # dbg
338 #print 'main_name:',main_name # dbg
339 sys.modules[main_name] = FakeModule(self.user_ns)
339 sys.modules[main_name] = FakeModule(self.user_ns)
340
340
341 # List of input with multi-line handling.
341 # List of input with multi-line handling.
342 # Fill its zero entry, user counter starts at 1
342 # Fill its zero entry, user counter starts at 1
343 self.input_hist = InputList(['\n'])
343 self.input_hist = InputList(['\n'])
344 # This one will hold the 'raw' input history, without any
344 # This one will hold the 'raw' input history, without any
345 # pre-processing. This will allow users to retrieve the input just as
345 # pre-processing. This will allow users to retrieve the input just as
346 # it was exactly typed in by the user, with %hist -r.
346 # it was exactly typed in by the user, with %hist -r.
347 self.input_hist_raw = InputList(['\n'])
347 self.input_hist_raw = InputList(['\n'])
348
348
349 # list of visited directories
349 # list of visited directories
350 try:
350 try:
351 self.dir_hist = [os.getcwd()]
351 self.dir_hist = [os.getcwd()]
352 except IOError, e:
352 except IOError, e:
353 self.dir_hist = []
353 self.dir_hist = []
354
354
355 # dict of output history
355 # dict of output history
356 self.output_hist = {}
356 self.output_hist = {}
357
357
358 # dict of things NOT to alias (keywords, builtins and some magics)
358 # dict of things NOT to alias (keywords, builtins and some magics)
359 no_alias = {}
359 no_alias = {}
360 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
360 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
361 for key in keyword.kwlist + no_alias_magics:
361 for key in keyword.kwlist + no_alias_magics:
362 no_alias[key] = 1
362 no_alias[key] = 1
363 no_alias.update(__builtin__.__dict__)
363 no_alias.update(__builtin__.__dict__)
364 self.no_alias = no_alias
364 self.no_alias = no_alias
365
365
366 # make global variables for user access to these
366 # make global variables for user access to these
367 self.user_ns['_ih'] = self.input_hist
367 self.user_ns['_ih'] = self.input_hist
368 self.user_ns['_oh'] = self.output_hist
368 self.user_ns['_oh'] = self.output_hist
369 self.user_ns['_dh'] = self.dir_hist
369 self.user_ns['_dh'] = self.dir_hist
370
370
371 # user aliases to input and output histories
371 # user aliases to input and output histories
372 self.user_ns['In'] = self.input_hist
372 self.user_ns['In'] = self.input_hist
373 self.user_ns['Out'] = self.output_hist
373 self.user_ns['Out'] = self.output_hist
374
374
375 # Object variable to store code object waiting execution. This is
375 # Object variable to store code object waiting execution. This is
376 # used mainly by the multithreaded shells, but it can come in handy in
376 # used mainly by the multithreaded shells, but it can come in handy in
377 # other situations. No need to use a Queue here, since it's a single
377 # other situations. No need to use a Queue here, since it's a single
378 # item which gets cleared once run.
378 # item which gets cleared once run.
379 self.code_to_run = None
379 self.code_to_run = None
380
380
381 # escapes for automatic behavior on the command line
381 # escapes for automatic behavior on the command line
382 self.ESC_SHELL = '!'
382 self.ESC_SHELL = '!'
383 self.ESC_HELP = '?'
383 self.ESC_HELP = '?'
384 self.ESC_MAGIC = '%'
384 self.ESC_MAGIC = '%'
385 self.ESC_QUOTE = ','
385 self.ESC_QUOTE = ','
386 self.ESC_QUOTE2 = ';'
386 self.ESC_QUOTE2 = ';'
387 self.ESC_PAREN = '/'
387 self.ESC_PAREN = '/'
388
388
389 # And their associated handlers
389 # And their associated handlers
390 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
390 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
391 self.ESC_QUOTE : self.handle_auto,
391 self.ESC_QUOTE : self.handle_auto,
392 self.ESC_QUOTE2 : self.handle_auto,
392 self.ESC_QUOTE2 : self.handle_auto,
393 self.ESC_MAGIC : self.handle_magic,
393 self.ESC_MAGIC : self.handle_magic,
394 self.ESC_HELP : self.handle_help,
394 self.ESC_HELP : self.handle_help,
395 self.ESC_SHELL : self.handle_shell_escape,
395 self.ESC_SHELL : self.handle_shell_escape,
396 }
396 }
397
397
398 # class initializations
398 # class initializations
399 Magic.__init__(self,self)
399 Magic.__init__(self,self)
400
400
401 # Python source parser/formatter for syntax highlighting
401 # Python source parser/formatter for syntax highlighting
402 pyformat = PyColorize.Parser().format
402 pyformat = PyColorize.Parser().format
403 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
403 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
404
404
405 # hooks holds pointers used for user-side customizations
405 # hooks holds pointers used for user-side customizations
406 self.hooks = Struct()
406 self.hooks = Struct()
407
407
408 self.strdispatchers = {}
408 self.strdispatchers = {}
409
409
410 # Set all default hooks, defined in the IPython.hooks module.
410 # Set all default hooks, defined in the IPython.hooks module.
411 hooks = IPython.hooks
411 hooks = IPython.hooks
412 for hook_name in hooks.__all__:
412 for hook_name in hooks.__all__:
413 # default hooks have priority 100, i.e. low; user hooks should have 0-100 priority
413 # default hooks have priority 100, i.e. low; user hooks should have 0-100 priority
414 self.set_hook(hook_name,getattr(hooks,hook_name), 100)
414 self.set_hook(hook_name,getattr(hooks,hook_name), 100)
415 #print "bound hook",hook_name
415 #print "bound hook",hook_name
416
416
417 # Flag to mark unconditional exit
417 # Flag to mark unconditional exit
418 self.exit_now = False
418 self.exit_now = False
419
419
420 self.usage_min = """\
420 self.usage_min = """\
421 An enhanced console for Python.
421 An enhanced console for Python.
422 Some of its features are:
422 Some of its features are:
423 - Readline support if the readline library is present.
423 - Readline support if the readline library is present.
424 - Tab completion in the local namespace.
424 - Tab completion in the local namespace.
425 - Logging of input, see command-line options.
425 - Logging of input, see command-line options.
426 - System shell escape via ! , eg !ls.
426 - System shell escape via ! , eg !ls.
427 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
427 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
428 - Keeps track of locally defined variables via %who, %whos.
428 - Keeps track of locally defined variables via %who, %whos.
429 - Show object information with a ? eg ?x or x? (use ?? for more info).
429 - Show object information with a ? eg ?x or x? (use ?? for more info).
430 """
430 """
431 if usage: self.usage = usage
431 if usage: self.usage = usage
432 else: self.usage = self.usage_min
432 else: self.usage = self.usage_min
433
433
434 # Storage
434 # Storage
435 self.rc = rc # This will hold all configuration information
435 self.rc = rc # This will hold all configuration information
436 self.pager = 'less'
436 self.pager = 'less'
437 # temporary files used for various purposes. Deleted at exit.
437 # temporary files used for various purposes. Deleted at exit.
438 self.tempfiles = []
438 self.tempfiles = []
439
439
440 # Keep track of readline usage (later set by init_readline)
440 # Keep track of readline usage (later set by init_readline)
441 self.has_readline = False
441 self.has_readline = False
442
442
443 # template for logfile headers. It gets resolved at runtime by the
443 # template for logfile headers. It gets resolved at runtime by the
444 # logstart method.
444 # logstart method.
445 self.loghead_tpl = \
445 self.loghead_tpl = \
446 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
446 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
447 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
447 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
448 #log# opts = %s
448 #log# opts = %s
449 #log# args = %s
449 #log# args = %s
450 #log# It is safe to make manual edits below here.
450 #log# It is safe to make manual edits below here.
451 #log#-----------------------------------------------------------------------
451 #log#-----------------------------------------------------------------------
452 """
452 """
453 # for pushd/popd management
453 # for pushd/popd management
454 try:
454 try:
455 self.home_dir = get_home_dir()
455 self.home_dir = get_home_dir()
456 except HomeDirError,msg:
456 except HomeDirError,msg:
457 fatal(msg)
457 fatal(msg)
458
458
459 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
459 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
460
460
461 # Functions to call the underlying shell.
461 # Functions to call the underlying shell.
462
462
463 # The first is similar to os.system, but it doesn't return a value,
463 # The first is similar to os.system, but it doesn't return a value,
464 # and it allows interpolation of variables in the user's namespace.
464 # and it allows interpolation of variables in the user's namespace.
465 self.system = lambda cmd: \
465 self.system = lambda cmd: \
466 shell(self.var_expand(cmd,depth=2),
466 shell(self.var_expand(cmd,depth=2),
467 header=self.rc.system_header,
467 header=self.rc.system_header,
468 verbose=self.rc.system_verbose)
468 verbose=self.rc.system_verbose)
469
469
470 # These are for getoutput and getoutputerror:
470 # These are for getoutput and getoutputerror:
471 self.getoutput = lambda cmd: \
471 self.getoutput = lambda cmd: \
472 getoutput(self.var_expand(cmd,depth=2),
472 getoutput(self.var_expand(cmd,depth=2),
473 header=self.rc.system_header,
473 header=self.rc.system_header,
474 verbose=self.rc.system_verbose)
474 verbose=self.rc.system_verbose)
475
475
476 self.getoutputerror = lambda cmd: \
476 self.getoutputerror = lambda cmd: \
477 getoutputerror(self.var_expand(cmd,depth=2),
477 getoutputerror(self.var_expand(cmd,depth=2),
478 header=self.rc.system_header,
478 header=self.rc.system_header,
479 verbose=self.rc.system_verbose)
479 verbose=self.rc.system_verbose)
480
480
481 # RegExp for splitting line contents into pre-char//first
481 # RegExp for splitting line contents into pre-char//first
482 # word-method//rest. For clarity, each group in on one line.
482 # word-method//rest. For clarity, each group in on one line.
483
483
484 # WARNING: update the regexp if the above escapes are changed, as they
484 # WARNING: update the regexp if the above escapes are changed, as they
485 # are hardwired in.
485 # are hardwired in.
486
486
487 # Don't get carried away with trying to make the autocalling catch too
487 # Don't get carried away with trying to make the autocalling catch too
488 # much: it's better to be conservative rather than to trigger hidden
488 # much: it's better to be conservative rather than to trigger hidden
489 # evals() somewhere and end up causing side effects.
489 # evals() somewhere and end up causing side effects.
490
490
491 self.line_split = re.compile(r'^([\s*,;/])'
491 self.line_split = re.compile(r'^([\s*,;/])'
492 r'([\?\w\.]+\w*\s*)'
492 r'([\?\w\.]+\w*\s*)'
493 r'(\(?.*$)')
493 r'(\(?.*$)')
494
494
495 # Original re, keep around for a while in case changes break something
495 # Original re, keep around for a while in case changes break something
496 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
496 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
497 # r'(\s*[\?\w\.]+\w*\s*)'
497 # r'(\s*[\?\w\.]+\w*\s*)'
498 # r'(\(?.*$)')
498 # r'(\(?.*$)')
499
499
500 # RegExp to identify potential function names
500 # RegExp to identify potential function names
501 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
501 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
502
502
503 # RegExp to exclude strings with this start from autocalling. In
503 # RegExp to exclude strings with this start from autocalling. In
504 # particular, all binary operators should be excluded, so that if foo
504 # particular, all binary operators should be excluded, so that if foo
505 # is callable, foo OP bar doesn't become foo(OP bar), which is
505 # is callable, foo OP bar doesn't become foo(OP bar), which is
506 # invalid. The characters '!=()' don't need to be checked for, as the
506 # invalid. The characters '!=()' don't need to be checked for, as the
507 # _prefilter routine explicitely does so, to catch direct calls and
507 # _prefilter routine explicitely does so, to catch direct calls and
508 # rebindings of existing names.
508 # rebindings of existing names.
509
509
510 # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise
510 # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise
511 # it affects the rest of the group in square brackets.
511 # it affects the rest of the group in square brackets.
512 self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]'
512 self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]'
513 '|^is |^not |^in |^and |^or ')
513 '|^is |^not |^in |^and |^or ')
514
514
515 # try to catch also methods for stuff in lists/tuples/dicts: off
515 # try to catch also methods for stuff in lists/tuples/dicts: off
516 # (experimental). For this to work, the line_split regexp would need
516 # (experimental). For this to work, the line_split regexp would need
517 # to be modified so it wouldn't break things at '['. That line is
517 # to be modified so it wouldn't break things at '['. That line is
518 # nasty enough that I shouldn't change it until I can test it _well_.
518 # nasty enough that I shouldn't change it until I can test it _well_.
519 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
519 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
520
520
521 # keep track of where we started running (mainly for crash post-mortem)
521 # keep track of where we started running (mainly for crash post-mortem)
522 self.starting_dir = os.getcwd()
522 self.starting_dir = os.getcwd()
523
523
524 # Various switches which can be set
524 # Various switches which can be set
525 self.CACHELENGTH = 5000 # this is cheap, it's just text
525 self.CACHELENGTH = 5000 # this is cheap, it's just text
526 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
526 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
527 self.banner2 = banner2
527 self.banner2 = banner2
528
528
529 # TraceBack handlers:
529 # TraceBack handlers:
530
530
531 # Syntax error handler.
531 # Syntax error handler.
532 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
532 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
533
533
534 # The interactive one is initialized with an offset, meaning we always
534 # The interactive one is initialized with an offset, meaning we always
535 # want to remove the topmost item in the traceback, which is our own
535 # want to remove the topmost item in the traceback, which is our own
536 # internal code. Valid modes: ['Plain','Context','Verbose']
536 # internal code. Valid modes: ['Plain','Context','Verbose']
537 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
537 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
538 color_scheme='NoColor',
538 color_scheme='NoColor',
539 tb_offset = 1)
539 tb_offset = 1)
540
540
541 # IPython itself shouldn't crash. This will produce a detailed
541 # IPython itself shouldn't crash. This will produce a detailed
542 # post-mortem if it does. But we only install the crash handler for
542 # post-mortem if it does. But we only install the crash handler for
543 # non-threaded shells, the threaded ones use a normal verbose reporter
543 # non-threaded shells, the threaded ones use a normal verbose reporter
544 # and lose the crash handler. This is because exceptions in the main
544 # and lose the crash handler. This is because exceptions in the main
545 # thread (such as in GUI code) propagate directly to sys.excepthook,
545 # thread (such as in GUI code) propagate directly to sys.excepthook,
546 # and there's no point in printing crash dumps for every user exception.
546 # and there's no point in printing crash dumps for every user exception.
547 if self.isthreaded:
547 if self.isthreaded:
548 ipCrashHandler = ultraTB.FormattedTB()
548 ipCrashHandler = ultraTB.FormattedTB()
549 else:
549 else:
550 from IPython import CrashHandler
550 from IPython import CrashHandler
551 ipCrashHandler = CrashHandler.IPythonCrashHandler(self)
551 ipCrashHandler = CrashHandler.IPythonCrashHandler(self)
552 self.set_crash_handler(ipCrashHandler)
552 self.set_crash_handler(ipCrashHandler)
553
553
554 # and add any custom exception handlers the user may have specified
554 # and add any custom exception handlers the user may have specified
555 self.set_custom_exc(*custom_exceptions)
555 self.set_custom_exc(*custom_exceptions)
556
556
557 # indentation management
557 # indentation management
558 self.autoindent = False
558 self.autoindent = False
559 self.indent_current_nsp = 0
559 self.indent_current_nsp = 0
560
560
561 # Make some aliases automatically
561 # Make some aliases automatically
562 # Prepare list of shell aliases to auto-define
562 # Prepare list of shell aliases to auto-define
563 if os.name == 'posix':
563 if os.name == 'posix':
564 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
564 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
565 'mv mv -i','rm rm -i','cp cp -i',
565 'mv mv -i','rm rm -i','cp cp -i',
566 'cat cat','less less','clear clear',
566 'cat cat','less less','clear clear',
567 # a better ls
567 # a better ls
568 'ls ls -F',
568 'ls ls -F',
569 # long ls
569 # long ls
570 'll ls -lF')
570 'll ls -lF')
571 # Extra ls aliases with color, which need special treatment on BSD
571 # Extra ls aliases with color, which need special treatment on BSD
572 # variants
572 # variants
573 ls_extra = ( # color ls
573 ls_extra = ( # color ls
574 'lc ls -F -o --color',
574 'lc ls -F -o --color',
575 # ls normal files only
575 # ls normal files only
576 'lf ls -F -o --color %l | grep ^-',
576 'lf ls -F -o --color %l | grep ^-',
577 # ls symbolic links
577 # ls symbolic links
578 'lk ls -F -o --color %l | grep ^l',
578 'lk ls -F -o --color %l | grep ^l',
579 # directories or links to directories,
579 # directories or links to directories,
580 'ldir ls -F -o --color %l | grep /$',
580 'ldir ls -F -o --color %l | grep /$',
581 # things which are executable
581 # things which are executable
582 'lx ls -F -o --color %l | grep ^-..x',
582 'lx ls -F -o --color %l | grep ^-..x',
583 )
583 )
584 # The BSDs don't ship GNU ls, so they don't understand the
584 # The BSDs don't ship GNU ls, so they don't understand the
585 # --color switch out of the box
585 # --color switch out of the box
586 if 'bsd' in sys.platform:
586 if 'bsd' in sys.platform:
587 ls_extra = ( # ls normal files only
587 ls_extra = ( # ls normal files only
588 'lf ls -lF | grep ^-',
588 'lf ls -lF | grep ^-',
589 # ls symbolic links
589 # ls symbolic links
590 'lk ls -lF | grep ^l',
590 'lk ls -lF | grep ^l',
591 # directories or links to directories,
591 # directories or links to directories,
592 'ldir ls -lF | grep /$',
592 'ldir ls -lF | grep /$',
593 # things which are executable
593 # things which are executable
594 'lx ls -lF | grep ^-..x',
594 'lx ls -lF | grep ^-..x',
595 )
595 )
596 auto_alias = auto_alias + ls_extra
596 auto_alias = auto_alias + ls_extra
597 elif os.name in ['nt','dos']:
597 elif os.name in ['nt','dos']:
598 auto_alias = ('dir dir /on', 'ls dir /on',
598 auto_alias = ('dir dir /on', 'ls dir /on',
599 'ddir dir /ad /on', 'ldir dir /ad /on',
599 'ddir dir /ad /on', 'ldir dir /ad /on',
600 'mkdir mkdir','rmdir rmdir','echo echo',
600 'mkdir mkdir','rmdir rmdir','echo echo',
601 'ren ren','cls cls','copy copy')
601 'ren ren','cls cls','copy copy')
602 else:
602 else:
603 auto_alias = ()
603 auto_alias = ()
604 self.auto_alias = [s.split(None,1) for s in auto_alias]
604 self.auto_alias = [s.split(None,1) for s in auto_alias]
605 # Call the actual (public) initializer
605 # Call the actual (public) initializer
606 self.init_auto_alias()
606 self.init_auto_alias()
607
607
608 # Produce a public API instance
608 # Produce a public API instance
609 self.api = IPython.ipapi.IPApi(self)
609 self.api = IPython.ipapi.IPApi(self)
610
610
611 # track which builtins we add, so we can clean up later
611 # track which builtins we add, so we can clean up later
612 self.builtins_added = {}
612 self.builtins_added = {}
613 # This method will add the necessary builtins for operation, but
613 # This method will add the necessary builtins for operation, but
614 # tracking what it did via the builtins_added dict.
614 # tracking what it did via the builtins_added dict.
615 self.add_builtins()
615 self.add_builtins()
616
616
617 # end __init__
617 # end __init__
618
618
619 def var_expand(self,cmd,depth=0):
619 def var_expand(self,cmd,depth=0):
620 """Expand python variables in a string.
620 """Expand python variables in a string.
621
621
622 The depth argument indicates how many frames above the caller should
622 The depth argument indicates how many frames above the caller should
623 be walked to look for the local namespace where to expand variables.
623 be walked to look for the local namespace where to expand variables.
624
624
625 The global namespace for expansion is always the user's interactive
625 The global namespace for expansion is always the user's interactive
626 namespace.
626 namespace.
627 """
627 """
628
628
629 return str(ItplNS(cmd.replace('#','\#'),
629 return str(ItplNS(cmd.replace('#','\#'),
630 self.user_ns, # globals
630 self.user_ns, # globals
631 # Skip our own frame in searching for locals:
631 # Skip our own frame in searching for locals:
632 sys._getframe(depth+1).f_locals # locals
632 sys._getframe(depth+1).f_locals # locals
633 ))
633 ))
634
634
635 def pre_config_initialization(self):
635 def pre_config_initialization(self):
636 """Pre-configuration init method
636 """Pre-configuration init method
637
637
638 This is called before the configuration files are processed to
638 This is called before the configuration files are processed to
639 prepare the services the config files might need.
639 prepare the services the config files might need.
640
640
641 self.rc already has reasonable default values at this point.
641 self.rc already has reasonable default values at this point.
642 """
642 """
643 rc = self.rc
643 rc = self.rc
644
644
645 self.db = pickleshare.PickleShareDB(rc.ipythondir + "/db")
645 self.db = pickleshare.PickleShareDB(rc.ipythondir + "/db")
646
646
647 def post_config_initialization(self):
647 def post_config_initialization(self):
648 """Post configuration init method
648 """Post configuration init method
649
649
650 This is called after the configuration files have been processed to
650 This is called after the configuration files have been processed to
651 'finalize' the initialization."""
651 'finalize' the initialization."""
652
652
653 rc = self.rc
653 rc = self.rc
654
654
655 # Object inspector
655 # Object inspector
656 self.inspector = OInspect.Inspector(OInspect.InspectColors,
656 self.inspector = OInspect.Inspector(OInspect.InspectColors,
657 PyColorize.ANSICodeColors,
657 PyColorize.ANSICodeColors,
658 'NoColor',
658 'NoColor',
659 rc.object_info_string_level)
659 rc.object_info_string_level)
660
660
661 # Load readline proper
661 # Load readline proper
662 if rc.readline:
662 if rc.readline:
663 self.init_readline()
663 self.init_readline()
664
664
665 # local shortcut, this is used a LOT
665 # local shortcut, this is used a LOT
666 self.log = self.logger.log
666 self.log = self.logger.log
667
667
668 # Initialize cache, set in/out prompts and printing system
668 # Initialize cache, set in/out prompts and printing system
669 self.outputcache = CachedOutput(self,
669 self.outputcache = CachedOutput(self,
670 rc.cache_size,
670 rc.cache_size,
671 rc.pprint,
671 rc.pprint,
672 input_sep = rc.separate_in,
672 input_sep = rc.separate_in,
673 output_sep = rc.separate_out,
673 output_sep = rc.separate_out,
674 output_sep2 = rc.separate_out2,
674 output_sep2 = rc.separate_out2,
675 ps1 = rc.prompt_in1,
675 ps1 = rc.prompt_in1,
676 ps2 = rc.prompt_in2,
676 ps2 = rc.prompt_in2,
677 ps_out = rc.prompt_out,
677 ps_out = rc.prompt_out,
678 pad_left = rc.prompts_pad_left)
678 pad_left = rc.prompts_pad_left)
679
679
680 # user may have over-ridden the default print hook:
680 # user may have over-ridden the default print hook:
681 try:
681 try:
682 self.outputcache.__class__.display = self.hooks.display
682 self.outputcache.__class__.display = self.hooks.display
683 except AttributeError:
683 except AttributeError:
684 pass
684 pass
685
685
686 # I don't like assigning globally to sys, because it means when
686 # I don't like assigning globally to sys, because it means when
687 # embedding instances, each embedded instance overrides the previous
687 # embedding instances, each embedded instance overrides the previous
688 # choice. But sys.displayhook seems to be called internally by exec,
688 # choice. But sys.displayhook seems to be called internally by exec,
689 # so I don't see a way around it. We first save the original and then
689 # so I don't see a way around it. We first save the original and then
690 # overwrite it.
690 # overwrite it.
691 self.sys_displayhook = sys.displayhook
691 self.sys_displayhook = sys.displayhook
692 sys.displayhook = self.outputcache
692 sys.displayhook = self.outputcache
693
693
694 # Set user colors (don't do it in the constructor above so that it
694 # Set user colors (don't do it in the constructor above so that it
695 # doesn't crash if colors option is invalid)
695 # doesn't crash if colors option is invalid)
696 self.magic_colors(rc.colors)
696 self.magic_colors(rc.colors)
697
697
698 # Set calling of pdb on exceptions
698 # Set calling of pdb on exceptions
699 self.call_pdb = rc.pdb
699 self.call_pdb = rc.pdb
700
700
701 # Load user aliases
701 # Load user aliases
702 for alias in rc.alias:
702 for alias in rc.alias:
703 self.magic_alias(alias)
703 self.magic_alias(alias)
704 self.hooks.late_startup_hook()
704 self.hooks.late_startup_hook()
705
705
706 batchrun = False
706 batchrun = False
707 for batchfile in [path(arg) for arg in self.rc.args
707 for batchfile in [path(arg) for arg in self.rc.args
708 if arg.lower().endswith('.ipy')]:
708 if arg.lower().endswith('.ipy')]:
709 if not batchfile.isfile():
709 if not batchfile.isfile():
710 print "No such batch file:", batchfile
710 print "No such batch file:", batchfile
711 continue
711 continue
712 self.api.runlines(batchfile.text())
712 self.api.runlines(batchfile.text())
713 batchrun = True
713 batchrun = True
714 if batchrun:
714 if batchrun:
715 self.exit_now = True
715 self.exit_now = True
716
716
717 def add_builtins(self):
717 def add_builtins(self):
718 """Store ipython references into the builtin namespace.
718 """Store ipython references into the builtin namespace.
719
719
720 Some parts of ipython operate via builtins injected here, which hold a
720 Some parts of ipython operate via builtins injected here, which hold a
721 reference to IPython itself."""
721 reference to IPython itself."""
722
722
723 # TODO: deprecate all except _ip; 'jobs' should be installed
723 # TODO: deprecate all except _ip; 'jobs' should be installed
724 # by an extension and the rest are under _ip, ipalias is redundant
724 # by an extension and the rest are under _ip, ipalias is redundant
725 builtins_new = dict(__IPYTHON__ = self,
725 builtins_new = dict(__IPYTHON__ = self,
726 ip_set_hook = self.set_hook,
726 ip_set_hook = self.set_hook,
727 jobs = self.jobs,
727 jobs = self.jobs,
728 ipmagic = wrap_deprecated(self.ipmagic,'_ip.magic()'),
728 ipmagic = wrap_deprecated(self.ipmagic,'_ip.magic()'),
729 ipalias = wrap_deprecated(self.ipalias),
729 ipalias = wrap_deprecated(self.ipalias),
730 ipsystem = wrap_deprecated(self.ipsystem,'_ip.system()'),
730 ipsystem = wrap_deprecated(self.ipsystem,'_ip.system()'),
731 _ip = self.api
731 _ip = self.api
732 )
732 )
733 for biname,bival in builtins_new.items():
733 for biname,bival in builtins_new.items():
734 try:
734 try:
735 # store the orignal value so we can restore it
735 # store the orignal value so we can restore it
736 self.builtins_added[biname] = __builtin__.__dict__[biname]
736 self.builtins_added[biname] = __builtin__.__dict__[biname]
737 except KeyError:
737 except KeyError:
738 # or mark that it wasn't defined, and we'll just delete it at
738 # or mark that it wasn't defined, and we'll just delete it at
739 # cleanup
739 # cleanup
740 self.builtins_added[biname] = Undefined
740 self.builtins_added[biname] = Undefined
741 __builtin__.__dict__[biname] = bival
741 __builtin__.__dict__[biname] = bival
742
742
743 # Keep in the builtins a flag for when IPython is active. We set it
743 # Keep in the builtins a flag for when IPython is active. We set it
744 # with setdefault so that multiple nested IPythons don't clobber one
744 # with setdefault so that multiple nested IPythons don't clobber one
745 # another. Each will increase its value by one upon being activated,
745 # another. Each will increase its value by one upon being activated,
746 # which also gives us a way to determine the nesting level.
746 # which also gives us a way to determine the nesting level.
747 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
747 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
748
748
749 def clean_builtins(self):
749 def clean_builtins(self):
750 """Remove any builtins which might have been added by add_builtins, or
750 """Remove any builtins which might have been added by add_builtins, or
751 restore overwritten ones to their previous values."""
751 restore overwritten ones to their previous values."""
752 for biname,bival in self.builtins_added.items():
752 for biname,bival in self.builtins_added.items():
753 if bival is Undefined:
753 if bival is Undefined:
754 del __builtin__.__dict__[biname]
754 del __builtin__.__dict__[biname]
755 else:
755 else:
756 __builtin__.__dict__[biname] = bival
756 __builtin__.__dict__[biname] = bival
757 self.builtins_added.clear()
757 self.builtins_added.clear()
758
758
759 def set_hook(self,name,hook, priority = 50, str_key = None, re_key = None):
759 def set_hook(self,name,hook, priority = 50, str_key = None, re_key = None):
760 """set_hook(name,hook) -> sets an internal IPython hook.
760 """set_hook(name,hook) -> sets an internal IPython hook.
761
761
762 IPython exposes some of its internal API as user-modifiable hooks. By
762 IPython exposes some of its internal API as user-modifiable hooks. By
763 adding your function to one of these hooks, you can modify IPython's
763 adding your function to one of these hooks, you can modify IPython's
764 behavior to call at runtime your own routines."""
764 behavior to call at runtime your own routines."""
765
765
766 # At some point in the future, this should validate the hook before it
766 # At some point in the future, this should validate the hook before it
767 # accepts it. Probably at least check that the hook takes the number
767 # accepts it. Probably at least check that the hook takes the number
768 # of args it's supposed to.
768 # of args it's supposed to.
769
769
770 f = new.instancemethod(hook,self,self.__class__)
770 f = new.instancemethod(hook,self,self.__class__)
771
771
772 # check if the hook is for strdispatcher first
772 # check if the hook is for strdispatcher first
773 if str_key is not None:
773 if str_key is not None:
774 sdp = self.strdispatchers.get(name, StrDispatch())
774 sdp = self.strdispatchers.get(name, StrDispatch())
775 sdp.add_s(str_key, f, priority )
775 sdp.add_s(str_key, f, priority )
776 self.strdispatchers[name] = sdp
776 self.strdispatchers[name] = sdp
777 return
777 return
778 if re_key is not None:
778 if re_key is not None:
779 sdp = self.strdispatchers.get(name, StrDispatch())
779 sdp = self.strdispatchers.get(name, StrDispatch())
780 sdp.add_re(re.compile(re_key), f, priority )
780 sdp.add_re(re.compile(re_key), f, priority )
781 self.strdispatchers[name] = sdp
781 self.strdispatchers[name] = sdp
782 return
782 return
783
783
784 dp = getattr(self.hooks, name, None)
784 dp = getattr(self.hooks, name, None)
785 if name not in IPython.hooks.__all__:
785 if name not in IPython.hooks.__all__:
786 print "Warning! Hook '%s' is not one of %s" % (name, IPython.hooks.__all__ )
786 print "Warning! Hook '%s' is not one of %s" % (name, IPython.hooks.__all__ )
787 if not dp:
787 if not dp:
788 dp = IPython.hooks.CommandChainDispatcher()
788 dp = IPython.hooks.CommandChainDispatcher()
789
789
790 try:
790 try:
791 dp.add(f,priority)
791 dp.add(f,priority)
792 except AttributeError:
792 except AttributeError:
793 # it was not commandchain, plain old func - replace
793 # it was not commandchain, plain old func - replace
794 dp = f
794 dp = f
795
795
796 setattr(self.hooks,name, dp)
796 setattr(self.hooks,name, dp)
797
797
798
798
799 #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
799 #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
800
800
801 def set_crash_handler(self,crashHandler):
801 def set_crash_handler(self,crashHandler):
802 """Set the IPython crash handler.
802 """Set the IPython crash handler.
803
803
804 This must be a callable with a signature suitable for use as
804 This must be a callable with a signature suitable for use as
805 sys.excepthook."""
805 sys.excepthook."""
806
806
807 # Install the given crash handler as the Python exception hook
807 # Install the given crash handler as the Python exception hook
808 sys.excepthook = crashHandler
808 sys.excepthook = crashHandler
809
809
810 # The instance will store a pointer to this, so that runtime code
810 # The instance will store a pointer to this, so that runtime code
811 # (such as magics) can access it. This is because during the
811 # (such as magics) can access it. This is because during the
812 # read-eval loop, it gets temporarily overwritten (to deal with GUI
812 # read-eval loop, it gets temporarily overwritten (to deal with GUI
813 # frameworks).
813 # frameworks).
814 self.sys_excepthook = sys.excepthook
814 self.sys_excepthook = sys.excepthook
815
815
816
816
817 def set_custom_exc(self,exc_tuple,handler):
817 def set_custom_exc(self,exc_tuple,handler):
818 """set_custom_exc(exc_tuple,handler)
818 """set_custom_exc(exc_tuple,handler)
819
819
820 Set a custom exception handler, which will be called if any of the
820 Set a custom exception handler, which will be called if any of the
821 exceptions in exc_tuple occur in the mainloop (specifically, in the
821 exceptions in exc_tuple occur in the mainloop (specifically, in the
822 runcode() method.
822 runcode() method.
823
823
824 Inputs:
824 Inputs:
825
825
826 - exc_tuple: a *tuple* of valid exceptions to call the defined
826 - exc_tuple: a *tuple* of valid exceptions to call the defined
827 handler for. It is very important that you use a tuple, and NOT A
827 handler for. It is very important that you use a tuple, and NOT A
828 LIST here, because of the way Python's except statement works. If
828 LIST here, because of the way Python's except statement works. If
829 you only want to trap a single exception, use a singleton tuple:
829 you only want to trap a single exception, use a singleton tuple:
830
830
831 exc_tuple == (MyCustomException,)
831 exc_tuple == (MyCustomException,)
832
832
833 - handler: this must be defined as a function with the following
833 - handler: this must be defined as a function with the following
834 basic interface: def my_handler(self,etype,value,tb).
834 basic interface: def my_handler(self,etype,value,tb).
835
835
836 This will be made into an instance method (via new.instancemethod)
836 This will be made into an instance method (via new.instancemethod)
837 of IPython itself, and it will be called if any of the exceptions
837 of IPython itself, and it will be called if any of the exceptions
838 listed in the exc_tuple are caught. If the handler is None, an
838 listed in the exc_tuple are caught. If the handler is None, an
839 internal basic one is used, which just prints basic info.
839 internal basic one is used, which just prints basic info.
840
840
841 WARNING: by putting in your own exception handler into IPython's main
841 WARNING: by putting in your own exception handler into IPython's main
842 execution loop, you run a very good chance of nasty crashes. This
842 execution loop, you run a very good chance of nasty crashes. This
843 facility should only be used if you really know what you are doing."""
843 facility should only be used if you really know what you are doing."""
844
844
845 assert type(exc_tuple)==type(()) , \
845 assert type(exc_tuple)==type(()) , \
846 "The custom exceptions must be given AS A TUPLE."
846 "The custom exceptions must be given AS A TUPLE."
847
847
848 def dummy_handler(self,etype,value,tb):
848 def dummy_handler(self,etype,value,tb):
849 print '*** Simple custom exception handler ***'
849 print '*** Simple custom exception handler ***'
850 print 'Exception type :',etype
850 print 'Exception type :',etype
851 print 'Exception value:',value
851 print 'Exception value:',value
852 print 'Traceback :',tb
852 print 'Traceback :',tb
853 print 'Source code :','\n'.join(self.buffer)
853 print 'Source code :','\n'.join(self.buffer)
854
854
855 if handler is None: handler = dummy_handler
855 if handler is None: handler = dummy_handler
856
856
857 self.CustomTB = new.instancemethod(handler,self,self.__class__)
857 self.CustomTB = new.instancemethod(handler,self,self.__class__)
858 self.custom_exceptions = exc_tuple
858 self.custom_exceptions = exc_tuple
859
859
860 def set_custom_completer(self,completer,pos=0):
860 def set_custom_completer(self,completer,pos=0):
861 """set_custom_completer(completer,pos=0)
861 """set_custom_completer(completer,pos=0)
862
862
863 Adds a new custom completer function.
863 Adds a new custom completer function.
864
864
865 The position argument (defaults to 0) is the index in the completers
865 The position argument (defaults to 0) is the index in the completers
866 list where you want the completer to be inserted."""
866 list where you want the completer to be inserted."""
867
867
868 newcomp = new.instancemethod(completer,self.Completer,
868 newcomp = new.instancemethod(completer,self.Completer,
869 self.Completer.__class__)
869 self.Completer.__class__)
870 self.Completer.matchers.insert(pos,newcomp)
870 self.Completer.matchers.insert(pos,newcomp)
871
871
872 def _get_call_pdb(self):
872 def _get_call_pdb(self):
873 return self._call_pdb
873 return self._call_pdb
874
874
875 def _set_call_pdb(self,val):
875 def _set_call_pdb(self,val):
876
876
877 if val not in (0,1,False,True):
877 if val not in (0,1,False,True):
878 raise ValueError,'new call_pdb value must be boolean'
878 raise ValueError,'new call_pdb value must be boolean'
879
879
880 # store value in instance
880 # store value in instance
881 self._call_pdb = val
881 self._call_pdb = val
882
882
883 # notify the actual exception handlers
883 # notify the actual exception handlers
884 self.InteractiveTB.call_pdb = val
884 self.InteractiveTB.call_pdb = val
885 if self.isthreaded:
885 if self.isthreaded:
886 try:
886 try:
887 self.sys_excepthook.call_pdb = val
887 self.sys_excepthook.call_pdb = val
888 except:
888 except:
889 warn('Failed to activate pdb for threaded exception handler')
889 warn('Failed to activate pdb for threaded exception handler')
890
890
891 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
891 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
892 'Control auto-activation of pdb at exceptions')
892 'Control auto-activation of pdb at exceptions')
893
893
894
894
895 # These special functions get installed in the builtin namespace, to
895 # These special functions get installed in the builtin namespace, to
896 # provide programmatic (pure python) access to magics, aliases and system
896 # provide programmatic (pure python) access to magics, aliases and system
897 # calls. This is important for logging, user scripting, and more.
897 # calls. This is important for logging, user scripting, and more.
898
898
899 # We are basically exposing, via normal python functions, the three
899 # We are basically exposing, via normal python functions, the three
900 # mechanisms in which ipython offers special call modes (magics for
900 # mechanisms in which ipython offers special call modes (magics for
901 # internal control, aliases for direct system access via pre-selected
901 # internal control, aliases for direct system access via pre-selected
902 # names, and !cmd for calling arbitrary system commands).
902 # names, and !cmd for calling arbitrary system commands).
903
903
904 def ipmagic(self,arg_s):
904 def ipmagic(self,arg_s):
905 """Call a magic function by name.
905 """Call a magic function by name.
906
906
907 Input: a string containing the name of the magic function to call and any
907 Input: a string containing the name of the magic function to call and any
908 additional arguments to be passed to the magic.
908 additional arguments to be passed to the magic.
909
909
910 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
910 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
911 prompt:
911 prompt:
912
912
913 In[1]: %name -opt foo bar
913 In[1]: %name -opt foo bar
914
914
915 To call a magic without arguments, simply use ipmagic('name').
915 To call a magic without arguments, simply use ipmagic('name').
916
916
917 This provides a proper Python function to call IPython's magics in any
917 This provides a proper Python function to call IPython's magics in any
918 valid Python code you can type at the interpreter, including loops and
918 valid Python code you can type at the interpreter, including loops and
919 compound statements. It is added by IPython to the Python builtin
919 compound statements. It is added by IPython to the Python builtin
920 namespace upon initialization."""
920 namespace upon initialization."""
921
921
922 args = arg_s.split(' ',1)
922 args = arg_s.split(' ',1)
923 magic_name = args[0]
923 magic_name = args[0]
924 magic_name = magic_name.lstrip(self.ESC_MAGIC)
924 magic_name = magic_name.lstrip(self.ESC_MAGIC)
925
925
926 try:
926 try:
927 magic_args = args[1]
927 magic_args = args[1]
928 except IndexError:
928 except IndexError:
929 magic_args = ''
929 magic_args = ''
930 fn = getattr(self,'magic_'+magic_name,None)
930 fn = getattr(self,'magic_'+magic_name,None)
931 if fn is None:
931 if fn is None:
932 error("Magic function `%s` not found." % magic_name)
932 error("Magic function `%s` not found." % magic_name)
933 else:
933 else:
934 magic_args = self.var_expand(magic_args,1)
934 magic_args = self.var_expand(magic_args,1)
935 return fn(magic_args)
935 return fn(magic_args)
936
936
937 def ipalias(self,arg_s):
937 def ipalias(self,arg_s):
938 """Call an alias by name.
938 """Call an alias by name.
939
939
940 Input: a string containing the name of the alias to call and any
940 Input: a string containing the name of the alias to call and any
941 additional arguments to be passed to the magic.
941 additional arguments to be passed to the magic.
942
942
943 ipalias('name -opt foo bar') is equivalent to typing at the ipython
943 ipalias('name -opt foo bar') is equivalent to typing at the ipython
944 prompt:
944 prompt:
945
945
946 In[1]: name -opt foo bar
946 In[1]: name -opt foo bar
947
947
948 To call an alias without arguments, simply use ipalias('name').
948 To call an alias without arguments, simply use ipalias('name').
949
949
950 This provides a proper Python function to call IPython's aliases in any
950 This provides a proper Python function to call IPython's aliases in any
951 valid Python code you can type at the interpreter, including loops and
951 valid Python code you can type at the interpreter, including loops and
952 compound statements. It is added by IPython to the Python builtin
952 compound statements. It is added by IPython to the Python builtin
953 namespace upon initialization."""
953 namespace upon initialization."""
954
954
955 args = arg_s.split(' ',1)
955 args = arg_s.split(' ',1)
956 alias_name = args[0]
956 alias_name = args[0]
957 try:
957 try:
958 alias_args = args[1]
958 alias_args = args[1]
959 except IndexError:
959 except IndexError:
960 alias_args = ''
960 alias_args = ''
961 if alias_name in self.alias_table:
961 if alias_name in self.alias_table:
962 self.call_alias(alias_name,alias_args)
962 self.call_alias(alias_name,alias_args)
963 else:
963 else:
964 error("Alias `%s` not found." % alias_name)
964 error("Alias `%s` not found." % alias_name)
965
965
966 def ipsystem(self,arg_s):
966 def ipsystem(self,arg_s):
967 """Make a system call, using IPython."""
967 """Make a system call, using IPython."""
968
968
969 self.system(arg_s)
969 self.system(arg_s)
970
970
971 def complete(self,text):
971 def complete(self,text):
972 """Return a sorted list of all possible completions on text.
972 """Return a sorted list of all possible completions on text.
973
973
974 Inputs:
974 Inputs:
975
975
976 - text: a string of text to be completed on.
976 - text: a string of text to be completed on.
977
977
978 This is a wrapper around the completion mechanism, similar to what
978 This is a wrapper around the completion mechanism, similar to what
979 readline does at the command line when the TAB key is hit. By
979 readline does at the command line when the TAB key is hit. By
980 exposing it as a method, it can be used by other non-readline
980 exposing it as a method, it can be used by other non-readline
981 environments (such as GUIs) for text completion.
981 environments (such as GUIs) for text completion.
982
982
983 Simple usage example:
983 Simple usage example:
984
984
985 In [1]: x = 'hello'
985 In [1]: x = 'hello'
986
986
987 In [2]: __IP.complete('x.l')
987 In [2]: __IP.complete('x.l')
988 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
988 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
989
989
990 complete = self.Completer.complete
990 complete = self.Completer.complete
991 state = 0
991 state = 0
992 # use a dict so we get unique keys, since ipyhton's multiple
992 # use a dict so we get unique keys, since ipyhton's multiple
993 # completers can return duplicates.
993 # completers can return duplicates.
994 comps = {}
994 comps = {}
995 while True:
995 while True:
996 newcomp = complete(text,state)
996 newcomp = complete(text,state)
997 if newcomp is None:
997 if newcomp is None:
998 break
998 break
999 comps[newcomp] = 1
999 comps[newcomp] = 1
1000 state += 1
1000 state += 1
1001 outcomps = comps.keys()
1001 outcomps = comps.keys()
1002 outcomps.sort()
1002 outcomps.sort()
1003 return outcomps
1003 return outcomps
1004
1004
1005 def set_completer_frame(self, frame=None):
1005 def set_completer_frame(self, frame=None):
1006 if frame:
1006 if frame:
1007 self.Completer.namespace = frame.f_locals
1007 self.Completer.namespace = frame.f_locals
1008 self.Completer.global_namespace = frame.f_globals
1008 self.Completer.global_namespace = frame.f_globals
1009 else:
1009 else:
1010 self.Completer.namespace = self.user_ns
1010 self.Completer.namespace = self.user_ns
1011 self.Completer.global_namespace = self.user_global_ns
1011 self.Completer.global_namespace = self.user_global_ns
1012
1012
1013 def init_auto_alias(self):
1013 def init_auto_alias(self):
1014 """Define some aliases automatically.
1014 """Define some aliases automatically.
1015
1015
1016 These are ALL parameter-less aliases"""
1016 These are ALL parameter-less aliases"""
1017
1017
1018 for alias,cmd in self.auto_alias:
1018 for alias,cmd in self.auto_alias:
1019 self.alias_table[alias] = (0,cmd)
1019 self.alias_table[alias] = (0,cmd)
1020
1020
1021 def alias_table_validate(self,verbose=0):
1021 def alias_table_validate(self,verbose=0):
1022 """Update information about the alias table.
1022 """Update information about the alias table.
1023
1023
1024 In particular, make sure no Python keywords/builtins are in it."""
1024 In particular, make sure no Python keywords/builtins are in it."""
1025
1025
1026 no_alias = self.no_alias
1026 no_alias = self.no_alias
1027 for k in self.alias_table.keys():
1027 for k in self.alias_table.keys():
1028 if k in no_alias:
1028 if k in no_alias:
1029 del self.alias_table[k]
1029 del self.alias_table[k]
1030 if verbose:
1030 if verbose:
1031 print ("Deleting alias <%s>, it's a Python "
1031 print ("Deleting alias <%s>, it's a Python "
1032 "keyword or builtin." % k)
1032 "keyword or builtin." % k)
1033
1033
1034 def set_autoindent(self,value=None):
1034 def set_autoindent(self,value=None):
1035 """Set the autoindent flag, checking for readline support.
1035 """Set the autoindent flag, checking for readline support.
1036
1036
1037 If called with no arguments, it acts as a toggle."""
1037 If called with no arguments, it acts as a toggle."""
1038
1038
1039 if not self.has_readline:
1039 if not self.has_readline:
1040 if os.name == 'posix':
1040 if os.name == 'posix':
1041 warn("The auto-indent feature requires the readline library")
1041 warn("The auto-indent feature requires the readline library")
1042 self.autoindent = 0
1042 self.autoindent = 0
1043 return
1043 return
1044 if value is None:
1044 if value is None:
1045 self.autoindent = not self.autoindent
1045 self.autoindent = not self.autoindent
1046 else:
1046 else:
1047 self.autoindent = value
1047 self.autoindent = value
1048
1048
1049 def rc_set_toggle(self,rc_field,value=None):
1049 def rc_set_toggle(self,rc_field,value=None):
1050 """Set or toggle a field in IPython's rc config. structure.
1050 """Set or toggle a field in IPython's rc config. structure.
1051
1051
1052 If called with no arguments, it acts as a toggle.
1052 If called with no arguments, it acts as a toggle.
1053
1053
1054 If called with a non-existent field, the resulting AttributeError
1054 If called with a non-existent field, the resulting AttributeError
1055 exception will propagate out."""
1055 exception will propagate out."""
1056
1056
1057 rc_val = getattr(self.rc,rc_field)
1057 rc_val = getattr(self.rc,rc_field)
1058 if value is None:
1058 if value is None:
1059 value = not rc_val
1059 value = not rc_val
1060 setattr(self.rc,rc_field,value)
1060 setattr(self.rc,rc_field,value)
1061
1061
1062 def user_setup(self,ipythondir,rc_suffix,mode='install'):
1062 def user_setup(self,ipythondir,rc_suffix,mode='install'):
1063 """Install the user configuration directory.
1063 """Install the user configuration directory.
1064
1064
1065 Can be called when running for the first time or to upgrade the user's
1065 Can be called when running for the first time or to upgrade the user's
1066 .ipython/ directory with the mode parameter. Valid modes are 'install'
1066 .ipython/ directory with the mode parameter. Valid modes are 'install'
1067 and 'upgrade'."""
1067 and 'upgrade'."""
1068
1068
1069 def wait():
1069 def wait():
1070 try:
1070 try:
1071 raw_input("Please press <RETURN> to start IPython.")
1071 raw_input("Please press <RETURN> to start IPython.")
1072 except EOFError:
1072 except EOFError:
1073 print >> Term.cout
1073 print >> Term.cout
1074 print '*'*70
1074 print '*'*70
1075
1075
1076 cwd = os.getcwd() # remember where we started
1076 cwd = os.getcwd() # remember where we started
1077 glb = glob.glob
1077 glb = glob.glob
1078 print '*'*70
1078 print '*'*70
1079 if mode == 'install':
1079 if mode == 'install':
1080 print \
1080 print \
1081 """Welcome to IPython. I will try to create a personal configuration directory
1081 """Welcome to IPython. I will try to create a personal configuration directory
1082 where you can customize many aspects of IPython's functionality in:\n"""
1082 where you can customize many aspects of IPython's functionality in:\n"""
1083 else:
1083 else:
1084 print 'I am going to upgrade your configuration in:'
1084 print 'I am going to upgrade your configuration in:'
1085
1085
1086 print ipythondir
1086 print ipythondir
1087
1087
1088 rcdirend = os.path.join('IPython','UserConfig')
1088 rcdirend = os.path.join('IPython','UserConfig')
1089 cfg = lambda d: os.path.join(d,rcdirend)
1089 cfg = lambda d: os.path.join(d,rcdirend)
1090 try:
1090 try:
1091 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1091 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1092 except IOError:
1092 except IOError:
1093 warning = """
1093 warning = """
1094 Installation error. IPython's directory was not found.
1094 Installation error. IPython's directory was not found.
1095
1095
1096 Check the following:
1096 Check the following:
1097
1097
1098 The ipython/IPython directory should be in a directory belonging to your
1098 The ipython/IPython directory should be in a directory belonging to your
1099 PYTHONPATH environment variable (that is, it should be in a directory
1099 PYTHONPATH environment variable (that is, it should be in a directory
1100 belonging to sys.path). You can copy it explicitly there or just link to it.
1100 belonging to sys.path). You can copy it explicitly there or just link to it.
1101
1101
1102 IPython will proceed with builtin defaults.
1102 IPython will proceed with builtin defaults.
1103 """
1103 """
1104 warn(warning)
1104 warn(warning)
1105 wait()
1105 wait()
1106 return
1106 return
1107
1107
1108 if mode == 'install':
1108 if mode == 'install':
1109 try:
1109 try:
1110 shutil.copytree(rcdir,ipythondir)
1110 shutil.copytree(rcdir,ipythondir)
1111 os.chdir(ipythondir)
1111 os.chdir(ipythondir)
1112 rc_files = glb("ipythonrc*")
1112 rc_files = glb("ipythonrc*")
1113 for rc_file in rc_files:
1113 for rc_file in rc_files:
1114 os.rename(rc_file,rc_file+rc_suffix)
1114 os.rename(rc_file,rc_file+rc_suffix)
1115 except:
1115 except:
1116 warning = """
1116 warning = """
1117
1117
1118 There was a problem with the installation:
1118 There was a problem with the installation:
1119 %s
1119 %s
1120 Try to correct it or contact the developers if you think it's a bug.
1120 Try to correct it or contact the developers if you think it's a bug.
1121 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1121 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1122 warn(warning)
1122 warn(warning)
1123 wait()
1123 wait()
1124 return
1124 return
1125
1125
1126 elif mode == 'upgrade':
1126 elif mode == 'upgrade':
1127 try:
1127 try:
1128 os.chdir(ipythondir)
1128 os.chdir(ipythondir)
1129 except:
1129 except:
1130 print """
1130 print """
1131 Can not upgrade: changing to directory %s failed. Details:
1131 Can not upgrade: changing to directory %s failed. Details:
1132 %s
1132 %s
1133 """ % (ipythondir,sys.exc_info()[1])
1133 """ % (ipythondir,sys.exc_info()[1])
1134 wait()
1134 wait()
1135 return
1135 return
1136 else:
1136 else:
1137 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1137 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1138 for new_full_path in sources:
1138 for new_full_path in sources:
1139 new_filename = os.path.basename(new_full_path)
1139 new_filename = os.path.basename(new_full_path)
1140 if new_filename.startswith('ipythonrc'):
1140 if new_filename.startswith('ipythonrc'):
1141 new_filename = new_filename + rc_suffix
1141 new_filename = new_filename + rc_suffix
1142 # The config directory should only contain files, skip any
1142 # The config directory should only contain files, skip any
1143 # directories which may be there (like CVS)
1143 # directories which may be there (like CVS)
1144 if os.path.isdir(new_full_path):
1144 if os.path.isdir(new_full_path):
1145 continue
1145 continue
1146 if os.path.exists(new_filename):
1146 if os.path.exists(new_filename):
1147 old_file = new_filename+'.old'
1147 old_file = new_filename+'.old'
1148 if os.path.exists(old_file):
1148 if os.path.exists(old_file):
1149 os.remove(old_file)
1149 os.remove(old_file)
1150 os.rename(new_filename,old_file)
1150 os.rename(new_filename,old_file)
1151 shutil.copy(new_full_path,new_filename)
1151 shutil.copy(new_full_path,new_filename)
1152 else:
1152 else:
1153 raise ValueError,'unrecognized mode for install:',`mode`
1153 raise ValueError,'unrecognized mode for install:',`mode`
1154
1154
1155 # Fix line-endings to those native to each platform in the config
1155 # Fix line-endings to those native to each platform in the config
1156 # directory.
1156 # directory.
1157 try:
1157 try:
1158 os.chdir(ipythondir)
1158 os.chdir(ipythondir)
1159 except:
1159 except:
1160 print """
1160 print """
1161 Problem: changing to directory %s failed.
1161 Problem: changing to directory %s failed.
1162 Details:
1162 Details:
1163 %s
1163 %s
1164
1164
1165 Some configuration files may have incorrect line endings. This should not
1165 Some configuration files may have incorrect line endings. This should not
1166 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1166 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1167 wait()
1167 wait()
1168 else:
1168 else:
1169 for fname in glb('ipythonrc*'):
1169 for fname in glb('ipythonrc*'):
1170 try:
1170 try:
1171 native_line_ends(fname,backup=0)
1171 native_line_ends(fname,backup=0)
1172 except IOError:
1172 except IOError:
1173 pass
1173 pass
1174
1174
1175 if mode == 'install':
1175 if mode == 'install':
1176 print """
1176 print """
1177 Successful installation!
1177 Successful installation!
1178
1178
1179 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1179 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1180 IPython manual (there are both HTML and PDF versions supplied with the
1180 IPython manual (there are both HTML and PDF versions supplied with the
1181 distribution) to make sure that your system environment is properly configured
1181 distribution) to make sure that your system environment is properly configured
1182 to take advantage of IPython's features.
1182 to take advantage of IPython's features.
1183
1183
1184 Important note: the configuration system has changed! The old system is
1184 Important note: the configuration system has changed! The old system is
1185 still in place, but its setting may be partly overridden by the settings in
1185 still in place, but its setting may be partly overridden by the settings in
1186 "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file
1186 "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file
1187 if some of the new settings bother you.
1187 if some of the new settings bother you.
1188
1188
1189 """
1189 """
1190 else:
1190 else:
1191 print """
1191 print """
1192 Successful upgrade!
1192 Successful upgrade!
1193
1193
1194 All files in your directory:
1194 All files in your directory:
1195 %(ipythondir)s
1195 %(ipythondir)s
1196 which would have been overwritten by the upgrade were backed up with a .old
1196 which would have been overwritten by the upgrade were backed up with a .old
1197 extension. If you had made particular customizations in those files you may
1197 extension. If you had made particular customizations in those files you may
1198 want to merge them back into the new files.""" % locals()
1198 want to merge them back into the new files.""" % locals()
1199 wait()
1199 wait()
1200 os.chdir(cwd)
1200 os.chdir(cwd)
1201 # end user_setup()
1201 # end user_setup()
1202
1202
1203 def atexit_operations(self):
1203 def atexit_operations(self):
1204 """This will be executed at the time of exit.
1204 """This will be executed at the time of exit.
1205
1205
1206 Saving of persistent data should be performed here. """
1206 Saving of persistent data should be performed here. """
1207
1207
1208 #print '*** IPython exit cleanup ***' # dbg
1208 #print '*** IPython exit cleanup ***' # dbg
1209 # input history
1209 # input history
1210 self.savehist()
1210 self.savehist()
1211
1211
1212 # Cleanup all tempfiles left around
1212 # Cleanup all tempfiles left around
1213 for tfile in self.tempfiles:
1213 for tfile in self.tempfiles:
1214 try:
1214 try:
1215 os.unlink(tfile)
1215 os.unlink(tfile)
1216 except OSError:
1216 except OSError:
1217 pass
1217 pass
1218
1218
1219 # save the "persistent data" catch-all dictionary
1219 # save the "persistent data" catch-all dictionary
1220 self.hooks.shutdown_hook()
1220 self.hooks.shutdown_hook()
1221
1221
1222 def savehist(self):
1222 def savehist(self):
1223 """Save input history to a file (via readline library)."""
1223 """Save input history to a file (via readline library)."""
1224 try:
1224 try:
1225 self.readline.write_history_file(self.histfile)
1225 self.readline.write_history_file(self.histfile)
1226 except:
1226 except:
1227 print 'Unable to save IPython command history to file: ' + \
1227 print 'Unable to save IPython command history to file: ' + \
1228 `self.histfile`
1228 `self.histfile`
1229
1229
1230 def history_saving_wrapper(self, func):
1230 def history_saving_wrapper(self, func):
1231 """ Wrap func for readline history saving
1231 """ Wrap func for readline history saving
1232
1232
1233 Convert func into callable that saves & restores
1233 Convert func into callable that saves & restores
1234 history around the call """
1234 history around the call """
1235
1235
1236 if not self.has_readline:
1236 if not self.has_readline:
1237 return func
1237 return func
1238
1238
1239 def wrapper():
1239 def wrapper():
1240 self.savehist()
1240 self.savehist()
1241 try:
1241 try:
1242 func()
1242 func()
1243 finally:
1243 finally:
1244 readline.read_history_file(self.histfile)
1244 readline.read_history_file(self.histfile)
1245 return wrapper
1245 return wrapper
1246
1246
1247
1247
1248 def pre_readline(self):
1248 def pre_readline(self):
1249 """readline hook to be used at the start of each line.
1249 """readline hook to be used at the start of each line.
1250
1250
1251 Currently it handles auto-indent only."""
1251 Currently it handles auto-indent only."""
1252
1252
1253 #debugx('self.indent_current_nsp','pre_readline:')
1253 #debugx('self.indent_current_nsp','pre_readline:')
1254 self.readline.insert_text(self.indent_current_str())
1254 self.readline.insert_text(self.indent_current_str())
1255
1255
1256 def init_readline(self):
1256 def init_readline(self):
1257 """Command history completion/saving/reloading."""
1257 """Command history completion/saving/reloading."""
1258
1258
1259 import IPython.rlineimpl as readline
1259 import IPython.rlineimpl as readline
1260 if not readline.have_readline:
1260 if not readline.have_readline:
1261 self.has_readline = 0
1261 self.has_readline = 0
1262 self.readline = None
1262 self.readline = None
1263 # no point in bugging windows users with this every time:
1263 # no point in bugging windows users with this every time:
1264 warn('Readline services not available on this platform.')
1264 warn('Readline services not available on this platform.')
1265 else:
1265 else:
1266 sys.modules['readline'] = readline
1266 sys.modules['readline'] = readline
1267 import atexit
1267 import atexit
1268 from IPython.completer import IPCompleter
1268 from IPython.completer import IPCompleter
1269 self.Completer = IPCompleter(self,
1269 self.Completer = IPCompleter(self,
1270 self.user_ns,
1270 self.user_ns,
1271 self.user_global_ns,
1271 self.user_global_ns,
1272 self.rc.readline_omit__names,
1272 self.rc.readline_omit__names,
1273 self.alias_table)
1273 self.alias_table)
1274 sdisp = self.strdispatchers.get('complete_command', StrDispatch())
1274 sdisp = self.strdispatchers.get('complete_command', StrDispatch())
1275 self.strdispatchers['complete_command'] = sdisp
1275 self.strdispatchers['complete_command'] = sdisp
1276 self.Completer.custom_completers = sdisp
1276 self.Completer.custom_completers = sdisp
1277 # Platform-specific configuration
1277 # Platform-specific configuration
1278 if os.name == 'nt':
1278 if os.name == 'nt':
1279 self.readline_startup_hook = readline.set_pre_input_hook
1279 self.readline_startup_hook = readline.set_pre_input_hook
1280 else:
1280 else:
1281 self.readline_startup_hook = readline.set_startup_hook
1281 self.readline_startup_hook = readline.set_startup_hook
1282
1282
1283 # Load user's initrc file (readline config)
1283 # Load user's initrc file (readline config)
1284 inputrc_name = os.environ.get('INPUTRC')
1284 inputrc_name = os.environ.get('INPUTRC')
1285 if inputrc_name is None:
1285 if inputrc_name is None:
1286 home_dir = get_home_dir()
1286 home_dir = get_home_dir()
1287 if home_dir is not None:
1287 if home_dir is not None:
1288 inputrc_name = os.path.join(home_dir,'.inputrc')
1288 inputrc_name = os.path.join(home_dir,'.inputrc')
1289 if os.path.isfile(inputrc_name):
1289 if os.path.isfile(inputrc_name):
1290 try:
1290 try:
1291 readline.read_init_file(inputrc_name)
1291 readline.read_init_file(inputrc_name)
1292 except:
1292 except:
1293 warn('Problems reading readline initialization file <%s>'
1293 warn('Problems reading readline initialization file <%s>'
1294 % inputrc_name)
1294 % inputrc_name)
1295
1295
1296 self.has_readline = 1
1296 self.has_readline = 1
1297 self.readline = readline
1297 self.readline = readline
1298 # save this in sys so embedded copies can restore it properly
1298 # save this in sys so embedded copies can restore it properly
1299 sys.ipcompleter = self.Completer.complete
1299 sys.ipcompleter = self.Completer.complete
1300 readline.set_completer(self.Completer.complete)
1300 readline.set_completer(self.Completer.complete)
1301
1301
1302 # Configure readline according to user's prefs
1302 # Configure readline according to user's prefs
1303 for rlcommand in self.rc.readline_parse_and_bind:
1303 for rlcommand in self.rc.readline_parse_and_bind:
1304 readline.parse_and_bind(rlcommand)
1304 readline.parse_and_bind(rlcommand)
1305
1305
1306 # remove some chars from the delimiters list
1306 # remove some chars from the delimiters list
1307 delims = readline.get_completer_delims()
1307 delims = readline.get_completer_delims()
1308 delims = delims.translate(string._idmap,
1308 delims = delims.translate(string._idmap,
1309 self.rc.readline_remove_delims)
1309 self.rc.readline_remove_delims)
1310 readline.set_completer_delims(delims)
1310 readline.set_completer_delims(delims)
1311 # otherwise we end up with a monster history after a while:
1311 # otherwise we end up with a monster history after a while:
1312 readline.set_history_length(1000)
1312 readline.set_history_length(1000)
1313 try:
1313 try:
1314 #print '*** Reading readline history' # dbg
1314 #print '*** Reading readline history' # dbg
1315 readline.read_history_file(self.histfile)
1315 readline.read_history_file(self.histfile)
1316 except IOError:
1316 except IOError:
1317 pass # It doesn't exist yet.
1317 pass # It doesn't exist yet.
1318
1318
1319 atexit.register(self.atexit_operations)
1319 atexit.register(self.atexit_operations)
1320 del atexit
1320 del atexit
1321
1321
1322 # Configure auto-indent for all platforms
1322 # Configure auto-indent for all platforms
1323 self.set_autoindent(self.rc.autoindent)
1323 self.set_autoindent(self.rc.autoindent)
1324
1324
1325 def ask_yes_no(self,prompt,default=True):
1325 def ask_yes_no(self,prompt,default=True):
1326 if self.rc.quiet:
1326 if self.rc.quiet:
1327 return True
1327 return True
1328 return ask_yes_no(prompt,default)
1328 return ask_yes_no(prompt,default)
1329
1329
1330 def _should_recompile(self,e):
1330 def _should_recompile(self,e):
1331 """Utility routine for edit_syntax_error"""
1331 """Utility routine for edit_syntax_error"""
1332
1332
1333 if e.filename in ('<ipython console>','<input>','<string>',
1333 if e.filename in ('<ipython console>','<input>','<string>',
1334 '<console>','<BackgroundJob compilation>',
1334 '<console>','<BackgroundJob compilation>',
1335 None):
1335 None):
1336
1336
1337 return False
1337 return False
1338 try:
1338 try:
1339 if (self.rc.autoedit_syntax and
1339 if (self.rc.autoedit_syntax and
1340 not self.ask_yes_no('Return to editor to correct syntax error? '
1340 not self.ask_yes_no('Return to editor to correct syntax error? '
1341 '[Y/n] ','y')):
1341 '[Y/n] ','y')):
1342 return False
1342 return False
1343 except EOFError:
1343 except EOFError:
1344 return False
1344 return False
1345
1345
1346 def int0(x):
1346 def int0(x):
1347 try:
1347 try:
1348 return int(x)
1348 return int(x)
1349 except TypeError:
1349 except TypeError:
1350 return 0
1350 return 0
1351 # always pass integer line and offset values to editor hook
1351 # always pass integer line and offset values to editor hook
1352 self.hooks.fix_error_editor(e.filename,
1352 self.hooks.fix_error_editor(e.filename,
1353 int0(e.lineno),int0(e.offset),e.msg)
1353 int0(e.lineno),int0(e.offset),e.msg)
1354 return True
1354 return True
1355
1355
1356 def edit_syntax_error(self):
1356 def edit_syntax_error(self):
1357 """The bottom half of the syntax error handler called in the main loop.
1357 """The bottom half of the syntax error handler called in the main loop.
1358
1358
1359 Loop until syntax error is fixed or user cancels.
1359 Loop until syntax error is fixed or user cancels.
1360 """
1360 """
1361
1361
1362 while self.SyntaxTB.last_syntax_error:
1362 while self.SyntaxTB.last_syntax_error:
1363 # copy and clear last_syntax_error
1363 # copy and clear last_syntax_error
1364 err = self.SyntaxTB.clear_err_state()
1364 err = self.SyntaxTB.clear_err_state()
1365 if not self._should_recompile(err):
1365 if not self._should_recompile(err):
1366 return
1366 return
1367 try:
1367 try:
1368 # may set last_syntax_error again if a SyntaxError is raised
1368 # may set last_syntax_error again if a SyntaxError is raised
1369 self.safe_execfile(err.filename,self.user_ns)
1369 self.safe_execfile(err.filename,self.user_ns)
1370 except:
1370 except:
1371 self.showtraceback()
1371 self.showtraceback()
1372 else:
1372 else:
1373 try:
1373 try:
1374 f = file(err.filename)
1374 f = file(err.filename)
1375 try:
1375 try:
1376 sys.displayhook(f.read())
1376 sys.displayhook(f.read())
1377 finally:
1377 finally:
1378 f.close()
1378 f.close()
1379 except:
1379 except:
1380 self.showtraceback()
1380 self.showtraceback()
1381
1381
1382 def showsyntaxerror(self, filename=None):
1382 def showsyntaxerror(self, filename=None):
1383 """Display the syntax error that just occurred.
1383 """Display the syntax error that just occurred.
1384
1384
1385 This doesn't display a stack trace because there isn't one.
1385 This doesn't display a stack trace because there isn't one.
1386
1386
1387 If a filename is given, it is stuffed in the exception instead
1387 If a filename is given, it is stuffed in the exception instead
1388 of what was there before (because Python's parser always uses
1388 of what was there before (because Python's parser always uses
1389 "<string>" when reading from a string).
1389 "<string>" when reading from a string).
1390 """
1390 """
1391 etype, value, last_traceback = sys.exc_info()
1391 etype, value, last_traceback = sys.exc_info()
1392
1392
1393 # See note about these variables in showtraceback() below
1393 # See note about these variables in showtraceback() below
1394 sys.last_type = etype
1394 sys.last_type = etype
1395 sys.last_value = value
1395 sys.last_value = value
1396 sys.last_traceback = last_traceback
1396 sys.last_traceback = last_traceback
1397
1397
1398 if filename and etype is SyntaxError:
1398 if filename and etype is SyntaxError:
1399 # Work hard to stuff the correct filename in the exception
1399 # Work hard to stuff the correct filename in the exception
1400 try:
1400 try:
1401 msg, (dummy_filename, lineno, offset, line) = value
1401 msg, (dummy_filename, lineno, offset, line) = value
1402 except:
1402 except:
1403 # Not the format we expect; leave it alone
1403 # Not the format we expect; leave it alone
1404 pass
1404 pass
1405 else:
1405 else:
1406 # Stuff in the right filename
1406 # Stuff in the right filename
1407 try:
1407 try:
1408 # Assume SyntaxError is a class exception
1408 # Assume SyntaxError is a class exception
1409 value = SyntaxError(msg, (filename, lineno, offset, line))
1409 value = SyntaxError(msg, (filename, lineno, offset, line))
1410 except:
1410 except:
1411 # If that failed, assume SyntaxError is a string
1411 # If that failed, assume SyntaxError is a string
1412 value = msg, (filename, lineno, offset, line)
1412 value = msg, (filename, lineno, offset, line)
1413 self.SyntaxTB(etype,value,[])
1413 self.SyntaxTB(etype,value,[])
1414
1414
1415 def debugger(self,force=False):
1415 def debugger(self,force=False):
1416 """Call the pydb/pdb debugger.
1416 """Call the pydb/pdb debugger.
1417
1417
1418 Keywords:
1418 Keywords:
1419
1419
1420 - force(False): by default, this routine checks the instance call_pdb
1420 - force(False): by default, this routine checks the instance call_pdb
1421 flag and does not actually invoke the debugger if the flag is false.
1421 flag and does not actually invoke the debugger if the flag is false.
1422 The 'force' option forces the debugger to activate even if the flag
1422 The 'force' option forces the debugger to activate even if the flag
1423 is false.
1423 is false.
1424 """
1424 """
1425
1425
1426 if not (force or self.call_pdb):
1426 if not (force or self.call_pdb):
1427 return
1427 return
1428
1428
1429 have_pydb = False
1429 have_pydb = False
1430 if sys.version[:3] >= '2.5':
1430 # use pydb if available
1431 # use pydb if available
1431 try:
1432 try:
1432 from pydb import pm
1433 from pydb import pm
1433 have_pydb = True
1434 have_pydb = True
1434 except ImportError:
1435 except ImportError:
1435 pass
1436 pass
1437 if not have_pydb:
1436 if not have_pydb:
1438 # fallback to our internal debugger
1437 # fallback to our internal debugger
1439 pm = lambda : self.InteractiveTB.debugger(force=True)
1438 pm = lambda : self.InteractiveTB.debugger(force=True)
1440 self.history_saving_wrapper(pm)()
1439 self.history_saving_wrapper(pm)()
1441
1440
1442 def showtraceback(self,exc_tuple = None,filename=None,tb_offset=None):
1441 def showtraceback(self,exc_tuple = None,filename=None,tb_offset=None):
1443 """Display the exception that just occurred.
1442 """Display the exception that just occurred.
1444
1443
1445 If nothing is known about the exception, this is the method which
1444 If nothing is known about the exception, this is the method which
1446 should be used throughout the code for presenting user tracebacks,
1445 should be used throughout the code for presenting user tracebacks,
1447 rather than directly invoking the InteractiveTB object.
1446 rather than directly invoking the InteractiveTB object.
1448
1447
1449 A specific showsyntaxerror() also exists, but this method can take
1448 A specific showsyntaxerror() also exists, but this method can take
1450 care of calling it if needed, so unless you are explicitly catching a
1449 care of calling it if needed, so unless you are explicitly catching a
1451 SyntaxError exception, don't try to analyze the stack manually and
1450 SyntaxError exception, don't try to analyze the stack manually and
1452 simply call this method."""
1451 simply call this method."""
1453
1452
1454 # Though this won't be called by syntax errors in the input line,
1453 # Though this won't be called by syntax errors in the input line,
1455 # there may be SyntaxError cases whith imported code.
1454 # there may be SyntaxError cases whith imported code.
1456 if exc_tuple is None:
1455 if exc_tuple is None:
1457 etype, value, tb = sys.exc_info()
1456 etype, value, tb = sys.exc_info()
1458 else:
1457 else:
1459 etype, value, tb = exc_tuple
1458 etype, value, tb = exc_tuple
1460 if etype is SyntaxError:
1459 if etype is SyntaxError:
1461 self.showsyntaxerror(filename)
1460 self.showsyntaxerror(filename)
1462 else:
1461 else:
1463 # WARNING: these variables are somewhat deprecated and not
1462 # WARNING: these variables are somewhat deprecated and not
1464 # necessarily safe to use in a threaded environment, but tools
1463 # necessarily safe to use in a threaded environment, but tools
1465 # like pdb depend on their existence, so let's set them. If we
1464 # like pdb depend on their existence, so let's set them. If we
1466 # find problems in the field, we'll need to revisit their use.
1465 # find problems in the field, we'll need to revisit their use.
1467 sys.last_type = etype
1466 sys.last_type = etype
1468 sys.last_value = value
1467 sys.last_value = value
1469 sys.last_traceback = tb
1468 sys.last_traceback = tb
1470
1469
1471 self.InteractiveTB(etype,value,tb,tb_offset=tb_offset)
1470 self.InteractiveTB(etype,value,tb,tb_offset=tb_offset)
1472 if self.InteractiveTB.call_pdb and self.has_readline:
1471 if self.InteractiveTB.call_pdb and self.has_readline:
1473 # pdb mucks up readline, fix it back
1472 # pdb mucks up readline, fix it back
1474 self.readline.set_completer(self.Completer.complete)
1473 self.readline.set_completer(self.Completer.complete)
1475
1474
1476 def mainloop(self,banner=None):
1475 def mainloop(self,banner=None):
1477 """Creates the local namespace and starts the mainloop.
1476 """Creates the local namespace and starts the mainloop.
1478
1477
1479 If an optional banner argument is given, it will override the
1478 If an optional banner argument is given, it will override the
1480 internally created default banner."""
1479 internally created default banner."""
1481
1480
1482 if self.rc.c: # Emulate Python's -c option
1481 if self.rc.c: # Emulate Python's -c option
1483 self.exec_init_cmd()
1482 self.exec_init_cmd()
1484 if banner is None:
1483 if banner is None:
1485 if not self.rc.banner:
1484 if not self.rc.banner:
1486 banner = ''
1485 banner = ''
1487 # banner is string? Use it directly!
1486 # banner is string? Use it directly!
1488 elif isinstance(self.rc.banner,basestring):
1487 elif isinstance(self.rc.banner,basestring):
1489 banner = self.rc.banner
1488 banner = self.rc.banner
1490 else:
1489 else:
1491 banner = self.BANNER+self.banner2
1490 banner = self.BANNER+self.banner2
1492
1491
1493 self.interact(banner)
1492 self.interact(banner)
1494
1493
1495 def exec_init_cmd(self):
1494 def exec_init_cmd(self):
1496 """Execute a command given at the command line.
1495 """Execute a command given at the command line.
1497
1496
1498 This emulates Python's -c option."""
1497 This emulates Python's -c option."""
1499
1498
1500 #sys.argv = ['-c']
1499 #sys.argv = ['-c']
1501 self.push(self.rc.c)
1500 self.push(self.rc.c)
1502
1501
1503 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1502 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1504 """Embeds IPython into a running python program.
1503 """Embeds IPython into a running python program.
1505
1504
1506 Input:
1505 Input:
1507
1506
1508 - header: An optional header message can be specified.
1507 - header: An optional header message can be specified.
1509
1508
1510 - local_ns, global_ns: working namespaces. If given as None, the
1509 - local_ns, global_ns: working namespaces. If given as None, the
1511 IPython-initialized one is updated with __main__.__dict__, so that
1510 IPython-initialized one is updated with __main__.__dict__, so that
1512 program variables become visible but user-specific configuration
1511 program variables become visible but user-specific configuration
1513 remains possible.
1512 remains possible.
1514
1513
1515 - stack_depth: specifies how many levels in the stack to go to
1514 - stack_depth: specifies how many levels in the stack to go to
1516 looking for namespaces (when local_ns and global_ns are None). This
1515 looking for namespaces (when local_ns and global_ns are None). This
1517 allows an intermediate caller to make sure that this function gets
1516 allows an intermediate caller to make sure that this function gets
1518 the namespace from the intended level in the stack. By default (0)
1517 the namespace from the intended level in the stack. By default (0)
1519 it will get its locals and globals from the immediate caller.
1518 it will get its locals and globals from the immediate caller.
1520
1519
1521 Warning: it's possible to use this in a program which is being run by
1520 Warning: it's possible to use this in a program which is being run by
1522 IPython itself (via %run), but some funny things will happen (a few
1521 IPython itself (via %run), but some funny things will happen (a few
1523 globals get overwritten). In the future this will be cleaned up, as
1522 globals get overwritten). In the future this will be cleaned up, as
1524 there is no fundamental reason why it can't work perfectly."""
1523 there is no fundamental reason why it can't work perfectly."""
1525
1524
1526 # Get locals and globals from caller
1525 # Get locals and globals from caller
1527 if local_ns is None or global_ns is None:
1526 if local_ns is None or global_ns is None:
1528 call_frame = sys._getframe(stack_depth).f_back
1527 call_frame = sys._getframe(stack_depth).f_back
1529
1528
1530 if local_ns is None:
1529 if local_ns is None:
1531 local_ns = call_frame.f_locals
1530 local_ns = call_frame.f_locals
1532 if global_ns is None:
1531 if global_ns is None:
1533 global_ns = call_frame.f_globals
1532 global_ns = call_frame.f_globals
1534
1533
1535 # Update namespaces and fire up interpreter
1534 # Update namespaces and fire up interpreter
1536
1535
1537 # The global one is easy, we can just throw it in
1536 # The global one is easy, we can just throw it in
1538 self.user_global_ns = global_ns
1537 self.user_global_ns = global_ns
1539
1538
1540 # but the user/local one is tricky: ipython needs it to store internal
1539 # but the user/local one is tricky: ipython needs it to store internal
1541 # data, but we also need the locals. We'll copy locals in the user
1540 # data, but we also need the locals. We'll copy locals in the user
1542 # one, but will track what got copied so we can delete them at exit.
1541 # one, but will track what got copied so we can delete them at exit.
1543 # This is so that a later embedded call doesn't see locals from a
1542 # This is so that a later embedded call doesn't see locals from a
1544 # previous call (which most likely existed in a separate scope).
1543 # previous call (which most likely existed in a separate scope).
1545 local_varnames = local_ns.keys()
1544 local_varnames = local_ns.keys()
1546 self.user_ns.update(local_ns)
1545 self.user_ns.update(local_ns)
1547
1546
1548 # Patch for global embedding to make sure that things don't overwrite
1547 # Patch for global embedding to make sure that things don't overwrite
1549 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1548 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1550 # FIXME. Test this a bit more carefully (the if.. is new)
1549 # FIXME. Test this a bit more carefully (the if.. is new)
1551 if local_ns is None and global_ns is None:
1550 if local_ns is None and global_ns is None:
1552 self.user_global_ns.update(__main__.__dict__)
1551 self.user_global_ns.update(__main__.__dict__)
1553
1552
1554 # make sure the tab-completer has the correct frame information, so it
1553 # make sure the tab-completer has the correct frame information, so it
1555 # actually completes using the frame's locals/globals
1554 # actually completes using the frame's locals/globals
1556 self.set_completer_frame()
1555 self.set_completer_frame()
1557
1556
1558 # before activating the interactive mode, we need to make sure that
1557 # before activating the interactive mode, we need to make sure that
1559 # all names in the builtin namespace needed by ipython point to
1558 # all names in the builtin namespace needed by ipython point to
1560 # ourselves, and not to other instances.
1559 # ourselves, and not to other instances.
1561 self.add_builtins()
1560 self.add_builtins()
1562
1561
1563 self.interact(header)
1562 self.interact(header)
1564
1563
1565 # now, purge out the user namespace from anything we might have added
1564 # now, purge out the user namespace from anything we might have added
1566 # from the caller's local namespace
1565 # from the caller's local namespace
1567 delvar = self.user_ns.pop
1566 delvar = self.user_ns.pop
1568 for var in local_varnames:
1567 for var in local_varnames:
1569 delvar(var,None)
1568 delvar(var,None)
1570 # and clean builtins we may have overridden
1569 # and clean builtins we may have overridden
1571 self.clean_builtins()
1570 self.clean_builtins()
1572
1571
1573 def interact(self, banner=None):
1572 def interact(self, banner=None):
1574 """Closely emulate the interactive Python console.
1573 """Closely emulate the interactive Python console.
1575
1574
1576 The optional banner argument specify the banner to print
1575 The optional banner argument specify the banner to print
1577 before the first interaction; by default it prints a banner
1576 before the first interaction; by default it prints a banner
1578 similar to the one printed by the real Python interpreter,
1577 similar to the one printed by the real Python interpreter,
1579 followed by the current class name in parentheses (so as not
1578 followed by the current class name in parentheses (so as not
1580 to confuse this with the real interpreter -- since it's so
1579 to confuse this with the real interpreter -- since it's so
1581 close!).
1580 close!).
1582
1581
1583 """
1582 """
1584
1583
1585 if self.exit_now:
1584 if self.exit_now:
1586 # batch run -> do not interact
1585 # batch run -> do not interact
1587 return
1586 return
1588 cprt = 'Type "copyright", "credits" or "license" for more information.'
1587 cprt = 'Type "copyright", "credits" or "license" for more information.'
1589 if banner is None:
1588 if banner is None:
1590 self.write("Python %s on %s\n%s\n(%s)\n" %
1589 self.write("Python %s on %s\n%s\n(%s)\n" %
1591 (sys.version, sys.platform, cprt,
1590 (sys.version, sys.platform, cprt,
1592 self.__class__.__name__))
1591 self.__class__.__name__))
1593 else:
1592 else:
1594 self.write(banner)
1593 self.write(banner)
1595
1594
1596 more = 0
1595 more = 0
1597
1596
1598 # Mark activity in the builtins
1597 # Mark activity in the builtins
1599 __builtin__.__dict__['__IPYTHON__active'] += 1
1598 __builtin__.__dict__['__IPYTHON__active'] += 1
1600
1599
1601 # exit_now is set by a call to %Exit or %Quit
1600 # exit_now is set by a call to %Exit or %Quit
1602 while not self.exit_now:
1601 while not self.exit_now:
1603 if more:
1602 if more:
1604 prompt = self.hooks.generate_prompt(True)
1603 prompt = self.hooks.generate_prompt(True)
1605 if self.autoindent:
1604 if self.autoindent:
1606 self.readline_startup_hook(self.pre_readline)
1605 self.readline_startup_hook(self.pre_readline)
1607 else:
1606 else:
1608 prompt = self.hooks.generate_prompt(False)
1607 prompt = self.hooks.generate_prompt(False)
1609 try:
1608 try:
1610 line = self.raw_input(prompt,more)
1609 line = self.raw_input(prompt,more)
1611 if self.exit_now:
1610 if self.exit_now:
1612 # quick exit on sys.std[in|out] close
1611 # quick exit on sys.std[in|out] close
1613 break
1612 break
1614 if self.autoindent:
1613 if self.autoindent:
1615 self.readline_startup_hook(None)
1614 self.readline_startup_hook(None)
1616 except KeyboardInterrupt:
1615 except KeyboardInterrupt:
1617 self.write('\nKeyboardInterrupt\n')
1616 self.write('\nKeyboardInterrupt\n')
1618 self.resetbuffer()
1617 self.resetbuffer()
1619 # keep cache in sync with the prompt counter:
1618 # keep cache in sync with the prompt counter:
1620 self.outputcache.prompt_count -= 1
1619 self.outputcache.prompt_count -= 1
1621
1620
1622 if self.autoindent:
1621 if self.autoindent:
1623 self.indent_current_nsp = 0
1622 self.indent_current_nsp = 0
1624 more = 0
1623 more = 0
1625 except EOFError:
1624 except EOFError:
1626 if self.autoindent:
1625 if self.autoindent:
1627 self.readline_startup_hook(None)
1626 self.readline_startup_hook(None)
1628 self.write('\n')
1627 self.write('\n')
1629 self.exit()
1628 self.exit()
1630 except bdb.BdbQuit:
1629 except bdb.BdbQuit:
1631 warn('The Python debugger has exited with a BdbQuit exception.\n'
1630 warn('The Python debugger has exited with a BdbQuit exception.\n'
1632 'Because of how pdb handles the stack, it is impossible\n'
1631 'Because of how pdb handles the stack, it is impossible\n'
1633 'for IPython to properly format this particular exception.\n'
1632 'for IPython to properly format this particular exception.\n'
1634 'IPython will resume normal operation.')
1633 'IPython will resume normal operation.')
1635 except:
1634 except:
1636 # exceptions here are VERY RARE, but they can be triggered
1635 # exceptions here are VERY RARE, but they can be triggered
1637 # asynchronously by signal handlers, for example.
1636 # asynchronously by signal handlers, for example.
1638 self.showtraceback()
1637 self.showtraceback()
1639 else:
1638 else:
1640 more = self.push(line)
1639 more = self.push(line)
1641 if (self.SyntaxTB.last_syntax_error and
1640 if (self.SyntaxTB.last_syntax_error and
1642 self.rc.autoedit_syntax):
1641 self.rc.autoedit_syntax):
1643 self.edit_syntax_error()
1642 self.edit_syntax_error()
1644
1643
1645 # We are off again...
1644 # We are off again...
1646 __builtin__.__dict__['__IPYTHON__active'] -= 1
1645 __builtin__.__dict__['__IPYTHON__active'] -= 1
1647
1646
1648 def excepthook(self, etype, value, tb):
1647 def excepthook(self, etype, value, tb):
1649 """One more defense for GUI apps that call sys.excepthook.
1648 """One more defense for GUI apps that call sys.excepthook.
1650
1649
1651 GUI frameworks like wxPython trap exceptions and call
1650 GUI frameworks like wxPython trap exceptions and call
1652 sys.excepthook themselves. I guess this is a feature that
1651 sys.excepthook themselves. I guess this is a feature that
1653 enables them to keep running after exceptions that would
1652 enables them to keep running after exceptions that would
1654 otherwise kill their mainloop. This is a bother for IPython
1653 otherwise kill their mainloop. This is a bother for IPython
1655 which excepts to catch all of the program exceptions with a try:
1654 which excepts to catch all of the program exceptions with a try:
1656 except: statement.
1655 except: statement.
1657
1656
1658 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1657 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1659 any app directly invokes sys.excepthook, it will look to the user like
1658 any app directly invokes sys.excepthook, it will look to the user like
1660 IPython crashed. In order to work around this, we can disable the
1659 IPython crashed. In order to work around this, we can disable the
1661 CrashHandler and replace it with this excepthook instead, which prints a
1660 CrashHandler and replace it with this excepthook instead, which prints a
1662 regular traceback using our InteractiveTB. In this fashion, apps which
1661 regular traceback using our InteractiveTB. In this fashion, apps which
1663 call sys.excepthook will generate a regular-looking exception from
1662 call sys.excepthook will generate a regular-looking exception from
1664 IPython, and the CrashHandler will only be triggered by real IPython
1663 IPython, and the CrashHandler will only be triggered by real IPython
1665 crashes.
1664 crashes.
1666
1665
1667 This hook should be used sparingly, only in places which are not likely
1666 This hook should be used sparingly, only in places which are not likely
1668 to be true IPython errors.
1667 to be true IPython errors.
1669 """
1668 """
1670 self.showtraceback((etype,value,tb),tb_offset=0)
1669 self.showtraceback((etype,value,tb),tb_offset=0)
1671
1670
1672 def expand_aliases(self,fn,rest):
1671 def expand_aliases(self,fn,rest):
1673 """ Expand multiple levels of aliases:
1672 """ Expand multiple levels of aliases:
1674
1673
1675 if:
1674 if:
1676
1675
1677 alias foo bar /tmp
1676 alias foo bar /tmp
1678 alias baz foo
1677 alias baz foo
1679
1678
1680 then:
1679 then:
1681
1680
1682 baz huhhahhei -> bar /tmp huhhahhei
1681 baz huhhahhei -> bar /tmp huhhahhei
1683
1682
1684 """
1683 """
1685 line = fn + " " + rest
1684 line = fn + " " + rest
1686
1685
1687 done = Set()
1686 done = Set()
1688 while 1:
1687 while 1:
1689 pre,fn,rest = self.split_user_input(line)
1688 pre,fn,rest = self.split_user_input(line)
1690 if fn in self.alias_table:
1689 if fn in self.alias_table:
1691 if fn in done:
1690 if fn in done:
1692 warn("Cyclic alias definition, repeated '%s'" % fn)
1691 warn("Cyclic alias definition, repeated '%s'" % fn)
1693 return ""
1692 return ""
1694 done.add(fn)
1693 done.add(fn)
1695
1694
1696 l2 = self.transform_alias(fn,rest)
1695 l2 = self.transform_alias(fn,rest)
1697 # dir -> dir
1696 # dir -> dir
1698 # print "alias",line, "->",l2 #dbg
1697 # print "alias",line, "->",l2 #dbg
1699 if l2 == line:
1698 if l2 == line:
1700 break
1699 break
1701 # ls -> ls -F should not recurse forever
1700 # ls -> ls -F should not recurse forever
1702 if l2.split(None,1)[0] == line.split(None,1)[0]:
1701 if l2.split(None,1)[0] == line.split(None,1)[0]:
1703 line = l2
1702 line = l2
1704 break
1703 break
1705
1704
1706 line=l2
1705 line=l2
1707
1706
1708
1707
1709 # print "al expand to",line #dbg
1708 # print "al expand to",line #dbg
1710 else:
1709 else:
1711 break
1710 break
1712
1711
1713 return line
1712 return line
1714
1713
1715 def transform_alias(self, alias,rest=''):
1714 def transform_alias(self, alias,rest=''):
1716 """ Transform alias to system command string.
1715 """ Transform alias to system command string.
1717 """
1716 """
1718 nargs,cmd = self.alias_table[alias]
1717 nargs,cmd = self.alias_table[alias]
1719 if ' ' in cmd and os.path.isfile(cmd):
1718 if ' ' in cmd and os.path.isfile(cmd):
1720 cmd = '"%s"' % cmd
1719 cmd = '"%s"' % cmd
1721
1720
1722 # Expand the %l special to be the user's input line
1721 # Expand the %l special to be the user's input line
1723 if cmd.find('%l') >= 0:
1722 if cmd.find('%l') >= 0:
1724 cmd = cmd.replace('%l',rest)
1723 cmd = cmd.replace('%l',rest)
1725 rest = ''
1724 rest = ''
1726 if nargs==0:
1725 if nargs==0:
1727 # Simple, argument-less aliases
1726 # Simple, argument-less aliases
1728 cmd = '%s %s' % (cmd,rest)
1727 cmd = '%s %s' % (cmd,rest)
1729 else:
1728 else:
1730 # Handle aliases with positional arguments
1729 # Handle aliases with positional arguments
1731 args = rest.split(None,nargs)
1730 args = rest.split(None,nargs)
1732 if len(args)< nargs:
1731 if len(args)< nargs:
1733 error('Alias <%s> requires %s arguments, %s given.' %
1732 error('Alias <%s> requires %s arguments, %s given.' %
1734 (alias,nargs,len(args)))
1733 (alias,nargs,len(args)))
1735 return None
1734 return None
1736 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1735 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1737 # Now call the macro, evaluating in the user's namespace
1736 # Now call the macro, evaluating in the user's namespace
1738 #print 'new command: <%r>' % cmd # dbg
1737 #print 'new command: <%r>' % cmd # dbg
1739 return cmd
1738 return cmd
1740
1739
1741 def call_alias(self,alias,rest=''):
1740 def call_alias(self,alias,rest=''):
1742 """Call an alias given its name and the rest of the line.
1741 """Call an alias given its name and the rest of the line.
1743
1742
1744 This is only used to provide backwards compatibility for users of
1743 This is only used to provide backwards compatibility for users of
1745 ipalias(), use of which is not recommended for anymore."""
1744 ipalias(), use of which is not recommended for anymore."""
1746
1745
1747 # Now call the macro, evaluating in the user's namespace
1746 # Now call the macro, evaluating in the user's namespace
1748 cmd = self.transform_alias(alias, rest)
1747 cmd = self.transform_alias(alias, rest)
1749 try:
1748 try:
1750 self.system(cmd)
1749 self.system(cmd)
1751 except:
1750 except:
1752 self.showtraceback()
1751 self.showtraceback()
1753
1752
1754 def indent_current_str(self):
1753 def indent_current_str(self):
1755 """return the current level of indentation as a string"""
1754 """return the current level of indentation as a string"""
1756 return self.indent_current_nsp * ' '
1755 return self.indent_current_nsp * ' '
1757
1756
1758 def autoindent_update(self,line):
1757 def autoindent_update(self,line):
1759 """Keep track of the indent level."""
1758 """Keep track of the indent level."""
1760
1759
1761 #debugx('line')
1760 #debugx('line')
1762 #debugx('self.indent_current_nsp')
1761 #debugx('self.indent_current_nsp')
1763 if self.autoindent:
1762 if self.autoindent:
1764 if line:
1763 if line:
1765 inisp = num_ini_spaces(line)
1764 inisp = num_ini_spaces(line)
1766 if inisp < self.indent_current_nsp:
1765 if inisp < self.indent_current_nsp:
1767 self.indent_current_nsp = inisp
1766 self.indent_current_nsp = inisp
1768
1767
1769 if line[-1] == ':':
1768 if line[-1] == ':':
1770 self.indent_current_nsp += 4
1769 self.indent_current_nsp += 4
1771 elif dedent_re.match(line):
1770 elif dedent_re.match(line):
1772 self.indent_current_nsp -= 4
1771 self.indent_current_nsp -= 4
1773 else:
1772 else:
1774 self.indent_current_nsp = 0
1773 self.indent_current_nsp = 0
1775
1774
1776 def runlines(self,lines):
1775 def runlines(self,lines):
1777 """Run a string of one or more lines of source.
1776 """Run a string of one or more lines of source.
1778
1777
1779 This method is capable of running a string containing multiple source
1778 This method is capable of running a string containing multiple source
1780 lines, as if they had been entered at the IPython prompt. Since it
1779 lines, as if they had been entered at the IPython prompt. Since it
1781 exposes IPython's processing machinery, the given strings can contain
1780 exposes IPython's processing machinery, the given strings can contain
1782 magic calls (%magic), special shell access (!cmd), etc."""
1781 magic calls (%magic), special shell access (!cmd), etc."""
1783
1782
1784 # We must start with a clean buffer, in case this is run from an
1783 # We must start with a clean buffer, in case this is run from an
1785 # interactive IPython session (via a magic, for example).
1784 # interactive IPython session (via a magic, for example).
1786 self.resetbuffer()
1785 self.resetbuffer()
1787 lines = lines.split('\n')
1786 lines = lines.split('\n')
1788 more = 0
1787 more = 0
1789 for line in lines:
1788 for line in lines:
1790 # skip blank lines so we don't mess up the prompt counter, but do
1789 # skip blank lines so we don't mess up the prompt counter, but do
1791 # NOT skip even a blank line if we are in a code block (more is
1790 # NOT skip even a blank line if we are in a code block (more is
1792 # true)
1791 # true)
1793 if line or more:
1792 if line or more:
1794 more = self.push(self.prefilter(line,more))
1793 more = self.push(self.prefilter(line,more))
1795 # IPython's runsource returns None if there was an error
1794 # IPython's runsource returns None if there was an error
1796 # compiling the code. This allows us to stop processing right
1795 # compiling the code. This allows us to stop processing right
1797 # away, so the user gets the error message at the right place.
1796 # away, so the user gets the error message at the right place.
1798 if more is None:
1797 if more is None:
1799 break
1798 break
1800 # final newline in case the input didn't have it, so that the code
1799 # final newline in case the input didn't have it, so that the code
1801 # actually does get executed
1800 # actually does get executed
1802 if more:
1801 if more:
1803 self.push('\n')
1802 self.push('\n')
1804
1803
1805 def runsource(self, source, filename='<input>', symbol='single'):
1804 def runsource(self, source, filename='<input>', symbol='single'):
1806 """Compile and run some source in the interpreter.
1805 """Compile and run some source in the interpreter.
1807
1806
1808 Arguments are as for compile_command().
1807 Arguments are as for compile_command().
1809
1808
1810 One several things can happen:
1809 One several things can happen:
1811
1810
1812 1) The input is incorrect; compile_command() raised an
1811 1) The input is incorrect; compile_command() raised an
1813 exception (SyntaxError or OverflowError). A syntax traceback
1812 exception (SyntaxError or OverflowError). A syntax traceback
1814 will be printed by calling the showsyntaxerror() method.
1813 will be printed by calling the showsyntaxerror() method.
1815
1814
1816 2) The input is incomplete, and more input is required;
1815 2) The input is incomplete, and more input is required;
1817 compile_command() returned None. Nothing happens.
1816 compile_command() returned None. Nothing happens.
1818
1817
1819 3) The input is complete; compile_command() returned a code
1818 3) The input is complete; compile_command() returned a code
1820 object. The code is executed by calling self.runcode() (which
1819 object. The code is executed by calling self.runcode() (which
1821 also handles run-time exceptions, except for SystemExit).
1820 also handles run-time exceptions, except for SystemExit).
1822
1821
1823 The return value is:
1822 The return value is:
1824
1823
1825 - True in case 2
1824 - True in case 2
1826
1825
1827 - False in the other cases, unless an exception is raised, where
1826 - False in the other cases, unless an exception is raised, where
1828 None is returned instead. This can be used by external callers to
1827 None is returned instead. This can be used by external callers to
1829 know whether to continue feeding input or not.
1828 know whether to continue feeding input or not.
1830
1829
1831 The return value can be used to decide whether to use sys.ps1 or
1830 The return value can be used to decide whether to use sys.ps1 or
1832 sys.ps2 to prompt the next line."""
1831 sys.ps2 to prompt the next line."""
1833
1832
1834 # if the source code has leading blanks, add 'if 1:\n' to it
1833 # if the source code has leading blanks, add 'if 1:\n' to it
1835 # this allows execution of indented pasted code. It is tempting
1834 # this allows execution of indented pasted code. It is tempting
1836 # to add '\n' at the end of source to run commands like ' a=1'
1835 # to add '\n' at the end of source to run commands like ' a=1'
1837 # directly, but this fails for more complicated scenarios
1836 # directly, but this fails for more complicated scenarios
1838 if source[:1] in [' ', '\t']:
1837 if source[:1] in [' ', '\t']:
1839 source = 'if 1:\n%s' % source
1838 source = 'if 1:\n%s' % source
1840
1839
1841 try:
1840 try:
1842 code = self.compile(source,filename,symbol)
1841 code = self.compile(source,filename,symbol)
1843 except (OverflowError, SyntaxError, ValueError):
1842 except (OverflowError, SyntaxError, ValueError):
1844 # Case 1
1843 # Case 1
1845 self.showsyntaxerror(filename)
1844 self.showsyntaxerror(filename)
1846 return None
1845 return None
1847
1846
1848 if code is None:
1847 if code is None:
1849 # Case 2
1848 # Case 2
1850 return True
1849 return True
1851
1850
1852 # Case 3
1851 # Case 3
1853 # We store the code object so that threaded shells and
1852 # We store the code object so that threaded shells and
1854 # custom exception handlers can access all this info if needed.
1853 # custom exception handlers can access all this info if needed.
1855 # The source corresponding to this can be obtained from the
1854 # The source corresponding to this can be obtained from the
1856 # buffer attribute as '\n'.join(self.buffer).
1855 # buffer attribute as '\n'.join(self.buffer).
1857 self.code_to_run = code
1856 self.code_to_run = code
1858 # now actually execute the code object
1857 # now actually execute the code object
1859 if self.runcode(code) == 0:
1858 if self.runcode(code) == 0:
1860 return False
1859 return False
1861 else:
1860 else:
1862 return None
1861 return None
1863
1862
1864 def runcode(self,code_obj):
1863 def runcode(self,code_obj):
1865 """Execute a code object.
1864 """Execute a code object.
1866
1865
1867 When an exception occurs, self.showtraceback() is called to display a
1866 When an exception occurs, self.showtraceback() is called to display a
1868 traceback.
1867 traceback.
1869
1868
1870 Return value: a flag indicating whether the code to be run completed
1869 Return value: a flag indicating whether the code to be run completed
1871 successfully:
1870 successfully:
1872
1871
1873 - 0: successful execution.
1872 - 0: successful execution.
1874 - 1: an error occurred.
1873 - 1: an error occurred.
1875 """
1874 """
1876
1875
1877 # Set our own excepthook in case the user code tries to call it
1876 # Set our own excepthook in case the user code tries to call it
1878 # directly, so that the IPython crash handler doesn't get triggered
1877 # directly, so that the IPython crash handler doesn't get triggered
1879 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1878 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1880
1879
1881 # we save the original sys.excepthook in the instance, in case config
1880 # we save the original sys.excepthook in the instance, in case config
1882 # code (such as magics) needs access to it.
1881 # code (such as magics) needs access to it.
1883 self.sys_excepthook = old_excepthook
1882 self.sys_excepthook = old_excepthook
1884 outflag = 1 # happens in more places, so it's easier as default
1883 outflag = 1 # happens in more places, so it's easier as default
1885 try:
1884 try:
1886 try:
1885 try:
1887 # Embedded instances require separate global/local namespaces
1886 # Embedded instances require separate global/local namespaces
1888 # so they can see both the surrounding (local) namespace and
1887 # so they can see both the surrounding (local) namespace and
1889 # the module-level globals when called inside another function.
1888 # the module-level globals when called inside another function.
1890 if self.embedded:
1889 if self.embedded:
1891 exec code_obj in self.user_global_ns, self.user_ns
1890 exec code_obj in self.user_global_ns, self.user_ns
1892 # Normal (non-embedded) instances should only have a single
1891 # Normal (non-embedded) instances should only have a single
1893 # namespace for user code execution, otherwise functions won't
1892 # namespace for user code execution, otherwise functions won't
1894 # see interactive top-level globals.
1893 # see interactive top-level globals.
1895 else:
1894 else:
1896 exec code_obj in self.user_ns
1895 exec code_obj in self.user_ns
1897 finally:
1896 finally:
1898 # Reset our crash handler in place
1897 # Reset our crash handler in place
1899 sys.excepthook = old_excepthook
1898 sys.excepthook = old_excepthook
1900 except SystemExit:
1899 except SystemExit:
1901 self.resetbuffer()
1900 self.resetbuffer()
1902 self.showtraceback()
1901 self.showtraceback()
1903 warn("Type %exit or %quit to exit IPython "
1902 warn("Type %exit or %quit to exit IPython "
1904 "(%Exit or %Quit do so unconditionally).",level=1)
1903 "(%Exit or %Quit do so unconditionally).",level=1)
1905 except self.custom_exceptions:
1904 except self.custom_exceptions:
1906 etype,value,tb = sys.exc_info()
1905 etype,value,tb = sys.exc_info()
1907 self.CustomTB(etype,value,tb)
1906 self.CustomTB(etype,value,tb)
1908 except:
1907 except:
1909 self.showtraceback()
1908 self.showtraceback()
1910 else:
1909 else:
1911 outflag = 0
1910 outflag = 0
1912 if softspace(sys.stdout, 0):
1911 if softspace(sys.stdout, 0):
1913 print
1912 print
1914 # Flush out code object which has been run (and source)
1913 # Flush out code object which has been run (and source)
1915 self.code_to_run = None
1914 self.code_to_run = None
1916 return outflag
1915 return outflag
1917
1916
1918 def push(self, line):
1917 def push(self, line):
1919 """Push a line to the interpreter.
1918 """Push a line to the interpreter.
1920
1919
1921 The line should not have a trailing newline; it may have
1920 The line should not have a trailing newline; it may have
1922 internal newlines. The line is appended to a buffer and the
1921 internal newlines. The line is appended to a buffer and the
1923 interpreter's runsource() method is called with the
1922 interpreter's runsource() method is called with the
1924 concatenated contents of the buffer as source. If this
1923 concatenated contents of the buffer as source. If this
1925 indicates that the command was executed or invalid, the buffer
1924 indicates that the command was executed or invalid, the buffer
1926 is reset; otherwise, the command is incomplete, and the buffer
1925 is reset; otherwise, the command is incomplete, and the buffer
1927 is left as it was after the line was appended. The return
1926 is left as it was after the line was appended. The return
1928 value is 1 if more input is required, 0 if the line was dealt
1927 value is 1 if more input is required, 0 if the line was dealt
1929 with in some way (this is the same as runsource()).
1928 with in some way (this is the same as runsource()).
1930 """
1929 """
1931
1930
1932 # autoindent management should be done here, and not in the
1931 # autoindent management should be done here, and not in the
1933 # interactive loop, since that one is only seen by keyboard input. We
1932 # interactive loop, since that one is only seen by keyboard input. We
1934 # need this done correctly even for code run via runlines (which uses
1933 # need this done correctly even for code run via runlines (which uses
1935 # push).
1934 # push).
1936
1935
1937 #print 'push line: <%s>' % line # dbg
1936 #print 'push line: <%s>' % line # dbg
1938 for subline in line.splitlines():
1937 for subline in line.splitlines():
1939 self.autoindent_update(subline)
1938 self.autoindent_update(subline)
1940 self.buffer.append(line)
1939 self.buffer.append(line)
1941 more = self.runsource('\n'.join(self.buffer), self.filename)
1940 more = self.runsource('\n'.join(self.buffer), self.filename)
1942 if not more:
1941 if not more:
1943 self.resetbuffer()
1942 self.resetbuffer()
1944 return more
1943 return more
1945
1944
1946 def resetbuffer(self):
1945 def resetbuffer(self):
1947 """Reset the input buffer."""
1946 """Reset the input buffer."""
1948 self.buffer[:] = []
1947 self.buffer[:] = []
1949
1948
1950 def raw_input(self,prompt='',continue_prompt=False):
1949 def raw_input(self,prompt='',continue_prompt=False):
1951 """Write a prompt and read a line.
1950 """Write a prompt and read a line.
1952
1951
1953 The returned line does not include the trailing newline.
1952 The returned line does not include the trailing newline.
1954 When the user enters the EOF key sequence, EOFError is raised.
1953 When the user enters the EOF key sequence, EOFError is raised.
1955
1954
1956 Optional inputs:
1955 Optional inputs:
1957
1956
1958 - prompt(''): a string to be printed to prompt the user.
1957 - prompt(''): a string to be printed to prompt the user.
1959
1958
1960 - continue_prompt(False): whether this line is the first one or a
1959 - continue_prompt(False): whether this line is the first one or a
1961 continuation in a sequence of inputs.
1960 continuation in a sequence of inputs.
1962 """
1961 """
1963
1962
1964 try:
1963 try:
1965 line = raw_input_original(prompt)
1964 line = raw_input_original(prompt)
1966 except ValueError:
1965 except ValueError:
1967 warn("\n********\nYou or a %run:ed script called sys.stdin.close() or sys.stdout.close()!\nExiting IPython!")
1966 warn("\n********\nYou or a %run:ed script called sys.stdin.close() or sys.stdout.close()!\nExiting IPython!")
1968 self.exit_now = True
1967 self.exit_now = True
1969 return ""
1968 return ""
1970
1969
1971
1970
1972 # Try to be reasonably smart about not re-indenting pasted input more
1971 # Try to be reasonably smart about not re-indenting pasted input more
1973 # than necessary. We do this by trimming out the auto-indent initial
1972 # than necessary. We do this by trimming out the auto-indent initial
1974 # spaces, if the user's actual input started itself with whitespace.
1973 # spaces, if the user's actual input started itself with whitespace.
1975 #debugx('self.buffer[-1]')
1974 #debugx('self.buffer[-1]')
1976
1975
1977 if self.autoindent:
1976 if self.autoindent:
1978 if num_ini_spaces(line) > self.indent_current_nsp:
1977 if num_ini_spaces(line) > self.indent_current_nsp:
1979 line = line[self.indent_current_nsp:]
1978 line = line[self.indent_current_nsp:]
1980 self.indent_current_nsp = 0
1979 self.indent_current_nsp = 0
1981
1980
1982 # store the unfiltered input before the user has any chance to modify
1981 # store the unfiltered input before the user has any chance to modify
1983 # it.
1982 # it.
1984 if line.strip():
1983 if line.strip():
1985 if continue_prompt:
1984 if continue_prompt:
1986 self.input_hist_raw[-1] += '%s\n' % line
1985 self.input_hist_raw[-1] += '%s\n' % line
1987 if self.has_readline: # and some config option is set?
1986 if self.has_readline: # and some config option is set?
1988 try:
1987 try:
1989 histlen = self.readline.get_current_history_length()
1988 histlen = self.readline.get_current_history_length()
1990 newhist = self.input_hist_raw[-1].rstrip()
1989 newhist = self.input_hist_raw[-1].rstrip()
1991 self.readline.remove_history_item(histlen-1)
1990 self.readline.remove_history_item(histlen-1)
1992 self.readline.replace_history_item(histlen-2,newhist)
1991 self.readline.replace_history_item(histlen-2,newhist)
1993 except AttributeError:
1992 except AttributeError:
1994 pass # re{move,place}_history_item are new in 2.4.
1993 pass # re{move,place}_history_item are new in 2.4.
1995 else:
1994 else:
1996 self.input_hist_raw.append('%s\n' % line)
1995 self.input_hist_raw.append('%s\n' % line)
1997
1996
1998 try:
1997 try:
1999 lineout = self.prefilter(line,continue_prompt)
1998 lineout = self.prefilter(line,continue_prompt)
2000 except:
1999 except:
2001 # blanket except, in case a user-defined prefilter crashes, so it
2000 # blanket except, in case a user-defined prefilter crashes, so it
2002 # can't take all of ipython with it.
2001 # can't take all of ipython with it.
2003 self.showtraceback()
2002 self.showtraceback()
2004 return ''
2003 return ''
2005 else:
2004 else:
2006 return lineout
2005 return lineout
2007
2006
2008 def split_user_input(self,line):
2007 def split_user_input(self,line):
2009 """Split user input into pre-char, function part and rest."""
2008 """Split user input into pre-char, function part and rest."""
2010
2009
2011 lsplit = self.line_split.match(line)
2010 lsplit = self.line_split.match(line)
2012 if lsplit is None: # no regexp match returns None
2011 if lsplit is None: # no regexp match returns None
2013 try:
2012 try:
2014 iFun,theRest = line.split(None,1)
2013 iFun,theRest = line.split(None,1)
2015 except ValueError:
2014 except ValueError:
2016 iFun,theRest = line,''
2015 iFun,theRest = line,''
2017 pre = re.match('^(\s*)(.*)',line).groups()[0]
2016 pre = re.match('^(\s*)(.*)',line).groups()[0]
2018 else:
2017 else:
2019 pre,iFun,theRest = lsplit.groups()
2018 pre,iFun,theRest = lsplit.groups()
2020
2019
2021 #print 'line:<%s>' % line # dbg
2020 #print 'line:<%s>' % line # dbg
2022 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
2021 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
2023 return pre,iFun.strip(),theRest
2022 return pre,iFun.strip(),theRest
2024
2023
2025 def _prefilter(self, line, continue_prompt):
2024 def _prefilter(self, line, continue_prompt):
2026 """Calls different preprocessors, depending on the form of line."""
2025 """Calls different preprocessors, depending on the form of line."""
2027
2026
2028 # All handlers *must* return a value, even if it's blank ('').
2027 # All handlers *must* return a value, even if it's blank ('').
2029
2028
2030 # Lines are NOT logged here. Handlers should process the line as
2029 # Lines are NOT logged here. Handlers should process the line as
2031 # needed, update the cache AND log it (so that the input cache array
2030 # needed, update the cache AND log it (so that the input cache array
2032 # stays synced).
2031 # stays synced).
2033
2032
2034 # This function is _very_ delicate, and since it's also the one which
2033 # This function is _very_ delicate, and since it's also the one which
2035 # determines IPython's response to user input, it must be as efficient
2034 # determines IPython's response to user input, it must be as efficient
2036 # as possible. For this reason it has _many_ returns in it, trying
2035 # as possible. For this reason it has _many_ returns in it, trying
2037 # always to exit as quickly as it can figure out what it needs to do.
2036 # always to exit as quickly as it can figure out what it needs to do.
2038
2037
2039 # This function is the main responsible for maintaining IPython's
2038 # This function is the main responsible for maintaining IPython's
2040 # behavior respectful of Python's semantics. So be _very_ careful if
2039 # behavior respectful of Python's semantics. So be _very_ careful if
2041 # making changes to anything here.
2040 # making changes to anything here.
2042
2041
2043 #.....................................................................
2042 #.....................................................................
2044 # Code begins
2043 # Code begins
2045
2044
2046 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
2045 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
2047
2046
2048 # save the line away in case we crash, so the post-mortem handler can
2047 # save the line away in case we crash, so the post-mortem handler can
2049 # record it
2048 # record it
2050 self._last_input_line = line
2049 self._last_input_line = line
2051
2050
2052 #print '***line: <%s>' % line # dbg
2051 #print '***line: <%s>' % line # dbg
2053
2052
2054 # the input history needs to track even empty lines
2053 # the input history needs to track even empty lines
2055 stripped = line.strip()
2054 stripped = line.strip()
2056
2055
2057 if not stripped:
2056 if not stripped:
2058 if not continue_prompt:
2057 if not continue_prompt:
2059 self.outputcache.prompt_count -= 1
2058 self.outputcache.prompt_count -= 1
2060 return self.handle_normal(line,continue_prompt)
2059 return self.handle_normal(line,continue_prompt)
2061 #return self.handle_normal('',continue_prompt)
2060 #return self.handle_normal('',continue_prompt)
2062
2061
2063 # print '***cont',continue_prompt # dbg
2062 # print '***cont',continue_prompt # dbg
2064 # special handlers are only allowed for single line statements
2063 # special handlers are only allowed for single line statements
2065 if continue_prompt and not self.rc.multi_line_specials:
2064 if continue_prompt and not self.rc.multi_line_specials:
2066 return self.handle_normal(line,continue_prompt)
2065 return self.handle_normal(line,continue_prompt)
2067
2066
2068
2067
2069 # For the rest, we need the structure of the input
2068 # For the rest, we need the structure of the input
2070 pre,iFun,theRest = self.split_user_input(line)
2069 pre,iFun,theRest = self.split_user_input(line)
2071
2070
2072 # See whether any pre-existing handler can take care of it
2071 # See whether any pre-existing handler can take care of it
2073
2072
2074 rewritten = self.hooks.input_prefilter(stripped)
2073 rewritten = self.hooks.input_prefilter(stripped)
2075 if rewritten != stripped: # ok, some prefilter did something
2074 if rewritten != stripped: # ok, some prefilter did something
2076 rewritten = pre + rewritten # add indentation
2075 rewritten = pre + rewritten # add indentation
2077 return self.handle_normal(rewritten)
2076 return self.handle_normal(rewritten)
2078
2077
2079 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2078 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2080
2079
2081 # First check for explicit escapes in the last/first character
2080 # First check for explicit escapes in the last/first character
2082 handler = None
2081 handler = None
2083 if line[-1] == self.ESC_HELP:
2082 if line[-1] == self.ESC_HELP:
2084 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
2083 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
2085 if handler is None:
2084 if handler is None:
2086 # look at the first character of iFun, NOT of line, so we skip
2085 # look at the first character of iFun, NOT of line, so we skip
2087 # leading whitespace in multiline input
2086 # leading whitespace in multiline input
2088 handler = self.esc_handlers.get(iFun[0:1])
2087 handler = self.esc_handlers.get(iFun[0:1])
2089 if handler is not None:
2088 if handler is not None:
2090 return handler(line,continue_prompt,pre,iFun,theRest)
2089 return handler(line,continue_prompt,pre,iFun,theRest)
2091 # Emacs ipython-mode tags certain input lines
2090 # Emacs ipython-mode tags certain input lines
2092 if line.endswith('# PYTHON-MODE'):
2091 if line.endswith('# PYTHON-MODE'):
2093 return self.handle_emacs(line,continue_prompt)
2092 return self.handle_emacs(line,continue_prompt)
2094
2093
2095 # Next, check if we can automatically execute this thing
2094 # Next, check if we can automatically execute this thing
2096
2095
2097 # Allow ! in multi-line statements if multi_line_specials is on:
2096 # Allow ! in multi-line statements if multi_line_specials is on:
2098 if continue_prompt and self.rc.multi_line_specials and \
2097 if continue_prompt and self.rc.multi_line_specials and \
2099 iFun.startswith(self.ESC_SHELL):
2098 iFun.startswith(self.ESC_SHELL):
2100 return self.handle_shell_escape(line,continue_prompt,
2099 return self.handle_shell_escape(line,continue_prompt,
2101 pre=pre,iFun=iFun,
2100 pre=pre,iFun=iFun,
2102 theRest=theRest)
2101 theRest=theRest)
2103
2102
2104 # Let's try to find if the input line is a magic fn
2103 # Let's try to find if the input line is a magic fn
2105 oinfo = None
2104 oinfo = None
2106 if hasattr(self,'magic_'+iFun):
2105 if hasattr(self,'magic_'+iFun):
2107 # WARNING: _ofind uses getattr(), so it can consume generators and
2106 # WARNING: _ofind uses getattr(), so it can consume generators and
2108 # cause other side effects.
2107 # cause other side effects.
2109 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2108 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2110 if oinfo['ismagic']:
2109 if oinfo['ismagic']:
2111 # Be careful not to call magics when a variable assignment is
2110 # Be careful not to call magics when a variable assignment is
2112 # being made (ls='hi', for example)
2111 # being made (ls='hi', for example)
2113 if self.rc.automagic and \
2112 if self.rc.automagic and \
2114 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
2113 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
2115 (self.rc.multi_line_specials or not continue_prompt):
2114 (self.rc.multi_line_specials or not continue_prompt):
2116 return self.handle_magic(line,continue_prompt,
2115 return self.handle_magic(line,continue_prompt,
2117 pre,iFun,theRest)
2116 pre,iFun,theRest)
2118 else:
2117 else:
2119 return self.handle_normal(line,continue_prompt)
2118 return self.handle_normal(line,continue_prompt)
2120
2119
2121 # If the rest of the line begins with an (in)equality, assginment or
2120 # If the rest of the line begins with an (in)equality, assginment or
2122 # function call, we should not call _ofind but simply execute it.
2121 # function call, we should not call _ofind but simply execute it.
2123 # This avoids spurious geattr() accesses on objects upon assignment.
2122 # This avoids spurious geattr() accesses on objects upon assignment.
2124 #
2123 #
2125 # It also allows users to assign to either alias or magic names true
2124 # It also allows users to assign to either alias or magic names true
2126 # python variables (the magic/alias systems always take second seat to
2125 # python variables (the magic/alias systems always take second seat to
2127 # true python code).
2126 # true python code).
2128 if theRest and theRest[0] in '!=()':
2127 if theRest and theRest[0] in '!=()':
2129 return self.handle_normal(line,continue_prompt)
2128 return self.handle_normal(line,continue_prompt)
2130
2129
2131 if oinfo is None:
2130 if oinfo is None:
2132 # let's try to ensure that _oinfo is ONLY called when autocall is
2131 # let's try to ensure that _oinfo is ONLY called when autocall is
2133 # on. Since it has inevitable potential side effects, at least
2132 # on. Since it has inevitable potential side effects, at least
2134 # having autocall off should be a guarantee to the user that no
2133 # having autocall off should be a guarantee to the user that no
2135 # weird things will happen.
2134 # weird things will happen.
2136
2135
2137 if self.rc.autocall:
2136 if self.rc.autocall:
2138 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2137 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2139 else:
2138 else:
2140 # in this case, all that's left is either an alias or
2139 # in this case, all that's left is either an alias or
2141 # processing the line normally.
2140 # processing the line normally.
2142 if iFun in self.alias_table:
2141 if iFun in self.alias_table:
2143 # if autocall is off, by not running _ofind we won't know
2142 # if autocall is off, by not running _ofind we won't know
2144 # whether the given name may also exist in one of the
2143 # whether the given name may also exist in one of the
2145 # user's namespace. At this point, it's best to do a
2144 # user's namespace. At this point, it's best to do a
2146 # quick check just to be sure that we don't let aliases
2145 # quick check just to be sure that we don't let aliases
2147 # shadow variables.
2146 # shadow variables.
2148 head = iFun.split('.',1)[0]
2147 head = iFun.split('.',1)[0]
2149 if head in self.user_ns or head in self.internal_ns \
2148 if head in self.user_ns or head in self.internal_ns \
2150 or head in __builtin__.__dict__:
2149 or head in __builtin__.__dict__:
2151 return self.handle_normal(line,continue_prompt)
2150 return self.handle_normal(line,continue_prompt)
2152 else:
2151 else:
2153 return self.handle_alias(line,continue_prompt,
2152 return self.handle_alias(line,continue_prompt,
2154 pre,iFun,theRest)
2153 pre,iFun,theRest)
2155
2154
2156 else:
2155 else:
2157 return self.handle_normal(line,continue_prompt)
2156 return self.handle_normal(line,continue_prompt)
2158
2157
2159 if not oinfo['found']:
2158 if not oinfo['found']:
2160 return self.handle_normal(line,continue_prompt)
2159 return self.handle_normal(line,continue_prompt)
2161 else:
2160 else:
2162 #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2161 #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2163 if oinfo['isalias']:
2162 if oinfo['isalias']:
2164 return self.handle_alias(line,continue_prompt,
2163 return self.handle_alias(line,continue_prompt,
2165 pre,iFun,theRest)
2164 pre,iFun,theRest)
2166
2165
2167 if (self.rc.autocall
2166 if (self.rc.autocall
2168 and
2167 and
2169 (
2168 (
2170 #only consider exclusion re if not "," or ";" autoquoting
2169 #only consider exclusion re if not "," or ";" autoquoting
2171 (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2
2170 (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2
2172 or pre == self.ESC_PAREN) or
2171 or pre == self.ESC_PAREN) or
2173 (not self.re_exclude_auto.match(theRest)))
2172 (not self.re_exclude_auto.match(theRest)))
2174 and
2173 and
2175 self.re_fun_name.match(iFun) and
2174 self.re_fun_name.match(iFun) and
2176 callable(oinfo['obj'])) :
2175 callable(oinfo['obj'])) :
2177 #print 'going auto' # dbg
2176 #print 'going auto' # dbg
2178 return self.handle_auto(line,continue_prompt,
2177 return self.handle_auto(line,continue_prompt,
2179 pre,iFun,theRest,oinfo['obj'])
2178 pre,iFun,theRest,oinfo['obj'])
2180 else:
2179 else:
2181 #print 'was callable?', callable(oinfo['obj']) # dbg
2180 #print 'was callable?', callable(oinfo['obj']) # dbg
2182 return self.handle_normal(line,continue_prompt)
2181 return self.handle_normal(line,continue_prompt)
2183
2182
2184 # If we get here, we have a normal Python line. Log and return.
2183 # If we get here, we have a normal Python line. Log and return.
2185 return self.handle_normal(line,continue_prompt)
2184 return self.handle_normal(line,continue_prompt)
2186
2185
2187 def _prefilter_dumb(self, line, continue_prompt):
2186 def _prefilter_dumb(self, line, continue_prompt):
2188 """simple prefilter function, for debugging"""
2187 """simple prefilter function, for debugging"""
2189 return self.handle_normal(line,continue_prompt)
2188 return self.handle_normal(line,continue_prompt)
2190
2189
2191
2190
2192 def multiline_prefilter(self, line, continue_prompt):
2191 def multiline_prefilter(self, line, continue_prompt):
2193 """ Run _prefilter for each line of input
2192 """ Run _prefilter for each line of input
2194
2193
2195 Covers cases where there are multiple lines in the user entry,
2194 Covers cases where there are multiple lines in the user entry,
2196 which is the case when the user goes back to a multiline history
2195 which is the case when the user goes back to a multiline history
2197 entry and presses enter.
2196 entry and presses enter.
2198
2197
2199 """
2198 """
2200 out = []
2199 out = []
2201 for l in line.rstrip('\n').split('\n'):
2200 for l in line.rstrip('\n').split('\n'):
2202 out.append(self._prefilter(l, continue_prompt))
2201 out.append(self._prefilter(l, continue_prompt))
2203 return '\n'.join(out)
2202 return '\n'.join(out)
2204
2203
2205 # Set the default prefilter() function (this can be user-overridden)
2204 # Set the default prefilter() function (this can be user-overridden)
2206 prefilter = multiline_prefilter
2205 prefilter = multiline_prefilter
2207
2206
2208 def handle_normal(self,line,continue_prompt=None,
2207 def handle_normal(self,line,continue_prompt=None,
2209 pre=None,iFun=None,theRest=None):
2208 pre=None,iFun=None,theRest=None):
2210 """Handle normal input lines. Use as a template for handlers."""
2209 """Handle normal input lines. Use as a template for handlers."""
2211
2210
2212 # With autoindent on, we need some way to exit the input loop, and I
2211 # With autoindent on, we need some way to exit the input loop, and I
2213 # don't want to force the user to have to backspace all the way to
2212 # don't want to force the user to have to backspace all the way to
2214 # clear the line. The rule will be in this case, that either two
2213 # clear the line. The rule will be in this case, that either two
2215 # lines of pure whitespace in a row, or a line of pure whitespace but
2214 # lines of pure whitespace in a row, or a line of pure whitespace but
2216 # of a size different to the indent level, will exit the input loop.
2215 # of a size different to the indent level, will exit the input loop.
2217
2216
2218 if (continue_prompt and self.autoindent and line.isspace() and
2217 if (continue_prompt and self.autoindent and line.isspace() and
2219 (0 < abs(len(line) - self.indent_current_nsp) <= 2 or
2218 (0 < abs(len(line) - self.indent_current_nsp) <= 2 or
2220 (self.buffer[-1]).isspace() )):
2219 (self.buffer[-1]).isspace() )):
2221 line = ''
2220 line = ''
2222
2221
2223 self.log(line,line,continue_prompt)
2222 self.log(line,line,continue_prompt)
2224 return line
2223 return line
2225
2224
2226 def handle_alias(self,line,continue_prompt=None,
2225 def handle_alias(self,line,continue_prompt=None,
2227 pre=None,iFun=None,theRest=None):
2226 pre=None,iFun=None,theRest=None):
2228 """Handle alias input lines. """
2227 """Handle alias input lines. """
2229
2228
2230 # pre is needed, because it carries the leading whitespace. Otherwise
2229 # pre is needed, because it carries the leading whitespace. Otherwise
2231 # aliases won't work in indented sections.
2230 # aliases won't work in indented sections.
2232 transformed = self.expand_aliases(iFun, theRest)
2231 transformed = self.expand_aliases(iFun, theRest)
2233 line_out = '%s_ip.system(%s)' % (pre, make_quoted_expr( transformed ))
2232 line_out = '%s_ip.system(%s)' % (pre, make_quoted_expr( transformed ))
2234 self.log(line,line_out,continue_prompt)
2233 self.log(line,line_out,continue_prompt)
2235 #print 'line out:',line_out # dbg
2234 #print 'line out:',line_out # dbg
2236 return line_out
2235 return line_out
2237
2236
2238 def handle_shell_escape(self, line, continue_prompt=None,
2237 def handle_shell_escape(self, line, continue_prompt=None,
2239 pre=None,iFun=None,theRest=None):
2238 pre=None,iFun=None,theRest=None):
2240 """Execute the line in a shell, empty return value"""
2239 """Execute the line in a shell, empty return value"""
2241
2240
2242 #print 'line in :', `line` # dbg
2241 #print 'line in :', `line` # dbg
2243 # Example of a special handler. Others follow a similar pattern.
2242 # Example of a special handler. Others follow a similar pattern.
2244 if line.lstrip().startswith('!!'):
2243 if line.lstrip().startswith('!!'):
2245 # rewrite iFun/theRest to properly hold the call to %sx and
2244 # rewrite iFun/theRest to properly hold the call to %sx and
2246 # the actual command to be executed, so handle_magic can work
2245 # the actual command to be executed, so handle_magic can work
2247 # correctly
2246 # correctly
2248 theRest = '%s %s' % (iFun[2:],theRest)
2247 theRest = '%s %s' % (iFun[2:],theRest)
2249 iFun = 'sx'
2248 iFun = 'sx'
2250 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,
2249 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,
2251 line.lstrip()[2:]),
2250 line.lstrip()[2:]),
2252 continue_prompt,pre,iFun,theRest)
2251 continue_prompt,pre,iFun,theRest)
2253 else:
2252 else:
2254 cmd=line.lstrip().lstrip('!')
2253 cmd=line.lstrip().lstrip('!')
2255 line_out = '%s_ip.system(%s)' % (pre,make_quoted_expr(cmd))
2254 line_out = '%s_ip.system(%s)' % (pre,make_quoted_expr(cmd))
2256 # update cache/log and return
2255 # update cache/log and return
2257 self.log(line,line_out,continue_prompt)
2256 self.log(line,line_out,continue_prompt)
2258 return line_out
2257 return line_out
2259
2258
2260 def handle_magic(self, line, continue_prompt=None,
2259 def handle_magic(self, line, continue_prompt=None,
2261 pre=None,iFun=None,theRest=None):
2260 pre=None,iFun=None,theRest=None):
2262 """Execute magic functions."""
2261 """Execute magic functions."""
2263
2262
2264
2263
2265 cmd = '%s_ip.magic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
2264 cmd = '%s_ip.magic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
2266 self.log(line,cmd,continue_prompt)
2265 self.log(line,cmd,continue_prompt)
2267 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
2266 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
2268 return cmd
2267 return cmd
2269
2268
2270 def handle_auto(self, line, continue_prompt=None,
2269 def handle_auto(self, line, continue_prompt=None,
2271 pre=None,iFun=None,theRest=None,obj=None):
2270 pre=None,iFun=None,theRest=None,obj=None):
2272 """Hande lines which can be auto-executed, quoting if requested."""
2271 """Hande lines which can be auto-executed, quoting if requested."""
2273
2272
2274 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2273 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2275
2274
2276 # This should only be active for single-line input!
2275 # This should only be active for single-line input!
2277 if continue_prompt:
2276 if continue_prompt:
2278 self.log(line,line,continue_prompt)
2277 self.log(line,line,continue_prompt)
2279 return line
2278 return line
2280
2279
2281 auto_rewrite = True
2280 auto_rewrite = True
2282
2281
2283 if pre == self.ESC_QUOTE:
2282 if pre == self.ESC_QUOTE:
2284 # Auto-quote splitting on whitespace
2283 # Auto-quote splitting on whitespace
2285 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
2284 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
2286 elif pre == self.ESC_QUOTE2:
2285 elif pre == self.ESC_QUOTE2:
2287 # Auto-quote whole string
2286 # Auto-quote whole string
2288 newcmd = '%s("%s")' % (iFun,theRest)
2287 newcmd = '%s("%s")' % (iFun,theRest)
2289 elif pre == self.ESC_PAREN:
2288 elif pre == self.ESC_PAREN:
2290 newcmd = '%s(%s)' % (iFun,",".join(theRest.split()))
2289 newcmd = '%s(%s)' % (iFun,",".join(theRest.split()))
2291 else:
2290 else:
2292 # Auto-paren.
2291 # Auto-paren.
2293 # We only apply it to argument-less calls if the autocall
2292 # We only apply it to argument-less calls if the autocall
2294 # parameter is set to 2. We only need to check that autocall is <
2293 # parameter is set to 2. We only need to check that autocall is <
2295 # 2, since this function isn't called unless it's at least 1.
2294 # 2, since this function isn't called unless it's at least 1.
2296 if not theRest and (self.rc.autocall < 2):
2295 if not theRest and (self.rc.autocall < 2):
2297 newcmd = '%s %s' % (iFun,theRest)
2296 newcmd = '%s %s' % (iFun,theRest)
2298 auto_rewrite = False
2297 auto_rewrite = False
2299 else:
2298 else:
2300 if theRest.startswith('['):
2299 if theRest.startswith('['):
2301 if hasattr(obj,'__getitem__'):
2300 if hasattr(obj,'__getitem__'):
2302 # Don't autocall in this case: item access for an object
2301 # Don't autocall in this case: item access for an object
2303 # which is BOTH callable and implements __getitem__.
2302 # which is BOTH callable and implements __getitem__.
2304 newcmd = '%s %s' % (iFun,theRest)
2303 newcmd = '%s %s' % (iFun,theRest)
2305 auto_rewrite = False
2304 auto_rewrite = False
2306 else:
2305 else:
2307 # if the object doesn't support [] access, go ahead and
2306 # if the object doesn't support [] access, go ahead and
2308 # autocall
2307 # autocall
2309 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2308 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2310 elif theRest.endswith(';'):
2309 elif theRest.endswith(';'):
2311 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
2310 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
2312 else:
2311 else:
2313 newcmd = '%s(%s)' % (iFun.rstrip(), theRest)
2312 newcmd = '%s(%s)' % (iFun.rstrip(), theRest)
2314
2313
2315 if auto_rewrite:
2314 if auto_rewrite:
2316 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
2315 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
2317 # log what is now valid Python, not the actual user input (without the
2316 # log what is now valid Python, not the actual user input (without the
2318 # final newline)
2317 # final newline)
2319 self.log(line,newcmd,continue_prompt)
2318 self.log(line,newcmd,continue_prompt)
2320 return newcmd
2319 return newcmd
2321
2320
2322 def handle_help(self, line, continue_prompt=None,
2321 def handle_help(self, line, continue_prompt=None,
2323 pre=None,iFun=None,theRest=None):
2322 pre=None,iFun=None,theRest=None):
2324 """Try to get some help for the object.
2323 """Try to get some help for the object.
2325
2324
2326 obj? or ?obj -> basic information.
2325 obj? or ?obj -> basic information.
2327 obj?? or ??obj -> more details.
2326 obj?? or ??obj -> more details.
2328 """
2327 """
2329
2328
2330 # We need to make sure that we don't process lines which would be
2329 # We need to make sure that we don't process lines which would be
2331 # otherwise valid python, such as "x=1 # what?"
2330 # otherwise valid python, such as "x=1 # what?"
2332 try:
2331 try:
2333 codeop.compile_command(line)
2332 codeop.compile_command(line)
2334 except SyntaxError:
2333 except SyntaxError:
2335 # We should only handle as help stuff which is NOT valid syntax
2334 # We should only handle as help stuff which is NOT valid syntax
2336 if line[0]==self.ESC_HELP:
2335 if line[0]==self.ESC_HELP:
2337 line = line[1:]
2336 line = line[1:]
2338 elif line[-1]==self.ESC_HELP:
2337 elif line[-1]==self.ESC_HELP:
2339 line = line[:-1]
2338 line = line[:-1]
2340 self.log(line,'#?'+line,continue_prompt)
2339 self.log(line,'#?'+line,continue_prompt)
2341 if line:
2340 if line:
2342 self.magic_pinfo(line)
2341 self.magic_pinfo(line)
2343 else:
2342 else:
2344 page(self.usage,screen_lines=self.rc.screen_length)
2343 page(self.usage,screen_lines=self.rc.screen_length)
2345 return '' # Empty string is needed here!
2344 return '' # Empty string is needed here!
2346 except:
2345 except:
2347 # Pass any other exceptions through to the normal handler
2346 # Pass any other exceptions through to the normal handler
2348 return self.handle_normal(line,continue_prompt)
2347 return self.handle_normal(line,continue_prompt)
2349 else:
2348 else:
2350 # If the code compiles ok, we should handle it normally
2349 # If the code compiles ok, we should handle it normally
2351 return self.handle_normal(line,continue_prompt)
2350 return self.handle_normal(line,continue_prompt)
2352
2351
2353 def getapi(self):
2352 def getapi(self):
2354 """ Get an IPApi object for this shell instance
2353 """ Get an IPApi object for this shell instance
2355
2354
2356 Getting an IPApi object is always preferable to accessing the shell
2355 Getting an IPApi object is always preferable to accessing the shell
2357 directly, but this holds true especially for extensions.
2356 directly, but this holds true especially for extensions.
2358
2357
2359 It should always be possible to implement an extension with IPApi
2358 It should always be possible to implement an extension with IPApi
2360 alone. If not, contact maintainer to request an addition.
2359 alone. If not, contact maintainer to request an addition.
2361
2360
2362 """
2361 """
2363 return self.api
2362 return self.api
2364
2363
2365 def handle_emacs(self,line,continue_prompt=None,
2364 def handle_emacs(self,line,continue_prompt=None,
2366 pre=None,iFun=None,theRest=None):
2365 pre=None,iFun=None,theRest=None):
2367 """Handle input lines marked by python-mode."""
2366 """Handle input lines marked by python-mode."""
2368
2367
2369 # Currently, nothing is done. Later more functionality can be added
2368 # Currently, nothing is done. Later more functionality can be added
2370 # here if needed.
2369 # here if needed.
2371
2370
2372 # The input cache shouldn't be updated
2371 # The input cache shouldn't be updated
2373
2372
2374 return line
2373 return line
2375
2374
2376 def mktempfile(self,data=None):
2375 def mktempfile(self,data=None):
2377 """Make a new tempfile and return its filename.
2376 """Make a new tempfile and return its filename.
2378
2377
2379 This makes a call to tempfile.mktemp, but it registers the created
2378 This makes a call to tempfile.mktemp, but it registers the created
2380 filename internally so ipython cleans it up at exit time.
2379 filename internally so ipython cleans it up at exit time.
2381
2380
2382 Optional inputs:
2381 Optional inputs:
2383
2382
2384 - data(None): if data is given, it gets written out to the temp file
2383 - data(None): if data is given, it gets written out to the temp file
2385 immediately, and the file is closed again."""
2384 immediately, and the file is closed again."""
2386
2385
2387 filename = tempfile.mktemp('.py','ipython_edit_')
2386 filename = tempfile.mktemp('.py','ipython_edit_')
2388 self.tempfiles.append(filename)
2387 self.tempfiles.append(filename)
2389
2388
2390 if data:
2389 if data:
2391 tmp_file = open(filename,'w')
2390 tmp_file = open(filename,'w')
2392 tmp_file.write(data)
2391 tmp_file.write(data)
2393 tmp_file.close()
2392 tmp_file.close()
2394 return filename
2393 return filename
2395
2394
2396 def write(self,data):
2395 def write(self,data):
2397 """Write a string to the default output"""
2396 """Write a string to the default output"""
2398 Term.cout.write(data)
2397 Term.cout.write(data)
2399
2398
2400 def write_err(self,data):
2399 def write_err(self,data):
2401 """Write a string to the default error output"""
2400 """Write a string to the default error output"""
2402 Term.cerr.write(data)
2401 Term.cerr.write(data)
2403
2402
2404 def exit(self):
2403 def exit(self):
2405 """Handle interactive exit.
2404 """Handle interactive exit.
2406
2405
2407 This method sets the exit_now attribute."""
2406 This method sets the exit_now attribute."""
2408
2407
2409 if self.rc.confirm_exit:
2408 if self.rc.confirm_exit:
2410 if self.ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2409 if self.ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2411 self.exit_now = True
2410 self.exit_now = True
2412 else:
2411 else:
2413 self.exit_now = True
2412 self.exit_now = True
2414
2413
2415 def safe_execfile(self,fname,*where,**kw):
2414 def safe_execfile(self,fname,*where,**kw):
2416 """A safe version of the builtin execfile().
2415 """A safe version of the builtin execfile().
2417
2416
2418 This version will never throw an exception, and knows how to handle
2417 This version will never throw an exception, and knows how to handle
2419 ipython logs as well."""
2418 ipython logs as well."""
2420
2419
2421 def syspath_cleanup():
2420 def syspath_cleanup():
2422 """Internal cleanup routine for sys.path."""
2421 """Internal cleanup routine for sys.path."""
2423 if add_dname:
2422 if add_dname:
2424 try:
2423 try:
2425 sys.path.remove(dname)
2424 sys.path.remove(dname)
2426 except ValueError:
2425 except ValueError:
2427 # For some reason the user has already removed it, ignore.
2426 # For some reason the user has already removed it, ignore.
2428 pass
2427 pass
2429
2428
2430 fname = os.path.expanduser(fname)
2429 fname = os.path.expanduser(fname)
2431
2430
2432 # Find things also in current directory. This is needed to mimic the
2431 # Find things also in current directory. This is needed to mimic the
2433 # behavior of running a script from the system command line, where
2432 # behavior of running a script from the system command line, where
2434 # Python inserts the script's directory into sys.path
2433 # Python inserts the script's directory into sys.path
2435 dname = os.path.dirname(os.path.abspath(fname))
2434 dname = os.path.dirname(os.path.abspath(fname))
2436 add_dname = False
2435 add_dname = False
2437 if dname not in sys.path:
2436 if dname not in sys.path:
2438 sys.path.insert(0,dname)
2437 sys.path.insert(0,dname)
2439 add_dname = True
2438 add_dname = True
2440
2439
2441 try:
2440 try:
2442 xfile = open(fname)
2441 xfile = open(fname)
2443 except:
2442 except:
2444 print >> Term.cerr, \
2443 print >> Term.cerr, \
2445 'Could not open file <%s> for safe execution.' % fname
2444 'Could not open file <%s> for safe execution.' % fname
2446 syspath_cleanup()
2445 syspath_cleanup()
2447 return None
2446 return None
2448
2447
2449 kw.setdefault('islog',0)
2448 kw.setdefault('islog',0)
2450 kw.setdefault('quiet',1)
2449 kw.setdefault('quiet',1)
2451 kw.setdefault('exit_ignore',0)
2450 kw.setdefault('exit_ignore',0)
2452 first = xfile.readline()
2451 first = xfile.readline()
2453 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2452 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2454 xfile.close()
2453 xfile.close()
2455 # line by line execution
2454 # line by line execution
2456 if first.startswith(loghead) or kw['islog']:
2455 if first.startswith(loghead) or kw['islog']:
2457 print 'Loading log file <%s> one line at a time...' % fname
2456 print 'Loading log file <%s> one line at a time...' % fname
2458 if kw['quiet']:
2457 if kw['quiet']:
2459 stdout_save = sys.stdout
2458 stdout_save = sys.stdout
2460 sys.stdout = StringIO.StringIO()
2459 sys.stdout = StringIO.StringIO()
2461 try:
2460 try:
2462 globs,locs = where[0:2]
2461 globs,locs = where[0:2]
2463 except:
2462 except:
2464 try:
2463 try:
2465 globs = locs = where[0]
2464 globs = locs = where[0]
2466 except:
2465 except:
2467 globs = locs = globals()
2466 globs = locs = globals()
2468 badblocks = []
2467 badblocks = []
2469
2468
2470 # we also need to identify indented blocks of code when replaying
2469 # we also need to identify indented blocks of code when replaying
2471 # logs and put them together before passing them to an exec
2470 # logs and put them together before passing them to an exec
2472 # statement. This takes a bit of regexp and look-ahead work in the
2471 # statement. This takes a bit of regexp and look-ahead work in the
2473 # file. It's easiest if we swallow the whole thing in memory
2472 # file. It's easiest if we swallow the whole thing in memory
2474 # first, and manually walk through the lines list moving the
2473 # first, and manually walk through the lines list moving the
2475 # counter ourselves.
2474 # counter ourselves.
2476 indent_re = re.compile('\s+\S')
2475 indent_re = re.compile('\s+\S')
2477 xfile = open(fname)
2476 xfile = open(fname)
2478 filelines = xfile.readlines()
2477 filelines = xfile.readlines()
2479 xfile.close()
2478 xfile.close()
2480 nlines = len(filelines)
2479 nlines = len(filelines)
2481 lnum = 0
2480 lnum = 0
2482 while lnum < nlines:
2481 while lnum < nlines:
2483 line = filelines[lnum]
2482 line = filelines[lnum]
2484 lnum += 1
2483 lnum += 1
2485 # don't re-insert logger status info into cache
2484 # don't re-insert logger status info into cache
2486 if line.startswith('#log#'):
2485 if line.startswith('#log#'):
2487 continue
2486 continue
2488 else:
2487 else:
2489 # build a block of code (maybe a single line) for execution
2488 # build a block of code (maybe a single line) for execution
2490 block = line
2489 block = line
2491 try:
2490 try:
2492 next = filelines[lnum] # lnum has already incremented
2491 next = filelines[lnum] # lnum has already incremented
2493 except:
2492 except:
2494 next = None
2493 next = None
2495 while next and indent_re.match(next):
2494 while next and indent_re.match(next):
2496 block += next
2495 block += next
2497 lnum += 1
2496 lnum += 1
2498 try:
2497 try:
2499 next = filelines[lnum]
2498 next = filelines[lnum]
2500 except:
2499 except:
2501 next = None
2500 next = None
2502 # now execute the block of one or more lines
2501 # now execute the block of one or more lines
2503 try:
2502 try:
2504 exec block in globs,locs
2503 exec block in globs,locs
2505 except SystemExit:
2504 except SystemExit:
2506 pass
2505 pass
2507 except:
2506 except:
2508 badblocks.append(block.rstrip())
2507 badblocks.append(block.rstrip())
2509 if kw['quiet']: # restore stdout
2508 if kw['quiet']: # restore stdout
2510 sys.stdout.close()
2509 sys.stdout.close()
2511 sys.stdout = stdout_save
2510 sys.stdout = stdout_save
2512 print 'Finished replaying log file <%s>' % fname
2511 print 'Finished replaying log file <%s>' % fname
2513 if badblocks:
2512 if badblocks:
2514 print >> sys.stderr, ('\nThe following lines/blocks in file '
2513 print >> sys.stderr, ('\nThe following lines/blocks in file '
2515 '<%s> reported errors:' % fname)
2514 '<%s> reported errors:' % fname)
2516
2515
2517 for badline in badblocks:
2516 for badline in badblocks:
2518 print >> sys.stderr, badline
2517 print >> sys.stderr, badline
2519 else: # regular file execution
2518 else: # regular file execution
2520 try:
2519 try:
2521 execfile(fname,*where)
2520 execfile(fname,*where)
2522 except SyntaxError:
2521 except SyntaxError:
2523 self.showsyntaxerror()
2522 self.showsyntaxerror()
2524 warn('Failure executing file: <%s>' % fname)
2523 warn('Failure executing file: <%s>' % fname)
2525 except SystemExit,status:
2524 except SystemExit,status:
2526 if not kw['exit_ignore']:
2525 if not kw['exit_ignore']:
2527 self.showtraceback()
2526 self.showtraceback()
2528 warn('Failure executing file: <%s>' % fname)
2527 warn('Failure executing file: <%s>' % fname)
2529 except:
2528 except:
2530 self.showtraceback()
2529 self.showtraceback()
2531 warn('Failure executing file: <%s>' % fname)
2530 warn('Failure executing file: <%s>' % fname)
2532
2531
2533 syspath_cleanup()
2532 syspath_cleanup()
2534
2533
2535 #************************* end of file <iplib.py> *****************************
2534 #************************* end of file <iplib.py> *****************************
@@ -1,6043 +1,6048 b''
1 2006-12-5 Ville Vainio <vivainio@gmail.com>
2
3 * Magic.py, iplib.py, completer.py: Apply R. Bernstein's
4 pydb patch 4 (rm debug printing, py 2.5 checking)
5
1 2006-11-30 Walter Doerwald <walter@livinglogic.de>
6 2006-11-30 Walter Doerwald <walter@livinglogic.de>
2 * IPython/Extensions/ibrowse.py: Add two new commands to ibrowse:
7 * IPython/Extensions/ibrowse.py: Add two new commands to ibrowse:
3 "refresh" (mapped to "r") refreshes the screen by restarting the iterator.
8 "refresh" (mapped to "r") refreshes the screen by restarting the iterator.
4 "refreshfind" (mapped to "R") does the same but tries to go back to the same
9 "refreshfind" (mapped to "R") does the same but tries to go back to the same
5 object the cursor was on before the refresh. The command "markrange" is
10 object the cursor was on before the refresh. The command "markrange" is
6 mapped to "%" now.
11 mapped to "%" now.
7 * IPython/Extensions/ibrowse.py: Make igrpentry and ipwdentry comparable.
12 * IPython/Extensions/ibrowse.py: Make igrpentry and ipwdentry comparable.
8
13
9 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu>
14 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu>
10
15
11 * IPython/Magic.py (magic_debug): new %debug magic to activate the
16 * IPython/Magic.py (magic_debug): new %debug magic to activate the
12 interactive debugger on the last traceback, without having to call
17 interactive debugger on the last traceback, without having to call
13 %pdb and rerun your code. Made minor changes in various modules,
18 %pdb and rerun your code. Made minor changes in various modules,
14 should automatically recognize pydb if available.
19 should automatically recognize pydb if available.
15
20
16 2006-11-28 Ville Vainio <vivainio@gmail.com>
21 2006-11-28 Ville Vainio <vivainio@gmail.com>
17
22
18 * completer.py: If the text start with !, show file completions
23 * completer.py: If the text start with !, show file completions
19 properly. This helps when trying to complete command name
24 properly. This helps when trying to complete command name
20 for shell escapes.
25 for shell escapes.
21
26
22 2006-11-27 Ville Vainio <vivainio@gmail.com>
27 2006-11-27 Ville Vainio <vivainio@gmail.com>
23
28
24 * ipy_stock_completers.py: bzr completer submitted by Stefan van
29 * ipy_stock_completers.py: bzr completer submitted by Stefan van
25 der Walt. Clean up svn and hg completers by using a common
30 der Walt. Clean up svn and hg completers by using a common
26 vcs_completer.
31 vcs_completer.
27
32
28 2006-11-26 Ville Vainio <vivainio@gmail.com>
33 2006-11-26 Ville Vainio <vivainio@gmail.com>
29
34
30 * Remove ipconfig and %config; you should use _ip.options structure
35 * Remove ipconfig and %config; you should use _ip.options structure
31 directly instead!
36 directly instead!
32
37
33 * genutils.py: add wrap_deprecated function for deprecating callables
38 * genutils.py: add wrap_deprecated function for deprecating callables
34
39
35 * iplib.py: deprecate ipmagic, ipsystem, ipalias. Use _ip.magic and
40 * iplib.py: deprecate ipmagic, ipsystem, ipalias. Use _ip.magic and
36 _ip.system instead. ipalias is redundant.
41 _ip.system instead. ipalias is redundant.
37
42
38 * Magic.py: %rehashdir no longer aliases 'cmdname' to 'cmdname.exe' on
43 * Magic.py: %rehashdir no longer aliases 'cmdname' to 'cmdname.exe' on
39 win32, but just 'cmdname'. Other extensions (non-'exe') are still made
44 win32, but just 'cmdname'. Other extensions (non-'exe') are still made
40 explicit.
45 explicit.
41
46
42 * ipy_stock_completers.py: 'hg' (mercurial VCS) now has a custom
47 * ipy_stock_completers.py: 'hg' (mercurial VCS) now has a custom
43 completer. Try it by entering 'hg ' and pressing tab.
48 completer. Try it by entering 'hg ' and pressing tab.
44
49
45 * macro.py: Give Macro a useful __repr__ method
50 * macro.py: Give Macro a useful __repr__ method
46
51
47 * Magic.py: %whos abbreviates the typename of Macro for brevity.
52 * Magic.py: %whos abbreviates the typename of Macro for brevity.
48
53
49 2006-11-24 Walter Doerwald <walter@livinglogic.de>
54 2006-11-24 Walter Doerwald <walter@livinglogic.de>
50 * IPython/Extensions/astyle.py: Do a relative import of ipipe, so that
55 * IPython/Extensions/astyle.py: Do a relative import of ipipe, so that
51 we don't get a duplicate ipipe module, where registration of the xrepr
56 we don't get a duplicate ipipe module, where registration of the xrepr
52 implementation for Text is useless.
57 implementation for Text is useless.
53
58
54 * IPython/Extensions/ipipe.py: Fix __xrepr__() implementation for ils.
59 * IPython/Extensions/ipipe.py: Fix __xrepr__() implementation for ils.
55
60
56 * IPython/Extensions/ibrowse.py: Fix keymapping for the enter command.
61 * IPython/Extensions/ibrowse.py: Fix keymapping for the enter command.
57
62
58 2006-11-24 Ville Vainio <vivainio@gmail.com>
63 2006-11-24 Ville Vainio <vivainio@gmail.com>
59
64
60 * Magic.py, manual_base.lyx: Kirill Smelkov patch:
65 * Magic.py, manual_base.lyx: Kirill Smelkov patch:
61 try to use "cProfile" instead of the slower pure python
66 try to use "cProfile" instead of the slower pure python
62 "profile"
67 "profile"
63
68
64 2006-11-23 Ville Vainio <vivainio@gmail.com>
69 2006-11-23 Ville Vainio <vivainio@gmail.com>
65
70
66 * manual_base.lyx: Kirill Smelkov patch: Fix wrong
71 * manual_base.lyx: Kirill Smelkov patch: Fix wrong
67 Qt+IPython+Designer link in documentation.
72 Qt+IPython+Designer link in documentation.
68
73
69 * Extensions/ipy_pydb.py: R. Bernstein's patch for passing
74 * Extensions/ipy_pydb.py: R. Bernstein's patch for passing
70 correct Pdb object to %pydb.
75 correct Pdb object to %pydb.
71
76
72
77
73 2006-11-22 Walter Doerwald <walter@livinglogic.de>
78 2006-11-22 Walter Doerwald <walter@livinglogic.de>
74 * IPython/Extensions/astyle.py: Text needs it's own implemenation of the
79 * IPython/Extensions/astyle.py: Text needs it's own implemenation of the
75 generic xrepr(), otherwise the list implementation would kick in.
80 generic xrepr(), otherwise the list implementation would kick in.
76
81
77 2006-11-21 Ville Vainio <vivainio@gmail.com>
82 2006-11-21 Ville Vainio <vivainio@gmail.com>
78
83
79 * upgrade_dir.py: Now actually overwrites a nonmodified user file
84 * upgrade_dir.py: Now actually overwrites a nonmodified user file
80 with one from UserConfig.
85 with one from UserConfig.
81
86
82 * ipy_profile_sh.py: Add dummy "depth" to var_expand lambda,
87 * ipy_profile_sh.py: Add dummy "depth" to var_expand lambda,
83 it was missing which broke the sh profile.
88 it was missing which broke the sh profile.
84
89
85 * completer.py: file completer now uses explicit '/' instead
90 * completer.py: file completer now uses explicit '/' instead
86 of os.path.join, expansion of 'foo' was broken on win32
91 of os.path.join, expansion of 'foo' was broken on win32
87 if there was one directory with name 'foobar'.
92 if there was one directory with name 'foobar'.
88
93
89 * A bunch of patches from Kirill Smelkov:
94 * A bunch of patches from Kirill Smelkov:
90
95
91 * [patch 9/9] doc: point bug-tracker URL to IPythons trac-tickets.
96 * [patch 9/9] doc: point bug-tracker URL to IPythons trac-tickets.
92
97
93 * [patch 7/9] Implement %page -r (page in raw mode) -
98 * [patch 7/9] Implement %page -r (page in raw mode) -
94
99
95 * [patch 5/9] ScientificPython webpage has moved
100 * [patch 5/9] ScientificPython webpage has moved
96
101
97 * [patch 4/9] The manual mentions %ds, should be %dhist
102 * [patch 4/9] The manual mentions %ds, should be %dhist
98
103
99 * [patch 3/9] Kill old bits from %prun doc.
104 * [patch 3/9] Kill old bits from %prun doc.
100
105
101 * [patch 1/9] Fix typos here and there.
106 * [patch 1/9] Fix typos here and there.
102
107
103 2006-11-08 Ville Vainio <vivainio@gmail.com>
108 2006-11-08 Ville Vainio <vivainio@gmail.com>
104
109
105 * completer.py (attr_matches): catch all exceptions raised
110 * completer.py (attr_matches): catch all exceptions raised
106 by eval of expr with dots.
111 by eval of expr with dots.
107
112
108 2006-11-07 Fernando Perez <Fernando.Perez@colorado.edu>
113 2006-11-07 Fernando Perez <Fernando.Perez@colorado.edu>
109
114
110 * IPython/iplib.py (runsource): Prepend an 'if 1:' to the user
115 * IPython/iplib.py (runsource): Prepend an 'if 1:' to the user
111 input if it starts with whitespace. This allows you to paste
116 input if it starts with whitespace. This allows you to paste
112 indented input from any editor without manually having to type in
117 indented input from any editor without manually having to type in
113 the 'if 1:', which is convenient when working interactively.
118 the 'if 1:', which is convenient when working interactively.
114 Slightly modifed version of a patch by Bo Peng
119 Slightly modifed version of a patch by Bo Peng
115 <bpeng-AT-rice.edu>.
120 <bpeng-AT-rice.edu>.
116
121
117 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
122 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
118
123
119 * IPython/irunner.py (main): modified irunner so it automatically
124 * IPython/irunner.py (main): modified irunner so it automatically
120 recognizes the right runner to use based on the extension (.py for
125 recognizes the right runner to use based on the extension (.py for
121 python, .ipy for ipython and .sage for sage).
126 python, .ipy for ipython and .sage for sage).
122
127
123 * IPython/iplib.py (InteractiveShell.ipconfig): new builtin, also
128 * IPython/iplib.py (InteractiveShell.ipconfig): new builtin, also
124 visible in ipapi as ip.config(), to programatically control the
129 visible in ipapi as ip.config(), to programatically control the
125 internal rc object. There's an accompanying %config magic for
130 internal rc object. There's an accompanying %config magic for
126 interactive use, which has been enhanced to match the
131 interactive use, which has been enhanced to match the
127 funtionality in ipconfig.
132 funtionality in ipconfig.
128
133
129 * IPython/Magic.py (magic_system_verbose): Change %system_verbose
134 * IPython/Magic.py (magic_system_verbose): Change %system_verbose
130 so it's not just a toggle, it now takes an argument. Add support
135 so it's not just a toggle, it now takes an argument. Add support
131 for a customizable header when making system calls, as the new
136 for a customizable header when making system calls, as the new
132 system_header variable in the ipythonrc file.
137 system_header variable in the ipythonrc file.
133
138
134 2006-11-03 Walter Doerwald <walter@livinglogic.de>
139 2006-11-03 Walter Doerwald <walter@livinglogic.de>
135
140
136 * IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now
141 * IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now
137 generic functions (using Philip J. Eby's simplegeneric package).
142 generic functions (using Philip J. Eby's simplegeneric package).
138 This makes it possible to customize the display of third-party classes
143 This makes it possible to customize the display of third-party classes
139 without having to monkeypatch them. xiter() no longer supports a mode
144 without having to monkeypatch them. xiter() no longer supports a mode
140 argument and the XMode class has been removed. The same functionality can
145 argument and the XMode class has been removed. The same functionality can
141 be implemented via IterAttributeDescriptor and IterMethodDescriptor.
146 be implemented via IterAttributeDescriptor and IterMethodDescriptor.
142 One consequence of the switch to generic functions is that xrepr() and
147 One consequence of the switch to generic functions is that xrepr() and
143 xattrs() implementation must define the default value for the mode
148 xattrs() implementation must define the default value for the mode
144 argument themselves and xattrs() implementations must return real
149 argument themselves and xattrs() implementations must return real
145 descriptors.
150 descriptors.
146
151
147 * IPython/external: This new subpackage will contain all third-party
152 * IPython/external: This new subpackage will contain all third-party
148 packages that are bundled with IPython. (The first one is simplegeneric).
153 packages that are bundled with IPython. (The first one is simplegeneric).
149
154
150 * IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent
155 * IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent
151 directory which as been dropped in r1703.
156 directory which as been dropped in r1703.
152
157
153 * IPython/Extensions/ipipe.py (iless): Fixed.
158 * IPython/Extensions/ipipe.py (iless): Fixed.
154
159
155 * IPython/Extensions/ibrowse: Fixed sorting under Python 2.3.
160 * IPython/Extensions/ibrowse: Fixed sorting under Python 2.3.
156
161
157 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
162 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
158
163
159 * IPython/iplib.py (InteractiveShell.var_expand): fix stack
164 * IPython/iplib.py (InteractiveShell.var_expand): fix stack
160 handling in variable expansion so that shells and magics recognize
165 handling in variable expansion so that shells and magics recognize
161 function local scopes correctly. Bug reported by Brian.
166 function local scopes correctly. Bug reported by Brian.
162
167
163 * scripts/ipython: remove the very first entry in sys.path which
168 * scripts/ipython: remove the very first entry in sys.path which
164 Python auto-inserts for scripts, so that sys.path under IPython is
169 Python auto-inserts for scripts, so that sys.path under IPython is
165 as similar as possible to that under plain Python.
170 as similar as possible to that under plain Python.
166
171
167 * IPython/completer.py (IPCompleter.file_matches): Fix
172 * IPython/completer.py (IPCompleter.file_matches): Fix
168 tab-completion so that quotes are not closed unless the completion
173 tab-completion so that quotes are not closed unless the completion
169 is unambiguous. After a request by Stefan. Minor cleanups in
174 is unambiguous. After a request by Stefan. Minor cleanups in
170 ipy_stock_completers.
175 ipy_stock_completers.
171
176
172 2006-11-02 Ville Vainio <vivainio@gmail.com>
177 2006-11-02 Ville Vainio <vivainio@gmail.com>
173
178
174 * ipy_stock_completers.py: Add %run and %cd completers.
179 * ipy_stock_completers.py: Add %run and %cd completers.
175
180
176 * completer.py: Try running custom completer for both
181 * completer.py: Try running custom completer for both
177 "foo" and "%foo" if the command is just "foo". Ignore case
182 "foo" and "%foo" if the command is just "foo". Ignore case
178 when filtering possible completions.
183 when filtering possible completions.
179
184
180 * UserConfig/ipy_user_conf.py: install stock completers as default
185 * UserConfig/ipy_user_conf.py: install stock completers as default
181
186
182 * iplib.py (history_saving_wrapper), debugger(), ipy_pydb.py:
187 * iplib.py (history_saving_wrapper), debugger(), ipy_pydb.py:
183 simplified readline history save / restore through a wrapper
188 simplified readline history save / restore through a wrapper
184 function
189 function
185
190
186
191
187 2006-10-31 Ville Vainio <vivainio@gmail.com>
192 2006-10-31 Ville Vainio <vivainio@gmail.com>
188
193
189 * strdispatch.py, completer.py, ipy_stock_completers.py:
194 * strdispatch.py, completer.py, ipy_stock_completers.py:
190 Allow str_key ("command") in completer hooks. Implement
195 Allow str_key ("command") in completer hooks. Implement
191 trivial completer for 'import' (stdlib modules only). Rename
196 trivial completer for 'import' (stdlib modules only). Rename
192 ipy_linux_package_managers.py to ipy_stock_completers.py.
197 ipy_linux_package_managers.py to ipy_stock_completers.py.
193 SVN completer.
198 SVN completer.
194
199
195 * Extensions/ledit.py: %magic line editor for easily and
200 * Extensions/ledit.py: %magic line editor for easily and
196 incrementally manipulating lists of strings. The magic command
201 incrementally manipulating lists of strings. The magic command
197 name is %led.
202 name is %led.
198
203
199 2006-10-30 Ville Vainio <vivainio@gmail.com>
204 2006-10-30 Ville Vainio <vivainio@gmail.com>
200
205
201 * Debugger.py, iplib.py (debugger()): Add last set of Rocky
206 * Debugger.py, iplib.py (debugger()): Add last set of Rocky
202 Bernsteins's patches for pydb integration.
207 Bernsteins's patches for pydb integration.
203 http://bashdb.sourceforge.net/pydb/
208 http://bashdb.sourceforge.net/pydb/
204
209
205 * strdispatch.py, iplib.py, completer.py, IPython/__init__.py,
210 * strdispatch.py, iplib.py, completer.py, IPython/__init__.py,
206 Extensions/ipy_linux_package_managers.py, hooks.py: Implement
211 Extensions/ipy_linux_package_managers.py, hooks.py: Implement
207 custom completer hook to allow the users to implement their own
212 custom completer hook to allow the users to implement their own
208 completers. See ipy_linux_package_managers.py for example. The
213 completers. See ipy_linux_package_managers.py for example. The
209 hook name is 'complete_command'.
214 hook name is 'complete_command'.
210
215
211 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
216 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
212
217
213 * IPython/UserConfig/ipythonrc-scipy: minor cleanups to remove old
218 * IPython/UserConfig/ipythonrc-scipy: minor cleanups to remove old
214 Numeric leftovers.
219 Numeric leftovers.
215
220
216 * ipython.el (py-execute-region): apply Stefan's patch to fix
221 * ipython.el (py-execute-region): apply Stefan's patch to fix
217 garbled results if the python shell hasn't been previously started.
222 garbled results if the python shell hasn't been previously started.
218
223
219 * IPython/genutils.py (arg_split): moved to genutils, since it's a
224 * IPython/genutils.py (arg_split): moved to genutils, since it's a
220 pretty generic function and useful for other things.
225 pretty generic function and useful for other things.
221
226
222 * IPython/OInspect.py (getsource): Add customizable source
227 * IPython/OInspect.py (getsource): Add customizable source
223 extractor. After a request/patch form W. Stein (SAGE).
228 extractor. After a request/patch form W. Stein (SAGE).
224
229
225 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
230 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
226 window size to a more reasonable value from what pexpect does,
231 window size to a more reasonable value from what pexpect does,
227 since their choice causes wrapping bugs with long input lines.
232 since their choice causes wrapping bugs with long input lines.
228
233
229 2006-10-28 Ville Vainio <vivainio@gmail.com>
234 2006-10-28 Ville Vainio <vivainio@gmail.com>
230
235
231 * Magic.py (%run): Save and restore the readline history from
236 * Magic.py (%run): Save and restore the readline history from
232 file around %run commands to prevent side effects from
237 file around %run commands to prevent side effects from
233 %runned programs that might use readline (e.g. pydb).
238 %runned programs that might use readline (e.g. pydb).
234
239
235 * extensions/ipy_pydb.py: Adds %pydb magic when imported, for
240 * extensions/ipy_pydb.py: Adds %pydb magic when imported, for
236 invoking the pydb enhanced debugger.
241 invoking the pydb enhanced debugger.
237
242
238 2006-10-23 Walter Doerwald <walter@livinglogic.de>
243 2006-10-23 Walter Doerwald <walter@livinglogic.de>
239
244
240 * IPython/Extensions/ipipe.py (ifile): Remove all methods that
245 * IPython/Extensions/ipipe.py (ifile): Remove all methods that
241 call the base class method and propagate the return value to
246 call the base class method and propagate the return value to
242 ifile. This is now done by path itself.
247 ifile. This is now done by path itself.
243
248
244 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
249 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
245
250
246 * IPython/ipapi.py (IPApi.__init__): Added new entry to public
251 * IPython/ipapi.py (IPApi.__init__): Added new entry to public
247 api: set_crash_handler(), to expose the ability to change the
252 api: set_crash_handler(), to expose the ability to change the
248 internal crash handler.
253 internal crash handler.
249
254
250 * IPython/CrashHandler.py (CrashHandler.__init__): abstract out
255 * IPython/CrashHandler.py (CrashHandler.__init__): abstract out
251 the various parameters of the crash handler so that apps using
256 the various parameters of the crash handler so that apps using
252 IPython as their engine can customize crash handling. Ipmlemented
257 IPython as their engine can customize crash handling. Ipmlemented
253 at the request of SAGE.
258 at the request of SAGE.
254
259
255 2006-10-14 Ville Vainio <vivainio@gmail.com>
260 2006-10-14 Ville Vainio <vivainio@gmail.com>
256
261
257 * Magic.py, ipython.el: applied first "safe" part of Rocky
262 * Magic.py, ipython.el: applied first "safe" part of Rocky
258 Bernstein's patch set for pydb integration.
263 Bernstein's patch set for pydb integration.
259
264
260 * Magic.py (%unalias, %alias): %store'd aliases can now be
265 * Magic.py (%unalias, %alias): %store'd aliases can now be
261 removed with '%unalias'. %alias w/o args now shows most
266 removed with '%unalias'. %alias w/o args now shows most
262 interesting (stored / manually defined) aliases last
267 interesting (stored / manually defined) aliases last
263 where they catch the eye w/o scrolling.
268 where they catch the eye w/o scrolling.
264
269
265 * Magic.py (%rehashx), ext_rehashdir.py: files with
270 * Magic.py (%rehashx), ext_rehashdir.py: files with
266 'py' extension are always considered executable, even
271 'py' extension are always considered executable, even
267 when not in PATHEXT environment variable.
272 when not in PATHEXT environment variable.
268
273
269 2006-10-12 Ville Vainio <vivainio@gmail.com>
274 2006-10-12 Ville Vainio <vivainio@gmail.com>
270
275
271 * jobctrl.py: Add new "jobctrl" extension for spawning background
276 * jobctrl.py: Add new "jobctrl" extension for spawning background
272 processes with "&find /". 'import jobctrl' to try it out. Requires
277 processes with "&find /". 'import jobctrl' to try it out. Requires
273 'subprocess' module, standard in python 2.4+.
278 'subprocess' module, standard in python 2.4+.
274
279
275 * iplib.py (expand_aliases, handle_alias): Aliases expand transitively,
280 * iplib.py (expand_aliases, handle_alias): Aliases expand transitively,
276 so if foo -> bar and bar -> baz, then foo -> baz.
281 so if foo -> bar and bar -> baz, then foo -> baz.
277
282
278 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
283 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
279
284
280 * IPython/Magic.py (Magic.parse_options): add a new posix option
285 * IPython/Magic.py (Magic.parse_options): add a new posix option
281 to allow parsing of input args in magics that doesn't strip quotes
286 to allow parsing of input args in magics that doesn't strip quotes
282 (if posix=False). This also closes %timeit bug reported by
287 (if posix=False). This also closes %timeit bug reported by
283 Stefan.
288 Stefan.
284
289
285 2006-10-03 Ville Vainio <vivainio@gmail.com>
290 2006-10-03 Ville Vainio <vivainio@gmail.com>
286
291
287 * iplib.py (raw_input, interact): Return ValueError catching for
292 * iplib.py (raw_input, interact): Return ValueError catching for
288 raw_input. Fixes infinite loop for sys.stdin.close() or
293 raw_input. Fixes infinite loop for sys.stdin.close() or
289 sys.stdout.close().
294 sys.stdout.close().
290
295
291 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
296 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
292
297
293 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
298 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
294 to help in handling doctests. irunner is now pretty useful for
299 to help in handling doctests. irunner is now pretty useful for
295 running standalone scripts and simulate a full interactive session
300 running standalone scripts and simulate a full interactive session
296 in a format that can be then pasted as a doctest.
301 in a format that can be then pasted as a doctest.
297
302
298 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
303 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
299 on top of the default (useless) ones. This also fixes the nasty
304 on top of the default (useless) ones. This also fixes the nasty
300 way in which 2.5's Quitter() exits (reverted [1785]).
305 way in which 2.5's Quitter() exits (reverted [1785]).
301
306
302 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
307 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
303 2.5.
308 2.5.
304
309
305 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
310 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
306 color scheme is updated as well when color scheme is changed
311 color scheme is updated as well when color scheme is changed
307 interactively.
312 interactively.
308
313
309 2006-09-27 Ville Vainio <vivainio@gmail.com>
314 2006-09-27 Ville Vainio <vivainio@gmail.com>
310
315
311 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
316 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
312 infinite loop and just exit. It's a hack, but will do for a while.
317 infinite loop and just exit. It's a hack, but will do for a while.
313
318
314 2006-08-25 Walter Doerwald <walter@livinglogic.de>
319 2006-08-25 Walter Doerwald <walter@livinglogic.de>
315
320
316 * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to
321 * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to
317 the constructor, this makes it possible to get a list of only directories
322 the constructor, this makes it possible to get a list of only directories
318 or only files.
323 or only files.
319
324
320 2006-08-12 Ville Vainio <vivainio@gmail.com>
325 2006-08-12 Ville Vainio <vivainio@gmail.com>
321
326
322 * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,
327 * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,
323 they broke unittest
328 they broke unittest
324
329
325 2006-08-11 Ville Vainio <vivainio@gmail.com>
330 2006-08-11 Ville Vainio <vivainio@gmail.com>
326
331
327 * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch
332 * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch
328 by resolving issue properly, i.e. by inheriting FakeModule
333 by resolving issue properly, i.e. by inheriting FakeModule
329 from types.ModuleType. Pickling ipython interactive data
334 from types.ModuleType. Pickling ipython interactive data
330 should still work as usual (testing appreciated).
335 should still work as usual (testing appreciated).
331
336
332 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
337 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
333
338
334 * IPython/OInspect.py: monkeypatch inspect from the stdlib if
339 * IPython/OInspect.py: monkeypatch inspect from the stdlib if
335 running under python 2.3 with code from 2.4 to fix a bug with
340 running under python 2.3 with code from 2.4 to fix a bug with
336 help(). Reported by the Debian maintainers, Norbert Tretkowski
341 help(). Reported by the Debian maintainers, Norbert Tretkowski
337 <norbert-AT-tretkowski.de> and Alexandre Fayolle
342 <norbert-AT-tretkowski.de> and Alexandre Fayolle
338 <afayolle-AT-debian.org>.
343 <afayolle-AT-debian.org>.
339
344
340 2006-08-04 Walter Doerwald <walter@livinglogic.de>
345 2006-08-04 Walter Doerwald <walter@livinglogic.de>
341
346
342 * IPython/Extensions/ibrowse.py: Fixed the help message in the footer
347 * IPython/Extensions/ibrowse.py: Fixed the help message in the footer
343 (which was displaying "quit" twice).
348 (which was displaying "quit" twice).
344
349
345 2006-07-28 Walter Doerwald <walter@livinglogic.de>
350 2006-07-28 Walter Doerwald <walter@livinglogic.de>
346
351
347 * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using
352 * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using
348 the mode argument).
353 the mode argument).
349
354
350 2006-07-27 Walter Doerwald <walter@livinglogic.de>
355 2006-07-27 Walter Doerwald <walter@livinglogic.de>
351
356
352 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
357 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
353 not running under IPython.
358 not running under IPython.
354
359
355 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
360 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
356 and make it iterable (iterating over the attribute itself). Add two new
361 and make it iterable (iterating over the attribute itself). Add two new
357 magic strings for __xattrs__(): If the string starts with "-", the attribute
362 magic strings for __xattrs__(): If the string starts with "-", the attribute
358 will not be displayed in ibrowse's detail view (but it can still be
363 will not be displayed in ibrowse's detail view (but it can still be
359 iterated over). This makes it possible to add attributes that are large
364 iterated over). This makes it possible to add attributes that are large
360 lists or generator methods to the detail view. Replace magic attribute names
365 lists or generator methods to the detail view. Replace magic attribute names
361 and _attrname() and _getattr() with "descriptors": For each type of magic
366 and _attrname() and _getattr() with "descriptors": For each type of magic
362 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
367 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
363 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
368 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
364 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
369 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
365 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
370 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
366 are still supported.
371 are still supported.
367
372
368 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
373 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
369 fails in ibrowse.fetch(), the exception object is added as the last item
374 fails in ibrowse.fetch(), the exception object is added as the last item
370 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
375 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
371 a generator throws an exception midway through execution.
376 a generator throws an exception midway through execution.
372
377
373 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
378 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
374 encoding into methods.
379 encoding into methods.
375
380
376 2006-07-26 Ville Vainio <vivainio@gmail.com>
381 2006-07-26 Ville Vainio <vivainio@gmail.com>
377
382
378 * iplib.py: history now stores multiline input as single
383 * iplib.py: history now stores multiline input as single
379 history entries. Patch by Jorgen Cederlof.
384 history entries. Patch by Jorgen Cederlof.
380
385
381 2006-07-18 Walter Doerwald <walter@livinglogic.de>
386 2006-07-18 Walter Doerwald <walter@livinglogic.de>
382
387
383 * IPython/Extensions/ibrowse.py: Make cursor visible over
388 * IPython/Extensions/ibrowse.py: Make cursor visible over
384 non existing attributes.
389 non existing attributes.
385
390
386 2006-07-14 Walter Doerwald <walter@livinglogic.de>
391 2006-07-14 Walter Doerwald <walter@livinglogic.de>
387
392
388 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
393 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
389 error output of the running command doesn't mess up the screen.
394 error output of the running command doesn't mess up the screen.
390
395
391 2006-07-13 Walter Doerwald <walter@livinglogic.de>
396 2006-07-13 Walter Doerwald <walter@livinglogic.de>
392
397
393 * IPython/Extensions/ipipe.py (isort): Make isort usable without
398 * IPython/Extensions/ipipe.py (isort): Make isort usable without
394 argument. This sorts the items themselves.
399 argument. This sorts the items themselves.
395
400
396 2006-07-12 Walter Doerwald <walter@livinglogic.de>
401 2006-07-12 Walter Doerwald <walter@livinglogic.de>
397
402
398 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
403 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
399 Compile expression strings into code objects. This should speed
404 Compile expression strings into code objects. This should speed
400 up ifilter and friends somewhat.
405 up ifilter and friends somewhat.
401
406
402 2006-07-08 Ville Vainio <vivainio@gmail.com>
407 2006-07-08 Ville Vainio <vivainio@gmail.com>
403
408
404 * Magic.py: %cpaste now strips > from the beginning of lines
409 * Magic.py: %cpaste now strips > from the beginning of lines
405 to ease pasting quoted code from emails. Contributed by
410 to ease pasting quoted code from emails. Contributed by
406 Stefan van der Walt.
411 Stefan van der Walt.
407
412
408 2006-06-29 Ville Vainio <vivainio@gmail.com>
413 2006-06-29 Ville Vainio <vivainio@gmail.com>
409
414
410 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
415 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
411 mode, patch contributed by Darren Dale. NEEDS TESTING!
416 mode, patch contributed by Darren Dale. NEEDS TESTING!
412
417
413 2006-06-28 Walter Doerwald <walter@livinglogic.de>
418 2006-06-28 Walter Doerwald <walter@livinglogic.de>
414
419
415 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
420 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
416 a blue background. Fix fetching new display rows when the browser
421 a blue background. Fix fetching new display rows when the browser
417 scrolls more than a screenful (e.g. by using the goto command).
422 scrolls more than a screenful (e.g. by using the goto command).
418
423
419 2006-06-27 Ville Vainio <vivainio@gmail.com>
424 2006-06-27 Ville Vainio <vivainio@gmail.com>
420
425
421 * Magic.py (_inspect, _ofind) Apply David Huard's
426 * Magic.py (_inspect, _ofind) Apply David Huard's
422 patch for displaying the correct docstring for 'property'
427 patch for displaying the correct docstring for 'property'
423 attributes.
428 attributes.
424
429
425 2006-06-23 Walter Doerwald <walter@livinglogic.de>
430 2006-06-23 Walter Doerwald <walter@livinglogic.de>
426
431
427 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
432 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
428 commands into the methods implementing them.
433 commands into the methods implementing them.
429
434
430 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
435 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
431
436
432 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
437 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
433 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
438 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
434 autoindent support was authored by Jin Liu.
439 autoindent support was authored by Jin Liu.
435
440
436 2006-06-22 Walter Doerwald <walter@livinglogic.de>
441 2006-06-22 Walter Doerwald <walter@livinglogic.de>
437
442
438 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
443 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
439 for keymaps with a custom class that simplifies handling.
444 for keymaps with a custom class that simplifies handling.
440
445
441 2006-06-19 Walter Doerwald <walter@livinglogic.de>
446 2006-06-19 Walter Doerwald <walter@livinglogic.de>
442
447
443 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
448 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
444 resizing. This requires Python 2.5 to work.
449 resizing. This requires Python 2.5 to work.
445
450
446 2006-06-16 Walter Doerwald <walter@livinglogic.de>
451 2006-06-16 Walter Doerwald <walter@livinglogic.de>
447
452
448 * IPython/Extensions/ibrowse.py: Add two new commands to
453 * IPython/Extensions/ibrowse.py: Add two new commands to
449 ibrowse: "hideattr" (mapped to "h") hides the attribute under
454 ibrowse: "hideattr" (mapped to "h") hides the attribute under
450 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
455 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
451 attributes again. Remapped the help command to "?". Display
456 attributes again. Remapped the help command to "?". Display
452 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
457 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
453 as keys for the "home" and "end" commands. Add three new commands
458 as keys for the "home" and "end" commands. Add three new commands
454 to the input mode for "find" and friends: "delend" (CTRL-K)
459 to the input mode for "find" and friends: "delend" (CTRL-K)
455 deletes to the end of line. "incsearchup" searches upwards in the
460 deletes to the end of line. "incsearchup" searches upwards in the
456 command history for an input that starts with the text before the cursor.
461 command history for an input that starts with the text before the cursor.
457 "incsearchdown" does the same downwards. Removed a bogus mapping of
462 "incsearchdown" does the same downwards. Removed a bogus mapping of
458 the x key to "delete".
463 the x key to "delete".
459
464
460 2006-06-15 Ville Vainio <vivainio@gmail.com>
465 2006-06-15 Ville Vainio <vivainio@gmail.com>
461
466
462 * iplib.py, hooks.py: Added new generate_prompt hook that can be
467 * iplib.py, hooks.py: Added new generate_prompt hook that can be
463 used to create prompts dynamically, instead of the "old" way of
468 used to create prompts dynamically, instead of the "old" way of
464 assigning "magic" strings to prompt_in1 and prompt_in2. The old
469 assigning "magic" strings to prompt_in1 and prompt_in2. The old
465 way still works (it's invoked by the default hook), of course.
470 way still works (it's invoked by the default hook), of course.
466
471
467 * Prompts.py: added generate_output_prompt hook for altering output
472 * Prompts.py: added generate_output_prompt hook for altering output
468 prompt
473 prompt
469
474
470 * Release.py: Changed version string to 0.7.3.svn.
475 * Release.py: Changed version string to 0.7.3.svn.
471
476
472 2006-06-15 Walter Doerwald <walter@livinglogic.de>
477 2006-06-15 Walter Doerwald <walter@livinglogic.de>
473
478
474 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
479 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
475 the call to fetch() always tries to fetch enough data for at least one
480 the call to fetch() always tries to fetch enough data for at least one
476 full screen. This makes it possible to simply call moveto(0,0,True) in
481 full screen. This makes it possible to simply call moveto(0,0,True) in
477 the constructor. Fix typos and removed the obsolete goto attribute.
482 the constructor. Fix typos and removed the obsolete goto attribute.
478
483
479 2006-06-12 Ville Vainio <vivainio@gmail.com>
484 2006-06-12 Ville Vainio <vivainio@gmail.com>
480
485
481 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
486 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
482 allowing $variable interpolation within multiline statements,
487 allowing $variable interpolation within multiline statements,
483 though so far only with "sh" profile for a testing period.
488 though so far only with "sh" profile for a testing period.
484 The patch also enables splitting long commands with \ but it
489 The patch also enables splitting long commands with \ but it
485 doesn't work properly yet.
490 doesn't work properly yet.
486
491
487 2006-06-12 Walter Doerwald <walter@livinglogic.de>
492 2006-06-12 Walter Doerwald <walter@livinglogic.de>
488
493
489 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
494 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
490 input history and the position of the cursor in the input history for
495 input history and the position of the cursor in the input history for
491 the find, findbackwards and goto command.
496 the find, findbackwards and goto command.
492
497
493 2006-06-10 Walter Doerwald <walter@livinglogic.de>
498 2006-06-10 Walter Doerwald <walter@livinglogic.de>
494
499
495 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
500 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
496 implements the basic functionality of browser commands that require
501 implements the basic functionality of browser commands that require
497 input. Reimplement the goto, find and findbackwards commands as
502 input. Reimplement the goto, find and findbackwards commands as
498 subclasses of _CommandInput. Add an input history and keymaps to those
503 subclasses of _CommandInput. Add an input history and keymaps to those
499 commands. Add "\r" as a keyboard shortcut for the enterdefault and
504 commands. Add "\r" as a keyboard shortcut for the enterdefault and
500 execute commands.
505 execute commands.
501
506
502 2006-06-07 Ville Vainio <vivainio@gmail.com>
507 2006-06-07 Ville Vainio <vivainio@gmail.com>
503
508
504 * iplib.py: ipython mybatch.ipy exits ipython immediately after
509 * iplib.py: ipython mybatch.ipy exits ipython immediately after
505 running the batch files instead of leaving the session open.
510 running the batch files instead of leaving the session open.
506
511
507 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
512 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
508
513
509 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
514 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
510 the original fix was incomplete. Patch submitted by W. Maier.
515 the original fix was incomplete. Patch submitted by W. Maier.
511
516
512 2006-06-07 Ville Vainio <vivainio@gmail.com>
517 2006-06-07 Ville Vainio <vivainio@gmail.com>
513
518
514 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
519 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
515 Confirmation prompts can be supressed by 'quiet' option.
520 Confirmation prompts can be supressed by 'quiet' option.
516 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
521 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
517
522
518 2006-06-06 *** Released version 0.7.2
523 2006-06-06 *** Released version 0.7.2
519
524
520 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
525 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
521
526
522 * IPython/Release.py (version): Made 0.7.2 final for release.
527 * IPython/Release.py (version): Made 0.7.2 final for release.
523 Repo tagged and release cut.
528 Repo tagged and release cut.
524
529
525 2006-06-05 Ville Vainio <vivainio@gmail.com>
530 2006-06-05 Ville Vainio <vivainio@gmail.com>
526
531
527 * Magic.py (magic_rehashx): Honor no_alias list earlier in
532 * Magic.py (magic_rehashx): Honor no_alias list earlier in
528 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
533 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
529
534
530 * upgrade_dir.py: try import 'path' module a bit harder
535 * upgrade_dir.py: try import 'path' module a bit harder
531 (for %upgrade)
536 (for %upgrade)
532
537
533 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
538 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
534
539
535 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
540 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
536 instead of looping 20 times.
541 instead of looping 20 times.
537
542
538 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
543 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
539 correctly at initialization time. Bug reported by Krishna Mohan
544 correctly at initialization time. Bug reported by Krishna Mohan
540 Gundu <gkmohan-AT-gmail.com> on the user list.
545 Gundu <gkmohan-AT-gmail.com> on the user list.
541
546
542 * IPython/Release.py (version): Mark 0.7.2 version to start
547 * IPython/Release.py (version): Mark 0.7.2 version to start
543 testing for release on 06/06.
548 testing for release on 06/06.
544
549
545 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
550 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
546
551
547 * scripts/irunner: thin script interface so users don't have to
552 * scripts/irunner: thin script interface so users don't have to
548 find the module and call it as an executable, since modules rarely
553 find the module and call it as an executable, since modules rarely
549 live in people's PATH.
554 live in people's PATH.
550
555
551 * IPython/irunner.py (InteractiveRunner.__init__): added
556 * IPython/irunner.py (InteractiveRunner.__init__): added
552 delaybeforesend attribute to control delays with newer versions of
557 delaybeforesend attribute to control delays with newer versions of
553 pexpect. Thanks to detailed help from pexpect's author, Noah
558 pexpect. Thanks to detailed help from pexpect's author, Noah
554 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
559 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
555 correctly (it works in NoColor mode).
560 correctly (it works in NoColor mode).
556
561
557 * IPython/iplib.py (handle_normal): fix nasty crash reported on
562 * IPython/iplib.py (handle_normal): fix nasty crash reported on
558 SAGE list, from improper log() calls.
563 SAGE list, from improper log() calls.
559
564
560 2006-05-31 Ville Vainio <vivainio@gmail.com>
565 2006-05-31 Ville Vainio <vivainio@gmail.com>
561
566
562 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
567 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
563 with args in parens to work correctly with dirs that have spaces.
568 with args in parens to work correctly with dirs that have spaces.
564
569
565 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
570 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
566
571
567 * IPython/Logger.py (Logger.logstart): add option to log raw input
572 * IPython/Logger.py (Logger.logstart): add option to log raw input
568 instead of the processed one. A -r flag was added to the
573 instead of the processed one. A -r flag was added to the
569 %logstart magic used for controlling logging.
574 %logstart magic used for controlling logging.
570
575
571 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
576 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
572
577
573 * IPython/iplib.py (InteractiveShell.__init__): add check for the
578 * IPython/iplib.py (InteractiveShell.__init__): add check for the
574 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
579 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
575 recognize the option. After a bug report by Will Maier. This
580 recognize the option. After a bug report by Will Maier. This
576 closes #64 (will do it after confirmation from W. Maier).
581 closes #64 (will do it after confirmation from W. Maier).
577
582
578 * IPython/irunner.py: New module to run scripts as if manually
583 * IPython/irunner.py: New module to run scripts as if manually
579 typed into an interactive environment, based on pexpect. After a
584 typed into an interactive environment, based on pexpect. After a
580 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
585 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
581 ipython-user list. Simple unittests in the tests/ directory.
586 ipython-user list. Simple unittests in the tests/ directory.
582
587
583 * tools/release: add Will Maier, OpenBSD port maintainer, to
588 * tools/release: add Will Maier, OpenBSD port maintainer, to
584 recepients list. We are now officially part of the OpenBSD ports:
589 recepients list. We are now officially part of the OpenBSD ports:
585 http://www.openbsd.org/ports.html ! Many thanks to Will for the
590 http://www.openbsd.org/ports.html ! Many thanks to Will for the
586 work.
591 work.
587
592
588 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
593 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
589
594
590 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
595 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
591 so that it doesn't break tkinter apps.
596 so that it doesn't break tkinter apps.
592
597
593 * IPython/iplib.py (_prefilter): fix bug where aliases would
598 * IPython/iplib.py (_prefilter): fix bug where aliases would
594 shadow variables when autocall was fully off. Reported by SAGE
599 shadow variables when autocall was fully off. Reported by SAGE
595 author William Stein.
600 author William Stein.
596
601
597 * IPython/OInspect.py (Inspector.__init__): add a flag to control
602 * IPython/OInspect.py (Inspector.__init__): add a flag to control
598 at what detail level strings are computed when foo? is requested.
603 at what detail level strings are computed when foo? is requested.
599 This allows users to ask for example that the string form of an
604 This allows users to ask for example that the string form of an
600 object is only computed when foo?? is called, or even never, by
605 object is only computed when foo?? is called, or even never, by
601 setting the object_info_string_level >= 2 in the configuration
606 setting the object_info_string_level >= 2 in the configuration
602 file. This new option has been added and documented. After a
607 file. This new option has been added and documented. After a
603 request by SAGE to be able to control the printing of very large
608 request by SAGE to be able to control the printing of very large
604 objects more easily.
609 objects more easily.
605
610
606 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
611 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
607
612
608 * IPython/ipmaker.py (make_IPython): remove the ipython call path
613 * IPython/ipmaker.py (make_IPython): remove the ipython call path
609 from sys.argv, to be 100% consistent with how Python itself works
614 from sys.argv, to be 100% consistent with how Python itself works
610 (as seen for example with python -i file.py). After a bug report
615 (as seen for example with python -i file.py). After a bug report
611 by Jeffrey Collins.
616 by Jeffrey Collins.
612
617
613 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
618 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
614 nasty bug which was preventing custom namespaces with -pylab,
619 nasty bug which was preventing custom namespaces with -pylab,
615 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
620 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
616 compatibility (long gone from mpl).
621 compatibility (long gone from mpl).
617
622
618 * IPython/ipapi.py (make_session): name change: create->make. We
623 * IPython/ipapi.py (make_session): name change: create->make. We
619 use make in other places (ipmaker,...), it's shorter and easier to
624 use make in other places (ipmaker,...), it's shorter and easier to
620 type and say, etc. I'm trying to clean things before 0.7.2 so
625 type and say, etc. I'm trying to clean things before 0.7.2 so
621 that I can keep things stable wrt to ipapi in the chainsaw branch.
626 that I can keep things stable wrt to ipapi in the chainsaw branch.
622
627
623 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
628 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
624 python-mode recognizes our debugger mode. Add support for
629 python-mode recognizes our debugger mode. Add support for
625 autoindent inside (X)emacs. After a patch sent in by Jin Liu
630 autoindent inside (X)emacs. After a patch sent in by Jin Liu
626 <m.liu.jin-AT-gmail.com> originally written by
631 <m.liu.jin-AT-gmail.com> originally written by
627 doxgen-AT-newsmth.net (with minor modifications for xemacs
632 doxgen-AT-newsmth.net (with minor modifications for xemacs
628 compatibility)
633 compatibility)
629
634
630 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
635 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
631 tracebacks when walking the stack so that the stack tracking system
636 tracebacks when walking the stack so that the stack tracking system
632 in emacs' python-mode can identify the frames correctly.
637 in emacs' python-mode can identify the frames correctly.
633
638
634 * IPython/ipmaker.py (make_IPython): make the internal (and
639 * IPython/ipmaker.py (make_IPython): make the internal (and
635 default config) autoedit_syntax value false by default. Too many
640 default config) autoedit_syntax value false by default. Too many
636 users have complained to me (both on and off-list) about problems
641 users have complained to me (both on and off-list) about problems
637 with this option being on by default, so I'm making it default to
642 with this option being on by default, so I'm making it default to
638 off. It can still be enabled by anyone via the usual mechanisms.
643 off. It can still be enabled by anyone via the usual mechanisms.
639
644
640 * IPython/completer.py (Completer.attr_matches): add support for
645 * IPython/completer.py (Completer.attr_matches): add support for
641 PyCrust-style _getAttributeNames magic method. Patch contributed
646 PyCrust-style _getAttributeNames magic method. Patch contributed
642 by <mscott-AT-goldenspud.com>. Closes #50.
647 by <mscott-AT-goldenspud.com>. Closes #50.
643
648
644 * IPython/iplib.py (InteractiveShell.__init__): remove the
649 * IPython/iplib.py (InteractiveShell.__init__): remove the
645 deletion of exit/quit from __builtin__, which can break
650 deletion of exit/quit from __builtin__, which can break
646 third-party tools like the Zope debugging console. The
651 third-party tools like the Zope debugging console. The
647 %exit/%quit magics remain. In general, it's probably a good idea
652 %exit/%quit magics remain. In general, it's probably a good idea
648 not to delete anything from __builtin__, since we never know what
653 not to delete anything from __builtin__, since we never know what
649 that will break. In any case, python now (for 2.5) will support
654 that will break. In any case, python now (for 2.5) will support
650 'real' exit/quit, so this issue is moot. Closes #55.
655 'real' exit/quit, so this issue is moot. Closes #55.
651
656
652 * IPython/genutils.py (with_obj): rename the 'with' function to
657 * IPython/genutils.py (with_obj): rename the 'with' function to
653 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
658 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
654 becomes a language keyword. Closes #53.
659 becomes a language keyword. Closes #53.
655
660
656 * IPython/FakeModule.py (FakeModule.__init__): add a proper
661 * IPython/FakeModule.py (FakeModule.__init__): add a proper
657 __file__ attribute to this so it fools more things into thinking
662 __file__ attribute to this so it fools more things into thinking
658 it is a real module. Closes #59.
663 it is a real module. Closes #59.
659
664
660 * IPython/Magic.py (magic_edit): add -n option to open the editor
665 * IPython/Magic.py (magic_edit): add -n option to open the editor
661 at a specific line number. After a patch by Stefan van der Walt.
666 at a specific line number. After a patch by Stefan van der Walt.
662
667
663 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
668 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
664
669
665 * IPython/iplib.py (edit_syntax_error): fix crash when for some
670 * IPython/iplib.py (edit_syntax_error): fix crash when for some
666 reason the file could not be opened. After automatic crash
671 reason the file could not be opened. After automatic crash
667 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
672 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
668 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
673 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
669 (_should_recompile): Don't fire editor if using %bg, since there
674 (_should_recompile): Don't fire editor if using %bg, since there
670 is no file in the first place. From the same report as above.
675 is no file in the first place. From the same report as above.
671 (raw_input): protect against faulty third-party prefilters. After
676 (raw_input): protect against faulty third-party prefilters. After
672 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
677 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
673 while running under SAGE.
678 while running under SAGE.
674
679
675 2006-05-23 Ville Vainio <vivainio@gmail.com>
680 2006-05-23 Ville Vainio <vivainio@gmail.com>
676
681
677 * ipapi.py: Stripped down ip.to_user_ns() to work only as
682 * ipapi.py: Stripped down ip.to_user_ns() to work only as
678 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
683 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
679 now returns None (again), unless dummy is specifically allowed by
684 now returns None (again), unless dummy is specifically allowed by
680 ipapi.get(allow_dummy=True).
685 ipapi.get(allow_dummy=True).
681
686
682 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
687 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
683
688
684 * IPython: remove all 2.2-compatibility objects and hacks from
689 * IPython: remove all 2.2-compatibility objects and hacks from
685 everywhere, since we only support 2.3 at this point. Docs
690 everywhere, since we only support 2.3 at this point. Docs
686 updated.
691 updated.
687
692
688 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
693 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
689 Anything requiring extra validation can be turned into a Python
694 Anything requiring extra validation can be turned into a Python
690 property in the future. I used a property for the db one b/c
695 property in the future. I used a property for the db one b/c
691 there was a nasty circularity problem with the initialization
696 there was a nasty circularity problem with the initialization
692 order, which right now I don't have time to clean up.
697 order, which right now I don't have time to clean up.
693
698
694 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
699 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
695 another locking bug reported by Jorgen. I'm not 100% sure though,
700 another locking bug reported by Jorgen. I'm not 100% sure though,
696 so more testing is needed...
701 so more testing is needed...
697
702
698 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
703 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
699
704
700 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
705 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
701 local variables from any routine in user code (typically executed
706 local variables from any routine in user code (typically executed
702 with %run) directly into the interactive namespace. Very useful
707 with %run) directly into the interactive namespace. Very useful
703 when doing complex debugging.
708 when doing complex debugging.
704 (IPythonNotRunning): Changed the default None object to a dummy
709 (IPythonNotRunning): Changed the default None object to a dummy
705 whose attributes can be queried as well as called without
710 whose attributes can be queried as well as called without
706 exploding, to ease writing code which works transparently both in
711 exploding, to ease writing code which works transparently both in
707 and out of ipython and uses some of this API.
712 and out of ipython and uses some of this API.
708
713
709 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
714 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
710
715
711 * IPython/hooks.py (result_display): Fix the fact that our display
716 * IPython/hooks.py (result_display): Fix the fact that our display
712 hook was using str() instead of repr(), as the default python
717 hook was using str() instead of repr(), as the default python
713 console does. This had gone unnoticed b/c it only happened if
718 console does. This had gone unnoticed b/c it only happened if
714 %Pprint was off, but the inconsistency was there.
719 %Pprint was off, but the inconsistency was there.
715
720
716 2006-05-15 Ville Vainio <vivainio@gmail.com>
721 2006-05-15 Ville Vainio <vivainio@gmail.com>
717
722
718 * Oinspect.py: Only show docstring for nonexisting/binary files
723 * Oinspect.py: Only show docstring for nonexisting/binary files
719 when doing object??, closing ticket #62
724 when doing object??, closing ticket #62
720
725
721 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
726 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
722
727
723 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
728 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
724 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
729 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
725 was being released in a routine which hadn't checked if it had
730 was being released in a routine which hadn't checked if it had
726 been the one to acquire it.
731 been the one to acquire it.
727
732
728 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
733 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
729
734
730 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
735 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
731
736
732 2006-04-11 Ville Vainio <vivainio@gmail.com>
737 2006-04-11 Ville Vainio <vivainio@gmail.com>
733
738
734 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
739 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
735 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
740 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
736 prefilters, allowing stuff like magics and aliases in the file.
741 prefilters, allowing stuff like magics and aliases in the file.
737
742
738 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
743 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
739 added. Supported now are "%clear in" and "%clear out" (clear input and
744 added. Supported now are "%clear in" and "%clear out" (clear input and
740 output history, respectively). Also fixed CachedOutput.flush to
745 output history, respectively). Also fixed CachedOutput.flush to
741 properly flush the output cache.
746 properly flush the output cache.
742
747
743 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
748 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
744 half-success (and fail explicitly).
749 half-success (and fail explicitly).
745
750
746 2006-03-28 Ville Vainio <vivainio@gmail.com>
751 2006-03-28 Ville Vainio <vivainio@gmail.com>
747
752
748 * iplib.py: Fix quoting of aliases so that only argless ones
753 * iplib.py: Fix quoting of aliases so that only argless ones
749 are quoted
754 are quoted
750
755
751 2006-03-28 Ville Vainio <vivainio@gmail.com>
756 2006-03-28 Ville Vainio <vivainio@gmail.com>
752
757
753 * iplib.py: Quote aliases with spaces in the name.
758 * iplib.py: Quote aliases with spaces in the name.
754 "c:\program files\blah\bin" is now legal alias target.
759 "c:\program files\blah\bin" is now legal alias target.
755
760
756 * ext_rehashdir.py: Space no longer allowed as arg
761 * ext_rehashdir.py: Space no longer allowed as arg
757 separator, since space is legal in path names.
762 separator, since space is legal in path names.
758
763
759 2006-03-16 Ville Vainio <vivainio@gmail.com>
764 2006-03-16 Ville Vainio <vivainio@gmail.com>
760
765
761 * upgrade_dir.py: Take path.py from Extensions, correcting
766 * upgrade_dir.py: Take path.py from Extensions, correcting
762 %upgrade magic
767 %upgrade magic
763
768
764 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
769 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
765
770
766 * hooks.py: Only enclose editor binary in quotes if legal and
771 * hooks.py: Only enclose editor binary in quotes if legal and
767 necessary (space in the name, and is an existing file). Fixes a bug
772 necessary (space in the name, and is an existing file). Fixes a bug
768 reported by Zachary Pincus.
773 reported by Zachary Pincus.
769
774
770 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
775 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
771
776
772 * Manual: thanks to a tip on proper color handling for Emacs, by
777 * Manual: thanks to a tip on proper color handling for Emacs, by
773 Eric J Haywiser <ejh1-AT-MIT.EDU>.
778 Eric J Haywiser <ejh1-AT-MIT.EDU>.
774
779
775 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
780 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
776 by applying the provided patch. Thanks to Liu Jin
781 by applying the provided patch. Thanks to Liu Jin
777 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
782 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
778 XEmacs/Linux, I'm trusting the submitter that it actually helps
783 XEmacs/Linux, I'm trusting the submitter that it actually helps
779 under win32/GNU Emacs. Will revisit if any problems are reported.
784 under win32/GNU Emacs. Will revisit if any problems are reported.
780
785
781 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
786 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
782
787
783 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
788 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
784 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
789 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
785
790
786 2006-03-12 Ville Vainio <vivainio@gmail.com>
791 2006-03-12 Ville Vainio <vivainio@gmail.com>
787
792
788 * Magic.py (magic_timeit): Added %timeit magic, contributed by
793 * Magic.py (magic_timeit): Added %timeit magic, contributed by
789 Torsten Marek.
794 Torsten Marek.
790
795
791 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
796 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
792
797
793 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
798 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
794 line ranges works again.
799 line ranges works again.
795
800
796 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
801 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
797
802
798 * IPython/iplib.py (showtraceback): add back sys.last_traceback
803 * IPython/iplib.py (showtraceback): add back sys.last_traceback
799 and friends, after a discussion with Zach Pincus on ipython-user.
804 and friends, after a discussion with Zach Pincus on ipython-user.
800 I'm not 100% sure, but after thinking about it quite a bit, it may
805 I'm not 100% sure, but after thinking about it quite a bit, it may
801 be OK. Testing with the multithreaded shells didn't reveal any
806 be OK. Testing with the multithreaded shells didn't reveal any
802 problems, but let's keep an eye out.
807 problems, but let's keep an eye out.
803
808
804 In the process, I fixed a few things which were calling
809 In the process, I fixed a few things which were calling
805 self.InteractiveTB() directly (like safe_execfile), which is a
810 self.InteractiveTB() directly (like safe_execfile), which is a
806 mistake: ALL exception reporting should be done by calling
811 mistake: ALL exception reporting should be done by calling
807 self.showtraceback(), which handles state and tab-completion and
812 self.showtraceback(), which handles state and tab-completion and
808 more.
813 more.
809
814
810 2006-03-01 Ville Vainio <vivainio@gmail.com>
815 2006-03-01 Ville Vainio <vivainio@gmail.com>
811
816
812 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
817 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
813 To use, do "from ipipe import *".
818 To use, do "from ipipe import *".
814
819
815 2006-02-24 Ville Vainio <vivainio@gmail.com>
820 2006-02-24 Ville Vainio <vivainio@gmail.com>
816
821
817 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
822 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
818 "cleanly" and safely than the older upgrade mechanism.
823 "cleanly" and safely than the older upgrade mechanism.
819
824
820 2006-02-21 Ville Vainio <vivainio@gmail.com>
825 2006-02-21 Ville Vainio <vivainio@gmail.com>
821
826
822 * Magic.py: %save works again.
827 * Magic.py: %save works again.
823
828
824 2006-02-15 Ville Vainio <vivainio@gmail.com>
829 2006-02-15 Ville Vainio <vivainio@gmail.com>
825
830
826 * Magic.py: %Pprint works again
831 * Magic.py: %Pprint works again
827
832
828 * Extensions/ipy_sane_defaults.py: Provide everything provided
833 * Extensions/ipy_sane_defaults.py: Provide everything provided
829 in default ipythonrc, to make it possible to have a completely empty
834 in default ipythonrc, to make it possible to have a completely empty
830 ipythonrc (and thus completely rc-file free configuration)
835 ipythonrc (and thus completely rc-file free configuration)
831
836
832 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
837 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
833
838
834 * IPython/hooks.py (editor): quote the call to the editor command,
839 * IPython/hooks.py (editor): quote the call to the editor command,
835 to allow commands with spaces in them. Problem noted by watching
840 to allow commands with spaces in them. Problem noted by watching
836 Ian Oswald's video about textpad under win32 at
841 Ian Oswald's video about textpad under win32 at
837 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
842 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
838
843
839 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
844 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
840 describing magics (we haven't used @ for a loong time).
845 describing magics (we haven't used @ for a loong time).
841
846
842 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
847 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
843 contributed by marienz to close
848 contributed by marienz to close
844 http://www.scipy.net/roundup/ipython/issue53.
849 http://www.scipy.net/roundup/ipython/issue53.
845
850
846 2006-02-10 Ville Vainio <vivainio@gmail.com>
851 2006-02-10 Ville Vainio <vivainio@gmail.com>
847
852
848 * genutils.py: getoutput now works in win32 too
853 * genutils.py: getoutput now works in win32 too
849
854
850 * completer.py: alias and magic completion only invoked
855 * completer.py: alias and magic completion only invoked
851 at the first "item" in the line, to avoid "cd %store"
856 at the first "item" in the line, to avoid "cd %store"
852 nonsense.
857 nonsense.
853
858
854 2006-02-09 Ville Vainio <vivainio@gmail.com>
859 2006-02-09 Ville Vainio <vivainio@gmail.com>
855
860
856 * test/*: Added a unit testing framework (finally).
861 * test/*: Added a unit testing framework (finally).
857 '%run runtests.py' to run test_*.
862 '%run runtests.py' to run test_*.
858
863
859 * ipapi.py: Exposed runlines and set_custom_exc
864 * ipapi.py: Exposed runlines and set_custom_exc
860
865
861 2006-02-07 Ville Vainio <vivainio@gmail.com>
866 2006-02-07 Ville Vainio <vivainio@gmail.com>
862
867
863 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
868 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
864 instead use "f(1 2)" as before.
869 instead use "f(1 2)" as before.
865
870
866 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
871 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
867
872
868 * IPython/demo.py (IPythonDemo): Add new classes to the demo
873 * IPython/demo.py (IPythonDemo): Add new classes to the demo
869 facilities, for demos processed by the IPython input filter
874 facilities, for demos processed by the IPython input filter
870 (IPythonDemo), and for running a script one-line-at-a-time as a
875 (IPythonDemo), and for running a script one-line-at-a-time as a
871 demo, both for pure Python (LineDemo) and for IPython-processed
876 demo, both for pure Python (LineDemo) and for IPython-processed
872 input (IPythonLineDemo). After a request by Dave Kohel, from the
877 input (IPythonLineDemo). After a request by Dave Kohel, from the
873 SAGE team.
878 SAGE team.
874 (Demo.edit): added an edit() method to the demo objects, to edit
879 (Demo.edit): added an edit() method to the demo objects, to edit
875 the in-memory copy of the last executed block.
880 the in-memory copy of the last executed block.
876
881
877 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
882 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
878 processing to %edit, %macro and %save. These commands can now be
883 processing to %edit, %macro and %save. These commands can now be
879 invoked on the unprocessed input as it was typed by the user
884 invoked on the unprocessed input as it was typed by the user
880 (without any prefilters applied). After requests by the SAGE team
885 (without any prefilters applied). After requests by the SAGE team
881 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
886 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
882
887
883 2006-02-01 Ville Vainio <vivainio@gmail.com>
888 2006-02-01 Ville Vainio <vivainio@gmail.com>
884
889
885 * setup.py, eggsetup.py: easy_install ipython==dev works
890 * setup.py, eggsetup.py: easy_install ipython==dev works
886 correctly now (on Linux)
891 correctly now (on Linux)
887
892
888 * ipy_user_conf,ipmaker: user config changes, removed spurious
893 * ipy_user_conf,ipmaker: user config changes, removed spurious
889 warnings
894 warnings
890
895
891 * iplib: if rc.banner is string, use it as is.
896 * iplib: if rc.banner is string, use it as is.
892
897
893 * Magic: %pycat accepts a string argument and pages it's contents.
898 * Magic: %pycat accepts a string argument and pages it's contents.
894
899
895
900
896 2006-01-30 Ville Vainio <vivainio@gmail.com>
901 2006-01-30 Ville Vainio <vivainio@gmail.com>
897
902
898 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
903 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
899 Now %store and bookmarks work through PickleShare, meaning that
904 Now %store and bookmarks work through PickleShare, meaning that
900 concurrent access is possible and all ipython sessions see the
905 concurrent access is possible and all ipython sessions see the
901 same database situation all the time, instead of snapshot of
906 same database situation all the time, instead of snapshot of
902 the situation when the session was started. Hence, %bookmark
907 the situation when the session was started. Hence, %bookmark
903 results are immediately accessible from othes sessions. The database
908 results are immediately accessible from othes sessions. The database
904 is also available for use by user extensions. See:
909 is also available for use by user extensions. See:
905 http://www.python.org/pypi/pickleshare
910 http://www.python.org/pypi/pickleshare
906
911
907 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
912 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
908
913
909 * aliases can now be %store'd
914 * aliases can now be %store'd
910
915
911 * path.py moved to Extensions so that pickleshare does not need
916 * path.py moved to Extensions so that pickleshare does not need
912 IPython-specific import. Extensions added to pythonpath right
917 IPython-specific import. Extensions added to pythonpath right
913 at __init__.
918 at __init__.
914
919
915 * iplib.py: ipalias deprecated/redundant; aliases are converted and
920 * iplib.py: ipalias deprecated/redundant; aliases are converted and
916 called with _ip.system and the pre-transformed command string.
921 called with _ip.system and the pre-transformed command string.
917
922
918 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
923 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
919
924
920 * IPython/iplib.py (interact): Fix that we were not catching
925 * IPython/iplib.py (interact): Fix that we were not catching
921 KeyboardInterrupt exceptions properly. I'm not quite sure why the
926 KeyboardInterrupt exceptions properly. I'm not quite sure why the
922 logic here had to change, but it's fixed now.
927 logic here had to change, but it's fixed now.
923
928
924 2006-01-29 Ville Vainio <vivainio@gmail.com>
929 2006-01-29 Ville Vainio <vivainio@gmail.com>
925
930
926 * iplib.py: Try to import pyreadline on Windows.
931 * iplib.py: Try to import pyreadline on Windows.
927
932
928 2006-01-27 Ville Vainio <vivainio@gmail.com>
933 2006-01-27 Ville Vainio <vivainio@gmail.com>
929
934
930 * iplib.py: Expose ipapi as _ip in builtin namespace.
935 * iplib.py: Expose ipapi as _ip in builtin namespace.
931 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
936 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
932 and ip_set_hook (-> _ip.set_hook) redundant. % and !
937 and ip_set_hook (-> _ip.set_hook) redundant. % and !
933 syntax now produce _ip.* variant of the commands.
938 syntax now produce _ip.* variant of the commands.
934
939
935 * "_ip.options().autoedit_syntax = 2" automatically throws
940 * "_ip.options().autoedit_syntax = 2" automatically throws
936 user to editor for syntax error correction without prompting.
941 user to editor for syntax error correction without prompting.
937
942
938 2006-01-27 Ville Vainio <vivainio@gmail.com>
943 2006-01-27 Ville Vainio <vivainio@gmail.com>
939
944
940 * ipmaker.py: Give "realistic" sys.argv for scripts (without
945 * ipmaker.py: Give "realistic" sys.argv for scripts (without
941 'ipython' at argv[0]) executed through command line.
946 'ipython' at argv[0]) executed through command line.
942 NOTE: this DEPRECATES calling ipython with multiple scripts
947 NOTE: this DEPRECATES calling ipython with multiple scripts
943 ("ipython a.py b.py c.py")
948 ("ipython a.py b.py c.py")
944
949
945 * iplib.py, hooks.py: Added configurable input prefilter,
950 * iplib.py, hooks.py: Added configurable input prefilter,
946 named 'input_prefilter'. See ext_rescapture.py for example
951 named 'input_prefilter'. See ext_rescapture.py for example
947 usage.
952 usage.
948
953
949 * ext_rescapture.py, Magic.py: Better system command output capture
954 * ext_rescapture.py, Magic.py: Better system command output capture
950 through 'var = !ls' (deprecates user-visible %sc). Same notation
955 through 'var = !ls' (deprecates user-visible %sc). Same notation
951 applies for magics, 'var = %alias' assigns alias list to var.
956 applies for magics, 'var = %alias' assigns alias list to var.
952
957
953 * ipapi.py: added meta() for accessing extension-usable data store.
958 * ipapi.py: added meta() for accessing extension-usable data store.
954
959
955 * iplib.py: added InteractiveShell.getapi(). New magics should be
960 * iplib.py: added InteractiveShell.getapi(). New magics should be
956 written doing self.getapi() instead of using the shell directly.
961 written doing self.getapi() instead of using the shell directly.
957
962
958 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
963 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
959 %store foo >> ~/myfoo.txt to store variables to files (in clean
964 %store foo >> ~/myfoo.txt to store variables to files (in clean
960 textual form, not a restorable pickle).
965 textual form, not a restorable pickle).
961
966
962 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
967 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
963
968
964 * usage.py, Magic.py: added %quickref
969 * usage.py, Magic.py: added %quickref
965
970
966 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
971 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
967
972
968 * GetoptErrors when invoking magics etc. with wrong args
973 * GetoptErrors when invoking magics etc. with wrong args
969 are now more helpful:
974 are now more helpful:
970 GetoptError: option -l not recognized (allowed: "qb" )
975 GetoptError: option -l not recognized (allowed: "qb" )
971
976
972 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
977 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
973
978
974 * IPython/demo.py (Demo.show): Flush stdout after each block, so
979 * IPython/demo.py (Demo.show): Flush stdout after each block, so
975 computationally intensive blocks don't appear to stall the demo.
980 computationally intensive blocks don't appear to stall the demo.
976
981
977 2006-01-24 Ville Vainio <vivainio@gmail.com>
982 2006-01-24 Ville Vainio <vivainio@gmail.com>
978
983
979 * iplib.py, hooks.py: 'result_display' hook can return a non-None
984 * iplib.py, hooks.py: 'result_display' hook can return a non-None
980 value to manipulate resulting history entry.
985 value to manipulate resulting history entry.
981
986
982 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
987 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
983 to instance methods of IPApi class, to make extending an embedded
988 to instance methods of IPApi class, to make extending an embedded
984 IPython feasible. See ext_rehashdir.py for example usage.
989 IPython feasible. See ext_rehashdir.py for example usage.
985
990
986 * Merged 1071-1076 from branches/0.7.1
991 * Merged 1071-1076 from branches/0.7.1
987
992
988
993
989 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
994 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
990
995
991 * tools/release (daystamp): Fix build tools to use the new
996 * tools/release (daystamp): Fix build tools to use the new
992 eggsetup.py script to build lightweight eggs.
997 eggsetup.py script to build lightweight eggs.
993
998
994 * Applied changesets 1062 and 1064 before 0.7.1 release.
999 * Applied changesets 1062 and 1064 before 0.7.1 release.
995
1000
996 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
1001 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
997 see the raw input history (without conversions like %ls ->
1002 see the raw input history (without conversions like %ls ->
998 ipmagic("ls")). After a request from W. Stein, SAGE
1003 ipmagic("ls")). After a request from W. Stein, SAGE
999 (http://modular.ucsd.edu/sage) developer. This information is
1004 (http://modular.ucsd.edu/sage) developer. This information is
1000 stored in the input_hist_raw attribute of the IPython instance, so
1005 stored in the input_hist_raw attribute of the IPython instance, so
1001 developers can access it if needed (it's an InputList instance).
1006 developers can access it if needed (it's an InputList instance).
1002
1007
1003 * Versionstring = 0.7.2.svn
1008 * Versionstring = 0.7.2.svn
1004
1009
1005 * eggsetup.py: A separate script for constructing eggs, creates
1010 * eggsetup.py: A separate script for constructing eggs, creates
1006 proper launch scripts even on Windows (an .exe file in
1011 proper launch scripts even on Windows (an .exe file in
1007 \python24\scripts).
1012 \python24\scripts).
1008
1013
1009 * ipapi.py: launch_new_instance, launch entry point needed for the
1014 * ipapi.py: launch_new_instance, launch entry point needed for the
1010 egg.
1015 egg.
1011
1016
1012 2006-01-23 Ville Vainio <vivainio@gmail.com>
1017 2006-01-23 Ville Vainio <vivainio@gmail.com>
1013
1018
1014 * Added %cpaste magic for pasting python code
1019 * Added %cpaste magic for pasting python code
1015
1020
1016 2006-01-22 Ville Vainio <vivainio@gmail.com>
1021 2006-01-22 Ville Vainio <vivainio@gmail.com>
1017
1022
1018 * Merge from branches/0.7.1 into trunk, revs 1052-1057
1023 * Merge from branches/0.7.1 into trunk, revs 1052-1057
1019
1024
1020 * Versionstring = 0.7.2.svn
1025 * Versionstring = 0.7.2.svn
1021
1026
1022 * eggsetup.py: A separate script for constructing eggs, creates
1027 * eggsetup.py: A separate script for constructing eggs, creates
1023 proper launch scripts even on Windows (an .exe file in
1028 proper launch scripts even on Windows (an .exe file in
1024 \python24\scripts).
1029 \python24\scripts).
1025
1030
1026 * ipapi.py: launch_new_instance, launch entry point needed for the
1031 * ipapi.py: launch_new_instance, launch entry point needed for the
1027 egg.
1032 egg.
1028
1033
1029 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
1034 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
1030
1035
1031 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
1036 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
1032 %pfile foo would print the file for foo even if it was a binary.
1037 %pfile foo would print the file for foo even if it was a binary.
1033 Now, extensions '.so' and '.dll' are skipped.
1038 Now, extensions '.so' and '.dll' are skipped.
1034
1039
1035 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
1040 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
1036 bug, where macros would fail in all threaded modes. I'm not 100%
1041 bug, where macros would fail in all threaded modes. I'm not 100%
1037 sure, so I'm going to put out an rc instead of making a release
1042 sure, so I'm going to put out an rc instead of making a release
1038 today, and wait for feedback for at least a few days.
1043 today, and wait for feedback for at least a few days.
1039
1044
1040 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
1045 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
1041 it...) the handling of pasting external code with autoindent on.
1046 it...) the handling of pasting external code with autoindent on.
1042 To get out of a multiline input, the rule will appear for most
1047 To get out of a multiline input, the rule will appear for most
1043 users unchanged: two blank lines or change the indent level
1048 users unchanged: two blank lines or change the indent level
1044 proposed by IPython. But there is a twist now: you can
1049 proposed by IPython. But there is a twist now: you can
1045 add/subtract only *one or two spaces*. If you add/subtract three
1050 add/subtract only *one or two spaces*. If you add/subtract three
1046 or more (unless you completely delete the line), IPython will
1051 or more (unless you completely delete the line), IPython will
1047 accept that line, and you'll need to enter a second one of pure
1052 accept that line, and you'll need to enter a second one of pure
1048 whitespace. I know it sounds complicated, but I can't find a
1053 whitespace. I know it sounds complicated, but I can't find a
1049 different solution that covers all the cases, with the right
1054 different solution that covers all the cases, with the right
1050 heuristics. Hopefully in actual use, nobody will really notice
1055 heuristics. Hopefully in actual use, nobody will really notice
1051 all these strange rules and things will 'just work'.
1056 all these strange rules and things will 'just work'.
1052
1057
1053 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
1058 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
1054
1059
1055 * IPython/iplib.py (interact): catch exceptions which can be
1060 * IPython/iplib.py (interact): catch exceptions which can be
1056 triggered asynchronously by signal handlers. Thanks to an
1061 triggered asynchronously by signal handlers. Thanks to an
1057 automatic crash report, submitted by Colin Kingsley
1062 automatic crash report, submitted by Colin Kingsley
1058 <tercel-AT-gentoo.org>.
1063 <tercel-AT-gentoo.org>.
1059
1064
1060 2006-01-20 Ville Vainio <vivainio@gmail.com>
1065 2006-01-20 Ville Vainio <vivainio@gmail.com>
1061
1066
1062 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
1067 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
1063 (%rehashdir, very useful, try it out) of how to extend ipython
1068 (%rehashdir, very useful, try it out) of how to extend ipython
1064 with new magics. Also added Extensions dir to pythonpath to make
1069 with new magics. Also added Extensions dir to pythonpath to make
1065 importing extensions easy.
1070 importing extensions easy.
1066
1071
1067 * %store now complains when trying to store interactively declared
1072 * %store now complains when trying to store interactively declared
1068 classes / instances of those classes.
1073 classes / instances of those classes.
1069
1074
1070 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
1075 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
1071 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
1076 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
1072 if they exist, and ipy_user_conf.py with some defaults is created for
1077 if they exist, and ipy_user_conf.py with some defaults is created for
1073 the user.
1078 the user.
1074
1079
1075 * Startup rehashing done by the config file, not InterpreterExec.
1080 * Startup rehashing done by the config file, not InterpreterExec.
1076 This means system commands are available even without selecting the
1081 This means system commands are available even without selecting the
1077 pysh profile. It's the sensible default after all.
1082 pysh profile. It's the sensible default after all.
1078
1083
1079 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
1084 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
1080
1085
1081 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
1086 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
1082 multiline code with autoindent on working. But I am really not
1087 multiline code with autoindent on working. But I am really not
1083 sure, so this needs more testing. Will commit a debug-enabled
1088 sure, so this needs more testing. Will commit a debug-enabled
1084 version for now, while I test it some more, so that Ville and
1089 version for now, while I test it some more, so that Ville and
1085 others may also catch any problems. Also made
1090 others may also catch any problems. Also made
1086 self.indent_current_str() a method, to ensure that there's no
1091 self.indent_current_str() a method, to ensure that there's no
1087 chance of the indent space count and the corresponding string
1092 chance of the indent space count and the corresponding string
1088 falling out of sync. All code needing the string should just call
1093 falling out of sync. All code needing the string should just call
1089 the method.
1094 the method.
1090
1095
1091 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
1096 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
1092
1097
1093 * IPython/Magic.py (magic_edit): fix check for when users don't
1098 * IPython/Magic.py (magic_edit): fix check for when users don't
1094 save their output files, the try/except was in the wrong section.
1099 save their output files, the try/except was in the wrong section.
1095
1100
1096 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
1101 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
1097
1102
1098 * IPython/Magic.py (magic_run): fix __file__ global missing from
1103 * IPython/Magic.py (magic_run): fix __file__ global missing from
1099 script's namespace when executed via %run. After a report by
1104 script's namespace when executed via %run. After a report by
1100 Vivian.
1105 Vivian.
1101
1106
1102 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
1107 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
1103 when using python 2.4. The parent constructor changed in 2.4, and
1108 when using python 2.4. The parent constructor changed in 2.4, and
1104 we need to track it directly (we can't call it, as it messes up
1109 we need to track it directly (we can't call it, as it messes up
1105 readline and tab-completion inside our pdb would stop working).
1110 readline and tab-completion inside our pdb would stop working).
1106 After a bug report by R. Bernstein <rocky-AT-panix.com>.
1111 After a bug report by R. Bernstein <rocky-AT-panix.com>.
1107
1112
1108 2006-01-16 Ville Vainio <vivainio@gmail.com>
1113 2006-01-16 Ville Vainio <vivainio@gmail.com>
1109
1114
1110 * Ipython/magic.py: Reverted back to old %edit functionality
1115 * Ipython/magic.py: Reverted back to old %edit functionality
1111 that returns file contents on exit.
1116 that returns file contents on exit.
1112
1117
1113 * IPython/path.py: Added Jason Orendorff's "path" module to
1118 * IPython/path.py: Added Jason Orendorff's "path" module to
1114 IPython tree, http://www.jorendorff.com/articles/python/path/.
1119 IPython tree, http://www.jorendorff.com/articles/python/path/.
1115 You can get path objects conveniently through %sc, and !!, e.g.:
1120 You can get path objects conveniently through %sc, and !!, e.g.:
1116 sc files=ls
1121 sc files=ls
1117 for p in files.paths: # or files.p
1122 for p in files.paths: # or files.p
1118 print p,p.mtime
1123 print p,p.mtime
1119
1124
1120 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
1125 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
1121 now work again without considering the exclusion regexp -
1126 now work again without considering the exclusion regexp -
1122 hence, things like ',foo my/path' turn to 'foo("my/path")'
1127 hence, things like ',foo my/path' turn to 'foo("my/path")'
1123 instead of syntax error.
1128 instead of syntax error.
1124
1129
1125
1130
1126 2006-01-14 Ville Vainio <vivainio@gmail.com>
1131 2006-01-14 Ville Vainio <vivainio@gmail.com>
1127
1132
1128 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
1133 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
1129 ipapi decorators for python 2.4 users, options() provides access to rc
1134 ipapi decorators for python 2.4 users, options() provides access to rc
1130 data.
1135 data.
1131
1136
1132 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
1137 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
1133 as path separators (even on Linux ;-). Space character after
1138 as path separators (even on Linux ;-). Space character after
1134 backslash (as yielded by tab completer) is still space;
1139 backslash (as yielded by tab completer) is still space;
1135 "%cd long\ name" works as expected.
1140 "%cd long\ name" works as expected.
1136
1141
1137 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
1142 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
1138 as "chain of command", with priority. API stays the same,
1143 as "chain of command", with priority. API stays the same,
1139 TryNext exception raised by a hook function signals that
1144 TryNext exception raised by a hook function signals that
1140 current hook failed and next hook should try handling it, as
1145 current hook failed and next hook should try handling it, as
1141 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
1146 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
1142 requested configurable display hook, which is now implemented.
1147 requested configurable display hook, which is now implemented.
1143
1148
1144 2006-01-13 Ville Vainio <vivainio@gmail.com>
1149 2006-01-13 Ville Vainio <vivainio@gmail.com>
1145
1150
1146 * IPython/platutils*.py: platform specific utility functions,
1151 * IPython/platutils*.py: platform specific utility functions,
1147 so far only set_term_title is implemented (change terminal
1152 so far only set_term_title is implemented (change terminal
1148 label in windowing systems). %cd now changes the title to
1153 label in windowing systems). %cd now changes the title to
1149 current dir.
1154 current dir.
1150
1155
1151 * IPython/Release.py: Added myself to "authors" list,
1156 * IPython/Release.py: Added myself to "authors" list,
1152 had to create new files.
1157 had to create new files.
1153
1158
1154 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
1159 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
1155 shell escape; not a known bug but had potential to be one in the
1160 shell escape; not a known bug but had potential to be one in the
1156 future.
1161 future.
1157
1162
1158 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
1163 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
1159 extension API for IPython! See the module for usage example. Fix
1164 extension API for IPython! See the module for usage example. Fix
1160 OInspect for docstring-less magic functions.
1165 OInspect for docstring-less magic functions.
1161
1166
1162
1167
1163 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
1168 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
1164
1169
1165 * IPython/iplib.py (raw_input): temporarily deactivate all
1170 * IPython/iplib.py (raw_input): temporarily deactivate all
1166 attempts at allowing pasting of code with autoindent on. It
1171 attempts at allowing pasting of code with autoindent on. It
1167 introduced bugs (reported by Prabhu) and I can't seem to find a
1172 introduced bugs (reported by Prabhu) and I can't seem to find a
1168 robust combination which works in all cases. Will have to revisit
1173 robust combination which works in all cases. Will have to revisit
1169 later.
1174 later.
1170
1175
1171 * IPython/genutils.py: remove isspace() function. We've dropped
1176 * IPython/genutils.py: remove isspace() function. We've dropped
1172 2.2 compatibility, so it's OK to use the string method.
1177 2.2 compatibility, so it's OK to use the string method.
1173
1178
1174 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1179 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1175
1180
1176 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
1181 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
1177 matching what NOT to autocall on, to include all python binary
1182 matching what NOT to autocall on, to include all python binary
1178 operators (including things like 'and', 'or', 'is' and 'in').
1183 operators (including things like 'and', 'or', 'is' and 'in').
1179 Prompted by a bug report on 'foo & bar', but I realized we had
1184 Prompted by a bug report on 'foo & bar', but I realized we had
1180 many more potential bug cases with other operators. The regexp is
1185 many more potential bug cases with other operators. The regexp is
1181 self.re_exclude_auto, it's fairly commented.
1186 self.re_exclude_auto, it's fairly commented.
1182
1187
1183 2006-01-12 Ville Vainio <vivainio@gmail.com>
1188 2006-01-12 Ville Vainio <vivainio@gmail.com>
1184
1189
1185 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
1190 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
1186 Prettified and hardened string/backslash quoting with ipsystem(),
1191 Prettified and hardened string/backslash quoting with ipsystem(),
1187 ipalias() and ipmagic(). Now even \ characters are passed to
1192 ipalias() and ipmagic(). Now even \ characters are passed to
1188 %magics, !shell escapes and aliases exactly as they are in the
1193 %magics, !shell escapes and aliases exactly as they are in the
1189 ipython command line. Should improve backslash experience,
1194 ipython command line. Should improve backslash experience,
1190 particularly in Windows (path delimiter for some commands that
1195 particularly in Windows (path delimiter for some commands that
1191 won't understand '/'), but Unix benefits as well (regexps). %cd
1196 won't understand '/'), but Unix benefits as well (regexps). %cd
1192 magic still doesn't support backslash path delimiters, though. Also
1197 magic still doesn't support backslash path delimiters, though. Also
1193 deleted all pretense of supporting multiline command strings in
1198 deleted all pretense of supporting multiline command strings in
1194 !system or %magic commands. Thanks to Jerry McRae for suggestions.
1199 !system or %magic commands. Thanks to Jerry McRae for suggestions.
1195
1200
1196 * doc/build_doc_instructions.txt added. Documentation on how to
1201 * doc/build_doc_instructions.txt added. Documentation on how to
1197 use doc/update_manual.py, added yesterday. Both files contributed
1202 use doc/update_manual.py, added yesterday. Both files contributed
1198 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
1203 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
1199 doc/*.sh for deprecation at a later date.
1204 doc/*.sh for deprecation at a later date.
1200
1205
1201 * /ipython.py Added ipython.py to root directory for
1206 * /ipython.py Added ipython.py to root directory for
1202 zero-installation (tar xzvf ipython.tgz; cd ipython; python
1207 zero-installation (tar xzvf ipython.tgz; cd ipython; python
1203 ipython.py) and development convenience (no need to keep doing
1208 ipython.py) and development convenience (no need to keep doing
1204 "setup.py install" between changes).
1209 "setup.py install" between changes).
1205
1210
1206 * Made ! and !! shell escapes work (again) in multiline expressions:
1211 * Made ! and !! shell escapes work (again) in multiline expressions:
1207 if 1:
1212 if 1:
1208 !ls
1213 !ls
1209 !!ls
1214 !!ls
1210
1215
1211 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1216 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1212
1217
1213 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
1218 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
1214 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
1219 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
1215 module in case-insensitive installation. Was causing crashes
1220 module in case-insensitive installation. Was causing crashes
1216 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
1221 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
1217
1222
1218 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
1223 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
1219 <marienz-AT-gentoo.org>, closes
1224 <marienz-AT-gentoo.org>, closes
1220 http://www.scipy.net/roundup/ipython/issue51.
1225 http://www.scipy.net/roundup/ipython/issue51.
1221
1226
1222 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
1227 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
1223
1228
1224 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
1229 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
1225 problem of excessive CPU usage under *nix and keyboard lag under
1230 problem of excessive CPU usage under *nix and keyboard lag under
1226 win32.
1231 win32.
1227
1232
1228 2006-01-10 *** Released version 0.7.0
1233 2006-01-10 *** Released version 0.7.0
1229
1234
1230 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
1235 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
1231
1236
1232 * IPython/Release.py (revision): tag version number to 0.7.0,
1237 * IPython/Release.py (revision): tag version number to 0.7.0,
1233 ready for release.
1238 ready for release.
1234
1239
1235 * IPython/Magic.py (magic_edit): Add print statement to %edit so
1240 * IPython/Magic.py (magic_edit): Add print statement to %edit so
1236 it informs the user of the name of the temp. file used. This can
1241 it informs the user of the name of the temp. file used. This can
1237 help if you decide later to reuse that same file, so you know
1242 help if you decide later to reuse that same file, so you know
1238 where to copy the info from.
1243 where to copy the info from.
1239
1244
1240 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
1245 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
1241
1246
1242 * setup_bdist_egg.py: little script to build an egg. Added
1247 * setup_bdist_egg.py: little script to build an egg. Added
1243 support in the release tools as well.
1248 support in the release tools as well.
1244
1249
1245 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
1250 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
1246
1251
1247 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
1252 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
1248 version selection (new -wxversion command line and ipythonrc
1253 version selection (new -wxversion command line and ipythonrc
1249 parameter). Patch contributed by Arnd Baecker
1254 parameter). Patch contributed by Arnd Baecker
1250 <arnd.baecker-AT-web.de>.
1255 <arnd.baecker-AT-web.de>.
1251
1256
1252 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1257 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1253 embedded instances, for variables defined at the interactive
1258 embedded instances, for variables defined at the interactive
1254 prompt of the embedded ipython. Reported by Arnd.
1259 prompt of the embedded ipython. Reported by Arnd.
1255
1260
1256 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
1261 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
1257 it can be used as a (stateful) toggle, or with a direct parameter.
1262 it can be used as a (stateful) toggle, or with a direct parameter.
1258
1263
1259 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
1264 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
1260 could be triggered in certain cases and cause the traceback
1265 could be triggered in certain cases and cause the traceback
1261 printer not to work.
1266 printer not to work.
1262
1267
1263 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
1268 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
1264
1269
1265 * IPython/iplib.py (_should_recompile): Small fix, closes
1270 * IPython/iplib.py (_should_recompile): Small fix, closes
1266 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
1271 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
1267
1272
1268 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
1273 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
1269
1274
1270 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
1275 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
1271 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
1276 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
1272 Moad for help with tracking it down.
1277 Moad for help with tracking it down.
1273
1278
1274 * IPython/iplib.py (handle_auto): fix autocall handling for
1279 * IPython/iplib.py (handle_auto): fix autocall handling for
1275 objects which support BOTH __getitem__ and __call__ (so that f [x]
1280 objects which support BOTH __getitem__ and __call__ (so that f [x]
1276 is left alone, instead of becoming f([x]) automatically).
1281 is left alone, instead of becoming f([x]) automatically).
1277
1282
1278 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
1283 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
1279 Ville's patch.
1284 Ville's patch.
1280
1285
1281 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
1286 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
1282
1287
1283 * IPython/iplib.py (handle_auto): changed autocall semantics to
1288 * IPython/iplib.py (handle_auto): changed autocall semantics to
1284 include 'smart' mode, where the autocall transformation is NOT
1289 include 'smart' mode, where the autocall transformation is NOT
1285 applied if there are no arguments on the line. This allows you to
1290 applied if there are no arguments on the line. This allows you to
1286 just type 'foo' if foo is a callable to see its internal form,
1291 just type 'foo' if foo is a callable to see its internal form,
1287 instead of having it called with no arguments (typically a
1292 instead of having it called with no arguments (typically a
1288 mistake). The old 'full' autocall still exists: for that, you
1293 mistake). The old 'full' autocall still exists: for that, you
1289 need to set the 'autocall' parameter to 2 in your ipythonrc file.
1294 need to set the 'autocall' parameter to 2 in your ipythonrc file.
1290
1295
1291 * IPython/completer.py (Completer.attr_matches): add
1296 * IPython/completer.py (Completer.attr_matches): add
1292 tab-completion support for Enthoughts' traits. After a report by
1297 tab-completion support for Enthoughts' traits. After a report by
1293 Arnd and a patch by Prabhu.
1298 Arnd and a patch by Prabhu.
1294
1299
1295 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
1300 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
1296
1301
1297 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
1302 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
1298 Schmolck's patch to fix inspect.getinnerframes().
1303 Schmolck's patch to fix inspect.getinnerframes().
1299
1304
1300 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
1305 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
1301 for embedded instances, regarding handling of namespaces and items
1306 for embedded instances, regarding handling of namespaces and items
1302 added to the __builtin__ one. Multiple embedded instances and
1307 added to the __builtin__ one. Multiple embedded instances and
1303 recursive embeddings should work better now (though I'm not sure
1308 recursive embeddings should work better now (though I'm not sure
1304 I've got all the corner cases fixed, that code is a bit of a brain
1309 I've got all the corner cases fixed, that code is a bit of a brain
1305 twister).
1310 twister).
1306
1311
1307 * IPython/Magic.py (magic_edit): added support to edit in-memory
1312 * IPython/Magic.py (magic_edit): added support to edit in-memory
1308 macros (automatically creates the necessary temp files). %edit
1313 macros (automatically creates the necessary temp files). %edit
1309 also doesn't return the file contents anymore, it's just noise.
1314 also doesn't return the file contents anymore, it's just noise.
1310
1315
1311 * IPython/completer.py (Completer.attr_matches): revert change to
1316 * IPython/completer.py (Completer.attr_matches): revert change to
1312 complete only on attributes listed in __all__. I realized it
1317 complete only on attributes listed in __all__. I realized it
1313 cripples the tab-completion system as a tool for exploring the
1318 cripples the tab-completion system as a tool for exploring the
1314 internals of unknown libraries (it renders any non-__all__
1319 internals of unknown libraries (it renders any non-__all__
1315 attribute off-limits). I got bit by this when trying to see
1320 attribute off-limits). I got bit by this when trying to see
1316 something inside the dis module.
1321 something inside the dis module.
1317
1322
1318 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
1323 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
1319
1324
1320 * IPython/iplib.py (InteractiveShell.__init__): add .meta
1325 * IPython/iplib.py (InteractiveShell.__init__): add .meta
1321 namespace for users and extension writers to hold data in. This
1326 namespace for users and extension writers to hold data in. This
1322 follows the discussion in
1327 follows the discussion in
1323 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
1328 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
1324
1329
1325 * IPython/completer.py (IPCompleter.complete): small patch to help
1330 * IPython/completer.py (IPCompleter.complete): small patch to help
1326 tab-completion under Emacs, after a suggestion by John Barnard
1331 tab-completion under Emacs, after a suggestion by John Barnard
1327 <barnarj-AT-ccf.org>.
1332 <barnarj-AT-ccf.org>.
1328
1333
1329 * IPython/Magic.py (Magic.extract_input_slices): added support for
1334 * IPython/Magic.py (Magic.extract_input_slices): added support for
1330 the slice notation in magics to use N-M to represent numbers N...M
1335 the slice notation in magics to use N-M to represent numbers N...M
1331 (closed endpoints). This is used by %macro and %save.
1336 (closed endpoints). This is used by %macro and %save.
1332
1337
1333 * IPython/completer.py (Completer.attr_matches): for modules which
1338 * IPython/completer.py (Completer.attr_matches): for modules which
1334 define __all__, complete only on those. After a patch by Jeffrey
1339 define __all__, complete only on those. After a patch by Jeffrey
1335 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
1340 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
1336 speed up this routine.
1341 speed up this routine.
1337
1342
1338 * IPython/Logger.py (Logger.log): fix a history handling bug. I
1343 * IPython/Logger.py (Logger.log): fix a history handling bug. I
1339 don't know if this is the end of it, but the behavior now is
1344 don't know if this is the end of it, but the behavior now is
1340 certainly much more correct. Note that coupled with macros,
1345 certainly much more correct. Note that coupled with macros,
1341 slightly surprising (at first) behavior may occur: a macro will in
1346 slightly surprising (at first) behavior may occur: a macro will in
1342 general expand to multiple lines of input, so upon exiting, the
1347 general expand to multiple lines of input, so upon exiting, the
1343 in/out counters will both be bumped by the corresponding amount
1348 in/out counters will both be bumped by the corresponding amount
1344 (as if the macro's contents had been typed interactively). Typing
1349 (as if the macro's contents had been typed interactively). Typing
1345 %hist will reveal the intermediate (silently processed) lines.
1350 %hist will reveal the intermediate (silently processed) lines.
1346
1351
1347 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
1352 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
1348 pickle to fail (%run was overwriting __main__ and not restoring
1353 pickle to fail (%run was overwriting __main__ and not restoring
1349 it, but pickle relies on __main__ to operate).
1354 it, but pickle relies on __main__ to operate).
1350
1355
1351 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
1356 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
1352 using properties, but forgot to make the main InteractiveShell
1357 using properties, but forgot to make the main InteractiveShell
1353 class a new-style class. Properties fail silently, and
1358 class a new-style class. Properties fail silently, and
1354 mysteriously, with old-style class (getters work, but
1359 mysteriously, with old-style class (getters work, but
1355 setters don't do anything).
1360 setters don't do anything).
1356
1361
1357 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
1362 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
1358
1363
1359 * IPython/Magic.py (magic_history): fix history reporting bug (I
1364 * IPython/Magic.py (magic_history): fix history reporting bug (I
1360 know some nasties are still there, I just can't seem to find a
1365 know some nasties are still there, I just can't seem to find a
1361 reproducible test case to track them down; the input history is
1366 reproducible test case to track them down; the input history is
1362 falling out of sync...)
1367 falling out of sync...)
1363
1368
1364 * IPython/iplib.py (handle_shell_escape): fix bug where both
1369 * IPython/iplib.py (handle_shell_escape): fix bug where both
1365 aliases and system accesses where broken for indented code (such
1370 aliases and system accesses where broken for indented code (such
1366 as loops).
1371 as loops).
1367
1372
1368 * IPython/genutils.py (shell): fix small but critical bug for
1373 * IPython/genutils.py (shell): fix small but critical bug for
1369 win32 system access.
1374 win32 system access.
1370
1375
1371 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
1376 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
1372
1377
1373 * IPython/iplib.py (showtraceback): remove use of the
1378 * IPython/iplib.py (showtraceback): remove use of the
1374 sys.last_{type/value/traceback} structures, which are non
1379 sys.last_{type/value/traceback} structures, which are non
1375 thread-safe.
1380 thread-safe.
1376 (_prefilter): change control flow to ensure that we NEVER
1381 (_prefilter): change control flow to ensure that we NEVER
1377 introspect objects when autocall is off. This will guarantee that
1382 introspect objects when autocall is off. This will guarantee that
1378 having an input line of the form 'x.y', where access to attribute
1383 having an input line of the form 'x.y', where access to attribute
1379 'y' has side effects, doesn't trigger the side effect TWICE. It
1384 'y' has side effects, doesn't trigger the side effect TWICE. It
1380 is important to note that, with autocall on, these side effects
1385 is important to note that, with autocall on, these side effects
1381 can still happen.
1386 can still happen.
1382 (ipsystem): new builtin, to complete the ip{magic/alias/system}
1387 (ipsystem): new builtin, to complete the ip{magic/alias/system}
1383 trio. IPython offers these three kinds of special calls which are
1388 trio. IPython offers these three kinds of special calls which are
1384 not python code, and it's a good thing to have their call method
1389 not python code, and it's a good thing to have their call method
1385 be accessible as pure python functions (not just special syntax at
1390 be accessible as pure python functions (not just special syntax at
1386 the command line). It gives us a better internal implementation
1391 the command line). It gives us a better internal implementation
1387 structure, as well as exposing these for user scripting more
1392 structure, as well as exposing these for user scripting more
1388 cleanly.
1393 cleanly.
1389
1394
1390 * IPython/macro.py (Macro.__init__): moved macros to a standalone
1395 * IPython/macro.py (Macro.__init__): moved macros to a standalone
1391 file. Now that they'll be more likely to be used with the
1396 file. Now that they'll be more likely to be used with the
1392 persistance system (%store), I want to make sure their module path
1397 persistance system (%store), I want to make sure their module path
1393 doesn't change in the future, so that we don't break things for
1398 doesn't change in the future, so that we don't break things for
1394 users' persisted data.
1399 users' persisted data.
1395
1400
1396 * IPython/iplib.py (autoindent_update): move indentation
1401 * IPython/iplib.py (autoindent_update): move indentation
1397 management into the _text_ processing loop, not the keyboard
1402 management into the _text_ processing loop, not the keyboard
1398 interactive one. This is necessary to correctly process non-typed
1403 interactive one. This is necessary to correctly process non-typed
1399 multiline input (such as macros).
1404 multiline input (such as macros).
1400
1405
1401 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
1406 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
1402 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
1407 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
1403 which was producing problems in the resulting manual.
1408 which was producing problems in the resulting manual.
1404 (magic_whos): improve reporting of instances (show their class,
1409 (magic_whos): improve reporting of instances (show their class,
1405 instead of simply printing 'instance' which isn't terribly
1410 instead of simply printing 'instance' which isn't terribly
1406 informative).
1411 informative).
1407
1412
1408 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
1413 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
1409 (minor mods) to support network shares under win32.
1414 (minor mods) to support network shares under win32.
1410
1415
1411 * IPython/winconsole.py (get_console_size): add new winconsole
1416 * IPython/winconsole.py (get_console_size): add new winconsole
1412 module and fixes to page_dumb() to improve its behavior under
1417 module and fixes to page_dumb() to improve its behavior under
1413 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
1418 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
1414
1419
1415 * IPython/Magic.py (Macro): simplified Macro class to just
1420 * IPython/Magic.py (Macro): simplified Macro class to just
1416 subclass list. We've had only 2.2 compatibility for a very long
1421 subclass list. We've had only 2.2 compatibility for a very long
1417 time, yet I was still avoiding subclassing the builtin types. No
1422 time, yet I was still avoiding subclassing the builtin types. No
1418 more (I'm also starting to use properties, though I won't shift to
1423 more (I'm also starting to use properties, though I won't shift to
1419 2.3-specific features quite yet).
1424 2.3-specific features quite yet).
1420 (magic_store): added Ville's patch for lightweight variable
1425 (magic_store): added Ville's patch for lightweight variable
1421 persistence, after a request on the user list by Matt Wilkie
1426 persistence, after a request on the user list by Matt Wilkie
1422 <maphew-AT-gmail.com>. The new %store magic's docstring has full
1427 <maphew-AT-gmail.com>. The new %store magic's docstring has full
1423 details.
1428 details.
1424
1429
1425 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1430 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1426 changed the default logfile name from 'ipython.log' to
1431 changed the default logfile name from 'ipython.log' to
1427 'ipython_log.py'. These logs are real python files, and now that
1432 'ipython_log.py'. These logs are real python files, and now that
1428 we have much better multiline support, people are more likely to
1433 we have much better multiline support, people are more likely to
1429 want to use them as such. Might as well name them correctly.
1434 want to use them as such. Might as well name them correctly.
1430
1435
1431 * IPython/Magic.py: substantial cleanup. While we can't stop
1436 * IPython/Magic.py: substantial cleanup. While we can't stop
1432 using magics as mixins, due to the existing customizations 'out
1437 using magics as mixins, due to the existing customizations 'out
1433 there' which rely on the mixin naming conventions, at least I
1438 there' which rely on the mixin naming conventions, at least I
1434 cleaned out all cross-class name usage. So once we are OK with
1439 cleaned out all cross-class name usage. So once we are OK with
1435 breaking compatibility, the two systems can be separated.
1440 breaking compatibility, the two systems can be separated.
1436
1441
1437 * IPython/Logger.py: major cleanup. This one is NOT a mixin
1442 * IPython/Logger.py: major cleanup. This one is NOT a mixin
1438 anymore, and the class is a fair bit less hideous as well. New
1443 anymore, and the class is a fair bit less hideous as well. New
1439 features were also introduced: timestamping of input, and logging
1444 features were also introduced: timestamping of input, and logging
1440 of output results. These are user-visible with the -t and -o
1445 of output results. These are user-visible with the -t and -o
1441 options to %logstart. Closes
1446 options to %logstart. Closes
1442 http://www.scipy.net/roundup/ipython/issue11 and a request by
1447 http://www.scipy.net/roundup/ipython/issue11 and a request by
1443 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
1448 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
1444
1449
1445 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
1450 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
1446
1451
1447 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
1452 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
1448 better handle backslashes in paths. See the thread 'More Windows
1453 better handle backslashes in paths. See the thread 'More Windows
1449 questions part 2 - \/ characters revisited' on the iypthon user
1454 questions part 2 - \/ characters revisited' on the iypthon user
1450 list:
1455 list:
1451 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
1456 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
1452
1457
1453 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
1458 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
1454
1459
1455 (InteractiveShell.__init__): change threaded shells to not use the
1460 (InteractiveShell.__init__): change threaded shells to not use the
1456 ipython crash handler. This was causing more problems than not,
1461 ipython crash handler. This was causing more problems than not,
1457 as exceptions in the main thread (GUI code, typically) would
1462 as exceptions in the main thread (GUI code, typically) would
1458 always show up as a 'crash', when they really weren't.
1463 always show up as a 'crash', when they really weren't.
1459
1464
1460 The colors and exception mode commands (%colors/%xmode) have been
1465 The colors and exception mode commands (%colors/%xmode) have been
1461 synchronized to also take this into account, so users can get
1466 synchronized to also take this into account, so users can get
1462 verbose exceptions for their threaded code as well. I also added
1467 verbose exceptions for their threaded code as well. I also added
1463 support for activating pdb inside this exception handler as well,
1468 support for activating pdb inside this exception handler as well,
1464 so now GUI authors can use IPython's enhanced pdb at runtime.
1469 so now GUI authors can use IPython's enhanced pdb at runtime.
1465
1470
1466 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
1471 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
1467 true by default, and add it to the shipped ipythonrc file. Since
1472 true by default, and add it to the shipped ipythonrc file. Since
1468 this asks the user before proceeding, I think it's OK to make it
1473 this asks the user before proceeding, I think it's OK to make it
1469 true by default.
1474 true by default.
1470
1475
1471 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
1476 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
1472 of the previous special-casing of input in the eval loop. I think
1477 of the previous special-casing of input in the eval loop. I think
1473 this is cleaner, as they really are commands and shouldn't have
1478 this is cleaner, as they really are commands and shouldn't have
1474 a special role in the middle of the core code.
1479 a special role in the middle of the core code.
1475
1480
1476 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
1481 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
1477
1482
1478 * IPython/iplib.py (edit_syntax_error): added support for
1483 * IPython/iplib.py (edit_syntax_error): added support for
1479 automatically reopening the editor if the file had a syntax error
1484 automatically reopening the editor if the file had a syntax error
1480 in it. Thanks to scottt who provided the patch at:
1485 in it. Thanks to scottt who provided the patch at:
1481 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
1486 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
1482 version committed).
1487 version committed).
1483
1488
1484 * IPython/iplib.py (handle_normal): add suport for multi-line
1489 * IPython/iplib.py (handle_normal): add suport for multi-line
1485 input with emtpy lines. This fixes
1490 input with emtpy lines. This fixes
1486 http://www.scipy.net/roundup/ipython/issue43 and a similar
1491 http://www.scipy.net/roundup/ipython/issue43 and a similar
1487 discussion on the user list.
1492 discussion on the user list.
1488
1493
1489 WARNING: a behavior change is necessarily introduced to support
1494 WARNING: a behavior change is necessarily introduced to support
1490 blank lines: now a single blank line with whitespace does NOT
1495 blank lines: now a single blank line with whitespace does NOT
1491 break the input loop, which means that when autoindent is on, by
1496 break the input loop, which means that when autoindent is on, by
1492 default hitting return on the next (indented) line does NOT exit.
1497 default hitting return on the next (indented) line does NOT exit.
1493
1498
1494 Instead, to exit a multiline input you can either have:
1499 Instead, to exit a multiline input you can either have:
1495
1500
1496 - TWO whitespace lines (just hit return again), or
1501 - TWO whitespace lines (just hit return again), or
1497 - a single whitespace line of a different length than provided
1502 - a single whitespace line of a different length than provided
1498 by the autoindent (add or remove a space).
1503 by the autoindent (add or remove a space).
1499
1504
1500 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
1505 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
1501 module to better organize all readline-related functionality.
1506 module to better organize all readline-related functionality.
1502 I've deleted FlexCompleter and put all completion clases here.
1507 I've deleted FlexCompleter and put all completion clases here.
1503
1508
1504 * IPython/iplib.py (raw_input): improve indentation management.
1509 * IPython/iplib.py (raw_input): improve indentation management.
1505 It is now possible to paste indented code with autoindent on, and
1510 It is now possible to paste indented code with autoindent on, and
1506 the code is interpreted correctly (though it still looks bad on
1511 the code is interpreted correctly (though it still looks bad on
1507 screen, due to the line-oriented nature of ipython).
1512 screen, due to the line-oriented nature of ipython).
1508 (MagicCompleter.complete): change behavior so that a TAB key on an
1513 (MagicCompleter.complete): change behavior so that a TAB key on an
1509 otherwise empty line actually inserts a tab, instead of completing
1514 otherwise empty line actually inserts a tab, instead of completing
1510 on the entire global namespace. This makes it easier to use the
1515 on the entire global namespace. This makes it easier to use the
1511 TAB key for indentation. After a request by Hans Meine
1516 TAB key for indentation. After a request by Hans Meine
1512 <hans_meine-AT-gmx.net>
1517 <hans_meine-AT-gmx.net>
1513 (_prefilter): add support so that typing plain 'exit' or 'quit'
1518 (_prefilter): add support so that typing plain 'exit' or 'quit'
1514 does a sensible thing. Originally I tried to deviate as little as
1519 does a sensible thing. Originally I tried to deviate as little as
1515 possible from the default python behavior, but even that one may
1520 possible from the default python behavior, but even that one may
1516 change in this direction (thread on python-dev to that effect).
1521 change in this direction (thread on python-dev to that effect).
1517 Regardless, ipython should do the right thing even if CPython's
1522 Regardless, ipython should do the right thing even if CPython's
1518 '>>>' prompt doesn't.
1523 '>>>' prompt doesn't.
1519 (InteractiveShell): removed subclassing code.InteractiveConsole
1524 (InteractiveShell): removed subclassing code.InteractiveConsole
1520 class. By now we'd overridden just about all of its methods: I've
1525 class. By now we'd overridden just about all of its methods: I've
1521 copied the remaining two over, and now ipython is a standalone
1526 copied the remaining two over, and now ipython is a standalone
1522 class. This will provide a clearer picture for the chainsaw
1527 class. This will provide a clearer picture for the chainsaw
1523 branch refactoring.
1528 branch refactoring.
1524
1529
1525 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
1530 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
1526
1531
1527 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
1532 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
1528 failures for objects which break when dir() is called on them.
1533 failures for objects which break when dir() is called on them.
1529
1534
1530 * IPython/FlexCompleter.py (Completer.__init__): Added support for
1535 * IPython/FlexCompleter.py (Completer.__init__): Added support for
1531 distinct local and global namespaces in the completer API. This
1536 distinct local and global namespaces in the completer API. This
1532 change allows us to properly handle completion with distinct
1537 change allows us to properly handle completion with distinct
1533 scopes, including in embedded instances (this had never really
1538 scopes, including in embedded instances (this had never really
1534 worked correctly).
1539 worked correctly).
1535
1540
1536 Note: this introduces a change in the constructor for
1541 Note: this introduces a change in the constructor for
1537 MagicCompleter, as a new global_namespace parameter is now the
1542 MagicCompleter, as a new global_namespace parameter is now the
1538 second argument (the others were bumped one position).
1543 second argument (the others were bumped one position).
1539
1544
1540 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
1545 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
1541
1546
1542 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1547 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1543 embedded instances (which can be done now thanks to Vivian's
1548 embedded instances (which can be done now thanks to Vivian's
1544 frame-handling fixes for pdb).
1549 frame-handling fixes for pdb).
1545 (InteractiveShell.__init__): Fix namespace handling problem in
1550 (InteractiveShell.__init__): Fix namespace handling problem in
1546 embedded instances. We were overwriting __main__ unconditionally,
1551 embedded instances. We were overwriting __main__ unconditionally,
1547 and this should only be done for 'full' (non-embedded) IPython;
1552 and this should only be done for 'full' (non-embedded) IPython;
1548 embedded instances must respect the caller's __main__. Thanks to
1553 embedded instances must respect the caller's __main__. Thanks to
1549 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
1554 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
1550
1555
1551 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
1556 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
1552
1557
1553 * setup.py: added download_url to setup(). This registers the
1558 * setup.py: added download_url to setup(). This registers the
1554 download address at PyPI, which is not only useful to humans
1559 download address at PyPI, which is not only useful to humans
1555 browsing the site, but is also picked up by setuptools (the Eggs
1560 browsing the site, but is also picked up by setuptools (the Eggs
1556 machinery). Thanks to Ville and R. Kern for the info/discussion
1561 machinery). Thanks to Ville and R. Kern for the info/discussion
1557 on this.
1562 on this.
1558
1563
1559 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
1564 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
1560
1565
1561 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
1566 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
1562 This brings a lot of nice functionality to the pdb mode, which now
1567 This brings a lot of nice functionality to the pdb mode, which now
1563 has tab-completion, syntax highlighting, and better stack handling
1568 has tab-completion, syntax highlighting, and better stack handling
1564 than before. Many thanks to Vivian De Smedt
1569 than before. Many thanks to Vivian De Smedt
1565 <vivian-AT-vdesmedt.com> for the original patches.
1570 <vivian-AT-vdesmedt.com> for the original patches.
1566
1571
1567 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
1572 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
1568
1573
1569 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
1574 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
1570 sequence to consistently accept the banner argument. The
1575 sequence to consistently accept the banner argument. The
1571 inconsistency was tripping SAGE, thanks to Gary Zablackis
1576 inconsistency was tripping SAGE, thanks to Gary Zablackis
1572 <gzabl-AT-yahoo.com> for the report.
1577 <gzabl-AT-yahoo.com> for the report.
1573
1578
1574 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1579 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1575
1580
1576 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1581 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1577 Fix bug where a naked 'alias' call in the ipythonrc file would
1582 Fix bug where a naked 'alias' call in the ipythonrc file would
1578 cause a crash. Bug reported by Jorgen Stenarson.
1583 cause a crash. Bug reported by Jorgen Stenarson.
1579
1584
1580 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1585 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1581
1586
1582 * IPython/ipmaker.py (make_IPython): cleanups which should improve
1587 * IPython/ipmaker.py (make_IPython): cleanups which should improve
1583 startup time.
1588 startup time.
1584
1589
1585 * IPython/iplib.py (runcode): my globals 'fix' for embedded
1590 * IPython/iplib.py (runcode): my globals 'fix' for embedded
1586 instances had introduced a bug with globals in normal code. Now
1591 instances had introduced a bug with globals in normal code. Now
1587 it's working in all cases.
1592 it's working in all cases.
1588
1593
1589 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
1594 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
1590 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
1595 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
1591 has been introduced to set the default case sensitivity of the
1596 has been introduced to set the default case sensitivity of the
1592 searches. Users can still select either mode at runtime on a
1597 searches. Users can still select either mode at runtime on a
1593 per-search basis.
1598 per-search basis.
1594
1599
1595 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
1600 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
1596
1601
1597 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
1602 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
1598 attributes in wildcard searches for subclasses. Modified version
1603 attributes in wildcard searches for subclasses. Modified version
1599 of a patch by Jorgen.
1604 of a patch by Jorgen.
1600
1605
1601 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
1606 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
1602
1607
1603 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
1608 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
1604 embedded instances. I added a user_global_ns attribute to the
1609 embedded instances. I added a user_global_ns attribute to the
1605 InteractiveShell class to handle this.
1610 InteractiveShell class to handle this.
1606
1611
1607 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
1612 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
1608
1613
1609 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
1614 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
1610 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
1615 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
1611 (reported under win32, but may happen also in other platforms).
1616 (reported under win32, but may happen also in other platforms).
1612 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
1617 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
1613
1618
1614 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
1619 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
1615
1620
1616 * IPython/Magic.py (magic_psearch): new support for wildcard
1621 * IPython/Magic.py (magic_psearch): new support for wildcard
1617 patterns. Now, typing ?a*b will list all names which begin with a
1622 patterns. Now, typing ?a*b will list all names which begin with a
1618 and end in b, for example. The %psearch magic has full
1623 and end in b, for example. The %psearch magic has full
1619 docstrings. Many thanks to JΓΆrgen Stenarson
1624 docstrings. Many thanks to JΓΆrgen Stenarson
1620 <jorgen.stenarson-AT-bostream.nu>, author of the patches
1625 <jorgen.stenarson-AT-bostream.nu>, author of the patches
1621 implementing this functionality.
1626 implementing this functionality.
1622
1627
1623 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1628 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1624
1629
1625 * Manual: fixed long-standing annoyance of double-dashes (as in
1630 * Manual: fixed long-standing annoyance of double-dashes (as in
1626 --prefix=~, for example) being stripped in the HTML version. This
1631 --prefix=~, for example) being stripped in the HTML version. This
1627 is a latex2html bug, but a workaround was provided. Many thanks
1632 is a latex2html bug, but a workaround was provided. Many thanks
1628 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
1633 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
1629 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
1634 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
1630 rolling. This seemingly small issue had tripped a number of users
1635 rolling. This seemingly small issue had tripped a number of users
1631 when first installing, so I'm glad to see it gone.
1636 when first installing, so I'm glad to see it gone.
1632
1637
1633 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1638 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1634
1639
1635 * IPython/Extensions/numeric_formats.py: fix missing import,
1640 * IPython/Extensions/numeric_formats.py: fix missing import,
1636 reported by Stephen Walton.
1641 reported by Stephen Walton.
1637
1642
1638 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
1643 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
1639
1644
1640 * IPython/demo.py: finish demo module, fully documented now.
1645 * IPython/demo.py: finish demo module, fully documented now.
1641
1646
1642 * IPython/genutils.py (file_read): simple little utility to read a
1647 * IPython/genutils.py (file_read): simple little utility to read a
1643 file and ensure it's closed afterwards.
1648 file and ensure it's closed afterwards.
1644
1649
1645 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
1650 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
1646
1651
1647 * IPython/demo.py (Demo.__init__): added support for individually
1652 * IPython/demo.py (Demo.__init__): added support for individually
1648 tagging blocks for automatic execution.
1653 tagging blocks for automatic execution.
1649
1654
1650 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
1655 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
1651 syntax-highlighted python sources, requested by John.
1656 syntax-highlighted python sources, requested by John.
1652
1657
1653 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
1658 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
1654
1659
1655 * IPython/demo.py (Demo.again): fix bug where again() blocks after
1660 * IPython/demo.py (Demo.again): fix bug where again() blocks after
1656 finishing.
1661 finishing.
1657
1662
1658 * IPython/genutils.py (shlex_split): moved from Magic to here,
1663 * IPython/genutils.py (shlex_split): moved from Magic to here,
1659 where all 2.2 compatibility stuff lives. I needed it for demo.py.
1664 where all 2.2 compatibility stuff lives. I needed it for demo.py.
1660
1665
1661 * IPython/demo.py (Demo.__init__): added support for silent
1666 * IPython/demo.py (Demo.__init__): added support for silent
1662 blocks, improved marks as regexps, docstrings written.
1667 blocks, improved marks as regexps, docstrings written.
1663 (Demo.__init__): better docstring, added support for sys.argv.
1668 (Demo.__init__): better docstring, added support for sys.argv.
1664
1669
1665 * IPython/genutils.py (marquee): little utility used by the demo
1670 * IPython/genutils.py (marquee): little utility used by the demo
1666 code, handy in general.
1671 code, handy in general.
1667
1672
1668 * IPython/demo.py (Demo.__init__): new class for interactive
1673 * IPython/demo.py (Demo.__init__): new class for interactive
1669 demos. Not documented yet, I just wrote it in a hurry for
1674 demos. Not documented yet, I just wrote it in a hurry for
1670 scipy'05. Will docstring later.
1675 scipy'05. Will docstring later.
1671
1676
1672 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
1677 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
1673
1678
1674 * IPython/Shell.py (sigint_handler): Drastic simplification which
1679 * IPython/Shell.py (sigint_handler): Drastic simplification which
1675 also seems to make Ctrl-C work correctly across threads! This is
1680 also seems to make Ctrl-C work correctly across threads! This is
1676 so simple, that I can't beleive I'd missed it before. Needs more
1681 so simple, that I can't beleive I'd missed it before. Needs more
1677 testing, though.
1682 testing, though.
1678 (KBINT): Never mind, revert changes. I'm sure I'd tried something
1683 (KBINT): Never mind, revert changes. I'm sure I'd tried something
1679 like this before...
1684 like this before...
1680
1685
1681 * IPython/genutils.py (get_home_dir): add protection against
1686 * IPython/genutils.py (get_home_dir): add protection against
1682 non-dirs in win32 registry.
1687 non-dirs in win32 registry.
1683
1688
1684 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
1689 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
1685 bug where dict was mutated while iterating (pysh crash).
1690 bug where dict was mutated while iterating (pysh crash).
1686
1691
1687 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
1692 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
1688
1693
1689 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
1694 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
1690 spurious newlines added by this routine. After a report by
1695 spurious newlines added by this routine. After a report by
1691 F. Mantegazza.
1696 F. Mantegazza.
1692
1697
1693 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
1698 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
1694
1699
1695 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
1700 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
1696 calls. These were a leftover from the GTK 1.x days, and can cause
1701 calls. These were a leftover from the GTK 1.x days, and can cause
1697 problems in certain cases (after a report by John Hunter).
1702 problems in certain cases (after a report by John Hunter).
1698
1703
1699 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
1704 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
1700 os.getcwd() fails at init time. Thanks to patch from David Remahl
1705 os.getcwd() fails at init time. Thanks to patch from David Remahl
1701 <chmod007-AT-mac.com>.
1706 <chmod007-AT-mac.com>.
1702 (InteractiveShell.__init__): prevent certain special magics from
1707 (InteractiveShell.__init__): prevent certain special magics from
1703 being shadowed by aliases. Closes
1708 being shadowed by aliases. Closes
1704 http://www.scipy.net/roundup/ipython/issue41.
1709 http://www.scipy.net/roundup/ipython/issue41.
1705
1710
1706 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
1711 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
1707
1712
1708 * IPython/iplib.py (InteractiveShell.complete): Added new
1713 * IPython/iplib.py (InteractiveShell.complete): Added new
1709 top-level completion method to expose the completion mechanism
1714 top-level completion method to expose the completion mechanism
1710 beyond readline-based environments.
1715 beyond readline-based environments.
1711
1716
1712 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
1717 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
1713
1718
1714 * tools/ipsvnc (svnversion): fix svnversion capture.
1719 * tools/ipsvnc (svnversion): fix svnversion capture.
1715
1720
1716 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
1721 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
1717 attribute to self, which was missing. Before, it was set by a
1722 attribute to self, which was missing. Before, it was set by a
1718 routine which in certain cases wasn't being called, so the
1723 routine which in certain cases wasn't being called, so the
1719 instance could end up missing the attribute. This caused a crash.
1724 instance could end up missing the attribute. This caused a crash.
1720 Closes http://www.scipy.net/roundup/ipython/issue40.
1725 Closes http://www.scipy.net/roundup/ipython/issue40.
1721
1726
1722 2005-08-16 Fernando Perez <fperez@colorado.edu>
1727 2005-08-16 Fernando Perez <fperez@colorado.edu>
1723
1728
1724 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
1729 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
1725 contains non-string attribute. Closes
1730 contains non-string attribute. Closes
1726 http://www.scipy.net/roundup/ipython/issue38.
1731 http://www.scipy.net/roundup/ipython/issue38.
1727
1732
1728 2005-08-14 Fernando Perez <fperez@colorado.edu>
1733 2005-08-14 Fernando Perez <fperez@colorado.edu>
1729
1734
1730 * tools/ipsvnc: Minor improvements, to add changeset info.
1735 * tools/ipsvnc: Minor improvements, to add changeset info.
1731
1736
1732 2005-08-12 Fernando Perez <fperez@colorado.edu>
1737 2005-08-12 Fernando Perez <fperez@colorado.edu>
1733
1738
1734 * IPython/iplib.py (runsource): remove self.code_to_run_src
1739 * IPython/iplib.py (runsource): remove self.code_to_run_src
1735 attribute. I realized this is nothing more than
1740 attribute. I realized this is nothing more than
1736 '\n'.join(self.buffer), and having the same data in two different
1741 '\n'.join(self.buffer), and having the same data in two different
1737 places is just asking for synchronization bugs. This may impact
1742 places is just asking for synchronization bugs. This may impact
1738 people who have custom exception handlers, so I need to warn
1743 people who have custom exception handlers, so I need to warn
1739 ipython-dev about it (F. Mantegazza may use them).
1744 ipython-dev about it (F. Mantegazza may use them).
1740
1745
1741 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
1746 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
1742
1747
1743 * IPython/genutils.py: fix 2.2 compatibility (generators)
1748 * IPython/genutils.py: fix 2.2 compatibility (generators)
1744
1749
1745 2005-07-18 Fernando Perez <fperez@colorado.edu>
1750 2005-07-18 Fernando Perez <fperez@colorado.edu>
1746
1751
1747 * IPython/genutils.py (get_home_dir): fix to help users with
1752 * IPython/genutils.py (get_home_dir): fix to help users with
1748 invalid $HOME under win32.
1753 invalid $HOME under win32.
1749
1754
1750 2005-07-17 Fernando Perez <fperez@colorado.edu>
1755 2005-07-17 Fernando Perez <fperez@colorado.edu>
1751
1756
1752 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
1757 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
1753 some old hacks and clean up a bit other routines; code should be
1758 some old hacks and clean up a bit other routines; code should be
1754 simpler and a bit faster.
1759 simpler and a bit faster.
1755
1760
1756 * IPython/iplib.py (interact): removed some last-resort attempts
1761 * IPython/iplib.py (interact): removed some last-resort attempts
1757 to survive broken stdout/stderr. That code was only making it
1762 to survive broken stdout/stderr. That code was only making it
1758 harder to abstract out the i/o (necessary for gui integration),
1763 harder to abstract out the i/o (necessary for gui integration),
1759 and the crashes it could prevent were extremely rare in practice
1764 and the crashes it could prevent were extremely rare in practice
1760 (besides being fully user-induced in a pretty violent manner).
1765 (besides being fully user-induced in a pretty violent manner).
1761
1766
1762 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
1767 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
1763 Nothing major yet, but the code is simpler to read; this should
1768 Nothing major yet, but the code is simpler to read; this should
1764 make it easier to do more serious modifications in the future.
1769 make it easier to do more serious modifications in the future.
1765
1770
1766 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
1771 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
1767 which broke in .15 (thanks to a report by Ville).
1772 which broke in .15 (thanks to a report by Ville).
1768
1773
1769 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
1774 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
1770 be quite correct, I know next to nothing about unicode). This
1775 be quite correct, I know next to nothing about unicode). This
1771 will allow unicode strings to be used in prompts, amongst other
1776 will allow unicode strings to be used in prompts, amongst other
1772 cases. It also will prevent ipython from crashing when unicode
1777 cases. It also will prevent ipython from crashing when unicode
1773 shows up unexpectedly in many places. If ascii encoding fails, we
1778 shows up unexpectedly in many places. If ascii encoding fails, we
1774 assume utf_8. Currently the encoding is not a user-visible
1779 assume utf_8. Currently the encoding is not a user-visible
1775 setting, though it could be made so if there is demand for it.
1780 setting, though it could be made so if there is demand for it.
1776
1781
1777 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
1782 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
1778
1783
1779 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
1784 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
1780
1785
1781 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
1786 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
1782
1787
1783 * IPython/genutils.py: Add 2.2 compatibility here, so all other
1788 * IPython/genutils.py: Add 2.2 compatibility here, so all other
1784 code can work transparently for 2.2/2.3.
1789 code can work transparently for 2.2/2.3.
1785
1790
1786 2005-07-16 Fernando Perez <fperez@colorado.edu>
1791 2005-07-16 Fernando Perez <fperez@colorado.edu>
1787
1792
1788 * IPython/ultraTB.py (ExceptionColors): Make a global variable
1793 * IPython/ultraTB.py (ExceptionColors): Make a global variable
1789 out of the color scheme table used for coloring exception
1794 out of the color scheme table used for coloring exception
1790 tracebacks. This allows user code to add new schemes at runtime.
1795 tracebacks. This allows user code to add new schemes at runtime.
1791 This is a minimally modified version of the patch at
1796 This is a minimally modified version of the patch at
1792 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
1797 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
1793 for the contribution.
1798 for the contribution.
1794
1799
1795 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
1800 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
1796 slightly modified version of the patch in
1801 slightly modified version of the patch in
1797 http://www.scipy.net/roundup/ipython/issue34, which also allows me
1802 http://www.scipy.net/roundup/ipython/issue34, which also allows me
1798 to remove the previous try/except solution (which was costlier).
1803 to remove the previous try/except solution (which was costlier).
1799 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
1804 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
1800
1805
1801 2005-06-08 Fernando Perez <fperez@colorado.edu>
1806 2005-06-08 Fernando Perez <fperez@colorado.edu>
1802
1807
1803 * IPython/iplib.py (write/write_err): Add methods to abstract all
1808 * IPython/iplib.py (write/write_err): Add methods to abstract all
1804 I/O a bit more.
1809 I/O a bit more.
1805
1810
1806 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
1811 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
1807 warning, reported by Aric Hagberg, fix by JD Hunter.
1812 warning, reported by Aric Hagberg, fix by JD Hunter.
1808
1813
1809 2005-06-02 *** Released version 0.6.15
1814 2005-06-02 *** Released version 0.6.15
1810
1815
1811 2005-06-01 Fernando Perez <fperez@colorado.edu>
1816 2005-06-01 Fernando Perez <fperez@colorado.edu>
1812
1817
1813 * IPython/iplib.py (MagicCompleter.file_matches): Fix
1818 * IPython/iplib.py (MagicCompleter.file_matches): Fix
1814 tab-completion of filenames within open-quoted strings. Note that
1819 tab-completion of filenames within open-quoted strings. Note that
1815 this requires that in ~/.ipython/ipythonrc, users change the
1820 this requires that in ~/.ipython/ipythonrc, users change the
1816 readline delimiters configuration to read:
1821 readline delimiters configuration to read:
1817
1822
1818 readline_remove_delims -/~
1823 readline_remove_delims -/~
1819
1824
1820
1825
1821 2005-05-31 *** Released version 0.6.14
1826 2005-05-31 *** Released version 0.6.14
1822
1827
1823 2005-05-29 Fernando Perez <fperez@colorado.edu>
1828 2005-05-29 Fernando Perez <fperez@colorado.edu>
1824
1829
1825 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
1830 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
1826 with files not on the filesystem. Reported by Eliyahu Sandler
1831 with files not on the filesystem. Reported by Eliyahu Sandler
1827 <eli@gondolin.net>
1832 <eli@gondolin.net>
1828
1833
1829 2005-05-22 Fernando Perez <fperez@colorado.edu>
1834 2005-05-22 Fernando Perez <fperez@colorado.edu>
1830
1835
1831 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
1836 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
1832 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
1837 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
1833
1838
1834 2005-05-19 Fernando Perez <fperez@colorado.edu>
1839 2005-05-19 Fernando Perez <fperez@colorado.edu>
1835
1840
1836 * IPython/iplib.py (safe_execfile): close a file which could be
1841 * IPython/iplib.py (safe_execfile): close a file which could be
1837 left open (causing problems in win32, which locks open files).
1842 left open (causing problems in win32, which locks open files).
1838 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
1843 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
1839
1844
1840 2005-05-18 Fernando Perez <fperez@colorado.edu>
1845 2005-05-18 Fernando Perez <fperez@colorado.edu>
1841
1846
1842 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
1847 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
1843 keyword arguments correctly to safe_execfile().
1848 keyword arguments correctly to safe_execfile().
1844
1849
1845 2005-05-13 Fernando Perez <fperez@colorado.edu>
1850 2005-05-13 Fernando Perez <fperez@colorado.edu>
1846
1851
1847 * ipython.1: Added info about Qt to manpage, and threads warning
1852 * ipython.1: Added info about Qt to manpage, and threads warning
1848 to usage page (invoked with --help).
1853 to usage page (invoked with --help).
1849
1854
1850 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
1855 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
1851 new matcher (it goes at the end of the priority list) to do
1856 new matcher (it goes at the end of the priority list) to do
1852 tab-completion on named function arguments. Submitted by George
1857 tab-completion on named function arguments. Submitted by George
1853 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
1858 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
1854 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
1859 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
1855 for more details.
1860 for more details.
1856
1861
1857 * IPython/Magic.py (magic_run): Added new -e flag to ignore
1862 * IPython/Magic.py (magic_run): Added new -e flag to ignore
1858 SystemExit exceptions in the script being run. Thanks to a report
1863 SystemExit exceptions in the script being run. Thanks to a report
1859 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
1864 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
1860 producing very annoying behavior when running unit tests.
1865 producing very annoying behavior when running unit tests.
1861
1866
1862 2005-05-12 Fernando Perez <fperez@colorado.edu>
1867 2005-05-12 Fernando Perez <fperez@colorado.edu>
1863
1868
1864 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
1869 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
1865 which I'd broken (again) due to a changed regexp. In the process,
1870 which I'd broken (again) due to a changed regexp. In the process,
1866 added ';' as an escape to auto-quote the whole line without
1871 added ';' as an escape to auto-quote the whole line without
1867 splitting its arguments. Thanks to a report by Jerry McRae
1872 splitting its arguments. Thanks to a report by Jerry McRae
1868 <qrs0xyc02-AT-sneakemail.com>.
1873 <qrs0xyc02-AT-sneakemail.com>.
1869
1874
1870 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
1875 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
1871 possible crashes caused by a TokenError. Reported by Ed Schofield
1876 possible crashes caused by a TokenError. Reported by Ed Schofield
1872 <schofield-AT-ftw.at>.
1877 <schofield-AT-ftw.at>.
1873
1878
1874 2005-05-06 Fernando Perez <fperez@colorado.edu>
1879 2005-05-06 Fernando Perez <fperez@colorado.edu>
1875
1880
1876 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
1881 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
1877
1882
1878 2005-04-29 Fernando Perez <fperez@colorado.edu>
1883 2005-04-29 Fernando Perez <fperez@colorado.edu>
1879
1884
1880 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
1885 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
1881 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
1886 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
1882 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
1887 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
1883 which provides support for Qt interactive usage (similar to the
1888 which provides support for Qt interactive usage (similar to the
1884 existing one for WX and GTK). This had been often requested.
1889 existing one for WX and GTK). This had been often requested.
1885
1890
1886 2005-04-14 *** Released version 0.6.13
1891 2005-04-14 *** Released version 0.6.13
1887
1892
1888 2005-04-08 Fernando Perez <fperez@colorado.edu>
1893 2005-04-08 Fernando Perez <fperez@colorado.edu>
1889
1894
1890 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
1895 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
1891 from _ofind, which gets called on almost every input line. Now,
1896 from _ofind, which gets called on almost every input line. Now,
1892 we only try to get docstrings if they are actually going to be
1897 we only try to get docstrings if they are actually going to be
1893 used (the overhead of fetching unnecessary docstrings can be
1898 used (the overhead of fetching unnecessary docstrings can be
1894 noticeable for certain objects, such as Pyro proxies).
1899 noticeable for certain objects, such as Pyro proxies).
1895
1900
1896 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
1901 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
1897 for completers. For some reason I had been passing them the state
1902 for completers. For some reason I had been passing them the state
1898 variable, which completers never actually need, and was in
1903 variable, which completers never actually need, and was in
1899 conflict with the rlcompleter API. Custom completers ONLY need to
1904 conflict with the rlcompleter API. Custom completers ONLY need to
1900 take the text parameter.
1905 take the text parameter.
1901
1906
1902 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
1907 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
1903 work correctly in pysh. I've also moved all the logic which used
1908 work correctly in pysh. I've also moved all the logic which used
1904 to be in pysh.py here, which will prevent problems with future
1909 to be in pysh.py here, which will prevent problems with future
1905 upgrades. However, this time I must warn users to update their
1910 upgrades. However, this time I must warn users to update their
1906 pysh profile to include the line
1911 pysh profile to include the line
1907
1912
1908 import_all IPython.Extensions.InterpreterExec
1913 import_all IPython.Extensions.InterpreterExec
1909
1914
1910 because otherwise things won't work for them. They MUST also
1915 because otherwise things won't work for them. They MUST also
1911 delete pysh.py and the line
1916 delete pysh.py and the line
1912
1917
1913 execfile pysh.py
1918 execfile pysh.py
1914
1919
1915 from their ipythonrc-pysh.
1920 from their ipythonrc-pysh.
1916
1921
1917 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
1922 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
1918 robust in the face of objects whose dir() returns non-strings
1923 robust in the face of objects whose dir() returns non-strings
1919 (which it shouldn't, but some broken libs like ITK do). Thanks to
1924 (which it shouldn't, but some broken libs like ITK do). Thanks to
1920 a patch by John Hunter (implemented differently, though). Also
1925 a patch by John Hunter (implemented differently, though). Also
1921 minor improvements by using .extend instead of + on lists.
1926 minor improvements by using .extend instead of + on lists.
1922
1927
1923 * pysh.py:
1928 * pysh.py:
1924
1929
1925 2005-04-06 Fernando Perez <fperez@colorado.edu>
1930 2005-04-06 Fernando Perez <fperez@colorado.edu>
1926
1931
1927 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
1932 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
1928 by default, so that all users benefit from it. Those who don't
1933 by default, so that all users benefit from it. Those who don't
1929 want it can still turn it off.
1934 want it can still turn it off.
1930
1935
1931 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
1936 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
1932 config file, I'd forgotten about this, so users were getting it
1937 config file, I'd forgotten about this, so users were getting it
1933 off by default.
1938 off by default.
1934
1939
1935 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
1940 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
1936 consistency. Now magics can be called in multiline statements,
1941 consistency. Now magics can be called in multiline statements,
1937 and python variables can be expanded in magic calls via $var.
1942 and python variables can be expanded in magic calls via $var.
1938 This makes the magic system behave just like aliases or !system
1943 This makes the magic system behave just like aliases or !system
1939 calls.
1944 calls.
1940
1945
1941 2005-03-28 Fernando Perez <fperez@colorado.edu>
1946 2005-03-28 Fernando Perez <fperez@colorado.edu>
1942
1947
1943 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
1948 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
1944 expensive string additions for building command. Add support for
1949 expensive string additions for building command. Add support for
1945 trailing ';' when autocall is used.
1950 trailing ';' when autocall is used.
1946
1951
1947 2005-03-26 Fernando Perez <fperez@colorado.edu>
1952 2005-03-26 Fernando Perez <fperez@colorado.edu>
1948
1953
1949 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
1954 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
1950 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
1955 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
1951 ipython.el robust against prompts with any number of spaces
1956 ipython.el robust against prompts with any number of spaces
1952 (including 0) after the ':' character.
1957 (including 0) after the ':' character.
1953
1958
1954 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
1959 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
1955 continuation prompt, which misled users to think the line was
1960 continuation prompt, which misled users to think the line was
1956 already indented. Closes debian Bug#300847, reported to me by
1961 already indented. Closes debian Bug#300847, reported to me by
1957 Norbert Tretkowski <tretkowski-AT-inittab.de>.
1962 Norbert Tretkowski <tretkowski-AT-inittab.de>.
1958
1963
1959 2005-03-23 Fernando Perez <fperez@colorado.edu>
1964 2005-03-23 Fernando Perez <fperez@colorado.edu>
1960
1965
1961 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
1966 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
1962 properly aligned if they have embedded newlines.
1967 properly aligned if they have embedded newlines.
1963
1968
1964 * IPython/iplib.py (runlines): Add a public method to expose
1969 * IPython/iplib.py (runlines): Add a public method to expose
1965 IPython's code execution machinery, so that users can run strings
1970 IPython's code execution machinery, so that users can run strings
1966 as if they had been typed at the prompt interactively.
1971 as if they had been typed at the prompt interactively.
1967 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
1972 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
1968 methods which can call the system shell, but with python variable
1973 methods which can call the system shell, but with python variable
1969 expansion. The three such methods are: __IPYTHON__.system,
1974 expansion. The three such methods are: __IPYTHON__.system,
1970 .getoutput and .getoutputerror. These need to be documented in a
1975 .getoutput and .getoutputerror. These need to be documented in a
1971 'public API' section (to be written) of the manual.
1976 'public API' section (to be written) of the manual.
1972
1977
1973 2005-03-20 Fernando Perez <fperez@colorado.edu>
1978 2005-03-20 Fernando Perez <fperez@colorado.edu>
1974
1979
1975 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
1980 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
1976 for custom exception handling. This is quite powerful, and it
1981 for custom exception handling. This is quite powerful, and it
1977 allows for user-installable exception handlers which can trap
1982 allows for user-installable exception handlers which can trap
1978 custom exceptions at runtime and treat them separately from
1983 custom exceptions at runtime and treat them separately from
1979 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
1984 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
1980 Mantegazza <mantegazza-AT-ill.fr>.
1985 Mantegazza <mantegazza-AT-ill.fr>.
1981 (InteractiveShell.set_custom_completer): public API function to
1986 (InteractiveShell.set_custom_completer): public API function to
1982 add new completers at runtime.
1987 add new completers at runtime.
1983
1988
1984 2005-03-19 Fernando Perez <fperez@colorado.edu>
1989 2005-03-19 Fernando Perez <fperez@colorado.edu>
1985
1990
1986 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
1991 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
1987 allow objects which provide their docstrings via non-standard
1992 allow objects which provide their docstrings via non-standard
1988 mechanisms (like Pyro proxies) to still be inspected by ipython's
1993 mechanisms (like Pyro proxies) to still be inspected by ipython's
1989 ? system.
1994 ? system.
1990
1995
1991 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
1996 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
1992 automatic capture system. I tried quite hard to make it work
1997 automatic capture system. I tried quite hard to make it work
1993 reliably, and simply failed. I tried many combinations with the
1998 reliably, and simply failed. I tried many combinations with the
1994 subprocess module, but eventually nothing worked in all needed
1999 subprocess module, but eventually nothing worked in all needed
1995 cases (not blocking stdin for the child, duplicating stdout
2000 cases (not blocking stdin for the child, duplicating stdout
1996 without blocking, etc). The new %sc/%sx still do capture to these
2001 without blocking, etc). The new %sc/%sx still do capture to these
1997 magical list/string objects which make shell use much more
2002 magical list/string objects which make shell use much more
1998 conveninent, so not all is lost.
2003 conveninent, so not all is lost.
1999
2004
2000 XXX - FIX MANUAL for the change above!
2005 XXX - FIX MANUAL for the change above!
2001
2006
2002 (runsource): I copied code.py's runsource() into ipython to modify
2007 (runsource): I copied code.py's runsource() into ipython to modify
2003 it a bit. Now the code object and source to be executed are
2008 it a bit. Now the code object and source to be executed are
2004 stored in ipython. This makes this info accessible to third-party
2009 stored in ipython. This makes this info accessible to third-party
2005 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
2010 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
2006 Mantegazza <mantegazza-AT-ill.fr>.
2011 Mantegazza <mantegazza-AT-ill.fr>.
2007
2012
2008 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
2013 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
2009 history-search via readline (like C-p/C-n). I'd wanted this for a
2014 history-search via readline (like C-p/C-n). I'd wanted this for a
2010 long time, but only recently found out how to do it. For users
2015 long time, but only recently found out how to do it. For users
2011 who already have their ipythonrc files made and want this, just
2016 who already have their ipythonrc files made and want this, just
2012 add:
2017 add:
2013
2018
2014 readline_parse_and_bind "\e[A": history-search-backward
2019 readline_parse_and_bind "\e[A": history-search-backward
2015 readline_parse_and_bind "\e[B": history-search-forward
2020 readline_parse_and_bind "\e[B": history-search-forward
2016
2021
2017 2005-03-18 Fernando Perez <fperez@colorado.edu>
2022 2005-03-18 Fernando Perez <fperez@colorado.edu>
2018
2023
2019 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
2024 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
2020 LSString and SList classes which allow transparent conversions
2025 LSString and SList classes which allow transparent conversions
2021 between list mode and whitespace-separated string.
2026 between list mode and whitespace-separated string.
2022 (magic_r): Fix recursion problem in %r.
2027 (magic_r): Fix recursion problem in %r.
2023
2028
2024 * IPython/genutils.py (LSString): New class to be used for
2029 * IPython/genutils.py (LSString): New class to be used for
2025 automatic storage of the results of all alias/system calls in _o
2030 automatic storage of the results of all alias/system calls in _o
2026 and _e (stdout/err). These provide a .l/.list attribute which
2031 and _e (stdout/err). These provide a .l/.list attribute which
2027 does automatic splitting on newlines. This means that for most
2032 does automatic splitting on newlines. This means that for most
2028 uses, you'll never need to do capturing of output with %sc/%sx
2033 uses, you'll never need to do capturing of output with %sc/%sx
2029 anymore, since ipython keeps this always done for you. Note that
2034 anymore, since ipython keeps this always done for you. Note that
2030 only the LAST results are stored, the _o/e variables are
2035 only the LAST results are stored, the _o/e variables are
2031 overwritten on each call. If you need to save their contents
2036 overwritten on each call. If you need to save their contents
2032 further, simply bind them to any other name.
2037 further, simply bind them to any other name.
2033
2038
2034 2005-03-17 Fernando Perez <fperez@colorado.edu>
2039 2005-03-17 Fernando Perez <fperez@colorado.edu>
2035
2040
2036 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
2041 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
2037 prompt namespace handling.
2042 prompt namespace handling.
2038
2043
2039 2005-03-16 Fernando Perez <fperez@colorado.edu>
2044 2005-03-16 Fernando Perez <fperez@colorado.edu>
2040
2045
2041 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
2046 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
2042 classic prompts to be '>>> ' (final space was missing, and it
2047 classic prompts to be '>>> ' (final space was missing, and it
2043 trips the emacs python mode).
2048 trips the emacs python mode).
2044 (BasePrompt.__str__): Added safe support for dynamic prompt
2049 (BasePrompt.__str__): Added safe support for dynamic prompt
2045 strings. Now you can set your prompt string to be '$x', and the
2050 strings. Now you can set your prompt string to be '$x', and the
2046 value of x will be printed from your interactive namespace. The
2051 value of x will be printed from your interactive namespace. The
2047 interpolation syntax includes the full Itpl support, so
2052 interpolation syntax includes the full Itpl support, so
2048 ${foo()+x+bar()} is a valid prompt string now, and the function
2053 ${foo()+x+bar()} is a valid prompt string now, and the function
2049 calls will be made at runtime.
2054 calls will be made at runtime.
2050
2055
2051 2005-03-15 Fernando Perez <fperez@colorado.edu>
2056 2005-03-15 Fernando Perez <fperez@colorado.edu>
2052
2057
2053 * IPython/Magic.py (magic_history): renamed %hist to %history, to
2058 * IPython/Magic.py (magic_history): renamed %hist to %history, to
2054 avoid name clashes in pylab. %hist still works, it just forwards
2059 avoid name clashes in pylab. %hist still works, it just forwards
2055 the call to %history.
2060 the call to %history.
2056
2061
2057 2005-03-02 *** Released version 0.6.12
2062 2005-03-02 *** Released version 0.6.12
2058
2063
2059 2005-03-02 Fernando Perez <fperez@colorado.edu>
2064 2005-03-02 Fernando Perez <fperez@colorado.edu>
2060
2065
2061 * IPython/iplib.py (handle_magic): log magic calls properly as
2066 * IPython/iplib.py (handle_magic): log magic calls properly as
2062 ipmagic() function calls.
2067 ipmagic() function calls.
2063
2068
2064 * IPython/Magic.py (magic_time): Improved %time to support
2069 * IPython/Magic.py (magic_time): Improved %time to support
2065 statements and provide wall-clock as well as CPU time.
2070 statements and provide wall-clock as well as CPU time.
2066
2071
2067 2005-02-27 Fernando Perez <fperez@colorado.edu>
2072 2005-02-27 Fernando Perez <fperez@colorado.edu>
2068
2073
2069 * IPython/hooks.py: New hooks module, to expose user-modifiable
2074 * IPython/hooks.py: New hooks module, to expose user-modifiable
2070 IPython functionality in a clean manner. For now only the editor
2075 IPython functionality in a clean manner. For now only the editor
2071 hook is actually written, and other thigns which I intend to turn
2076 hook is actually written, and other thigns which I intend to turn
2072 into proper hooks aren't yet there. The display and prefilter
2077 into proper hooks aren't yet there. The display and prefilter
2073 stuff, for example, should be hooks. But at least now the
2078 stuff, for example, should be hooks. But at least now the
2074 framework is in place, and the rest can be moved here with more
2079 framework is in place, and the rest can be moved here with more
2075 time later. IPython had had a .hooks variable for a long time for
2080 time later. IPython had had a .hooks variable for a long time for
2076 this purpose, but I'd never actually used it for anything.
2081 this purpose, but I'd never actually used it for anything.
2077
2082
2078 2005-02-26 Fernando Perez <fperez@colorado.edu>
2083 2005-02-26 Fernando Perez <fperez@colorado.edu>
2079
2084
2080 * IPython/ipmaker.py (make_IPython): make the default ipython
2085 * IPython/ipmaker.py (make_IPython): make the default ipython
2081 directory be called _ipython under win32, to follow more the
2086 directory be called _ipython under win32, to follow more the
2082 naming peculiarities of that platform (where buggy software like
2087 naming peculiarities of that platform (where buggy software like
2083 Visual Sourcesafe breaks with .named directories). Reported by
2088 Visual Sourcesafe breaks with .named directories). Reported by
2084 Ville Vainio.
2089 Ville Vainio.
2085
2090
2086 2005-02-23 Fernando Perez <fperez@colorado.edu>
2091 2005-02-23 Fernando Perez <fperez@colorado.edu>
2087
2092
2088 * IPython/iplib.py (InteractiveShell.__init__): removed a few
2093 * IPython/iplib.py (InteractiveShell.__init__): removed a few
2089 auto_aliases for win32 which were causing problems. Users can
2094 auto_aliases for win32 which were causing problems. Users can
2090 define the ones they personally like.
2095 define the ones they personally like.
2091
2096
2092 2005-02-21 Fernando Perez <fperez@colorado.edu>
2097 2005-02-21 Fernando Perez <fperez@colorado.edu>
2093
2098
2094 * IPython/Magic.py (magic_time): new magic to time execution of
2099 * IPython/Magic.py (magic_time): new magic to time execution of
2095 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
2100 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
2096
2101
2097 2005-02-19 Fernando Perez <fperez@colorado.edu>
2102 2005-02-19 Fernando Perez <fperez@colorado.edu>
2098
2103
2099 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
2104 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
2100 into keys (for prompts, for example).
2105 into keys (for prompts, for example).
2101
2106
2102 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
2107 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
2103 prompts in case users want them. This introduces a small behavior
2108 prompts in case users want them. This introduces a small behavior
2104 change: ipython does not automatically add a space to all prompts
2109 change: ipython does not automatically add a space to all prompts
2105 anymore. To get the old prompts with a space, users should add it
2110 anymore. To get the old prompts with a space, users should add it
2106 manually to their ipythonrc file, so for example prompt_in1 should
2111 manually to their ipythonrc file, so for example prompt_in1 should
2107 now read 'In [\#]: ' instead of 'In [\#]:'.
2112 now read 'In [\#]: ' instead of 'In [\#]:'.
2108 (BasePrompt.__init__): New option prompts_pad_left (only in rc
2113 (BasePrompt.__init__): New option prompts_pad_left (only in rc
2109 file) to control left-padding of secondary prompts.
2114 file) to control left-padding of secondary prompts.
2110
2115
2111 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
2116 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
2112 the profiler can't be imported. Fix for Debian, which removed
2117 the profiler can't be imported. Fix for Debian, which removed
2113 profile.py because of License issues. I applied a slightly
2118 profile.py because of License issues. I applied a slightly
2114 modified version of the original Debian patch at
2119 modified version of the original Debian patch at
2115 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
2120 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
2116
2121
2117 2005-02-17 Fernando Perez <fperez@colorado.edu>
2122 2005-02-17 Fernando Perez <fperez@colorado.edu>
2118
2123
2119 * IPython/genutils.py (native_line_ends): Fix bug which would
2124 * IPython/genutils.py (native_line_ends): Fix bug which would
2120 cause improper line-ends under win32 b/c I was not opening files
2125 cause improper line-ends under win32 b/c I was not opening files
2121 in binary mode. Bug report and fix thanks to Ville.
2126 in binary mode. Bug report and fix thanks to Ville.
2122
2127
2123 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
2128 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
2124 trying to catch spurious foo[1] autocalls. My fix actually broke
2129 trying to catch spurious foo[1] autocalls. My fix actually broke
2125 ',/' autoquote/call with explicit escape (bad regexp).
2130 ',/' autoquote/call with explicit escape (bad regexp).
2126
2131
2127 2005-02-15 *** Released version 0.6.11
2132 2005-02-15 *** Released version 0.6.11
2128
2133
2129 2005-02-14 Fernando Perez <fperez@colorado.edu>
2134 2005-02-14 Fernando Perez <fperez@colorado.edu>
2130
2135
2131 * IPython/background_jobs.py: New background job management
2136 * IPython/background_jobs.py: New background job management
2132 subsystem. This is implemented via a new set of classes, and
2137 subsystem. This is implemented via a new set of classes, and
2133 IPython now provides a builtin 'jobs' object for background job
2138 IPython now provides a builtin 'jobs' object for background job
2134 execution. A convenience %bg magic serves as a lightweight
2139 execution. A convenience %bg magic serves as a lightweight
2135 frontend for starting the more common type of calls. This was
2140 frontend for starting the more common type of calls. This was
2136 inspired by discussions with B. Granger and the BackgroundCommand
2141 inspired by discussions with B. Granger and the BackgroundCommand
2137 class described in the book Python Scripting for Computational
2142 class described in the book Python Scripting for Computational
2138 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
2143 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
2139 (although ultimately no code from this text was used, as IPython's
2144 (although ultimately no code from this text was used, as IPython's
2140 system is a separate implementation).
2145 system is a separate implementation).
2141
2146
2142 * IPython/iplib.py (MagicCompleter.python_matches): add new option
2147 * IPython/iplib.py (MagicCompleter.python_matches): add new option
2143 to control the completion of single/double underscore names
2148 to control the completion of single/double underscore names
2144 separately. As documented in the example ipytonrc file, the
2149 separately. As documented in the example ipytonrc file, the
2145 readline_omit__names variable can now be set to 2, to omit even
2150 readline_omit__names variable can now be set to 2, to omit even
2146 single underscore names. Thanks to a patch by Brian Wong
2151 single underscore names. Thanks to a patch by Brian Wong
2147 <BrianWong-AT-AirgoNetworks.Com>.
2152 <BrianWong-AT-AirgoNetworks.Com>.
2148 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
2153 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
2149 be autocalled as foo([1]) if foo were callable. A problem for
2154 be autocalled as foo([1]) if foo were callable. A problem for
2150 things which are both callable and implement __getitem__.
2155 things which are both callable and implement __getitem__.
2151 (init_readline): Fix autoindentation for win32. Thanks to a patch
2156 (init_readline): Fix autoindentation for win32. Thanks to a patch
2152 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
2157 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
2153
2158
2154 2005-02-12 Fernando Perez <fperez@colorado.edu>
2159 2005-02-12 Fernando Perez <fperez@colorado.edu>
2155
2160
2156 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
2161 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
2157 which I had written long ago to sort out user error messages which
2162 which I had written long ago to sort out user error messages which
2158 may occur during startup. This seemed like a good idea initially,
2163 may occur during startup. This seemed like a good idea initially,
2159 but it has proven a disaster in retrospect. I don't want to
2164 but it has proven a disaster in retrospect. I don't want to
2160 change much code for now, so my fix is to set the internal 'debug'
2165 change much code for now, so my fix is to set the internal 'debug'
2161 flag to true everywhere, whose only job was precisely to control
2166 flag to true everywhere, whose only job was precisely to control
2162 this subsystem. This closes issue 28 (as well as avoiding all
2167 this subsystem. This closes issue 28 (as well as avoiding all
2163 sorts of strange hangups which occur from time to time).
2168 sorts of strange hangups which occur from time to time).
2164
2169
2165 2005-02-07 Fernando Perez <fperez@colorado.edu>
2170 2005-02-07 Fernando Perez <fperez@colorado.edu>
2166
2171
2167 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
2172 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
2168 previous call produced a syntax error.
2173 previous call produced a syntax error.
2169
2174
2170 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2175 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2171 classes without constructor.
2176 classes without constructor.
2172
2177
2173 2005-02-06 Fernando Perez <fperez@colorado.edu>
2178 2005-02-06 Fernando Perez <fperez@colorado.edu>
2174
2179
2175 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
2180 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
2176 completions with the results of each matcher, so we return results
2181 completions with the results of each matcher, so we return results
2177 to the user from all namespaces. This breaks with ipython
2182 to the user from all namespaces. This breaks with ipython
2178 tradition, but I think it's a nicer behavior. Now you get all
2183 tradition, but I think it's a nicer behavior. Now you get all
2179 possible completions listed, from all possible namespaces (python,
2184 possible completions listed, from all possible namespaces (python,
2180 filesystem, magics...) After a request by John Hunter
2185 filesystem, magics...) After a request by John Hunter
2181 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2186 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2182
2187
2183 2005-02-05 Fernando Perez <fperez@colorado.edu>
2188 2005-02-05 Fernando Perez <fperez@colorado.edu>
2184
2189
2185 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
2190 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
2186 the call had quote characters in it (the quotes were stripped).
2191 the call had quote characters in it (the quotes were stripped).
2187
2192
2188 2005-01-31 Fernando Perez <fperez@colorado.edu>
2193 2005-01-31 Fernando Perez <fperez@colorado.edu>
2189
2194
2190 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
2195 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
2191 Itpl.itpl() to make the code more robust against psyco
2196 Itpl.itpl() to make the code more robust against psyco
2192 optimizations.
2197 optimizations.
2193
2198
2194 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
2199 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
2195 of causing an exception. Quicker, cleaner.
2200 of causing an exception. Quicker, cleaner.
2196
2201
2197 2005-01-28 Fernando Perez <fperez@colorado.edu>
2202 2005-01-28 Fernando Perez <fperez@colorado.edu>
2198
2203
2199 * scripts/ipython_win_post_install.py (install): hardcode
2204 * scripts/ipython_win_post_install.py (install): hardcode
2200 sys.prefix+'python.exe' as the executable path. It turns out that
2205 sys.prefix+'python.exe' as the executable path. It turns out that
2201 during the post-installation run, sys.executable resolves to the
2206 during the post-installation run, sys.executable resolves to the
2202 name of the binary installer! I should report this as a distutils
2207 name of the binary installer! I should report this as a distutils
2203 bug, I think. I updated the .10 release with this tiny fix, to
2208 bug, I think. I updated the .10 release with this tiny fix, to
2204 avoid annoying the lists further.
2209 avoid annoying the lists further.
2205
2210
2206 2005-01-27 *** Released version 0.6.10
2211 2005-01-27 *** Released version 0.6.10
2207
2212
2208 2005-01-27 Fernando Perez <fperez@colorado.edu>
2213 2005-01-27 Fernando Perez <fperez@colorado.edu>
2209
2214
2210 * IPython/numutils.py (norm): Added 'inf' as optional name for
2215 * IPython/numutils.py (norm): Added 'inf' as optional name for
2211 L-infinity norm, included references to mathworld.com for vector
2216 L-infinity norm, included references to mathworld.com for vector
2212 norm definitions.
2217 norm definitions.
2213 (amin/amax): added amin/amax for array min/max. Similar to what
2218 (amin/amax): added amin/amax for array min/max. Similar to what
2214 pylab ships with after the recent reorganization of names.
2219 pylab ships with after the recent reorganization of names.
2215 (spike/spike_odd): removed deprecated spike/spike_odd functions.
2220 (spike/spike_odd): removed deprecated spike/spike_odd functions.
2216
2221
2217 * ipython.el: committed Alex's recent fixes and improvements.
2222 * ipython.el: committed Alex's recent fixes and improvements.
2218 Tested with python-mode from CVS, and it looks excellent. Since
2223 Tested with python-mode from CVS, and it looks excellent. Since
2219 python-mode hasn't released anything in a while, I'm temporarily
2224 python-mode hasn't released anything in a while, I'm temporarily
2220 putting a copy of today's CVS (v 4.70) of python-mode in:
2225 putting a copy of today's CVS (v 4.70) of python-mode in:
2221 http://ipython.scipy.org/tmp/python-mode.el
2226 http://ipython.scipy.org/tmp/python-mode.el
2222
2227
2223 * scripts/ipython_win_post_install.py (install): Win32 fix to use
2228 * scripts/ipython_win_post_install.py (install): Win32 fix to use
2224 sys.executable for the executable name, instead of assuming it's
2229 sys.executable for the executable name, instead of assuming it's
2225 called 'python.exe' (the post-installer would have produced broken
2230 called 'python.exe' (the post-installer would have produced broken
2226 setups on systems with a differently named python binary).
2231 setups on systems with a differently named python binary).
2227
2232
2228 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
2233 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
2229 references to os.linesep, to make the code more
2234 references to os.linesep, to make the code more
2230 platform-independent. This is also part of the win32 coloring
2235 platform-independent. This is also part of the win32 coloring
2231 fixes.
2236 fixes.
2232
2237
2233 * IPython/genutils.py (page_dumb): Remove attempts to chop long
2238 * IPython/genutils.py (page_dumb): Remove attempts to chop long
2234 lines, which actually cause coloring bugs because the length of
2239 lines, which actually cause coloring bugs because the length of
2235 the line is very difficult to correctly compute with embedded
2240 the line is very difficult to correctly compute with embedded
2236 escapes. This was the source of all the coloring problems under
2241 escapes. This was the source of all the coloring problems under
2237 Win32. I think that _finally_, Win32 users have a properly
2242 Win32. I think that _finally_, Win32 users have a properly
2238 working ipython in all respects. This would never have happened
2243 working ipython in all respects. This would never have happened
2239 if not for Gary Bishop and Viktor Ransmayr's great help and work.
2244 if not for Gary Bishop and Viktor Ransmayr's great help and work.
2240
2245
2241 2005-01-26 *** Released version 0.6.9
2246 2005-01-26 *** Released version 0.6.9
2242
2247
2243 2005-01-25 Fernando Perez <fperez@colorado.edu>
2248 2005-01-25 Fernando Perez <fperez@colorado.edu>
2244
2249
2245 * setup.py: finally, we have a true Windows installer, thanks to
2250 * setup.py: finally, we have a true Windows installer, thanks to
2246 the excellent work of Viktor Ransmayr
2251 the excellent work of Viktor Ransmayr
2247 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
2252 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
2248 Windows users. The setup routine is quite a bit cleaner thanks to
2253 Windows users. The setup routine is quite a bit cleaner thanks to
2249 this, and the post-install script uses the proper functions to
2254 this, and the post-install script uses the proper functions to
2250 allow a clean de-installation using the standard Windows Control
2255 allow a clean de-installation using the standard Windows Control
2251 Panel.
2256 Panel.
2252
2257
2253 * IPython/genutils.py (get_home_dir): changed to use the $HOME
2258 * IPython/genutils.py (get_home_dir): changed to use the $HOME
2254 environment variable under all OSes (including win32) if
2259 environment variable under all OSes (including win32) if
2255 available. This will give consistency to win32 users who have set
2260 available. This will give consistency to win32 users who have set
2256 this variable for any reason. If os.environ['HOME'] fails, the
2261 this variable for any reason. If os.environ['HOME'] fails, the
2257 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
2262 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
2258
2263
2259 2005-01-24 Fernando Perez <fperez@colorado.edu>
2264 2005-01-24 Fernando Perez <fperez@colorado.edu>
2260
2265
2261 * IPython/numutils.py (empty_like): add empty_like(), similar to
2266 * IPython/numutils.py (empty_like): add empty_like(), similar to
2262 zeros_like() but taking advantage of the new empty() Numeric routine.
2267 zeros_like() but taking advantage of the new empty() Numeric routine.
2263
2268
2264 2005-01-23 *** Released version 0.6.8
2269 2005-01-23 *** Released version 0.6.8
2265
2270
2266 2005-01-22 Fernando Perez <fperez@colorado.edu>
2271 2005-01-22 Fernando Perez <fperez@colorado.edu>
2267
2272
2268 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
2273 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
2269 automatic show() calls. After discussing things with JDH, it
2274 automatic show() calls. After discussing things with JDH, it
2270 turns out there are too many corner cases where this can go wrong.
2275 turns out there are too many corner cases where this can go wrong.
2271 It's best not to try to be 'too smart', and simply have ipython
2276 It's best not to try to be 'too smart', and simply have ipython
2272 reproduce as much as possible the default behavior of a normal
2277 reproduce as much as possible the default behavior of a normal
2273 python shell.
2278 python shell.
2274
2279
2275 * IPython/iplib.py (InteractiveShell.__init__): Modified the
2280 * IPython/iplib.py (InteractiveShell.__init__): Modified the
2276 line-splitting regexp and _prefilter() to avoid calling getattr()
2281 line-splitting regexp and _prefilter() to avoid calling getattr()
2277 on assignments. This closes
2282 on assignments. This closes
2278 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
2283 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
2279 readline uses getattr(), so a simple <TAB> keypress is still
2284 readline uses getattr(), so a simple <TAB> keypress is still
2280 enough to trigger getattr() calls on an object.
2285 enough to trigger getattr() calls on an object.
2281
2286
2282 2005-01-21 Fernando Perez <fperez@colorado.edu>
2287 2005-01-21 Fernando Perez <fperez@colorado.edu>
2283
2288
2284 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
2289 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
2285 docstring under pylab so it doesn't mask the original.
2290 docstring under pylab so it doesn't mask the original.
2286
2291
2287 2005-01-21 *** Released version 0.6.7
2292 2005-01-21 *** Released version 0.6.7
2288
2293
2289 2005-01-21 Fernando Perez <fperez@colorado.edu>
2294 2005-01-21 Fernando Perez <fperez@colorado.edu>
2290
2295
2291 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
2296 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
2292 signal handling for win32 users in multithreaded mode.
2297 signal handling for win32 users in multithreaded mode.
2293
2298
2294 2005-01-17 Fernando Perez <fperez@colorado.edu>
2299 2005-01-17 Fernando Perez <fperez@colorado.edu>
2295
2300
2296 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2301 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2297 instances with no __init__. After a crash report by Norbert Nemec
2302 instances with no __init__. After a crash report by Norbert Nemec
2298 <Norbert-AT-nemec-online.de>.
2303 <Norbert-AT-nemec-online.de>.
2299
2304
2300 2005-01-14 Fernando Perez <fperez@colorado.edu>
2305 2005-01-14 Fernando Perez <fperez@colorado.edu>
2301
2306
2302 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
2307 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
2303 names for verbose exceptions, when multiple dotted names and the
2308 names for verbose exceptions, when multiple dotted names and the
2304 'parent' object were present on the same line.
2309 'parent' object were present on the same line.
2305
2310
2306 2005-01-11 Fernando Perez <fperez@colorado.edu>
2311 2005-01-11 Fernando Perez <fperez@colorado.edu>
2307
2312
2308 * IPython/genutils.py (flag_calls): new utility to trap and flag
2313 * IPython/genutils.py (flag_calls): new utility to trap and flag
2309 calls in functions. I need it to clean up matplotlib support.
2314 calls in functions. I need it to clean up matplotlib support.
2310 Also removed some deprecated code in genutils.
2315 Also removed some deprecated code in genutils.
2311
2316
2312 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
2317 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
2313 that matplotlib scripts called with %run, which don't call show()
2318 that matplotlib scripts called with %run, which don't call show()
2314 themselves, still have their plotting windows open.
2319 themselves, still have their plotting windows open.
2315
2320
2316 2005-01-05 Fernando Perez <fperez@colorado.edu>
2321 2005-01-05 Fernando Perez <fperez@colorado.edu>
2317
2322
2318 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
2323 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
2319 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
2324 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
2320
2325
2321 2004-12-19 Fernando Perez <fperez@colorado.edu>
2326 2004-12-19 Fernando Perez <fperez@colorado.edu>
2322
2327
2323 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
2328 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
2324 parent_runcode, which was an eyesore. The same result can be
2329 parent_runcode, which was an eyesore. The same result can be
2325 obtained with Python's regular superclass mechanisms.
2330 obtained with Python's regular superclass mechanisms.
2326
2331
2327 2004-12-17 Fernando Perez <fperez@colorado.edu>
2332 2004-12-17 Fernando Perez <fperez@colorado.edu>
2328
2333
2329 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
2334 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
2330 reported by Prabhu.
2335 reported by Prabhu.
2331 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
2336 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
2332 sys.stderr) instead of explicitly calling sys.stderr. This helps
2337 sys.stderr) instead of explicitly calling sys.stderr. This helps
2333 maintain our I/O abstractions clean, for future GUI embeddings.
2338 maintain our I/O abstractions clean, for future GUI embeddings.
2334
2339
2335 * IPython/genutils.py (info): added new utility for sys.stderr
2340 * IPython/genutils.py (info): added new utility for sys.stderr
2336 unified info message handling (thin wrapper around warn()).
2341 unified info message handling (thin wrapper around warn()).
2337
2342
2338 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
2343 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
2339 composite (dotted) names on verbose exceptions.
2344 composite (dotted) names on verbose exceptions.
2340 (VerboseTB.nullrepr): harden against another kind of errors which
2345 (VerboseTB.nullrepr): harden against another kind of errors which
2341 Python's inspect module can trigger, and which were crashing
2346 Python's inspect module can trigger, and which were crashing
2342 IPython. Thanks to a report by Marco Lombardi
2347 IPython. Thanks to a report by Marco Lombardi
2343 <mlombard-AT-ma010192.hq.eso.org>.
2348 <mlombard-AT-ma010192.hq.eso.org>.
2344
2349
2345 2004-12-13 *** Released version 0.6.6
2350 2004-12-13 *** Released version 0.6.6
2346
2351
2347 2004-12-12 Fernando Perez <fperez@colorado.edu>
2352 2004-12-12 Fernando Perez <fperez@colorado.edu>
2348
2353
2349 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
2354 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
2350 generated by pygtk upon initialization if it was built without
2355 generated by pygtk upon initialization if it was built without
2351 threads (for matplotlib users). After a crash reported by
2356 threads (for matplotlib users). After a crash reported by
2352 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
2357 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
2353
2358
2354 * IPython/ipmaker.py (make_IPython): fix small bug in the
2359 * IPython/ipmaker.py (make_IPython): fix small bug in the
2355 import_some parameter for multiple imports.
2360 import_some parameter for multiple imports.
2356
2361
2357 * IPython/iplib.py (ipmagic): simplified the interface of
2362 * IPython/iplib.py (ipmagic): simplified the interface of
2358 ipmagic() to take a single string argument, just as it would be
2363 ipmagic() to take a single string argument, just as it would be
2359 typed at the IPython cmd line.
2364 typed at the IPython cmd line.
2360 (ipalias): Added new ipalias() with an interface identical to
2365 (ipalias): Added new ipalias() with an interface identical to
2361 ipmagic(). This completes exposing a pure python interface to the
2366 ipmagic(). This completes exposing a pure python interface to the
2362 alias and magic system, which can be used in loops or more complex
2367 alias and magic system, which can be used in loops or more complex
2363 code where IPython's automatic line mangling is not active.
2368 code where IPython's automatic line mangling is not active.
2364
2369
2365 * IPython/genutils.py (timing): changed interface of timing to
2370 * IPython/genutils.py (timing): changed interface of timing to
2366 simply run code once, which is the most common case. timings()
2371 simply run code once, which is the most common case. timings()
2367 remains unchanged, for the cases where you want multiple runs.
2372 remains unchanged, for the cases where you want multiple runs.
2368
2373
2369 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
2374 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
2370 bug where Python2.2 crashes with exec'ing code which does not end
2375 bug where Python2.2 crashes with exec'ing code which does not end
2371 in a single newline. Python 2.3 is OK, so I hadn't noticed this
2376 in a single newline. Python 2.3 is OK, so I hadn't noticed this
2372 before.
2377 before.
2373
2378
2374 2004-12-10 Fernando Perez <fperez@colorado.edu>
2379 2004-12-10 Fernando Perez <fperez@colorado.edu>
2375
2380
2376 * IPython/Magic.py (Magic.magic_prun): changed name of option from
2381 * IPython/Magic.py (Magic.magic_prun): changed name of option from
2377 -t to -T, to accomodate the new -t flag in %run (the %run and
2382 -t to -T, to accomodate the new -t flag in %run (the %run and
2378 %prun options are kind of intermixed, and it's not easy to change
2383 %prun options are kind of intermixed, and it's not easy to change
2379 this with the limitations of python's getopt).
2384 this with the limitations of python's getopt).
2380
2385
2381 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
2386 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
2382 the execution of scripts. It's not as fine-tuned as timeit.py,
2387 the execution of scripts. It's not as fine-tuned as timeit.py,
2383 but it works from inside ipython (and under 2.2, which lacks
2388 but it works from inside ipython (and under 2.2, which lacks
2384 timeit.py). Optionally a number of runs > 1 can be given for
2389 timeit.py). Optionally a number of runs > 1 can be given for
2385 timing very short-running code.
2390 timing very short-running code.
2386
2391
2387 * IPython/genutils.py (uniq_stable): new routine which returns a
2392 * IPython/genutils.py (uniq_stable): new routine which returns a
2388 list of unique elements in any iterable, but in stable order of
2393 list of unique elements in any iterable, but in stable order of
2389 appearance. I needed this for the ultraTB fixes, and it's a handy
2394 appearance. I needed this for the ultraTB fixes, and it's a handy
2390 utility.
2395 utility.
2391
2396
2392 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
2397 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
2393 dotted names in Verbose exceptions. This had been broken since
2398 dotted names in Verbose exceptions. This had been broken since
2394 the very start, now x.y will properly be printed in a Verbose
2399 the very start, now x.y will properly be printed in a Verbose
2395 traceback, instead of x being shown and y appearing always as an
2400 traceback, instead of x being shown and y appearing always as an
2396 'undefined global'. Getting this to work was a bit tricky,
2401 'undefined global'. Getting this to work was a bit tricky,
2397 because by default python tokenizers are stateless. Saved by
2402 because by default python tokenizers are stateless. Saved by
2398 python's ability to easily add a bit of state to an arbitrary
2403 python's ability to easily add a bit of state to an arbitrary
2399 function (without needing to build a full-blown callable object).
2404 function (without needing to build a full-blown callable object).
2400
2405
2401 Also big cleanup of this code, which had horrendous runtime
2406 Also big cleanup of this code, which had horrendous runtime
2402 lookups of zillions of attributes for colorization. Moved all
2407 lookups of zillions of attributes for colorization. Moved all
2403 this code into a few templates, which make it cleaner and quicker.
2408 this code into a few templates, which make it cleaner and quicker.
2404
2409
2405 Printout quality was also improved for Verbose exceptions: one
2410 Printout quality was also improved for Verbose exceptions: one
2406 variable per line, and memory addresses are printed (this can be
2411 variable per line, and memory addresses are printed (this can be
2407 quite handy in nasty debugging situations, which is what Verbose
2412 quite handy in nasty debugging situations, which is what Verbose
2408 is for).
2413 is for).
2409
2414
2410 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
2415 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
2411 the command line as scripts to be loaded by embedded instances.
2416 the command line as scripts to be loaded by embedded instances.
2412 Doing so has the potential for an infinite recursion if there are
2417 Doing so has the potential for an infinite recursion if there are
2413 exceptions thrown in the process. This fixes a strange crash
2418 exceptions thrown in the process. This fixes a strange crash
2414 reported by Philippe MULLER <muller-AT-irit.fr>.
2419 reported by Philippe MULLER <muller-AT-irit.fr>.
2415
2420
2416 2004-12-09 Fernando Perez <fperez@colorado.edu>
2421 2004-12-09 Fernando Perez <fperez@colorado.edu>
2417
2422
2418 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
2423 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
2419 to reflect new names in matplotlib, which now expose the
2424 to reflect new names in matplotlib, which now expose the
2420 matlab-compatible interface via a pylab module instead of the
2425 matlab-compatible interface via a pylab module instead of the
2421 'matlab' name. The new code is backwards compatible, so users of
2426 'matlab' name. The new code is backwards compatible, so users of
2422 all matplotlib versions are OK. Patch by J. Hunter.
2427 all matplotlib versions are OK. Patch by J. Hunter.
2423
2428
2424 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
2429 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
2425 of __init__ docstrings for instances (class docstrings are already
2430 of __init__ docstrings for instances (class docstrings are already
2426 automatically printed). Instances with customized docstrings
2431 automatically printed). Instances with customized docstrings
2427 (indep. of the class) are also recognized and all 3 separate
2432 (indep. of the class) are also recognized and all 3 separate
2428 docstrings are printed (instance, class, constructor). After some
2433 docstrings are printed (instance, class, constructor). After some
2429 comments/suggestions by J. Hunter.
2434 comments/suggestions by J. Hunter.
2430
2435
2431 2004-12-05 Fernando Perez <fperez@colorado.edu>
2436 2004-12-05 Fernando Perez <fperez@colorado.edu>
2432
2437
2433 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
2438 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
2434 warnings when tab-completion fails and triggers an exception.
2439 warnings when tab-completion fails and triggers an exception.
2435
2440
2436 2004-12-03 Fernando Perez <fperez@colorado.edu>
2441 2004-12-03 Fernando Perez <fperez@colorado.edu>
2437
2442
2438 * IPython/Magic.py (magic_prun): Fix bug where an exception would
2443 * IPython/Magic.py (magic_prun): Fix bug where an exception would
2439 be triggered when using 'run -p'. An incorrect option flag was
2444 be triggered when using 'run -p'. An incorrect option flag was
2440 being set ('d' instead of 'D').
2445 being set ('d' instead of 'D').
2441 (manpage): fix missing escaped \- sign.
2446 (manpage): fix missing escaped \- sign.
2442
2447
2443 2004-11-30 *** Released version 0.6.5
2448 2004-11-30 *** Released version 0.6.5
2444
2449
2445 2004-11-30 Fernando Perez <fperez@colorado.edu>
2450 2004-11-30 Fernando Perez <fperez@colorado.edu>
2446
2451
2447 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
2452 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
2448 setting with -d option.
2453 setting with -d option.
2449
2454
2450 * setup.py (docfiles): Fix problem where the doc glob I was using
2455 * setup.py (docfiles): Fix problem where the doc glob I was using
2451 was COMPLETELY BROKEN. It was giving the right files by pure
2456 was COMPLETELY BROKEN. It was giving the right files by pure
2452 accident, but failed once I tried to include ipython.el. Note:
2457 accident, but failed once I tried to include ipython.el. Note:
2453 glob() does NOT allow you to do exclusion on multiple endings!
2458 glob() does NOT allow you to do exclusion on multiple endings!
2454
2459
2455 2004-11-29 Fernando Perez <fperez@colorado.edu>
2460 2004-11-29 Fernando Perez <fperez@colorado.edu>
2456
2461
2457 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
2462 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
2458 the manpage as the source. Better formatting & consistency.
2463 the manpage as the source. Better formatting & consistency.
2459
2464
2460 * IPython/Magic.py (magic_run): Added new -d option, to run
2465 * IPython/Magic.py (magic_run): Added new -d option, to run
2461 scripts under the control of the python pdb debugger. Note that
2466 scripts under the control of the python pdb debugger. Note that
2462 this required changing the %prun option -d to -D, to avoid a clash
2467 this required changing the %prun option -d to -D, to avoid a clash
2463 (since %run must pass options to %prun, and getopt is too dumb to
2468 (since %run must pass options to %prun, and getopt is too dumb to
2464 handle options with string values with embedded spaces). Thanks
2469 handle options with string values with embedded spaces). Thanks
2465 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
2470 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
2466 (magic_who_ls): added type matching to %who and %whos, so that one
2471 (magic_who_ls): added type matching to %who and %whos, so that one
2467 can filter their output to only include variables of certain
2472 can filter their output to only include variables of certain
2468 types. Another suggestion by Matthew.
2473 types. Another suggestion by Matthew.
2469 (magic_whos): Added memory summaries in kb and Mb for arrays.
2474 (magic_whos): Added memory summaries in kb and Mb for arrays.
2470 (magic_who): Improve formatting (break lines every 9 vars).
2475 (magic_who): Improve formatting (break lines every 9 vars).
2471
2476
2472 2004-11-28 Fernando Perez <fperez@colorado.edu>
2477 2004-11-28 Fernando Perez <fperez@colorado.edu>
2473
2478
2474 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
2479 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
2475 cache when empty lines were present.
2480 cache when empty lines were present.
2476
2481
2477 2004-11-24 Fernando Perez <fperez@colorado.edu>
2482 2004-11-24 Fernando Perez <fperez@colorado.edu>
2478
2483
2479 * IPython/usage.py (__doc__): document the re-activated threading
2484 * IPython/usage.py (__doc__): document the re-activated threading
2480 options for WX and GTK.
2485 options for WX and GTK.
2481
2486
2482 2004-11-23 Fernando Perez <fperez@colorado.edu>
2487 2004-11-23 Fernando Perez <fperez@colorado.edu>
2483
2488
2484 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
2489 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
2485 the -wthread and -gthread options, along with a new -tk one to try
2490 the -wthread and -gthread options, along with a new -tk one to try
2486 and coordinate Tk threading with wx/gtk. The tk support is very
2491 and coordinate Tk threading with wx/gtk. The tk support is very
2487 platform dependent, since it seems to require Tcl and Tk to be
2492 platform dependent, since it seems to require Tcl and Tk to be
2488 built with threads (Fedora1/2 appears NOT to have it, but in
2493 built with threads (Fedora1/2 appears NOT to have it, but in
2489 Prabhu's Debian boxes it works OK). But even with some Tk
2494 Prabhu's Debian boxes it works OK). But even with some Tk
2490 limitations, this is a great improvement.
2495 limitations, this is a great improvement.
2491
2496
2492 * IPython/Prompts.py (prompt_specials_color): Added \t for time
2497 * IPython/Prompts.py (prompt_specials_color): Added \t for time
2493 info in user prompts. Patch by Prabhu.
2498 info in user prompts. Patch by Prabhu.
2494
2499
2495 2004-11-18 Fernando Perez <fperez@colorado.edu>
2500 2004-11-18 Fernando Perez <fperez@colorado.edu>
2496
2501
2497 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
2502 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
2498 EOFErrors and bail, to avoid infinite loops if a non-terminating
2503 EOFErrors and bail, to avoid infinite loops if a non-terminating
2499 file is fed into ipython. Patch submitted in issue 19 by user,
2504 file is fed into ipython. Patch submitted in issue 19 by user,
2500 many thanks.
2505 many thanks.
2501
2506
2502 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
2507 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
2503 autoquote/parens in continuation prompts, which can cause lots of
2508 autoquote/parens in continuation prompts, which can cause lots of
2504 problems. Closes roundup issue 20.
2509 problems. Closes roundup issue 20.
2505
2510
2506 2004-11-17 Fernando Perez <fperez@colorado.edu>
2511 2004-11-17 Fernando Perez <fperez@colorado.edu>
2507
2512
2508 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
2513 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
2509 reported as debian bug #280505. I'm not sure my local changelog
2514 reported as debian bug #280505. I'm not sure my local changelog
2510 entry has the proper debian format (Jack?).
2515 entry has the proper debian format (Jack?).
2511
2516
2512 2004-11-08 *** Released version 0.6.4
2517 2004-11-08 *** Released version 0.6.4
2513
2518
2514 2004-11-08 Fernando Perez <fperez@colorado.edu>
2519 2004-11-08 Fernando Perez <fperez@colorado.edu>
2515
2520
2516 * IPython/iplib.py (init_readline): Fix exit message for Windows
2521 * IPython/iplib.py (init_readline): Fix exit message for Windows
2517 when readline is active. Thanks to a report by Eric Jones
2522 when readline is active. Thanks to a report by Eric Jones
2518 <eric-AT-enthought.com>.
2523 <eric-AT-enthought.com>.
2519
2524
2520 2004-11-07 Fernando Perez <fperez@colorado.edu>
2525 2004-11-07 Fernando Perez <fperez@colorado.edu>
2521
2526
2522 * IPython/genutils.py (page): Add a trap for OSError exceptions,
2527 * IPython/genutils.py (page): Add a trap for OSError exceptions,
2523 sometimes seen by win2k/cygwin users.
2528 sometimes seen by win2k/cygwin users.
2524
2529
2525 2004-11-06 Fernando Perez <fperez@colorado.edu>
2530 2004-11-06 Fernando Perez <fperez@colorado.edu>
2526
2531
2527 * IPython/iplib.py (interact): Change the handling of %Exit from
2532 * IPython/iplib.py (interact): Change the handling of %Exit from
2528 trying to propagate a SystemExit to an internal ipython flag.
2533 trying to propagate a SystemExit to an internal ipython flag.
2529 This is less elegant than using Python's exception mechanism, but
2534 This is less elegant than using Python's exception mechanism, but
2530 I can't get that to work reliably with threads, so under -pylab
2535 I can't get that to work reliably with threads, so under -pylab
2531 %Exit was hanging IPython. Cross-thread exception handling is
2536 %Exit was hanging IPython. Cross-thread exception handling is
2532 really a bitch. Thaks to a bug report by Stephen Walton
2537 really a bitch. Thaks to a bug report by Stephen Walton
2533 <stephen.walton-AT-csun.edu>.
2538 <stephen.walton-AT-csun.edu>.
2534
2539
2535 2004-11-04 Fernando Perez <fperez@colorado.edu>
2540 2004-11-04 Fernando Perez <fperez@colorado.edu>
2536
2541
2537 * IPython/iplib.py (raw_input_original): store a pointer to the
2542 * IPython/iplib.py (raw_input_original): store a pointer to the
2538 true raw_input to harden against code which can modify it
2543 true raw_input to harden against code which can modify it
2539 (wx.py.PyShell does this and would otherwise crash ipython).
2544 (wx.py.PyShell does this and would otherwise crash ipython).
2540 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
2545 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
2541
2546
2542 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
2547 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
2543 Ctrl-C problem, which does not mess up the input line.
2548 Ctrl-C problem, which does not mess up the input line.
2544
2549
2545 2004-11-03 Fernando Perez <fperez@colorado.edu>
2550 2004-11-03 Fernando Perez <fperez@colorado.edu>
2546
2551
2547 * IPython/Release.py: Changed licensing to BSD, in all files.
2552 * IPython/Release.py: Changed licensing to BSD, in all files.
2548 (name): lowercase name for tarball/RPM release.
2553 (name): lowercase name for tarball/RPM release.
2549
2554
2550 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
2555 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
2551 use throughout ipython.
2556 use throughout ipython.
2552
2557
2553 * IPython/Magic.py (Magic._ofind): Switch to using the new
2558 * IPython/Magic.py (Magic._ofind): Switch to using the new
2554 OInspect.getdoc() function.
2559 OInspect.getdoc() function.
2555
2560
2556 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
2561 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
2557 of the line currently being canceled via Ctrl-C. It's extremely
2562 of the line currently being canceled via Ctrl-C. It's extremely
2558 ugly, but I don't know how to do it better (the problem is one of
2563 ugly, but I don't know how to do it better (the problem is one of
2559 handling cross-thread exceptions).
2564 handling cross-thread exceptions).
2560
2565
2561 2004-10-28 Fernando Perez <fperez@colorado.edu>
2566 2004-10-28 Fernando Perez <fperez@colorado.edu>
2562
2567
2563 * IPython/Shell.py (signal_handler): add signal handlers to trap
2568 * IPython/Shell.py (signal_handler): add signal handlers to trap
2564 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
2569 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
2565 report by Francesc Alted.
2570 report by Francesc Alted.
2566
2571
2567 2004-10-21 Fernando Perez <fperez@colorado.edu>
2572 2004-10-21 Fernando Perez <fperez@colorado.edu>
2568
2573
2569 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
2574 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
2570 to % for pysh syntax extensions.
2575 to % for pysh syntax extensions.
2571
2576
2572 2004-10-09 Fernando Perez <fperez@colorado.edu>
2577 2004-10-09 Fernando Perez <fperez@colorado.edu>
2573
2578
2574 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
2579 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
2575 arrays to print a more useful summary, without calling str(arr).
2580 arrays to print a more useful summary, without calling str(arr).
2576 This avoids the problem of extremely lengthy computations which
2581 This avoids the problem of extremely lengthy computations which
2577 occur if arr is large, and appear to the user as a system lockup
2582 occur if arr is large, and appear to the user as a system lockup
2578 with 100% cpu activity. After a suggestion by Kristian Sandberg
2583 with 100% cpu activity. After a suggestion by Kristian Sandberg
2579 <Kristian.Sandberg@colorado.edu>.
2584 <Kristian.Sandberg@colorado.edu>.
2580 (Magic.__init__): fix bug in global magic escapes not being
2585 (Magic.__init__): fix bug in global magic escapes not being
2581 correctly set.
2586 correctly set.
2582
2587
2583 2004-10-08 Fernando Perez <fperez@colorado.edu>
2588 2004-10-08 Fernando Perez <fperez@colorado.edu>
2584
2589
2585 * IPython/Magic.py (__license__): change to absolute imports of
2590 * IPython/Magic.py (__license__): change to absolute imports of
2586 ipython's own internal packages, to start adapting to the absolute
2591 ipython's own internal packages, to start adapting to the absolute
2587 import requirement of PEP-328.
2592 import requirement of PEP-328.
2588
2593
2589 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
2594 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
2590 files, and standardize author/license marks through the Release
2595 files, and standardize author/license marks through the Release
2591 module instead of having per/file stuff (except for files with
2596 module instead of having per/file stuff (except for files with
2592 particular licenses, like the MIT/PSF-licensed codes).
2597 particular licenses, like the MIT/PSF-licensed codes).
2593
2598
2594 * IPython/Debugger.py: remove dead code for python 2.1
2599 * IPython/Debugger.py: remove dead code for python 2.1
2595
2600
2596 2004-10-04 Fernando Perez <fperez@colorado.edu>
2601 2004-10-04 Fernando Perez <fperez@colorado.edu>
2597
2602
2598 * IPython/iplib.py (ipmagic): New function for accessing magics
2603 * IPython/iplib.py (ipmagic): New function for accessing magics
2599 via a normal python function call.
2604 via a normal python function call.
2600
2605
2601 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
2606 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
2602 from '@' to '%', to accomodate the new @decorator syntax of python
2607 from '@' to '%', to accomodate the new @decorator syntax of python
2603 2.4.
2608 2.4.
2604
2609
2605 2004-09-29 Fernando Perez <fperez@colorado.edu>
2610 2004-09-29 Fernando Perez <fperez@colorado.edu>
2606
2611
2607 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
2612 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
2608 matplotlib.use to prevent running scripts which try to switch
2613 matplotlib.use to prevent running scripts which try to switch
2609 interactive backends from within ipython. This will just crash
2614 interactive backends from within ipython. This will just crash
2610 the python interpreter, so we can't allow it (but a detailed error
2615 the python interpreter, so we can't allow it (but a detailed error
2611 is given to the user).
2616 is given to the user).
2612
2617
2613 2004-09-28 Fernando Perez <fperez@colorado.edu>
2618 2004-09-28 Fernando Perez <fperez@colorado.edu>
2614
2619
2615 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
2620 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
2616 matplotlib-related fixes so that using @run with non-matplotlib
2621 matplotlib-related fixes so that using @run with non-matplotlib
2617 scripts doesn't pop up spurious plot windows. This requires
2622 scripts doesn't pop up spurious plot windows. This requires
2618 matplotlib >= 0.63, where I had to make some changes as well.
2623 matplotlib >= 0.63, where I had to make some changes as well.
2619
2624
2620 * IPython/ipmaker.py (make_IPython): update version requirement to
2625 * IPython/ipmaker.py (make_IPython): update version requirement to
2621 python 2.2.
2626 python 2.2.
2622
2627
2623 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
2628 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
2624 banner arg for embedded customization.
2629 banner arg for embedded customization.
2625
2630
2626 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
2631 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
2627 explicit uses of __IP as the IPython's instance name. Now things
2632 explicit uses of __IP as the IPython's instance name. Now things
2628 are properly handled via the shell.name value. The actual code
2633 are properly handled via the shell.name value. The actual code
2629 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
2634 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
2630 is much better than before. I'll clean things completely when the
2635 is much better than before. I'll clean things completely when the
2631 magic stuff gets a real overhaul.
2636 magic stuff gets a real overhaul.
2632
2637
2633 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
2638 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
2634 minor changes to debian dir.
2639 minor changes to debian dir.
2635
2640
2636 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
2641 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
2637 pointer to the shell itself in the interactive namespace even when
2642 pointer to the shell itself in the interactive namespace even when
2638 a user-supplied dict is provided. This is needed for embedding
2643 a user-supplied dict is provided. This is needed for embedding
2639 purposes (found by tests with Michel Sanner).
2644 purposes (found by tests with Michel Sanner).
2640
2645
2641 2004-09-27 Fernando Perez <fperez@colorado.edu>
2646 2004-09-27 Fernando Perez <fperez@colorado.edu>
2642
2647
2643 * IPython/UserConfig/ipythonrc: remove []{} from
2648 * IPython/UserConfig/ipythonrc: remove []{} from
2644 readline_remove_delims, so that things like [modname.<TAB> do
2649 readline_remove_delims, so that things like [modname.<TAB> do
2645 proper completion. This disables [].TAB, but that's a less common
2650 proper completion. This disables [].TAB, but that's a less common
2646 case than module names in list comprehensions, for example.
2651 case than module names in list comprehensions, for example.
2647 Thanks to a report by Andrea Riciputi.
2652 Thanks to a report by Andrea Riciputi.
2648
2653
2649 2004-09-09 Fernando Perez <fperez@colorado.edu>
2654 2004-09-09 Fernando Perez <fperez@colorado.edu>
2650
2655
2651 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
2656 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
2652 blocking problems in win32 and osx. Fix by John.
2657 blocking problems in win32 and osx. Fix by John.
2653
2658
2654 2004-09-08 Fernando Perez <fperez@colorado.edu>
2659 2004-09-08 Fernando Perez <fperez@colorado.edu>
2655
2660
2656 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
2661 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
2657 for Win32 and OSX. Fix by John Hunter.
2662 for Win32 and OSX. Fix by John Hunter.
2658
2663
2659 2004-08-30 *** Released version 0.6.3
2664 2004-08-30 *** Released version 0.6.3
2660
2665
2661 2004-08-30 Fernando Perez <fperez@colorado.edu>
2666 2004-08-30 Fernando Perez <fperez@colorado.edu>
2662
2667
2663 * setup.py (isfile): Add manpages to list of dependent files to be
2668 * setup.py (isfile): Add manpages to list of dependent files to be
2664 updated.
2669 updated.
2665
2670
2666 2004-08-27 Fernando Perez <fperez@colorado.edu>
2671 2004-08-27 Fernando Perez <fperez@colorado.edu>
2667
2672
2668 * IPython/Shell.py (start): I've disabled -wthread and -gthread
2673 * IPython/Shell.py (start): I've disabled -wthread and -gthread
2669 for now. They don't really work with standalone WX/GTK code
2674 for now. They don't really work with standalone WX/GTK code
2670 (though matplotlib IS working fine with both of those backends).
2675 (though matplotlib IS working fine with both of those backends).
2671 This will neeed much more testing. I disabled most things with
2676 This will neeed much more testing. I disabled most things with
2672 comments, so turning it back on later should be pretty easy.
2677 comments, so turning it back on later should be pretty easy.
2673
2678
2674 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
2679 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
2675 autocalling of expressions like r'foo', by modifying the line
2680 autocalling of expressions like r'foo', by modifying the line
2676 split regexp. Closes
2681 split regexp. Closes
2677 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
2682 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
2678 Riley <ipythonbugs-AT-sabi.net>.
2683 Riley <ipythonbugs-AT-sabi.net>.
2679 (InteractiveShell.mainloop): honor --nobanner with banner
2684 (InteractiveShell.mainloop): honor --nobanner with banner
2680 extensions.
2685 extensions.
2681
2686
2682 * IPython/Shell.py: Significant refactoring of all classes, so
2687 * IPython/Shell.py: Significant refactoring of all classes, so
2683 that we can really support ALL matplotlib backends and threading
2688 that we can really support ALL matplotlib backends and threading
2684 models (John spotted a bug with Tk which required this). Now we
2689 models (John spotted a bug with Tk which required this). Now we
2685 should support single-threaded, WX-threads and GTK-threads, both
2690 should support single-threaded, WX-threads and GTK-threads, both
2686 for generic code and for matplotlib.
2691 for generic code and for matplotlib.
2687
2692
2688 * IPython/ipmaker.py (__call__): Changed -mpthread option to
2693 * IPython/ipmaker.py (__call__): Changed -mpthread option to
2689 -pylab, to simplify things for users. Will also remove the pylab
2694 -pylab, to simplify things for users. Will also remove the pylab
2690 profile, since now all of matplotlib configuration is directly
2695 profile, since now all of matplotlib configuration is directly
2691 handled here. This also reduces startup time.
2696 handled here. This also reduces startup time.
2692
2697
2693 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
2698 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
2694 shell wasn't being correctly called. Also in IPShellWX.
2699 shell wasn't being correctly called. Also in IPShellWX.
2695
2700
2696 * IPython/iplib.py (InteractiveShell.__init__): Added option to
2701 * IPython/iplib.py (InteractiveShell.__init__): Added option to
2697 fine-tune banner.
2702 fine-tune banner.
2698
2703
2699 * IPython/numutils.py (spike): Deprecate these spike functions,
2704 * IPython/numutils.py (spike): Deprecate these spike functions,
2700 delete (long deprecated) gnuplot_exec handler.
2705 delete (long deprecated) gnuplot_exec handler.
2701
2706
2702 2004-08-26 Fernando Perez <fperez@colorado.edu>
2707 2004-08-26 Fernando Perez <fperez@colorado.edu>
2703
2708
2704 * ipython.1: Update for threading options, plus some others which
2709 * ipython.1: Update for threading options, plus some others which
2705 were missing.
2710 were missing.
2706
2711
2707 * IPython/ipmaker.py (__call__): Added -wthread option for
2712 * IPython/ipmaker.py (__call__): Added -wthread option for
2708 wxpython thread handling. Make sure threading options are only
2713 wxpython thread handling. Make sure threading options are only
2709 valid at the command line.
2714 valid at the command line.
2710
2715
2711 * scripts/ipython: moved shell selection into a factory function
2716 * scripts/ipython: moved shell selection into a factory function
2712 in Shell.py, to keep the starter script to a minimum.
2717 in Shell.py, to keep the starter script to a minimum.
2713
2718
2714 2004-08-25 Fernando Perez <fperez@colorado.edu>
2719 2004-08-25 Fernando Perez <fperez@colorado.edu>
2715
2720
2716 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
2721 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
2717 John. Along with some recent changes he made to matplotlib, the
2722 John. Along with some recent changes he made to matplotlib, the
2718 next versions of both systems should work very well together.
2723 next versions of both systems should work very well together.
2719
2724
2720 2004-08-24 Fernando Perez <fperez@colorado.edu>
2725 2004-08-24 Fernando Perez <fperez@colorado.edu>
2721
2726
2722 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
2727 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
2723 tried to switch the profiling to using hotshot, but I'm getting
2728 tried to switch the profiling to using hotshot, but I'm getting
2724 strange errors from prof.runctx() there. I may be misreading the
2729 strange errors from prof.runctx() there. I may be misreading the
2725 docs, but it looks weird. For now the profiling code will
2730 docs, but it looks weird. For now the profiling code will
2726 continue to use the standard profiler.
2731 continue to use the standard profiler.
2727
2732
2728 2004-08-23 Fernando Perez <fperez@colorado.edu>
2733 2004-08-23 Fernando Perez <fperez@colorado.edu>
2729
2734
2730 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
2735 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
2731 threaded shell, by John Hunter. It's not quite ready yet, but
2736 threaded shell, by John Hunter. It's not quite ready yet, but
2732 close.
2737 close.
2733
2738
2734 2004-08-22 Fernando Perez <fperez@colorado.edu>
2739 2004-08-22 Fernando Perez <fperez@colorado.edu>
2735
2740
2736 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
2741 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
2737 in Magic and ultraTB.
2742 in Magic and ultraTB.
2738
2743
2739 * ipython.1: document threading options in manpage.
2744 * ipython.1: document threading options in manpage.
2740
2745
2741 * scripts/ipython: Changed name of -thread option to -gthread,
2746 * scripts/ipython: Changed name of -thread option to -gthread,
2742 since this is GTK specific. I want to leave the door open for a
2747 since this is GTK specific. I want to leave the door open for a
2743 -wthread option for WX, which will most likely be necessary. This
2748 -wthread option for WX, which will most likely be necessary. This
2744 change affects usage and ipmaker as well.
2749 change affects usage and ipmaker as well.
2745
2750
2746 * IPython/Shell.py (matplotlib_shell): Add a factory function to
2751 * IPython/Shell.py (matplotlib_shell): Add a factory function to
2747 handle the matplotlib shell issues. Code by John Hunter
2752 handle the matplotlib shell issues. Code by John Hunter
2748 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2753 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2749 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
2754 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
2750 broken (and disabled for end users) for now, but it puts the
2755 broken (and disabled for end users) for now, but it puts the
2751 infrastructure in place.
2756 infrastructure in place.
2752
2757
2753 2004-08-21 Fernando Perez <fperez@colorado.edu>
2758 2004-08-21 Fernando Perez <fperez@colorado.edu>
2754
2759
2755 * ipythonrc-pylab: Add matplotlib support.
2760 * ipythonrc-pylab: Add matplotlib support.
2756
2761
2757 * matplotlib_config.py: new files for matplotlib support, part of
2762 * matplotlib_config.py: new files for matplotlib support, part of
2758 the pylab profile.
2763 the pylab profile.
2759
2764
2760 * IPython/usage.py (__doc__): documented the threading options.
2765 * IPython/usage.py (__doc__): documented the threading options.
2761
2766
2762 2004-08-20 Fernando Perez <fperez@colorado.edu>
2767 2004-08-20 Fernando Perez <fperez@colorado.edu>
2763
2768
2764 * ipython: Modified the main calling routine to handle the -thread
2769 * ipython: Modified the main calling routine to handle the -thread
2765 and -mpthread options. This needs to be done as a top-level hack,
2770 and -mpthread options. This needs to be done as a top-level hack,
2766 because it determines which class to instantiate for IPython
2771 because it determines which class to instantiate for IPython
2767 itself.
2772 itself.
2768
2773
2769 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
2774 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
2770 classes to support multithreaded GTK operation without blocking,
2775 classes to support multithreaded GTK operation without blocking,
2771 and matplotlib with all backends. This is a lot of still very
2776 and matplotlib with all backends. This is a lot of still very
2772 experimental code, and threads are tricky. So it may still have a
2777 experimental code, and threads are tricky. So it may still have a
2773 few rough edges... This code owes a lot to
2778 few rough edges... This code owes a lot to
2774 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
2779 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
2775 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
2780 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
2776 to John Hunter for all the matplotlib work.
2781 to John Hunter for all the matplotlib work.
2777
2782
2778 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
2783 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
2779 options for gtk thread and matplotlib support.
2784 options for gtk thread and matplotlib support.
2780
2785
2781 2004-08-16 Fernando Perez <fperez@colorado.edu>
2786 2004-08-16 Fernando Perez <fperez@colorado.edu>
2782
2787
2783 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
2788 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
2784 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
2789 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
2785 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
2790 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
2786
2791
2787 2004-08-11 Fernando Perez <fperez@colorado.edu>
2792 2004-08-11 Fernando Perez <fperez@colorado.edu>
2788
2793
2789 * setup.py (isfile): Fix build so documentation gets updated for
2794 * setup.py (isfile): Fix build so documentation gets updated for
2790 rpms (it was only done for .tgz builds).
2795 rpms (it was only done for .tgz builds).
2791
2796
2792 2004-08-10 Fernando Perez <fperez@colorado.edu>
2797 2004-08-10 Fernando Perez <fperez@colorado.edu>
2793
2798
2794 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
2799 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
2795
2800
2796 * iplib.py : Silence syntax error exceptions in tab-completion.
2801 * iplib.py : Silence syntax error exceptions in tab-completion.
2797
2802
2798 2004-08-05 Fernando Perez <fperez@colorado.edu>
2803 2004-08-05 Fernando Perez <fperez@colorado.edu>
2799
2804
2800 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
2805 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
2801 'color off' mark for continuation prompts. This was causing long
2806 'color off' mark for continuation prompts. This was causing long
2802 continuation lines to mis-wrap.
2807 continuation lines to mis-wrap.
2803
2808
2804 2004-08-01 Fernando Perez <fperez@colorado.edu>
2809 2004-08-01 Fernando Perez <fperez@colorado.edu>
2805
2810
2806 * IPython/ipmaker.py (make_IPython): Allow the shell class used
2811 * IPython/ipmaker.py (make_IPython): Allow the shell class used
2807 for building ipython to be a parameter. All this is necessary
2812 for building ipython to be a parameter. All this is necessary
2808 right now to have a multithreaded version, but this insane
2813 right now to have a multithreaded version, but this insane
2809 non-design will be cleaned up soon. For now, it's a hack that
2814 non-design will be cleaned up soon. For now, it's a hack that
2810 works.
2815 works.
2811
2816
2812 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
2817 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
2813 args in various places. No bugs so far, but it's a dangerous
2818 args in various places. No bugs so far, but it's a dangerous
2814 practice.
2819 practice.
2815
2820
2816 2004-07-31 Fernando Perez <fperez@colorado.edu>
2821 2004-07-31 Fernando Perez <fperez@colorado.edu>
2817
2822
2818 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
2823 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
2819 fix completion of files with dots in their names under most
2824 fix completion of files with dots in their names under most
2820 profiles (pysh was OK because the completion order is different).
2825 profiles (pysh was OK because the completion order is different).
2821
2826
2822 2004-07-27 Fernando Perez <fperez@colorado.edu>
2827 2004-07-27 Fernando Perez <fperez@colorado.edu>
2823
2828
2824 * IPython/iplib.py (InteractiveShell.__init__): build dict of
2829 * IPython/iplib.py (InteractiveShell.__init__): build dict of
2825 keywords manually, b/c the one in keyword.py was removed in python
2830 keywords manually, b/c the one in keyword.py was removed in python
2826 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
2831 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
2827 This is NOT a bug under python 2.3 and earlier.
2832 This is NOT a bug under python 2.3 and earlier.
2828
2833
2829 2004-07-26 Fernando Perez <fperez@colorado.edu>
2834 2004-07-26 Fernando Perez <fperez@colorado.edu>
2830
2835
2831 * IPython/ultraTB.py (VerboseTB.text): Add another
2836 * IPython/ultraTB.py (VerboseTB.text): Add another
2832 linecache.checkcache() call to try to prevent inspect.py from
2837 linecache.checkcache() call to try to prevent inspect.py from
2833 crashing under python 2.3. I think this fixes
2838 crashing under python 2.3. I think this fixes
2834 http://www.scipy.net/roundup/ipython/issue17.
2839 http://www.scipy.net/roundup/ipython/issue17.
2835
2840
2836 2004-07-26 *** Released version 0.6.2
2841 2004-07-26 *** Released version 0.6.2
2837
2842
2838 2004-07-26 Fernando Perez <fperez@colorado.edu>
2843 2004-07-26 Fernando Perez <fperez@colorado.edu>
2839
2844
2840 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
2845 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
2841 fail for any number.
2846 fail for any number.
2842 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
2847 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
2843 empty bookmarks.
2848 empty bookmarks.
2844
2849
2845 2004-07-26 *** Released version 0.6.1
2850 2004-07-26 *** Released version 0.6.1
2846
2851
2847 2004-07-26 Fernando Perez <fperez@colorado.edu>
2852 2004-07-26 Fernando Perez <fperez@colorado.edu>
2848
2853
2849 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
2854 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
2850
2855
2851 * IPython/iplib.py (protect_filename): Applied Ville's patch for
2856 * IPython/iplib.py (protect_filename): Applied Ville's patch for
2852 escaping '()[]{}' in filenames.
2857 escaping '()[]{}' in filenames.
2853
2858
2854 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
2859 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
2855 Python 2.2 users who lack a proper shlex.split.
2860 Python 2.2 users who lack a proper shlex.split.
2856
2861
2857 2004-07-19 Fernando Perez <fperez@colorado.edu>
2862 2004-07-19 Fernando Perez <fperez@colorado.edu>
2858
2863
2859 * IPython/iplib.py (InteractiveShell.init_readline): Add support
2864 * IPython/iplib.py (InteractiveShell.init_readline): Add support
2860 for reading readline's init file. I follow the normal chain:
2865 for reading readline's init file. I follow the normal chain:
2861 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
2866 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
2862 report by Mike Heeter. This closes
2867 report by Mike Heeter. This closes
2863 http://www.scipy.net/roundup/ipython/issue16.
2868 http://www.scipy.net/roundup/ipython/issue16.
2864
2869
2865 2004-07-18 Fernando Perez <fperez@colorado.edu>
2870 2004-07-18 Fernando Perez <fperez@colorado.edu>
2866
2871
2867 * IPython/iplib.py (__init__): Add better handling of '\' under
2872 * IPython/iplib.py (__init__): Add better handling of '\' under
2868 Win32 for filenames. After a patch by Ville.
2873 Win32 for filenames. After a patch by Ville.
2869
2874
2870 2004-07-17 Fernando Perez <fperez@colorado.edu>
2875 2004-07-17 Fernando Perez <fperez@colorado.edu>
2871
2876
2872 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2877 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
2873 autocalling would be triggered for 'foo is bar' if foo is
2878 autocalling would be triggered for 'foo is bar' if foo is
2874 callable. I also cleaned up the autocall detection code to use a
2879 callable. I also cleaned up the autocall detection code to use a
2875 regexp, which is faster. Bug reported by Alexander Schmolck.
2880 regexp, which is faster. Bug reported by Alexander Schmolck.
2876
2881
2877 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
2882 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
2878 '?' in them would confuse the help system. Reported by Alex
2883 '?' in them would confuse the help system. Reported by Alex
2879 Schmolck.
2884 Schmolck.
2880
2885
2881 2004-07-16 Fernando Perez <fperez@colorado.edu>
2886 2004-07-16 Fernando Perez <fperez@colorado.edu>
2882
2887
2883 * IPython/GnuplotInteractive.py (__all__): added plot2.
2888 * IPython/GnuplotInteractive.py (__all__): added plot2.
2884
2889
2885 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
2890 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
2886 plotting dictionaries, lists or tuples of 1d arrays.
2891 plotting dictionaries, lists or tuples of 1d arrays.
2887
2892
2888 * IPython/Magic.py (Magic.magic_hist): small clenaups and
2893 * IPython/Magic.py (Magic.magic_hist): small clenaups and
2889 optimizations.
2894 optimizations.
2890
2895
2891 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
2896 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
2892 the information which was there from Janko's original IPP code:
2897 the information which was there from Janko's original IPP code:
2893
2898
2894 03.05.99 20:53 porto.ifm.uni-kiel.de
2899 03.05.99 20:53 porto.ifm.uni-kiel.de
2895 --Started changelog.
2900 --Started changelog.
2896 --make clear do what it say it does
2901 --make clear do what it say it does
2897 --added pretty output of lines from inputcache
2902 --added pretty output of lines from inputcache
2898 --Made Logger a mixin class, simplifies handling of switches
2903 --Made Logger a mixin class, simplifies handling of switches
2899 --Added own completer class. .string<TAB> expands to last history
2904 --Added own completer class. .string<TAB> expands to last history
2900 line which starts with string. The new expansion is also present
2905 line which starts with string. The new expansion is also present
2901 with Ctrl-r from the readline library. But this shows, who this
2906 with Ctrl-r from the readline library. But this shows, who this
2902 can be done for other cases.
2907 can be done for other cases.
2903 --Added convention that all shell functions should accept a
2908 --Added convention that all shell functions should accept a
2904 parameter_string This opens the door for different behaviour for
2909 parameter_string This opens the door for different behaviour for
2905 each function. @cd is a good example of this.
2910 each function. @cd is a good example of this.
2906
2911
2907 04.05.99 12:12 porto.ifm.uni-kiel.de
2912 04.05.99 12:12 porto.ifm.uni-kiel.de
2908 --added logfile rotation
2913 --added logfile rotation
2909 --added new mainloop method which freezes first the namespace
2914 --added new mainloop method which freezes first the namespace
2910
2915
2911 07.05.99 21:24 porto.ifm.uni-kiel.de
2916 07.05.99 21:24 porto.ifm.uni-kiel.de
2912 --added the docreader classes. Now there is a help system.
2917 --added the docreader classes. Now there is a help system.
2913 -This is only a first try. Currently it's not easy to put new
2918 -This is only a first try. Currently it's not easy to put new
2914 stuff in the indices. But this is the way to go. Info would be
2919 stuff in the indices. But this is the way to go. Info would be
2915 better, but HTML is every where and not everybody has an info
2920 better, but HTML is every where and not everybody has an info
2916 system installed and it's not so easy to change html-docs to info.
2921 system installed and it's not so easy to change html-docs to info.
2917 --added global logfile option
2922 --added global logfile option
2918 --there is now a hook for object inspection method pinfo needs to
2923 --there is now a hook for object inspection method pinfo needs to
2919 be provided for this. Can be reached by two '??'.
2924 be provided for this. Can be reached by two '??'.
2920
2925
2921 08.05.99 20:51 porto.ifm.uni-kiel.de
2926 08.05.99 20:51 porto.ifm.uni-kiel.de
2922 --added a README
2927 --added a README
2923 --bug in rc file. Something has changed so functions in the rc
2928 --bug in rc file. Something has changed so functions in the rc
2924 file need to reference the shell and not self. Not clear if it's a
2929 file need to reference the shell and not self. Not clear if it's a
2925 bug or feature.
2930 bug or feature.
2926 --changed rc file for new behavior
2931 --changed rc file for new behavior
2927
2932
2928 2004-07-15 Fernando Perez <fperez@colorado.edu>
2933 2004-07-15 Fernando Perez <fperez@colorado.edu>
2929
2934
2930 * IPython/Logger.py (Logger.log): fixed recent bug where the input
2935 * IPython/Logger.py (Logger.log): fixed recent bug where the input
2931 cache was falling out of sync in bizarre manners when multi-line
2936 cache was falling out of sync in bizarre manners when multi-line
2932 input was present. Minor optimizations and cleanup.
2937 input was present. Minor optimizations and cleanup.
2933
2938
2934 (Logger): Remove old Changelog info for cleanup. This is the
2939 (Logger): Remove old Changelog info for cleanup. This is the
2935 information which was there from Janko's original code:
2940 information which was there from Janko's original code:
2936
2941
2937 Changes to Logger: - made the default log filename a parameter
2942 Changes to Logger: - made the default log filename a parameter
2938
2943
2939 - put a check for lines beginning with !@? in log(). Needed
2944 - put a check for lines beginning with !@? in log(). Needed
2940 (even if the handlers properly log their lines) for mid-session
2945 (even if the handlers properly log their lines) for mid-session
2941 logging activation to work properly. Without this, lines logged
2946 logging activation to work properly. Without this, lines logged
2942 in mid session, which get read from the cache, would end up
2947 in mid session, which get read from the cache, would end up
2943 'bare' (with !@? in the open) in the log. Now they are caught
2948 'bare' (with !@? in the open) in the log. Now they are caught
2944 and prepended with a #.
2949 and prepended with a #.
2945
2950
2946 * IPython/iplib.py (InteractiveShell.init_readline): added check
2951 * IPython/iplib.py (InteractiveShell.init_readline): added check
2947 in case MagicCompleter fails to be defined, so we don't crash.
2952 in case MagicCompleter fails to be defined, so we don't crash.
2948
2953
2949 2004-07-13 Fernando Perez <fperez@colorado.edu>
2954 2004-07-13 Fernando Perez <fperez@colorado.edu>
2950
2955
2951 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
2956 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
2952 of EPS if the requested filename ends in '.eps'.
2957 of EPS if the requested filename ends in '.eps'.
2953
2958
2954 2004-07-04 Fernando Perez <fperez@colorado.edu>
2959 2004-07-04 Fernando Perez <fperez@colorado.edu>
2955
2960
2956 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
2961 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
2957 escaping of quotes when calling the shell.
2962 escaping of quotes when calling the shell.
2958
2963
2959 2004-07-02 Fernando Perez <fperez@colorado.edu>
2964 2004-07-02 Fernando Perez <fperez@colorado.edu>
2960
2965
2961 * IPython/Prompts.py (CachedOutput.update): Fix problem with
2966 * IPython/Prompts.py (CachedOutput.update): Fix problem with
2962 gettext not working because we were clobbering '_'. Fixes
2967 gettext not working because we were clobbering '_'. Fixes
2963 http://www.scipy.net/roundup/ipython/issue6.
2968 http://www.scipy.net/roundup/ipython/issue6.
2964
2969
2965 2004-07-01 Fernando Perez <fperez@colorado.edu>
2970 2004-07-01 Fernando Perez <fperez@colorado.edu>
2966
2971
2967 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
2972 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
2968 into @cd. Patch by Ville.
2973 into @cd. Patch by Ville.
2969
2974
2970 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2975 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2971 new function to store things after ipmaker runs. Patch by Ville.
2976 new function to store things after ipmaker runs. Patch by Ville.
2972 Eventually this will go away once ipmaker is removed and the class
2977 Eventually this will go away once ipmaker is removed and the class
2973 gets cleaned up, but for now it's ok. Key functionality here is
2978 gets cleaned up, but for now it's ok. Key functionality here is
2974 the addition of the persistent storage mechanism, a dict for
2979 the addition of the persistent storage mechanism, a dict for
2975 keeping data across sessions (for now just bookmarks, but more can
2980 keeping data across sessions (for now just bookmarks, but more can
2976 be implemented later).
2981 be implemented later).
2977
2982
2978 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
2983 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
2979 persistent across sections. Patch by Ville, I modified it
2984 persistent across sections. Patch by Ville, I modified it
2980 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
2985 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
2981 added a '-l' option to list all bookmarks.
2986 added a '-l' option to list all bookmarks.
2982
2987
2983 * IPython/iplib.py (InteractiveShell.atexit_operations): new
2988 * IPython/iplib.py (InteractiveShell.atexit_operations): new
2984 center for cleanup. Registered with atexit.register(). I moved
2989 center for cleanup. Registered with atexit.register(). I moved
2985 here the old exit_cleanup(). After a patch by Ville.
2990 here the old exit_cleanup(). After a patch by Ville.
2986
2991
2987 * IPython/Magic.py (get_py_filename): added '~' to the accepted
2992 * IPython/Magic.py (get_py_filename): added '~' to the accepted
2988 characters in the hacked shlex_split for python 2.2.
2993 characters in the hacked shlex_split for python 2.2.
2989
2994
2990 * IPython/iplib.py (file_matches): more fixes to filenames with
2995 * IPython/iplib.py (file_matches): more fixes to filenames with
2991 whitespace in them. It's not perfect, but limitations in python's
2996 whitespace in them. It's not perfect, but limitations in python's
2992 readline make it impossible to go further.
2997 readline make it impossible to go further.
2993
2998
2994 2004-06-29 Fernando Perez <fperez@colorado.edu>
2999 2004-06-29 Fernando Perez <fperez@colorado.edu>
2995
3000
2996 * IPython/iplib.py (file_matches): escape whitespace correctly in
3001 * IPython/iplib.py (file_matches): escape whitespace correctly in
2997 filename completions. Bug reported by Ville.
3002 filename completions. Bug reported by Ville.
2998
3003
2999 2004-06-28 Fernando Perez <fperez@colorado.edu>
3004 2004-06-28 Fernando Perez <fperez@colorado.edu>
3000
3005
3001 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
3006 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
3002 the history file will be called 'history-PROFNAME' (or just
3007 the history file will be called 'history-PROFNAME' (or just
3003 'history' if no profile is loaded). I was getting annoyed at
3008 'history' if no profile is loaded). I was getting annoyed at
3004 getting my Numerical work history clobbered by pysh sessions.
3009 getting my Numerical work history clobbered by pysh sessions.
3005
3010
3006 * IPython/iplib.py (InteractiveShell.__init__): Internal
3011 * IPython/iplib.py (InteractiveShell.__init__): Internal
3007 getoutputerror() function so that we can honor the system_verbose
3012 getoutputerror() function so that we can honor the system_verbose
3008 flag for _all_ system calls. I also added escaping of #
3013 flag for _all_ system calls. I also added escaping of #
3009 characters here to avoid confusing Itpl.
3014 characters here to avoid confusing Itpl.
3010
3015
3011 * IPython/Magic.py (shlex_split): removed call to shell in
3016 * IPython/Magic.py (shlex_split): removed call to shell in
3012 parse_options and replaced it with shlex.split(). The annoying
3017 parse_options and replaced it with shlex.split(). The annoying
3013 part was that in Python 2.2, shlex.split() doesn't exist, so I had
3018 part was that in Python 2.2, shlex.split() doesn't exist, so I had
3014 to backport it from 2.3, with several frail hacks (the shlex
3019 to backport it from 2.3, with several frail hacks (the shlex
3015 module is rather limited in 2.2). Thanks to a suggestion by Ville
3020 module is rather limited in 2.2). Thanks to a suggestion by Ville
3016 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
3021 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
3017 problem.
3022 problem.
3018
3023
3019 (Magic.magic_system_verbose): new toggle to print the actual
3024 (Magic.magic_system_verbose): new toggle to print the actual
3020 system calls made by ipython. Mainly for debugging purposes.
3025 system calls made by ipython. Mainly for debugging purposes.
3021
3026
3022 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
3027 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
3023 doesn't support persistence. Reported (and fix suggested) by
3028 doesn't support persistence. Reported (and fix suggested) by
3024 Travis Caldwell <travis_caldwell2000@yahoo.com>.
3029 Travis Caldwell <travis_caldwell2000@yahoo.com>.
3025
3030
3026 2004-06-26 Fernando Perez <fperez@colorado.edu>
3031 2004-06-26 Fernando Perez <fperez@colorado.edu>
3027
3032
3028 * IPython/Logger.py (Logger.log): fix to handle correctly empty
3033 * IPython/Logger.py (Logger.log): fix to handle correctly empty
3029 continue prompts.
3034 continue prompts.
3030
3035
3031 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
3036 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
3032 function (basically a big docstring) and a few more things here to
3037 function (basically a big docstring) and a few more things here to
3033 speedup startup. pysh.py is now very lightweight. We want because
3038 speedup startup. pysh.py is now very lightweight. We want because
3034 it gets execfile'd, while InterpreterExec gets imported, so
3039 it gets execfile'd, while InterpreterExec gets imported, so
3035 byte-compilation saves time.
3040 byte-compilation saves time.
3036
3041
3037 2004-06-25 Fernando Perez <fperez@colorado.edu>
3042 2004-06-25 Fernando Perez <fperez@colorado.edu>
3038
3043
3039 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
3044 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
3040 -NUM', which was recently broken.
3045 -NUM', which was recently broken.
3041
3046
3042 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
3047 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
3043 in multi-line input (but not !!, which doesn't make sense there).
3048 in multi-line input (but not !!, which doesn't make sense there).
3044
3049
3045 * IPython/UserConfig/ipythonrc: made autoindent on by default.
3050 * IPython/UserConfig/ipythonrc: made autoindent on by default.
3046 It's just too useful, and people can turn it off in the less
3051 It's just too useful, and people can turn it off in the less
3047 common cases where it's a problem.
3052 common cases where it's a problem.
3048
3053
3049 2004-06-24 Fernando Perez <fperez@colorado.edu>
3054 2004-06-24 Fernando Perez <fperez@colorado.edu>
3050
3055
3051 * IPython/iplib.py (InteractiveShell._prefilter): big change -
3056 * IPython/iplib.py (InteractiveShell._prefilter): big change -
3052 special syntaxes (like alias calling) is now allied in multi-line
3057 special syntaxes (like alias calling) is now allied in multi-line
3053 input. This is still _very_ experimental, but it's necessary for
3058 input. This is still _very_ experimental, but it's necessary for
3054 efficient shell usage combining python looping syntax with system
3059 efficient shell usage combining python looping syntax with system
3055 calls. For now it's restricted to aliases, I don't think it
3060 calls. For now it's restricted to aliases, I don't think it
3056 really even makes sense to have this for magics.
3061 really even makes sense to have this for magics.
3057
3062
3058 2004-06-23 Fernando Perez <fperez@colorado.edu>
3063 2004-06-23 Fernando Perez <fperez@colorado.edu>
3059
3064
3060 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
3065 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
3061 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
3066 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
3062
3067
3063 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
3068 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
3064 extensions under Windows (after code sent by Gary Bishop). The
3069 extensions under Windows (after code sent by Gary Bishop). The
3065 extensions considered 'executable' are stored in IPython's rc
3070 extensions considered 'executable' are stored in IPython's rc
3066 structure as win_exec_ext.
3071 structure as win_exec_ext.
3067
3072
3068 * IPython/genutils.py (shell): new function, like system() but
3073 * IPython/genutils.py (shell): new function, like system() but
3069 without return value. Very useful for interactive shell work.
3074 without return value. Very useful for interactive shell work.
3070
3075
3071 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
3076 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
3072 delete aliases.
3077 delete aliases.
3073
3078
3074 * IPython/iplib.py (InteractiveShell.alias_table_update): make
3079 * IPython/iplib.py (InteractiveShell.alias_table_update): make
3075 sure that the alias table doesn't contain python keywords.
3080 sure that the alias table doesn't contain python keywords.
3076
3081
3077 2004-06-21 Fernando Perez <fperez@colorado.edu>
3082 2004-06-21 Fernando Perez <fperez@colorado.edu>
3078
3083
3079 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
3084 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
3080 non-existent items are found in $PATH. Reported by Thorsten.
3085 non-existent items are found in $PATH. Reported by Thorsten.
3081
3086
3082 2004-06-20 Fernando Perez <fperez@colorado.edu>
3087 2004-06-20 Fernando Perez <fperez@colorado.edu>
3083
3088
3084 * IPython/iplib.py (complete): modified the completer so that the
3089 * IPython/iplib.py (complete): modified the completer so that the
3085 order of priorities can be easily changed at runtime.
3090 order of priorities can be easily changed at runtime.
3086
3091
3087 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
3092 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
3088 Modified to auto-execute all lines beginning with '~', '/' or '.'.
3093 Modified to auto-execute all lines beginning with '~', '/' or '.'.
3089
3094
3090 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
3095 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
3091 expand Python variables prepended with $ in all system calls. The
3096 expand Python variables prepended with $ in all system calls. The
3092 same was done to InteractiveShell.handle_shell_escape. Now all
3097 same was done to InteractiveShell.handle_shell_escape. Now all
3093 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
3098 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
3094 expansion of python variables and expressions according to the
3099 expansion of python variables and expressions according to the
3095 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
3100 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
3096
3101
3097 Though PEP-215 has been rejected, a similar (but simpler) one
3102 Though PEP-215 has been rejected, a similar (but simpler) one
3098 seems like it will go into Python 2.4, PEP-292 -
3103 seems like it will go into Python 2.4, PEP-292 -
3099 http://www.python.org/peps/pep-0292.html.
3104 http://www.python.org/peps/pep-0292.html.
3100
3105
3101 I'll keep the full syntax of PEP-215, since IPython has since the
3106 I'll keep the full syntax of PEP-215, since IPython has since the
3102 start used Ka-Ping Yee's reference implementation discussed there
3107 start used Ka-Ping Yee's reference implementation discussed there
3103 (Itpl), and I actually like the powerful semantics it offers.
3108 (Itpl), and I actually like the powerful semantics it offers.
3104
3109
3105 In order to access normal shell variables, the $ has to be escaped
3110 In order to access normal shell variables, the $ has to be escaped
3106 via an extra $. For example:
3111 via an extra $. For example:
3107
3112
3108 In [7]: PATH='a python variable'
3113 In [7]: PATH='a python variable'
3109
3114
3110 In [8]: !echo $PATH
3115 In [8]: !echo $PATH
3111 a python variable
3116 a python variable
3112
3117
3113 In [9]: !echo $$PATH
3118 In [9]: !echo $$PATH
3114 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
3119 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
3115
3120
3116 (Magic.parse_options): escape $ so the shell doesn't evaluate
3121 (Magic.parse_options): escape $ so the shell doesn't evaluate
3117 things prematurely.
3122 things prematurely.
3118
3123
3119 * IPython/iplib.py (InteractiveShell.call_alias): added the
3124 * IPython/iplib.py (InteractiveShell.call_alias): added the
3120 ability for aliases to expand python variables via $.
3125 ability for aliases to expand python variables via $.
3121
3126
3122 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
3127 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
3123 system, now there's a @rehash/@rehashx pair of magics. These work
3128 system, now there's a @rehash/@rehashx pair of magics. These work
3124 like the csh rehash command, and can be invoked at any time. They
3129 like the csh rehash command, and can be invoked at any time. They
3125 build a table of aliases to everything in the user's $PATH
3130 build a table of aliases to everything in the user's $PATH
3126 (@rehash uses everything, @rehashx is slower but only adds
3131 (@rehash uses everything, @rehashx is slower but only adds
3127 executable files). With this, the pysh.py-based shell profile can
3132 executable files). With this, the pysh.py-based shell profile can
3128 now simply call rehash upon startup, and full access to all
3133 now simply call rehash upon startup, and full access to all
3129 programs in the user's path is obtained.
3134 programs in the user's path is obtained.
3130
3135
3131 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
3136 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
3132 functionality is now fully in place. I removed the old dynamic
3137 functionality is now fully in place. I removed the old dynamic
3133 code generation based approach, in favor of a much lighter one
3138 code generation based approach, in favor of a much lighter one
3134 based on a simple dict. The advantage is that this allows me to
3139 based on a simple dict. The advantage is that this allows me to
3135 now have thousands of aliases with negligible cost (unthinkable
3140 now have thousands of aliases with negligible cost (unthinkable
3136 with the old system).
3141 with the old system).
3137
3142
3138 2004-06-19 Fernando Perez <fperez@colorado.edu>
3143 2004-06-19 Fernando Perez <fperez@colorado.edu>
3139
3144
3140 * IPython/iplib.py (__init__): extended MagicCompleter class to
3145 * IPython/iplib.py (__init__): extended MagicCompleter class to
3141 also complete (last in priority) on user aliases.
3146 also complete (last in priority) on user aliases.
3142
3147
3143 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
3148 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
3144 call to eval.
3149 call to eval.
3145 (ItplNS.__init__): Added a new class which functions like Itpl,
3150 (ItplNS.__init__): Added a new class which functions like Itpl,
3146 but allows configuring the namespace for the evaluation to occur
3151 but allows configuring the namespace for the evaluation to occur
3147 in.
3152 in.
3148
3153
3149 2004-06-18 Fernando Perez <fperez@colorado.edu>
3154 2004-06-18 Fernando Perez <fperez@colorado.edu>
3150
3155
3151 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
3156 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
3152 better message when 'exit' or 'quit' are typed (a common newbie
3157 better message when 'exit' or 'quit' are typed (a common newbie
3153 confusion).
3158 confusion).
3154
3159
3155 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
3160 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
3156 check for Windows users.
3161 check for Windows users.
3157
3162
3158 * IPython/iplib.py (InteractiveShell.user_setup): removed
3163 * IPython/iplib.py (InteractiveShell.user_setup): removed
3159 disabling of colors for Windows. I'll test at runtime and issue a
3164 disabling of colors for Windows. I'll test at runtime and issue a
3160 warning if Gary's readline isn't found, as to nudge users to
3165 warning if Gary's readline isn't found, as to nudge users to
3161 download it.
3166 download it.
3162
3167
3163 2004-06-16 Fernando Perez <fperez@colorado.edu>
3168 2004-06-16 Fernando Perez <fperez@colorado.edu>
3164
3169
3165 * IPython/genutils.py (Stream.__init__): changed to print errors
3170 * IPython/genutils.py (Stream.__init__): changed to print errors
3166 to sys.stderr. I had a circular dependency here. Now it's
3171 to sys.stderr. I had a circular dependency here. Now it's
3167 possible to run ipython as IDLE's shell (consider this pre-alpha,
3172 possible to run ipython as IDLE's shell (consider this pre-alpha,
3168 since true stdout things end up in the starting terminal instead
3173 since true stdout things end up in the starting terminal instead
3169 of IDLE's out).
3174 of IDLE's out).
3170
3175
3171 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
3176 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
3172 users who haven't # updated their prompt_in2 definitions. Remove
3177 users who haven't # updated their prompt_in2 definitions. Remove
3173 eventually.
3178 eventually.
3174 (multiple_replace): added credit to original ASPN recipe.
3179 (multiple_replace): added credit to original ASPN recipe.
3175
3180
3176 2004-06-15 Fernando Perez <fperez@colorado.edu>
3181 2004-06-15 Fernando Perez <fperez@colorado.edu>
3177
3182
3178 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
3183 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
3179 list of auto-defined aliases.
3184 list of auto-defined aliases.
3180
3185
3181 2004-06-13 Fernando Perez <fperez@colorado.edu>
3186 2004-06-13 Fernando Perez <fperez@colorado.edu>
3182
3187
3183 * setup.py (scriptfiles): Don't trigger win_post_install unless an
3188 * setup.py (scriptfiles): Don't trigger win_post_install unless an
3184 install was really requested (so setup.py can be used for other
3189 install was really requested (so setup.py can be used for other
3185 things under Windows).
3190 things under Windows).
3186
3191
3187 2004-06-10 Fernando Perez <fperez@colorado.edu>
3192 2004-06-10 Fernando Perez <fperez@colorado.edu>
3188
3193
3189 * IPython/Logger.py (Logger.create_log): Manually remove any old
3194 * IPython/Logger.py (Logger.create_log): Manually remove any old
3190 backup, since os.remove may fail under Windows. Fixes bug
3195 backup, since os.remove may fail under Windows. Fixes bug
3191 reported by Thorsten.
3196 reported by Thorsten.
3192
3197
3193 2004-06-09 Fernando Perez <fperez@colorado.edu>
3198 2004-06-09 Fernando Perez <fperez@colorado.edu>
3194
3199
3195 * examples/example-embed.py: fixed all references to %n (replaced
3200 * examples/example-embed.py: fixed all references to %n (replaced
3196 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
3201 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
3197 for all examples and the manual as well.
3202 for all examples and the manual as well.
3198
3203
3199 2004-06-08 Fernando Perez <fperez@colorado.edu>
3204 2004-06-08 Fernando Perez <fperez@colorado.edu>
3200
3205
3201 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
3206 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
3202 alignment and color management. All 3 prompt subsystems now
3207 alignment and color management. All 3 prompt subsystems now
3203 inherit from BasePrompt.
3208 inherit from BasePrompt.
3204
3209
3205 * tools/release: updates for windows installer build and tag rpms
3210 * tools/release: updates for windows installer build and tag rpms
3206 with python version (since paths are fixed).
3211 with python version (since paths are fixed).
3207
3212
3208 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
3213 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
3209 which will become eventually obsolete. Also fixed the default
3214 which will become eventually obsolete. Also fixed the default
3210 prompt_in2 to use \D, so at least new users start with the correct
3215 prompt_in2 to use \D, so at least new users start with the correct
3211 defaults.
3216 defaults.
3212 WARNING: Users with existing ipythonrc files will need to apply
3217 WARNING: Users with existing ipythonrc files will need to apply
3213 this fix manually!
3218 this fix manually!
3214
3219
3215 * setup.py: make windows installer (.exe). This is finally the
3220 * setup.py: make windows installer (.exe). This is finally the
3216 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
3221 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
3217 which I hadn't included because it required Python 2.3 (or recent
3222 which I hadn't included because it required Python 2.3 (or recent
3218 distutils).
3223 distutils).
3219
3224
3220 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
3225 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
3221 usage of new '\D' escape.
3226 usage of new '\D' escape.
3222
3227
3223 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
3228 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
3224 lacks os.getuid())
3229 lacks os.getuid())
3225 (CachedOutput.set_colors): Added the ability to turn coloring
3230 (CachedOutput.set_colors): Added the ability to turn coloring
3226 on/off with @colors even for manually defined prompt colors. It
3231 on/off with @colors even for manually defined prompt colors. It
3227 uses a nasty global, but it works safely and via the generic color
3232 uses a nasty global, but it works safely and via the generic color
3228 handling mechanism.
3233 handling mechanism.
3229 (Prompt2.__init__): Introduced new escape '\D' for continuation
3234 (Prompt2.__init__): Introduced new escape '\D' for continuation
3230 prompts. It represents the counter ('\#') as dots.
3235 prompts. It represents the counter ('\#') as dots.
3231 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
3236 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
3232 need to update their ipythonrc files and replace '%n' with '\D' in
3237 need to update their ipythonrc files and replace '%n' with '\D' in
3233 their prompt_in2 settings everywhere. Sorry, but there's
3238 their prompt_in2 settings everywhere. Sorry, but there's
3234 otherwise no clean way to get all prompts to properly align. The
3239 otherwise no clean way to get all prompts to properly align. The
3235 ipythonrc shipped with IPython has been updated.
3240 ipythonrc shipped with IPython has been updated.
3236
3241
3237 2004-06-07 Fernando Perez <fperez@colorado.edu>
3242 2004-06-07 Fernando Perez <fperez@colorado.edu>
3238
3243
3239 * setup.py (isfile): Pass local_icons option to latex2html, so the
3244 * setup.py (isfile): Pass local_icons option to latex2html, so the
3240 resulting HTML file is self-contained. Thanks to
3245 resulting HTML file is self-contained. Thanks to
3241 dryice-AT-liu.com.cn for the tip.
3246 dryice-AT-liu.com.cn for the tip.
3242
3247
3243 * pysh.py: I created a new profile 'shell', which implements a
3248 * pysh.py: I created a new profile 'shell', which implements a
3244 _rudimentary_ IPython-based shell. This is in NO WAY a realy
3249 _rudimentary_ IPython-based shell. This is in NO WAY a realy
3245 system shell, nor will it become one anytime soon. It's mainly
3250 system shell, nor will it become one anytime soon. It's mainly
3246 meant to illustrate the use of the new flexible bash-like prompts.
3251 meant to illustrate the use of the new flexible bash-like prompts.
3247 I guess it could be used by hardy souls for true shell management,
3252 I guess it could be used by hardy souls for true shell management,
3248 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
3253 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
3249 profile. This uses the InterpreterExec extension provided by
3254 profile. This uses the InterpreterExec extension provided by
3250 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
3255 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
3251
3256
3252 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
3257 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
3253 auto-align itself with the length of the previous input prompt
3258 auto-align itself with the length of the previous input prompt
3254 (taking into account the invisible color escapes).
3259 (taking into account the invisible color escapes).
3255 (CachedOutput.__init__): Large restructuring of this class. Now
3260 (CachedOutput.__init__): Large restructuring of this class. Now
3256 all three prompts (primary1, primary2, output) are proper objects,
3261 all three prompts (primary1, primary2, output) are proper objects,
3257 managed by the 'parent' CachedOutput class. The code is still a
3262 managed by the 'parent' CachedOutput class. The code is still a
3258 bit hackish (all prompts share state via a pointer to the cache),
3263 bit hackish (all prompts share state via a pointer to the cache),
3259 but it's overall far cleaner than before.
3264 but it's overall far cleaner than before.
3260
3265
3261 * IPython/genutils.py (getoutputerror): modified to add verbose,
3266 * IPython/genutils.py (getoutputerror): modified to add verbose,
3262 debug and header options. This makes the interface of all getout*
3267 debug and header options. This makes the interface of all getout*
3263 functions uniform.
3268 functions uniform.
3264 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
3269 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
3265
3270
3266 * IPython/Magic.py (Magic.default_option): added a function to
3271 * IPython/Magic.py (Magic.default_option): added a function to
3267 allow registering default options for any magic command. This
3272 allow registering default options for any magic command. This
3268 makes it easy to have profiles which customize the magics globally
3273 makes it easy to have profiles which customize the magics globally
3269 for a certain use. The values set through this function are
3274 for a certain use. The values set through this function are
3270 picked up by the parse_options() method, which all magics should
3275 picked up by the parse_options() method, which all magics should
3271 use to parse their options.
3276 use to parse their options.
3272
3277
3273 * IPython/genutils.py (warn): modified the warnings framework to
3278 * IPython/genutils.py (warn): modified the warnings framework to
3274 use the Term I/O class. I'm trying to slowly unify all of
3279 use the Term I/O class. I'm trying to slowly unify all of
3275 IPython's I/O operations to pass through Term.
3280 IPython's I/O operations to pass through Term.
3276
3281
3277 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
3282 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
3278 the secondary prompt to correctly match the length of the primary
3283 the secondary prompt to correctly match the length of the primary
3279 one for any prompt. Now multi-line code will properly line up
3284 one for any prompt. Now multi-line code will properly line up
3280 even for path dependent prompts, such as the new ones available
3285 even for path dependent prompts, such as the new ones available
3281 via the prompt_specials.
3286 via the prompt_specials.
3282
3287
3283 2004-06-06 Fernando Perez <fperez@colorado.edu>
3288 2004-06-06 Fernando Perez <fperez@colorado.edu>
3284
3289
3285 * IPython/Prompts.py (prompt_specials): Added the ability to have
3290 * IPython/Prompts.py (prompt_specials): Added the ability to have
3286 bash-like special sequences in the prompts, which get
3291 bash-like special sequences in the prompts, which get
3287 automatically expanded. Things like hostname, current working
3292 automatically expanded. Things like hostname, current working
3288 directory and username are implemented already, but it's easy to
3293 directory and username are implemented already, but it's easy to
3289 add more in the future. Thanks to a patch by W.J. van der Laan
3294 add more in the future. Thanks to a patch by W.J. van der Laan
3290 <gnufnork-AT-hetdigitalegat.nl>
3295 <gnufnork-AT-hetdigitalegat.nl>
3291 (prompt_specials): Added color support for prompt strings, so
3296 (prompt_specials): Added color support for prompt strings, so
3292 users can define arbitrary color setups for their prompts.
3297 users can define arbitrary color setups for their prompts.
3293
3298
3294 2004-06-05 Fernando Perez <fperez@colorado.edu>
3299 2004-06-05 Fernando Perez <fperez@colorado.edu>
3295
3300
3296 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
3301 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
3297 code to load Gary Bishop's readline and configure it
3302 code to load Gary Bishop's readline and configure it
3298 automatically. Thanks to Gary for help on this.
3303 automatically. Thanks to Gary for help on this.
3299
3304
3300 2004-06-01 Fernando Perez <fperez@colorado.edu>
3305 2004-06-01 Fernando Perez <fperez@colorado.edu>
3301
3306
3302 * IPython/Logger.py (Logger.create_log): fix bug for logging
3307 * IPython/Logger.py (Logger.create_log): fix bug for logging
3303 with no filename (previous fix was incomplete).
3308 with no filename (previous fix was incomplete).
3304
3309
3305 2004-05-25 Fernando Perez <fperez@colorado.edu>
3310 2004-05-25 Fernando Perez <fperez@colorado.edu>
3306
3311
3307 * IPython/Magic.py (Magic.parse_options): fix bug where naked
3312 * IPython/Magic.py (Magic.parse_options): fix bug where naked
3308 parens would get passed to the shell.
3313 parens would get passed to the shell.
3309
3314
3310 2004-05-20 Fernando Perez <fperez@colorado.edu>
3315 2004-05-20 Fernando Perez <fperez@colorado.edu>
3311
3316
3312 * IPython/Magic.py (Magic.magic_prun): changed default profile
3317 * IPython/Magic.py (Magic.magic_prun): changed default profile
3313 sort order to 'time' (the more common profiling need).
3318 sort order to 'time' (the more common profiling need).
3314
3319
3315 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
3320 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
3316 so that source code shown is guaranteed in sync with the file on
3321 so that source code shown is guaranteed in sync with the file on
3317 disk (also changed in psource). Similar fix to the one for
3322 disk (also changed in psource). Similar fix to the one for
3318 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
3323 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
3319 <yann.ledu-AT-noos.fr>.
3324 <yann.ledu-AT-noos.fr>.
3320
3325
3321 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
3326 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
3322 with a single option would not be correctly parsed. Closes
3327 with a single option would not be correctly parsed. Closes
3323 http://www.scipy.net/roundup/ipython/issue14. This bug had been
3328 http://www.scipy.net/roundup/ipython/issue14. This bug had been
3324 introduced in 0.6.0 (on 2004-05-06).
3329 introduced in 0.6.0 (on 2004-05-06).
3325
3330
3326 2004-05-13 *** Released version 0.6.0
3331 2004-05-13 *** Released version 0.6.0
3327
3332
3328 2004-05-13 Fernando Perez <fperez@colorado.edu>
3333 2004-05-13 Fernando Perez <fperez@colorado.edu>
3329
3334
3330 * debian/: Added debian/ directory to CVS, so that debian support
3335 * debian/: Added debian/ directory to CVS, so that debian support
3331 is publicly accessible. The debian package is maintained by Jack
3336 is publicly accessible. The debian package is maintained by Jack
3332 Moffit <jack-AT-xiph.org>.
3337 Moffit <jack-AT-xiph.org>.
3333
3338
3334 * Documentation: included the notes about an ipython-based system
3339 * Documentation: included the notes about an ipython-based system
3335 shell (the hypothetical 'pysh') into the new_design.pdf document,
3340 shell (the hypothetical 'pysh') into the new_design.pdf document,
3336 so that these ideas get distributed to users along with the
3341 so that these ideas get distributed to users along with the
3337 official documentation.
3342 official documentation.
3338
3343
3339 2004-05-10 Fernando Perez <fperez@colorado.edu>
3344 2004-05-10 Fernando Perez <fperez@colorado.edu>
3340
3345
3341 * IPython/Logger.py (Logger.create_log): fix recently introduced
3346 * IPython/Logger.py (Logger.create_log): fix recently introduced
3342 bug (misindented line) where logstart would fail when not given an
3347 bug (misindented line) where logstart would fail when not given an
3343 explicit filename.
3348 explicit filename.
3344
3349
3345 2004-05-09 Fernando Perez <fperez@colorado.edu>
3350 2004-05-09 Fernando Perez <fperez@colorado.edu>
3346
3351
3347 * IPython/Magic.py (Magic.parse_options): skip system call when
3352 * IPython/Magic.py (Magic.parse_options): skip system call when
3348 there are no options to look for. Faster, cleaner for the common
3353 there are no options to look for. Faster, cleaner for the common
3349 case.
3354 case.
3350
3355
3351 * Documentation: many updates to the manual: describing Windows
3356 * Documentation: many updates to the manual: describing Windows
3352 support better, Gnuplot updates, credits, misc small stuff. Also
3357 support better, Gnuplot updates, credits, misc small stuff. Also
3353 updated the new_design doc a bit.
3358 updated the new_design doc a bit.
3354
3359
3355 2004-05-06 *** Released version 0.6.0.rc1
3360 2004-05-06 *** Released version 0.6.0.rc1
3356
3361
3357 2004-05-06 Fernando Perez <fperez@colorado.edu>
3362 2004-05-06 Fernando Perez <fperez@colorado.edu>
3358
3363
3359 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
3364 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
3360 operations to use the vastly more efficient list/''.join() method.
3365 operations to use the vastly more efficient list/''.join() method.
3361 (FormattedTB.text): Fix
3366 (FormattedTB.text): Fix
3362 http://www.scipy.net/roundup/ipython/issue12 - exception source
3367 http://www.scipy.net/roundup/ipython/issue12 - exception source
3363 extract not updated after reload. Thanks to Mike Salib
3368 extract not updated after reload. Thanks to Mike Salib
3364 <msalib-AT-mit.edu> for pinning the source of the problem.
3369 <msalib-AT-mit.edu> for pinning the source of the problem.
3365 Fortunately, the solution works inside ipython and doesn't require
3370 Fortunately, the solution works inside ipython and doesn't require
3366 any changes to python proper.
3371 any changes to python proper.
3367
3372
3368 * IPython/Magic.py (Magic.parse_options): Improved to process the
3373 * IPython/Magic.py (Magic.parse_options): Improved to process the
3369 argument list as a true shell would (by actually using the
3374 argument list as a true shell would (by actually using the
3370 underlying system shell). This way, all @magics automatically get
3375 underlying system shell). This way, all @magics automatically get
3371 shell expansion for variables. Thanks to a comment by Alex
3376 shell expansion for variables. Thanks to a comment by Alex
3372 Schmolck.
3377 Schmolck.
3373
3378
3374 2004-04-04 Fernando Perez <fperez@colorado.edu>
3379 2004-04-04 Fernando Perez <fperez@colorado.edu>
3375
3380
3376 * IPython/iplib.py (InteractiveShell.interact): Added a special
3381 * IPython/iplib.py (InteractiveShell.interact): Added a special
3377 trap for a debugger quit exception, which is basically impossible
3382 trap for a debugger quit exception, which is basically impossible
3378 to handle by normal mechanisms, given what pdb does to the stack.
3383 to handle by normal mechanisms, given what pdb does to the stack.
3379 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
3384 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
3380
3385
3381 2004-04-03 Fernando Perez <fperez@colorado.edu>
3386 2004-04-03 Fernando Perez <fperez@colorado.edu>
3382
3387
3383 * IPython/genutils.py (Term): Standardized the names of the Term
3388 * IPython/genutils.py (Term): Standardized the names of the Term
3384 class streams to cin/cout/cerr, following C++ naming conventions
3389 class streams to cin/cout/cerr, following C++ naming conventions
3385 (I can't use in/out/err because 'in' is not a valid attribute
3390 (I can't use in/out/err because 'in' is not a valid attribute
3386 name).
3391 name).
3387
3392
3388 * IPython/iplib.py (InteractiveShell.interact): don't increment
3393 * IPython/iplib.py (InteractiveShell.interact): don't increment
3389 the prompt if there's no user input. By Daniel 'Dang' Griffith
3394 the prompt if there's no user input. By Daniel 'Dang' Griffith
3390 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
3395 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
3391 Francois Pinard.
3396 Francois Pinard.
3392
3397
3393 2004-04-02 Fernando Perez <fperez@colorado.edu>
3398 2004-04-02 Fernando Perez <fperez@colorado.edu>
3394
3399
3395 * IPython/genutils.py (Stream.__init__): Modified to survive at
3400 * IPython/genutils.py (Stream.__init__): Modified to survive at
3396 least importing in contexts where stdin/out/err aren't true file
3401 least importing in contexts where stdin/out/err aren't true file
3397 objects, such as PyCrust (they lack fileno() and mode). However,
3402 objects, such as PyCrust (they lack fileno() and mode). However,
3398 the recovery facilities which rely on these things existing will
3403 the recovery facilities which rely on these things existing will
3399 not work.
3404 not work.
3400
3405
3401 2004-04-01 Fernando Perez <fperez@colorado.edu>
3406 2004-04-01 Fernando Perez <fperez@colorado.edu>
3402
3407
3403 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
3408 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
3404 use the new getoutputerror() function, so it properly
3409 use the new getoutputerror() function, so it properly
3405 distinguishes stdout/err.
3410 distinguishes stdout/err.
3406
3411
3407 * IPython/genutils.py (getoutputerror): added a function to
3412 * IPython/genutils.py (getoutputerror): added a function to
3408 capture separately the standard output and error of a command.
3413 capture separately the standard output and error of a command.
3409 After a comment from dang on the mailing lists. This code is
3414 After a comment from dang on the mailing lists. This code is
3410 basically a modified version of commands.getstatusoutput(), from
3415 basically a modified version of commands.getstatusoutput(), from
3411 the standard library.
3416 the standard library.
3412
3417
3413 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
3418 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
3414 '!!' as a special syntax (shorthand) to access @sx.
3419 '!!' as a special syntax (shorthand) to access @sx.
3415
3420
3416 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
3421 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
3417 command and return its output as a list split on '\n'.
3422 command and return its output as a list split on '\n'.
3418
3423
3419 2004-03-31 Fernando Perez <fperez@colorado.edu>
3424 2004-03-31 Fernando Perez <fperez@colorado.edu>
3420
3425
3421 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
3426 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
3422 method to dictionaries used as FakeModule instances if they lack
3427 method to dictionaries used as FakeModule instances if they lack
3423 it. At least pydoc in python2.3 breaks for runtime-defined
3428 it. At least pydoc in python2.3 breaks for runtime-defined
3424 functions without this hack. At some point I need to _really_
3429 functions without this hack. At some point I need to _really_
3425 understand what FakeModule is doing, because it's a gross hack.
3430 understand what FakeModule is doing, because it's a gross hack.
3426 But it solves Arnd's problem for now...
3431 But it solves Arnd's problem for now...
3427
3432
3428 2004-02-27 Fernando Perez <fperez@colorado.edu>
3433 2004-02-27 Fernando Perez <fperez@colorado.edu>
3429
3434
3430 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
3435 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
3431 mode would behave erratically. Also increased the number of
3436 mode would behave erratically. Also increased the number of
3432 possible logs in rotate mod to 999. Thanks to Rod Holland
3437 possible logs in rotate mod to 999. Thanks to Rod Holland
3433 <rhh@StructureLABS.com> for the report and fixes.
3438 <rhh@StructureLABS.com> for the report and fixes.
3434
3439
3435 2004-02-26 Fernando Perez <fperez@colorado.edu>
3440 2004-02-26 Fernando Perez <fperez@colorado.edu>
3436
3441
3437 * IPython/genutils.py (page): Check that the curses module really
3442 * IPython/genutils.py (page): Check that the curses module really
3438 has the initscr attribute before trying to use it. For some
3443 has the initscr attribute before trying to use it. For some
3439 reason, the Solaris curses module is missing this. I think this
3444 reason, the Solaris curses module is missing this. I think this
3440 should be considered a Solaris python bug, but I'm not sure.
3445 should be considered a Solaris python bug, but I'm not sure.
3441
3446
3442 2004-01-17 Fernando Perez <fperez@colorado.edu>
3447 2004-01-17 Fernando Perez <fperez@colorado.edu>
3443
3448
3444 * IPython/genutils.py (Stream.__init__): Changes to try to make
3449 * IPython/genutils.py (Stream.__init__): Changes to try to make
3445 ipython robust against stdin/out/err being closed by the user.
3450 ipython robust against stdin/out/err being closed by the user.
3446 This is 'user error' (and blocks a normal python session, at least
3451 This is 'user error' (and blocks a normal python session, at least
3447 the stdout case). However, Ipython should be able to survive such
3452 the stdout case). However, Ipython should be able to survive such
3448 instances of abuse as gracefully as possible. To simplify the
3453 instances of abuse as gracefully as possible. To simplify the
3449 coding and maintain compatibility with Gary Bishop's Term
3454 coding and maintain compatibility with Gary Bishop's Term
3450 contributions, I've made use of classmethods for this. I think
3455 contributions, I've made use of classmethods for this. I think
3451 this introduces a dependency on python 2.2.
3456 this introduces a dependency on python 2.2.
3452
3457
3453 2004-01-13 Fernando Perez <fperez@colorado.edu>
3458 2004-01-13 Fernando Perez <fperez@colorado.edu>
3454
3459
3455 * IPython/numutils.py (exp_safe): simplified the code a bit and
3460 * IPython/numutils.py (exp_safe): simplified the code a bit and
3456 removed the need for importing the kinds module altogether.
3461 removed the need for importing the kinds module altogether.
3457
3462
3458 2004-01-06 Fernando Perez <fperez@colorado.edu>
3463 2004-01-06 Fernando Perez <fperez@colorado.edu>
3459
3464
3460 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
3465 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
3461 a magic function instead, after some community feedback. No
3466 a magic function instead, after some community feedback. No
3462 special syntax will exist for it, but its name is deliberately
3467 special syntax will exist for it, but its name is deliberately
3463 very short.
3468 very short.
3464
3469
3465 2003-12-20 Fernando Perez <fperez@colorado.edu>
3470 2003-12-20 Fernando Perez <fperez@colorado.edu>
3466
3471
3467 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
3472 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
3468 new functionality, to automagically assign the result of a shell
3473 new functionality, to automagically assign the result of a shell
3469 command to a variable. I'll solicit some community feedback on
3474 command to a variable. I'll solicit some community feedback on
3470 this before making it permanent.
3475 this before making it permanent.
3471
3476
3472 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
3477 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
3473 requested about callables for which inspect couldn't obtain a
3478 requested about callables for which inspect couldn't obtain a
3474 proper argspec. Thanks to a crash report sent by Etienne
3479 proper argspec. Thanks to a crash report sent by Etienne
3475 Posthumus <etienne-AT-apple01.cs.vu.nl>.
3480 Posthumus <etienne-AT-apple01.cs.vu.nl>.
3476
3481
3477 2003-12-09 Fernando Perez <fperez@colorado.edu>
3482 2003-12-09 Fernando Perez <fperez@colorado.edu>
3478
3483
3479 * IPython/genutils.py (page): patch for the pager to work across
3484 * IPython/genutils.py (page): patch for the pager to work across
3480 various versions of Windows. By Gary Bishop.
3485 various versions of Windows. By Gary Bishop.
3481
3486
3482 2003-12-04 Fernando Perez <fperez@colorado.edu>
3487 2003-12-04 Fernando Perez <fperez@colorado.edu>
3483
3488
3484 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
3489 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
3485 Gnuplot.py version 1.7, whose internal names changed quite a bit.
3490 Gnuplot.py version 1.7, whose internal names changed quite a bit.
3486 While I tested this and it looks ok, there may still be corner
3491 While I tested this and it looks ok, there may still be corner
3487 cases I've missed.
3492 cases I've missed.
3488
3493
3489 2003-12-01 Fernando Perez <fperez@colorado.edu>
3494 2003-12-01 Fernando Perez <fperez@colorado.edu>
3490
3495
3491 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
3496 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
3492 where a line like 'p,q=1,2' would fail because the automagic
3497 where a line like 'p,q=1,2' would fail because the automagic
3493 system would be triggered for @p.
3498 system would be triggered for @p.
3494
3499
3495 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
3500 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
3496 cleanups, code unmodified.
3501 cleanups, code unmodified.
3497
3502
3498 * IPython/genutils.py (Term): added a class for IPython to handle
3503 * IPython/genutils.py (Term): added a class for IPython to handle
3499 output. In most cases it will just be a proxy for stdout/err, but
3504 output. In most cases it will just be a proxy for stdout/err, but
3500 having this allows modifications to be made for some platforms,
3505 having this allows modifications to be made for some platforms,
3501 such as handling color escapes under Windows. All of this code
3506 such as handling color escapes under Windows. All of this code
3502 was contributed by Gary Bishop, with minor modifications by me.
3507 was contributed by Gary Bishop, with minor modifications by me.
3503 The actual changes affect many files.
3508 The actual changes affect many files.
3504
3509
3505 2003-11-30 Fernando Perez <fperez@colorado.edu>
3510 2003-11-30 Fernando Perez <fperez@colorado.edu>
3506
3511
3507 * IPython/iplib.py (file_matches): new completion code, courtesy
3512 * IPython/iplib.py (file_matches): new completion code, courtesy
3508 of Jeff Collins. This enables filename completion again under
3513 of Jeff Collins. This enables filename completion again under
3509 python 2.3, which disabled it at the C level.
3514 python 2.3, which disabled it at the C level.
3510
3515
3511 2003-11-11 Fernando Perez <fperez@colorado.edu>
3516 2003-11-11 Fernando Perez <fperez@colorado.edu>
3512
3517
3513 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
3518 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
3514 for Numeric.array(map(...)), but often convenient.
3519 for Numeric.array(map(...)), but often convenient.
3515
3520
3516 2003-11-05 Fernando Perez <fperez@colorado.edu>
3521 2003-11-05 Fernando Perez <fperez@colorado.edu>
3517
3522
3518 * IPython/numutils.py (frange): Changed a call from int() to
3523 * IPython/numutils.py (frange): Changed a call from int() to
3519 int(round()) to prevent a problem reported with arange() in the
3524 int(round()) to prevent a problem reported with arange() in the
3520 numpy list.
3525 numpy list.
3521
3526
3522 2003-10-06 Fernando Perez <fperez@colorado.edu>
3527 2003-10-06 Fernando Perez <fperez@colorado.edu>
3523
3528
3524 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
3529 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
3525 prevent crashes if sys lacks an argv attribute (it happens with
3530 prevent crashes if sys lacks an argv attribute (it happens with
3526 embedded interpreters which build a bare-bones sys module).
3531 embedded interpreters which build a bare-bones sys module).
3527 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
3532 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
3528
3533
3529 2003-09-24 Fernando Perez <fperez@colorado.edu>
3534 2003-09-24 Fernando Perez <fperez@colorado.edu>
3530
3535
3531 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
3536 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
3532 to protect against poorly written user objects where __getattr__
3537 to protect against poorly written user objects where __getattr__
3533 raises exceptions other than AttributeError. Thanks to a bug
3538 raises exceptions other than AttributeError. Thanks to a bug
3534 report by Oliver Sander <osander-AT-gmx.de>.
3539 report by Oliver Sander <osander-AT-gmx.de>.
3535
3540
3536 * IPython/FakeModule.py (FakeModule.__repr__): this method was
3541 * IPython/FakeModule.py (FakeModule.__repr__): this method was
3537 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
3542 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
3538
3543
3539 2003-09-09 Fernando Perez <fperez@colorado.edu>
3544 2003-09-09 Fernando Perez <fperez@colorado.edu>
3540
3545
3541 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3546 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3542 unpacking a list whith a callable as first element would
3547 unpacking a list whith a callable as first element would
3543 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
3548 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
3544 Collins.
3549 Collins.
3545
3550
3546 2003-08-25 *** Released version 0.5.0
3551 2003-08-25 *** Released version 0.5.0
3547
3552
3548 2003-08-22 Fernando Perez <fperez@colorado.edu>
3553 2003-08-22 Fernando Perez <fperez@colorado.edu>
3549
3554
3550 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
3555 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
3551 improperly defined user exceptions. Thanks to feedback from Mark
3556 improperly defined user exceptions. Thanks to feedback from Mark
3552 Russell <mrussell-AT-verio.net>.
3557 Russell <mrussell-AT-verio.net>.
3553
3558
3554 2003-08-20 Fernando Perez <fperez@colorado.edu>
3559 2003-08-20 Fernando Perez <fperez@colorado.edu>
3555
3560
3556 * IPython/OInspect.py (Inspector.pinfo): changed String Form
3561 * IPython/OInspect.py (Inspector.pinfo): changed String Form
3557 printing so that it would print multi-line string forms starting
3562 printing so that it would print multi-line string forms starting
3558 with a new line. This way the formatting is better respected for
3563 with a new line. This way the formatting is better respected for
3559 objects which work hard to make nice string forms.
3564 objects which work hard to make nice string forms.
3560
3565
3561 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
3566 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
3562 autocall would overtake data access for objects with both
3567 autocall would overtake data access for objects with both
3563 __getitem__ and __call__.
3568 __getitem__ and __call__.
3564
3569
3565 2003-08-19 *** Released version 0.5.0-rc1
3570 2003-08-19 *** Released version 0.5.0-rc1
3566
3571
3567 2003-08-19 Fernando Perez <fperez@colorado.edu>
3572 2003-08-19 Fernando Perez <fperez@colorado.edu>
3568
3573
3569 * IPython/deep_reload.py (load_tail): single tiny change here
3574 * IPython/deep_reload.py (load_tail): single tiny change here
3570 seems to fix the long-standing bug of dreload() failing to work
3575 seems to fix the long-standing bug of dreload() failing to work
3571 for dotted names. But this module is pretty tricky, so I may have
3576 for dotted names. But this module is pretty tricky, so I may have
3572 missed some subtlety. Needs more testing!.
3577 missed some subtlety. Needs more testing!.
3573
3578
3574 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
3579 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
3575 exceptions which have badly implemented __str__ methods.
3580 exceptions which have badly implemented __str__ methods.
3576 (VerboseTB.text): harden against inspect.getinnerframes crashing,
3581 (VerboseTB.text): harden against inspect.getinnerframes crashing,
3577 which I've been getting reports about from Python 2.3 users. I
3582 which I've been getting reports about from Python 2.3 users. I
3578 wish I had a simple test case to reproduce the problem, so I could
3583 wish I had a simple test case to reproduce the problem, so I could
3579 either write a cleaner workaround or file a bug report if
3584 either write a cleaner workaround or file a bug report if
3580 necessary.
3585 necessary.
3581
3586
3582 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
3587 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
3583 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
3588 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
3584 a bug report by Tjabo Kloppenburg.
3589 a bug report by Tjabo Kloppenburg.
3585
3590
3586 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
3591 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
3587 crashes. Wrapped the pdb call in a blanket try/except, since pdb
3592 crashes. Wrapped the pdb call in a blanket try/except, since pdb
3588 seems rather unstable. Thanks to a bug report by Tjabo
3593 seems rather unstable. Thanks to a bug report by Tjabo
3589 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
3594 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
3590
3595
3591 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
3596 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
3592 this out soon because of the critical fixes in the inner loop for
3597 this out soon because of the critical fixes in the inner loop for
3593 generators.
3598 generators.
3594
3599
3595 * IPython/Magic.py (Magic.getargspec): removed. This (and
3600 * IPython/Magic.py (Magic.getargspec): removed. This (and
3596 _get_def) have been obsoleted by OInspect for a long time, I
3601 _get_def) have been obsoleted by OInspect for a long time, I
3597 hadn't noticed that they were dead code.
3602 hadn't noticed that they were dead code.
3598 (Magic._ofind): restored _ofind functionality for a few literals
3603 (Magic._ofind): restored _ofind functionality for a few literals
3599 (those in ["''",'""','[]','{}','()']). But it won't work anymore
3604 (those in ["''",'""','[]','{}','()']). But it won't work anymore
3600 for things like "hello".capitalize?, since that would require a
3605 for things like "hello".capitalize?, since that would require a
3601 potentially dangerous eval() again.
3606 potentially dangerous eval() again.
3602
3607
3603 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
3608 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
3604 logic a bit more to clean up the escapes handling and minimize the
3609 logic a bit more to clean up the escapes handling and minimize the
3605 use of _ofind to only necessary cases. The interactive 'feel' of
3610 use of _ofind to only necessary cases. The interactive 'feel' of
3606 IPython should have improved quite a bit with the changes in
3611 IPython should have improved quite a bit with the changes in
3607 _prefilter and _ofind (besides being far safer than before).
3612 _prefilter and _ofind (besides being far safer than before).
3608
3613
3609 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
3614 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
3610 obscure, never reported). Edit would fail to find the object to
3615 obscure, never reported). Edit would fail to find the object to
3611 edit under some circumstances.
3616 edit under some circumstances.
3612 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
3617 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
3613 which were causing double-calling of generators. Those eval calls
3618 which were causing double-calling of generators. Those eval calls
3614 were _very_ dangerous, since code with side effects could be
3619 were _very_ dangerous, since code with side effects could be
3615 triggered. As they say, 'eval is evil'... These were the
3620 triggered. As they say, 'eval is evil'... These were the
3616 nastiest evals in IPython. Besides, _ofind is now far simpler,
3621 nastiest evals in IPython. Besides, _ofind is now far simpler,
3617 and it should also be quite a bit faster. Its use of inspect is
3622 and it should also be quite a bit faster. Its use of inspect is
3618 also safer, so perhaps some of the inspect-related crashes I've
3623 also safer, so perhaps some of the inspect-related crashes I've
3619 seen lately with Python 2.3 might be taken care of. That will
3624 seen lately with Python 2.3 might be taken care of. That will
3620 need more testing.
3625 need more testing.
3621
3626
3622 2003-08-17 Fernando Perez <fperez@colorado.edu>
3627 2003-08-17 Fernando Perez <fperez@colorado.edu>
3623
3628
3624 * IPython/iplib.py (InteractiveShell._prefilter): significant
3629 * IPython/iplib.py (InteractiveShell._prefilter): significant
3625 simplifications to the logic for handling user escapes. Faster
3630 simplifications to the logic for handling user escapes. Faster
3626 and simpler code.
3631 and simpler code.
3627
3632
3628 2003-08-14 Fernando Perez <fperez@colorado.edu>
3633 2003-08-14 Fernando Perez <fperez@colorado.edu>
3629
3634
3630 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
3635 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
3631 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
3636 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
3632 but it should be quite a bit faster. And the recursive version
3637 but it should be quite a bit faster. And the recursive version
3633 generated O(log N) intermediate storage for all rank>1 arrays,
3638 generated O(log N) intermediate storage for all rank>1 arrays,
3634 even if they were contiguous.
3639 even if they were contiguous.
3635 (l1norm): Added this function.
3640 (l1norm): Added this function.
3636 (norm): Added this function for arbitrary norms (including
3641 (norm): Added this function for arbitrary norms (including
3637 l-infinity). l1 and l2 are still special cases for convenience
3642 l-infinity). l1 and l2 are still special cases for convenience
3638 and speed.
3643 and speed.
3639
3644
3640 2003-08-03 Fernando Perez <fperez@colorado.edu>
3645 2003-08-03 Fernando Perez <fperez@colorado.edu>
3641
3646
3642 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
3647 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
3643 exceptions, which now raise PendingDeprecationWarnings in Python
3648 exceptions, which now raise PendingDeprecationWarnings in Python
3644 2.3. There were some in Magic and some in Gnuplot2.
3649 2.3. There were some in Magic and some in Gnuplot2.
3645
3650
3646 2003-06-30 Fernando Perez <fperez@colorado.edu>
3651 2003-06-30 Fernando Perez <fperez@colorado.edu>
3647
3652
3648 * IPython/genutils.py (page): modified to call curses only for
3653 * IPython/genutils.py (page): modified to call curses only for
3649 terminals where TERM=='xterm'. After problems under many other
3654 terminals where TERM=='xterm'. After problems under many other
3650 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
3655 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
3651
3656
3652 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
3657 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
3653 would be triggered when readline was absent. This was just an old
3658 would be triggered when readline was absent. This was just an old
3654 debugging statement I'd forgotten to take out.
3659 debugging statement I'd forgotten to take out.
3655
3660
3656 2003-06-20 Fernando Perez <fperez@colorado.edu>
3661 2003-06-20 Fernando Perez <fperez@colorado.edu>
3657
3662
3658 * IPython/genutils.py (clock): modified to return only user time
3663 * IPython/genutils.py (clock): modified to return only user time
3659 (not counting system time), after a discussion on scipy. While
3664 (not counting system time), after a discussion on scipy. While
3660 system time may be a useful quantity occasionally, it may much
3665 system time may be a useful quantity occasionally, it may much
3661 more easily be skewed by occasional swapping or other similar
3666 more easily be skewed by occasional swapping or other similar
3662 activity.
3667 activity.
3663
3668
3664 2003-06-05 Fernando Perez <fperez@colorado.edu>
3669 2003-06-05 Fernando Perez <fperez@colorado.edu>
3665
3670
3666 * IPython/numutils.py (identity): new function, for building
3671 * IPython/numutils.py (identity): new function, for building
3667 arbitrary rank Kronecker deltas (mostly backwards compatible with
3672 arbitrary rank Kronecker deltas (mostly backwards compatible with
3668 Numeric.identity)
3673 Numeric.identity)
3669
3674
3670 2003-06-03 Fernando Perez <fperez@colorado.edu>
3675 2003-06-03 Fernando Perez <fperez@colorado.edu>
3671
3676
3672 * IPython/iplib.py (InteractiveShell.handle_magic): protect
3677 * IPython/iplib.py (InteractiveShell.handle_magic): protect
3673 arguments passed to magics with spaces, to allow trailing '\' to
3678 arguments passed to magics with spaces, to allow trailing '\' to
3674 work normally (mainly for Windows users).
3679 work normally (mainly for Windows users).
3675
3680
3676 2003-05-29 Fernando Perez <fperez@colorado.edu>
3681 2003-05-29 Fernando Perez <fperez@colorado.edu>
3677
3682
3678 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
3683 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
3679 instead of pydoc.help. This fixes a bizarre behavior where
3684 instead of pydoc.help. This fixes a bizarre behavior where
3680 printing '%s' % locals() would trigger the help system. Now
3685 printing '%s' % locals() would trigger the help system. Now
3681 ipython behaves like normal python does.
3686 ipython behaves like normal python does.
3682
3687
3683 Note that if one does 'from pydoc import help', the bizarre
3688 Note that if one does 'from pydoc import help', the bizarre
3684 behavior returns, but this will also happen in normal python, so
3689 behavior returns, but this will also happen in normal python, so
3685 it's not an ipython bug anymore (it has to do with how pydoc.help
3690 it's not an ipython bug anymore (it has to do with how pydoc.help
3686 is implemented).
3691 is implemented).
3687
3692
3688 2003-05-22 Fernando Perez <fperez@colorado.edu>
3693 2003-05-22 Fernando Perez <fperez@colorado.edu>
3689
3694
3690 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
3695 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
3691 return [] instead of None when nothing matches, also match to end
3696 return [] instead of None when nothing matches, also match to end
3692 of line. Patch by Gary Bishop.
3697 of line. Patch by Gary Bishop.
3693
3698
3694 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
3699 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
3695 protection as before, for files passed on the command line. This
3700 protection as before, for files passed on the command line. This
3696 prevents the CrashHandler from kicking in if user files call into
3701 prevents the CrashHandler from kicking in if user files call into
3697 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
3702 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
3698 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
3703 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
3699
3704
3700 2003-05-20 *** Released version 0.4.0
3705 2003-05-20 *** Released version 0.4.0
3701
3706
3702 2003-05-20 Fernando Perez <fperez@colorado.edu>
3707 2003-05-20 Fernando Perez <fperez@colorado.edu>
3703
3708
3704 * setup.py: added support for manpages. It's a bit hackish b/c of
3709 * setup.py: added support for manpages. It's a bit hackish b/c of
3705 a bug in the way the bdist_rpm distutils target handles gzipped
3710 a bug in the way the bdist_rpm distutils target handles gzipped
3706 manpages, but it works. After a patch by Jack.
3711 manpages, but it works. After a patch by Jack.
3707
3712
3708 2003-05-19 Fernando Perez <fperez@colorado.edu>
3713 2003-05-19 Fernando Perez <fperez@colorado.edu>
3709
3714
3710 * IPython/numutils.py: added a mockup of the kinds module, since
3715 * IPython/numutils.py: added a mockup of the kinds module, since
3711 it was recently removed from Numeric. This way, numutils will
3716 it was recently removed from Numeric. This way, numutils will
3712 work for all users even if they are missing kinds.
3717 work for all users even if they are missing kinds.
3713
3718
3714 * IPython/Magic.py (Magic._ofind): Harden against an inspect
3719 * IPython/Magic.py (Magic._ofind): Harden against an inspect
3715 failure, which can occur with SWIG-wrapped extensions. After a
3720 failure, which can occur with SWIG-wrapped extensions. After a
3716 crash report from Prabhu.
3721 crash report from Prabhu.
3717
3722
3718 2003-05-16 Fernando Perez <fperez@colorado.edu>
3723 2003-05-16 Fernando Perez <fperez@colorado.edu>
3719
3724
3720 * IPython/iplib.py (InteractiveShell.excepthook): New method to
3725 * IPython/iplib.py (InteractiveShell.excepthook): New method to
3721 protect ipython from user code which may call directly
3726 protect ipython from user code which may call directly
3722 sys.excepthook (this looks like an ipython crash to the user, even
3727 sys.excepthook (this looks like an ipython crash to the user, even
3723 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
3728 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
3724 This is especially important to help users of WxWindows, but may
3729 This is especially important to help users of WxWindows, but may
3725 also be useful in other cases.
3730 also be useful in other cases.
3726
3731
3727 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
3732 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
3728 an optional tb_offset to be specified, and to preserve exception
3733 an optional tb_offset to be specified, and to preserve exception
3729 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
3734 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
3730
3735
3731 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
3736 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
3732
3737
3733 2003-05-15 Fernando Perez <fperez@colorado.edu>
3738 2003-05-15 Fernando Perez <fperez@colorado.edu>
3734
3739
3735 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
3740 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
3736 installing for a new user under Windows.
3741 installing for a new user under Windows.
3737
3742
3738 2003-05-12 Fernando Perez <fperez@colorado.edu>
3743 2003-05-12 Fernando Perez <fperez@colorado.edu>
3739
3744
3740 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
3745 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
3741 handler for Emacs comint-based lines. Currently it doesn't do
3746 handler for Emacs comint-based lines. Currently it doesn't do
3742 much (but importantly, it doesn't update the history cache). In
3747 much (but importantly, it doesn't update the history cache). In
3743 the future it may be expanded if Alex needs more functionality
3748 the future it may be expanded if Alex needs more functionality
3744 there.
3749 there.
3745
3750
3746 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
3751 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
3747 info to crash reports.
3752 info to crash reports.
3748
3753
3749 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
3754 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
3750 just like Python's -c. Also fixed crash with invalid -color
3755 just like Python's -c. Also fixed crash with invalid -color
3751 option value at startup. Thanks to Will French
3756 option value at startup. Thanks to Will French
3752 <wfrench-AT-bestweb.net> for the bug report.
3757 <wfrench-AT-bestweb.net> for the bug report.
3753
3758
3754 2003-05-09 Fernando Perez <fperez@colorado.edu>
3759 2003-05-09 Fernando Perez <fperez@colorado.edu>
3755
3760
3756 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
3761 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
3757 to EvalDict (it's a mapping, after all) and simplified its code
3762 to EvalDict (it's a mapping, after all) and simplified its code
3758 quite a bit, after a nice discussion on c.l.py where Gustavo
3763 quite a bit, after a nice discussion on c.l.py where Gustavo
3759 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
3764 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
3760
3765
3761 2003-04-30 Fernando Perez <fperez@colorado.edu>
3766 2003-04-30 Fernando Perez <fperez@colorado.edu>
3762
3767
3763 * IPython/genutils.py (timings_out): modified it to reduce its
3768 * IPython/genutils.py (timings_out): modified it to reduce its
3764 overhead in the common reps==1 case.
3769 overhead in the common reps==1 case.
3765
3770
3766 2003-04-29 Fernando Perez <fperez@colorado.edu>
3771 2003-04-29 Fernando Perez <fperez@colorado.edu>
3767
3772
3768 * IPython/genutils.py (timings_out): Modified to use the resource
3773 * IPython/genutils.py (timings_out): Modified to use the resource
3769 module, which avoids the wraparound problems of time.clock().
3774 module, which avoids the wraparound problems of time.clock().
3770
3775
3771 2003-04-17 *** Released version 0.2.15pre4
3776 2003-04-17 *** Released version 0.2.15pre4
3772
3777
3773 2003-04-17 Fernando Perez <fperez@colorado.edu>
3778 2003-04-17 Fernando Perez <fperez@colorado.edu>
3774
3779
3775 * setup.py (scriptfiles): Split windows-specific stuff over to a
3780 * setup.py (scriptfiles): Split windows-specific stuff over to a
3776 separate file, in an attempt to have a Windows GUI installer.
3781 separate file, in an attempt to have a Windows GUI installer.
3777 That didn't work, but part of the groundwork is done.
3782 That didn't work, but part of the groundwork is done.
3778
3783
3779 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
3784 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
3780 indent/unindent with 4 spaces. Particularly useful in combination
3785 indent/unindent with 4 spaces. Particularly useful in combination
3781 with the new auto-indent option.
3786 with the new auto-indent option.
3782
3787
3783 2003-04-16 Fernando Perez <fperez@colorado.edu>
3788 2003-04-16 Fernando Perez <fperez@colorado.edu>
3784
3789
3785 * IPython/Magic.py: various replacements of self.rc for
3790 * IPython/Magic.py: various replacements of self.rc for
3786 self.shell.rc. A lot more remains to be done to fully disentangle
3791 self.shell.rc. A lot more remains to be done to fully disentangle
3787 this class from the main Shell class.
3792 this class from the main Shell class.
3788
3793
3789 * IPython/GnuplotRuntime.py: added checks for mouse support so
3794 * IPython/GnuplotRuntime.py: added checks for mouse support so
3790 that we don't try to enable it if the current gnuplot doesn't
3795 that we don't try to enable it if the current gnuplot doesn't
3791 really support it. Also added checks so that we don't try to
3796 really support it. Also added checks so that we don't try to
3792 enable persist under Windows (where Gnuplot doesn't recognize the
3797 enable persist under Windows (where Gnuplot doesn't recognize the
3793 option).
3798 option).
3794
3799
3795 * IPython/iplib.py (InteractiveShell.interact): Added optional
3800 * IPython/iplib.py (InteractiveShell.interact): Added optional
3796 auto-indenting code, after a patch by King C. Shu
3801 auto-indenting code, after a patch by King C. Shu
3797 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
3802 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
3798 get along well with pasting indented code. If I ever figure out
3803 get along well with pasting indented code. If I ever figure out
3799 how to make that part go well, it will become on by default.
3804 how to make that part go well, it will become on by default.
3800
3805
3801 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
3806 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
3802 crash ipython if there was an unmatched '%' in the user's prompt
3807 crash ipython if there was an unmatched '%' in the user's prompt
3803 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3808 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
3804
3809
3805 * IPython/iplib.py (InteractiveShell.interact): removed the
3810 * IPython/iplib.py (InteractiveShell.interact): removed the
3806 ability to ask the user whether he wants to crash or not at the
3811 ability to ask the user whether he wants to crash or not at the
3807 'last line' exception handler. Calling functions at that point
3812 'last line' exception handler. Calling functions at that point
3808 changes the stack, and the error reports would have incorrect
3813 changes the stack, and the error reports would have incorrect
3809 tracebacks.
3814 tracebacks.
3810
3815
3811 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
3816 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
3812 pass through a peger a pretty-printed form of any object. After a
3817 pass through a peger a pretty-printed form of any object. After a
3813 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
3818 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
3814
3819
3815 2003-04-14 Fernando Perez <fperez@colorado.edu>
3820 2003-04-14 Fernando Perez <fperez@colorado.edu>
3816
3821
3817 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
3822 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
3818 all files in ~ would be modified at first install (instead of
3823 all files in ~ would be modified at first install (instead of
3819 ~/.ipython). This could be potentially disastrous, as the
3824 ~/.ipython). This could be potentially disastrous, as the
3820 modification (make line-endings native) could damage binary files.
3825 modification (make line-endings native) could damage binary files.
3821
3826
3822 2003-04-10 Fernando Perez <fperez@colorado.edu>
3827 2003-04-10 Fernando Perez <fperez@colorado.edu>
3823
3828
3824 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
3829 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
3825 handle only lines which are invalid python. This now means that
3830 handle only lines which are invalid python. This now means that
3826 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
3831 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
3827 for the bug report.
3832 for the bug report.
3828
3833
3829 2003-04-01 Fernando Perez <fperez@colorado.edu>
3834 2003-04-01 Fernando Perez <fperez@colorado.edu>
3830
3835
3831 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
3836 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
3832 where failing to set sys.last_traceback would crash pdb.pm().
3837 where failing to set sys.last_traceback would crash pdb.pm().
3833 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
3838 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
3834 report.
3839 report.
3835
3840
3836 2003-03-25 Fernando Perez <fperez@colorado.edu>
3841 2003-03-25 Fernando Perez <fperez@colorado.edu>
3837
3842
3838 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
3843 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
3839 before printing it (it had a lot of spurious blank lines at the
3844 before printing it (it had a lot of spurious blank lines at the
3840 end).
3845 end).
3841
3846
3842 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
3847 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
3843 output would be sent 21 times! Obviously people don't use this
3848 output would be sent 21 times! Obviously people don't use this
3844 too often, or I would have heard about it.
3849 too often, or I would have heard about it.
3845
3850
3846 2003-03-24 Fernando Perez <fperez@colorado.edu>
3851 2003-03-24 Fernando Perez <fperez@colorado.edu>
3847
3852
3848 * setup.py (scriptfiles): renamed the data_files parameter from
3853 * setup.py (scriptfiles): renamed the data_files parameter from
3849 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
3854 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
3850 for the patch.
3855 for the patch.
3851
3856
3852 2003-03-20 Fernando Perez <fperez@colorado.edu>
3857 2003-03-20 Fernando Perez <fperez@colorado.edu>
3853
3858
3854 * IPython/genutils.py (error): added error() and fatal()
3859 * IPython/genutils.py (error): added error() and fatal()
3855 functions.
3860 functions.
3856
3861
3857 2003-03-18 *** Released version 0.2.15pre3
3862 2003-03-18 *** Released version 0.2.15pre3
3858
3863
3859 2003-03-18 Fernando Perez <fperez@colorado.edu>
3864 2003-03-18 Fernando Perez <fperez@colorado.edu>
3860
3865
3861 * setupext/install_data_ext.py
3866 * setupext/install_data_ext.py
3862 (install_data_ext.initialize_options): Class contributed by Jack
3867 (install_data_ext.initialize_options): Class contributed by Jack
3863 Moffit for fixing the old distutils hack. He is sending this to
3868 Moffit for fixing the old distutils hack. He is sending this to
3864 the distutils folks so in the future we may not need it as a
3869 the distutils folks so in the future we may not need it as a
3865 private fix.
3870 private fix.
3866
3871
3867 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
3872 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
3868 changes for Debian packaging. See his patch for full details.
3873 changes for Debian packaging. See his patch for full details.
3869 The old distutils hack of making the ipythonrc* files carry a
3874 The old distutils hack of making the ipythonrc* files carry a
3870 bogus .py extension is gone, at last. Examples were moved to a
3875 bogus .py extension is gone, at last. Examples were moved to a
3871 separate subdir under doc/, and the separate executable scripts
3876 separate subdir under doc/, and the separate executable scripts
3872 now live in their own directory. Overall a great cleanup. The
3877 now live in their own directory. Overall a great cleanup. The
3873 manual was updated to use the new files, and setup.py has been
3878 manual was updated to use the new files, and setup.py has been
3874 fixed for this setup.
3879 fixed for this setup.
3875
3880
3876 * IPython/PyColorize.py (Parser.usage): made non-executable and
3881 * IPython/PyColorize.py (Parser.usage): made non-executable and
3877 created a pycolor wrapper around it to be included as a script.
3882 created a pycolor wrapper around it to be included as a script.
3878
3883
3879 2003-03-12 *** Released version 0.2.15pre2
3884 2003-03-12 *** Released version 0.2.15pre2
3880
3885
3881 2003-03-12 Fernando Perez <fperez@colorado.edu>
3886 2003-03-12 Fernando Perez <fperez@colorado.edu>
3882
3887
3883 * IPython/ColorANSI.py (make_color_table): Finally fixed the
3888 * IPython/ColorANSI.py (make_color_table): Finally fixed the
3884 long-standing problem with garbage characters in some terminals.
3889 long-standing problem with garbage characters in some terminals.
3885 The issue was really that the \001 and \002 escapes must _only_ be
3890 The issue was really that the \001 and \002 escapes must _only_ be
3886 passed to input prompts (which call readline), but _never_ to
3891 passed to input prompts (which call readline), but _never_ to
3887 normal text to be printed on screen. I changed ColorANSI to have
3892 normal text to be printed on screen. I changed ColorANSI to have
3888 two classes: TermColors and InputTermColors, each with the
3893 two classes: TermColors and InputTermColors, each with the
3889 appropriate escapes for input prompts or normal text. The code in
3894 appropriate escapes for input prompts or normal text. The code in
3890 Prompts.py got slightly more complicated, but this very old and
3895 Prompts.py got slightly more complicated, but this very old and
3891 annoying bug is finally fixed.
3896 annoying bug is finally fixed.
3892
3897
3893 All the credit for nailing down the real origin of this problem
3898 All the credit for nailing down the real origin of this problem
3894 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
3899 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
3895 *Many* thanks to him for spending quite a bit of effort on this.
3900 *Many* thanks to him for spending quite a bit of effort on this.
3896
3901
3897 2003-03-05 *** Released version 0.2.15pre1
3902 2003-03-05 *** Released version 0.2.15pre1
3898
3903
3899 2003-03-03 Fernando Perez <fperez@colorado.edu>
3904 2003-03-03 Fernando Perez <fperez@colorado.edu>
3900
3905
3901 * IPython/FakeModule.py: Moved the former _FakeModule to a
3906 * IPython/FakeModule.py: Moved the former _FakeModule to a
3902 separate file, because it's also needed by Magic (to fix a similar
3907 separate file, because it's also needed by Magic (to fix a similar
3903 pickle-related issue in @run).
3908 pickle-related issue in @run).
3904
3909
3905 2003-03-02 Fernando Perez <fperez@colorado.edu>
3910 2003-03-02 Fernando Perez <fperez@colorado.edu>
3906
3911
3907 * IPython/Magic.py (Magic.magic_autocall): new magic to control
3912 * IPython/Magic.py (Magic.magic_autocall): new magic to control
3908 the autocall option at runtime.
3913 the autocall option at runtime.
3909 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
3914 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
3910 across Magic.py to start separating Magic from InteractiveShell.
3915 across Magic.py to start separating Magic from InteractiveShell.
3911 (Magic._ofind): Fixed to return proper namespace for dotted
3916 (Magic._ofind): Fixed to return proper namespace for dotted
3912 names. Before, a dotted name would always return 'not currently
3917 names. Before, a dotted name would always return 'not currently
3913 defined', because it would find the 'parent'. s.x would be found,
3918 defined', because it would find the 'parent'. s.x would be found,
3914 but since 'x' isn't defined by itself, it would get confused.
3919 but since 'x' isn't defined by itself, it would get confused.
3915 (Magic.magic_run): Fixed pickling problems reported by Ralf
3920 (Magic.magic_run): Fixed pickling problems reported by Ralf
3916 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
3921 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
3917 that I'd used when Mike Heeter reported similar issues at the
3922 that I'd used when Mike Heeter reported similar issues at the
3918 top-level, but now for @run. It boils down to injecting the
3923 top-level, but now for @run. It boils down to injecting the
3919 namespace where code is being executed with something that looks
3924 namespace where code is being executed with something that looks
3920 enough like a module to fool pickle.dump(). Since a pickle stores
3925 enough like a module to fool pickle.dump(). Since a pickle stores
3921 a named reference to the importing module, we need this for
3926 a named reference to the importing module, we need this for
3922 pickles to save something sensible.
3927 pickles to save something sensible.
3923
3928
3924 * IPython/ipmaker.py (make_IPython): added an autocall option.
3929 * IPython/ipmaker.py (make_IPython): added an autocall option.
3925
3930
3926 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
3931 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
3927 the auto-eval code. Now autocalling is an option, and the code is
3932 the auto-eval code. Now autocalling is an option, and the code is
3928 also vastly safer. There is no more eval() involved at all.
3933 also vastly safer. There is no more eval() involved at all.
3929
3934
3930 2003-03-01 Fernando Perez <fperez@colorado.edu>
3935 2003-03-01 Fernando Perez <fperez@colorado.edu>
3931
3936
3932 * IPython/Magic.py (Magic._ofind): Changed interface to return a
3937 * IPython/Magic.py (Magic._ofind): Changed interface to return a
3933 dict with named keys instead of a tuple.
3938 dict with named keys instead of a tuple.
3934
3939
3935 * IPython: Started using CVS for IPython as of 0.2.15pre1.
3940 * IPython: Started using CVS for IPython as of 0.2.15pre1.
3936
3941
3937 * setup.py (make_shortcut): Fixed message about directories
3942 * setup.py (make_shortcut): Fixed message about directories
3938 created during Windows installation (the directories were ok, just
3943 created during Windows installation (the directories were ok, just
3939 the printed message was misleading). Thanks to Chris Liechti
3944 the printed message was misleading). Thanks to Chris Liechti
3940 <cliechti-AT-gmx.net> for the heads up.
3945 <cliechti-AT-gmx.net> for the heads up.
3941
3946
3942 2003-02-21 Fernando Perez <fperez@colorado.edu>
3947 2003-02-21 Fernando Perez <fperez@colorado.edu>
3943
3948
3944 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
3949 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
3945 of ValueError exception when checking for auto-execution. This
3950 of ValueError exception when checking for auto-execution. This
3946 one is raised by things like Numeric arrays arr.flat when the
3951 one is raised by things like Numeric arrays arr.flat when the
3947 array is non-contiguous.
3952 array is non-contiguous.
3948
3953
3949 2003-01-31 Fernando Perez <fperez@colorado.edu>
3954 2003-01-31 Fernando Perez <fperez@colorado.edu>
3950
3955
3951 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
3956 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
3952 not return any value at all (even though the command would get
3957 not return any value at all (even though the command would get
3953 executed).
3958 executed).
3954 (xsys): Flush stdout right after printing the command to ensure
3959 (xsys): Flush stdout right after printing the command to ensure
3955 proper ordering of commands and command output in the total
3960 proper ordering of commands and command output in the total
3956 output.
3961 output.
3957 (SystemExec/xsys/bq): Switched the names of xsys/bq and
3962 (SystemExec/xsys/bq): Switched the names of xsys/bq and
3958 system/getoutput as defaults. The old ones are kept for
3963 system/getoutput as defaults. The old ones are kept for
3959 compatibility reasons, so no code which uses this library needs
3964 compatibility reasons, so no code which uses this library needs
3960 changing.
3965 changing.
3961
3966
3962 2003-01-27 *** Released version 0.2.14
3967 2003-01-27 *** Released version 0.2.14
3963
3968
3964 2003-01-25 Fernando Perez <fperez@colorado.edu>
3969 2003-01-25 Fernando Perez <fperez@colorado.edu>
3965
3970
3966 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
3971 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
3967 functions defined in previous edit sessions could not be re-edited
3972 functions defined in previous edit sessions could not be re-edited
3968 (because the temp files were immediately removed). Now temp files
3973 (because the temp files were immediately removed). Now temp files
3969 are removed only at IPython's exit.
3974 are removed only at IPython's exit.
3970 (Magic.magic_run): Improved @run to perform shell-like expansions
3975 (Magic.magic_run): Improved @run to perform shell-like expansions
3971 on its arguments (~users and $VARS). With this, @run becomes more
3976 on its arguments (~users and $VARS). With this, @run becomes more
3972 like a normal command-line.
3977 like a normal command-line.
3973
3978
3974 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
3979 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
3975 bugs related to embedding and cleaned up that code. A fairly
3980 bugs related to embedding and cleaned up that code. A fairly
3976 important one was the impossibility to access the global namespace
3981 important one was the impossibility to access the global namespace
3977 through the embedded IPython (only local variables were visible).
3982 through the embedded IPython (only local variables were visible).
3978
3983
3979 2003-01-14 Fernando Perez <fperez@colorado.edu>
3984 2003-01-14 Fernando Perez <fperez@colorado.edu>
3980
3985
3981 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
3986 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
3982 auto-calling to be a bit more conservative. Now it doesn't get
3987 auto-calling to be a bit more conservative. Now it doesn't get
3983 triggered if any of '!=()<>' are in the rest of the input line, to
3988 triggered if any of '!=()<>' are in the rest of the input line, to
3984 allow comparing callables. Thanks to Alex for the heads up.
3989 allow comparing callables. Thanks to Alex for the heads up.
3985
3990
3986 2003-01-07 Fernando Perez <fperez@colorado.edu>
3991 2003-01-07 Fernando Perez <fperez@colorado.edu>
3987
3992
3988 * IPython/genutils.py (page): fixed estimation of the number of
3993 * IPython/genutils.py (page): fixed estimation of the number of
3989 lines in a string to be paged to simply count newlines. This
3994 lines in a string to be paged to simply count newlines. This
3990 prevents over-guessing due to embedded escape sequences. A better
3995 prevents over-guessing due to embedded escape sequences. A better
3991 long-term solution would involve stripping out the control chars
3996 long-term solution would involve stripping out the control chars
3992 for the count, but it's potentially so expensive I just don't
3997 for the count, but it's potentially so expensive I just don't
3993 think it's worth doing.
3998 think it's worth doing.
3994
3999
3995 2002-12-19 *** Released version 0.2.14pre50
4000 2002-12-19 *** Released version 0.2.14pre50
3996
4001
3997 2002-12-19 Fernando Perez <fperez@colorado.edu>
4002 2002-12-19 Fernando Perez <fperez@colorado.edu>
3998
4003
3999 * tools/release (version): Changed release scripts to inform
4004 * tools/release (version): Changed release scripts to inform
4000 Andrea and build a NEWS file with a list of recent changes.
4005 Andrea and build a NEWS file with a list of recent changes.
4001
4006
4002 * IPython/ColorANSI.py (__all__): changed terminal detection
4007 * IPython/ColorANSI.py (__all__): changed terminal detection
4003 code. Seems to work better for xterms without breaking
4008 code. Seems to work better for xterms without breaking
4004 konsole. Will need more testing to determine if WinXP and Mac OSX
4009 konsole. Will need more testing to determine if WinXP and Mac OSX
4005 also work ok.
4010 also work ok.
4006
4011
4007 2002-12-18 *** Released version 0.2.14pre49
4012 2002-12-18 *** Released version 0.2.14pre49
4008
4013
4009 2002-12-18 Fernando Perez <fperez@colorado.edu>
4014 2002-12-18 Fernando Perez <fperez@colorado.edu>
4010
4015
4011 * Docs: added new info about Mac OSX, from Andrea.
4016 * Docs: added new info about Mac OSX, from Andrea.
4012
4017
4013 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
4018 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
4014 allow direct plotting of python strings whose format is the same
4019 allow direct plotting of python strings whose format is the same
4015 of gnuplot data files.
4020 of gnuplot data files.
4016
4021
4017 2002-12-16 Fernando Perez <fperez@colorado.edu>
4022 2002-12-16 Fernando Perez <fperez@colorado.edu>
4018
4023
4019 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
4024 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
4020 value of exit question to be acknowledged.
4025 value of exit question to be acknowledged.
4021
4026
4022 2002-12-03 Fernando Perez <fperez@colorado.edu>
4027 2002-12-03 Fernando Perez <fperez@colorado.edu>
4023
4028
4024 * IPython/ipmaker.py: removed generators, which had been added
4029 * IPython/ipmaker.py: removed generators, which had been added
4025 by mistake in an earlier debugging run. This was causing trouble
4030 by mistake in an earlier debugging run. This was causing trouble
4026 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
4031 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
4027 for pointing this out.
4032 for pointing this out.
4028
4033
4029 2002-11-17 Fernando Perez <fperez@colorado.edu>
4034 2002-11-17 Fernando Perez <fperez@colorado.edu>
4030
4035
4031 * Manual: updated the Gnuplot section.
4036 * Manual: updated the Gnuplot section.
4032
4037
4033 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
4038 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
4034 a much better split of what goes in Runtime and what goes in
4039 a much better split of what goes in Runtime and what goes in
4035 Interactive.
4040 Interactive.
4036
4041
4037 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
4042 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
4038 being imported from iplib.
4043 being imported from iplib.
4039
4044
4040 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
4045 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
4041 for command-passing. Now the global Gnuplot instance is called
4046 for command-passing. Now the global Gnuplot instance is called
4042 'gp' instead of 'g', which was really a far too fragile and
4047 'gp' instead of 'g', which was really a far too fragile and
4043 common name.
4048 common name.
4044
4049
4045 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
4050 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
4046 bounding boxes generated by Gnuplot for square plots.
4051 bounding boxes generated by Gnuplot for square plots.
4047
4052
4048 * IPython/genutils.py (popkey): new function added. I should
4053 * IPython/genutils.py (popkey): new function added. I should
4049 suggest this on c.l.py as a dict method, it seems useful.
4054 suggest this on c.l.py as a dict method, it seems useful.
4050
4055
4051 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
4056 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
4052 to transparently handle PostScript generation. MUCH better than
4057 to transparently handle PostScript generation. MUCH better than
4053 the previous plot_eps/replot_eps (which I removed now). The code
4058 the previous plot_eps/replot_eps (which I removed now). The code
4054 is also fairly clean and well documented now (including
4059 is also fairly clean and well documented now (including
4055 docstrings).
4060 docstrings).
4056
4061
4057 2002-11-13 Fernando Perez <fperez@colorado.edu>
4062 2002-11-13 Fernando Perez <fperez@colorado.edu>
4058
4063
4059 * IPython/Magic.py (Magic.magic_edit): fixed docstring
4064 * IPython/Magic.py (Magic.magic_edit): fixed docstring
4060 (inconsistent with options).
4065 (inconsistent with options).
4061
4066
4062 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
4067 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
4063 manually disabled, I don't know why. Fixed it.
4068 manually disabled, I don't know why. Fixed it.
4064 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
4069 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
4065 eps output.
4070 eps output.
4066
4071
4067 2002-11-12 Fernando Perez <fperez@colorado.edu>
4072 2002-11-12 Fernando Perez <fperez@colorado.edu>
4068
4073
4069 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
4074 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
4070 don't propagate up to caller. Fixes crash reported by François
4075 don't propagate up to caller. Fixes crash reported by François
4071 Pinard.
4076 Pinard.
4072
4077
4073 2002-11-09 Fernando Perez <fperez@colorado.edu>
4078 2002-11-09 Fernando Perez <fperez@colorado.edu>
4074
4079
4075 * IPython/ipmaker.py (make_IPython): fixed problem with writing
4080 * IPython/ipmaker.py (make_IPython): fixed problem with writing
4076 history file for new users.
4081 history file for new users.
4077 (make_IPython): fixed bug where initial install would leave the
4082 (make_IPython): fixed bug where initial install would leave the
4078 user running in the .ipython dir.
4083 user running in the .ipython dir.
4079 (make_IPython): fixed bug where config dir .ipython would be
4084 (make_IPython): fixed bug where config dir .ipython would be
4080 created regardless of the given -ipythondir option. Thanks to Cory
4085 created regardless of the given -ipythondir option. Thanks to Cory
4081 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
4086 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
4082
4087
4083 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
4088 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
4084 type confirmations. Will need to use it in all of IPython's code
4089 type confirmations. Will need to use it in all of IPython's code
4085 consistently.
4090 consistently.
4086
4091
4087 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
4092 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
4088 context to print 31 lines instead of the default 5. This will make
4093 context to print 31 lines instead of the default 5. This will make
4089 the crash reports extremely detailed in case the problem is in
4094 the crash reports extremely detailed in case the problem is in
4090 libraries I don't have access to.
4095 libraries I don't have access to.
4091
4096
4092 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
4097 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
4093 line of defense' code to still crash, but giving users fair
4098 line of defense' code to still crash, but giving users fair
4094 warning. I don't want internal errors to go unreported: if there's
4099 warning. I don't want internal errors to go unreported: if there's
4095 an internal problem, IPython should crash and generate a full
4100 an internal problem, IPython should crash and generate a full
4096 report.
4101 report.
4097
4102
4098 2002-11-08 Fernando Perez <fperez@colorado.edu>
4103 2002-11-08 Fernando Perez <fperez@colorado.edu>
4099
4104
4100 * IPython/iplib.py (InteractiveShell.interact): added code to trap
4105 * IPython/iplib.py (InteractiveShell.interact): added code to trap
4101 otherwise uncaught exceptions which can appear if people set
4106 otherwise uncaught exceptions which can appear if people set
4102 sys.stdout to something badly broken. Thanks to a crash report
4107 sys.stdout to something badly broken. Thanks to a crash report
4103 from henni-AT-mail.brainbot.com.
4108 from henni-AT-mail.brainbot.com.
4104
4109
4105 2002-11-04 Fernando Perez <fperez@colorado.edu>
4110 2002-11-04 Fernando Perez <fperez@colorado.edu>
4106
4111
4107 * IPython/iplib.py (InteractiveShell.interact): added
4112 * IPython/iplib.py (InteractiveShell.interact): added
4108 __IPYTHON__active to the builtins. It's a flag which goes on when
4113 __IPYTHON__active to the builtins. It's a flag which goes on when
4109 the interaction starts and goes off again when it stops. This
4114 the interaction starts and goes off again when it stops. This
4110 allows embedding code to detect being inside IPython. Before this
4115 allows embedding code to detect being inside IPython. Before this
4111 was done via __IPYTHON__, but that only shows that an IPython
4116 was done via __IPYTHON__, but that only shows that an IPython
4112 instance has been created.
4117 instance has been created.
4113
4118
4114 * IPython/Magic.py (Magic.magic_env): I realized that in a
4119 * IPython/Magic.py (Magic.magic_env): I realized that in a
4115 UserDict, instance.data holds the data as a normal dict. So I
4120 UserDict, instance.data holds the data as a normal dict. So I
4116 modified @env to return os.environ.data instead of rebuilding a
4121 modified @env to return os.environ.data instead of rebuilding a
4117 dict by hand.
4122 dict by hand.
4118
4123
4119 2002-11-02 Fernando Perez <fperez@colorado.edu>
4124 2002-11-02 Fernando Perez <fperez@colorado.edu>
4120
4125
4121 * IPython/genutils.py (warn): changed so that level 1 prints no
4126 * IPython/genutils.py (warn): changed so that level 1 prints no
4122 header. Level 2 is now the default (with 'WARNING' header, as
4127 header. Level 2 is now the default (with 'WARNING' header, as
4123 before). I think I tracked all places where changes were needed in
4128 before). I think I tracked all places where changes were needed in
4124 IPython, but outside code using the old level numbering may have
4129 IPython, but outside code using the old level numbering may have
4125 broken.
4130 broken.
4126
4131
4127 * IPython/iplib.py (InteractiveShell.runcode): added this to
4132 * IPython/iplib.py (InteractiveShell.runcode): added this to
4128 handle the tracebacks in SystemExit traps correctly. The previous
4133 handle the tracebacks in SystemExit traps correctly. The previous
4129 code (through interact) was printing more of the stack than
4134 code (through interact) was printing more of the stack than
4130 necessary, showing IPython internal code to the user.
4135 necessary, showing IPython internal code to the user.
4131
4136
4132 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
4137 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
4133 default. Now that the default at the confirmation prompt is yes,
4138 default. Now that the default at the confirmation prompt is yes,
4134 it's not so intrusive. François' argument that ipython sessions
4139 it's not so intrusive. François' argument that ipython sessions
4135 tend to be complex enough not to lose them from an accidental C-d,
4140 tend to be complex enough not to lose them from an accidental C-d,
4136 is a valid one.
4141 is a valid one.
4137
4142
4138 * IPython/iplib.py (InteractiveShell.interact): added a
4143 * IPython/iplib.py (InteractiveShell.interact): added a
4139 showtraceback() call to the SystemExit trap, and modified the exit
4144 showtraceback() call to the SystemExit trap, and modified the exit
4140 confirmation to have yes as the default.
4145 confirmation to have yes as the default.
4141
4146
4142 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
4147 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
4143 this file. It's been gone from the code for a long time, this was
4148 this file. It's been gone from the code for a long time, this was
4144 simply leftover junk.
4149 simply leftover junk.
4145
4150
4146 2002-11-01 Fernando Perez <fperez@colorado.edu>
4151 2002-11-01 Fernando Perez <fperez@colorado.edu>
4147
4152
4148 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
4153 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
4149 added. If set, IPython now traps EOF and asks for
4154 added. If set, IPython now traps EOF and asks for
4150 confirmation. After a request by François Pinard.
4155 confirmation. After a request by François Pinard.
4151
4156
4152 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
4157 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
4153 of @abort, and with a new (better) mechanism for handling the
4158 of @abort, and with a new (better) mechanism for handling the
4154 exceptions.
4159 exceptions.
4155
4160
4156 2002-10-27 Fernando Perez <fperez@colorado.edu>
4161 2002-10-27 Fernando Perez <fperez@colorado.edu>
4157
4162
4158 * IPython/usage.py (__doc__): updated the --help information and
4163 * IPython/usage.py (__doc__): updated the --help information and
4159 the ipythonrc file to indicate that -log generates
4164 the ipythonrc file to indicate that -log generates
4160 ./ipython.log. Also fixed the corresponding info in @logstart.
4165 ./ipython.log. Also fixed the corresponding info in @logstart.
4161 This and several other fixes in the manuals thanks to reports by
4166 This and several other fixes in the manuals thanks to reports by
4162 François Pinard <pinard-AT-iro.umontreal.ca>.
4167 François Pinard <pinard-AT-iro.umontreal.ca>.
4163
4168
4164 * IPython/Logger.py (Logger.switch_log): Fixed error message to
4169 * IPython/Logger.py (Logger.switch_log): Fixed error message to
4165 refer to @logstart (instead of @log, which doesn't exist).
4170 refer to @logstart (instead of @log, which doesn't exist).
4166
4171
4167 * IPython/iplib.py (InteractiveShell._prefilter): fixed
4172 * IPython/iplib.py (InteractiveShell._prefilter): fixed
4168 AttributeError crash. Thanks to Christopher Armstrong
4173 AttributeError crash. Thanks to Christopher Armstrong
4169 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
4174 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
4170 introduced recently (in 0.2.14pre37) with the fix to the eval
4175 introduced recently (in 0.2.14pre37) with the fix to the eval
4171 problem mentioned below.
4176 problem mentioned below.
4172
4177
4173 2002-10-17 Fernando Perez <fperez@colorado.edu>
4178 2002-10-17 Fernando Perez <fperez@colorado.edu>
4174
4179
4175 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
4180 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
4176 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
4181 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
4177
4182
4178 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
4183 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
4179 this function to fix a problem reported by Alex Schmolck. He saw
4184 this function to fix a problem reported by Alex Schmolck. He saw
4180 it with list comprehensions and generators, which were getting
4185 it with list comprehensions and generators, which were getting
4181 called twice. The real problem was an 'eval' call in testing for
4186 called twice. The real problem was an 'eval' call in testing for
4182 automagic which was evaluating the input line silently.
4187 automagic which was evaluating the input line silently.
4183
4188
4184 This is a potentially very nasty bug, if the input has side
4189 This is a potentially very nasty bug, if the input has side
4185 effects which must not be repeated. The code is much cleaner now,
4190 effects which must not be repeated. The code is much cleaner now,
4186 without any blanket 'except' left and with a regexp test for
4191 without any blanket 'except' left and with a regexp test for
4187 actual function names.
4192 actual function names.
4188
4193
4189 But an eval remains, which I'm not fully comfortable with. I just
4194 But an eval remains, which I'm not fully comfortable with. I just
4190 don't know how to find out if an expression could be a callable in
4195 don't know how to find out if an expression could be a callable in
4191 the user's namespace without doing an eval on the string. However
4196 the user's namespace without doing an eval on the string. However
4192 that string is now much more strictly checked so that no code
4197 that string is now much more strictly checked so that no code
4193 slips by, so the eval should only happen for things that can
4198 slips by, so the eval should only happen for things that can
4194 really be only function/method names.
4199 really be only function/method names.
4195
4200
4196 2002-10-15 Fernando Perez <fperez@colorado.edu>
4201 2002-10-15 Fernando Perez <fperez@colorado.edu>
4197
4202
4198 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
4203 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
4199 OSX information to main manual, removed README_Mac_OSX file from
4204 OSX information to main manual, removed README_Mac_OSX file from
4200 distribution. Also updated credits for recent additions.
4205 distribution. Also updated credits for recent additions.
4201
4206
4202 2002-10-10 Fernando Perez <fperez@colorado.edu>
4207 2002-10-10 Fernando Perez <fperez@colorado.edu>
4203
4208
4204 * README_Mac_OSX: Added a README for Mac OSX users for fixing
4209 * README_Mac_OSX: Added a README for Mac OSX users for fixing
4205 terminal-related issues. Many thanks to Andrea Riciputi
4210 terminal-related issues. Many thanks to Andrea Riciputi
4206 <andrea.riciputi-AT-libero.it> for writing it.
4211 <andrea.riciputi-AT-libero.it> for writing it.
4207
4212
4208 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
4213 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
4209 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4214 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4210
4215
4211 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
4216 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
4212 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
4217 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
4213 <syver-en-AT-online.no> who both submitted patches for this problem.
4218 <syver-en-AT-online.no> who both submitted patches for this problem.
4214
4219
4215 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
4220 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
4216 global embedding to make sure that things don't overwrite user
4221 global embedding to make sure that things don't overwrite user
4217 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
4222 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
4218
4223
4219 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
4224 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
4220 compatibility. Thanks to Hayden Callow
4225 compatibility. Thanks to Hayden Callow
4221 <h.callow-AT-elec.canterbury.ac.nz>
4226 <h.callow-AT-elec.canterbury.ac.nz>
4222
4227
4223 2002-10-04 Fernando Perez <fperez@colorado.edu>
4228 2002-10-04 Fernando Perez <fperez@colorado.edu>
4224
4229
4225 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
4230 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
4226 Gnuplot.File objects.
4231 Gnuplot.File objects.
4227
4232
4228 2002-07-23 Fernando Perez <fperez@colorado.edu>
4233 2002-07-23 Fernando Perez <fperez@colorado.edu>
4229
4234
4230 * IPython/genutils.py (timing): Added timings() and timing() for
4235 * IPython/genutils.py (timing): Added timings() and timing() for
4231 quick access to the most commonly needed data, the execution
4236 quick access to the most commonly needed data, the execution
4232 times. Old timing() renamed to timings_out().
4237 times. Old timing() renamed to timings_out().
4233
4238
4234 2002-07-18 Fernando Perez <fperez@colorado.edu>
4239 2002-07-18 Fernando Perez <fperez@colorado.edu>
4235
4240
4236 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
4241 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
4237 bug with nested instances disrupting the parent's tab completion.
4242 bug with nested instances disrupting the parent's tab completion.
4238
4243
4239 * IPython/iplib.py (all_completions): Added Alex Schmolck's
4244 * IPython/iplib.py (all_completions): Added Alex Schmolck's
4240 all_completions code to begin the emacs integration.
4245 all_completions code to begin the emacs integration.
4241
4246
4242 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
4247 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
4243 argument to allow titling individual arrays when plotting.
4248 argument to allow titling individual arrays when plotting.
4244
4249
4245 2002-07-15 Fernando Perez <fperez@colorado.edu>
4250 2002-07-15 Fernando Perez <fperez@colorado.edu>
4246
4251
4247 * setup.py (make_shortcut): changed to retrieve the value of
4252 * setup.py (make_shortcut): changed to retrieve the value of
4248 'Program Files' directory from the registry (this value changes in
4253 'Program Files' directory from the registry (this value changes in
4249 non-english versions of Windows). Thanks to Thomas Fanslau
4254 non-english versions of Windows). Thanks to Thomas Fanslau
4250 <tfanslau-AT-gmx.de> for the report.
4255 <tfanslau-AT-gmx.de> for the report.
4251
4256
4252 2002-07-10 Fernando Perez <fperez@colorado.edu>
4257 2002-07-10 Fernando Perez <fperez@colorado.edu>
4253
4258
4254 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
4259 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
4255 a bug in pdb, which crashes if a line with only whitespace is
4260 a bug in pdb, which crashes if a line with only whitespace is
4256 entered. Bug report submitted to sourceforge.
4261 entered. Bug report submitted to sourceforge.
4257
4262
4258 2002-07-09 Fernando Perez <fperez@colorado.edu>
4263 2002-07-09 Fernando Perez <fperez@colorado.edu>
4259
4264
4260 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
4265 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
4261 reporting exceptions (it's a bug in inspect.py, I just set a
4266 reporting exceptions (it's a bug in inspect.py, I just set a
4262 workaround).
4267 workaround).
4263
4268
4264 2002-07-08 Fernando Perez <fperez@colorado.edu>
4269 2002-07-08 Fernando Perez <fperez@colorado.edu>
4265
4270
4266 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
4271 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
4267 __IPYTHON__ in __builtins__ to show up in user_ns.
4272 __IPYTHON__ in __builtins__ to show up in user_ns.
4268
4273
4269 2002-07-03 Fernando Perez <fperez@colorado.edu>
4274 2002-07-03 Fernando Perez <fperez@colorado.edu>
4270
4275
4271 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
4276 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
4272 name from @gp_set_instance to @gp_set_default.
4277 name from @gp_set_instance to @gp_set_default.
4273
4278
4274 * IPython/ipmaker.py (make_IPython): default editor value set to
4279 * IPython/ipmaker.py (make_IPython): default editor value set to
4275 '0' (a string), to match the rc file. Otherwise will crash when
4280 '0' (a string), to match the rc file. Otherwise will crash when
4276 .strip() is called on it.
4281 .strip() is called on it.
4277
4282
4278
4283
4279 2002-06-28 Fernando Perez <fperez@colorado.edu>
4284 2002-06-28 Fernando Perez <fperez@colorado.edu>
4280
4285
4281 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
4286 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
4282 of files in current directory when a file is executed via
4287 of files in current directory when a file is executed via
4283 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
4288 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
4284
4289
4285 * setup.py (manfiles): fix for rpm builds, submitted by RA
4290 * setup.py (manfiles): fix for rpm builds, submitted by RA
4286 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
4291 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
4287
4292
4288 * IPython/ipmaker.py (make_IPython): fixed lookup of default
4293 * IPython/ipmaker.py (make_IPython): fixed lookup of default
4289 editor when set to '0'. Problem was, '0' evaluates to True (it's a
4294 editor when set to '0'. Problem was, '0' evaluates to True (it's a
4290 string!). A. Schmolck caught this one.
4295 string!). A. Schmolck caught this one.
4291
4296
4292 2002-06-27 Fernando Perez <fperez@colorado.edu>
4297 2002-06-27 Fernando Perez <fperez@colorado.edu>
4293
4298
4294 * IPython/ipmaker.py (make_IPython): fixed bug when running user
4299 * IPython/ipmaker.py (make_IPython): fixed bug when running user
4295 defined files at the cmd line. __name__ wasn't being set to
4300 defined files at the cmd line. __name__ wasn't being set to
4296 __main__.
4301 __main__.
4297
4302
4298 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
4303 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
4299 regular lists and tuples besides Numeric arrays.
4304 regular lists and tuples besides Numeric arrays.
4300
4305
4301 * IPython/Prompts.py (CachedOutput.__call__): Added output
4306 * IPython/Prompts.py (CachedOutput.__call__): Added output
4302 supression for input ending with ';'. Similar to Mathematica and
4307 supression for input ending with ';'. Similar to Mathematica and
4303 Matlab. The _* vars and Out[] list are still updated, just like
4308 Matlab. The _* vars and Out[] list are still updated, just like
4304 Mathematica behaves.
4309 Mathematica behaves.
4305
4310
4306 2002-06-25 Fernando Perez <fperez@colorado.edu>
4311 2002-06-25 Fernando Perez <fperez@colorado.edu>
4307
4312
4308 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
4313 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
4309 .ini extensions for profiels under Windows.
4314 .ini extensions for profiels under Windows.
4310
4315
4311 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
4316 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
4312 string form. Fix contributed by Alexander Schmolck
4317 string form. Fix contributed by Alexander Schmolck
4313 <a.schmolck-AT-gmx.net>
4318 <a.schmolck-AT-gmx.net>
4314
4319
4315 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
4320 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
4316 pre-configured Gnuplot instance.
4321 pre-configured Gnuplot instance.
4317
4322
4318 2002-06-21 Fernando Perez <fperez@colorado.edu>
4323 2002-06-21 Fernando Perez <fperez@colorado.edu>
4319
4324
4320 * IPython/numutils.py (exp_safe): new function, works around the
4325 * IPython/numutils.py (exp_safe): new function, works around the
4321 underflow problems in Numeric.
4326 underflow problems in Numeric.
4322 (log2): New fn. Safe log in base 2: returns exact integer answer
4327 (log2): New fn. Safe log in base 2: returns exact integer answer
4323 for exact integer powers of 2.
4328 for exact integer powers of 2.
4324
4329
4325 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
4330 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
4326 properly.
4331 properly.
4327
4332
4328 2002-06-20 Fernando Perez <fperez@colorado.edu>
4333 2002-06-20 Fernando Perez <fperez@colorado.edu>
4329
4334
4330 * IPython/genutils.py (timing): new function like
4335 * IPython/genutils.py (timing): new function like
4331 Mathematica's. Similar to time_test, but returns more info.
4336 Mathematica's. Similar to time_test, but returns more info.
4332
4337
4333 2002-06-18 Fernando Perez <fperez@colorado.edu>
4338 2002-06-18 Fernando Perez <fperez@colorado.edu>
4334
4339
4335 * IPython/Magic.py (Magic.magic_save): modified @save and @r
4340 * IPython/Magic.py (Magic.magic_save): modified @save and @r
4336 according to Mike Heeter's suggestions.
4341 according to Mike Heeter's suggestions.
4337
4342
4338 2002-06-16 Fernando Perez <fperez@colorado.edu>
4343 2002-06-16 Fernando Perez <fperez@colorado.edu>
4339
4344
4340 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
4345 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
4341 system. GnuplotMagic is gone as a user-directory option. New files
4346 system. GnuplotMagic is gone as a user-directory option. New files
4342 make it easier to use all the gnuplot stuff both from external
4347 make it easier to use all the gnuplot stuff both from external
4343 programs as well as from IPython. Had to rewrite part of
4348 programs as well as from IPython. Had to rewrite part of
4344 hardcopy() b/c of a strange bug: often the ps files simply don't
4349 hardcopy() b/c of a strange bug: often the ps files simply don't
4345 get created, and require a repeat of the command (often several
4350 get created, and require a repeat of the command (often several
4346 times).
4351 times).
4347
4352
4348 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
4353 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
4349 resolve output channel at call time, so that if sys.stderr has
4354 resolve output channel at call time, so that if sys.stderr has
4350 been redirected by user this gets honored.
4355 been redirected by user this gets honored.
4351
4356
4352 2002-06-13 Fernando Perez <fperez@colorado.edu>
4357 2002-06-13 Fernando Perez <fperez@colorado.edu>
4353
4358
4354 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
4359 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
4355 IPShell. Kept a copy with the old names to avoid breaking people's
4360 IPShell. Kept a copy with the old names to avoid breaking people's
4356 embedded code.
4361 embedded code.
4357
4362
4358 * IPython/ipython: simplified it to the bare minimum after
4363 * IPython/ipython: simplified it to the bare minimum after
4359 Holger's suggestions. Added info about how to use it in
4364 Holger's suggestions. Added info about how to use it in
4360 PYTHONSTARTUP.
4365 PYTHONSTARTUP.
4361
4366
4362 * IPython/Shell.py (IPythonShell): changed the options passing
4367 * IPython/Shell.py (IPythonShell): changed the options passing
4363 from a string with funky %s replacements to a straight list. Maybe
4368 from a string with funky %s replacements to a straight list. Maybe
4364 a bit more typing, but it follows sys.argv conventions, so there's
4369 a bit more typing, but it follows sys.argv conventions, so there's
4365 less special-casing to remember.
4370 less special-casing to remember.
4366
4371
4367 2002-06-12 Fernando Perez <fperez@colorado.edu>
4372 2002-06-12 Fernando Perez <fperez@colorado.edu>
4368
4373
4369 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
4374 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
4370 command. Thanks to a suggestion by Mike Heeter.
4375 command. Thanks to a suggestion by Mike Heeter.
4371 (Magic.magic_pfile): added behavior to look at filenames if given
4376 (Magic.magic_pfile): added behavior to look at filenames if given
4372 arg is not a defined object.
4377 arg is not a defined object.
4373 (Magic.magic_save): New @save function to save code snippets. Also
4378 (Magic.magic_save): New @save function to save code snippets. Also
4374 a Mike Heeter idea.
4379 a Mike Heeter idea.
4375
4380
4376 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
4381 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
4377 plot() and replot(). Much more convenient now, especially for
4382 plot() and replot(). Much more convenient now, especially for
4378 interactive use.
4383 interactive use.
4379
4384
4380 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
4385 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
4381 filenames.
4386 filenames.
4382
4387
4383 2002-06-02 Fernando Perez <fperez@colorado.edu>
4388 2002-06-02 Fernando Perez <fperez@colorado.edu>
4384
4389
4385 * IPython/Struct.py (Struct.__init__): modified to admit
4390 * IPython/Struct.py (Struct.__init__): modified to admit
4386 initialization via another struct.
4391 initialization via another struct.
4387
4392
4388 * IPython/genutils.py (SystemExec.__init__): New stateful
4393 * IPython/genutils.py (SystemExec.__init__): New stateful
4389 interface to xsys and bq. Useful for writing system scripts.
4394 interface to xsys and bq. Useful for writing system scripts.
4390
4395
4391 2002-05-30 Fernando Perez <fperez@colorado.edu>
4396 2002-05-30 Fernando Perez <fperez@colorado.edu>
4392
4397
4393 * MANIFEST.in: Changed docfile selection to exclude all the lyx
4398 * MANIFEST.in: Changed docfile selection to exclude all the lyx
4394 documents. This will make the user download smaller (it's getting
4399 documents. This will make the user download smaller (it's getting
4395 too big).
4400 too big).
4396
4401
4397 2002-05-29 Fernando Perez <fperez@colorado.edu>
4402 2002-05-29 Fernando Perez <fperez@colorado.edu>
4398
4403
4399 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
4404 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
4400 fix problems with shelve and pickle. Seems to work, but I don't
4405 fix problems with shelve and pickle. Seems to work, but I don't
4401 know if corner cases break it. Thanks to Mike Heeter
4406 know if corner cases break it. Thanks to Mike Heeter
4402 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
4407 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
4403
4408
4404 2002-05-24 Fernando Perez <fperez@colorado.edu>
4409 2002-05-24 Fernando Perez <fperez@colorado.edu>
4405
4410
4406 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
4411 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
4407 macros having broken.
4412 macros having broken.
4408
4413
4409 2002-05-21 Fernando Perez <fperez@colorado.edu>
4414 2002-05-21 Fernando Perez <fperez@colorado.edu>
4410
4415
4411 * IPython/Magic.py (Magic.magic_logstart): fixed recently
4416 * IPython/Magic.py (Magic.magic_logstart): fixed recently
4412 introduced logging bug: all history before logging started was
4417 introduced logging bug: all history before logging started was
4413 being written one character per line! This came from the redesign
4418 being written one character per line! This came from the redesign
4414 of the input history as a special list which slices to strings,
4419 of the input history as a special list which slices to strings,
4415 not to lists.
4420 not to lists.
4416
4421
4417 2002-05-20 Fernando Perez <fperez@colorado.edu>
4422 2002-05-20 Fernando Perez <fperez@colorado.edu>
4418
4423
4419 * IPython/Prompts.py (CachedOutput.__init__): made the color table
4424 * IPython/Prompts.py (CachedOutput.__init__): made the color table
4420 be an attribute of all classes in this module. The design of these
4425 be an attribute of all classes in this module. The design of these
4421 classes needs some serious overhauling.
4426 classes needs some serious overhauling.
4422
4427
4423 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
4428 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
4424 which was ignoring '_' in option names.
4429 which was ignoring '_' in option names.
4425
4430
4426 * IPython/ultraTB.py (FormattedTB.__init__): Changed
4431 * IPython/ultraTB.py (FormattedTB.__init__): Changed
4427 'Verbose_novars' to 'Context' and made it the new default. It's a
4432 'Verbose_novars' to 'Context' and made it the new default. It's a
4428 bit more readable and also safer than verbose.
4433 bit more readable and also safer than verbose.
4429
4434
4430 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
4435 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
4431 triple-quoted strings.
4436 triple-quoted strings.
4432
4437
4433 * IPython/OInspect.py (__all__): new module exposing the object
4438 * IPython/OInspect.py (__all__): new module exposing the object
4434 introspection facilities. Now the corresponding magics are dummy
4439 introspection facilities. Now the corresponding magics are dummy
4435 wrappers around this. Having this module will make it much easier
4440 wrappers around this. Having this module will make it much easier
4436 to put these functions into our modified pdb.
4441 to put these functions into our modified pdb.
4437 This new object inspector system uses the new colorizing module,
4442 This new object inspector system uses the new colorizing module,
4438 so source code and other things are nicely syntax highlighted.
4443 so source code and other things are nicely syntax highlighted.
4439
4444
4440 2002-05-18 Fernando Perez <fperez@colorado.edu>
4445 2002-05-18 Fernando Perez <fperez@colorado.edu>
4441
4446
4442 * IPython/ColorANSI.py: Split the coloring tools into a separate
4447 * IPython/ColorANSI.py: Split the coloring tools into a separate
4443 module so I can use them in other code easier (they were part of
4448 module so I can use them in other code easier (they were part of
4444 ultraTB).
4449 ultraTB).
4445
4450
4446 2002-05-17 Fernando Perez <fperez@colorado.edu>
4451 2002-05-17 Fernando Perez <fperez@colorado.edu>
4447
4452
4448 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4453 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4449 fixed it to set the global 'g' also to the called instance, as
4454 fixed it to set the global 'g' also to the called instance, as
4450 long as 'g' was still a gnuplot instance (so it doesn't overwrite
4455 long as 'g' was still a gnuplot instance (so it doesn't overwrite
4451 user's 'g' variables).
4456 user's 'g' variables).
4452
4457
4453 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
4458 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
4454 global variables (aliases to _ih,_oh) so that users which expect
4459 global variables (aliases to _ih,_oh) so that users which expect
4455 In[5] or Out[7] to work aren't unpleasantly surprised.
4460 In[5] or Out[7] to work aren't unpleasantly surprised.
4456 (InputList.__getslice__): new class to allow executing slices of
4461 (InputList.__getslice__): new class to allow executing slices of
4457 input history directly. Very simple class, complements the use of
4462 input history directly. Very simple class, complements the use of
4458 macros.
4463 macros.
4459
4464
4460 2002-05-16 Fernando Perez <fperez@colorado.edu>
4465 2002-05-16 Fernando Perez <fperez@colorado.edu>
4461
4466
4462 * setup.py (docdirbase): make doc directory be just doc/IPython
4467 * setup.py (docdirbase): make doc directory be just doc/IPython
4463 without version numbers, it will reduce clutter for users.
4468 without version numbers, it will reduce clutter for users.
4464
4469
4465 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
4470 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
4466 execfile call to prevent possible memory leak. See for details:
4471 execfile call to prevent possible memory leak. See for details:
4467 http://mail.python.org/pipermail/python-list/2002-February/088476.html
4472 http://mail.python.org/pipermail/python-list/2002-February/088476.html
4468
4473
4469 2002-05-15 Fernando Perez <fperez@colorado.edu>
4474 2002-05-15 Fernando Perez <fperez@colorado.edu>
4470
4475
4471 * IPython/Magic.py (Magic.magic_psource): made the object
4476 * IPython/Magic.py (Magic.magic_psource): made the object
4472 introspection names be more standard: pdoc, pdef, pfile and
4477 introspection names be more standard: pdoc, pdef, pfile and
4473 psource. They all print/page their output, and it makes
4478 psource. They all print/page their output, and it makes
4474 remembering them easier. Kept old names for compatibility as
4479 remembering them easier. Kept old names for compatibility as
4475 aliases.
4480 aliases.
4476
4481
4477 2002-05-14 Fernando Perez <fperez@colorado.edu>
4482 2002-05-14 Fernando Perez <fperez@colorado.edu>
4478
4483
4479 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
4484 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
4480 what the mouse problem was. The trick is to use gnuplot with temp
4485 what the mouse problem was. The trick is to use gnuplot with temp
4481 files and NOT with pipes (for data communication), because having
4486 files and NOT with pipes (for data communication), because having
4482 both pipes and the mouse on is bad news.
4487 both pipes and the mouse on is bad news.
4483
4488
4484 2002-05-13 Fernando Perez <fperez@colorado.edu>
4489 2002-05-13 Fernando Perez <fperez@colorado.edu>
4485
4490
4486 * IPython/Magic.py (Magic._ofind): fixed namespace order search
4491 * IPython/Magic.py (Magic._ofind): fixed namespace order search
4487 bug. Information would be reported about builtins even when
4492 bug. Information would be reported about builtins even when
4488 user-defined functions overrode them.
4493 user-defined functions overrode them.
4489
4494
4490 2002-05-11 Fernando Perez <fperez@colorado.edu>
4495 2002-05-11 Fernando Perez <fperez@colorado.edu>
4491
4496
4492 * IPython/__init__.py (__all__): removed FlexCompleter from
4497 * IPython/__init__.py (__all__): removed FlexCompleter from
4493 __all__ so that things don't fail in platforms without readline.
4498 __all__ so that things don't fail in platforms without readline.
4494
4499
4495 2002-05-10 Fernando Perez <fperez@colorado.edu>
4500 2002-05-10 Fernando Perez <fperez@colorado.edu>
4496
4501
4497 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
4502 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
4498 it requires Numeric, effectively making Numeric a dependency for
4503 it requires Numeric, effectively making Numeric a dependency for
4499 IPython.
4504 IPython.
4500
4505
4501 * Released 0.2.13
4506 * Released 0.2.13
4502
4507
4503 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
4508 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
4504 profiler interface. Now all the major options from the profiler
4509 profiler interface. Now all the major options from the profiler
4505 module are directly supported in IPython, both for single
4510 module are directly supported in IPython, both for single
4506 expressions (@prun) and for full programs (@run -p).
4511 expressions (@prun) and for full programs (@run -p).
4507
4512
4508 2002-05-09 Fernando Perez <fperez@colorado.edu>
4513 2002-05-09 Fernando Perez <fperez@colorado.edu>
4509
4514
4510 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
4515 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
4511 magic properly formatted for screen.
4516 magic properly formatted for screen.
4512
4517
4513 * setup.py (make_shortcut): Changed things to put pdf version in
4518 * setup.py (make_shortcut): Changed things to put pdf version in
4514 doc/ instead of doc/manual (had to change lyxport a bit).
4519 doc/ instead of doc/manual (had to change lyxport a bit).
4515
4520
4516 * IPython/Magic.py (Profile.string_stats): made profile runs go
4521 * IPython/Magic.py (Profile.string_stats): made profile runs go
4517 through pager (they are long and a pager allows searching, saving,
4522 through pager (they are long and a pager allows searching, saving,
4518 etc.)
4523 etc.)
4519
4524
4520 2002-05-08 Fernando Perez <fperez@colorado.edu>
4525 2002-05-08 Fernando Perez <fperez@colorado.edu>
4521
4526
4522 * Released 0.2.12
4527 * Released 0.2.12
4523
4528
4524 2002-05-06 Fernando Perez <fperez@colorado.edu>
4529 2002-05-06 Fernando Perez <fperez@colorado.edu>
4525
4530
4526 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
4531 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
4527 introduced); 'hist n1 n2' was broken.
4532 introduced); 'hist n1 n2' was broken.
4528 (Magic.magic_pdb): added optional on/off arguments to @pdb
4533 (Magic.magic_pdb): added optional on/off arguments to @pdb
4529 (Magic.magic_run): added option -i to @run, which executes code in
4534 (Magic.magic_run): added option -i to @run, which executes code in
4530 the IPython namespace instead of a clean one. Also added @irun as
4535 the IPython namespace instead of a clean one. Also added @irun as
4531 an alias to @run -i.
4536 an alias to @run -i.
4532
4537
4533 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4538 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4534 fixed (it didn't really do anything, the namespaces were wrong).
4539 fixed (it didn't really do anything, the namespaces were wrong).
4535
4540
4536 * IPython/Debugger.py (__init__): Added workaround for python 2.1
4541 * IPython/Debugger.py (__init__): Added workaround for python 2.1
4537
4542
4538 * IPython/__init__.py (__all__): Fixed package namespace, now
4543 * IPython/__init__.py (__all__): Fixed package namespace, now
4539 'import IPython' does give access to IPython.<all> as
4544 'import IPython' does give access to IPython.<all> as
4540 expected. Also renamed __release__ to Release.
4545 expected. Also renamed __release__ to Release.
4541
4546
4542 * IPython/Debugger.py (__license__): created new Pdb class which
4547 * IPython/Debugger.py (__license__): created new Pdb class which
4543 functions like a drop-in for the normal pdb.Pdb but does NOT
4548 functions like a drop-in for the normal pdb.Pdb but does NOT
4544 import readline by default. This way it doesn't muck up IPython's
4549 import readline by default. This way it doesn't muck up IPython's
4545 readline handling, and now tab-completion finally works in the
4550 readline handling, and now tab-completion finally works in the
4546 debugger -- sort of. It completes things globally visible, but the
4551 debugger -- sort of. It completes things globally visible, but the
4547 completer doesn't track the stack as pdb walks it. That's a bit
4552 completer doesn't track the stack as pdb walks it. That's a bit
4548 tricky, and I'll have to implement it later.
4553 tricky, and I'll have to implement it later.
4549
4554
4550 2002-05-05 Fernando Perez <fperez@colorado.edu>
4555 2002-05-05 Fernando Perez <fperez@colorado.edu>
4551
4556
4552 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
4557 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
4553 magic docstrings when printed via ? (explicit \'s were being
4558 magic docstrings when printed via ? (explicit \'s were being
4554 printed).
4559 printed).
4555
4560
4556 * IPython/ipmaker.py (make_IPython): fixed namespace
4561 * IPython/ipmaker.py (make_IPython): fixed namespace
4557 identification bug. Now variables loaded via logs or command-line
4562 identification bug. Now variables loaded via logs or command-line
4558 files are recognized in the interactive namespace by @who.
4563 files are recognized in the interactive namespace by @who.
4559
4564
4560 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
4565 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
4561 log replay system stemming from the string form of Structs.
4566 log replay system stemming from the string form of Structs.
4562
4567
4563 * IPython/Magic.py (Macro.__init__): improved macros to properly
4568 * IPython/Magic.py (Macro.__init__): improved macros to properly
4564 handle magic commands in them.
4569 handle magic commands in them.
4565 (Magic.magic_logstart): usernames are now expanded so 'logstart
4570 (Magic.magic_logstart): usernames are now expanded so 'logstart
4566 ~/mylog' now works.
4571 ~/mylog' now works.
4567
4572
4568 * IPython/iplib.py (complete): fixed bug where paths starting with
4573 * IPython/iplib.py (complete): fixed bug where paths starting with
4569 '/' would be completed as magic names.
4574 '/' would be completed as magic names.
4570
4575
4571 2002-05-04 Fernando Perez <fperez@colorado.edu>
4576 2002-05-04 Fernando Perez <fperez@colorado.edu>
4572
4577
4573 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
4578 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
4574 allow running full programs under the profiler's control.
4579 allow running full programs under the profiler's control.
4575
4580
4576 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
4581 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
4577 mode to report exceptions verbosely but without formatting
4582 mode to report exceptions verbosely but without formatting
4578 variables. This addresses the issue of ipython 'freezing' (it's
4583 variables. This addresses the issue of ipython 'freezing' (it's
4579 not frozen, but caught in an expensive formatting loop) when huge
4584 not frozen, but caught in an expensive formatting loop) when huge
4580 variables are in the context of an exception.
4585 variables are in the context of an exception.
4581 (VerboseTB.text): Added '--->' markers at line where exception was
4586 (VerboseTB.text): Added '--->' markers at line where exception was
4582 triggered. Much clearer to read, especially in NoColor modes.
4587 triggered. Much clearer to read, especially in NoColor modes.
4583
4588
4584 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
4589 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
4585 implemented in reverse when changing to the new parse_options().
4590 implemented in reverse when changing to the new parse_options().
4586
4591
4587 2002-05-03 Fernando Perez <fperez@colorado.edu>
4592 2002-05-03 Fernando Perez <fperez@colorado.edu>
4588
4593
4589 * IPython/Magic.py (Magic.parse_options): new function so that
4594 * IPython/Magic.py (Magic.parse_options): new function so that
4590 magics can parse options easier.
4595 magics can parse options easier.
4591 (Magic.magic_prun): new function similar to profile.run(),
4596 (Magic.magic_prun): new function similar to profile.run(),
4592 suggested by Chris Hart.
4597 suggested by Chris Hart.
4593 (Magic.magic_cd): fixed behavior so that it only changes if
4598 (Magic.magic_cd): fixed behavior so that it only changes if
4594 directory actually is in history.
4599 directory actually is in history.
4595
4600
4596 * IPython/usage.py (__doc__): added information about potential
4601 * IPython/usage.py (__doc__): added information about potential
4597 slowness of Verbose exception mode when there are huge data
4602 slowness of Verbose exception mode when there are huge data
4598 structures to be formatted (thanks to Archie Paulson).
4603 structures to be formatted (thanks to Archie Paulson).
4599
4604
4600 * IPython/ipmaker.py (make_IPython): Changed default logging
4605 * IPython/ipmaker.py (make_IPython): Changed default logging
4601 (when simply called with -log) to use curr_dir/ipython.log in
4606 (when simply called with -log) to use curr_dir/ipython.log in
4602 rotate mode. Fixed crash which was occuring with -log before
4607 rotate mode. Fixed crash which was occuring with -log before
4603 (thanks to Jim Boyle).
4608 (thanks to Jim Boyle).
4604
4609
4605 2002-05-01 Fernando Perez <fperez@colorado.edu>
4610 2002-05-01 Fernando Perez <fperez@colorado.edu>
4606
4611
4607 * Released 0.2.11 for these fixes (mainly the ultraTB one which
4612 * Released 0.2.11 for these fixes (mainly the ultraTB one which
4608 was nasty -- though somewhat of a corner case).
4613 was nasty -- though somewhat of a corner case).
4609
4614
4610 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
4615 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
4611 text (was a bug).
4616 text (was a bug).
4612
4617
4613 2002-04-30 Fernando Perez <fperez@colorado.edu>
4618 2002-04-30 Fernando Perez <fperez@colorado.edu>
4614
4619
4615 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
4620 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
4616 a print after ^D or ^C from the user so that the In[] prompt
4621 a print after ^D or ^C from the user so that the In[] prompt
4617 doesn't over-run the gnuplot one.
4622 doesn't over-run the gnuplot one.
4618
4623
4619 2002-04-29 Fernando Perez <fperez@colorado.edu>
4624 2002-04-29 Fernando Perez <fperez@colorado.edu>
4620
4625
4621 * Released 0.2.10
4626 * Released 0.2.10
4622
4627
4623 * IPython/__release__.py (version): get date dynamically.
4628 * IPython/__release__.py (version): get date dynamically.
4624
4629
4625 * Misc. documentation updates thanks to Arnd's comments. Also ran
4630 * Misc. documentation updates thanks to Arnd's comments. Also ran
4626 a full spellcheck on the manual (hadn't been done in a while).
4631 a full spellcheck on the manual (hadn't been done in a while).
4627
4632
4628 2002-04-27 Fernando Perez <fperez@colorado.edu>
4633 2002-04-27 Fernando Perez <fperez@colorado.edu>
4629
4634
4630 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
4635 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
4631 starting a log in mid-session would reset the input history list.
4636 starting a log in mid-session would reset the input history list.
4632
4637
4633 2002-04-26 Fernando Perez <fperez@colorado.edu>
4638 2002-04-26 Fernando Perez <fperez@colorado.edu>
4634
4639
4635 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
4640 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
4636 all files were being included in an update. Now anything in
4641 all files were being included in an update. Now anything in
4637 UserConfig that matches [A-Za-z]*.py will go (this excludes
4642 UserConfig that matches [A-Za-z]*.py will go (this excludes
4638 __init__.py)
4643 __init__.py)
4639
4644
4640 2002-04-25 Fernando Perez <fperez@colorado.edu>
4645 2002-04-25 Fernando Perez <fperez@colorado.edu>
4641
4646
4642 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
4647 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
4643 to __builtins__ so that any form of embedded or imported code can
4648 to __builtins__ so that any form of embedded or imported code can
4644 test for being inside IPython.
4649 test for being inside IPython.
4645
4650
4646 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
4651 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
4647 changed to GnuplotMagic because it's now an importable module,
4652 changed to GnuplotMagic because it's now an importable module,
4648 this makes the name follow that of the standard Gnuplot module.
4653 this makes the name follow that of the standard Gnuplot module.
4649 GnuplotMagic can now be loaded at any time in mid-session.
4654 GnuplotMagic can now be loaded at any time in mid-session.
4650
4655
4651 2002-04-24 Fernando Perez <fperez@colorado.edu>
4656 2002-04-24 Fernando Perez <fperez@colorado.edu>
4652
4657
4653 * IPython/numutils.py: removed SIUnits. It doesn't properly set
4658 * IPython/numutils.py: removed SIUnits. It doesn't properly set
4654 the globals (IPython has its own namespace) and the
4659 the globals (IPython has its own namespace) and the
4655 PhysicalQuantity stuff is much better anyway.
4660 PhysicalQuantity stuff is much better anyway.
4656
4661
4657 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
4662 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
4658 embedding example to standard user directory for
4663 embedding example to standard user directory for
4659 distribution. Also put it in the manual.
4664 distribution. Also put it in the manual.
4660
4665
4661 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
4666 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
4662 instance as first argument (so it doesn't rely on some obscure
4667 instance as first argument (so it doesn't rely on some obscure
4663 hidden global).
4668 hidden global).
4664
4669
4665 * IPython/UserConfig/ipythonrc.py: put () back in accepted
4670 * IPython/UserConfig/ipythonrc.py: put () back in accepted
4666 delimiters. While it prevents ().TAB from working, it allows
4671 delimiters. While it prevents ().TAB from working, it allows
4667 completions in open (... expressions. This is by far a more common
4672 completions in open (... expressions. This is by far a more common
4668 case.
4673 case.
4669
4674
4670 2002-04-23 Fernando Perez <fperez@colorado.edu>
4675 2002-04-23 Fernando Perez <fperez@colorado.edu>
4671
4676
4672 * IPython/Extensions/InterpreterPasteInput.py: new
4677 * IPython/Extensions/InterpreterPasteInput.py: new
4673 syntax-processing module for pasting lines with >>> or ... at the
4678 syntax-processing module for pasting lines with >>> or ... at the
4674 start.
4679 start.
4675
4680
4676 * IPython/Extensions/PhysicalQ_Interactive.py
4681 * IPython/Extensions/PhysicalQ_Interactive.py
4677 (PhysicalQuantityInteractive.__int__): fixed to work with either
4682 (PhysicalQuantityInteractive.__int__): fixed to work with either
4678 Numeric or math.
4683 Numeric or math.
4679
4684
4680 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
4685 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
4681 provided profiles. Now we have:
4686 provided profiles. Now we have:
4682 -math -> math module as * and cmath with its own namespace.
4687 -math -> math module as * and cmath with its own namespace.
4683 -numeric -> Numeric as *, plus gnuplot & grace
4688 -numeric -> Numeric as *, plus gnuplot & grace
4684 -physics -> same as before
4689 -physics -> same as before
4685
4690
4686 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
4691 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
4687 user-defined magics wouldn't be found by @magic if they were
4692 user-defined magics wouldn't be found by @magic if they were
4688 defined as class methods. Also cleaned up the namespace search
4693 defined as class methods. Also cleaned up the namespace search
4689 logic and the string building (to use %s instead of many repeated
4694 logic and the string building (to use %s instead of many repeated
4690 string adds).
4695 string adds).
4691
4696
4692 * IPython/UserConfig/example-magic.py (magic_foo): updated example
4697 * IPython/UserConfig/example-magic.py (magic_foo): updated example
4693 of user-defined magics to operate with class methods (cleaner, in
4698 of user-defined magics to operate with class methods (cleaner, in
4694 line with the gnuplot code).
4699 line with the gnuplot code).
4695
4700
4696 2002-04-22 Fernando Perez <fperez@colorado.edu>
4701 2002-04-22 Fernando Perez <fperez@colorado.edu>
4697
4702
4698 * setup.py: updated dependency list so that manual is updated when
4703 * setup.py: updated dependency list so that manual is updated when
4699 all included files change.
4704 all included files change.
4700
4705
4701 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
4706 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
4702 the delimiter removal option (the fix is ugly right now).
4707 the delimiter removal option (the fix is ugly right now).
4703
4708
4704 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
4709 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
4705 all of the math profile (quicker loading, no conflict between
4710 all of the math profile (quicker loading, no conflict between
4706 g-9.8 and g-gnuplot).
4711 g-9.8 and g-gnuplot).
4707
4712
4708 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
4713 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
4709 name of post-mortem files to IPython_crash_report.txt.
4714 name of post-mortem files to IPython_crash_report.txt.
4710
4715
4711 * Cleanup/update of the docs. Added all the new readline info and
4716 * Cleanup/update of the docs. Added all the new readline info and
4712 formatted all lists as 'real lists'.
4717 formatted all lists as 'real lists'.
4713
4718
4714 * IPython/ipmaker.py (make_IPython): removed now-obsolete
4719 * IPython/ipmaker.py (make_IPython): removed now-obsolete
4715 tab-completion options, since the full readline parse_and_bind is
4720 tab-completion options, since the full readline parse_and_bind is
4716 now accessible.
4721 now accessible.
4717
4722
4718 * IPython/iplib.py (InteractiveShell.init_readline): Changed
4723 * IPython/iplib.py (InteractiveShell.init_readline): Changed
4719 handling of readline options. Now users can specify any string to
4724 handling of readline options. Now users can specify any string to
4720 be passed to parse_and_bind(), as well as the delimiters to be
4725 be passed to parse_and_bind(), as well as the delimiters to be
4721 removed.
4726 removed.
4722 (InteractiveShell.__init__): Added __name__ to the global
4727 (InteractiveShell.__init__): Added __name__ to the global
4723 namespace so that things like Itpl which rely on its existence
4728 namespace so that things like Itpl which rely on its existence
4724 don't crash.
4729 don't crash.
4725 (InteractiveShell._prefilter): Defined the default with a _ so
4730 (InteractiveShell._prefilter): Defined the default with a _ so
4726 that prefilter() is easier to override, while the default one
4731 that prefilter() is easier to override, while the default one
4727 remains available.
4732 remains available.
4728
4733
4729 2002-04-18 Fernando Perez <fperez@colorado.edu>
4734 2002-04-18 Fernando Perez <fperez@colorado.edu>
4730
4735
4731 * Added information about pdb in the docs.
4736 * Added information about pdb in the docs.
4732
4737
4733 2002-04-17 Fernando Perez <fperez@colorado.edu>
4738 2002-04-17 Fernando Perez <fperez@colorado.edu>
4734
4739
4735 * IPython/ipmaker.py (make_IPython): added rc_override option to
4740 * IPython/ipmaker.py (make_IPython): added rc_override option to
4736 allow passing config options at creation time which may override
4741 allow passing config options at creation time which may override
4737 anything set in the config files or command line. This is
4742 anything set in the config files or command line. This is
4738 particularly useful for configuring embedded instances.
4743 particularly useful for configuring embedded instances.
4739
4744
4740 2002-04-15 Fernando Perez <fperez@colorado.edu>
4745 2002-04-15 Fernando Perez <fperez@colorado.edu>
4741
4746
4742 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
4747 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
4743 crash embedded instances because of the input cache falling out of
4748 crash embedded instances because of the input cache falling out of
4744 sync with the output counter.
4749 sync with the output counter.
4745
4750
4746 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
4751 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
4747 mode which calls pdb after an uncaught exception in IPython itself.
4752 mode which calls pdb after an uncaught exception in IPython itself.
4748
4753
4749 2002-04-14 Fernando Perez <fperez@colorado.edu>
4754 2002-04-14 Fernando Perez <fperez@colorado.edu>
4750
4755
4751 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
4756 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
4752 readline, fix it back after each call.
4757 readline, fix it back after each call.
4753
4758
4754 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
4759 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
4755 method to force all access via __call__(), which guarantees that
4760 method to force all access via __call__(), which guarantees that
4756 traceback references are properly deleted.
4761 traceback references are properly deleted.
4757
4762
4758 * IPython/Prompts.py (CachedOutput._display): minor fixes to
4763 * IPython/Prompts.py (CachedOutput._display): minor fixes to
4759 improve printing when pprint is in use.
4764 improve printing when pprint is in use.
4760
4765
4761 2002-04-13 Fernando Perez <fperez@colorado.edu>
4766 2002-04-13 Fernando Perez <fperez@colorado.edu>
4762
4767
4763 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
4768 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
4764 exceptions aren't caught anymore. If the user triggers one, he
4769 exceptions aren't caught anymore. If the user triggers one, he
4765 should know why he's doing it and it should go all the way up,
4770 should know why he's doing it and it should go all the way up,
4766 just like any other exception. So now @abort will fully kill the
4771 just like any other exception. So now @abort will fully kill the
4767 embedded interpreter and the embedding code (unless that happens
4772 embedded interpreter and the embedding code (unless that happens
4768 to catch SystemExit).
4773 to catch SystemExit).
4769
4774
4770 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
4775 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
4771 and a debugger() method to invoke the interactive pdb debugger
4776 and a debugger() method to invoke the interactive pdb debugger
4772 after printing exception information. Also added the corresponding
4777 after printing exception information. Also added the corresponding
4773 -pdb option and @pdb magic to control this feature, and updated
4778 -pdb option and @pdb magic to control this feature, and updated
4774 the docs. After a suggestion from Christopher Hart
4779 the docs. After a suggestion from Christopher Hart
4775 (hart-AT-caltech.edu).
4780 (hart-AT-caltech.edu).
4776
4781
4777 2002-04-12 Fernando Perez <fperez@colorado.edu>
4782 2002-04-12 Fernando Perez <fperez@colorado.edu>
4778
4783
4779 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
4784 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
4780 the exception handlers defined by the user (not the CrashHandler)
4785 the exception handlers defined by the user (not the CrashHandler)
4781 so that user exceptions don't trigger an ipython bug report.
4786 so that user exceptions don't trigger an ipython bug report.
4782
4787
4783 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
4788 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
4784 configurable (it should have always been so).
4789 configurable (it should have always been so).
4785
4790
4786 2002-03-26 Fernando Perez <fperez@colorado.edu>
4791 2002-03-26 Fernando Perez <fperez@colorado.edu>
4787
4792
4788 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
4793 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
4789 and there to fix embedding namespace issues. This should all be
4794 and there to fix embedding namespace issues. This should all be
4790 done in a more elegant way.
4795 done in a more elegant way.
4791
4796
4792 2002-03-25 Fernando Perez <fperez@colorado.edu>
4797 2002-03-25 Fernando Perez <fperez@colorado.edu>
4793
4798
4794 * IPython/genutils.py (get_home_dir): Try to make it work under
4799 * IPython/genutils.py (get_home_dir): Try to make it work under
4795 win9x also.
4800 win9x also.
4796
4801
4797 2002-03-20 Fernando Perez <fperez@colorado.edu>
4802 2002-03-20 Fernando Perez <fperez@colorado.edu>
4798
4803
4799 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
4804 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
4800 sys.displayhook untouched upon __init__.
4805 sys.displayhook untouched upon __init__.
4801
4806
4802 2002-03-19 Fernando Perez <fperez@colorado.edu>
4807 2002-03-19 Fernando Perez <fperez@colorado.edu>
4803
4808
4804 * Released 0.2.9 (for embedding bug, basically).
4809 * Released 0.2.9 (for embedding bug, basically).
4805
4810
4806 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
4811 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
4807 exceptions so that enclosing shell's state can be restored.
4812 exceptions so that enclosing shell's state can be restored.
4808
4813
4809 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
4814 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
4810 naming conventions in the .ipython/ dir.
4815 naming conventions in the .ipython/ dir.
4811
4816
4812 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
4817 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
4813 from delimiters list so filenames with - in them get expanded.
4818 from delimiters list so filenames with - in them get expanded.
4814
4819
4815 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
4820 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
4816 sys.displayhook not being properly restored after an embedded call.
4821 sys.displayhook not being properly restored after an embedded call.
4817
4822
4818 2002-03-18 Fernando Perez <fperez@colorado.edu>
4823 2002-03-18 Fernando Perez <fperez@colorado.edu>
4819
4824
4820 * Released 0.2.8
4825 * Released 0.2.8
4821
4826
4822 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
4827 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
4823 some files weren't being included in a -upgrade.
4828 some files weren't being included in a -upgrade.
4824 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
4829 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
4825 on' so that the first tab completes.
4830 on' so that the first tab completes.
4826 (InteractiveShell.handle_magic): fixed bug with spaces around
4831 (InteractiveShell.handle_magic): fixed bug with spaces around
4827 quotes breaking many magic commands.
4832 quotes breaking many magic commands.
4828
4833
4829 * setup.py: added note about ignoring the syntax error messages at
4834 * setup.py: added note about ignoring the syntax error messages at
4830 installation.
4835 installation.
4831
4836
4832 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
4837 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
4833 streamlining the gnuplot interface, now there's only one magic @gp.
4838 streamlining the gnuplot interface, now there's only one magic @gp.
4834
4839
4835 2002-03-17 Fernando Perez <fperez@colorado.edu>
4840 2002-03-17 Fernando Perez <fperez@colorado.edu>
4836
4841
4837 * IPython/UserConfig/magic_gnuplot.py: new name for the
4842 * IPython/UserConfig/magic_gnuplot.py: new name for the
4838 example-magic_pm.py file. Much enhanced system, now with a shell
4843 example-magic_pm.py file. Much enhanced system, now with a shell
4839 for communicating directly with gnuplot, one command at a time.
4844 for communicating directly with gnuplot, one command at a time.
4840
4845
4841 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
4846 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
4842 setting __name__=='__main__'.
4847 setting __name__=='__main__'.
4843
4848
4844 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
4849 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
4845 mini-shell for accessing gnuplot from inside ipython. Should
4850 mini-shell for accessing gnuplot from inside ipython. Should
4846 extend it later for grace access too. Inspired by Arnd's
4851 extend it later for grace access too. Inspired by Arnd's
4847 suggestion.
4852 suggestion.
4848
4853
4849 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
4854 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
4850 calling magic functions with () in their arguments. Thanks to Arnd
4855 calling magic functions with () in their arguments. Thanks to Arnd
4851 Baecker for pointing this to me.
4856 Baecker for pointing this to me.
4852
4857
4853 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
4858 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
4854 infinitely for integer or complex arrays (only worked with floats).
4859 infinitely for integer or complex arrays (only worked with floats).
4855
4860
4856 2002-03-16 Fernando Perez <fperez@colorado.edu>
4861 2002-03-16 Fernando Perez <fperez@colorado.edu>
4857
4862
4858 * setup.py: Merged setup and setup_windows into a single script
4863 * setup.py: Merged setup and setup_windows into a single script
4859 which properly handles things for windows users.
4864 which properly handles things for windows users.
4860
4865
4861 2002-03-15 Fernando Perez <fperez@colorado.edu>
4866 2002-03-15 Fernando Perez <fperez@colorado.edu>
4862
4867
4863 * Big change to the manual: now the magics are all automatically
4868 * Big change to the manual: now the magics are all automatically
4864 documented. This information is generated from their docstrings
4869 documented. This information is generated from their docstrings
4865 and put in a latex file included by the manual lyx file. This way
4870 and put in a latex file included by the manual lyx file. This way
4866 we get always up to date information for the magics. The manual
4871 we get always up to date information for the magics. The manual
4867 now also has proper version information, also auto-synced.
4872 now also has proper version information, also auto-synced.
4868
4873
4869 For this to work, an undocumented --magic_docstrings option was added.
4874 For this to work, an undocumented --magic_docstrings option was added.
4870
4875
4871 2002-03-13 Fernando Perez <fperez@colorado.edu>
4876 2002-03-13 Fernando Perez <fperez@colorado.edu>
4872
4877
4873 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
4878 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
4874 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
4879 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
4875
4880
4876 2002-03-12 Fernando Perez <fperez@colorado.edu>
4881 2002-03-12 Fernando Perez <fperez@colorado.edu>
4877
4882
4878 * IPython/ultraTB.py (TermColors): changed color escapes again to
4883 * IPython/ultraTB.py (TermColors): changed color escapes again to
4879 fix the (old, reintroduced) line-wrapping bug. Basically, if
4884 fix the (old, reintroduced) line-wrapping bug. Basically, if
4880 \001..\002 aren't given in the color escapes, lines get wrapped
4885 \001..\002 aren't given in the color escapes, lines get wrapped
4881 weirdly. But giving those screws up old xterms and emacs terms. So
4886 weirdly. But giving those screws up old xterms and emacs terms. So
4882 I added some logic for emacs terms to be ok, but I can't identify old
4887 I added some logic for emacs terms to be ok, but I can't identify old
4883 xterms separately ($TERM=='xterm' for many terminals, like konsole).
4888 xterms separately ($TERM=='xterm' for many terminals, like konsole).
4884
4889
4885 2002-03-10 Fernando Perez <fperez@colorado.edu>
4890 2002-03-10 Fernando Perez <fperez@colorado.edu>
4886
4891
4887 * IPython/usage.py (__doc__): Various documentation cleanups and
4892 * IPython/usage.py (__doc__): Various documentation cleanups and
4888 updates, both in usage docstrings and in the manual.
4893 updates, both in usage docstrings and in the manual.
4889
4894
4890 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
4895 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
4891 handling of caching. Set minimum acceptabe value for having a
4896 handling of caching. Set minimum acceptabe value for having a
4892 cache at 20 values.
4897 cache at 20 values.
4893
4898
4894 * IPython/iplib.py (InteractiveShell.user_setup): moved the
4899 * IPython/iplib.py (InteractiveShell.user_setup): moved the
4895 install_first_time function to a method, renamed it and added an
4900 install_first_time function to a method, renamed it and added an
4896 'upgrade' mode. Now people can update their config directory with
4901 'upgrade' mode. Now people can update their config directory with
4897 a simple command line switch (-upgrade, also new).
4902 a simple command line switch (-upgrade, also new).
4898
4903
4899 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
4904 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
4900 @file (convenient for automagic users under Python >= 2.2).
4905 @file (convenient for automagic users under Python >= 2.2).
4901 Removed @files (it seemed more like a plural than an abbrev. of
4906 Removed @files (it seemed more like a plural than an abbrev. of
4902 'file show').
4907 'file show').
4903
4908
4904 * IPython/iplib.py (install_first_time): Fixed crash if there were
4909 * IPython/iplib.py (install_first_time): Fixed crash if there were
4905 backup files ('~') in .ipython/ install directory.
4910 backup files ('~') in .ipython/ install directory.
4906
4911
4907 * IPython/ipmaker.py (make_IPython): fixes for new prompt
4912 * IPython/ipmaker.py (make_IPython): fixes for new prompt
4908 system. Things look fine, but these changes are fairly
4913 system. Things look fine, but these changes are fairly
4909 intrusive. Test them for a few days.
4914 intrusive. Test them for a few days.
4910
4915
4911 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
4916 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
4912 the prompts system. Now all in/out prompt strings are user
4917 the prompts system. Now all in/out prompt strings are user
4913 controllable. This is particularly useful for embedding, as one
4918 controllable. This is particularly useful for embedding, as one
4914 can tag embedded instances with particular prompts.
4919 can tag embedded instances with particular prompts.
4915
4920
4916 Also removed global use of sys.ps1/2, which now allows nested
4921 Also removed global use of sys.ps1/2, which now allows nested
4917 embeddings without any problems. Added command-line options for
4922 embeddings without any problems. Added command-line options for
4918 the prompt strings.
4923 the prompt strings.
4919
4924
4920 2002-03-08 Fernando Perez <fperez@colorado.edu>
4925 2002-03-08 Fernando Perez <fperez@colorado.edu>
4921
4926
4922 * IPython/UserConfig/example-embed-short.py (ipshell): added
4927 * IPython/UserConfig/example-embed-short.py (ipshell): added
4923 example file with the bare minimum code for embedding.
4928 example file with the bare minimum code for embedding.
4924
4929
4925 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
4930 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
4926 functionality for the embeddable shell to be activated/deactivated
4931 functionality for the embeddable shell to be activated/deactivated
4927 either globally or at each call.
4932 either globally or at each call.
4928
4933
4929 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
4934 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
4930 rewriting the prompt with '--->' for auto-inputs with proper
4935 rewriting the prompt with '--->' for auto-inputs with proper
4931 coloring. Now the previous UGLY hack in handle_auto() is gone, and
4936 coloring. Now the previous UGLY hack in handle_auto() is gone, and
4932 this is handled by the prompts class itself, as it should.
4937 this is handled by the prompts class itself, as it should.
4933
4938
4934 2002-03-05 Fernando Perez <fperez@colorado.edu>
4939 2002-03-05 Fernando Perez <fperez@colorado.edu>
4935
4940
4936 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
4941 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
4937 @logstart to avoid name clashes with the math log function.
4942 @logstart to avoid name clashes with the math log function.
4938
4943
4939 * Big updates to X/Emacs section of the manual.
4944 * Big updates to X/Emacs section of the manual.
4940
4945
4941 * Removed ipython_emacs. Milan explained to me how to pass
4946 * Removed ipython_emacs. Milan explained to me how to pass
4942 arguments to ipython through Emacs. Some day I'm going to end up
4947 arguments to ipython through Emacs. Some day I'm going to end up
4943 learning some lisp...
4948 learning some lisp...
4944
4949
4945 2002-03-04 Fernando Perez <fperez@colorado.edu>
4950 2002-03-04 Fernando Perez <fperez@colorado.edu>
4946
4951
4947 * IPython/ipython_emacs: Created script to be used as the
4952 * IPython/ipython_emacs: Created script to be used as the
4948 py-python-command Emacs variable so we can pass IPython
4953 py-python-command Emacs variable so we can pass IPython
4949 parameters. I can't figure out how to tell Emacs directly to pass
4954 parameters. I can't figure out how to tell Emacs directly to pass
4950 parameters to IPython, so a dummy shell script will do it.
4955 parameters to IPython, so a dummy shell script will do it.
4951
4956
4952 Other enhancements made for things to work better under Emacs'
4957 Other enhancements made for things to work better under Emacs'
4953 various types of terminals. Many thanks to Milan Zamazal
4958 various types of terminals. Many thanks to Milan Zamazal
4954 <pdm-AT-zamazal.org> for all the suggestions and pointers.
4959 <pdm-AT-zamazal.org> for all the suggestions and pointers.
4955
4960
4956 2002-03-01 Fernando Perez <fperez@colorado.edu>
4961 2002-03-01 Fernando Perez <fperez@colorado.edu>
4957
4962
4958 * IPython/ipmaker.py (make_IPython): added a --readline! option so
4963 * IPython/ipmaker.py (make_IPython): added a --readline! option so
4959 that loading of readline is now optional. This gives better
4964 that loading of readline is now optional. This gives better
4960 control to emacs users.
4965 control to emacs users.
4961
4966
4962 * IPython/ultraTB.py (__date__): Modified color escape sequences
4967 * IPython/ultraTB.py (__date__): Modified color escape sequences
4963 and now things work fine under xterm and in Emacs' term buffers
4968 and now things work fine under xterm and in Emacs' term buffers
4964 (though not shell ones). Well, in emacs you get colors, but all
4969 (though not shell ones). Well, in emacs you get colors, but all
4965 seem to be 'light' colors (no difference between dark and light
4970 seem to be 'light' colors (no difference between dark and light
4966 ones). But the garbage chars are gone, and also in xterms. It
4971 ones). But the garbage chars are gone, and also in xterms. It
4967 seems that now I'm using 'cleaner' ansi sequences.
4972 seems that now I'm using 'cleaner' ansi sequences.
4968
4973
4969 2002-02-21 Fernando Perez <fperez@colorado.edu>
4974 2002-02-21 Fernando Perez <fperez@colorado.edu>
4970
4975
4971 * Released 0.2.7 (mainly to publish the scoping fix).
4976 * Released 0.2.7 (mainly to publish the scoping fix).
4972
4977
4973 * IPython/Logger.py (Logger.logstate): added. A corresponding
4978 * IPython/Logger.py (Logger.logstate): added. A corresponding
4974 @logstate magic was created.
4979 @logstate magic was created.
4975
4980
4976 * IPython/Magic.py: fixed nested scoping problem under Python
4981 * IPython/Magic.py: fixed nested scoping problem under Python
4977 2.1.x (automagic wasn't working).
4982 2.1.x (automagic wasn't working).
4978
4983
4979 2002-02-20 Fernando Perez <fperez@colorado.edu>
4984 2002-02-20 Fernando Perez <fperez@colorado.edu>
4980
4985
4981 * Released 0.2.6.
4986 * Released 0.2.6.
4982
4987
4983 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
4988 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
4984 option so that logs can come out without any headers at all.
4989 option so that logs can come out without any headers at all.
4985
4990
4986 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
4991 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
4987 SciPy.
4992 SciPy.
4988
4993
4989 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
4994 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
4990 that embedded IPython calls don't require vars() to be explicitly
4995 that embedded IPython calls don't require vars() to be explicitly
4991 passed. Now they are extracted from the caller's frame (code
4996 passed. Now they are extracted from the caller's frame (code
4992 snatched from Eric Jones' weave). Added better documentation to
4997 snatched from Eric Jones' weave). Added better documentation to
4993 the section on embedding and the example file.
4998 the section on embedding and the example file.
4994
4999
4995 * IPython/genutils.py (page): Changed so that under emacs, it just
5000 * IPython/genutils.py (page): Changed so that under emacs, it just
4996 prints the string. You can then page up and down in the emacs
5001 prints the string. You can then page up and down in the emacs
4997 buffer itself. This is how the builtin help() works.
5002 buffer itself. This is how the builtin help() works.
4998
5003
4999 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
5004 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
5000 macro scoping: macros need to be executed in the user's namespace
5005 macro scoping: macros need to be executed in the user's namespace
5001 to work as if they had been typed by the user.
5006 to work as if they had been typed by the user.
5002
5007
5003 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
5008 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
5004 execute automatically (no need to type 'exec...'). They then
5009 execute automatically (no need to type 'exec...'). They then
5005 behave like 'true macros'. The printing system was also modified
5010 behave like 'true macros'. The printing system was also modified
5006 for this to work.
5011 for this to work.
5007
5012
5008 2002-02-19 Fernando Perez <fperez@colorado.edu>
5013 2002-02-19 Fernando Perez <fperez@colorado.edu>
5009
5014
5010 * IPython/genutils.py (page_file): new function for paging files
5015 * IPython/genutils.py (page_file): new function for paging files
5011 in an OS-independent way. Also necessary for file viewing to work
5016 in an OS-independent way. Also necessary for file viewing to work
5012 well inside Emacs buffers.
5017 well inside Emacs buffers.
5013 (page): Added checks for being in an emacs buffer.
5018 (page): Added checks for being in an emacs buffer.
5014 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
5019 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
5015 same bug in iplib.
5020 same bug in iplib.
5016
5021
5017 2002-02-18 Fernando Perez <fperez@colorado.edu>
5022 2002-02-18 Fernando Perez <fperez@colorado.edu>
5018
5023
5019 * IPython/iplib.py (InteractiveShell.init_readline): modified use
5024 * IPython/iplib.py (InteractiveShell.init_readline): modified use
5020 of readline so that IPython can work inside an Emacs buffer.
5025 of readline so that IPython can work inside an Emacs buffer.
5021
5026
5022 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
5027 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
5023 method signatures (they weren't really bugs, but it looks cleaner
5028 method signatures (they weren't really bugs, but it looks cleaner
5024 and keeps PyChecker happy).
5029 and keeps PyChecker happy).
5025
5030
5026 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
5031 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
5027 for implementing various user-defined hooks. Currently only
5032 for implementing various user-defined hooks. Currently only
5028 display is done.
5033 display is done.
5029
5034
5030 * IPython/Prompts.py (CachedOutput._display): changed display
5035 * IPython/Prompts.py (CachedOutput._display): changed display
5031 functions so that they can be dynamically changed by users easily.
5036 functions so that they can be dynamically changed by users easily.
5032
5037
5033 * IPython/Extensions/numeric_formats.py (num_display): added an
5038 * IPython/Extensions/numeric_formats.py (num_display): added an
5034 extension for printing NumPy arrays in flexible manners. It
5039 extension for printing NumPy arrays in flexible manners. It
5035 doesn't do anything yet, but all the structure is in
5040 doesn't do anything yet, but all the structure is in
5036 place. Ultimately the plan is to implement output format control
5041 place. Ultimately the plan is to implement output format control
5037 like in Octave.
5042 like in Octave.
5038
5043
5039 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
5044 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
5040 methods are found at run-time by all the automatic machinery.
5045 methods are found at run-time by all the automatic machinery.
5041
5046
5042 2002-02-17 Fernando Perez <fperez@colorado.edu>
5047 2002-02-17 Fernando Perez <fperez@colorado.edu>
5043
5048
5044 * setup_Windows.py (make_shortcut): documented. Cleaned up the
5049 * setup_Windows.py (make_shortcut): documented. Cleaned up the
5045 whole file a little.
5050 whole file a little.
5046
5051
5047 * ToDo: closed this document. Now there's a new_design.lyx
5052 * ToDo: closed this document. Now there's a new_design.lyx
5048 document for all new ideas. Added making a pdf of it for the
5053 document for all new ideas. Added making a pdf of it for the
5049 end-user distro.
5054 end-user distro.
5050
5055
5051 * IPython/Logger.py (Logger.switch_log): Created this to replace
5056 * IPython/Logger.py (Logger.switch_log): Created this to replace
5052 logon() and logoff(). It also fixes a nasty crash reported by
5057 logon() and logoff(). It also fixes a nasty crash reported by
5053 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
5058 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
5054
5059
5055 * IPython/iplib.py (complete): got auto-completion to work with
5060 * IPython/iplib.py (complete): got auto-completion to work with
5056 automagic (I had wanted this for a long time).
5061 automagic (I had wanted this for a long time).
5057
5062
5058 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
5063 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
5059 to @file, since file() is now a builtin and clashes with automagic
5064 to @file, since file() is now a builtin and clashes with automagic
5060 for @file.
5065 for @file.
5061
5066
5062 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
5067 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
5063 of this was previously in iplib, which had grown to more than 2000
5068 of this was previously in iplib, which had grown to more than 2000
5064 lines, way too long. No new functionality, but it makes managing
5069 lines, way too long. No new functionality, but it makes managing
5065 the code a bit easier.
5070 the code a bit easier.
5066
5071
5067 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
5072 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
5068 information to crash reports.
5073 information to crash reports.
5069
5074
5070 2002-02-12 Fernando Perez <fperez@colorado.edu>
5075 2002-02-12 Fernando Perez <fperez@colorado.edu>
5071
5076
5072 * Released 0.2.5.
5077 * Released 0.2.5.
5073
5078
5074 2002-02-11 Fernando Perez <fperez@colorado.edu>
5079 2002-02-11 Fernando Perez <fperez@colorado.edu>
5075
5080
5076 * Wrote a relatively complete Windows installer. It puts
5081 * Wrote a relatively complete Windows installer. It puts
5077 everything in place, creates Start Menu entries and fixes the
5082 everything in place, creates Start Menu entries and fixes the
5078 color issues. Nothing fancy, but it works.
5083 color issues. Nothing fancy, but it works.
5079
5084
5080 2002-02-10 Fernando Perez <fperez@colorado.edu>
5085 2002-02-10 Fernando Perez <fperez@colorado.edu>
5081
5086
5082 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
5087 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
5083 os.path.expanduser() call so that we can type @run ~/myfile.py and
5088 os.path.expanduser() call so that we can type @run ~/myfile.py and
5084 have thigs work as expected.
5089 have thigs work as expected.
5085
5090
5086 * IPython/genutils.py (page): fixed exception handling so things
5091 * IPython/genutils.py (page): fixed exception handling so things
5087 work both in Unix and Windows correctly. Quitting a pager triggers
5092 work both in Unix and Windows correctly. Quitting a pager triggers
5088 an IOError/broken pipe in Unix, and in windows not finding a pager
5093 an IOError/broken pipe in Unix, and in windows not finding a pager
5089 is also an IOError, so I had to actually look at the return value
5094 is also an IOError, so I had to actually look at the return value
5090 of the exception, not just the exception itself. Should be ok now.
5095 of the exception, not just the exception itself. Should be ok now.
5091
5096
5092 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
5097 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
5093 modified to allow case-insensitive color scheme changes.
5098 modified to allow case-insensitive color scheme changes.
5094
5099
5095 2002-02-09 Fernando Perez <fperez@colorado.edu>
5100 2002-02-09 Fernando Perez <fperez@colorado.edu>
5096
5101
5097 * IPython/genutils.py (native_line_ends): new function to leave
5102 * IPython/genutils.py (native_line_ends): new function to leave
5098 user config files with os-native line-endings.
5103 user config files with os-native line-endings.
5099
5104
5100 * README and manual updates.
5105 * README and manual updates.
5101
5106
5102 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
5107 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
5103 instead of StringType to catch Unicode strings.
5108 instead of StringType to catch Unicode strings.
5104
5109
5105 * IPython/genutils.py (filefind): fixed bug for paths with
5110 * IPython/genutils.py (filefind): fixed bug for paths with
5106 embedded spaces (very common in Windows).
5111 embedded spaces (very common in Windows).
5107
5112
5108 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
5113 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
5109 files under Windows, so that they get automatically associated
5114 files under Windows, so that they get automatically associated
5110 with a text editor. Windows makes it a pain to handle
5115 with a text editor. Windows makes it a pain to handle
5111 extension-less files.
5116 extension-less files.
5112
5117
5113 * IPython/iplib.py (InteractiveShell.init_readline): Made the
5118 * IPython/iplib.py (InteractiveShell.init_readline): Made the
5114 warning about readline only occur for Posix. In Windows there's no
5119 warning about readline only occur for Posix. In Windows there's no
5115 way to get readline, so why bother with the warning.
5120 way to get readline, so why bother with the warning.
5116
5121
5117 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
5122 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
5118 for __str__ instead of dir(self), since dir() changed in 2.2.
5123 for __str__ instead of dir(self), since dir() changed in 2.2.
5119
5124
5120 * Ported to Windows! Tested on XP, I suspect it should work fine
5125 * Ported to Windows! Tested on XP, I suspect it should work fine
5121 on NT/2000, but I don't think it will work on 98 et al. That
5126 on NT/2000, but I don't think it will work on 98 et al. That
5122 series of Windows is such a piece of junk anyway that I won't try
5127 series of Windows is such a piece of junk anyway that I won't try
5123 porting it there. The XP port was straightforward, showed a few
5128 porting it there. The XP port was straightforward, showed a few
5124 bugs here and there (fixed all), in particular some string
5129 bugs here and there (fixed all), in particular some string
5125 handling stuff which required considering Unicode strings (which
5130 handling stuff which required considering Unicode strings (which
5126 Windows uses). This is good, but hasn't been too tested :) No
5131 Windows uses). This is good, but hasn't been too tested :) No
5127 fancy installer yet, I'll put a note in the manual so people at
5132 fancy installer yet, I'll put a note in the manual so people at
5128 least make manually a shortcut.
5133 least make manually a shortcut.
5129
5134
5130 * IPython/iplib.py (Magic.magic_colors): Unified the color options
5135 * IPython/iplib.py (Magic.magic_colors): Unified the color options
5131 into a single one, "colors". This now controls both prompt and
5136 into a single one, "colors". This now controls both prompt and
5132 exception color schemes, and can be changed both at startup
5137 exception color schemes, and can be changed both at startup
5133 (either via command-line switches or via ipythonrc files) and at
5138 (either via command-line switches or via ipythonrc files) and at
5134 runtime, with @colors.
5139 runtime, with @colors.
5135 (Magic.magic_run): renamed @prun to @run and removed the old
5140 (Magic.magic_run): renamed @prun to @run and removed the old
5136 @run. The two were too similar to warrant keeping both.
5141 @run. The two were too similar to warrant keeping both.
5137
5142
5138 2002-02-03 Fernando Perez <fperez@colorado.edu>
5143 2002-02-03 Fernando Perez <fperez@colorado.edu>
5139
5144
5140 * IPython/iplib.py (install_first_time): Added comment on how to
5145 * IPython/iplib.py (install_first_time): Added comment on how to
5141 configure the color options for first-time users. Put a <return>
5146 configure the color options for first-time users. Put a <return>
5142 request at the end so that small-terminal users get a chance to
5147 request at the end so that small-terminal users get a chance to
5143 read the startup info.
5148 read the startup info.
5144
5149
5145 2002-01-23 Fernando Perez <fperez@colorado.edu>
5150 2002-01-23 Fernando Perez <fperez@colorado.edu>
5146
5151
5147 * IPython/iplib.py (CachedOutput.update): Changed output memory
5152 * IPython/iplib.py (CachedOutput.update): Changed output memory
5148 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
5153 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
5149 input history we still use _i. Did this b/c these variable are
5154 input history we still use _i. Did this b/c these variable are
5150 very commonly used in interactive work, so the less we need to
5155 very commonly used in interactive work, so the less we need to
5151 type the better off we are.
5156 type the better off we are.
5152 (Magic.magic_prun): updated @prun to better handle the namespaces
5157 (Magic.magic_prun): updated @prun to better handle the namespaces
5153 the file will run in, including a fix for __name__ not being set
5158 the file will run in, including a fix for __name__ not being set
5154 before.
5159 before.
5155
5160
5156 2002-01-20 Fernando Perez <fperez@colorado.edu>
5161 2002-01-20 Fernando Perez <fperez@colorado.edu>
5157
5162
5158 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
5163 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
5159 extra garbage for Python 2.2. Need to look more carefully into
5164 extra garbage for Python 2.2. Need to look more carefully into
5160 this later.
5165 this later.
5161
5166
5162 2002-01-19 Fernando Perez <fperez@colorado.edu>
5167 2002-01-19 Fernando Perez <fperez@colorado.edu>
5163
5168
5164 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
5169 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
5165 display SyntaxError exceptions properly formatted when they occur
5170 display SyntaxError exceptions properly formatted when they occur
5166 (they can be triggered by imported code).
5171 (they can be triggered by imported code).
5167
5172
5168 2002-01-18 Fernando Perez <fperez@colorado.edu>
5173 2002-01-18 Fernando Perez <fperez@colorado.edu>
5169
5174
5170 * IPython/iplib.py (InteractiveShell.safe_execfile): now
5175 * IPython/iplib.py (InteractiveShell.safe_execfile): now
5171 SyntaxError exceptions are reported nicely formatted, instead of
5176 SyntaxError exceptions are reported nicely formatted, instead of
5172 spitting out only offset information as before.
5177 spitting out only offset information as before.
5173 (Magic.magic_prun): Added the @prun function for executing
5178 (Magic.magic_prun): Added the @prun function for executing
5174 programs with command line args inside IPython.
5179 programs with command line args inside IPython.
5175
5180
5176 2002-01-16 Fernando Perez <fperez@colorado.edu>
5181 2002-01-16 Fernando Perez <fperez@colorado.edu>
5177
5182
5178 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
5183 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
5179 to *not* include the last item given in a range. This brings their
5184 to *not* include the last item given in a range. This brings their
5180 behavior in line with Python's slicing:
5185 behavior in line with Python's slicing:
5181 a[n1:n2] -> a[n1]...a[n2-1]
5186 a[n1:n2] -> a[n1]...a[n2-1]
5182 It may be a bit less convenient, but I prefer to stick to Python's
5187 It may be a bit less convenient, but I prefer to stick to Python's
5183 conventions *everywhere*, so users never have to wonder.
5188 conventions *everywhere*, so users never have to wonder.
5184 (Magic.magic_macro): Added @macro function to ease the creation of
5189 (Magic.magic_macro): Added @macro function to ease the creation of
5185 macros.
5190 macros.
5186
5191
5187 2002-01-05 Fernando Perez <fperez@colorado.edu>
5192 2002-01-05 Fernando Perez <fperez@colorado.edu>
5188
5193
5189 * Released 0.2.4.
5194 * Released 0.2.4.
5190
5195
5191 * IPython/iplib.py (Magic.magic_pdef):
5196 * IPython/iplib.py (Magic.magic_pdef):
5192 (InteractiveShell.safe_execfile): report magic lines and error
5197 (InteractiveShell.safe_execfile): report magic lines and error
5193 lines without line numbers so one can easily copy/paste them for
5198 lines without line numbers so one can easily copy/paste them for
5194 re-execution.
5199 re-execution.
5195
5200
5196 * Updated manual with recent changes.
5201 * Updated manual with recent changes.
5197
5202
5198 * IPython/iplib.py (Magic.magic_oinfo): added constructor
5203 * IPython/iplib.py (Magic.magic_oinfo): added constructor
5199 docstring printing when class? is called. Very handy for knowing
5204 docstring printing when class? is called. Very handy for knowing
5200 how to create class instances (as long as __init__ is well
5205 how to create class instances (as long as __init__ is well
5201 documented, of course :)
5206 documented, of course :)
5202 (Magic.magic_doc): print both class and constructor docstrings.
5207 (Magic.magic_doc): print both class and constructor docstrings.
5203 (Magic.magic_pdef): give constructor info if passed a class and
5208 (Magic.magic_pdef): give constructor info if passed a class and
5204 __call__ info for callable object instances.
5209 __call__ info for callable object instances.
5205
5210
5206 2002-01-04 Fernando Perez <fperez@colorado.edu>
5211 2002-01-04 Fernando Perez <fperez@colorado.edu>
5207
5212
5208 * Made deep_reload() off by default. It doesn't always work
5213 * Made deep_reload() off by default. It doesn't always work
5209 exactly as intended, so it's probably safer to have it off. It's
5214 exactly as intended, so it's probably safer to have it off. It's
5210 still available as dreload() anyway, so nothing is lost.
5215 still available as dreload() anyway, so nothing is lost.
5211
5216
5212 2002-01-02 Fernando Perez <fperez@colorado.edu>
5217 2002-01-02 Fernando Perez <fperez@colorado.edu>
5213
5218
5214 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
5219 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
5215 so I wanted an updated release).
5220 so I wanted an updated release).
5216
5221
5217 2001-12-27 Fernando Perez <fperez@colorado.edu>
5222 2001-12-27 Fernando Perez <fperez@colorado.edu>
5218
5223
5219 * IPython/iplib.py (InteractiveShell.interact): Added the original
5224 * IPython/iplib.py (InteractiveShell.interact): Added the original
5220 code from 'code.py' for this module in order to change the
5225 code from 'code.py' for this module in order to change the
5221 handling of a KeyboardInterrupt. This was necessary b/c otherwise
5226 handling of a KeyboardInterrupt. This was necessary b/c otherwise
5222 the history cache would break when the user hit Ctrl-C, and
5227 the history cache would break when the user hit Ctrl-C, and
5223 interact() offers no way to add any hooks to it.
5228 interact() offers no way to add any hooks to it.
5224
5229
5225 2001-12-23 Fernando Perez <fperez@colorado.edu>
5230 2001-12-23 Fernando Perez <fperez@colorado.edu>
5226
5231
5227 * setup.py: added check for 'MANIFEST' before trying to remove
5232 * setup.py: added check for 'MANIFEST' before trying to remove
5228 it. Thanks to Sean Reifschneider.
5233 it. Thanks to Sean Reifschneider.
5229
5234
5230 2001-12-22 Fernando Perez <fperez@colorado.edu>
5235 2001-12-22 Fernando Perez <fperez@colorado.edu>
5231
5236
5232 * Released 0.2.2.
5237 * Released 0.2.2.
5233
5238
5234 * Finished (reasonably) writing the manual. Later will add the
5239 * Finished (reasonably) writing the manual. Later will add the
5235 python-standard navigation stylesheets, but for the time being
5240 python-standard navigation stylesheets, but for the time being
5236 it's fairly complete. Distribution will include html and pdf
5241 it's fairly complete. Distribution will include html and pdf
5237 versions.
5242 versions.
5238
5243
5239 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
5244 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
5240 (MayaVi author).
5245 (MayaVi author).
5241
5246
5242 2001-12-21 Fernando Perez <fperez@colorado.edu>
5247 2001-12-21 Fernando Perez <fperez@colorado.edu>
5243
5248
5244 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
5249 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
5245 good public release, I think (with the manual and the distutils
5250 good public release, I think (with the manual and the distutils
5246 installer). The manual can use some work, but that can go
5251 installer). The manual can use some work, but that can go
5247 slowly. Otherwise I think it's quite nice for end users. Next
5252 slowly. Otherwise I think it's quite nice for end users. Next
5248 summer, rewrite the guts of it...
5253 summer, rewrite the guts of it...
5249
5254
5250 * Changed format of ipythonrc files to use whitespace as the
5255 * Changed format of ipythonrc files to use whitespace as the
5251 separator instead of an explicit '='. Cleaner.
5256 separator instead of an explicit '='. Cleaner.
5252
5257
5253 2001-12-20 Fernando Perez <fperez@colorado.edu>
5258 2001-12-20 Fernando Perez <fperez@colorado.edu>
5254
5259
5255 * Started a manual in LyX. For now it's just a quick merge of the
5260 * Started a manual in LyX. For now it's just a quick merge of the
5256 various internal docstrings and READMEs. Later it may grow into a
5261 various internal docstrings and READMEs. Later it may grow into a
5257 nice, full-blown manual.
5262 nice, full-blown manual.
5258
5263
5259 * Set up a distutils based installer. Installation should now be
5264 * Set up a distutils based installer. Installation should now be
5260 trivially simple for end-users.
5265 trivially simple for end-users.
5261
5266
5262 2001-12-11 Fernando Perez <fperez@colorado.edu>
5267 2001-12-11 Fernando Perez <fperez@colorado.edu>
5263
5268
5264 * Released 0.2.0. First public release, announced it at
5269 * Released 0.2.0. First public release, announced it at
5265 comp.lang.python. From now on, just bugfixes...
5270 comp.lang.python. From now on, just bugfixes...
5266
5271
5267 * Went through all the files, set copyright/license notices and
5272 * Went through all the files, set copyright/license notices and
5268 cleaned up things. Ready for release.
5273 cleaned up things. Ready for release.
5269
5274
5270 2001-12-10 Fernando Perez <fperez@colorado.edu>
5275 2001-12-10 Fernando Perez <fperez@colorado.edu>
5271
5276
5272 * Changed the first-time installer not to use tarfiles. It's more
5277 * Changed the first-time installer not to use tarfiles. It's more
5273 robust now and less unix-dependent. Also makes it easier for
5278 robust now and less unix-dependent. Also makes it easier for
5274 people to later upgrade versions.
5279 people to later upgrade versions.
5275
5280
5276 * Changed @exit to @abort to reflect the fact that it's pretty
5281 * Changed @exit to @abort to reflect the fact that it's pretty
5277 brutal (a sys.exit()). The difference between @abort and Ctrl-D
5282 brutal (a sys.exit()). The difference between @abort and Ctrl-D
5278 becomes significant only when IPyhton is embedded: in that case,
5283 becomes significant only when IPyhton is embedded: in that case,
5279 C-D closes IPython only, but @abort kills the enclosing program
5284 C-D closes IPython only, but @abort kills the enclosing program
5280 too (unless it had called IPython inside a try catching
5285 too (unless it had called IPython inside a try catching
5281 SystemExit).
5286 SystemExit).
5282
5287
5283 * Created Shell module which exposes the actuall IPython Shell
5288 * Created Shell module which exposes the actuall IPython Shell
5284 classes, currently the normal and the embeddable one. This at
5289 classes, currently the normal and the embeddable one. This at
5285 least offers a stable interface we won't need to change when
5290 least offers a stable interface we won't need to change when
5286 (later) the internals are rewritten. That rewrite will be confined
5291 (later) the internals are rewritten. That rewrite will be confined
5287 to iplib and ipmaker, but the Shell interface should remain as is.
5292 to iplib and ipmaker, but the Shell interface should remain as is.
5288
5293
5289 * Added embed module which offers an embeddable IPShell object,
5294 * Added embed module which offers an embeddable IPShell object,
5290 useful to fire up IPython *inside* a running program. Great for
5295 useful to fire up IPython *inside* a running program. Great for
5291 debugging or dynamical data analysis.
5296 debugging or dynamical data analysis.
5292
5297
5293 2001-12-08 Fernando Perez <fperez@colorado.edu>
5298 2001-12-08 Fernando Perez <fperez@colorado.edu>
5294
5299
5295 * Fixed small bug preventing seeing info from methods of defined
5300 * Fixed small bug preventing seeing info from methods of defined
5296 objects (incorrect namespace in _ofind()).
5301 objects (incorrect namespace in _ofind()).
5297
5302
5298 * Documentation cleanup. Moved the main usage docstrings to a
5303 * Documentation cleanup. Moved the main usage docstrings to a
5299 separate file, usage.py (cleaner to maintain, and hopefully in the
5304 separate file, usage.py (cleaner to maintain, and hopefully in the
5300 future some perlpod-like way of producing interactive, man and
5305 future some perlpod-like way of producing interactive, man and
5301 html docs out of it will be found).
5306 html docs out of it will be found).
5302
5307
5303 * Added @profile to see your profile at any time.
5308 * Added @profile to see your profile at any time.
5304
5309
5305 * Added @p as an alias for 'print'. It's especially convenient if
5310 * Added @p as an alias for 'print'. It's especially convenient if
5306 using automagic ('p x' prints x).
5311 using automagic ('p x' prints x).
5307
5312
5308 * Small cleanups and fixes after a pychecker run.
5313 * Small cleanups and fixes after a pychecker run.
5309
5314
5310 * Changed the @cd command to handle @cd - and @cd -<n> for
5315 * Changed the @cd command to handle @cd - and @cd -<n> for
5311 visiting any directory in _dh.
5316 visiting any directory in _dh.
5312
5317
5313 * Introduced _dh, a history of visited directories. @dhist prints
5318 * Introduced _dh, a history of visited directories. @dhist prints
5314 it out with numbers.
5319 it out with numbers.
5315
5320
5316 2001-12-07 Fernando Perez <fperez@colorado.edu>
5321 2001-12-07 Fernando Perez <fperez@colorado.edu>
5317
5322
5318 * Released 0.1.22
5323 * Released 0.1.22
5319
5324
5320 * Made initialization a bit more robust against invalid color
5325 * Made initialization a bit more robust against invalid color
5321 options in user input (exit, not traceback-crash).
5326 options in user input (exit, not traceback-crash).
5322
5327
5323 * Changed the bug crash reporter to write the report only in the
5328 * Changed the bug crash reporter to write the report only in the
5324 user's .ipython directory. That way IPython won't litter people's
5329 user's .ipython directory. That way IPython won't litter people's
5325 hard disks with crash files all over the place. Also print on
5330 hard disks with crash files all over the place. Also print on
5326 screen the necessary mail command.
5331 screen the necessary mail command.
5327
5332
5328 * With the new ultraTB, implemented LightBG color scheme for light
5333 * With the new ultraTB, implemented LightBG color scheme for light
5329 background terminals. A lot of people like white backgrounds, so I
5334 background terminals. A lot of people like white backgrounds, so I
5330 guess we should at least give them something readable.
5335 guess we should at least give them something readable.
5331
5336
5332 2001-12-06 Fernando Perez <fperez@colorado.edu>
5337 2001-12-06 Fernando Perez <fperez@colorado.edu>
5333
5338
5334 * Modified the structure of ultraTB. Now there's a proper class
5339 * Modified the structure of ultraTB. Now there's a proper class
5335 for tables of color schemes which allow adding schemes easily and
5340 for tables of color schemes which allow adding schemes easily and
5336 switching the active scheme without creating a new instance every
5341 switching the active scheme without creating a new instance every
5337 time (which was ridiculous). The syntax for creating new schemes
5342 time (which was ridiculous). The syntax for creating new schemes
5338 is also cleaner. I think ultraTB is finally done, with a clean
5343 is also cleaner. I think ultraTB is finally done, with a clean
5339 class structure. Names are also much cleaner (now there's proper
5344 class structure. Names are also much cleaner (now there's proper
5340 color tables, no need for every variable to also have 'color' in
5345 color tables, no need for every variable to also have 'color' in
5341 its name).
5346 its name).
5342
5347
5343 * Broke down genutils into separate files. Now genutils only
5348 * Broke down genutils into separate files. Now genutils only
5344 contains utility functions, and classes have been moved to their
5349 contains utility functions, and classes have been moved to their
5345 own files (they had enough independent functionality to warrant
5350 own files (they had enough independent functionality to warrant
5346 it): ConfigLoader, OutputTrap, Struct.
5351 it): ConfigLoader, OutputTrap, Struct.
5347
5352
5348 2001-12-05 Fernando Perez <fperez@colorado.edu>
5353 2001-12-05 Fernando Perez <fperez@colorado.edu>
5349
5354
5350 * IPython turns 21! Released version 0.1.21, as a candidate for
5355 * IPython turns 21! Released version 0.1.21, as a candidate for
5351 public consumption. If all goes well, release in a few days.
5356 public consumption. If all goes well, release in a few days.
5352
5357
5353 * Fixed path bug (files in Extensions/ directory wouldn't be found
5358 * Fixed path bug (files in Extensions/ directory wouldn't be found
5354 unless IPython/ was explicitly in sys.path).
5359 unless IPython/ was explicitly in sys.path).
5355
5360
5356 * Extended the FlexCompleter class as MagicCompleter to allow
5361 * Extended the FlexCompleter class as MagicCompleter to allow
5357 completion of @-starting lines.
5362 completion of @-starting lines.
5358
5363
5359 * Created __release__.py file as a central repository for release
5364 * Created __release__.py file as a central repository for release
5360 info that other files can read from.
5365 info that other files can read from.
5361
5366
5362 * Fixed small bug in logging: when logging was turned on in
5367 * Fixed small bug in logging: when logging was turned on in
5363 mid-session, old lines with special meanings (!@?) were being
5368 mid-session, old lines with special meanings (!@?) were being
5364 logged without the prepended comment, which is necessary since
5369 logged without the prepended comment, which is necessary since
5365 they are not truly valid python syntax. This should make session
5370 they are not truly valid python syntax. This should make session
5366 restores produce less errors.
5371 restores produce less errors.
5367
5372
5368 * The namespace cleanup forced me to make a FlexCompleter class
5373 * The namespace cleanup forced me to make a FlexCompleter class
5369 which is nothing but a ripoff of rlcompleter, but with selectable
5374 which is nothing but a ripoff of rlcompleter, but with selectable
5370 namespace (rlcompleter only works in __main__.__dict__). I'll try
5375 namespace (rlcompleter only works in __main__.__dict__). I'll try
5371 to submit a note to the authors to see if this change can be
5376 to submit a note to the authors to see if this change can be
5372 incorporated in future rlcompleter releases (Dec.6: done)
5377 incorporated in future rlcompleter releases (Dec.6: done)
5373
5378
5374 * More fixes to namespace handling. It was a mess! Now all
5379 * More fixes to namespace handling. It was a mess! Now all
5375 explicit references to __main__.__dict__ are gone (except when
5380 explicit references to __main__.__dict__ are gone (except when
5376 really needed) and everything is handled through the namespace
5381 really needed) and everything is handled through the namespace
5377 dicts in the IPython instance. We seem to be getting somewhere
5382 dicts in the IPython instance. We seem to be getting somewhere
5378 with this, finally...
5383 with this, finally...
5379
5384
5380 * Small documentation updates.
5385 * Small documentation updates.
5381
5386
5382 * Created the Extensions directory under IPython (with an
5387 * Created the Extensions directory under IPython (with an
5383 __init__.py). Put the PhysicalQ stuff there. This directory should
5388 __init__.py). Put the PhysicalQ stuff there. This directory should
5384 be used for all special-purpose extensions.
5389 be used for all special-purpose extensions.
5385
5390
5386 * File renaming:
5391 * File renaming:
5387 ipythonlib --> ipmaker
5392 ipythonlib --> ipmaker
5388 ipplib --> iplib
5393 ipplib --> iplib
5389 This makes a bit more sense in terms of what these files actually do.
5394 This makes a bit more sense in terms of what these files actually do.
5390
5395
5391 * Moved all the classes and functions in ipythonlib to ipplib, so
5396 * Moved all the classes and functions in ipythonlib to ipplib, so
5392 now ipythonlib only has make_IPython(). This will ease up its
5397 now ipythonlib only has make_IPython(). This will ease up its
5393 splitting in smaller functional chunks later.
5398 splitting in smaller functional chunks later.
5394
5399
5395 * Cleaned up (done, I think) output of @whos. Better column
5400 * Cleaned up (done, I think) output of @whos. Better column
5396 formatting, and now shows str(var) for as much as it can, which is
5401 formatting, and now shows str(var) for as much as it can, which is
5397 typically what one gets with a 'print var'.
5402 typically what one gets with a 'print var'.
5398
5403
5399 2001-12-04 Fernando Perez <fperez@colorado.edu>
5404 2001-12-04 Fernando Perez <fperez@colorado.edu>
5400
5405
5401 * Fixed namespace problems. Now builtin/IPyhton/user names get
5406 * Fixed namespace problems. Now builtin/IPyhton/user names get
5402 properly reported in their namespace. Internal namespace handling
5407 properly reported in their namespace. Internal namespace handling
5403 is finally getting decent (not perfect yet, but much better than
5408 is finally getting decent (not perfect yet, but much better than
5404 the ad-hoc mess we had).
5409 the ad-hoc mess we had).
5405
5410
5406 * Removed -exit option. If people just want to run a python
5411 * Removed -exit option. If people just want to run a python
5407 script, that's what the normal interpreter is for. Less
5412 script, that's what the normal interpreter is for. Less
5408 unnecessary options, less chances for bugs.
5413 unnecessary options, less chances for bugs.
5409
5414
5410 * Added a crash handler which generates a complete post-mortem if
5415 * Added a crash handler which generates a complete post-mortem if
5411 IPython crashes. This will help a lot in tracking bugs down the
5416 IPython crashes. This will help a lot in tracking bugs down the
5412 road.
5417 road.
5413
5418
5414 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
5419 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
5415 which were boud to functions being reassigned would bypass the
5420 which were boud to functions being reassigned would bypass the
5416 logger, breaking the sync of _il with the prompt counter. This
5421 logger, breaking the sync of _il with the prompt counter. This
5417 would then crash IPython later when a new line was logged.
5422 would then crash IPython later when a new line was logged.
5418
5423
5419 2001-12-02 Fernando Perez <fperez@colorado.edu>
5424 2001-12-02 Fernando Perez <fperez@colorado.edu>
5420
5425
5421 * Made IPython a package. This means people don't have to clutter
5426 * Made IPython a package. This means people don't have to clutter
5422 their sys.path with yet another directory. Changed the INSTALL
5427 their sys.path with yet another directory. Changed the INSTALL
5423 file accordingly.
5428 file accordingly.
5424
5429
5425 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
5430 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
5426 sorts its output (so @who shows it sorted) and @whos formats the
5431 sorts its output (so @who shows it sorted) and @whos formats the
5427 table according to the width of the first column. Nicer, easier to
5432 table according to the width of the first column. Nicer, easier to
5428 read. Todo: write a generic table_format() which takes a list of
5433 read. Todo: write a generic table_format() which takes a list of
5429 lists and prints it nicely formatted, with optional row/column
5434 lists and prints it nicely formatted, with optional row/column
5430 separators and proper padding and justification.
5435 separators and proper padding and justification.
5431
5436
5432 * Released 0.1.20
5437 * Released 0.1.20
5433
5438
5434 * Fixed bug in @log which would reverse the inputcache list (a
5439 * Fixed bug in @log which would reverse the inputcache list (a
5435 copy operation was missing).
5440 copy operation was missing).
5436
5441
5437 * Code cleanup. @config was changed to use page(). Better, since
5442 * Code cleanup. @config was changed to use page(). Better, since
5438 its output is always quite long.
5443 its output is always quite long.
5439
5444
5440 * Itpl is back as a dependency. I was having too many problems
5445 * Itpl is back as a dependency. I was having too many problems
5441 getting the parametric aliases to work reliably, and it's just
5446 getting the parametric aliases to work reliably, and it's just
5442 easier to code weird string operations with it than playing %()s
5447 easier to code weird string operations with it than playing %()s
5443 games. It's only ~6k, so I don't think it's too big a deal.
5448 games. It's only ~6k, so I don't think it's too big a deal.
5444
5449
5445 * Found (and fixed) a very nasty bug with history. !lines weren't
5450 * Found (and fixed) a very nasty bug with history. !lines weren't
5446 getting cached, and the out of sync caches would crash
5451 getting cached, and the out of sync caches would crash
5447 IPython. Fixed it by reorganizing the prefilter/handlers/logger
5452 IPython. Fixed it by reorganizing the prefilter/handlers/logger
5448 division of labor a bit better. Bug fixed, cleaner structure.
5453 division of labor a bit better. Bug fixed, cleaner structure.
5449
5454
5450 2001-12-01 Fernando Perez <fperez@colorado.edu>
5455 2001-12-01 Fernando Perez <fperez@colorado.edu>
5451
5456
5452 * Released 0.1.19
5457 * Released 0.1.19
5453
5458
5454 * Added option -n to @hist to prevent line number printing. Much
5459 * Added option -n to @hist to prevent line number printing. Much
5455 easier to copy/paste code this way.
5460 easier to copy/paste code this way.
5456
5461
5457 * Created global _il to hold the input list. Allows easy
5462 * Created global _il to hold the input list. Allows easy
5458 re-execution of blocks of code by slicing it (inspired by Janko's
5463 re-execution of blocks of code by slicing it (inspired by Janko's
5459 comment on 'macros').
5464 comment on 'macros').
5460
5465
5461 * Small fixes and doc updates.
5466 * Small fixes and doc updates.
5462
5467
5463 * Rewrote @history function (was @h). Renamed it to @hist, @h is
5468 * Rewrote @history function (was @h). Renamed it to @hist, @h is
5464 much too fragile with automagic. Handles properly multi-line
5469 much too fragile with automagic. Handles properly multi-line
5465 statements and takes parameters.
5470 statements and takes parameters.
5466
5471
5467 2001-11-30 Fernando Perez <fperez@colorado.edu>
5472 2001-11-30 Fernando Perez <fperez@colorado.edu>
5468
5473
5469 * Version 0.1.18 released.
5474 * Version 0.1.18 released.
5470
5475
5471 * Fixed nasty namespace bug in initial module imports.
5476 * Fixed nasty namespace bug in initial module imports.
5472
5477
5473 * Added copyright/license notes to all code files (except
5478 * Added copyright/license notes to all code files (except
5474 DPyGetOpt). For the time being, LGPL. That could change.
5479 DPyGetOpt). For the time being, LGPL. That could change.
5475
5480
5476 * Rewrote a much nicer README, updated INSTALL, cleaned up
5481 * Rewrote a much nicer README, updated INSTALL, cleaned up
5477 ipythonrc-* samples.
5482 ipythonrc-* samples.
5478
5483
5479 * Overall code/documentation cleanup. Basically ready for
5484 * Overall code/documentation cleanup. Basically ready for
5480 release. Only remaining thing: licence decision (LGPL?).
5485 release. Only remaining thing: licence decision (LGPL?).
5481
5486
5482 * Converted load_config to a class, ConfigLoader. Now recursion
5487 * Converted load_config to a class, ConfigLoader. Now recursion
5483 control is better organized. Doesn't include the same file twice.
5488 control is better organized. Doesn't include the same file twice.
5484
5489
5485 2001-11-29 Fernando Perez <fperez@colorado.edu>
5490 2001-11-29 Fernando Perez <fperez@colorado.edu>
5486
5491
5487 * Got input history working. Changed output history variables from
5492 * Got input history working. Changed output history variables from
5488 _p to _o so that _i is for input and _o for output. Just cleaner
5493 _p to _o so that _i is for input and _o for output. Just cleaner
5489 convention.
5494 convention.
5490
5495
5491 * Implemented parametric aliases. This pretty much allows the
5496 * Implemented parametric aliases. This pretty much allows the
5492 alias system to offer full-blown shell convenience, I think.
5497 alias system to offer full-blown shell convenience, I think.
5493
5498
5494 * Version 0.1.17 released, 0.1.18 opened.
5499 * Version 0.1.17 released, 0.1.18 opened.
5495
5500
5496 * dot_ipython/ipythonrc (alias): added documentation.
5501 * dot_ipython/ipythonrc (alias): added documentation.
5497 (xcolor): Fixed small bug (xcolors -> xcolor)
5502 (xcolor): Fixed small bug (xcolors -> xcolor)
5498
5503
5499 * Changed the alias system. Now alias is a magic command to define
5504 * Changed the alias system. Now alias is a magic command to define
5500 aliases just like the shell. Rationale: the builtin magics should
5505 aliases just like the shell. Rationale: the builtin magics should
5501 be there for things deeply connected to IPython's
5506 be there for things deeply connected to IPython's
5502 architecture. And this is a much lighter system for what I think
5507 architecture. And this is a much lighter system for what I think
5503 is the really important feature: allowing users to define quickly
5508 is the really important feature: allowing users to define quickly
5504 magics that will do shell things for them, so they can customize
5509 magics that will do shell things for them, so they can customize
5505 IPython easily to match their work habits. If someone is really
5510 IPython easily to match their work habits. If someone is really
5506 desperate to have another name for a builtin alias, they can
5511 desperate to have another name for a builtin alias, they can
5507 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
5512 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
5508 works.
5513 works.
5509
5514
5510 2001-11-28 Fernando Perez <fperez@colorado.edu>
5515 2001-11-28 Fernando Perez <fperez@colorado.edu>
5511
5516
5512 * Changed @file so that it opens the source file at the proper
5517 * Changed @file so that it opens the source file at the proper
5513 line. Since it uses less, if your EDITOR environment is
5518 line. Since it uses less, if your EDITOR environment is
5514 configured, typing v will immediately open your editor of choice
5519 configured, typing v will immediately open your editor of choice
5515 right at the line where the object is defined. Not as quick as
5520 right at the line where the object is defined. Not as quick as
5516 having a direct @edit command, but for all intents and purposes it
5521 having a direct @edit command, but for all intents and purposes it
5517 works. And I don't have to worry about writing @edit to deal with
5522 works. And I don't have to worry about writing @edit to deal with
5518 all the editors, less does that.
5523 all the editors, less does that.
5519
5524
5520 * Version 0.1.16 released, 0.1.17 opened.
5525 * Version 0.1.16 released, 0.1.17 opened.
5521
5526
5522 * Fixed some nasty bugs in the page/page_dumb combo that could
5527 * Fixed some nasty bugs in the page/page_dumb combo that could
5523 crash IPython.
5528 crash IPython.
5524
5529
5525 2001-11-27 Fernando Perez <fperez@colorado.edu>
5530 2001-11-27 Fernando Perez <fperez@colorado.edu>
5526
5531
5527 * Version 0.1.15 released, 0.1.16 opened.
5532 * Version 0.1.15 released, 0.1.16 opened.
5528
5533
5529 * Finally got ? and ?? to work for undefined things: now it's
5534 * Finally got ? and ?? to work for undefined things: now it's
5530 possible to type {}.get? and get information about the get method
5535 possible to type {}.get? and get information about the get method
5531 of dicts, or os.path? even if only os is defined (so technically
5536 of dicts, or os.path? even if only os is defined (so technically
5532 os.path isn't). Works at any level. For example, after import os,
5537 os.path isn't). Works at any level. For example, after import os,
5533 os?, os.path?, os.path.abspath? all work. This is great, took some
5538 os?, os.path?, os.path.abspath? all work. This is great, took some
5534 work in _ofind.
5539 work in _ofind.
5535
5540
5536 * Fixed more bugs with logging. The sanest way to do it was to add
5541 * Fixed more bugs with logging. The sanest way to do it was to add
5537 to @log a 'mode' parameter. Killed two in one shot (this mode
5542 to @log a 'mode' parameter. Killed two in one shot (this mode
5538 option was a request of Janko's). I think it's finally clean
5543 option was a request of Janko's). I think it's finally clean
5539 (famous last words).
5544 (famous last words).
5540
5545
5541 * Added a page_dumb() pager which does a decent job of paging on
5546 * Added a page_dumb() pager which does a decent job of paging on
5542 screen, if better things (like less) aren't available. One less
5547 screen, if better things (like less) aren't available. One less
5543 unix dependency (someday maybe somebody will port this to
5548 unix dependency (someday maybe somebody will port this to
5544 windows).
5549 windows).
5545
5550
5546 * Fixed problem in magic_log: would lock of logging out if log
5551 * Fixed problem in magic_log: would lock of logging out if log
5547 creation failed (because it would still think it had succeeded).
5552 creation failed (because it would still think it had succeeded).
5548
5553
5549 * Improved the page() function using curses to auto-detect screen
5554 * Improved the page() function using curses to auto-detect screen
5550 size. Now it can make a much better decision on whether to print
5555 size. Now it can make a much better decision on whether to print
5551 or page a string. Option screen_length was modified: a value 0
5556 or page a string. Option screen_length was modified: a value 0
5552 means auto-detect, and that's the default now.
5557 means auto-detect, and that's the default now.
5553
5558
5554 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
5559 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
5555 go out. I'll test it for a few days, then talk to Janko about
5560 go out. I'll test it for a few days, then talk to Janko about
5556 licences and announce it.
5561 licences and announce it.
5557
5562
5558 * Fixed the length of the auto-generated ---> prompt which appears
5563 * Fixed the length of the auto-generated ---> prompt which appears
5559 for auto-parens and auto-quotes. Getting this right isn't trivial,
5564 for auto-parens and auto-quotes. Getting this right isn't trivial,
5560 with all the color escapes, different prompt types and optional
5565 with all the color escapes, different prompt types and optional
5561 separators. But it seems to be working in all the combinations.
5566 separators. But it seems to be working in all the combinations.
5562
5567
5563 2001-11-26 Fernando Perez <fperez@colorado.edu>
5568 2001-11-26 Fernando Perez <fperez@colorado.edu>
5564
5569
5565 * Wrote a regexp filter to get option types from the option names
5570 * Wrote a regexp filter to get option types from the option names
5566 string. This eliminates the need to manually keep two duplicate
5571 string. This eliminates the need to manually keep two duplicate
5567 lists.
5572 lists.
5568
5573
5569 * Removed the unneeded check_option_names. Now options are handled
5574 * Removed the unneeded check_option_names. Now options are handled
5570 in a much saner manner and it's easy to visually check that things
5575 in a much saner manner and it's easy to visually check that things
5571 are ok.
5576 are ok.
5572
5577
5573 * Updated version numbers on all files I modified to carry a
5578 * Updated version numbers on all files I modified to carry a
5574 notice so Janko and Nathan have clear version markers.
5579 notice so Janko and Nathan have clear version markers.
5575
5580
5576 * Updated docstring for ultraTB with my changes. I should send
5581 * Updated docstring for ultraTB with my changes. I should send
5577 this to Nathan.
5582 this to Nathan.
5578
5583
5579 * Lots of small fixes. Ran everything through pychecker again.
5584 * Lots of small fixes. Ran everything through pychecker again.
5580
5585
5581 * Made loading of deep_reload an cmd line option. If it's not too
5586 * Made loading of deep_reload an cmd line option. If it's not too
5582 kosher, now people can just disable it. With -nodeep_reload it's
5587 kosher, now people can just disable it. With -nodeep_reload it's
5583 still available as dreload(), it just won't overwrite reload().
5588 still available as dreload(), it just won't overwrite reload().
5584
5589
5585 * Moved many options to the no| form (-opt and -noopt
5590 * Moved many options to the no| form (-opt and -noopt
5586 accepted). Cleaner.
5591 accepted). Cleaner.
5587
5592
5588 * Changed magic_log so that if called with no parameters, it uses
5593 * Changed magic_log so that if called with no parameters, it uses
5589 'rotate' mode. That way auto-generated logs aren't automatically
5594 'rotate' mode. That way auto-generated logs aren't automatically
5590 over-written. For normal logs, now a backup is made if it exists
5595 over-written. For normal logs, now a backup is made if it exists
5591 (only 1 level of backups). A new 'backup' mode was added to the
5596 (only 1 level of backups). A new 'backup' mode was added to the
5592 Logger class to support this. This was a request by Janko.
5597 Logger class to support this. This was a request by Janko.
5593
5598
5594 * Added @logoff/@logon to stop/restart an active log.
5599 * Added @logoff/@logon to stop/restart an active log.
5595
5600
5596 * Fixed a lot of bugs in log saving/replay. It was pretty
5601 * Fixed a lot of bugs in log saving/replay. It was pretty
5597 broken. Now special lines (!@,/) appear properly in the command
5602 broken. Now special lines (!@,/) appear properly in the command
5598 history after a log replay.
5603 history after a log replay.
5599
5604
5600 * Tried and failed to implement full session saving via pickle. My
5605 * Tried and failed to implement full session saving via pickle. My
5601 idea was to pickle __main__.__dict__, but modules can't be
5606 idea was to pickle __main__.__dict__, but modules can't be
5602 pickled. This would be a better alternative to replaying logs, but
5607 pickled. This would be a better alternative to replaying logs, but
5603 seems quite tricky to get to work. Changed -session to be called
5608 seems quite tricky to get to work. Changed -session to be called
5604 -logplay, which more accurately reflects what it does. And if we
5609 -logplay, which more accurately reflects what it does. And if we
5605 ever get real session saving working, -session is now available.
5610 ever get real session saving working, -session is now available.
5606
5611
5607 * Implemented color schemes for prompts also. As for tracebacks,
5612 * Implemented color schemes for prompts also. As for tracebacks,
5608 currently only NoColor and Linux are supported. But now the
5613 currently only NoColor and Linux are supported. But now the
5609 infrastructure is in place, based on a generic ColorScheme
5614 infrastructure is in place, based on a generic ColorScheme
5610 class. So writing and activating new schemes both for the prompts
5615 class. So writing and activating new schemes both for the prompts
5611 and the tracebacks should be straightforward.
5616 and the tracebacks should be straightforward.
5612
5617
5613 * Version 0.1.13 released, 0.1.14 opened.
5618 * Version 0.1.13 released, 0.1.14 opened.
5614
5619
5615 * Changed handling of options for output cache. Now counter is
5620 * Changed handling of options for output cache. Now counter is
5616 hardwired starting at 1 and one specifies the maximum number of
5621 hardwired starting at 1 and one specifies the maximum number of
5617 entries *in the outcache* (not the max prompt counter). This is
5622 entries *in the outcache* (not the max prompt counter). This is
5618 much better, since many statements won't increase the cache
5623 much better, since many statements won't increase the cache
5619 count. It also eliminated some confusing options, now there's only
5624 count. It also eliminated some confusing options, now there's only
5620 one: cache_size.
5625 one: cache_size.
5621
5626
5622 * Added 'alias' magic function and magic_alias option in the
5627 * Added 'alias' magic function and magic_alias option in the
5623 ipythonrc file. Now the user can easily define whatever names he
5628 ipythonrc file. Now the user can easily define whatever names he
5624 wants for the magic functions without having to play weird
5629 wants for the magic functions without having to play weird
5625 namespace games. This gives IPython a real shell-like feel.
5630 namespace games. This gives IPython a real shell-like feel.
5626
5631
5627 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
5632 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
5628 @ or not).
5633 @ or not).
5629
5634
5630 This was one of the last remaining 'visible' bugs (that I know
5635 This was one of the last remaining 'visible' bugs (that I know
5631 of). I think if I can clean up the session loading so it works
5636 of). I think if I can clean up the session loading so it works
5632 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
5637 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
5633 about licensing).
5638 about licensing).
5634
5639
5635 2001-11-25 Fernando Perez <fperez@colorado.edu>
5640 2001-11-25 Fernando Perez <fperez@colorado.edu>
5636
5641
5637 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
5642 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
5638 there's a cleaner distinction between what ? and ?? show.
5643 there's a cleaner distinction between what ? and ?? show.
5639
5644
5640 * Added screen_length option. Now the user can define his own
5645 * Added screen_length option. Now the user can define his own
5641 screen size for page() operations.
5646 screen size for page() operations.
5642
5647
5643 * Implemented magic shell-like functions with automatic code
5648 * Implemented magic shell-like functions with automatic code
5644 generation. Now adding another function is just a matter of adding
5649 generation. Now adding another function is just a matter of adding
5645 an entry to a dict, and the function is dynamically generated at
5650 an entry to a dict, and the function is dynamically generated at
5646 run-time. Python has some really cool features!
5651 run-time. Python has some really cool features!
5647
5652
5648 * Renamed many options to cleanup conventions a little. Now all
5653 * Renamed many options to cleanup conventions a little. Now all
5649 are lowercase, and only underscores where needed. Also in the code
5654 are lowercase, and only underscores where needed. Also in the code
5650 option name tables are clearer.
5655 option name tables are clearer.
5651
5656
5652 * Changed prompts a little. Now input is 'In [n]:' instead of
5657 * Changed prompts a little. Now input is 'In [n]:' instead of
5653 'In[n]:='. This allows it the numbers to be aligned with the
5658 'In[n]:='. This allows it the numbers to be aligned with the
5654 Out[n] numbers, and removes usage of ':=' which doesn't exist in
5659 Out[n] numbers, and removes usage of ':=' which doesn't exist in
5655 Python (it was a Mathematica thing). The '...' continuation prompt
5660 Python (it was a Mathematica thing). The '...' continuation prompt
5656 was also changed a little to align better.
5661 was also changed a little to align better.
5657
5662
5658 * Fixed bug when flushing output cache. Not all _p<n> variables
5663 * Fixed bug when flushing output cache. Not all _p<n> variables
5659 exist, so their deletion needs to be wrapped in a try:
5664 exist, so their deletion needs to be wrapped in a try:
5660
5665
5661 * Figured out how to properly use inspect.formatargspec() (it
5666 * Figured out how to properly use inspect.formatargspec() (it
5662 requires the args preceded by *). So I removed all the code from
5667 requires the args preceded by *). So I removed all the code from
5663 _get_pdef in Magic, which was just replicating that.
5668 _get_pdef in Magic, which was just replicating that.
5664
5669
5665 * Added test to prefilter to allow redefining magic function names
5670 * Added test to prefilter to allow redefining magic function names
5666 as variables. This is ok, since the @ form is always available,
5671 as variables. This is ok, since the @ form is always available,
5667 but whe should allow the user to define a variable called 'ls' if
5672 but whe should allow the user to define a variable called 'ls' if
5668 he needs it.
5673 he needs it.
5669
5674
5670 * Moved the ToDo information from README into a separate ToDo.
5675 * Moved the ToDo information from README into a separate ToDo.
5671
5676
5672 * General code cleanup and small bugfixes. I think it's close to a
5677 * General code cleanup and small bugfixes. I think it's close to a
5673 state where it can be released, obviously with a big 'beta'
5678 state where it can be released, obviously with a big 'beta'
5674 warning on it.
5679 warning on it.
5675
5680
5676 * Got the magic function split to work. Now all magics are defined
5681 * Got the magic function split to work. Now all magics are defined
5677 in a separate class. It just organizes things a bit, and now
5682 in a separate class. It just organizes things a bit, and now
5678 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
5683 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
5679 was too long).
5684 was too long).
5680
5685
5681 * Changed @clear to @reset to avoid potential confusions with
5686 * Changed @clear to @reset to avoid potential confusions with
5682 the shell command clear. Also renamed @cl to @clear, which does
5687 the shell command clear. Also renamed @cl to @clear, which does
5683 exactly what people expect it to from their shell experience.
5688 exactly what people expect it to from their shell experience.
5684
5689
5685 Added a check to the @reset command (since it's so
5690 Added a check to the @reset command (since it's so
5686 destructive, it's probably a good idea to ask for confirmation).
5691 destructive, it's probably a good idea to ask for confirmation).
5687 But now reset only works for full namespace resetting. Since the
5692 But now reset only works for full namespace resetting. Since the
5688 del keyword is already there for deleting a few specific
5693 del keyword is already there for deleting a few specific
5689 variables, I don't see the point of having a redundant magic
5694 variables, I don't see the point of having a redundant magic
5690 function for the same task.
5695 function for the same task.
5691
5696
5692 2001-11-24 Fernando Perez <fperez@colorado.edu>
5697 2001-11-24 Fernando Perez <fperez@colorado.edu>
5693
5698
5694 * Updated the builtin docs (esp. the ? ones).
5699 * Updated the builtin docs (esp. the ? ones).
5695
5700
5696 * Ran all the code through pychecker. Not terribly impressed with
5701 * Ran all the code through pychecker. Not terribly impressed with
5697 it: lots of spurious warnings and didn't really find anything of
5702 it: lots of spurious warnings and didn't really find anything of
5698 substance (just a few modules being imported and not used).
5703 substance (just a few modules being imported and not used).
5699
5704
5700 * Implemented the new ultraTB functionality into IPython. New
5705 * Implemented the new ultraTB functionality into IPython. New
5701 option: xcolors. This chooses color scheme. xmode now only selects
5706 option: xcolors. This chooses color scheme. xmode now only selects
5702 between Plain and Verbose. Better orthogonality.
5707 between Plain and Verbose. Better orthogonality.
5703
5708
5704 * Large rewrite of ultraTB. Much cleaner now, with a separation of
5709 * Large rewrite of ultraTB. Much cleaner now, with a separation of
5705 mode and color scheme for the exception handlers. Now it's
5710 mode and color scheme for the exception handlers. Now it's
5706 possible to have the verbose traceback with no coloring.
5711 possible to have the verbose traceback with no coloring.
5707
5712
5708 2001-11-23 Fernando Perez <fperez@colorado.edu>
5713 2001-11-23 Fernando Perez <fperez@colorado.edu>
5709
5714
5710 * Version 0.1.12 released, 0.1.13 opened.
5715 * Version 0.1.12 released, 0.1.13 opened.
5711
5716
5712 * Removed option to set auto-quote and auto-paren escapes by
5717 * Removed option to set auto-quote and auto-paren escapes by
5713 user. The chances of breaking valid syntax are just too high. If
5718 user. The chances of breaking valid syntax are just too high. If
5714 someone *really* wants, they can always dig into the code.
5719 someone *really* wants, they can always dig into the code.
5715
5720
5716 * Made prompt separators configurable.
5721 * Made prompt separators configurable.
5717
5722
5718 2001-11-22 Fernando Perez <fperez@colorado.edu>
5723 2001-11-22 Fernando Perez <fperez@colorado.edu>
5719
5724
5720 * Small bugfixes in many places.
5725 * Small bugfixes in many places.
5721
5726
5722 * Removed the MyCompleter class from ipplib. It seemed redundant
5727 * Removed the MyCompleter class from ipplib. It seemed redundant
5723 with the C-p,C-n history search functionality. Less code to
5728 with the C-p,C-n history search functionality. Less code to
5724 maintain.
5729 maintain.
5725
5730
5726 * Moved all the original ipython.py code into ipythonlib.py. Right
5731 * Moved all the original ipython.py code into ipythonlib.py. Right
5727 now it's just one big dump into a function called make_IPython, so
5732 now it's just one big dump into a function called make_IPython, so
5728 no real modularity has been gained. But at least it makes the
5733 no real modularity has been gained. But at least it makes the
5729 wrapper script tiny, and since ipythonlib is a module, it gets
5734 wrapper script tiny, and since ipythonlib is a module, it gets
5730 compiled and startup is much faster.
5735 compiled and startup is much faster.
5731
5736
5732 This is a reasobably 'deep' change, so we should test it for a
5737 This is a reasobably 'deep' change, so we should test it for a
5733 while without messing too much more with the code.
5738 while without messing too much more with the code.
5734
5739
5735 2001-11-21 Fernando Perez <fperez@colorado.edu>
5740 2001-11-21 Fernando Perez <fperez@colorado.edu>
5736
5741
5737 * Version 0.1.11 released, 0.1.12 opened for further work.
5742 * Version 0.1.11 released, 0.1.12 opened for further work.
5738
5743
5739 * Removed dependency on Itpl. It was only needed in one place. It
5744 * Removed dependency on Itpl. It was only needed in one place. It
5740 would be nice if this became part of python, though. It makes life
5745 would be nice if this became part of python, though. It makes life
5741 *a lot* easier in some cases.
5746 *a lot* easier in some cases.
5742
5747
5743 * Simplified the prefilter code a bit. Now all handlers are
5748 * Simplified the prefilter code a bit. Now all handlers are
5744 expected to explicitly return a value (at least a blank string).
5749 expected to explicitly return a value (at least a blank string).
5745
5750
5746 * Heavy edits in ipplib. Removed the help system altogether. Now
5751 * Heavy edits in ipplib. Removed the help system altogether. Now
5747 obj?/?? is used for inspecting objects, a magic @doc prints
5752 obj?/?? is used for inspecting objects, a magic @doc prints
5748 docstrings, and full-blown Python help is accessed via the 'help'
5753 docstrings, and full-blown Python help is accessed via the 'help'
5749 keyword. This cleans up a lot of code (less to maintain) and does
5754 keyword. This cleans up a lot of code (less to maintain) and does
5750 the job. Since 'help' is now a standard Python component, might as
5755 the job. Since 'help' is now a standard Python component, might as
5751 well use it and remove duplicate functionality.
5756 well use it and remove duplicate functionality.
5752
5757
5753 Also removed the option to use ipplib as a standalone program. By
5758 Also removed the option to use ipplib as a standalone program. By
5754 now it's too dependent on other parts of IPython to function alone.
5759 now it's too dependent on other parts of IPython to function alone.
5755
5760
5756 * Fixed bug in genutils.pager. It would crash if the pager was
5761 * Fixed bug in genutils.pager. It would crash if the pager was
5757 exited immediately after opening (broken pipe).
5762 exited immediately after opening (broken pipe).
5758
5763
5759 * Trimmed down the VerboseTB reporting a little. The header is
5764 * Trimmed down the VerboseTB reporting a little. The header is
5760 much shorter now and the repeated exception arguments at the end
5765 much shorter now and the repeated exception arguments at the end
5761 have been removed. For interactive use the old header seemed a bit
5766 have been removed. For interactive use the old header seemed a bit
5762 excessive.
5767 excessive.
5763
5768
5764 * Fixed small bug in output of @whos for variables with multi-word
5769 * Fixed small bug in output of @whos for variables with multi-word
5765 types (only first word was displayed).
5770 types (only first word was displayed).
5766
5771
5767 2001-11-17 Fernando Perez <fperez@colorado.edu>
5772 2001-11-17 Fernando Perez <fperez@colorado.edu>
5768
5773
5769 * Version 0.1.10 released, 0.1.11 opened for further work.
5774 * Version 0.1.10 released, 0.1.11 opened for further work.
5770
5775
5771 * Modified dirs and friends. dirs now *returns* the stack (not
5776 * Modified dirs and friends. dirs now *returns* the stack (not
5772 prints), so one can manipulate it as a variable. Convenient to
5777 prints), so one can manipulate it as a variable. Convenient to
5773 travel along many directories.
5778 travel along many directories.
5774
5779
5775 * Fixed bug in magic_pdef: would only work with functions with
5780 * Fixed bug in magic_pdef: would only work with functions with
5776 arguments with default values.
5781 arguments with default values.
5777
5782
5778 2001-11-14 Fernando Perez <fperez@colorado.edu>
5783 2001-11-14 Fernando Perez <fperez@colorado.edu>
5779
5784
5780 * Added the PhysicsInput stuff to dot_ipython so it ships as an
5785 * Added the PhysicsInput stuff to dot_ipython so it ships as an
5781 example with IPython. Various other minor fixes and cleanups.
5786 example with IPython. Various other minor fixes and cleanups.
5782
5787
5783 * Version 0.1.9 released, 0.1.10 opened for further work.
5788 * Version 0.1.9 released, 0.1.10 opened for further work.
5784
5789
5785 * Added sys.path to the list of directories searched in the
5790 * Added sys.path to the list of directories searched in the
5786 execfile= option. It used to be the current directory and the
5791 execfile= option. It used to be the current directory and the
5787 user's IPYTHONDIR only.
5792 user's IPYTHONDIR only.
5788
5793
5789 2001-11-13 Fernando Perez <fperez@colorado.edu>
5794 2001-11-13 Fernando Perez <fperez@colorado.edu>
5790
5795
5791 * Reinstated the raw_input/prefilter separation that Janko had
5796 * Reinstated the raw_input/prefilter separation that Janko had
5792 initially. This gives a more convenient setup for extending the
5797 initially. This gives a more convenient setup for extending the
5793 pre-processor from the outside: raw_input always gets a string,
5798 pre-processor from the outside: raw_input always gets a string,
5794 and prefilter has to process it. We can then redefine prefilter
5799 and prefilter has to process it. We can then redefine prefilter
5795 from the outside and implement extensions for special
5800 from the outside and implement extensions for special
5796 purposes.
5801 purposes.
5797
5802
5798 Today I got one for inputting PhysicalQuantity objects
5803 Today I got one for inputting PhysicalQuantity objects
5799 (from Scientific) without needing any function calls at
5804 (from Scientific) without needing any function calls at
5800 all. Extremely convenient, and it's all done as a user-level
5805 all. Extremely convenient, and it's all done as a user-level
5801 extension (no IPython code was touched). Now instead of:
5806 extension (no IPython code was touched). Now instead of:
5802 a = PhysicalQuantity(4.2,'m/s**2')
5807 a = PhysicalQuantity(4.2,'m/s**2')
5803 one can simply say
5808 one can simply say
5804 a = 4.2 m/s**2
5809 a = 4.2 m/s**2
5805 or even
5810 or even
5806 a = 4.2 m/s^2
5811 a = 4.2 m/s^2
5807
5812
5808 I use this, but it's also a proof of concept: IPython really is
5813 I use this, but it's also a proof of concept: IPython really is
5809 fully user-extensible, even at the level of the parsing of the
5814 fully user-extensible, even at the level of the parsing of the
5810 command line. It's not trivial, but it's perfectly doable.
5815 command line. It's not trivial, but it's perfectly doable.
5811
5816
5812 * Added 'add_flip' method to inclusion conflict resolver. Fixes
5817 * Added 'add_flip' method to inclusion conflict resolver. Fixes
5813 the problem of modules being loaded in the inverse order in which
5818 the problem of modules being loaded in the inverse order in which
5814 they were defined in
5819 they were defined in
5815
5820
5816 * Version 0.1.8 released, 0.1.9 opened for further work.
5821 * Version 0.1.8 released, 0.1.9 opened for further work.
5817
5822
5818 * Added magics pdef, source and file. They respectively show the
5823 * Added magics pdef, source and file. They respectively show the
5819 definition line ('prototype' in C), source code and full python
5824 definition line ('prototype' in C), source code and full python
5820 file for any callable object. The object inspector oinfo uses
5825 file for any callable object. The object inspector oinfo uses
5821 these to show the same information.
5826 these to show the same information.
5822
5827
5823 * Version 0.1.7 released, 0.1.8 opened for further work.
5828 * Version 0.1.7 released, 0.1.8 opened for further work.
5824
5829
5825 * Separated all the magic functions into a class called Magic. The
5830 * Separated all the magic functions into a class called Magic. The
5826 InteractiveShell class was becoming too big for Xemacs to handle
5831 InteractiveShell class was becoming too big for Xemacs to handle
5827 (de-indenting a line would lock it up for 10 seconds while it
5832 (de-indenting a line would lock it up for 10 seconds while it
5828 backtracked on the whole class!)
5833 backtracked on the whole class!)
5829
5834
5830 FIXME: didn't work. It can be done, but right now namespaces are
5835 FIXME: didn't work. It can be done, but right now namespaces are
5831 all messed up. Do it later (reverted it for now, so at least
5836 all messed up. Do it later (reverted it for now, so at least
5832 everything works as before).
5837 everything works as before).
5833
5838
5834 * Got the object introspection system (magic_oinfo) working! I
5839 * Got the object introspection system (magic_oinfo) working! I
5835 think this is pretty much ready for release to Janko, so he can
5840 think this is pretty much ready for release to Janko, so he can
5836 test it for a while and then announce it. Pretty much 100% of what
5841 test it for a while and then announce it. Pretty much 100% of what
5837 I wanted for the 'phase 1' release is ready. Happy, tired.
5842 I wanted for the 'phase 1' release is ready. Happy, tired.
5838
5843
5839 2001-11-12 Fernando Perez <fperez@colorado.edu>
5844 2001-11-12 Fernando Perez <fperez@colorado.edu>
5840
5845
5841 * Version 0.1.6 released, 0.1.7 opened for further work.
5846 * Version 0.1.6 released, 0.1.7 opened for further work.
5842
5847
5843 * Fixed bug in printing: it used to test for truth before
5848 * Fixed bug in printing: it used to test for truth before
5844 printing, so 0 wouldn't print. Now checks for None.
5849 printing, so 0 wouldn't print. Now checks for None.
5845
5850
5846 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
5851 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
5847 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
5852 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
5848 reaches by hand into the outputcache. Think of a better way to do
5853 reaches by hand into the outputcache. Think of a better way to do
5849 this later.
5854 this later.
5850
5855
5851 * Various small fixes thanks to Nathan's comments.
5856 * Various small fixes thanks to Nathan's comments.
5852
5857
5853 * Changed magic_pprint to magic_Pprint. This way it doesn't
5858 * Changed magic_pprint to magic_Pprint. This way it doesn't
5854 collide with pprint() and the name is consistent with the command
5859 collide with pprint() and the name is consistent with the command
5855 line option.
5860 line option.
5856
5861
5857 * Changed prompt counter behavior to be fully like
5862 * Changed prompt counter behavior to be fully like
5858 Mathematica's. That is, even input that doesn't return a result
5863 Mathematica's. That is, even input that doesn't return a result
5859 raises the prompt counter. The old behavior was kind of confusing
5864 raises the prompt counter. The old behavior was kind of confusing
5860 (getting the same prompt number several times if the operation
5865 (getting the same prompt number several times if the operation
5861 didn't return a result).
5866 didn't return a result).
5862
5867
5863 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
5868 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
5864
5869
5865 * Fixed -Classic mode (wasn't working anymore).
5870 * Fixed -Classic mode (wasn't working anymore).
5866
5871
5867 * Added colored prompts using Nathan's new code. Colors are
5872 * Added colored prompts using Nathan's new code. Colors are
5868 currently hardwired, they can be user-configurable. For
5873 currently hardwired, they can be user-configurable. For
5869 developers, they can be chosen in file ipythonlib.py, at the
5874 developers, they can be chosen in file ipythonlib.py, at the
5870 beginning of the CachedOutput class def.
5875 beginning of the CachedOutput class def.
5871
5876
5872 2001-11-11 Fernando Perez <fperez@colorado.edu>
5877 2001-11-11 Fernando Perez <fperez@colorado.edu>
5873
5878
5874 * Version 0.1.5 released, 0.1.6 opened for further work.
5879 * Version 0.1.5 released, 0.1.6 opened for further work.
5875
5880
5876 * Changed magic_env to *return* the environment as a dict (not to
5881 * Changed magic_env to *return* the environment as a dict (not to
5877 print it). This way it prints, but it can also be processed.
5882 print it). This way it prints, but it can also be processed.
5878
5883
5879 * Added Verbose exception reporting to interactive
5884 * Added Verbose exception reporting to interactive
5880 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
5885 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
5881 traceback. Had to make some changes to the ultraTB file. This is
5886 traceback. Had to make some changes to the ultraTB file. This is
5882 probably the last 'big' thing in my mental todo list. This ties
5887 probably the last 'big' thing in my mental todo list. This ties
5883 in with the next entry:
5888 in with the next entry:
5884
5889
5885 * Changed -Xi and -Xf to a single -xmode option. Now all the user
5890 * Changed -Xi and -Xf to a single -xmode option. Now all the user
5886 has to specify is Plain, Color or Verbose for all exception
5891 has to specify is Plain, Color or Verbose for all exception
5887 handling.
5892 handling.
5888
5893
5889 * Removed ShellServices option. All this can really be done via
5894 * Removed ShellServices option. All this can really be done via
5890 the magic system. It's easier to extend, cleaner and has automatic
5895 the magic system. It's easier to extend, cleaner and has automatic
5891 namespace protection and documentation.
5896 namespace protection and documentation.
5892
5897
5893 2001-11-09 Fernando Perez <fperez@colorado.edu>
5898 2001-11-09 Fernando Perez <fperez@colorado.edu>
5894
5899
5895 * Fixed bug in output cache flushing (missing parameter to
5900 * Fixed bug in output cache flushing (missing parameter to
5896 __init__). Other small bugs fixed (found using pychecker).
5901 __init__). Other small bugs fixed (found using pychecker).
5897
5902
5898 * Version 0.1.4 opened for bugfixing.
5903 * Version 0.1.4 opened for bugfixing.
5899
5904
5900 2001-11-07 Fernando Perez <fperez@colorado.edu>
5905 2001-11-07 Fernando Perez <fperez@colorado.edu>
5901
5906
5902 * Version 0.1.3 released, mainly because of the raw_input bug.
5907 * Version 0.1.3 released, mainly because of the raw_input bug.
5903
5908
5904 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
5909 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
5905 and when testing for whether things were callable, a call could
5910 and when testing for whether things were callable, a call could
5906 actually be made to certain functions. They would get called again
5911 actually be made to certain functions. They would get called again
5907 once 'really' executed, with a resulting double call. A disaster
5912 once 'really' executed, with a resulting double call. A disaster
5908 in many cases (list.reverse() would never work!).
5913 in many cases (list.reverse() would never work!).
5909
5914
5910 * Removed prefilter() function, moved its code to raw_input (which
5915 * Removed prefilter() function, moved its code to raw_input (which
5911 after all was just a near-empty caller for prefilter). This saves
5916 after all was just a near-empty caller for prefilter). This saves
5912 a function call on every prompt, and simplifies the class a tiny bit.
5917 a function call on every prompt, and simplifies the class a tiny bit.
5913
5918
5914 * Fix _ip to __ip name in magic example file.
5919 * Fix _ip to __ip name in magic example file.
5915
5920
5916 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
5921 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
5917 work with non-gnu versions of tar.
5922 work with non-gnu versions of tar.
5918
5923
5919 2001-11-06 Fernando Perez <fperez@colorado.edu>
5924 2001-11-06 Fernando Perez <fperez@colorado.edu>
5920
5925
5921 * Version 0.1.2. Just to keep track of the recent changes.
5926 * Version 0.1.2. Just to keep track of the recent changes.
5922
5927
5923 * Fixed nasty bug in output prompt routine. It used to check 'if
5928 * Fixed nasty bug in output prompt routine. It used to check 'if
5924 arg != None...'. Problem is, this fails if arg implements a
5929 arg != None...'. Problem is, this fails if arg implements a
5925 special comparison (__cmp__) which disallows comparing to
5930 special comparison (__cmp__) which disallows comparing to
5926 None. Found it when trying to use the PhysicalQuantity module from
5931 None. Found it when trying to use the PhysicalQuantity module from
5927 ScientificPython.
5932 ScientificPython.
5928
5933
5929 2001-11-05 Fernando Perez <fperez@colorado.edu>
5934 2001-11-05 Fernando Perez <fperez@colorado.edu>
5930
5935
5931 * Also added dirs. Now the pushd/popd/dirs family functions
5936 * Also added dirs. Now the pushd/popd/dirs family functions
5932 basically like the shell, with the added convenience of going home
5937 basically like the shell, with the added convenience of going home
5933 when called with no args.
5938 when called with no args.
5934
5939
5935 * pushd/popd slightly modified to mimic shell behavior more
5940 * pushd/popd slightly modified to mimic shell behavior more
5936 closely.
5941 closely.
5937
5942
5938 * Added env,pushd,popd from ShellServices as magic functions. I
5943 * Added env,pushd,popd from ShellServices as magic functions. I
5939 think the cleanest will be to port all desired functions from
5944 think the cleanest will be to port all desired functions from
5940 ShellServices as magics and remove ShellServices altogether. This
5945 ShellServices as magics and remove ShellServices altogether. This
5941 will provide a single, clean way of adding functionality
5946 will provide a single, clean way of adding functionality
5942 (shell-type or otherwise) to IP.
5947 (shell-type or otherwise) to IP.
5943
5948
5944 2001-11-04 Fernando Perez <fperez@colorado.edu>
5949 2001-11-04 Fernando Perez <fperez@colorado.edu>
5945
5950
5946 * Added .ipython/ directory to sys.path. This way users can keep
5951 * Added .ipython/ directory to sys.path. This way users can keep
5947 customizations there and access them via import.
5952 customizations there and access them via import.
5948
5953
5949 2001-11-03 Fernando Perez <fperez@colorado.edu>
5954 2001-11-03 Fernando Perez <fperez@colorado.edu>
5950
5955
5951 * Opened version 0.1.1 for new changes.
5956 * Opened version 0.1.1 for new changes.
5952
5957
5953 * Changed version number to 0.1.0: first 'public' release, sent to
5958 * Changed version number to 0.1.0: first 'public' release, sent to
5954 Nathan and Janko.
5959 Nathan and Janko.
5955
5960
5956 * Lots of small fixes and tweaks.
5961 * Lots of small fixes and tweaks.
5957
5962
5958 * Minor changes to whos format. Now strings are shown, snipped if
5963 * Minor changes to whos format. Now strings are shown, snipped if
5959 too long.
5964 too long.
5960
5965
5961 * Changed ShellServices to work on __main__ so they show up in @who
5966 * Changed ShellServices to work on __main__ so they show up in @who
5962
5967
5963 * Help also works with ? at the end of a line:
5968 * Help also works with ? at the end of a line:
5964 ?sin and sin?
5969 ?sin and sin?
5965 both produce the same effect. This is nice, as often I use the
5970 both produce the same effect. This is nice, as often I use the
5966 tab-complete to find the name of a method, but I used to then have
5971 tab-complete to find the name of a method, but I used to then have
5967 to go to the beginning of the line to put a ? if I wanted more
5972 to go to the beginning of the line to put a ? if I wanted more
5968 info. Now I can just add the ? and hit return. Convenient.
5973 info. Now I can just add the ? and hit return. Convenient.
5969
5974
5970 2001-11-02 Fernando Perez <fperez@colorado.edu>
5975 2001-11-02 Fernando Perez <fperez@colorado.edu>
5971
5976
5972 * Python version check (>=2.1) added.
5977 * Python version check (>=2.1) added.
5973
5978
5974 * Added LazyPython documentation. At this point the docs are quite
5979 * Added LazyPython documentation. At this point the docs are quite
5975 a mess. A cleanup is in order.
5980 a mess. A cleanup is in order.
5976
5981
5977 * Auto-installer created. For some bizarre reason, the zipfiles
5982 * Auto-installer created. For some bizarre reason, the zipfiles
5978 module isn't working on my system. So I made a tar version
5983 module isn't working on my system. So I made a tar version
5979 (hopefully the command line options in various systems won't kill
5984 (hopefully the command line options in various systems won't kill
5980 me).
5985 me).
5981
5986
5982 * Fixes to Struct in genutils. Now all dictionary-like methods are
5987 * Fixes to Struct in genutils. Now all dictionary-like methods are
5983 protected (reasonably).
5988 protected (reasonably).
5984
5989
5985 * Added pager function to genutils and changed ? to print usage
5990 * Added pager function to genutils and changed ? to print usage
5986 note through it (it was too long).
5991 note through it (it was too long).
5987
5992
5988 * Added the LazyPython functionality. Works great! I changed the
5993 * Added the LazyPython functionality. Works great! I changed the
5989 auto-quote escape to ';', it's on home row and next to '. But
5994 auto-quote escape to ';', it's on home row and next to '. But
5990 both auto-quote and auto-paren (still /) escapes are command-line
5995 both auto-quote and auto-paren (still /) escapes are command-line
5991 parameters.
5996 parameters.
5992
5997
5993
5998
5994 2001-11-01 Fernando Perez <fperez@colorado.edu>
5999 2001-11-01 Fernando Perez <fperez@colorado.edu>
5995
6000
5996 * Version changed to 0.0.7. Fairly large change: configuration now
6001 * Version changed to 0.0.7. Fairly large change: configuration now
5997 is all stored in a directory, by default .ipython. There, all
6002 is all stored in a directory, by default .ipython. There, all
5998 config files have normal looking names (not .names)
6003 config files have normal looking names (not .names)
5999
6004
6000 * Version 0.0.6 Released first to Lucas and Archie as a test
6005 * Version 0.0.6 Released first to Lucas and Archie as a test
6001 run. Since it's the first 'semi-public' release, change version to
6006 run. Since it's the first 'semi-public' release, change version to
6002 > 0.0.6 for any changes now.
6007 > 0.0.6 for any changes now.
6003
6008
6004 * Stuff I had put in the ipplib.py changelog:
6009 * Stuff I had put in the ipplib.py changelog:
6005
6010
6006 Changes to InteractiveShell:
6011 Changes to InteractiveShell:
6007
6012
6008 - Made the usage message a parameter.
6013 - Made the usage message a parameter.
6009
6014
6010 - Require the name of the shell variable to be given. It's a bit
6015 - Require the name of the shell variable to be given. It's a bit
6011 of a hack, but allows the name 'shell' not to be hardwired in the
6016 of a hack, but allows the name 'shell' not to be hardwired in the
6012 magic (@) handler, which is problematic b/c it requires
6017 magic (@) handler, which is problematic b/c it requires
6013 polluting the global namespace with 'shell'. This in turn is
6018 polluting the global namespace with 'shell'. This in turn is
6014 fragile: if a user redefines a variable called shell, things
6019 fragile: if a user redefines a variable called shell, things
6015 break.
6020 break.
6016
6021
6017 - magic @: all functions available through @ need to be defined
6022 - magic @: all functions available through @ need to be defined
6018 as magic_<name>, even though they can be called simply as
6023 as magic_<name>, even though they can be called simply as
6019 @<name>. This allows the special command @magic to gather
6024 @<name>. This allows the special command @magic to gather
6020 information automatically about all existing magic functions,
6025 information automatically about all existing magic functions,
6021 even if they are run-time user extensions, by parsing the shell
6026 even if they are run-time user extensions, by parsing the shell
6022 instance __dict__ looking for special magic_ names.
6027 instance __dict__ looking for special magic_ names.
6023
6028
6024 - mainloop: added *two* local namespace parameters. This allows
6029 - mainloop: added *two* local namespace parameters. This allows
6025 the class to differentiate between parameters which were there
6030 the class to differentiate between parameters which were there
6026 before and after command line initialization was processed. This
6031 before and after command line initialization was processed. This
6027 way, later @who can show things loaded at startup by the
6032 way, later @who can show things loaded at startup by the
6028 user. This trick was necessary to make session saving/reloading
6033 user. This trick was necessary to make session saving/reloading
6029 really work: ideally after saving/exiting/reloading a session,
6034 really work: ideally after saving/exiting/reloading a session,
6030 *everything* should look the same, including the output of @who. I
6035 *everything* should look the same, including the output of @who. I
6031 was only able to make this work with this double namespace
6036 was only able to make this work with this double namespace
6032 trick.
6037 trick.
6033
6038
6034 - added a header to the logfile which allows (almost) full
6039 - added a header to the logfile which allows (almost) full
6035 session restoring.
6040 session restoring.
6036
6041
6037 - prepend lines beginning with @ or !, with a and log
6042 - prepend lines beginning with @ or !, with a and log
6038 them. Why? !lines: may be useful to know what you did @lines:
6043 them. Why? !lines: may be useful to know what you did @lines:
6039 they may affect session state. So when restoring a session, at
6044 they may affect session state. So when restoring a session, at
6040 least inform the user of their presence. I couldn't quite get
6045 least inform the user of their presence. I couldn't quite get
6041 them to properly re-execute, but at least the user is warned.
6046 them to properly re-execute, but at least the user is warned.
6042
6047
6043 * Started ChangeLog.
6048 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now