##// END OF EJS Templates
Fix for unicode support, python identifiers can only be ascii so we need to...
fperez -
Show More
@@ -1,3096 +1,3101 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 2153 2007-03-18 22:53:18Z fperez $"""
4 $Id: Magic.py 2187 2007-03-30 04:56:40Z fperez $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
8 # Copyright (C) 2001-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 #print 'oname_rest:', oname_rest # dbg
213 #print 'oname_rest:', oname_rest # dbg
214 for part in oname_rest:
214 for part in oname_rest:
215 try:
215 try:
216 parent = obj
216 parent = obj
217 obj = getattr(obj,part)
217 obj = getattr(obj,part)
218 except:
218 except:
219 # Blanket except b/c some badly implemented objects
219 # Blanket except b/c some badly implemented objects
220 # allow __getattr__ to raise exceptions other than
220 # allow __getattr__ to raise exceptions other than
221 # AttributeError, which then crashes IPython.
221 # AttributeError, which then crashes IPython.
222 break
222 break
223 else:
223 else:
224 # If we finish the for loop (no break), we got all members
224 # If we finish the for loop (no break), we got all members
225 found = 1
225 found = 1
226 ospace = nsname
226 ospace = nsname
227 if ns == alias_ns:
227 if ns == alias_ns:
228 isalias = 1
228 isalias = 1
229 break # namespace loop
229 break # namespace loop
230
230
231 # Try to see if it's magic
231 # Try to see if it's magic
232 if not found:
232 if not found:
233 if oname.startswith(self.shell.ESC_MAGIC):
233 if oname.startswith(self.shell.ESC_MAGIC):
234 oname = oname[1:]
234 oname = oname[1:]
235 obj = getattr(self,'magic_'+oname,None)
235 obj = getattr(self,'magic_'+oname,None)
236 if obj is not None:
236 if obj is not None:
237 found = 1
237 found = 1
238 ospace = 'IPython internal'
238 ospace = 'IPython internal'
239 ismagic = 1
239 ismagic = 1
240
240
241 # Last try: special-case some literals like '', [], {}, etc:
241 # Last try: special-case some literals like '', [], {}, etc:
242 if not found and oname_head in ["''",'""','[]','{}','()']:
242 if not found and oname_head in ["''",'""','[]','{}','()']:
243 obj = eval(oname_head)
243 obj = eval(oname_head)
244 found = 1
244 found = 1
245 ospace = 'Interactive'
245 ospace = 'Interactive'
246
246
247 return {'found':found, 'obj':obj, 'namespace':ospace,
247 return {'found':found, 'obj':obj, 'namespace':ospace,
248 'ismagic':ismagic, 'isalias':isalias, 'parent':parent}
248 'ismagic':ismagic, 'isalias':isalias, 'parent':parent}
249
249
250 def arg_err(self,func):
250 def arg_err(self,func):
251 """Print docstring if incorrect arguments were passed"""
251 """Print docstring if incorrect arguments were passed"""
252 print 'Error in arguments:'
252 print 'Error in arguments:'
253 print OInspect.getdoc(func)
253 print OInspect.getdoc(func)
254
254
255 def format_latex(self,strng):
255 def format_latex(self,strng):
256 """Format a string for latex inclusion."""
256 """Format a string for latex inclusion."""
257
257
258 # Characters that need to be escaped for latex:
258 # Characters that need to be escaped for latex:
259 escape_re = re.compile(r'(%|_|\$|#|&)',re.MULTILINE)
259 escape_re = re.compile(r'(%|_|\$|#|&)',re.MULTILINE)
260 # Magic command names as headers:
260 # Magic command names as headers:
261 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
261 cmd_name_re = re.compile(r'^(%s.*?):' % self.shell.ESC_MAGIC,
262 re.MULTILINE)
262 re.MULTILINE)
263 # Magic commands
263 # Magic commands
264 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
264 cmd_re = re.compile(r'(?P<cmd>%s.+?\b)(?!\}\}:)' % self.shell.ESC_MAGIC,
265 re.MULTILINE)
265 re.MULTILINE)
266 # Paragraph continue
266 # Paragraph continue
267 par_re = re.compile(r'\\$',re.MULTILINE)
267 par_re = re.compile(r'\\$',re.MULTILINE)
268
268
269 # The "\n" symbol
269 # The "\n" symbol
270 newline_re = re.compile(r'\\n')
270 newline_re = re.compile(r'\\n')
271
271
272 # Now build the string for output:
272 # Now build the string for output:
273 #strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng)
273 #strng = cmd_name_re.sub(r'\n\\texttt{\\textsl{\\large \1}}:',strng)
274 strng = cmd_name_re.sub(r'\n\\bigskip\n\\texttt{\\textbf{ \1}}:',
274 strng = cmd_name_re.sub(r'\n\\bigskip\n\\texttt{\\textbf{ \1}}:',
275 strng)
275 strng)
276 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
276 strng = cmd_re.sub(r'\\texttt{\g<cmd>}',strng)
277 strng = par_re.sub(r'\\\\',strng)
277 strng = par_re.sub(r'\\\\',strng)
278 strng = escape_re.sub(r'\\\1',strng)
278 strng = escape_re.sub(r'\\\1',strng)
279 strng = newline_re.sub(r'\\textbackslash{}n',strng)
279 strng = newline_re.sub(r'\\textbackslash{}n',strng)
280 return strng
280 return strng
281
281
282 def format_screen(self,strng):
282 def format_screen(self,strng):
283 """Format a string for screen printing.
283 """Format a string for screen printing.
284
284
285 This removes some latex-type format codes."""
285 This removes some latex-type format codes."""
286 # Paragraph continue
286 # Paragraph continue
287 par_re = re.compile(r'\\$',re.MULTILINE)
287 par_re = re.compile(r'\\$',re.MULTILINE)
288 strng = par_re.sub('',strng)
288 strng = par_re.sub('',strng)
289 return strng
289 return strng
290
290
291 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
291 def parse_options(self,arg_str,opt_str,*long_opts,**kw):
292 """Parse options passed to an argument string.
292 """Parse options passed to an argument string.
293
293
294 The interface is similar to that of getopt(), but it returns back a
294 The interface is similar to that of getopt(), but it returns back a
295 Struct with the options as keys and the stripped argument string still
295 Struct with the options as keys and the stripped argument string still
296 as a string.
296 as a string.
297
297
298 arg_str is quoted as a true sys.argv vector by using shlex.split.
298 arg_str is quoted as a true sys.argv vector by using shlex.split.
299 This allows us to easily expand variables, glob files, quote
299 This allows us to easily expand variables, glob files, quote
300 arguments, etc.
300 arguments, etc.
301
301
302 Options:
302 Options:
303 -mode: default 'string'. If given as 'list', the argument string is
303 -mode: default 'string'. If given as 'list', the argument string is
304 returned as a list (split on whitespace) instead of a string.
304 returned as a list (split on whitespace) instead of a string.
305
305
306 -list_all: put all option values in lists. Normally only options
306 -list_all: put all option values in lists. Normally only options
307 appearing more than once are put in a list.
307 appearing more than once are put in a list.
308
308
309 -posix (True): whether to split the input line in POSIX mode or not,
309 -posix (True): whether to split the input line in POSIX mode or not,
310 as per the conventions outlined in the shlex module from the
310 as per the conventions outlined in the shlex module from the
311 standard library."""
311 standard library."""
312
312
313 # inject default options at the beginning of the input line
313 # inject default options at the beginning of the input line
314 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
314 caller = sys._getframe(1).f_code.co_name.replace('magic_','')
315 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
315 arg_str = '%s %s' % (self.options_table.get(caller,''),arg_str)
316
316
317 mode = kw.get('mode','string')
317 mode = kw.get('mode','string')
318 if mode not in ['string','list']:
318 if mode not in ['string','list']:
319 raise ValueError,'incorrect mode given: %s' % mode
319 raise ValueError,'incorrect mode given: %s' % mode
320 # Get options
320 # Get options
321 list_all = kw.get('list_all',0)
321 list_all = kw.get('list_all',0)
322 posix = kw.get('posix',True)
322 posix = kw.get('posix',True)
323
323
324 # Check if we have more than one argument to warrant extra processing:
324 # Check if we have more than one argument to warrant extra processing:
325 odict = {} # Dictionary with options
325 odict = {} # Dictionary with options
326 args = arg_str.split()
326 args = arg_str.split()
327 if len(args) >= 1:
327 if len(args) >= 1:
328 # If the list of inputs only has 0 or 1 thing in it, there's no
328 # If the list of inputs only has 0 or 1 thing in it, there's no
329 # need to look for options
329 # need to look for options
330 argv = arg_split(arg_str,posix)
330 argv = arg_split(arg_str,posix)
331 # Do regular option processing
331 # Do regular option processing
332 try:
332 try:
333 opts,args = getopt(argv,opt_str,*long_opts)
333 opts,args = getopt(argv,opt_str,*long_opts)
334 except GetoptError,e:
334 except GetoptError,e:
335 raise GetoptError('%s ( allowed: "%s" %s)' % (e.msg,opt_str,
335 raise GetoptError('%s ( allowed: "%s" %s)' % (e.msg,opt_str,
336 " ".join(long_opts)))
336 " ".join(long_opts)))
337 for o,a in opts:
337 for o,a in opts:
338 if o.startswith('--'):
338 if o.startswith('--'):
339 o = o[2:]
339 o = o[2:]
340 else:
340 else:
341 o = o[1:]
341 o = o[1:]
342 try:
342 try:
343 odict[o].append(a)
343 odict[o].append(a)
344 except AttributeError:
344 except AttributeError:
345 odict[o] = [odict[o],a]
345 odict[o] = [odict[o],a]
346 except KeyError:
346 except KeyError:
347 if list_all:
347 if list_all:
348 odict[o] = [a]
348 odict[o] = [a]
349 else:
349 else:
350 odict[o] = a
350 odict[o] = a
351
351
352 # Prepare opts,args for return
352 # Prepare opts,args for return
353 opts = Struct(odict)
353 opts = Struct(odict)
354 if mode == 'string':
354 if mode == 'string':
355 args = ' '.join(args)
355 args = ' '.join(args)
356
356
357 return opts,args
357 return opts,args
358
358
359 #......................................................................
359 #......................................................................
360 # And now the actual magic functions
360 # And now the actual magic functions
361
361
362 # Functions for IPython shell work (vars,funcs, config, etc)
362 # Functions for IPython shell work (vars,funcs, config, etc)
363 def magic_lsmagic(self, parameter_s = ''):
363 def magic_lsmagic(self, parameter_s = ''):
364 """List currently available magic functions."""
364 """List currently available magic functions."""
365 mesc = self.shell.ESC_MAGIC
365 mesc = self.shell.ESC_MAGIC
366 print 'Available magic functions:\n'+mesc+\
366 print 'Available magic functions:\n'+mesc+\
367 (' '+mesc).join(self.lsmagic())
367 (' '+mesc).join(self.lsmagic())
368 print '\n' + Magic.auto_status[self.shell.rc.automagic]
368 print '\n' + Magic.auto_status[self.shell.rc.automagic]
369 return None
369 return None
370
370
371 def magic_magic(self, parameter_s = ''):
371 def magic_magic(self, parameter_s = ''):
372 """Print information about the magic function system."""
372 """Print information about the magic function system."""
373
373
374 mode = ''
374 mode = ''
375 try:
375 try:
376 if parameter_s.split()[0] == '-latex':
376 if parameter_s.split()[0] == '-latex':
377 mode = 'latex'
377 mode = 'latex'
378 if parameter_s.split()[0] == '-brief':
378 if parameter_s.split()[0] == '-brief':
379 mode = 'brief'
379 mode = 'brief'
380 except:
380 except:
381 pass
381 pass
382
382
383 magic_docs = []
383 magic_docs = []
384 for fname in self.lsmagic():
384 for fname in self.lsmagic():
385 mname = 'magic_' + fname
385 mname = 'magic_' + fname
386 for space in (Magic,self,self.__class__):
386 for space in (Magic,self,self.__class__):
387 try:
387 try:
388 fn = space.__dict__[mname]
388 fn = space.__dict__[mname]
389 except KeyError:
389 except KeyError:
390 pass
390 pass
391 else:
391 else:
392 break
392 break
393 if mode == 'brief':
393 if mode == 'brief':
394 # only first line
394 # only first line
395 fndoc = fn.__doc__.split('\n',1)[0]
395 fndoc = fn.__doc__.split('\n',1)[0]
396 else:
396 else:
397 fndoc = fn.__doc__
397 fndoc = fn.__doc__
398
398
399 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
399 magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC,
400 fname,fndoc))
400 fname,fndoc))
401 magic_docs = ''.join(magic_docs)
401 magic_docs = ''.join(magic_docs)
402
402
403 if mode == 'latex':
403 if mode == 'latex':
404 print self.format_latex(magic_docs)
404 print self.format_latex(magic_docs)
405 return
405 return
406 else:
406 else:
407 magic_docs = self.format_screen(magic_docs)
407 magic_docs = self.format_screen(magic_docs)
408 if mode == 'brief':
408 if mode == 'brief':
409 return magic_docs
409 return magic_docs
410
410
411 outmsg = """
411 outmsg = """
412 IPython's 'magic' functions
412 IPython's 'magic' functions
413 ===========================
413 ===========================
414
414
415 The magic function system provides a series of functions which allow you to
415 The magic function system provides a series of functions which allow you to
416 control the behavior of IPython itself, plus a lot of system-type
416 control the behavior of IPython itself, plus a lot of system-type
417 features. All these functions are prefixed with a % character, but parameters
417 features. All these functions are prefixed with a % character, but parameters
418 are given without parentheses or quotes.
418 are given without parentheses or quotes.
419
419
420 NOTE: If you have 'automagic' enabled (via the command line option or with the
420 NOTE: If you have 'automagic' enabled (via the command line option or with the
421 %automagic function), you don't need to type in the % explicitly. By default,
421 %automagic function), you don't need to type in the % explicitly. By default,
422 IPython ships with automagic on, so you should only rarely need the % escape.
422 IPython ships with automagic on, so you should only rarely need the % escape.
423
423
424 Example: typing '%cd mydir' (without the quotes) changes you working directory
424 Example: typing '%cd mydir' (without the quotes) changes you working directory
425 to 'mydir', if it exists.
425 to 'mydir', if it exists.
426
426
427 You can define your own magic functions to extend the system. See the supplied
427 You can define your own magic functions to extend the system. See the supplied
428 ipythonrc and example-magic.py files for details (in your ipython
428 ipythonrc and example-magic.py files for details (in your ipython
429 configuration directory, typically $HOME/.ipython/).
429 configuration directory, typically $HOME/.ipython/).
430
430
431 You can also define your own aliased names for magic functions. In your
431 You can also define your own aliased names for magic functions. In your
432 ipythonrc file, placing a line like:
432 ipythonrc file, placing a line like:
433
433
434 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
434 execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
435
435
436 will define %pf as a new name for %profile.
436 will define %pf as a new name for %profile.
437
437
438 You can also call magics in code using the ipmagic() function, which IPython
438 You can also call magics in code using the ipmagic() function, which IPython
439 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
439 automatically adds to the builtin namespace. Type 'ipmagic?' for details.
440
440
441 For a list of the available magic functions, use %lsmagic. For a description
441 For a list of the available magic functions, use %lsmagic. For a description
442 of any of them, type %magic_name?, e.g. '%cd?'.
442 of any of them, type %magic_name?, e.g. '%cd?'.
443
443
444 Currently the magic system has the following functions:\n"""
444 Currently the magic system has the following functions:\n"""
445
445
446 mesc = self.shell.ESC_MAGIC
446 mesc = self.shell.ESC_MAGIC
447 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
447 outmsg = ("%s\n%s\n\nSummary of magic functions (from %slsmagic):"
448 "\n\n%s%s\n\n%s" % (outmsg,
448 "\n\n%s%s\n\n%s" % (outmsg,
449 magic_docs,mesc,mesc,
449 magic_docs,mesc,mesc,
450 (' '+mesc).join(self.lsmagic()),
450 (' '+mesc).join(self.lsmagic()),
451 Magic.auto_status[self.shell.rc.automagic] ) )
451 Magic.auto_status[self.shell.rc.automagic] ) )
452
452
453 page(outmsg,screen_lines=self.shell.rc.screen_length)
453 page(outmsg,screen_lines=self.shell.rc.screen_length)
454
454
455 def magic_automagic(self, parameter_s = ''):
455 def magic_automagic(self, parameter_s = ''):
456 """Make magic functions callable without having to type the initial %.
456 """Make magic functions callable without having to type the initial %.
457
457
458 Without argumentsl toggles on/off (when off, you must call it as
458 Without argumentsl toggles on/off (when off, you must call it as
459 %automagic, of course). With arguments it sets the value, and you can
459 %automagic, of course). With arguments it sets the value, and you can
460 use any of (case insensitive):
460 use any of (case insensitive):
461
461
462 - on,1,True: to activate
462 - on,1,True: to activate
463
463
464 - off,0,False: to deactivate.
464 - off,0,False: to deactivate.
465
465
466 Note that magic functions have lowest priority, so if there's a
466 Note that magic functions have lowest priority, so if there's a
467 variable whose name collides with that of a magic fn, automagic won't
467 variable whose name collides with that of a magic fn, automagic won't
468 work for that function (you get the variable instead). However, if you
468 work for that function (you get the variable instead). However, if you
469 delete the variable (del var), the previously shadowed magic function
469 delete the variable (del var), the previously shadowed magic function
470 becomes visible to automagic again."""
470 becomes visible to automagic again."""
471
471
472 rc = self.shell.rc
472 rc = self.shell.rc
473 arg = parameter_s.lower()
473 arg = parameter_s.lower()
474 if parameter_s in ('on','1','true'):
474 if parameter_s in ('on','1','true'):
475 rc.automagic = True
475 rc.automagic = True
476 elif parameter_s in ('off','0','false'):
476 elif parameter_s in ('off','0','false'):
477 rc.automagic = False
477 rc.automagic = False
478 else:
478 else:
479 rc.automagic = not rc.automagic
479 rc.automagic = not rc.automagic
480 print '\n' + Magic.auto_status[rc.automagic]
480 print '\n' + Magic.auto_status[rc.automagic]
481
481
482 def magic_autocall(self, parameter_s = ''):
482 def magic_autocall(self, parameter_s = ''):
483 """Make functions callable without having to type parentheses.
483 """Make functions callable without having to type parentheses.
484
484
485 Usage:
485 Usage:
486
486
487 %autocall [mode]
487 %autocall [mode]
488
488
489 The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the
489 The mode can be one of: 0->Off, 1->Smart, 2->Full. If not given, the
490 value is toggled on and off (remembering the previous state)."""
490 value is toggled on and off (remembering the previous state)."""
491
491
492 rc = self.shell.rc
492 rc = self.shell.rc
493
493
494 if parameter_s:
494 if parameter_s:
495 arg = int(parameter_s)
495 arg = int(parameter_s)
496 else:
496 else:
497 arg = 'toggle'
497 arg = 'toggle'
498
498
499 if not arg in (0,1,2,'toggle'):
499 if not arg in (0,1,2,'toggle'):
500 error('Valid modes: (0->Off, 1->Smart, 2->Full')
500 error('Valid modes: (0->Off, 1->Smart, 2->Full')
501 return
501 return
502
502
503 if arg in (0,1,2):
503 if arg in (0,1,2):
504 rc.autocall = arg
504 rc.autocall = arg
505 else: # toggle
505 else: # toggle
506 if rc.autocall:
506 if rc.autocall:
507 self._magic_state.autocall_save = rc.autocall
507 self._magic_state.autocall_save = rc.autocall
508 rc.autocall = 0
508 rc.autocall = 0
509 else:
509 else:
510 try:
510 try:
511 rc.autocall = self._magic_state.autocall_save
511 rc.autocall = self._magic_state.autocall_save
512 except AttributeError:
512 except AttributeError:
513 rc.autocall = self._magic_state.autocall_save = 1
513 rc.autocall = self._magic_state.autocall_save = 1
514
514
515 print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall]
515 print "Automatic calling is:",['OFF','Smart','Full'][rc.autocall]
516
516
517 def magic_autoindent(self, parameter_s = ''):
517 def magic_autoindent(self, parameter_s = ''):
518 """Toggle autoindent on/off (if available)."""
518 """Toggle autoindent on/off (if available)."""
519
519
520 self.shell.set_autoindent()
520 self.shell.set_autoindent()
521 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
521 print "Automatic indentation is:",['OFF','ON'][self.shell.autoindent]
522
522
523 def magic_system_verbose(self, parameter_s = ''):
523 def magic_system_verbose(self, parameter_s = ''):
524 """Set verbose printing of system calls.
524 """Set verbose printing of system calls.
525
525
526 If called without an argument, act as a toggle"""
526 If called without an argument, act as a toggle"""
527
527
528 if parameter_s:
528 if parameter_s:
529 val = bool(eval(parameter_s))
529 val = bool(eval(parameter_s))
530 else:
530 else:
531 val = None
531 val = None
532
532
533 self.shell.rc_set_toggle('system_verbose',val)
533 self.shell.rc_set_toggle('system_verbose',val)
534 print "System verbose printing is:",\
534 print "System verbose printing is:",\
535 ['OFF','ON'][self.shell.rc.system_verbose]
535 ['OFF','ON'][self.shell.rc.system_verbose]
536
536
537 def magic_history(self, parameter_s = ''):
537 def magic_history(self, parameter_s = ''):
538 """Print input history (_i<n> variables), with most recent last.
538 """Print input history (_i<n> variables), with most recent last.
539
539
540 %history -> print at most 40 inputs (some may be multi-line)\\
540 %history -> print at most 40 inputs (some may be multi-line)\\
541 %history n -> print at most n inputs\\
541 %history n -> print at most n inputs\\
542 %history n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
542 %history n1 n2 -> print inputs between n1 and n2 (n2 not included)\\
543
543
544 Each input's number <n> is shown, and is accessible as the
544 Each input's number <n> is shown, and is accessible as the
545 automatically generated variable _i<n>. Multi-line statements are
545 automatically generated variable _i<n>. Multi-line statements are
546 printed starting at a new line for easy copy/paste.
546 printed starting at a new line for easy copy/paste.
547
547
548
548
549 Options:
549 Options:
550
550
551 -n: do NOT print line numbers. This is useful if you want to get a
551 -n: do NOT print line numbers. This is useful if you want to get a
552 printout of many lines which can be directly pasted into a text
552 printout of many lines which can be directly pasted into a text
553 editor.
553 editor.
554
554
555 This feature is only available if numbered prompts are in use.
555 This feature is only available if numbered prompts are in use.
556
556
557 -r: print the 'raw' history. IPython filters your input and
557 -r: print the 'raw' history. IPython filters your input and
558 converts it all into valid Python source before executing it (things
558 converts it all into valid Python source before executing it (things
559 like magics or aliases are turned into function calls, for
559 like magics or aliases are turned into function calls, for
560 example). With this option, you'll see the unfiltered history
560 example). With this option, you'll see the unfiltered history
561 instead of the filtered version: '%cd /' will be seen as '%cd /'
561 instead of the filtered version: '%cd /' will be seen as '%cd /'
562 instead of '_ip.magic("%cd /")'.
562 instead of '_ip.magic("%cd /")'.
563 """
563 """
564
564
565 shell = self.shell
565 shell = self.shell
566 if not shell.outputcache.do_full_cache:
566 if not shell.outputcache.do_full_cache:
567 print 'This feature is only available if numbered prompts are in use.'
567 print 'This feature is only available if numbered prompts are in use.'
568 return
568 return
569 opts,args = self.parse_options(parameter_s,'nr',mode='list')
569 opts,args = self.parse_options(parameter_s,'nr',mode='list')
570
570
571 if opts.has_key('r'):
571 if opts.has_key('r'):
572 input_hist = shell.input_hist_raw
572 input_hist = shell.input_hist_raw
573 else:
573 else:
574 input_hist = shell.input_hist
574 input_hist = shell.input_hist
575
575
576 default_length = 40
576 default_length = 40
577 if len(args) == 0:
577 if len(args) == 0:
578 final = len(input_hist)
578 final = len(input_hist)
579 init = max(1,final-default_length)
579 init = max(1,final-default_length)
580 elif len(args) == 1:
580 elif len(args) == 1:
581 final = len(input_hist)
581 final = len(input_hist)
582 init = max(1,final-int(args[0]))
582 init = max(1,final-int(args[0]))
583 elif len(args) == 2:
583 elif len(args) == 2:
584 init,final = map(int,args)
584 init,final = map(int,args)
585 else:
585 else:
586 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
586 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
587 print self.magic_hist.__doc__
587 print self.magic_hist.__doc__
588 return
588 return
589 width = len(str(final))
589 width = len(str(final))
590 line_sep = ['','\n']
590 line_sep = ['','\n']
591 print_nums = not opts.has_key('n')
591 print_nums = not opts.has_key('n')
592 for in_num in range(init,final):
592 for in_num in range(init,final):
593 inline = input_hist[in_num]
593 inline = input_hist[in_num]
594 multiline = int(inline.count('\n') > 1)
594 multiline = int(inline.count('\n') > 1)
595 if print_nums:
595 if print_nums:
596 print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]),
596 print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]),
597 print inline,
597 print inline,
598
598
599 def magic_hist(self, parameter_s=''):
599 def magic_hist(self, parameter_s=''):
600 """Alternate name for %history."""
600 """Alternate name for %history."""
601 return self.magic_history(parameter_s)
601 return self.magic_history(parameter_s)
602
602
603 def magic_p(self, parameter_s=''):
603 def magic_p(self, parameter_s=''):
604 """Just a short alias for Python's 'print'."""
604 """Just a short alias for Python's 'print'."""
605 exec 'print ' + parameter_s in self.shell.user_ns
605 exec 'print ' + parameter_s in self.shell.user_ns
606
606
607 def magic_r(self, parameter_s=''):
607 def magic_r(self, parameter_s=''):
608 """Repeat previous input.
608 """Repeat previous input.
609
609
610 If given an argument, repeats the previous command which starts with
610 If given an argument, repeats the previous command which starts with
611 the same string, otherwise it just repeats the previous input.
611 the same string, otherwise it just repeats the previous input.
612
612
613 Shell escaped commands (with ! as first character) are not recognized
613 Shell escaped commands (with ! as first character) are not recognized
614 by this system, only pure python code and magic commands.
614 by this system, only pure python code and magic commands.
615 """
615 """
616
616
617 start = parameter_s.strip()
617 start = parameter_s.strip()
618 esc_magic = self.shell.ESC_MAGIC
618 esc_magic = self.shell.ESC_MAGIC
619 # Identify magic commands even if automagic is on (which means
619 # Identify magic commands even if automagic is on (which means
620 # the in-memory version is different from that typed by the user).
620 # the in-memory version is different from that typed by the user).
621 if self.shell.rc.automagic:
621 if self.shell.rc.automagic:
622 start_magic = esc_magic+start
622 start_magic = esc_magic+start
623 else:
623 else:
624 start_magic = start
624 start_magic = start
625 # Look through the input history in reverse
625 # Look through the input history in reverse
626 for n in range(len(self.shell.input_hist)-2,0,-1):
626 for n in range(len(self.shell.input_hist)-2,0,-1):
627 input = self.shell.input_hist[n]
627 input = self.shell.input_hist[n]
628 # skip plain 'r' lines so we don't recurse to infinity
628 # skip plain 'r' lines so we don't recurse to infinity
629 if input != '_ip.magic("r")\n' and \
629 if input != '_ip.magic("r")\n' and \
630 (input.startswith(start) or input.startswith(start_magic)):
630 (input.startswith(start) or input.startswith(start_magic)):
631 #print 'match',`input` # dbg
631 #print 'match',`input` # dbg
632 print 'Executing:',input,
632 print 'Executing:',input,
633 self.shell.runlines(input)
633 self.shell.runlines(input)
634 return
634 return
635 print 'No previous input matching `%s` found.' % start
635 print 'No previous input matching `%s` found.' % start
636
636
637 def magic_page(self, parameter_s=''):
637 def magic_page(self, parameter_s=''):
638 """Pretty print the object and display it through a pager.
638 """Pretty print the object and display it through a pager.
639
639
640 %page [options] OBJECT
640 %page [options] OBJECT
641
641
642 If no object is given, use _ (last output).
642 If no object is given, use _ (last output).
643
643
644 Options:
644 Options:
645
645
646 -r: page str(object), don't pretty-print it."""
646 -r: page str(object), don't pretty-print it."""
647
647
648 # After a function contributed by Olivier Aubert, slightly modified.
648 # After a function contributed by Olivier Aubert, slightly modified.
649
649
650 # Process options/args
650 # Process options/args
651 opts,args = self.parse_options(parameter_s,'r')
651 opts,args = self.parse_options(parameter_s,'r')
652 raw = 'r' in opts
652 raw = 'r' in opts
653
653
654 oname = args and args or '_'
654 oname = args and args or '_'
655 info = self._ofind(oname)
655 info = self._ofind(oname)
656 if info['found']:
656 if info['found']:
657 txt = (raw and str or pformat)( info['obj'] )
657 txt = (raw and str or pformat)( info['obj'] )
658 page(txt)
658 page(txt)
659 else:
659 else:
660 print 'Object `%s` not found' % oname
660 print 'Object `%s` not found' % oname
661
661
662 def magic_profile(self, parameter_s=''):
662 def magic_profile(self, parameter_s=''):
663 """Print your currently active IPyhton profile."""
663 """Print your currently active IPyhton profile."""
664 if self.shell.rc.profile:
664 if self.shell.rc.profile:
665 printpl('Current IPython profile: $self.shell.rc.profile.')
665 printpl('Current IPython profile: $self.shell.rc.profile.')
666 else:
666 else:
667 print 'No profile active.'
667 print 'No profile active.'
668
668
669 def _inspect(self,meth,oname,namespaces=None,**kw):
669 def _inspect(self,meth,oname,namespaces=None,**kw):
670 """Generic interface to the inspector system.
670 """Generic interface to the inspector system.
671
671
672 This function is meant to be called by pdef, pdoc & friends."""
672 This function is meant to be called by pdef, pdoc & friends."""
673
673
674 oname = oname.strip()
674 try:
675 oname = oname.strip().encode('ascii')
676 except UnicodeEncodeError:
677 print 'Python identifiers can only contain ascii characters.'
678 return 'not found'
679
675 info = Struct(self._ofind(oname, namespaces))
680 info = Struct(self._ofind(oname, namespaces))
676
681
677 if info.found:
682 if info.found:
678 # Get the docstring of the class property if it exists.
683 # Get the docstring of the class property if it exists.
679 path = oname.split('.')
684 path = oname.split('.')
680 root = '.'.join(path[:-1])
685 root = '.'.join(path[:-1])
681 if info.parent is not None:
686 if info.parent is not None:
682 try:
687 try:
683 target = getattr(info.parent, '__class__')
688 target = getattr(info.parent, '__class__')
684 # The object belongs to a class instance.
689 # The object belongs to a class instance.
685 try:
690 try:
686 target = getattr(target, path[-1])
691 target = getattr(target, path[-1])
687 # The class defines the object.
692 # The class defines the object.
688 if isinstance(target, property):
693 if isinstance(target, property):
689 oname = root + '.__class__.' + path[-1]
694 oname = root + '.__class__.' + path[-1]
690 info = Struct(self._ofind(oname))
695 info = Struct(self._ofind(oname))
691 except AttributeError: pass
696 except AttributeError: pass
692 except AttributeError: pass
697 except AttributeError: pass
693
698
694 pmethod = getattr(self.shell.inspector,meth)
699 pmethod = getattr(self.shell.inspector,meth)
695 formatter = info.ismagic and self.format_screen or None
700 formatter = info.ismagic and self.format_screen or None
696 if meth == 'pdoc':
701 if meth == 'pdoc':
697 pmethod(info.obj,oname,formatter)
702 pmethod(info.obj,oname,formatter)
698 elif meth == 'pinfo':
703 elif meth == 'pinfo':
699 pmethod(info.obj,oname,formatter,info,**kw)
704 pmethod(info.obj,oname,formatter,info,**kw)
700 else:
705 else:
701 pmethod(info.obj,oname)
706 pmethod(info.obj,oname)
702 else:
707 else:
703 print 'Object `%s` not found.' % oname
708 print 'Object `%s` not found.' % oname
704 return 'not found' # so callers can take other action
709 return 'not found' # so callers can take other action
705
710
706 def magic_pdef(self, parameter_s='', namespaces=None):
711 def magic_pdef(self, parameter_s='', namespaces=None):
707 """Print the definition header for any callable object.
712 """Print the definition header for any callable object.
708
713
709 If the object is a class, print the constructor information."""
714 If the object is a class, print the constructor information."""
710 self._inspect('pdef',parameter_s, namespaces)
715 self._inspect('pdef',parameter_s, namespaces)
711
716
712 def magic_pdoc(self, parameter_s='', namespaces=None):
717 def magic_pdoc(self, parameter_s='', namespaces=None):
713 """Print the docstring for an object.
718 """Print the docstring for an object.
714
719
715 If the given object is a class, it will print both the class and the
720 If the given object is a class, it will print both the class and the
716 constructor docstrings."""
721 constructor docstrings."""
717 self._inspect('pdoc',parameter_s, namespaces)
722 self._inspect('pdoc',parameter_s, namespaces)
718
723
719 def magic_psource(self, parameter_s='', namespaces=None):
724 def magic_psource(self, parameter_s='', namespaces=None):
720 """Print (or run through pager) the source code for an object."""
725 """Print (or run through pager) the source code for an object."""
721 self._inspect('psource',parameter_s, namespaces)
726 self._inspect('psource',parameter_s, namespaces)
722
727
723 def magic_pfile(self, parameter_s=''):
728 def magic_pfile(self, parameter_s=''):
724 """Print (or run through pager) the file where an object is defined.
729 """Print (or run through pager) the file where an object is defined.
725
730
726 The file opens at the line where the object definition begins. IPython
731 The file opens at the line where the object definition begins. IPython
727 will honor the environment variable PAGER if set, and otherwise will
732 will honor the environment variable PAGER if set, and otherwise will
728 do its best to print the file in a convenient form.
733 do its best to print the file in a convenient form.
729
734
730 If the given argument is not an object currently defined, IPython will
735 If the given argument is not an object currently defined, IPython will
731 try to interpret it as a filename (automatically adding a .py extension
736 try to interpret it as a filename (automatically adding a .py extension
732 if needed). You can thus use %pfile as a syntax highlighting code
737 if needed). You can thus use %pfile as a syntax highlighting code
733 viewer."""
738 viewer."""
734
739
735 # first interpret argument as an object name
740 # first interpret argument as an object name
736 out = self._inspect('pfile',parameter_s)
741 out = self._inspect('pfile',parameter_s)
737 # if not, try the input as a filename
742 # if not, try the input as a filename
738 if out == 'not found':
743 if out == 'not found':
739 try:
744 try:
740 filename = get_py_filename(parameter_s)
745 filename = get_py_filename(parameter_s)
741 except IOError,msg:
746 except IOError,msg:
742 print msg
747 print msg
743 return
748 return
744 page(self.shell.inspector.format(file(filename).read()))
749 page(self.shell.inspector.format(file(filename).read()))
745
750
746 def magic_pinfo(self, parameter_s='', namespaces=None):
751 def magic_pinfo(self, parameter_s='', namespaces=None):
747 """Provide detailed information about an object.
752 """Provide detailed information about an object.
748
753
749 '%pinfo object' is just a synonym for object? or ?object."""
754 '%pinfo object' is just a synonym for object? or ?object."""
750
755
751 #print 'pinfo par: <%s>' % parameter_s # dbg
756 #print 'pinfo par: <%s>' % parameter_s # dbg
752
757
753 # detail_level: 0 -> obj? , 1 -> obj??
758 # detail_level: 0 -> obj? , 1 -> obj??
754 detail_level = 0
759 detail_level = 0
755 # We need to detect if we got called as 'pinfo pinfo foo', which can
760 # We need to detect if we got called as 'pinfo pinfo foo', which can
756 # happen if the user types 'pinfo foo?' at the cmd line.
761 # happen if the user types 'pinfo foo?' at the cmd line.
757 pinfo,qmark1,oname,qmark2 = \
762 pinfo,qmark1,oname,qmark2 = \
758 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
763 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
759 if pinfo or qmark1 or qmark2:
764 if pinfo or qmark1 or qmark2:
760 detail_level = 1
765 detail_level = 1
761 if "*" in oname:
766 if "*" in oname:
762 self.magic_psearch(oname)
767 self.magic_psearch(oname)
763 else:
768 else:
764 self._inspect('pinfo', oname, detail_level=detail_level,
769 self._inspect('pinfo', oname, detail_level=detail_level,
765 namespaces=namespaces)
770 namespaces=namespaces)
766
771
767 def magic_psearch(self, parameter_s=''):
772 def magic_psearch(self, parameter_s=''):
768 """Search for object in namespaces by wildcard.
773 """Search for object in namespaces by wildcard.
769
774
770 %psearch [options] PATTERN [OBJECT TYPE]
775 %psearch [options] PATTERN [OBJECT TYPE]
771
776
772 Note: ? can be used as a synonym for %psearch, at the beginning or at
777 Note: ? can be used as a synonym for %psearch, at the beginning or at
773 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
778 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
774 rest of the command line must be unchanged (options come first), so
779 rest of the command line must be unchanged (options come first), so
775 for example the following forms are equivalent
780 for example the following forms are equivalent
776
781
777 %psearch -i a* function
782 %psearch -i a* function
778 -i a* function?
783 -i a* function?
779 ?-i a* function
784 ?-i a* function
780
785
781 Arguments:
786 Arguments:
782
787
783 PATTERN
788 PATTERN
784
789
785 where PATTERN is a string containing * as a wildcard similar to its
790 where PATTERN is a string containing * as a wildcard similar to its
786 use in a shell. The pattern is matched in all namespaces on the
791 use in a shell. The pattern is matched in all namespaces on the
787 search path. By default objects starting with a single _ are not
792 search path. By default objects starting with a single _ are not
788 matched, many IPython generated objects have a single
793 matched, many IPython generated objects have a single
789 underscore. The default is case insensitive matching. Matching is
794 underscore. The default is case insensitive matching. Matching is
790 also done on the attributes of objects and not only on the objects
795 also done on the attributes of objects and not only on the objects
791 in a module.
796 in a module.
792
797
793 [OBJECT TYPE]
798 [OBJECT TYPE]
794
799
795 Is the name of a python type from the types module. The name is
800 Is the name of a python type from the types module. The name is
796 given in lowercase without the ending type, ex. StringType is
801 given in lowercase without the ending type, ex. StringType is
797 written string. By adding a type here only objects matching the
802 written string. By adding a type here only objects matching the
798 given type are matched. Using all here makes the pattern match all
803 given type are matched. Using all here makes the pattern match all
799 types (this is the default).
804 types (this is the default).
800
805
801 Options:
806 Options:
802
807
803 -a: makes the pattern match even objects whose names start with a
808 -a: makes the pattern match even objects whose names start with a
804 single underscore. These names are normally ommitted from the
809 single underscore. These names are normally ommitted from the
805 search.
810 search.
806
811
807 -i/-c: make the pattern case insensitive/sensitive. If neither of
812 -i/-c: make the pattern case insensitive/sensitive. If neither of
808 these options is given, the default is read from your ipythonrc
813 these options is given, the default is read from your ipythonrc
809 file. The option name which sets this value is
814 file. The option name which sets this value is
810 'wildcards_case_sensitive'. If this option is not specified in your
815 'wildcards_case_sensitive'. If this option is not specified in your
811 ipythonrc file, IPython's internal default is to do a case sensitive
816 ipythonrc file, IPython's internal default is to do a case sensitive
812 search.
817 search.
813
818
814 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
819 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
815 specifiy can be searched in any of the following namespaces:
820 specifiy can be searched in any of the following namespaces:
816 'builtin', 'user', 'user_global','internal', 'alias', where
821 'builtin', 'user', 'user_global','internal', 'alias', where
817 'builtin' and 'user' are the search defaults. Note that you should
822 'builtin' and 'user' are the search defaults. Note that you should
818 not use quotes when specifying namespaces.
823 not use quotes when specifying namespaces.
819
824
820 'Builtin' contains the python module builtin, 'user' contains all
825 'Builtin' contains the python module builtin, 'user' contains all
821 user data, 'alias' only contain the shell aliases and no python
826 user data, 'alias' only contain the shell aliases and no python
822 objects, 'internal' contains objects used by IPython. The
827 objects, 'internal' contains objects used by IPython. The
823 'user_global' namespace is only used by embedded IPython instances,
828 'user_global' namespace is only used by embedded IPython instances,
824 and it contains module-level globals. You can add namespaces to the
829 and it contains module-level globals. You can add namespaces to the
825 search with -s or exclude them with -e (these options can be given
830 search with -s or exclude them with -e (these options can be given
826 more than once).
831 more than once).
827
832
828 Examples:
833 Examples:
829
834
830 %psearch a* -> objects beginning with an a
835 %psearch a* -> objects beginning with an a
831 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
836 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
832 %psearch a* function -> all functions beginning with an a
837 %psearch a* function -> all functions beginning with an a
833 %psearch re.e* -> objects beginning with an e in module re
838 %psearch re.e* -> objects beginning with an e in module re
834 %psearch r*.e* -> objects that start with e in modules starting in r
839 %psearch r*.e* -> objects that start with e in modules starting in r
835 %psearch r*.* string -> all strings in modules beginning with r
840 %psearch r*.* string -> all strings in modules beginning with r
836
841
837 Case sensitve search:
842 Case sensitve search:
838
843
839 %psearch -c a* list all object beginning with lower case a
844 %psearch -c a* list all object beginning with lower case a
840
845
841 Show objects beginning with a single _:
846 Show objects beginning with a single _:
842
847
843 %psearch -a _* list objects beginning with a single underscore"""
848 %psearch -a _* list objects beginning with a single underscore"""
844
849
845 # default namespaces to be searched
850 # default namespaces to be searched
846 def_search = ['user','builtin']
851 def_search = ['user','builtin']
847
852
848 # Process options/args
853 # Process options/args
849 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
854 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
850 opt = opts.get
855 opt = opts.get
851 shell = self.shell
856 shell = self.shell
852 psearch = shell.inspector.psearch
857 psearch = shell.inspector.psearch
853
858
854 # select case options
859 # select case options
855 if opts.has_key('i'):
860 if opts.has_key('i'):
856 ignore_case = True
861 ignore_case = True
857 elif opts.has_key('c'):
862 elif opts.has_key('c'):
858 ignore_case = False
863 ignore_case = False
859 else:
864 else:
860 ignore_case = not shell.rc.wildcards_case_sensitive
865 ignore_case = not shell.rc.wildcards_case_sensitive
861
866
862 # Build list of namespaces to search from user options
867 # Build list of namespaces to search from user options
863 def_search.extend(opt('s',[]))
868 def_search.extend(opt('s',[]))
864 ns_exclude = ns_exclude=opt('e',[])
869 ns_exclude = ns_exclude=opt('e',[])
865 ns_search = [nm for nm in def_search if nm not in ns_exclude]
870 ns_search = [nm for nm in def_search if nm not in ns_exclude]
866
871
867 # Call the actual search
872 # Call the actual search
868 try:
873 try:
869 psearch(args,shell.ns_table,ns_search,
874 psearch(args,shell.ns_table,ns_search,
870 show_all=opt('a'),ignore_case=ignore_case)
875 show_all=opt('a'),ignore_case=ignore_case)
871 except:
876 except:
872 shell.showtraceback()
877 shell.showtraceback()
873
878
874 def magic_who_ls(self, parameter_s=''):
879 def magic_who_ls(self, parameter_s=''):
875 """Return a sorted list of all interactive variables.
880 """Return a sorted list of all interactive variables.
876
881
877 If arguments are given, only variables of types matching these
882 If arguments are given, only variables of types matching these
878 arguments are returned."""
883 arguments are returned."""
879
884
880 user_ns = self.shell.user_ns
885 user_ns = self.shell.user_ns
881 internal_ns = self.shell.internal_ns
886 internal_ns = self.shell.internal_ns
882 user_config_ns = self.shell.user_config_ns
887 user_config_ns = self.shell.user_config_ns
883 out = []
888 out = []
884 typelist = parameter_s.split()
889 typelist = parameter_s.split()
885
890
886 for i in user_ns:
891 for i in user_ns:
887 if not (i.startswith('_') or i.startswith('_i')) \
892 if not (i.startswith('_') or i.startswith('_i')) \
888 and not (i in internal_ns or i in user_config_ns):
893 and not (i in internal_ns or i in user_config_ns):
889 if typelist:
894 if typelist:
890 if type(user_ns[i]).__name__ in typelist:
895 if type(user_ns[i]).__name__ in typelist:
891 out.append(i)
896 out.append(i)
892 else:
897 else:
893 out.append(i)
898 out.append(i)
894 out.sort()
899 out.sort()
895 return out
900 return out
896
901
897 def magic_who(self, parameter_s=''):
902 def magic_who(self, parameter_s=''):
898 """Print all interactive variables, with some minimal formatting.
903 """Print all interactive variables, with some minimal formatting.
899
904
900 If any arguments are given, only variables whose type matches one of
905 If any arguments are given, only variables whose type matches one of
901 these are printed. For example:
906 these are printed. For example:
902
907
903 %who function str
908 %who function str
904
909
905 will only list functions and strings, excluding all other types of
910 will only list functions and strings, excluding all other types of
906 variables. To find the proper type names, simply use type(var) at a
911 variables. To find the proper type names, simply use type(var) at a
907 command line to see how python prints type names. For example:
912 command line to see how python prints type names. For example:
908
913
909 In [1]: type('hello')\\
914 In [1]: type('hello')\\
910 Out[1]: <type 'str'>
915 Out[1]: <type 'str'>
911
916
912 indicates that the type name for strings is 'str'.
917 indicates that the type name for strings is 'str'.
913
918
914 %who always excludes executed names loaded through your configuration
919 %who always excludes executed names loaded through your configuration
915 file and things which are internal to IPython.
920 file and things which are internal to IPython.
916
921
917 This is deliberate, as typically you may load many modules and the
922 This is deliberate, as typically you may load many modules and the
918 purpose of %who is to show you only what you've manually defined."""
923 purpose of %who is to show you only what you've manually defined."""
919
924
920 varlist = self.magic_who_ls(parameter_s)
925 varlist = self.magic_who_ls(parameter_s)
921 if not varlist:
926 if not varlist:
922 print 'Interactive namespace is empty.'
927 print 'Interactive namespace is empty.'
923 return
928 return
924
929
925 # if we have variables, move on...
930 # if we have variables, move on...
926
931
927 # stupid flushing problem: when prompts have no separators, stdout is
932 # stupid flushing problem: when prompts have no separators, stdout is
928 # getting lost. I'm starting to think this is a python bug. I'm having
933 # getting lost. I'm starting to think this is a python bug. I'm having
929 # to force a flush with a print because even a sys.stdout.flush
934 # to force a flush with a print because even a sys.stdout.flush
930 # doesn't seem to do anything!
935 # doesn't seem to do anything!
931
936
932 count = 0
937 count = 0
933 for i in varlist:
938 for i in varlist:
934 print i+'\t',
939 print i+'\t',
935 count += 1
940 count += 1
936 if count > 8:
941 if count > 8:
937 count = 0
942 count = 0
938 print
943 print
939 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
944 sys.stdout.flush() # FIXME. Why the hell isn't this flushing???
940
945
941 print # well, this does force a flush at the expense of an extra \n
946 print # well, this does force a flush at the expense of an extra \n
942
947
943 def magic_whos(self, parameter_s=''):
948 def magic_whos(self, parameter_s=''):
944 """Like %who, but gives some extra information about each variable.
949 """Like %who, but gives some extra information about each variable.
945
950
946 The same type filtering of %who can be applied here.
951 The same type filtering of %who can be applied here.
947
952
948 For all variables, the type is printed. Additionally it prints:
953 For all variables, the type is printed. Additionally it prints:
949
954
950 - For {},[],(): their length.
955 - For {},[],(): their length.
951
956
952 - For Numeric arrays, a summary with shape, number of elements,
957 - For Numeric arrays, a summary with shape, number of elements,
953 typecode and size in memory.
958 typecode and size in memory.
954
959
955 - Everything else: a string representation, snipping their middle if
960 - Everything else: a string representation, snipping their middle if
956 too long."""
961 too long."""
957
962
958 varnames = self.magic_who_ls(parameter_s)
963 varnames = self.magic_who_ls(parameter_s)
959 if not varnames:
964 if not varnames:
960 print 'Interactive namespace is empty.'
965 print 'Interactive namespace is empty.'
961 return
966 return
962
967
963 # if we have variables, move on...
968 # if we have variables, move on...
964
969
965 # for these types, show len() instead of data:
970 # for these types, show len() instead of data:
966 seq_types = [types.DictType,types.ListType,types.TupleType]
971 seq_types = [types.DictType,types.ListType,types.TupleType]
967
972
968 # for Numeric arrays, display summary info
973 # for Numeric arrays, display summary info
969 try:
974 try:
970 import Numeric
975 import Numeric
971 except ImportError:
976 except ImportError:
972 array_type = None
977 array_type = None
973 else:
978 else:
974 array_type = Numeric.ArrayType.__name__
979 array_type = Numeric.ArrayType.__name__
975
980
976 # Find all variable names and types so we can figure out column sizes
981 # Find all variable names and types so we can figure out column sizes
977
982
978 def get_vars(i):
983 def get_vars(i):
979 return self.shell.user_ns[i]
984 return self.shell.user_ns[i]
980
985
981 # some types are well known and can be shorter
986 # some types are well known and can be shorter
982 abbrevs = {'IPython.macro.Macro' : 'Macro'}
987 abbrevs = {'IPython.macro.Macro' : 'Macro'}
983 def type_name(v):
988 def type_name(v):
984 tn = type(v).__name__
989 tn = type(v).__name__
985 return abbrevs.get(tn,tn)
990 return abbrevs.get(tn,tn)
986
991
987 varlist = map(get_vars,varnames)
992 varlist = map(get_vars,varnames)
988
993
989 typelist = []
994 typelist = []
990 for vv in varlist:
995 for vv in varlist:
991 tt = type_name(vv)
996 tt = type_name(vv)
992
997
993 if tt=='instance':
998 if tt=='instance':
994 typelist.append( abbrevs.get(str(vv.__class__),str(vv.__class__)))
999 typelist.append( abbrevs.get(str(vv.__class__),str(vv.__class__)))
995 else:
1000 else:
996 typelist.append(tt)
1001 typelist.append(tt)
997
1002
998 # column labels and # of spaces as separator
1003 # column labels and # of spaces as separator
999 varlabel = 'Variable'
1004 varlabel = 'Variable'
1000 typelabel = 'Type'
1005 typelabel = 'Type'
1001 datalabel = 'Data/Info'
1006 datalabel = 'Data/Info'
1002 colsep = 3
1007 colsep = 3
1003 # variable format strings
1008 # variable format strings
1004 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
1009 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
1005 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
1010 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
1006 aformat = "%s: %s elems, type `%s`, %s bytes"
1011 aformat = "%s: %s elems, type `%s`, %s bytes"
1007 # find the size of the columns to format the output nicely
1012 # find the size of the columns to format the output nicely
1008 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
1013 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
1009 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
1014 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
1010 # table header
1015 # table header
1011 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
1016 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
1012 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
1017 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
1013 # and the table itself
1018 # and the table itself
1014 kb = 1024
1019 kb = 1024
1015 Mb = 1048576 # kb**2
1020 Mb = 1048576 # kb**2
1016 for vname,var,vtype in zip(varnames,varlist,typelist):
1021 for vname,var,vtype in zip(varnames,varlist,typelist):
1017 print itpl(vformat),
1022 print itpl(vformat),
1018 if vtype in seq_types:
1023 if vtype in seq_types:
1019 print len(var)
1024 print len(var)
1020 elif vtype==array_type:
1025 elif vtype==array_type:
1021 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
1026 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
1022 vsize = Numeric.size(var)
1027 vsize = Numeric.size(var)
1023 vbytes = vsize*var.itemsize()
1028 vbytes = vsize*var.itemsize()
1024 if vbytes < 100000:
1029 if vbytes < 100000:
1025 print aformat % (vshape,vsize,var.typecode(),vbytes)
1030 print aformat % (vshape,vsize,var.typecode(),vbytes)
1026 else:
1031 else:
1027 print aformat % (vshape,vsize,var.typecode(),vbytes),
1032 print aformat % (vshape,vsize,var.typecode(),vbytes),
1028 if vbytes < Mb:
1033 if vbytes < Mb:
1029 print '(%s kb)' % (vbytes/kb,)
1034 print '(%s kb)' % (vbytes/kb,)
1030 else:
1035 else:
1031 print '(%s Mb)' % (vbytes/Mb,)
1036 print '(%s Mb)' % (vbytes/Mb,)
1032 else:
1037 else:
1033 vstr = str(var).replace('\n','\\n')
1038 vstr = str(var).replace('\n','\\n')
1034 if len(vstr) < 50:
1039 if len(vstr) < 50:
1035 print vstr
1040 print vstr
1036 else:
1041 else:
1037 printpl(vfmt_short)
1042 printpl(vfmt_short)
1038
1043
1039 def magic_reset(self, parameter_s=''):
1044 def magic_reset(self, parameter_s=''):
1040 """Resets the namespace by removing all names defined by the user.
1045 """Resets the namespace by removing all names defined by the user.
1041
1046
1042 Input/Output history are left around in case you need them."""
1047 Input/Output history are left around in case you need them."""
1043
1048
1044 ans = self.shell.ask_yes_no(
1049 ans = self.shell.ask_yes_no(
1045 "Once deleted, variables cannot be recovered. Proceed (y/[n])? ")
1050 "Once deleted, variables cannot be recovered. Proceed (y/[n])? ")
1046 if not ans:
1051 if not ans:
1047 print 'Nothing done.'
1052 print 'Nothing done.'
1048 return
1053 return
1049 user_ns = self.shell.user_ns
1054 user_ns = self.shell.user_ns
1050 for i in self.magic_who_ls():
1055 for i in self.magic_who_ls():
1051 del(user_ns[i])
1056 del(user_ns[i])
1052
1057
1053 def magic_logstart(self,parameter_s=''):
1058 def magic_logstart(self,parameter_s=''):
1054 """Start logging anywhere in a session.
1059 """Start logging anywhere in a session.
1055
1060
1056 %logstart [-o|-r|-t] [log_name [log_mode]]
1061 %logstart [-o|-r|-t] [log_name [log_mode]]
1057
1062
1058 If no name is given, it defaults to a file named 'ipython_log.py' in your
1063 If no name is given, it defaults to a file named 'ipython_log.py' in your
1059 current directory, in 'rotate' mode (see below).
1064 current directory, in 'rotate' mode (see below).
1060
1065
1061 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
1066 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
1062 history up to that point and then continues logging.
1067 history up to that point and then continues logging.
1063
1068
1064 %logstart takes a second optional parameter: logging mode. This can be one
1069 %logstart takes a second optional parameter: logging mode. This can be one
1065 of (note that the modes are given unquoted):\\
1070 of (note that the modes are given unquoted):\\
1066 append: well, that says it.\\
1071 append: well, that says it.\\
1067 backup: rename (if exists) to name~ and start name.\\
1072 backup: rename (if exists) to name~ and start name.\\
1068 global: single logfile in your home dir, appended to.\\
1073 global: single logfile in your home dir, appended to.\\
1069 over : overwrite existing log.\\
1074 over : overwrite existing log.\\
1070 rotate: create rotating logs name.1~, name.2~, etc.
1075 rotate: create rotating logs name.1~, name.2~, etc.
1071
1076
1072 Options:
1077 Options:
1073
1078
1074 -o: log also IPython's output. In this mode, all commands which
1079 -o: log also IPython's output. In this mode, all commands which
1075 generate an Out[NN] prompt are recorded to the logfile, right after
1080 generate an Out[NN] prompt are recorded to the logfile, right after
1076 their corresponding input line. The output lines are always
1081 their corresponding input line. The output lines are always
1077 prepended with a '#[Out]# ' marker, so that the log remains valid
1082 prepended with a '#[Out]# ' marker, so that the log remains valid
1078 Python code.
1083 Python code.
1079
1084
1080 Since this marker is always the same, filtering only the output from
1085 Since this marker is always the same, filtering only the output from
1081 a log is very easy, using for example a simple awk call:
1086 a log is very easy, using for example a simple awk call:
1082
1087
1083 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
1088 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
1084
1089
1085 -r: log 'raw' input. Normally, IPython's logs contain the processed
1090 -r: log 'raw' input. Normally, IPython's logs contain the processed
1086 input, so that user lines are logged in their final form, converted
1091 input, so that user lines are logged in their final form, converted
1087 into valid Python. For example, %Exit is logged as
1092 into valid Python. For example, %Exit is logged as
1088 '_ip.magic("Exit"). If the -r flag is given, all input is logged
1093 '_ip.magic("Exit"). If the -r flag is given, all input is logged
1089 exactly as typed, with no transformations applied.
1094 exactly as typed, with no transformations applied.
1090
1095
1091 -t: put timestamps before each input line logged (these are put in
1096 -t: put timestamps before each input line logged (these are put in
1092 comments)."""
1097 comments)."""
1093
1098
1094 opts,par = self.parse_options(parameter_s,'ort')
1099 opts,par = self.parse_options(parameter_s,'ort')
1095 log_output = 'o' in opts
1100 log_output = 'o' in opts
1096 log_raw_input = 'r' in opts
1101 log_raw_input = 'r' in opts
1097 timestamp = 't' in opts
1102 timestamp = 't' in opts
1098
1103
1099 rc = self.shell.rc
1104 rc = self.shell.rc
1100 logger = self.shell.logger
1105 logger = self.shell.logger
1101
1106
1102 # if no args are given, the defaults set in the logger constructor by
1107 # if no args are given, the defaults set in the logger constructor by
1103 # ipytohn remain valid
1108 # ipytohn remain valid
1104 if par:
1109 if par:
1105 try:
1110 try:
1106 logfname,logmode = par.split()
1111 logfname,logmode = par.split()
1107 except:
1112 except:
1108 logfname = par
1113 logfname = par
1109 logmode = 'backup'
1114 logmode = 'backup'
1110 else:
1115 else:
1111 logfname = logger.logfname
1116 logfname = logger.logfname
1112 logmode = logger.logmode
1117 logmode = logger.logmode
1113 # put logfname into rc struct as if it had been called on the command
1118 # put logfname into rc struct as if it had been called on the command
1114 # line, so it ends up saved in the log header Save it in case we need
1119 # line, so it ends up saved in the log header Save it in case we need
1115 # to restore it...
1120 # to restore it...
1116 old_logfile = rc.opts.get('logfile','')
1121 old_logfile = rc.opts.get('logfile','')
1117 if logfname:
1122 if logfname:
1118 logfname = os.path.expanduser(logfname)
1123 logfname = os.path.expanduser(logfname)
1119 rc.opts.logfile = logfname
1124 rc.opts.logfile = logfname
1120 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
1125 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
1121 try:
1126 try:
1122 started = logger.logstart(logfname,loghead,logmode,
1127 started = logger.logstart(logfname,loghead,logmode,
1123 log_output,timestamp,log_raw_input)
1128 log_output,timestamp,log_raw_input)
1124 except:
1129 except:
1125 rc.opts.logfile = old_logfile
1130 rc.opts.logfile = old_logfile
1126 warn("Couldn't start log: %s" % sys.exc_info()[1])
1131 warn("Couldn't start log: %s" % sys.exc_info()[1])
1127 else:
1132 else:
1128 # log input history up to this point, optionally interleaving
1133 # log input history up to this point, optionally interleaving
1129 # output if requested
1134 # output if requested
1130
1135
1131 if timestamp:
1136 if timestamp:
1132 # disable timestamping for the previous history, since we've
1137 # disable timestamping for the previous history, since we've
1133 # lost those already (no time machine here).
1138 # lost those already (no time machine here).
1134 logger.timestamp = False
1139 logger.timestamp = False
1135
1140
1136 if log_raw_input:
1141 if log_raw_input:
1137 input_hist = self.shell.input_hist_raw
1142 input_hist = self.shell.input_hist_raw
1138 else:
1143 else:
1139 input_hist = self.shell.input_hist
1144 input_hist = self.shell.input_hist
1140
1145
1141 if log_output:
1146 if log_output:
1142 log_write = logger.log_write
1147 log_write = logger.log_write
1143 output_hist = self.shell.output_hist
1148 output_hist = self.shell.output_hist
1144 for n in range(1,len(input_hist)-1):
1149 for n in range(1,len(input_hist)-1):
1145 log_write(input_hist[n].rstrip())
1150 log_write(input_hist[n].rstrip())
1146 if n in output_hist:
1151 if n in output_hist:
1147 log_write(repr(output_hist[n]),'output')
1152 log_write(repr(output_hist[n]),'output')
1148 else:
1153 else:
1149 logger.log_write(input_hist[1:])
1154 logger.log_write(input_hist[1:])
1150 if timestamp:
1155 if timestamp:
1151 # re-enable timestamping
1156 # re-enable timestamping
1152 logger.timestamp = True
1157 logger.timestamp = True
1153
1158
1154 print ('Activating auto-logging. '
1159 print ('Activating auto-logging. '
1155 'Current session state plus future input saved.')
1160 'Current session state plus future input saved.')
1156 logger.logstate()
1161 logger.logstate()
1157
1162
1158 def magic_logoff(self,parameter_s=''):
1163 def magic_logoff(self,parameter_s=''):
1159 """Temporarily stop logging.
1164 """Temporarily stop logging.
1160
1165
1161 You must have previously started logging."""
1166 You must have previously started logging."""
1162 self.shell.logger.switch_log(0)
1167 self.shell.logger.switch_log(0)
1163
1168
1164 def magic_logon(self,parameter_s=''):
1169 def magic_logon(self,parameter_s=''):
1165 """Restart logging.
1170 """Restart logging.
1166
1171
1167 This function is for restarting logging which you've temporarily
1172 This function is for restarting logging which you've temporarily
1168 stopped with %logoff. For starting logging for the first time, you
1173 stopped with %logoff. For starting logging for the first time, you
1169 must use the %logstart function, which allows you to specify an
1174 must use the %logstart function, which allows you to specify an
1170 optional log filename."""
1175 optional log filename."""
1171
1176
1172 self.shell.logger.switch_log(1)
1177 self.shell.logger.switch_log(1)
1173
1178
1174 def magic_logstate(self,parameter_s=''):
1179 def magic_logstate(self,parameter_s=''):
1175 """Print the status of the logging system."""
1180 """Print the status of the logging system."""
1176
1181
1177 self.shell.logger.logstate()
1182 self.shell.logger.logstate()
1178
1183
1179 def magic_pdb(self, parameter_s=''):
1184 def magic_pdb(self, parameter_s=''):
1180 """Control the automatic calling of the pdb interactive debugger.
1185 """Control the automatic calling of the pdb interactive debugger.
1181
1186
1182 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1187 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1183 argument it works as a toggle.
1188 argument it works as a toggle.
1184
1189
1185 When an exception is triggered, IPython can optionally call the
1190 When an exception is triggered, IPython can optionally call the
1186 interactive pdb debugger after the traceback printout. %pdb toggles
1191 interactive pdb debugger after the traceback printout. %pdb toggles
1187 this feature on and off.
1192 this feature on and off.
1188
1193
1189 The initial state of this feature is set in your ipythonrc
1194 The initial state of this feature is set in your ipythonrc
1190 configuration file (the variable is called 'pdb').
1195 configuration file (the variable is called 'pdb').
1191
1196
1192 If you want to just activate the debugger AFTER an exception has fired,
1197 If you want to just activate the debugger AFTER an exception has fired,
1193 without having to type '%pdb on' and rerunning your code, you can use
1198 without having to type '%pdb on' and rerunning your code, you can use
1194 the %debug magic."""
1199 the %debug magic."""
1195
1200
1196 par = parameter_s.strip().lower()
1201 par = parameter_s.strip().lower()
1197
1202
1198 if par:
1203 if par:
1199 try:
1204 try:
1200 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1205 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1201 except KeyError:
1206 except KeyError:
1202 print ('Incorrect argument. Use on/1, off/0, '
1207 print ('Incorrect argument. Use on/1, off/0, '
1203 'or nothing for a toggle.')
1208 'or nothing for a toggle.')
1204 return
1209 return
1205 else:
1210 else:
1206 # toggle
1211 # toggle
1207 new_pdb = not self.shell.call_pdb
1212 new_pdb = not self.shell.call_pdb
1208
1213
1209 # set on the shell
1214 # set on the shell
1210 self.shell.call_pdb = new_pdb
1215 self.shell.call_pdb = new_pdb
1211 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1216 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1212
1217
1213 def magic_debug(self, parameter_s=''):
1218 def magic_debug(self, parameter_s=''):
1214 """Activate the interactive debugger in post-mortem mode.
1219 """Activate the interactive debugger in post-mortem mode.
1215
1220
1216 If an exception has just occurred, this lets you inspect its stack
1221 If an exception has just occurred, this lets you inspect its stack
1217 frames interactively. Note that this will always work only on the last
1222 frames interactively. Note that this will always work only on the last
1218 traceback that occurred, so you must call this quickly after an
1223 traceback that occurred, so you must call this quickly after an
1219 exception that you wish to inspect has fired, because if another one
1224 exception that you wish to inspect has fired, because if another one
1220 occurs, it clobbers the previous one.
1225 occurs, it clobbers the previous one.
1221
1226
1222 If you want IPython to automatically do this on every exception, see
1227 If you want IPython to automatically do this on every exception, see
1223 the %pdb magic for more details.
1228 the %pdb magic for more details.
1224 """
1229 """
1225
1230
1226 self.shell.debugger(force=True)
1231 self.shell.debugger(force=True)
1227
1232
1228 def magic_prun(self, parameter_s ='',user_mode=1,
1233 def magic_prun(self, parameter_s ='',user_mode=1,
1229 opts=None,arg_lst=None,prog_ns=None):
1234 opts=None,arg_lst=None,prog_ns=None):
1230
1235
1231 """Run a statement through the python code profiler.
1236 """Run a statement through the python code profiler.
1232
1237
1233 Usage:\\
1238 Usage:\\
1234 %prun [options] statement
1239 %prun [options] statement
1235
1240
1236 The given statement (which doesn't require quote marks) is run via the
1241 The given statement (which doesn't require quote marks) is run via the
1237 python profiler in a manner similar to the profile.run() function.
1242 python profiler in a manner similar to the profile.run() function.
1238 Namespaces are internally managed to work correctly; profile.run
1243 Namespaces are internally managed to work correctly; profile.run
1239 cannot be used in IPython because it makes certain assumptions about
1244 cannot be used in IPython because it makes certain assumptions about
1240 namespaces which do not hold under IPython.
1245 namespaces which do not hold under IPython.
1241
1246
1242 Options:
1247 Options:
1243
1248
1244 -l <limit>: you can place restrictions on what or how much of the
1249 -l <limit>: you can place restrictions on what or how much of the
1245 profile gets printed. The limit value can be:
1250 profile gets printed. The limit value can be:
1246
1251
1247 * A string: only information for function names containing this string
1252 * A string: only information for function names containing this string
1248 is printed.
1253 is printed.
1249
1254
1250 * An integer: only these many lines are printed.
1255 * An integer: only these many lines are printed.
1251
1256
1252 * A float (between 0 and 1): this fraction of the report is printed
1257 * A float (between 0 and 1): this fraction of the report is printed
1253 (for example, use a limit of 0.4 to see the topmost 40% only).
1258 (for example, use a limit of 0.4 to see the topmost 40% only).
1254
1259
1255 You can combine several limits with repeated use of the option. For
1260 You can combine several limits with repeated use of the option. For
1256 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1261 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1257 information about class constructors.
1262 information about class constructors.
1258
1263
1259 -r: return the pstats.Stats object generated by the profiling. This
1264 -r: return the pstats.Stats object generated by the profiling. This
1260 object has all the information about the profile in it, and you can
1265 object has all the information about the profile in it, and you can
1261 later use it for further analysis or in other functions.
1266 later use it for further analysis or in other functions.
1262
1267
1263 -s <key>: sort profile by given key. You can provide more than one key
1268 -s <key>: sort profile by given key. You can provide more than one key
1264 by using the option several times: '-s key1 -s key2 -s key3...'. The
1269 by using the option several times: '-s key1 -s key2 -s key3...'. The
1265 default sorting key is 'time'.
1270 default sorting key is 'time'.
1266
1271
1267 The following is copied verbatim from the profile documentation
1272 The following is copied verbatim from the profile documentation
1268 referenced below:
1273 referenced below:
1269
1274
1270 When more than one key is provided, additional keys are used as
1275 When more than one key is provided, additional keys are used as
1271 secondary criteria when the there is equality in all keys selected
1276 secondary criteria when the there is equality in all keys selected
1272 before them.
1277 before them.
1273
1278
1274 Abbreviations can be used for any key names, as long as the
1279 Abbreviations can be used for any key names, as long as the
1275 abbreviation is unambiguous. The following are the keys currently
1280 abbreviation is unambiguous. The following are the keys currently
1276 defined:
1281 defined:
1277
1282
1278 Valid Arg Meaning\\
1283 Valid Arg Meaning\\
1279 "calls" call count\\
1284 "calls" call count\\
1280 "cumulative" cumulative time\\
1285 "cumulative" cumulative time\\
1281 "file" file name\\
1286 "file" file name\\
1282 "module" file name\\
1287 "module" file name\\
1283 "pcalls" primitive call count\\
1288 "pcalls" primitive call count\\
1284 "line" line number\\
1289 "line" line number\\
1285 "name" function name\\
1290 "name" function name\\
1286 "nfl" name/file/line\\
1291 "nfl" name/file/line\\
1287 "stdname" standard name\\
1292 "stdname" standard name\\
1288 "time" internal time
1293 "time" internal time
1289
1294
1290 Note that all sorts on statistics are in descending order (placing
1295 Note that all sorts on statistics are in descending order (placing
1291 most time consuming items first), where as name, file, and line number
1296 most time consuming items first), where as name, file, and line number
1292 searches are in ascending order (i.e., alphabetical). The subtle
1297 searches are in ascending order (i.e., alphabetical). The subtle
1293 distinction between "nfl" and "stdname" is that the standard name is a
1298 distinction between "nfl" and "stdname" is that the standard name is a
1294 sort of the name as printed, which means that the embedded line
1299 sort of the name as printed, which means that the embedded line
1295 numbers get compared in an odd way. For example, lines 3, 20, and 40
1300 numbers get compared in an odd way. For example, lines 3, 20, and 40
1296 would (if the file names were the same) appear in the string order
1301 would (if the file names were the same) appear in the string order
1297 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1302 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1298 line numbers. In fact, sort_stats("nfl") is the same as
1303 line numbers. In fact, sort_stats("nfl") is the same as
1299 sort_stats("name", "file", "line").
1304 sort_stats("name", "file", "line").
1300
1305
1301 -T <filename>: save profile results as shown on screen to a text
1306 -T <filename>: save profile results as shown on screen to a text
1302 file. The profile is still shown on screen.
1307 file. The profile is still shown on screen.
1303
1308
1304 -D <filename>: save (via dump_stats) profile statistics to given
1309 -D <filename>: save (via dump_stats) profile statistics to given
1305 filename. This data is in a format understod by the pstats module, and
1310 filename. This data is in a format understod by the pstats module, and
1306 is generated by a call to the dump_stats() method of profile
1311 is generated by a call to the dump_stats() method of profile
1307 objects. The profile is still shown on screen.
1312 objects. The profile is still shown on screen.
1308
1313
1309 If you want to run complete programs under the profiler's control, use
1314 If you want to run complete programs under the profiler's control, use
1310 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1315 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1311 contains profiler specific options as described here.
1316 contains profiler specific options as described here.
1312
1317
1313 You can read the complete documentation for the profile module with:\\
1318 You can read the complete documentation for the profile module with:\\
1314 In [1]: import profile; profile.help() """
1319 In [1]: import profile; profile.help() """
1315
1320
1316 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1321 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1317 # protect user quote marks
1322 # protect user quote marks
1318 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1323 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1319
1324
1320 if user_mode: # regular user call
1325 if user_mode: # regular user call
1321 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1326 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1322 list_all=1)
1327 list_all=1)
1323 namespace = self.shell.user_ns
1328 namespace = self.shell.user_ns
1324 else: # called to run a program by %run -p
1329 else: # called to run a program by %run -p
1325 try:
1330 try:
1326 filename = get_py_filename(arg_lst[0])
1331 filename = get_py_filename(arg_lst[0])
1327 except IOError,msg:
1332 except IOError,msg:
1328 error(msg)
1333 error(msg)
1329 return
1334 return
1330
1335
1331 arg_str = 'execfile(filename,prog_ns)'
1336 arg_str = 'execfile(filename,prog_ns)'
1332 namespace = locals()
1337 namespace = locals()
1333
1338
1334 opts.merge(opts_def)
1339 opts.merge(opts_def)
1335
1340
1336 prof = profile.Profile()
1341 prof = profile.Profile()
1337 try:
1342 try:
1338 prof = prof.runctx(arg_str,namespace,namespace)
1343 prof = prof.runctx(arg_str,namespace,namespace)
1339 sys_exit = ''
1344 sys_exit = ''
1340 except SystemExit:
1345 except SystemExit:
1341 sys_exit = """*** SystemExit exception caught in code being profiled."""
1346 sys_exit = """*** SystemExit exception caught in code being profiled."""
1342
1347
1343 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1348 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1344
1349
1345 lims = opts.l
1350 lims = opts.l
1346 if lims:
1351 if lims:
1347 lims = [] # rebuild lims with ints/floats/strings
1352 lims = [] # rebuild lims with ints/floats/strings
1348 for lim in opts.l:
1353 for lim in opts.l:
1349 try:
1354 try:
1350 lims.append(int(lim))
1355 lims.append(int(lim))
1351 except ValueError:
1356 except ValueError:
1352 try:
1357 try:
1353 lims.append(float(lim))
1358 lims.append(float(lim))
1354 except ValueError:
1359 except ValueError:
1355 lims.append(lim)
1360 lims.append(lim)
1356
1361
1357 # Trap output.
1362 # Trap output.
1358 stdout_trap = StringIO()
1363 stdout_trap = StringIO()
1359
1364
1360 if hasattr(stats,'stream'):
1365 if hasattr(stats,'stream'):
1361 # In newer versions of python, the stats object has a 'stream'
1366 # In newer versions of python, the stats object has a 'stream'
1362 # attribute to write into.
1367 # attribute to write into.
1363 stats.stream = stdout_trap
1368 stats.stream = stdout_trap
1364 stats.print_stats(*lims)
1369 stats.print_stats(*lims)
1365 else:
1370 else:
1366 # For older versions, we manually redirect stdout during printing
1371 # For older versions, we manually redirect stdout during printing
1367 sys_stdout = sys.stdout
1372 sys_stdout = sys.stdout
1368 try:
1373 try:
1369 sys.stdout = stdout_trap
1374 sys.stdout = stdout_trap
1370 stats.print_stats(*lims)
1375 stats.print_stats(*lims)
1371 finally:
1376 finally:
1372 sys.stdout = sys_stdout
1377 sys.stdout = sys_stdout
1373
1378
1374 output = stdout_trap.getvalue()
1379 output = stdout_trap.getvalue()
1375 output = output.rstrip()
1380 output = output.rstrip()
1376
1381
1377 page(output,screen_lines=self.shell.rc.screen_length)
1382 page(output,screen_lines=self.shell.rc.screen_length)
1378 print sys_exit,
1383 print sys_exit,
1379
1384
1380 dump_file = opts.D[0]
1385 dump_file = opts.D[0]
1381 text_file = opts.T[0]
1386 text_file = opts.T[0]
1382 if dump_file:
1387 if dump_file:
1383 prof.dump_stats(dump_file)
1388 prof.dump_stats(dump_file)
1384 print '\n*** Profile stats marshalled to file',\
1389 print '\n*** Profile stats marshalled to file',\
1385 `dump_file`+'.',sys_exit
1390 `dump_file`+'.',sys_exit
1386 if text_file:
1391 if text_file:
1387 pfile = file(text_file,'w')
1392 pfile = file(text_file,'w')
1388 pfile.write(output)
1393 pfile.write(output)
1389 pfile.close()
1394 pfile.close()
1390 print '\n*** Profile printout saved to text file',\
1395 print '\n*** Profile printout saved to text file',\
1391 `text_file`+'.',sys_exit
1396 `text_file`+'.',sys_exit
1392
1397
1393 if opts.has_key('r'):
1398 if opts.has_key('r'):
1394 return stats
1399 return stats
1395 else:
1400 else:
1396 return None
1401 return None
1397
1402
1398 def magic_run(self, parameter_s ='',runner=None):
1403 def magic_run(self, parameter_s ='',runner=None):
1399 """Run the named file inside IPython as a program.
1404 """Run the named file inside IPython as a program.
1400
1405
1401 Usage:\\
1406 Usage:\\
1402 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1407 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1403
1408
1404 Parameters after the filename are passed as command-line arguments to
1409 Parameters after the filename are passed as command-line arguments to
1405 the program (put in sys.argv). Then, control returns to IPython's
1410 the program (put in sys.argv). Then, control returns to IPython's
1406 prompt.
1411 prompt.
1407
1412
1408 This is similar to running at a system prompt:\\
1413 This is similar to running at a system prompt:\\
1409 $ python file args\\
1414 $ python file args\\
1410 but with the advantage of giving you IPython's tracebacks, and of
1415 but with the advantage of giving you IPython's tracebacks, and of
1411 loading all variables into your interactive namespace for further use
1416 loading all variables into your interactive namespace for further use
1412 (unless -p is used, see below).
1417 (unless -p is used, see below).
1413
1418
1414 The file is executed in a namespace initially consisting only of
1419 The file is executed in a namespace initially consisting only of
1415 __name__=='__main__' and sys.argv constructed as indicated. It thus
1420 __name__=='__main__' and sys.argv constructed as indicated. It thus
1416 sees its environment as if it were being run as a stand-alone
1421 sees its environment as if it were being run as a stand-alone
1417 program. But after execution, the IPython interactive namespace gets
1422 program. But after execution, the IPython interactive namespace gets
1418 updated with all variables defined in the program (except for __name__
1423 updated with all variables defined in the program (except for __name__
1419 and sys.argv). This allows for very convenient loading of code for
1424 and sys.argv). This allows for very convenient loading of code for
1420 interactive work, while giving each program a 'clean sheet' to run in.
1425 interactive work, while giving each program a 'clean sheet' to run in.
1421
1426
1422 Options:
1427 Options:
1423
1428
1424 -n: __name__ is NOT set to '__main__', but to the running file's name
1429 -n: __name__ is NOT set to '__main__', but to the running file's name
1425 without extension (as python does under import). This allows running
1430 without extension (as python does under import). This allows running
1426 scripts and reloading the definitions in them without calling code
1431 scripts and reloading the definitions in them without calling code
1427 protected by an ' if __name__ == "__main__" ' clause.
1432 protected by an ' if __name__ == "__main__" ' clause.
1428
1433
1429 -i: run the file in IPython's namespace instead of an empty one. This
1434 -i: run the file in IPython's namespace instead of an empty one. This
1430 is useful if you are experimenting with code written in a text editor
1435 is useful if you are experimenting with code written in a text editor
1431 which depends on variables defined interactively.
1436 which depends on variables defined interactively.
1432
1437
1433 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1438 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1434 being run. This is particularly useful if IPython is being used to
1439 being run. This is particularly useful if IPython is being used to
1435 run unittests, which always exit with a sys.exit() call. In such
1440 run unittests, which always exit with a sys.exit() call. In such
1436 cases you are interested in the output of the test results, not in
1441 cases you are interested in the output of the test results, not in
1437 seeing a traceback of the unittest module.
1442 seeing a traceback of the unittest module.
1438
1443
1439 -t: print timing information at the end of the run. IPython will give
1444 -t: print timing information at the end of the run. IPython will give
1440 you an estimated CPU time consumption for your script, which under
1445 you an estimated CPU time consumption for your script, which under
1441 Unix uses the resource module to avoid the wraparound problems of
1446 Unix uses the resource module to avoid the wraparound problems of
1442 time.clock(). Under Unix, an estimate of time spent on system tasks
1447 time.clock(). Under Unix, an estimate of time spent on system tasks
1443 is also given (for Windows platforms this is reported as 0.0).
1448 is also given (for Windows platforms this is reported as 0.0).
1444
1449
1445 If -t is given, an additional -N<N> option can be given, where <N>
1450 If -t is given, an additional -N<N> option can be given, where <N>
1446 must be an integer indicating how many times you want the script to
1451 must be an integer indicating how many times you want the script to
1447 run. The final timing report will include total and per run results.
1452 run. The final timing report will include total and per run results.
1448
1453
1449 For example (testing the script uniq_stable.py):
1454 For example (testing the script uniq_stable.py):
1450
1455
1451 In [1]: run -t uniq_stable
1456 In [1]: run -t uniq_stable
1452
1457
1453 IPython CPU timings (estimated):\\
1458 IPython CPU timings (estimated):\\
1454 User : 0.19597 s.\\
1459 User : 0.19597 s.\\
1455 System: 0.0 s.\\
1460 System: 0.0 s.\\
1456
1461
1457 In [2]: run -t -N5 uniq_stable
1462 In [2]: run -t -N5 uniq_stable
1458
1463
1459 IPython CPU timings (estimated):\\
1464 IPython CPU timings (estimated):\\
1460 Total runs performed: 5\\
1465 Total runs performed: 5\\
1461 Times : Total Per run\\
1466 Times : Total Per run\\
1462 User : 0.910862 s, 0.1821724 s.\\
1467 User : 0.910862 s, 0.1821724 s.\\
1463 System: 0.0 s, 0.0 s.
1468 System: 0.0 s, 0.0 s.
1464
1469
1465 -d: run your program under the control of pdb, the Python debugger.
1470 -d: run your program under the control of pdb, the Python debugger.
1466 This allows you to execute your program step by step, watch variables,
1471 This allows you to execute your program step by step, watch variables,
1467 etc. Internally, what IPython does is similar to calling:
1472 etc. Internally, what IPython does is similar to calling:
1468
1473
1469 pdb.run('execfile("YOURFILENAME")')
1474 pdb.run('execfile("YOURFILENAME")')
1470
1475
1471 with a breakpoint set on line 1 of your file. You can change the line
1476 with a breakpoint set on line 1 of your file. You can change the line
1472 number for this automatic breakpoint to be <N> by using the -bN option
1477 number for this automatic breakpoint to be <N> by using the -bN option
1473 (where N must be an integer). For example:
1478 (where N must be an integer). For example:
1474
1479
1475 %run -d -b40 myscript
1480 %run -d -b40 myscript
1476
1481
1477 will set the first breakpoint at line 40 in myscript.py. Note that
1482 will set the first breakpoint at line 40 in myscript.py. Note that
1478 the first breakpoint must be set on a line which actually does
1483 the first breakpoint must be set on a line which actually does
1479 something (not a comment or docstring) for it to stop execution.
1484 something (not a comment or docstring) for it to stop execution.
1480
1485
1481 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1486 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1482 first enter 'c' (without qoutes) to start execution up to the first
1487 first enter 'c' (without qoutes) to start execution up to the first
1483 breakpoint.
1488 breakpoint.
1484
1489
1485 Entering 'help' gives information about the use of the debugger. You
1490 Entering 'help' gives information about the use of the debugger. You
1486 can easily see pdb's full documentation with "import pdb;pdb.help()"
1491 can easily see pdb's full documentation with "import pdb;pdb.help()"
1487 at a prompt.
1492 at a prompt.
1488
1493
1489 -p: run program under the control of the Python profiler module (which
1494 -p: run program under the control of the Python profiler module (which
1490 prints a detailed report of execution times, function calls, etc).
1495 prints a detailed report of execution times, function calls, etc).
1491
1496
1492 You can pass other options after -p which affect the behavior of the
1497 You can pass other options after -p which affect the behavior of the
1493 profiler itself. See the docs for %prun for details.
1498 profiler itself. See the docs for %prun for details.
1494
1499
1495 In this mode, the program's variables do NOT propagate back to the
1500 In this mode, the program's variables do NOT propagate back to the
1496 IPython interactive namespace (because they remain in the namespace
1501 IPython interactive namespace (because they remain in the namespace
1497 where the profiler executes them).
1502 where the profiler executes them).
1498
1503
1499 Internally this triggers a call to %prun, see its documentation for
1504 Internally this triggers a call to %prun, see its documentation for
1500 details on the options available specifically for profiling.
1505 details on the options available specifically for profiling.
1501
1506
1502 There is one special usage for which the text above doesn't apply:
1507 There is one special usage for which the text above doesn't apply:
1503 if the filename ends with .ipy, the file is run as ipython script,
1508 if the filename ends with .ipy, the file is run as ipython script,
1504 just as if the commands were written on IPython prompt.
1509 just as if the commands were written on IPython prompt.
1505 """
1510 """
1506
1511
1507 # get arguments and set sys.argv for program to be run.
1512 # get arguments and set sys.argv for program to be run.
1508 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1513 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1509 mode='list',list_all=1)
1514 mode='list',list_all=1)
1510
1515
1511 try:
1516 try:
1512 filename = get_py_filename(arg_lst[0])
1517 filename = get_py_filename(arg_lst[0])
1513 except IndexError:
1518 except IndexError:
1514 warn('you must provide at least a filename.')
1519 warn('you must provide at least a filename.')
1515 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1520 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1516 return
1521 return
1517 except IOError,msg:
1522 except IOError,msg:
1518 error(msg)
1523 error(msg)
1519 return
1524 return
1520
1525
1521 if filename.lower().endswith('.ipy'):
1526 if filename.lower().endswith('.ipy'):
1522 self.api.runlines(open(filename).read())
1527 self.api.runlines(open(filename).read())
1523 return
1528 return
1524
1529
1525 # Control the response to exit() calls made by the script being run
1530 # Control the response to exit() calls made by the script being run
1526 exit_ignore = opts.has_key('e')
1531 exit_ignore = opts.has_key('e')
1527
1532
1528 # Make sure that the running script gets a proper sys.argv as if it
1533 # Make sure that the running script gets a proper sys.argv as if it
1529 # were run from a system shell.
1534 # were run from a system shell.
1530 save_argv = sys.argv # save it for later restoring
1535 save_argv = sys.argv # save it for later restoring
1531 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1536 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1532
1537
1533 if opts.has_key('i'):
1538 if opts.has_key('i'):
1534 prog_ns = self.shell.user_ns
1539 prog_ns = self.shell.user_ns
1535 __name__save = self.shell.user_ns['__name__']
1540 __name__save = self.shell.user_ns['__name__']
1536 prog_ns['__name__'] = '__main__'
1541 prog_ns['__name__'] = '__main__'
1537 else:
1542 else:
1538 if opts.has_key('n'):
1543 if opts.has_key('n'):
1539 name = os.path.splitext(os.path.basename(filename))[0]
1544 name = os.path.splitext(os.path.basename(filename))[0]
1540 else:
1545 else:
1541 name = '__main__'
1546 name = '__main__'
1542 prog_ns = {'__name__':name}
1547 prog_ns = {'__name__':name}
1543
1548
1544 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
1549 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
1545 # set the __file__ global in the script's namespace
1550 # set the __file__ global in the script's namespace
1546 prog_ns['__file__'] = filename
1551 prog_ns['__file__'] = filename
1547
1552
1548 # pickle fix. See iplib for an explanation. But we need to make sure
1553 # pickle fix. See iplib for an explanation. But we need to make sure
1549 # that, if we overwrite __main__, we replace it at the end
1554 # that, if we overwrite __main__, we replace it at the end
1550 if prog_ns['__name__'] == '__main__':
1555 if prog_ns['__name__'] == '__main__':
1551 restore_main = sys.modules['__main__']
1556 restore_main = sys.modules['__main__']
1552 else:
1557 else:
1553 restore_main = False
1558 restore_main = False
1554
1559
1555 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1560 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1556
1561
1557 stats = None
1562 stats = None
1558 try:
1563 try:
1559 if self.shell.has_readline:
1564 if self.shell.has_readline:
1560 self.shell.savehist()
1565 self.shell.savehist()
1561
1566
1562 if opts.has_key('p'):
1567 if opts.has_key('p'):
1563 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1568 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1564 else:
1569 else:
1565 if opts.has_key('d'):
1570 if opts.has_key('d'):
1566 deb = Debugger.Pdb(self.shell.rc.colors)
1571 deb = Debugger.Pdb(self.shell.rc.colors)
1567 # reset Breakpoint state, which is moronically kept
1572 # reset Breakpoint state, which is moronically kept
1568 # in a class
1573 # in a class
1569 bdb.Breakpoint.next = 1
1574 bdb.Breakpoint.next = 1
1570 bdb.Breakpoint.bplist = {}
1575 bdb.Breakpoint.bplist = {}
1571 bdb.Breakpoint.bpbynumber = [None]
1576 bdb.Breakpoint.bpbynumber = [None]
1572 # Set an initial breakpoint to stop execution
1577 # Set an initial breakpoint to stop execution
1573 maxtries = 10
1578 maxtries = 10
1574 bp = int(opts.get('b',[1])[0])
1579 bp = int(opts.get('b',[1])[0])
1575 checkline = deb.checkline(filename,bp)
1580 checkline = deb.checkline(filename,bp)
1576 if not checkline:
1581 if not checkline:
1577 for bp in range(bp+1,bp+maxtries+1):
1582 for bp in range(bp+1,bp+maxtries+1):
1578 if deb.checkline(filename,bp):
1583 if deb.checkline(filename,bp):
1579 break
1584 break
1580 else:
1585 else:
1581 msg = ("\nI failed to find a valid line to set "
1586 msg = ("\nI failed to find a valid line to set "
1582 "a breakpoint\n"
1587 "a breakpoint\n"
1583 "after trying up to line: %s.\n"
1588 "after trying up to line: %s.\n"
1584 "Please set a valid breakpoint manually "
1589 "Please set a valid breakpoint manually "
1585 "with the -b option." % bp)
1590 "with the -b option." % bp)
1586 error(msg)
1591 error(msg)
1587 return
1592 return
1588 # if we find a good linenumber, set the breakpoint
1593 # if we find a good linenumber, set the breakpoint
1589 deb.do_break('%s:%s' % (filename,bp))
1594 deb.do_break('%s:%s' % (filename,bp))
1590 # Start file run
1595 # Start file run
1591 print "NOTE: Enter 'c' at the",
1596 print "NOTE: Enter 'c' at the",
1592 print "%s prompt to start your script." % deb.prompt
1597 print "%s prompt to start your script." % deb.prompt
1593 try:
1598 try:
1594 deb.run('execfile("%s")' % filename,prog_ns)
1599 deb.run('execfile("%s")' % filename,prog_ns)
1595
1600
1596 except:
1601 except:
1597 etype, value, tb = sys.exc_info()
1602 etype, value, tb = sys.exc_info()
1598 # Skip three frames in the traceback: the %run one,
1603 # Skip three frames in the traceback: the %run one,
1599 # one inside bdb.py, and the command-line typed by the
1604 # one inside bdb.py, and the command-line typed by the
1600 # user (run by exec in pdb itself).
1605 # user (run by exec in pdb itself).
1601 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1606 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1602 else:
1607 else:
1603 if runner is None:
1608 if runner is None:
1604 runner = self.shell.safe_execfile
1609 runner = self.shell.safe_execfile
1605 if opts.has_key('t'):
1610 if opts.has_key('t'):
1606 try:
1611 try:
1607 nruns = int(opts['N'][0])
1612 nruns = int(opts['N'][0])
1608 if nruns < 1:
1613 if nruns < 1:
1609 error('Number of runs must be >=1')
1614 error('Number of runs must be >=1')
1610 return
1615 return
1611 except (KeyError):
1616 except (KeyError):
1612 nruns = 1
1617 nruns = 1
1613 if nruns == 1:
1618 if nruns == 1:
1614 t0 = clock2()
1619 t0 = clock2()
1615 runner(filename,prog_ns,prog_ns,
1620 runner(filename,prog_ns,prog_ns,
1616 exit_ignore=exit_ignore)
1621 exit_ignore=exit_ignore)
1617 t1 = clock2()
1622 t1 = clock2()
1618 t_usr = t1[0]-t0[0]
1623 t_usr = t1[0]-t0[0]
1619 t_sys = t1[1]-t1[1]
1624 t_sys = t1[1]-t1[1]
1620 print "\nIPython CPU timings (estimated):"
1625 print "\nIPython CPU timings (estimated):"
1621 print " User : %10s s." % t_usr
1626 print " User : %10s s." % t_usr
1622 print " System: %10s s." % t_sys
1627 print " System: %10s s." % t_sys
1623 else:
1628 else:
1624 runs = range(nruns)
1629 runs = range(nruns)
1625 t0 = clock2()
1630 t0 = clock2()
1626 for nr in runs:
1631 for nr in runs:
1627 runner(filename,prog_ns,prog_ns,
1632 runner(filename,prog_ns,prog_ns,
1628 exit_ignore=exit_ignore)
1633 exit_ignore=exit_ignore)
1629 t1 = clock2()
1634 t1 = clock2()
1630 t_usr = t1[0]-t0[0]
1635 t_usr = t1[0]-t0[0]
1631 t_sys = t1[1]-t1[1]
1636 t_sys = t1[1]-t1[1]
1632 print "\nIPython CPU timings (estimated):"
1637 print "\nIPython CPU timings (estimated):"
1633 print "Total runs performed:",nruns
1638 print "Total runs performed:",nruns
1634 print " Times : %10s %10s" % ('Total','Per run')
1639 print " Times : %10s %10s" % ('Total','Per run')
1635 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1640 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1636 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1641 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1637
1642
1638 else:
1643 else:
1639 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1644 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1640 if opts.has_key('i'):
1645 if opts.has_key('i'):
1641 self.shell.user_ns['__name__'] = __name__save
1646 self.shell.user_ns['__name__'] = __name__save
1642 else:
1647 else:
1643 # update IPython interactive namespace
1648 # update IPython interactive namespace
1644 del prog_ns['__name__']
1649 del prog_ns['__name__']
1645 self.shell.user_ns.update(prog_ns)
1650 self.shell.user_ns.update(prog_ns)
1646 finally:
1651 finally:
1647 sys.argv = save_argv
1652 sys.argv = save_argv
1648 if restore_main:
1653 if restore_main:
1649 sys.modules['__main__'] = restore_main
1654 sys.modules['__main__'] = restore_main
1650 if self.shell.has_readline:
1655 if self.shell.has_readline:
1651 self.shell.readline.read_history_file(self.shell.histfile)
1656 self.shell.readline.read_history_file(self.shell.histfile)
1652
1657
1653 return stats
1658 return stats
1654
1659
1655 def magic_runlog(self, parameter_s =''):
1660 def magic_runlog(self, parameter_s =''):
1656 """Run files as logs.
1661 """Run files as logs.
1657
1662
1658 Usage:\\
1663 Usage:\\
1659 %runlog file1 file2 ...
1664 %runlog file1 file2 ...
1660
1665
1661 Run the named files (treating them as log files) in sequence inside
1666 Run the named files (treating them as log files) in sequence inside
1662 the interpreter, and return to the prompt. This is much slower than
1667 the interpreter, and return to the prompt. This is much slower than
1663 %run because each line is executed in a try/except block, but it
1668 %run because each line is executed in a try/except block, but it
1664 allows running files with syntax errors in them.
1669 allows running files with syntax errors in them.
1665
1670
1666 Normally IPython will guess when a file is one of its own logfiles, so
1671 Normally IPython will guess when a file is one of its own logfiles, so
1667 you can typically use %run even for logs. This shorthand allows you to
1672 you can typically use %run even for logs. This shorthand allows you to
1668 force any file to be treated as a log file."""
1673 force any file to be treated as a log file."""
1669
1674
1670 for f in parameter_s.split():
1675 for f in parameter_s.split():
1671 self.shell.safe_execfile(f,self.shell.user_ns,
1676 self.shell.safe_execfile(f,self.shell.user_ns,
1672 self.shell.user_ns,islog=1)
1677 self.shell.user_ns,islog=1)
1673
1678
1674 def magic_timeit(self, parameter_s =''):
1679 def magic_timeit(self, parameter_s =''):
1675 """Time execution of a Python statement or expression
1680 """Time execution of a Python statement or expression
1676
1681
1677 Usage:\\
1682 Usage:\\
1678 %timeit [-n<N> -r<R> [-t|-c]] statement
1683 %timeit [-n<N> -r<R> [-t|-c]] statement
1679
1684
1680 Time execution of a Python statement or expression using the timeit
1685 Time execution of a Python statement or expression using the timeit
1681 module.
1686 module.
1682
1687
1683 Options:
1688 Options:
1684 -n<N>: execute the given statement <N> times in a loop. If this value
1689 -n<N>: execute the given statement <N> times in a loop. If this value
1685 is not given, a fitting value is chosen.
1690 is not given, a fitting value is chosen.
1686
1691
1687 -r<R>: repeat the loop iteration <R> times and take the best result.
1692 -r<R>: repeat the loop iteration <R> times and take the best result.
1688 Default: 3
1693 Default: 3
1689
1694
1690 -t: use time.time to measure the time, which is the default on Unix.
1695 -t: use time.time to measure the time, which is the default on Unix.
1691 This function measures wall time.
1696 This function measures wall time.
1692
1697
1693 -c: use time.clock to measure the time, which is the default on
1698 -c: use time.clock to measure the time, which is the default on
1694 Windows and measures wall time. On Unix, resource.getrusage is used
1699 Windows and measures wall time. On Unix, resource.getrusage is used
1695 instead and returns the CPU user time.
1700 instead and returns the CPU user time.
1696
1701
1697 -p<P>: use a precision of <P> digits to display the timing result.
1702 -p<P>: use a precision of <P> digits to display the timing result.
1698 Default: 3
1703 Default: 3
1699
1704
1700
1705
1701 Examples:\\
1706 Examples:\\
1702 In [1]: %timeit pass
1707 In [1]: %timeit pass
1703 10000000 loops, best of 3: 53.3 ns per loop
1708 10000000 loops, best of 3: 53.3 ns per loop
1704
1709
1705 In [2]: u = None
1710 In [2]: u = None
1706
1711
1707 In [3]: %timeit u is None
1712 In [3]: %timeit u is None
1708 10000000 loops, best of 3: 184 ns per loop
1713 10000000 loops, best of 3: 184 ns per loop
1709
1714
1710 In [4]: %timeit -r 4 u == None
1715 In [4]: %timeit -r 4 u == None
1711 1000000 loops, best of 4: 242 ns per loop
1716 1000000 loops, best of 4: 242 ns per loop
1712
1717
1713 In [5]: import time
1718 In [5]: import time
1714
1719
1715 In [6]: %timeit -n1 time.sleep(2)
1720 In [6]: %timeit -n1 time.sleep(2)
1716 1 loops, best of 3: 2 s per loop
1721 1 loops, best of 3: 2 s per loop
1717
1722
1718
1723
1719 The times reported by %timeit will be slightly higher than those
1724 The times reported by %timeit will be slightly higher than those
1720 reported by the timeit.py script when variables are accessed. This is
1725 reported by the timeit.py script when variables are accessed. This is
1721 due to the fact that %timeit executes the statement in the namespace
1726 due to the fact that %timeit executes the statement in the namespace
1722 of the shell, compared with timeit.py, which uses a single setup
1727 of the shell, compared with timeit.py, which uses a single setup
1723 statement to import function or create variables. Generally, the bias
1728 statement to import function or create variables. Generally, the bias
1724 does not matter as long as results from timeit.py are not mixed with
1729 does not matter as long as results from timeit.py are not mixed with
1725 those from %timeit."""
1730 those from %timeit."""
1726
1731
1727 import timeit
1732 import timeit
1728 import math
1733 import math
1729
1734
1730 units = ["s", "ms", "\xc2\xb5s", "ns"]
1735 units = ["s", "ms", "\xc2\xb5s", "ns"]
1731 scaling = [1, 1e3, 1e6, 1e9]
1736 scaling = [1, 1e3, 1e6, 1e9]
1732
1737
1733 opts, stmt = self.parse_options(parameter_s,'n:r:tcp:',
1738 opts, stmt = self.parse_options(parameter_s,'n:r:tcp:',
1734 posix=False)
1739 posix=False)
1735 if stmt == "":
1740 if stmt == "":
1736 return
1741 return
1737 timefunc = timeit.default_timer
1742 timefunc = timeit.default_timer
1738 number = int(getattr(opts, "n", 0))
1743 number = int(getattr(opts, "n", 0))
1739 repeat = int(getattr(opts, "r", timeit.default_repeat))
1744 repeat = int(getattr(opts, "r", timeit.default_repeat))
1740 precision = int(getattr(opts, "p", 3))
1745 precision = int(getattr(opts, "p", 3))
1741 if hasattr(opts, "t"):
1746 if hasattr(opts, "t"):
1742 timefunc = time.time
1747 timefunc = time.time
1743 if hasattr(opts, "c"):
1748 if hasattr(opts, "c"):
1744 timefunc = clock
1749 timefunc = clock
1745
1750
1746 timer = timeit.Timer(timer=timefunc)
1751 timer = timeit.Timer(timer=timefunc)
1747 # this code has tight coupling to the inner workings of timeit.Timer,
1752 # this code has tight coupling to the inner workings of timeit.Timer,
1748 # but is there a better way to achieve that the code stmt has access
1753 # but is there a better way to achieve that the code stmt has access
1749 # to the shell namespace?
1754 # to the shell namespace?
1750
1755
1751 src = timeit.template % {'stmt': timeit.reindent(stmt, 8),
1756 src = timeit.template % {'stmt': timeit.reindent(stmt, 8),
1752 'setup': "pass"}
1757 'setup': "pass"}
1753 code = compile(src, "<magic-timeit>", "exec")
1758 code = compile(src, "<magic-timeit>", "exec")
1754 ns = {}
1759 ns = {}
1755 exec code in self.shell.user_ns, ns
1760 exec code in self.shell.user_ns, ns
1756 timer.inner = ns["inner"]
1761 timer.inner = ns["inner"]
1757
1762
1758 if number == 0:
1763 if number == 0:
1759 # determine number so that 0.2 <= total time < 2.0
1764 # determine number so that 0.2 <= total time < 2.0
1760 number = 1
1765 number = 1
1761 for i in range(1, 10):
1766 for i in range(1, 10):
1762 number *= 10
1767 number *= 10
1763 if timer.timeit(number) >= 0.2:
1768 if timer.timeit(number) >= 0.2:
1764 break
1769 break
1765
1770
1766 best = min(timer.repeat(repeat, number)) / number
1771 best = min(timer.repeat(repeat, number)) / number
1767
1772
1768 if best > 0.0:
1773 if best > 0.0:
1769 order = min(-int(math.floor(math.log10(best)) // 3), 3)
1774 order = min(-int(math.floor(math.log10(best)) // 3), 3)
1770 else:
1775 else:
1771 order = 3
1776 order = 3
1772 print "%d loops, best of %d: %.*g %s per loop" % (number, repeat,
1777 print "%d loops, best of %d: %.*g %s per loop" % (number, repeat,
1773 precision,
1778 precision,
1774 best * scaling[order],
1779 best * scaling[order],
1775 units[order])
1780 units[order])
1776
1781
1777 def magic_time(self,parameter_s = ''):
1782 def magic_time(self,parameter_s = ''):
1778 """Time execution of a Python statement or expression.
1783 """Time execution of a Python statement or expression.
1779
1784
1780 The CPU and wall clock times are printed, and the value of the
1785 The CPU and wall clock times are printed, and the value of the
1781 expression (if any) is returned. Note that under Win32, system time
1786 expression (if any) is returned. Note that under Win32, system time
1782 is always reported as 0, since it can not be measured.
1787 is always reported as 0, since it can not be measured.
1783
1788
1784 This function provides very basic timing functionality. In Python
1789 This function provides very basic timing functionality. In Python
1785 2.3, the timeit module offers more control and sophistication, so this
1790 2.3, the timeit module offers more control and sophistication, so this
1786 could be rewritten to use it (patches welcome).
1791 could be rewritten to use it (patches welcome).
1787
1792
1788 Some examples:
1793 Some examples:
1789
1794
1790 In [1]: time 2**128
1795 In [1]: time 2**128
1791 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1796 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1792 Wall time: 0.00
1797 Wall time: 0.00
1793 Out[1]: 340282366920938463463374607431768211456L
1798 Out[1]: 340282366920938463463374607431768211456L
1794
1799
1795 In [2]: n = 1000000
1800 In [2]: n = 1000000
1796
1801
1797 In [3]: time sum(range(n))
1802 In [3]: time sum(range(n))
1798 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1803 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1799 Wall time: 1.37
1804 Wall time: 1.37
1800 Out[3]: 499999500000L
1805 Out[3]: 499999500000L
1801
1806
1802 In [4]: time print 'hello world'
1807 In [4]: time print 'hello world'
1803 hello world
1808 hello world
1804 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1809 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1805 Wall time: 0.00
1810 Wall time: 0.00
1806 """
1811 """
1807
1812
1808 # fail immediately if the given expression can't be compiled
1813 # fail immediately if the given expression can't be compiled
1809 try:
1814 try:
1810 mode = 'eval'
1815 mode = 'eval'
1811 code = compile(parameter_s,'<timed eval>',mode)
1816 code = compile(parameter_s,'<timed eval>',mode)
1812 except SyntaxError:
1817 except SyntaxError:
1813 mode = 'exec'
1818 mode = 'exec'
1814 code = compile(parameter_s,'<timed exec>',mode)
1819 code = compile(parameter_s,'<timed exec>',mode)
1815 # skew measurement as little as possible
1820 # skew measurement as little as possible
1816 glob = self.shell.user_ns
1821 glob = self.shell.user_ns
1817 clk = clock2
1822 clk = clock2
1818 wtime = time.time
1823 wtime = time.time
1819 # time execution
1824 # time execution
1820 wall_st = wtime()
1825 wall_st = wtime()
1821 if mode=='eval':
1826 if mode=='eval':
1822 st = clk()
1827 st = clk()
1823 out = eval(code,glob)
1828 out = eval(code,glob)
1824 end = clk()
1829 end = clk()
1825 else:
1830 else:
1826 st = clk()
1831 st = clk()
1827 exec code in glob
1832 exec code in glob
1828 end = clk()
1833 end = clk()
1829 out = None
1834 out = None
1830 wall_end = wtime()
1835 wall_end = wtime()
1831 # Compute actual times and report
1836 # Compute actual times and report
1832 wall_time = wall_end-wall_st
1837 wall_time = wall_end-wall_st
1833 cpu_user = end[0]-st[0]
1838 cpu_user = end[0]-st[0]
1834 cpu_sys = end[1]-st[1]
1839 cpu_sys = end[1]-st[1]
1835 cpu_tot = cpu_user+cpu_sys
1840 cpu_tot = cpu_user+cpu_sys
1836 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1841 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1837 (cpu_user,cpu_sys,cpu_tot)
1842 (cpu_user,cpu_sys,cpu_tot)
1838 print "Wall time: %.2f" % wall_time
1843 print "Wall time: %.2f" % wall_time
1839 return out
1844 return out
1840
1845
1841 def magic_macro(self,parameter_s = ''):
1846 def magic_macro(self,parameter_s = ''):
1842 """Define a set of input lines as a macro for future re-execution.
1847 """Define a set of input lines as a macro for future re-execution.
1843
1848
1844 Usage:\\
1849 Usage:\\
1845 %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...
1850 %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...
1846
1851
1847 Options:
1852 Options:
1848
1853
1849 -r: use 'raw' input. By default, the 'processed' history is used,
1854 -r: use 'raw' input. By default, the 'processed' history is used,
1850 so that magics are loaded in their transformed version to valid
1855 so that magics are loaded in their transformed version to valid
1851 Python. If this option is given, the raw input as typed as the
1856 Python. If this option is given, the raw input as typed as the
1852 command line is used instead.
1857 command line is used instead.
1853
1858
1854 This will define a global variable called `name` which is a string
1859 This will define a global variable called `name` which is a string
1855 made of joining the slices and lines you specify (n1,n2,... numbers
1860 made of joining the slices and lines you specify (n1,n2,... numbers
1856 above) from your input history into a single string. This variable
1861 above) from your input history into a single string. This variable
1857 acts like an automatic function which re-executes those lines as if
1862 acts like an automatic function which re-executes those lines as if
1858 you had typed them. You just type 'name' at the prompt and the code
1863 you had typed them. You just type 'name' at the prompt and the code
1859 executes.
1864 executes.
1860
1865
1861 The notation for indicating number ranges is: n1-n2 means 'use line
1866 The notation for indicating number ranges is: n1-n2 means 'use line
1862 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1867 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1863 using the lines numbered 5,6 and 7.
1868 using the lines numbered 5,6 and 7.
1864
1869
1865 Note: as a 'hidden' feature, you can also use traditional python slice
1870 Note: as a 'hidden' feature, you can also use traditional python slice
1866 notation, where N:M means numbers N through M-1.
1871 notation, where N:M means numbers N through M-1.
1867
1872
1868 For example, if your history contains (%hist prints it):
1873 For example, if your history contains (%hist prints it):
1869
1874
1870 44: x=1\\
1875 44: x=1\\
1871 45: y=3\\
1876 45: y=3\\
1872 46: z=x+y\\
1877 46: z=x+y\\
1873 47: print x\\
1878 47: print x\\
1874 48: a=5\\
1879 48: a=5\\
1875 49: print 'x',x,'y',y\\
1880 49: print 'x',x,'y',y\\
1876
1881
1877 you can create a macro with lines 44 through 47 (included) and line 49
1882 you can create a macro with lines 44 through 47 (included) and line 49
1878 called my_macro with:
1883 called my_macro with:
1879
1884
1880 In [51]: %macro my_macro 44-47 49
1885 In [51]: %macro my_macro 44-47 49
1881
1886
1882 Now, typing `my_macro` (without quotes) will re-execute all this code
1887 Now, typing `my_macro` (without quotes) will re-execute all this code
1883 in one pass.
1888 in one pass.
1884
1889
1885 You don't need to give the line-numbers in order, and any given line
1890 You don't need to give the line-numbers in order, and any given line
1886 number can appear multiple times. You can assemble macros with any
1891 number can appear multiple times. You can assemble macros with any
1887 lines from your input history in any order.
1892 lines from your input history in any order.
1888
1893
1889 The macro is a simple object which holds its value in an attribute,
1894 The macro is a simple object which holds its value in an attribute,
1890 but IPython's display system checks for macros and executes them as
1895 but IPython's display system checks for macros and executes them as
1891 code instead of printing them when you type their name.
1896 code instead of printing them when you type their name.
1892
1897
1893 You can view a macro's contents by explicitly printing it with:
1898 You can view a macro's contents by explicitly printing it with:
1894
1899
1895 'print macro_name'.
1900 'print macro_name'.
1896
1901
1897 For one-off cases which DON'T contain magic function calls in them you
1902 For one-off cases which DON'T contain magic function calls in them you
1898 can obtain similar results by explicitly executing slices from your
1903 can obtain similar results by explicitly executing slices from your
1899 input history with:
1904 input history with:
1900
1905
1901 In [60]: exec In[44:48]+In[49]"""
1906 In [60]: exec In[44:48]+In[49]"""
1902
1907
1903 opts,args = self.parse_options(parameter_s,'r',mode='list')
1908 opts,args = self.parse_options(parameter_s,'r',mode='list')
1904 name,ranges = args[0], args[1:]
1909 name,ranges = args[0], args[1:]
1905 #print 'rng',ranges # dbg
1910 #print 'rng',ranges # dbg
1906 lines = self.extract_input_slices(ranges,opts.has_key('r'))
1911 lines = self.extract_input_slices(ranges,opts.has_key('r'))
1907 macro = Macro(lines)
1912 macro = Macro(lines)
1908 self.shell.user_ns.update({name:macro})
1913 self.shell.user_ns.update({name:macro})
1909 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1914 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1910 print 'Macro contents:'
1915 print 'Macro contents:'
1911 print macro,
1916 print macro,
1912
1917
1913 def magic_save(self,parameter_s = ''):
1918 def magic_save(self,parameter_s = ''):
1914 """Save a set of lines to a given filename.
1919 """Save a set of lines to a given filename.
1915
1920
1916 Usage:\\
1921 Usage:\\
1917 %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...
1922 %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...
1918
1923
1919 Options:
1924 Options:
1920
1925
1921 -r: use 'raw' input. By default, the 'processed' history is used,
1926 -r: use 'raw' input. By default, the 'processed' history is used,
1922 so that magics are loaded in their transformed version to valid
1927 so that magics are loaded in their transformed version to valid
1923 Python. If this option is given, the raw input as typed as the
1928 Python. If this option is given, the raw input as typed as the
1924 command line is used instead.
1929 command line is used instead.
1925
1930
1926 This function uses the same syntax as %macro for line extraction, but
1931 This function uses the same syntax as %macro for line extraction, but
1927 instead of creating a macro it saves the resulting string to the
1932 instead of creating a macro it saves the resulting string to the
1928 filename you specify.
1933 filename you specify.
1929
1934
1930 It adds a '.py' extension to the file if you don't do so yourself, and
1935 It adds a '.py' extension to the file if you don't do so yourself, and
1931 it asks for confirmation before overwriting existing files."""
1936 it asks for confirmation before overwriting existing files."""
1932
1937
1933 opts,args = self.parse_options(parameter_s,'r',mode='list')
1938 opts,args = self.parse_options(parameter_s,'r',mode='list')
1934 fname,ranges = args[0], args[1:]
1939 fname,ranges = args[0], args[1:]
1935 if not fname.endswith('.py'):
1940 if not fname.endswith('.py'):
1936 fname += '.py'
1941 fname += '.py'
1937 if os.path.isfile(fname):
1942 if os.path.isfile(fname):
1938 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1943 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1939 if ans.lower() not in ['y','yes']:
1944 if ans.lower() not in ['y','yes']:
1940 print 'Operation cancelled.'
1945 print 'Operation cancelled.'
1941 return
1946 return
1942 cmds = ''.join(self.extract_input_slices(ranges,opts.has_key('r')))
1947 cmds = ''.join(self.extract_input_slices(ranges,opts.has_key('r')))
1943 f = file(fname,'w')
1948 f = file(fname,'w')
1944 f.write(cmds)
1949 f.write(cmds)
1945 f.close()
1950 f.close()
1946 print 'The following commands were written to file `%s`:' % fname
1951 print 'The following commands were written to file `%s`:' % fname
1947 print cmds
1952 print cmds
1948
1953
1949 def _edit_macro(self,mname,macro):
1954 def _edit_macro(self,mname,macro):
1950 """open an editor with the macro data in a file"""
1955 """open an editor with the macro data in a file"""
1951 filename = self.shell.mktempfile(macro.value)
1956 filename = self.shell.mktempfile(macro.value)
1952 self.shell.hooks.editor(filename)
1957 self.shell.hooks.editor(filename)
1953
1958
1954 # and make a new macro object, to replace the old one
1959 # and make a new macro object, to replace the old one
1955 mfile = open(filename)
1960 mfile = open(filename)
1956 mvalue = mfile.read()
1961 mvalue = mfile.read()
1957 mfile.close()
1962 mfile.close()
1958 self.shell.user_ns[mname] = Macro(mvalue)
1963 self.shell.user_ns[mname] = Macro(mvalue)
1959
1964
1960 def magic_ed(self,parameter_s=''):
1965 def magic_ed(self,parameter_s=''):
1961 """Alias to %edit."""
1966 """Alias to %edit."""
1962 return self.magic_edit(parameter_s)
1967 return self.magic_edit(parameter_s)
1963
1968
1964 def magic_edit(self,parameter_s='',last_call=['','']):
1969 def magic_edit(self,parameter_s='',last_call=['','']):
1965 """Bring up an editor and execute the resulting code.
1970 """Bring up an editor and execute the resulting code.
1966
1971
1967 Usage:
1972 Usage:
1968 %edit [options] [args]
1973 %edit [options] [args]
1969
1974
1970 %edit runs IPython's editor hook. The default version of this hook is
1975 %edit runs IPython's editor hook. The default version of this hook is
1971 set to call the __IPYTHON__.rc.editor command. This is read from your
1976 set to call the __IPYTHON__.rc.editor command. This is read from your
1972 environment variable $EDITOR. If this isn't found, it will default to
1977 environment variable $EDITOR. If this isn't found, it will default to
1973 vi under Linux/Unix and to notepad under Windows. See the end of this
1978 vi under Linux/Unix and to notepad under Windows. See the end of this
1974 docstring for how to change the editor hook.
1979 docstring for how to change the editor hook.
1975
1980
1976 You can also set the value of this editor via the command line option
1981 You can also set the value of this editor via the command line option
1977 '-editor' or in your ipythonrc file. This is useful if you wish to use
1982 '-editor' or in your ipythonrc file. This is useful if you wish to use
1978 specifically for IPython an editor different from your typical default
1983 specifically for IPython an editor different from your typical default
1979 (and for Windows users who typically don't set environment variables).
1984 (and for Windows users who typically don't set environment variables).
1980
1985
1981 This command allows you to conveniently edit multi-line code right in
1986 This command allows you to conveniently edit multi-line code right in
1982 your IPython session.
1987 your IPython session.
1983
1988
1984 If called without arguments, %edit opens up an empty editor with a
1989 If called without arguments, %edit opens up an empty editor with a
1985 temporary file and will execute the contents of this file when you
1990 temporary file and will execute the contents of this file when you
1986 close it (don't forget to save it!).
1991 close it (don't forget to save it!).
1987
1992
1988
1993
1989 Options:
1994 Options:
1990
1995
1991 -n <number>: open the editor at a specified line number. By default,
1996 -n <number>: open the editor at a specified line number. By default,
1992 the IPython editor hook uses the unix syntax 'editor +N filename', but
1997 the IPython editor hook uses the unix syntax 'editor +N filename', but
1993 you can configure this by providing your own modified hook if your
1998 you can configure this by providing your own modified hook if your
1994 favorite editor supports line-number specifications with a different
1999 favorite editor supports line-number specifications with a different
1995 syntax.
2000 syntax.
1996
2001
1997 -p: this will call the editor with the same data as the previous time
2002 -p: this will call the editor with the same data as the previous time
1998 it was used, regardless of how long ago (in your current session) it
2003 it was used, regardless of how long ago (in your current session) it
1999 was.
2004 was.
2000
2005
2001 -r: use 'raw' input. This option only applies to input taken from the
2006 -r: use 'raw' input. This option only applies to input taken from the
2002 user's history. By default, the 'processed' history is used, so that
2007 user's history. By default, the 'processed' history is used, so that
2003 magics are loaded in their transformed version to valid Python. If
2008 magics are loaded in their transformed version to valid Python. If
2004 this option is given, the raw input as typed as the command line is
2009 this option is given, the raw input as typed as the command line is
2005 used instead. When you exit the editor, it will be executed by
2010 used instead. When you exit the editor, it will be executed by
2006 IPython's own processor.
2011 IPython's own processor.
2007
2012
2008 -x: do not execute the edited code immediately upon exit. This is
2013 -x: do not execute the edited code immediately upon exit. This is
2009 mainly useful if you are editing programs which need to be called with
2014 mainly useful if you are editing programs which need to be called with
2010 command line arguments, which you can then do using %run.
2015 command line arguments, which you can then do using %run.
2011
2016
2012
2017
2013 Arguments:
2018 Arguments:
2014
2019
2015 If arguments are given, the following possibilites exist:
2020 If arguments are given, the following possibilites exist:
2016
2021
2017 - The arguments are numbers or pairs of colon-separated numbers (like
2022 - The arguments are numbers or pairs of colon-separated numbers (like
2018 1 4:8 9). These are interpreted as lines of previous input to be
2023 1 4:8 9). These are interpreted as lines of previous input to be
2019 loaded into the editor. The syntax is the same of the %macro command.
2024 loaded into the editor. The syntax is the same of the %macro command.
2020
2025
2021 - If the argument doesn't start with a number, it is evaluated as a
2026 - If the argument doesn't start with a number, it is evaluated as a
2022 variable and its contents loaded into the editor. You can thus edit
2027 variable and its contents loaded into the editor. You can thus edit
2023 any string which contains python code (including the result of
2028 any string which contains python code (including the result of
2024 previous edits).
2029 previous edits).
2025
2030
2026 - If the argument is the name of an object (other than a string),
2031 - If the argument is the name of an object (other than a string),
2027 IPython will try to locate the file where it was defined and open the
2032 IPython will try to locate the file where it was defined and open the
2028 editor at the point where it is defined. You can use `%edit function`
2033 editor at the point where it is defined. You can use `%edit function`
2029 to load an editor exactly at the point where 'function' is defined,
2034 to load an editor exactly at the point where 'function' is defined,
2030 edit it and have the file be executed automatically.
2035 edit it and have the file be executed automatically.
2031
2036
2032 If the object is a macro (see %macro for details), this opens up your
2037 If the object is a macro (see %macro for details), this opens up your
2033 specified editor with a temporary file containing the macro's data.
2038 specified editor with a temporary file containing the macro's data.
2034 Upon exit, the macro is reloaded with the contents of the file.
2039 Upon exit, the macro is reloaded with the contents of the file.
2035
2040
2036 Note: opening at an exact line is only supported under Unix, and some
2041 Note: opening at an exact line is only supported under Unix, and some
2037 editors (like kedit and gedit up to Gnome 2.8) do not understand the
2042 editors (like kedit and gedit up to Gnome 2.8) do not understand the
2038 '+NUMBER' parameter necessary for this feature. Good editors like
2043 '+NUMBER' parameter necessary for this feature. Good editors like
2039 (X)Emacs, vi, jed, pico and joe all do.
2044 (X)Emacs, vi, jed, pico and joe all do.
2040
2045
2041 - If the argument is not found as a variable, IPython will look for a
2046 - If the argument is not found as a variable, IPython will look for a
2042 file with that name (adding .py if necessary) and load it into the
2047 file with that name (adding .py if necessary) and load it into the
2043 editor. It will execute its contents with execfile() when you exit,
2048 editor. It will execute its contents with execfile() when you exit,
2044 loading any code in the file into your interactive namespace.
2049 loading any code in the file into your interactive namespace.
2045
2050
2046 After executing your code, %edit will return as output the code you
2051 After executing your code, %edit will return as output the code you
2047 typed in the editor (except when it was an existing file). This way
2052 typed in the editor (except when it was an existing file). This way
2048 you can reload the code in further invocations of %edit as a variable,
2053 you can reload the code in further invocations of %edit as a variable,
2049 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
2054 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
2050 the output.
2055 the output.
2051
2056
2052 Note that %edit is also available through the alias %ed.
2057 Note that %edit is also available through the alias %ed.
2053
2058
2054 This is an example of creating a simple function inside the editor and
2059 This is an example of creating a simple function inside the editor and
2055 then modifying it. First, start up the editor:
2060 then modifying it. First, start up the editor:
2056
2061
2057 In [1]: ed\\
2062 In [1]: ed\\
2058 Editing... done. Executing edited code...\\
2063 Editing... done. Executing edited code...\\
2059 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
2064 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
2060
2065
2061 We can then call the function foo():
2066 We can then call the function foo():
2062
2067
2063 In [2]: foo()\\
2068 In [2]: foo()\\
2064 foo() was defined in an editing session
2069 foo() was defined in an editing session
2065
2070
2066 Now we edit foo. IPython automatically loads the editor with the
2071 Now we edit foo. IPython automatically loads the editor with the
2067 (temporary) file where foo() was previously defined:
2072 (temporary) file where foo() was previously defined:
2068
2073
2069 In [3]: ed foo\\
2074 In [3]: ed foo\\
2070 Editing... done. Executing edited code...
2075 Editing... done. Executing edited code...
2071
2076
2072 And if we call foo() again we get the modified version:
2077 And if we call foo() again we get the modified version:
2073
2078
2074 In [4]: foo()\\
2079 In [4]: foo()\\
2075 foo() has now been changed!
2080 foo() has now been changed!
2076
2081
2077 Here is an example of how to edit a code snippet successive
2082 Here is an example of how to edit a code snippet successive
2078 times. First we call the editor:
2083 times. First we call the editor:
2079
2084
2080 In [8]: ed\\
2085 In [8]: ed\\
2081 Editing... done. Executing edited code...\\
2086 Editing... done. Executing edited code...\\
2082 hello\\
2087 hello\\
2083 Out[8]: "print 'hello'\\n"
2088 Out[8]: "print 'hello'\\n"
2084
2089
2085 Now we call it again with the previous output (stored in _):
2090 Now we call it again with the previous output (stored in _):
2086
2091
2087 In [9]: ed _\\
2092 In [9]: ed _\\
2088 Editing... done. Executing edited code...\\
2093 Editing... done. Executing edited code...\\
2089 hello world\\
2094 hello world\\
2090 Out[9]: "print 'hello world'\\n"
2095 Out[9]: "print 'hello world'\\n"
2091
2096
2092 Now we call it with the output #8 (stored in _8, also as Out[8]):
2097 Now we call it with the output #8 (stored in _8, also as Out[8]):
2093
2098
2094 In [10]: ed _8\\
2099 In [10]: ed _8\\
2095 Editing... done. Executing edited code...\\
2100 Editing... done. Executing edited code...\\
2096 hello again\\
2101 hello again\\
2097 Out[10]: "print 'hello again'\\n"
2102 Out[10]: "print 'hello again'\\n"
2098
2103
2099
2104
2100 Changing the default editor hook:
2105 Changing the default editor hook:
2101
2106
2102 If you wish to write your own editor hook, you can put it in a
2107 If you wish to write your own editor hook, you can put it in a
2103 configuration file which you load at startup time. The default hook
2108 configuration file which you load at startup time. The default hook
2104 is defined in the IPython.hooks module, and you can use that as a
2109 is defined in the IPython.hooks module, and you can use that as a
2105 starting example for further modifications. That file also has
2110 starting example for further modifications. That file also has
2106 general instructions on how to set a new hook for use once you've
2111 general instructions on how to set a new hook for use once you've
2107 defined it."""
2112 defined it."""
2108
2113
2109 # FIXME: This function has become a convoluted mess. It needs a
2114 # FIXME: This function has become a convoluted mess. It needs a
2110 # ground-up rewrite with clean, simple logic.
2115 # ground-up rewrite with clean, simple logic.
2111
2116
2112 def make_filename(arg):
2117 def make_filename(arg):
2113 "Make a filename from the given args"
2118 "Make a filename from the given args"
2114 try:
2119 try:
2115 filename = get_py_filename(arg)
2120 filename = get_py_filename(arg)
2116 except IOError:
2121 except IOError:
2117 if args.endswith('.py'):
2122 if args.endswith('.py'):
2118 filename = arg
2123 filename = arg
2119 else:
2124 else:
2120 filename = None
2125 filename = None
2121 return filename
2126 return filename
2122
2127
2123 # custom exceptions
2128 # custom exceptions
2124 class DataIsObject(Exception): pass
2129 class DataIsObject(Exception): pass
2125
2130
2126 opts,args = self.parse_options(parameter_s,'prxn:')
2131 opts,args = self.parse_options(parameter_s,'prxn:')
2127 # Set a few locals from the options for convenience:
2132 # Set a few locals from the options for convenience:
2128 opts_p = opts.has_key('p')
2133 opts_p = opts.has_key('p')
2129 opts_r = opts.has_key('r')
2134 opts_r = opts.has_key('r')
2130
2135
2131 # Default line number value
2136 # Default line number value
2132 lineno = opts.get('n',None)
2137 lineno = opts.get('n',None)
2133
2138
2134 if opts_p:
2139 if opts_p:
2135 args = '_%s' % last_call[0]
2140 args = '_%s' % last_call[0]
2136 if not self.shell.user_ns.has_key(args):
2141 if not self.shell.user_ns.has_key(args):
2137 args = last_call[1]
2142 args = last_call[1]
2138
2143
2139 # use last_call to remember the state of the previous call, but don't
2144 # use last_call to remember the state of the previous call, but don't
2140 # let it be clobbered by successive '-p' calls.
2145 # let it be clobbered by successive '-p' calls.
2141 try:
2146 try:
2142 last_call[0] = self.shell.outputcache.prompt_count
2147 last_call[0] = self.shell.outputcache.prompt_count
2143 if not opts_p:
2148 if not opts_p:
2144 last_call[1] = parameter_s
2149 last_call[1] = parameter_s
2145 except:
2150 except:
2146 pass
2151 pass
2147
2152
2148 # by default this is done with temp files, except when the given
2153 # by default this is done with temp files, except when the given
2149 # arg is a filename
2154 # arg is a filename
2150 use_temp = 1
2155 use_temp = 1
2151
2156
2152 if re.match(r'\d',args):
2157 if re.match(r'\d',args):
2153 # Mode where user specifies ranges of lines, like in %macro.
2158 # Mode where user specifies ranges of lines, like in %macro.
2154 # This means that you can't edit files whose names begin with
2159 # This means that you can't edit files whose names begin with
2155 # numbers this way. Tough.
2160 # numbers this way. Tough.
2156 ranges = args.split()
2161 ranges = args.split()
2157 data = ''.join(self.extract_input_slices(ranges,opts_r))
2162 data = ''.join(self.extract_input_slices(ranges,opts_r))
2158 elif args.endswith('.py'):
2163 elif args.endswith('.py'):
2159 filename = make_filename(args)
2164 filename = make_filename(args)
2160 data = ''
2165 data = ''
2161 use_temp = 0
2166 use_temp = 0
2162 elif args:
2167 elif args:
2163 try:
2168 try:
2164 # Load the parameter given as a variable. If not a string,
2169 # Load the parameter given as a variable. If not a string,
2165 # process it as an object instead (below)
2170 # process it as an object instead (below)
2166
2171
2167 #print '*** args',args,'type',type(args) # dbg
2172 #print '*** args',args,'type',type(args) # dbg
2168 data = eval(args,self.shell.user_ns)
2173 data = eval(args,self.shell.user_ns)
2169 if not type(data) in StringTypes:
2174 if not type(data) in StringTypes:
2170 raise DataIsObject
2175 raise DataIsObject
2171
2176
2172 except (NameError,SyntaxError):
2177 except (NameError,SyntaxError):
2173 # given argument is not a variable, try as a filename
2178 # given argument is not a variable, try as a filename
2174 filename = make_filename(args)
2179 filename = make_filename(args)
2175 if filename is None:
2180 if filename is None:
2176 warn("Argument given (%s) can't be found as a variable "
2181 warn("Argument given (%s) can't be found as a variable "
2177 "or as a filename." % args)
2182 "or as a filename." % args)
2178 return
2183 return
2179
2184
2180 data = ''
2185 data = ''
2181 use_temp = 0
2186 use_temp = 0
2182 except DataIsObject:
2187 except DataIsObject:
2183
2188
2184 # macros have a special edit function
2189 # macros have a special edit function
2185 if isinstance(data,Macro):
2190 if isinstance(data,Macro):
2186 self._edit_macro(args,data)
2191 self._edit_macro(args,data)
2187 return
2192 return
2188
2193
2189 # For objects, try to edit the file where they are defined
2194 # For objects, try to edit the file where they are defined
2190 try:
2195 try:
2191 filename = inspect.getabsfile(data)
2196 filename = inspect.getabsfile(data)
2192 datafile = 1
2197 datafile = 1
2193 except TypeError:
2198 except TypeError:
2194 filename = make_filename(args)
2199 filename = make_filename(args)
2195 datafile = 1
2200 datafile = 1
2196 warn('Could not find file where `%s` is defined.\n'
2201 warn('Could not find file where `%s` is defined.\n'
2197 'Opening a file named `%s`' % (args,filename))
2202 'Opening a file named `%s`' % (args,filename))
2198 # Now, make sure we can actually read the source (if it was in
2203 # Now, make sure we can actually read the source (if it was in
2199 # a temp file it's gone by now).
2204 # a temp file it's gone by now).
2200 if datafile:
2205 if datafile:
2201 try:
2206 try:
2202 if lineno is None:
2207 if lineno is None:
2203 lineno = inspect.getsourcelines(data)[1]
2208 lineno = inspect.getsourcelines(data)[1]
2204 except IOError:
2209 except IOError:
2205 filename = make_filename(args)
2210 filename = make_filename(args)
2206 if filename is None:
2211 if filename is None:
2207 warn('The file `%s` where `%s` was defined cannot '
2212 warn('The file `%s` where `%s` was defined cannot '
2208 'be read.' % (filename,data))
2213 'be read.' % (filename,data))
2209 return
2214 return
2210 use_temp = 0
2215 use_temp = 0
2211 else:
2216 else:
2212 data = ''
2217 data = ''
2213
2218
2214 if use_temp:
2219 if use_temp:
2215 filename = self.shell.mktempfile(data)
2220 filename = self.shell.mktempfile(data)
2216 print 'IPython will make a temporary file named:',filename
2221 print 'IPython will make a temporary file named:',filename
2217
2222
2218 # do actual editing here
2223 # do actual editing here
2219 print 'Editing...',
2224 print 'Editing...',
2220 sys.stdout.flush()
2225 sys.stdout.flush()
2221 self.shell.hooks.editor(filename,lineno)
2226 self.shell.hooks.editor(filename,lineno)
2222 if opts.has_key('x'): # -x prevents actual execution
2227 if opts.has_key('x'): # -x prevents actual execution
2223 print
2228 print
2224 else:
2229 else:
2225 print 'done. Executing edited code...'
2230 print 'done. Executing edited code...'
2226 if opts_r:
2231 if opts_r:
2227 self.shell.runlines(file_read(filename))
2232 self.shell.runlines(file_read(filename))
2228 else:
2233 else:
2229 self.shell.safe_execfile(filename,self.shell.user_ns)
2234 self.shell.safe_execfile(filename,self.shell.user_ns)
2230 if use_temp:
2235 if use_temp:
2231 try:
2236 try:
2232 return open(filename).read()
2237 return open(filename).read()
2233 except IOError,msg:
2238 except IOError,msg:
2234 if msg.filename == filename:
2239 if msg.filename == filename:
2235 warn('File not found. Did you forget to save?')
2240 warn('File not found. Did you forget to save?')
2236 return
2241 return
2237 else:
2242 else:
2238 self.shell.showtraceback()
2243 self.shell.showtraceback()
2239
2244
2240 def magic_xmode(self,parameter_s = ''):
2245 def magic_xmode(self,parameter_s = ''):
2241 """Switch modes for the exception handlers.
2246 """Switch modes for the exception handlers.
2242
2247
2243 Valid modes: Plain, Context and Verbose.
2248 Valid modes: Plain, Context and Verbose.
2244
2249
2245 If called without arguments, acts as a toggle."""
2250 If called without arguments, acts as a toggle."""
2246
2251
2247 def xmode_switch_err(name):
2252 def xmode_switch_err(name):
2248 warn('Error changing %s exception modes.\n%s' %
2253 warn('Error changing %s exception modes.\n%s' %
2249 (name,sys.exc_info()[1]))
2254 (name,sys.exc_info()[1]))
2250
2255
2251 shell = self.shell
2256 shell = self.shell
2252 new_mode = parameter_s.strip().capitalize()
2257 new_mode = parameter_s.strip().capitalize()
2253 try:
2258 try:
2254 shell.InteractiveTB.set_mode(mode=new_mode)
2259 shell.InteractiveTB.set_mode(mode=new_mode)
2255 print 'Exception reporting mode:',shell.InteractiveTB.mode
2260 print 'Exception reporting mode:',shell.InteractiveTB.mode
2256 except:
2261 except:
2257 xmode_switch_err('user')
2262 xmode_switch_err('user')
2258
2263
2259 # threaded shells use a special handler in sys.excepthook
2264 # threaded shells use a special handler in sys.excepthook
2260 if shell.isthreaded:
2265 if shell.isthreaded:
2261 try:
2266 try:
2262 shell.sys_excepthook.set_mode(mode=new_mode)
2267 shell.sys_excepthook.set_mode(mode=new_mode)
2263 except:
2268 except:
2264 xmode_switch_err('threaded')
2269 xmode_switch_err('threaded')
2265
2270
2266 def magic_colors(self,parameter_s = ''):
2271 def magic_colors(self,parameter_s = ''):
2267 """Switch color scheme for prompts, info system and exception handlers.
2272 """Switch color scheme for prompts, info system and exception handlers.
2268
2273
2269 Currently implemented schemes: NoColor, Linux, LightBG.
2274 Currently implemented schemes: NoColor, Linux, LightBG.
2270
2275
2271 Color scheme names are not case-sensitive."""
2276 Color scheme names are not case-sensitive."""
2272
2277
2273 def color_switch_err(name):
2278 def color_switch_err(name):
2274 warn('Error changing %s color schemes.\n%s' %
2279 warn('Error changing %s color schemes.\n%s' %
2275 (name,sys.exc_info()[1]))
2280 (name,sys.exc_info()[1]))
2276
2281
2277
2282
2278 new_scheme = parameter_s.strip()
2283 new_scheme = parameter_s.strip()
2279 if not new_scheme:
2284 if not new_scheme:
2280 print 'You must specify a color scheme.'
2285 print 'You must specify a color scheme.'
2281 return
2286 return
2282 import IPython.rlineimpl as readline
2287 import IPython.rlineimpl as readline
2283 if not readline.have_readline:
2288 if not readline.have_readline:
2284 msg = """\
2289 msg = """\
2285 Proper color support under MS Windows requires the pyreadline library.
2290 Proper color support under MS Windows requires the pyreadline library.
2286 You can find it at:
2291 You can find it at:
2287 http://ipython.scipy.org/moin/PyReadline/Intro
2292 http://ipython.scipy.org/moin/PyReadline/Intro
2288 Gary's readline needs the ctypes module, from:
2293 Gary's readline needs the ctypes module, from:
2289 http://starship.python.net/crew/theller/ctypes
2294 http://starship.python.net/crew/theller/ctypes
2290 (Note that ctypes is already part of Python versions 2.5 and newer).
2295 (Note that ctypes is already part of Python versions 2.5 and newer).
2291
2296
2292 Defaulting color scheme to 'NoColor'"""
2297 Defaulting color scheme to 'NoColor'"""
2293 new_scheme = 'NoColor'
2298 new_scheme = 'NoColor'
2294 warn(msg)
2299 warn(msg)
2295 # local shortcut
2300 # local shortcut
2296 shell = self.shell
2301 shell = self.shell
2297
2302
2298 # Set prompt colors
2303 # Set prompt colors
2299 try:
2304 try:
2300 shell.outputcache.set_colors(new_scheme)
2305 shell.outputcache.set_colors(new_scheme)
2301 except:
2306 except:
2302 color_switch_err('prompt')
2307 color_switch_err('prompt')
2303 else:
2308 else:
2304 shell.rc.colors = \
2309 shell.rc.colors = \
2305 shell.outputcache.color_table.active_scheme_name
2310 shell.outputcache.color_table.active_scheme_name
2306 # Set exception colors
2311 # Set exception colors
2307 try:
2312 try:
2308 shell.InteractiveTB.set_colors(scheme = new_scheme)
2313 shell.InteractiveTB.set_colors(scheme = new_scheme)
2309 shell.SyntaxTB.set_colors(scheme = new_scheme)
2314 shell.SyntaxTB.set_colors(scheme = new_scheme)
2310 except:
2315 except:
2311 color_switch_err('exception')
2316 color_switch_err('exception')
2312
2317
2313 # threaded shells use a verbose traceback in sys.excepthook
2318 # threaded shells use a verbose traceback in sys.excepthook
2314 if shell.isthreaded:
2319 if shell.isthreaded:
2315 try:
2320 try:
2316 shell.sys_excepthook.set_colors(scheme=new_scheme)
2321 shell.sys_excepthook.set_colors(scheme=new_scheme)
2317 except:
2322 except:
2318 color_switch_err('system exception handler')
2323 color_switch_err('system exception handler')
2319
2324
2320 # Set info (for 'object?') colors
2325 # Set info (for 'object?') colors
2321 if shell.rc.color_info:
2326 if shell.rc.color_info:
2322 try:
2327 try:
2323 shell.inspector.set_active_scheme(new_scheme)
2328 shell.inspector.set_active_scheme(new_scheme)
2324 except:
2329 except:
2325 color_switch_err('object inspector')
2330 color_switch_err('object inspector')
2326 else:
2331 else:
2327 shell.inspector.set_active_scheme('NoColor')
2332 shell.inspector.set_active_scheme('NoColor')
2328
2333
2329 def magic_color_info(self,parameter_s = ''):
2334 def magic_color_info(self,parameter_s = ''):
2330 """Toggle color_info.
2335 """Toggle color_info.
2331
2336
2332 The color_info configuration parameter controls whether colors are
2337 The color_info configuration parameter controls whether colors are
2333 used for displaying object details (by things like %psource, %pfile or
2338 used for displaying object details (by things like %psource, %pfile or
2334 the '?' system). This function toggles this value with each call.
2339 the '?' system). This function toggles this value with each call.
2335
2340
2336 Note that unless you have a fairly recent pager (less works better
2341 Note that unless you have a fairly recent pager (less works better
2337 than more) in your system, using colored object information displays
2342 than more) in your system, using colored object information displays
2338 will not work properly. Test it and see."""
2343 will not work properly. Test it and see."""
2339
2344
2340 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2345 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2341 self.magic_colors(self.shell.rc.colors)
2346 self.magic_colors(self.shell.rc.colors)
2342 print 'Object introspection functions have now coloring:',
2347 print 'Object introspection functions have now coloring:',
2343 print ['OFF','ON'][self.shell.rc.color_info]
2348 print ['OFF','ON'][self.shell.rc.color_info]
2344
2349
2345 def magic_Pprint(self, parameter_s=''):
2350 def magic_Pprint(self, parameter_s=''):
2346 """Toggle pretty printing on/off."""
2351 """Toggle pretty printing on/off."""
2347
2352
2348 self.shell.rc.pprint = 1 - self.shell.rc.pprint
2353 self.shell.rc.pprint = 1 - self.shell.rc.pprint
2349 print 'Pretty printing has been turned', \
2354 print 'Pretty printing has been turned', \
2350 ['OFF','ON'][self.shell.rc.pprint]
2355 ['OFF','ON'][self.shell.rc.pprint]
2351
2356
2352 def magic_exit(self, parameter_s=''):
2357 def magic_exit(self, parameter_s=''):
2353 """Exit IPython, confirming if configured to do so.
2358 """Exit IPython, confirming if configured to do so.
2354
2359
2355 You can configure whether IPython asks for confirmation upon exit by
2360 You can configure whether IPython asks for confirmation upon exit by
2356 setting the confirm_exit flag in the ipythonrc file."""
2361 setting the confirm_exit flag in the ipythonrc file."""
2357
2362
2358 self.shell.exit()
2363 self.shell.exit()
2359
2364
2360 def magic_quit(self, parameter_s=''):
2365 def magic_quit(self, parameter_s=''):
2361 """Exit IPython, confirming if configured to do so (like %exit)"""
2366 """Exit IPython, confirming if configured to do so (like %exit)"""
2362
2367
2363 self.shell.exit()
2368 self.shell.exit()
2364
2369
2365 def magic_Exit(self, parameter_s=''):
2370 def magic_Exit(self, parameter_s=''):
2366 """Exit IPython without confirmation."""
2371 """Exit IPython without confirmation."""
2367
2372
2368 self.shell.exit_now = True
2373 self.shell.exit_now = True
2369
2374
2370 def magic_Quit(self, parameter_s=''):
2375 def magic_Quit(self, parameter_s=''):
2371 """Exit IPython without confirmation (like %Exit)."""
2376 """Exit IPython without confirmation (like %Exit)."""
2372
2377
2373 self.shell.exit_now = True
2378 self.shell.exit_now = True
2374
2379
2375 #......................................................................
2380 #......................................................................
2376 # Functions to implement unix shell-type things
2381 # Functions to implement unix shell-type things
2377
2382
2378 def magic_alias(self, parameter_s = ''):
2383 def magic_alias(self, parameter_s = ''):
2379 """Define an alias for a system command.
2384 """Define an alias for a system command.
2380
2385
2381 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2386 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2382
2387
2383 Then, typing 'alias_name params' will execute the system command 'cmd
2388 Then, typing 'alias_name params' will execute the system command 'cmd
2384 params' (from your underlying operating system).
2389 params' (from your underlying operating system).
2385
2390
2386 Aliases have lower precedence than magic functions and Python normal
2391 Aliases have lower precedence than magic functions and Python normal
2387 variables, so if 'foo' is both a Python variable and an alias, the
2392 variables, so if 'foo' is both a Python variable and an alias, the
2388 alias can not be executed until 'del foo' removes the Python variable.
2393 alias can not be executed until 'del foo' removes the Python variable.
2389
2394
2390 You can use the %l specifier in an alias definition to represent the
2395 You can use the %l specifier in an alias definition to represent the
2391 whole line when the alias is called. For example:
2396 whole line when the alias is called. For example:
2392
2397
2393 In [2]: alias all echo "Input in brackets: <%l>"\\
2398 In [2]: alias all echo "Input in brackets: <%l>"\\
2394 In [3]: all hello world\\
2399 In [3]: all hello world\\
2395 Input in brackets: <hello world>
2400 Input in brackets: <hello world>
2396
2401
2397 You can also define aliases with parameters using %s specifiers (one
2402 You can also define aliases with parameters using %s specifiers (one
2398 per parameter):
2403 per parameter):
2399
2404
2400 In [1]: alias parts echo first %s second %s\\
2405 In [1]: alias parts echo first %s second %s\\
2401 In [2]: %parts A B\\
2406 In [2]: %parts A B\\
2402 first A second B\\
2407 first A second B\\
2403 In [3]: %parts A\\
2408 In [3]: %parts A\\
2404 Incorrect number of arguments: 2 expected.\\
2409 Incorrect number of arguments: 2 expected.\\
2405 parts is an alias to: 'echo first %s second %s'
2410 parts is an alias to: 'echo first %s second %s'
2406
2411
2407 Note that %l and %s are mutually exclusive. You can only use one or
2412 Note that %l and %s are mutually exclusive. You can only use one or
2408 the other in your aliases.
2413 the other in your aliases.
2409
2414
2410 Aliases expand Python variables just like system calls using ! or !!
2415 Aliases expand Python variables just like system calls using ! or !!
2411 do: all expressions prefixed with '$' get expanded. For details of
2416 do: all expressions prefixed with '$' get expanded. For details of
2412 the semantic rules, see PEP-215:
2417 the semantic rules, see PEP-215:
2413 http://www.python.org/peps/pep-0215.html. This is the library used by
2418 http://www.python.org/peps/pep-0215.html. This is the library used by
2414 IPython for variable expansion. If you want to access a true shell
2419 IPython for variable expansion. If you want to access a true shell
2415 variable, an extra $ is necessary to prevent its expansion by IPython:
2420 variable, an extra $ is necessary to prevent its expansion by IPython:
2416
2421
2417 In [6]: alias show echo\\
2422 In [6]: alias show echo\\
2418 In [7]: PATH='A Python string'\\
2423 In [7]: PATH='A Python string'\\
2419 In [8]: show $PATH\\
2424 In [8]: show $PATH\\
2420 A Python string\\
2425 A Python string\\
2421 In [9]: show $$PATH\\
2426 In [9]: show $$PATH\\
2422 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2427 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2423
2428
2424 You can use the alias facility to acess all of $PATH. See the %rehash
2429 You can use the alias facility to acess all of $PATH. See the %rehash
2425 and %rehashx functions, which automatically create aliases for the
2430 and %rehashx functions, which automatically create aliases for the
2426 contents of your $PATH.
2431 contents of your $PATH.
2427
2432
2428 If called with no parameters, %alias prints the current alias table."""
2433 If called with no parameters, %alias prints the current alias table."""
2429
2434
2430 par = parameter_s.strip()
2435 par = parameter_s.strip()
2431 if not par:
2436 if not par:
2432 stored = self.db.get('stored_aliases', {} )
2437 stored = self.db.get('stored_aliases', {} )
2433 atab = self.shell.alias_table
2438 atab = self.shell.alias_table
2434 aliases = atab.keys()
2439 aliases = atab.keys()
2435 aliases.sort()
2440 aliases.sort()
2436 res = []
2441 res = []
2437 showlast = []
2442 showlast = []
2438 for alias in aliases:
2443 for alias in aliases:
2439 tgt = atab[alias][1]
2444 tgt = atab[alias][1]
2440 # 'interesting' aliases
2445 # 'interesting' aliases
2441 if (alias in stored or
2446 if (alias in stored or
2442 alias != os.path.splitext(tgt)[0] or
2447 alias != os.path.splitext(tgt)[0] or
2443 ' ' in tgt):
2448 ' ' in tgt):
2444 showlast.append((alias, tgt))
2449 showlast.append((alias, tgt))
2445 else:
2450 else:
2446 res.append((alias, tgt ))
2451 res.append((alias, tgt ))
2447
2452
2448 # show most interesting aliases last
2453 # show most interesting aliases last
2449 res.extend(showlast)
2454 res.extend(showlast)
2450 print "Total number of aliases:",len(aliases)
2455 print "Total number of aliases:",len(aliases)
2451 return res
2456 return res
2452 try:
2457 try:
2453 alias,cmd = par.split(None,1)
2458 alias,cmd = par.split(None,1)
2454 except:
2459 except:
2455 print OInspect.getdoc(self.magic_alias)
2460 print OInspect.getdoc(self.magic_alias)
2456 else:
2461 else:
2457 nargs = cmd.count('%s')
2462 nargs = cmd.count('%s')
2458 if nargs>0 and cmd.find('%l')>=0:
2463 if nargs>0 and cmd.find('%l')>=0:
2459 error('The %s and %l specifiers are mutually exclusive '
2464 error('The %s and %l specifiers are mutually exclusive '
2460 'in alias definitions.')
2465 'in alias definitions.')
2461 else: # all looks OK
2466 else: # all looks OK
2462 self.shell.alias_table[alias] = (nargs,cmd)
2467 self.shell.alias_table[alias] = (nargs,cmd)
2463 self.shell.alias_table_validate(verbose=0)
2468 self.shell.alias_table_validate(verbose=0)
2464 # end magic_alias
2469 # end magic_alias
2465
2470
2466 def magic_unalias(self, parameter_s = ''):
2471 def magic_unalias(self, parameter_s = ''):
2467 """Remove an alias"""
2472 """Remove an alias"""
2468
2473
2469 aname = parameter_s.strip()
2474 aname = parameter_s.strip()
2470 if aname in self.shell.alias_table:
2475 if aname in self.shell.alias_table:
2471 del self.shell.alias_table[aname]
2476 del self.shell.alias_table[aname]
2472 stored = self.db.get('stored_aliases', {} )
2477 stored = self.db.get('stored_aliases', {} )
2473 if aname in stored:
2478 if aname in stored:
2474 print "Removing %stored alias",aname
2479 print "Removing %stored alias",aname
2475 del stored[aname]
2480 del stored[aname]
2476 self.db['stored_aliases'] = stored
2481 self.db['stored_aliases'] = stored
2477
2482
2478 def magic_rehash(self, parameter_s = ''):
2483 def magic_rehash(self, parameter_s = ''):
2479 """Update the alias table with all entries in $PATH.
2484 """Update the alias table with all entries in $PATH.
2480
2485
2481 This version does no checks on execute permissions or whether the
2486 This version does no checks on execute permissions or whether the
2482 contents of $PATH are truly files (instead of directories or something
2487 contents of $PATH are truly files (instead of directories or something
2483 else). For such a safer (but slower) version, use %rehashx."""
2488 else). For such a safer (but slower) version, use %rehashx."""
2484
2489
2485 # This function (and rehashx) manipulate the alias_table directly
2490 # This function (and rehashx) manipulate the alias_table directly
2486 # rather than calling magic_alias, for speed reasons. A rehash on a
2491 # rather than calling magic_alias, for speed reasons. A rehash on a
2487 # typical Linux box involves several thousand entries, so efficiency
2492 # typical Linux box involves several thousand entries, so efficiency
2488 # here is a top concern.
2493 # here is a top concern.
2489
2494
2490 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2495 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2491 alias_table = self.shell.alias_table
2496 alias_table = self.shell.alias_table
2492 for pdir in path:
2497 for pdir in path:
2493 for ff in os.listdir(pdir):
2498 for ff in os.listdir(pdir):
2494 # each entry in the alias table must be (N,name), where
2499 # each entry in the alias table must be (N,name), where
2495 # N is the number of positional arguments of the alias.
2500 # N is the number of positional arguments of the alias.
2496 alias_table[ff] = (0,ff)
2501 alias_table[ff] = (0,ff)
2497 # Make sure the alias table doesn't contain keywords or builtins
2502 # Make sure the alias table doesn't contain keywords or builtins
2498 self.shell.alias_table_validate()
2503 self.shell.alias_table_validate()
2499 # Call again init_auto_alias() so we get 'rm -i' and other modified
2504 # Call again init_auto_alias() so we get 'rm -i' and other modified
2500 # aliases since %rehash will probably clobber them
2505 # aliases since %rehash will probably clobber them
2501 self.shell.init_auto_alias()
2506 self.shell.init_auto_alias()
2502
2507
2503 def magic_rehashx(self, parameter_s = ''):
2508 def magic_rehashx(self, parameter_s = ''):
2504 """Update the alias table with all executable files in $PATH.
2509 """Update the alias table with all executable files in $PATH.
2505
2510
2506 This version explicitly checks that every entry in $PATH is a file
2511 This version explicitly checks that every entry in $PATH is a file
2507 with execute access (os.X_OK), so it is much slower than %rehash.
2512 with execute access (os.X_OK), so it is much slower than %rehash.
2508
2513
2509 Under Windows, it checks executability as a match agains a
2514 Under Windows, it checks executability as a match agains a
2510 '|'-separated string of extensions, stored in the IPython config
2515 '|'-separated string of extensions, stored in the IPython config
2511 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2516 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2512
2517
2513 path = [os.path.abspath(os.path.expanduser(p)) for p in
2518 path = [os.path.abspath(os.path.expanduser(p)) for p in
2514 os.environ['PATH'].split(os.pathsep)]
2519 os.environ['PATH'].split(os.pathsep)]
2515 path = filter(os.path.isdir,path)
2520 path = filter(os.path.isdir,path)
2516
2521
2517 alias_table = self.shell.alias_table
2522 alias_table = self.shell.alias_table
2518 syscmdlist = []
2523 syscmdlist = []
2519 if os.name == 'posix':
2524 if os.name == 'posix':
2520 isexec = lambda fname:os.path.isfile(fname) and \
2525 isexec = lambda fname:os.path.isfile(fname) and \
2521 os.access(fname,os.X_OK)
2526 os.access(fname,os.X_OK)
2522 else:
2527 else:
2523
2528
2524 try:
2529 try:
2525 winext = os.environ['pathext'].replace(';','|').replace('.','')
2530 winext = os.environ['pathext'].replace(';','|').replace('.','')
2526 except KeyError:
2531 except KeyError:
2527 winext = 'exe|com|bat|py'
2532 winext = 'exe|com|bat|py'
2528 if 'py' not in winext:
2533 if 'py' not in winext:
2529 winext += '|py'
2534 winext += '|py'
2530 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2535 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2531 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2536 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2532 savedir = os.getcwd()
2537 savedir = os.getcwd()
2533 try:
2538 try:
2534 # write the whole loop for posix/Windows so we don't have an if in
2539 # write the whole loop for posix/Windows so we don't have an if in
2535 # the innermost part
2540 # the innermost part
2536 if os.name == 'posix':
2541 if os.name == 'posix':
2537 for pdir in path:
2542 for pdir in path:
2538 os.chdir(pdir)
2543 os.chdir(pdir)
2539 for ff in os.listdir(pdir):
2544 for ff in os.listdir(pdir):
2540 if isexec(ff) and ff not in self.shell.no_alias:
2545 if isexec(ff) and ff not in self.shell.no_alias:
2541 # each entry in the alias table must be (N,name),
2546 # each entry in the alias table must be (N,name),
2542 # where N is the number of positional arguments of the
2547 # where N is the number of positional arguments of the
2543 # alias.
2548 # alias.
2544 alias_table[ff] = (0,ff)
2549 alias_table[ff] = (0,ff)
2545 syscmdlist.append(ff)
2550 syscmdlist.append(ff)
2546 else:
2551 else:
2547 for pdir in path:
2552 for pdir in path:
2548 os.chdir(pdir)
2553 os.chdir(pdir)
2549 for ff in os.listdir(pdir):
2554 for ff in os.listdir(pdir):
2550 base, ext = os.path.splitext(ff)
2555 base, ext = os.path.splitext(ff)
2551 if isexec(ff) and base not in self.shell.no_alias:
2556 if isexec(ff) and base not in self.shell.no_alias:
2552 if ext.lower() == '.exe':
2557 if ext.lower() == '.exe':
2553 ff = base
2558 ff = base
2554 alias_table[base] = (0,ff)
2559 alias_table[base] = (0,ff)
2555 syscmdlist.append(ff)
2560 syscmdlist.append(ff)
2556 # Make sure the alias table doesn't contain keywords or builtins
2561 # Make sure the alias table doesn't contain keywords or builtins
2557 self.shell.alias_table_validate()
2562 self.shell.alias_table_validate()
2558 # Call again init_auto_alias() so we get 'rm -i' and other
2563 # Call again init_auto_alias() so we get 'rm -i' and other
2559 # modified aliases since %rehashx will probably clobber them
2564 # modified aliases since %rehashx will probably clobber them
2560 self.shell.init_auto_alias()
2565 self.shell.init_auto_alias()
2561 db = self.getapi().db
2566 db = self.getapi().db
2562 db['syscmdlist'] = syscmdlist
2567 db['syscmdlist'] = syscmdlist
2563 finally:
2568 finally:
2564 os.chdir(savedir)
2569 os.chdir(savedir)
2565
2570
2566 def magic_pwd(self, parameter_s = ''):
2571 def magic_pwd(self, parameter_s = ''):
2567 """Return the current working directory path."""
2572 """Return the current working directory path."""
2568 return os.getcwd()
2573 return os.getcwd()
2569
2574
2570 def magic_cd(self, parameter_s=''):
2575 def magic_cd(self, parameter_s=''):
2571 """Change the current working directory.
2576 """Change the current working directory.
2572
2577
2573 This command automatically maintains an internal list of directories
2578 This command automatically maintains an internal list of directories
2574 you visit during your IPython session, in the variable _dh. The
2579 you visit during your IPython session, in the variable _dh. The
2575 command %dhist shows this history nicely formatted. You can also
2580 command %dhist shows this history nicely formatted. You can also
2576 do 'cd -<tab>' to see directory history conveniently.
2581 do 'cd -<tab>' to see directory history conveniently.
2577
2582
2578 Usage:
2583 Usage:
2579
2584
2580 cd 'dir': changes to directory 'dir'.
2585 cd 'dir': changes to directory 'dir'.
2581
2586
2582 cd -: changes to the last visited directory.
2587 cd -: changes to the last visited directory.
2583
2588
2584 cd -<n>: changes to the n-th directory in the directory history.
2589 cd -<n>: changes to the n-th directory in the directory history.
2585
2590
2586 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2591 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2587 (note: cd <bookmark_name> is enough if there is no
2592 (note: cd <bookmark_name> is enough if there is no
2588 directory <bookmark_name>, but a bookmark with the name exists.)
2593 directory <bookmark_name>, but a bookmark with the name exists.)
2589 'cd -b <tab>' allows you to tab-complete bookmark names.
2594 'cd -b <tab>' allows you to tab-complete bookmark names.
2590
2595
2591 Options:
2596 Options:
2592
2597
2593 -q: quiet. Do not print the working directory after the cd command is
2598 -q: quiet. Do not print the working directory after the cd command is
2594 executed. By default IPython's cd command does print this directory,
2599 executed. By default IPython's cd command does print this directory,
2595 since the default prompts do not display path information.
2600 since the default prompts do not display path information.
2596
2601
2597 Note that !cd doesn't work for this purpose because the shell where
2602 Note that !cd doesn't work for this purpose because the shell where
2598 !command runs is immediately discarded after executing 'command'."""
2603 !command runs is immediately discarded after executing 'command'."""
2599
2604
2600 parameter_s = parameter_s.strip()
2605 parameter_s = parameter_s.strip()
2601 #bkms = self.shell.persist.get("bookmarks",{})
2606 #bkms = self.shell.persist.get("bookmarks",{})
2602
2607
2603 numcd = re.match(r'(-)(\d+)$',parameter_s)
2608 numcd = re.match(r'(-)(\d+)$',parameter_s)
2604 # jump in directory history by number
2609 # jump in directory history by number
2605 if numcd:
2610 if numcd:
2606 nn = int(numcd.group(2))
2611 nn = int(numcd.group(2))
2607 try:
2612 try:
2608 ps = self.shell.user_ns['_dh'][nn]
2613 ps = self.shell.user_ns['_dh'][nn]
2609 except IndexError:
2614 except IndexError:
2610 print 'The requested directory does not exist in history.'
2615 print 'The requested directory does not exist in history.'
2611 return
2616 return
2612 else:
2617 else:
2613 opts = {}
2618 opts = {}
2614 else:
2619 else:
2615 #turn all non-space-escaping backslashes to slashes,
2620 #turn all non-space-escaping backslashes to slashes,
2616 # for c:\windows\directory\names\
2621 # for c:\windows\directory\names\
2617 parameter_s = re.sub(r'\\(?! )','/', parameter_s)
2622 parameter_s = re.sub(r'\\(?! )','/', parameter_s)
2618 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2623 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2619 # jump to previous
2624 # jump to previous
2620 if ps == '-':
2625 if ps == '-':
2621 try:
2626 try:
2622 ps = self.shell.user_ns['_dh'][-2]
2627 ps = self.shell.user_ns['_dh'][-2]
2623 except IndexError:
2628 except IndexError:
2624 print 'No previous directory to change to.'
2629 print 'No previous directory to change to.'
2625 return
2630 return
2626 # jump to bookmark if needed
2631 # jump to bookmark if needed
2627 else:
2632 else:
2628 if not os.path.isdir(ps) or opts.has_key('b'):
2633 if not os.path.isdir(ps) or opts.has_key('b'):
2629 bkms = self.db.get('bookmarks', {})
2634 bkms = self.db.get('bookmarks', {})
2630
2635
2631 if bkms.has_key(ps):
2636 if bkms.has_key(ps):
2632 target = bkms[ps]
2637 target = bkms[ps]
2633 print '(bookmark:%s) -> %s' % (ps,target)
2638 print '(bookmark:%s) -> %s' % (ps,target)
2634 ps = target
2639 ps = target
2635 else:
2640 else:
2636 if opts.has_key('b'):
2641 if opts.has_key('b'):
2637 error("Bookmark '%s' not found. "
2642 error("Bookmark '%s' not found. "
2638 "Use '%%bookmark -l' to see your bookmarks." % ps)
2643 "Use '%%bookmark -l' to see your bookmarks." % ps)
2639 return
2644 return
2640
2645
2641 # at this point ps should point to the target dir
2646 # at this point ps should point to the target dir
2642 if ps:
2647 if ps:
2643 try:
2648 try:
2644 os.chdir(os.path.expanduser(ps))
2649 os.chdir(os.path.expanduser(ps))
2645 if self.shell.rc.term_title:
2650 if self.shell.rc.term_title:
2646 #print 'set term title:',self.shell.rc.term_title # dbg
2651 #print 'set term title:',self.shell.rc.term_title # dbg
2647 ttitle = ("IPy:" + (
2652 ttitle = ("IPy:" + (
2648 os.getcwd() == '/' and '/' or \
2653 os.getcwd() == '/' and '/' or \
2649 os.path.basename(os.getcwd())))
2654 os.path.basename(os.getcwd())))
2650 platutils.set_term_title(ttitle)
2655 platutils.set_term_title(ttitle)
2651 except OSError:
2656 except OSError:
2652 print sys.exc_info()[1]
2657 print sys.exc_info()[1]
2653 else:
2658 else:
2654 self.shell.user_ns['_dh'].append(os.getcwd())
2659 self.shell.user_ns['_dh'].append(os.getcwd())
2655 else:
2660 else:
2656 os.chdir(self.shell.home_dir)
2661 os.chdir(self.shell.home_dir)
2657 if self.shell.rc.term_title:
2662 if self.shell.rc.term_title:
2658 platutils.set_term_title("IPy:~")
2663 platutils.set_term_title("IPy:~")
2659 self.shell.user_ns['_dh'].append(os.getcwd())
2664 self.shell.user_ns['_dh'].append(os.getcwd())
2660 if not 'q' in opts:
2665 if not 'q' in opts:
2661 print self.shell.user_ns['_dh'][-1]
2666 print self.shell.user_ns['_dh'][-1]
2662
2667
2663 def magic_dhist(self, parameter_s=''):
2668 def magic_dhist(self, parameter_s=''):
2664 """Print your history of visited directories.
2669 """Print your history of visited directories.
2665
2670
2666 %dhist -> print full history\\
2671 %dhist -> print full history\\
2667 %dhist n -> print last n entries only\\
2672 %dhist n -> print last n entries only\\
2668 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2673 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2669
2674
2670 This history is automatically maintained by the %cd command, and
2675 This history is automatically maintained by the %cd command, and
2671 always available as the global list variable _dh. You can use %cd -<n>
2676 always available as the global list variable _dh. You can use %cd -<n>
2672 to go to directory number <n>."""
2677 to go to directory number <n>."""
2673
2678
2674 dh = self.shell.user_ns['_dh']
2679 dh = self.shell.user_ns['_dh']
2675 if parameter_s:
2680 if parameter_s:
2676 try:
2681 try:
2677 args = map(int,parameter_s.split())
2682 args = map(int,parameter_s.split())
2678 except:
2683 except:
2679 self.arg_err(Magic.magic_dhist)
2684 self.arg_err(Magic.magic_dhist)
2680 return
2685 return
2681 if len(args) == 1:
2686 if len(args) == 1:
2682 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2687 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2683 elif len(args) == 2:
2688 elif len(args) == 2:
2684 ini,fin = args
2689 ini,fin = args
2685 else:
2690 else:
2686 self.arg_err(Magic.magic_dhist)
2691 self.arg_err(Magic.magic_dhist)
2687 return
2692 return
2688 else:
2693 else:
2689 ini,fin = 0,len(dh)
2694 ini,fin = 0,len(dh)
2690 nlprint(dh,
2695 nlprint(dh,
2691 header = 'Directory history (kept in _dh)',
2696 header = 'Directory history (kept in _dh)',
2692 start=ini,stop=fin)
2697 start=ini,stop=fin)
2693
2698
2694 def magic_env(self, parameter_s=''):
2699 def magic_env(self, parameter_s=''):
2695 """List environment variables."""
2700 """List environment variables."""
2696
2701
2697 return os.environ.data
2702 return os.environ.data
2698
2703
2699 def magic_pushd(self, parameter_s=''):
2704 def magic_pushd(self, parameter_s=''):
2700 """Place the current dir on stack and change directory.
2705 """Place the current dir on stack and change directory.
2701
2706
2702 Usage:\\
2707 Usage:\\
2703 %pushd ['dirname']
2708 %pushd ['dirname']
2704
2709
2705 %pushd with no arguments does a %pushd to your home directory.
2710 %pushd with no arguments does a %pushd to your home directory.
2706 """
2711 """
2707 if parameter_s == '': parameter_s = '~'
2712 if parameter_s == '': parameter_s = '~'
2708 dir_s = self.shell.dir_stack
2713 dir_s = self.shell.dir_stack
2709 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2714 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2710 os.path.expanduser(self.shell.dir_stack[0]):
2715 os.path.expanduser(self.shell.dir_stack[0]):
2711 try:
2716 try:
2712 self.magic_cd(parameter_s)
2717 self.magic_cd(parameter_s)
2713 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2718 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2714 self.magic_dirs()
2719 self.magic_dirs()
2715 except:
2720 except:
2716 print 'Invalid directory'
2721 print 'Invalid directory'
2717 else:
2722 else:
2718 print 'You are already there!'
2723 print 'You are already there!'
2719
2724
2720 def magic_popd(self, parameter_s=''):
2725 def magic_popd(self, parameter_s=''):
2721 """Change to directory popped off the top of the stack.
2726 """Change to directory popped off the top of the stack.
2722 """
2727 """
2723 if len (self.shell.dir_stack) > 1:
2728 if len (self.shell.dir_stack) > 1:
2724 self.shell.dir_stack.pop(0)
2729 self.shell.dir_stack.pop(0)
2725 self.magic_cd(self.shell.dir_stack[0])
2730 self.magic_cd(self.shell.dir_stack[0])
2726 print self.shell.dir_stack[0]
2731 print self.shell.dir_stack[0]
2727 else:
2732 else:
2728 print "You can't remove the starting directory from the stack:",\
2733 print "You can't remove the starting directory from the stack:",\
2729 self.shell.dir_stack
2734 self.shell.dir_stack
2730
2735
2731 def magic_dirs(self, parameter_s=''):
2736 def magic_dirs(self, parameter_s=''):
2732 """Return the current directory stack."""
2737 """Return the current directory stack."""
2733
2738
2734 return self.shell.dir_stack[:]
2739 return self.shell.dir_stack[:]
2735
2740
2736 def magic_sc(self, parameter_s=''):
2741 def magic_sc(self, parameter_s=''):
2737 """Shell capture - execute a shell command and capture its output.
2742 """Shell capture - execute a shell command and capture its output.
2738
2743
2739 DEPRECATED. Suboptimal, retained for backwards compatibility.
2744 DEPRECATED. Suboptimal, retained for backwards compatibility.
2740
2745
2741 You should use the form 'var = !command' instead. Example:
2746 You should use the form 'var = !command' instead. Example:
2742
2747
2743 "%sc -l myfiles = ls ~" should now be written as
2748 "%sc -l myfiles = ls ~" should now be written as
2744
2749
2745 "myfiles = !ls ~"
2750 "myfiles = !ls ~"
2746
2751
2747 myfiles.s, myfiles.l and myfiles.n still apply as documented
2752 myfiles.s, myfiles.l and myfiles.n still apply as documented
2748 below.
2753 below.
2749
2754
2750 --
2755 --
2751 %sc [options] varname=command
2756 %sc [options] varname=command
2752
2757
2753 IPython will run the given command using commands.getoutput(), and
2758 IPython will run the given command using commands.getoutput(), and
2754 will then update the user's interactive namespace with a variable
2759 will then update the user's interactive namespace with a variable
2755 called varname, containing the value of the call. Your command can
2760 called varname, containing the value of the call. Your command can
2756 contain shell wildcards, pipes, etc.
2761 contain shell wildcards, pipes, etc.
2757
2762
2758 The '=' sign in the syntax is mandatory, and the variable name you
2763 The '=' sign in the syntax is mandatory, and the variable name you
2759 supply must follow Python's standard conventions for valid names.
2764 supply must follow Python's standard conventions for valid names.
2760
2765
2761 (A special format without variable name exists for internal use)
2766 (A special format without variable name exists for internal use)
2762
2767
2763 Options:
2768 Options:
2764
2769
2765 -l: list output. Split the output on newlines into a list before
2770 -l: list output. Split the output on newlines into a list before
2766 assigning it to the given variable. By default the output is stored
2771 assigning it to the given variable. By default the output is stored
2767 as a single string.
2772 as a single string.
2768
2773
2769 -v: verbose. Print the contents of the variable.
2774 -v: verbose. Print the contents of the variable.
2770
2775
2771 In most cases you should not need to split as a list, because the
2776 In most cases you should not need to split as a list, because the
2772 returned value is a special type of string which can automatically
2777 returned value is a special type of string which can automatically
2773 provide its contents either as a list (split on newlines) or as a
2778 provide its contents either as a list (split on newlines) or as a
2774 space-separated string. These are convenient, respectively, either
2779 space-separated string. These are convenient, respectively, either
2775 for sequential processing or to be passed to a shell command.
2780 for sequential processing or to be passed to a shell command.
2776
2781
2777 For example:
2782 For example:
2778
2783
2779 # Capture into variable a
2784 # Capture into variable a
2780 In [9]: sc a=ls *py
2785 In [9]: sc a=ls *py
2781
2786
2782 # a is a string with embedded newlines
2787 # a is a string with embedded newlines
2783 In [10]: a
2788 In [10]: a
2784 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2789 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2785
2790
2786 # which can be seen as a list:
2791 # which can be seen as a list:
2787 In [11]: a.l
2792 In [11]: a.l
2788 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2793 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2789
2794
2790 # or as a whitespace-separated string:
2795 # or as a whitespace-separated string:
2791 In [12]: a.s
2796 In [12]: a.s
2792 Out[12]: 'setup.py win32_manual_post_install.py'
2797 Out[12]: 'setup.py win32_manual_post_install.py'
2793
2798
2794 # a.s is useful to pass as a single command line:
2799 # a.s is useful to pass as a single command line:
2795 In [13]: !wc -l $a.s
2800 In [13]: !wc -l $a.s
2796 146 setup.py
2801 146 setup.py
2797 130 win32_manual_post_install.py
2802 130 win32_manual_post_install.py
2798 276 total
2803 276 total
2799
2804
2800 # while the list form is useful to loop over:
2805 # while the list form is useful to loop over:
2801 In [14]: for f in a.l:
2806 In [14]: for f in a.l:
2802 ....: !wc -l $f
2807 ....: !wc -l $f
2803 ....:
2808 ....:
2804 146 setup.py
2809 146 setup.py
2805 130 win32_manual_post_install.py
2810 130 win32_manual_post_install.py
2806
2811
2807 Similiarly, the lists returned by the -l option are also special, in
2812 Similiarly, the lists returned by the -l option are also special, in
2808 the sense that you can equally invoke the .s attribute on them to
2813 the sense that you can equally invoke the .s attribute on them to
2809 automatically get a whitespace-separated string from their contents:
2814 automatically get a whitespace-separated string from their contents:
2810
2815
2811 In [1]: sc -l b=ls *py
2816 In [1]: sc -l b=ls *py
2812
2817
2813 In [2]: b
2818 In [2]: b
2814 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2819 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2815
2820
2816 In [3]: b.s
2821 In [3]: b.s
2817 Out[3]: 'setup.py win32_manual_post_install.py'
2822 Out[3]: 'setup.py win32_manual_post_install.py'
2818
2823
2819 In summary, both the lists and strings used for ouptut capture have
2824 In summary, both the lists and strings used for ouptut capture have
2820 the following special attributes:
2825 the following special attributes:
2821
2826
2822 .l (or .list) : value as list.
2827 .l (or .list) : value as list.
2823 .n (or .nlstr): value as newline-separated string.
2828 .n (or .nlstr): value as newline-separated string.
2824 .s (or .spstr): value as space-separated string.
2829 .s (or .spstr): value as space-separated string.
2825 """
2830 """
2826
2831
2827 opts,args = self.parse_options(parameter_s,'lv')
2832 opts,args = self.parse_options(parameter_s,'lv')
2828 # Try to get a variable name and command to run
2833 # Try to get a variable name and command to run
2829 try:
2834 try:
2830 # the variable name must be obtained from the parse_options
2835 # the variable name must be obtained from the parse_options
2831 # output, which uses shlex.split to strip options out.
2836 # output, which uses shlex.split to strip options out.
2832 var,_ = args.split('=',1)
2837 var,_ = args.split('=',1)
2833 var = var.strip()
2838 var = var.strip()
2834 # But the the command has to be extracted from the original input
2839 # But the the command has to be extracted from the original input
2835 # parameter_s, not on what parse_options returns, to avoid the
2840 # parameter_s, not on what parse_options returns, to avoid the
2836 # quote stripping which shlex.split performs on it.
2841 # quote stripping which shlex.split performs on it.
2837 _,cmd = parameter_s.split('=',1)
2842 _,cmd = parameter_s.split('=',1)
2838 except ValueError:
2843 except ValueError:
2839 var,cmd = '',''
2844 var,cmd = '',''
2840 # If all looks ok, proceed
2845 # If all looks ok, proceed
2841 out,err = self.shell.getoutputerror(cmd)
2846 out,err = self.shell.getoutputerror(cmd)
2842 if err:
2847 if err:
2843 print >> Term.cerr,err
2848 print >> Term.cerr,err
2844 if opts.has_key('l'):
2849 if opts.has_key('l'):
2845 out = SList(out.split('\n'))
2850 out = SList(out.split('\n'))
2846 else:
2851 else:
2847 out = LSString(out)
2852 out = LSString(out)
2848 if opts.has_key('v'):
2853 if opts.has_key('v'):
2849 print '%s ==\n%s' % (var,pformat(out))
2854 print '%s ==\n%s' % (var,pformat(out))
2850 if var:
2855 if var:
2851 self.shell.user_ns.update({var:out})
2856 self.shell.user_ns.update({var:out})
2852 else:
2857 else:
2853 return out
2858 return out
2854
2859
2855 def magic_sx(self, parameter_s=''):
2860 def magic_sx(self, parameter_s=''):
2856 """Shell execute - run a shell command and capture its output.
2861 """Shell execute - run a shell command and capture its output.
2857
2862
2858 %sx command
2863 %sx command
2859
2864
2860 IPython will run the given command using commands.getoutput(), and
2865 IPython will run the given command using commands.getoutput(), and
2861 return the result formatted as a list (split on '\\n'). Since the
2866 return the result formatted as a list (split on '\\n'). Since the
2862 output is _returned_, it will be stored in ipython's regular output
2867 output is _returned_, it will be stored in ipython's regular output
2863 cache Out[N] and in the '_N' automatic variables.
2868 cache Out[N] and in the '_N' automatic variables.
2864
2869
2865 Notes:
2870 Notes:
2866
2871
2867 1) If an input line begins with '!!', then %sx is automatically
2872 1) If an input line begins with '!!', then %sx is automatically
2868 invoked. That is, while:
2873 invoked. That is, while:
2869 !ls
2874 !ls
2870 causes ipython to simply issue system('ls'), typing
2875 causes ipython to simply issue system('ls'), typing
2871 !!ls
2876 !!ls
2872 is a shorthand equivalent to:
2877 is a shorthand equivalent to:
2873 %sx ls
2878 %sx ls
2874
2879
2875 2) %sx differs from %sc in that %sx automatically splits into a list,
2880 2) %sx differs from %sc in that %sx automatically splits into a list,
2876 like '%sc -l'. The reason for this is to make it as easy as possible
2881 like '%sc -l'. The reason for this is to make it as easy as possible
2877 to process line-oriented shell output via further python commands.
2882 to process line-oriented shell output via further python commands.
2878 %sc is meant to provide much finer control, but requires more
2883 %sc is meant to provide much finer control, but requires more
2879 typing.
2884 typing.
2880
2885
2881 3) Just like %sc -l, this is a list with special attributes:
2886 3) Just like %sc -l, this is a list with special attributes:
2882
2887
2883 .l (or .list) : value as list.
2888 .l (or .list) : value as list.
2884 .n (or .nlstr): value as newline-separated string.
2889 .n (or .nlstr): value as newline-separated string.
2885 .s (or .spstr): value as whitespace-separated string.
2890 .s (or .spstr): value as whitespace-separated string.
2886
2891
2887 This is very useful when trying to use such lists as arguments to
2892 This is very useful when trying to use such lists as arguments to
2888 system commands."""
2893 system commands."""
2889
2894
2890 if parameter_s:
2895 if parameter_s:
2891 out,err = self.shell.getoutputerror(parameter_s)
2896 out,err = self.shell.getoutputerror(parameter_s)
2892 if err:
2897 if err:
2893 print >> Term.cerr,err
2898 print >> Term.cerr,err
2894 return SList(out.split('\n'))
2899 return SList(out.split('\n'))
2895
2900
2896 def magic_bg(self, parameter_s=''):
2901 def magic_bg(self, parameter_s=''):
2897 """Run a job in the background, in a separate thread.
2902 """Run a job in the background, in a separate thread.
2898
2903
2899 For example,
2904 For example,
2900
2905
2901 %bg myfunc(x,y,z=1)
2906 %bg myfunc(x,y,z=1)
2902
2907
2903 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2908 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2904 execution starts, a message will be printed indicating the job
2909 execution starts, a message will be printed indicating the job
2905 number. If your job number is 5, you can use
2910 number. If your job number is 5, you can use
2906
2911
2907 myvar = jobs.result(5) or myvar = jobs[5].result
2912 myvar = jobs.result(5) or myvar = jobs[5].result
2908
2913
2909 to assign this result to variable 'myvar'.
2914 to assign this result to variable 'myvar'.
2910
2915
2911 IPython has a job manager, accessible via the 'jobs' object. You can
2916 IPython has a job manager, accessible via the 'jobs' object. You can
2912 type jobs? to get more information about it, and use jobs.<TAB> to see
2917 type jobs? to get more information about it, and use jobs.<TAB> to see
2913 its attributes. All attributes not starting with an underscore are
2918 its attributes. All attributes not starting with an underscore are
2914 meant for public use.
2919 meant for public use.
2915
2920
2916 In particular, look at the jobs.new() method, which is used to create
2921 In particular, look at the jobs.new() method, which is used to create
2917 new jobs. This magic %bg function is just a convenience wrapper
2922 new jobs. This magic %bg function is just a convenience wrapper
2918 around jobs.new(), for expression-based jobs. If you want to create a
2923 around jobs.new(), for expression-based jobs. If you want to create a
2919 new job with an explicit function object and arguments, you must call
2924 new job with an explicit function object and arguments, you must call
2920 jobs.new() directly.
2925 jobs.new() directly.
2921
2926
2922 The jobs.new docstring also describes in detail several important
2927 The jobs.new docstring also describes in detail several important
2923 caveats associated with a thread-based model for background job
2928 caveats associated with a thread-based model for background job
2924 execution. Type jobs.new? for details.
2929 execution. Type jobs.new? for details.
2925
2930
2926 You can check the status of all jobs with jobs.status().
2931 You can check the status of all jobs with jobs.status().
2927
2932
2928 The jobs variable is set by IPython into the Python builtin namespace.
2933 The jobs variable is set by IPython into the Python builtin namespace.
2929 If you ever declare a variable named 'jobs', you will shadow this
2934 If you ever declare a variable named 'jobs', you will shadow this
2930 name. You can either delete your global jobs variable to regain
2935 name. You can either delete your global jobs variable to regain
2931 access to the job manager, or make a new name and assign it manually
2936 access to the job manager, or make a new name and assign it manually
2932 to the manager (stored in IPython's namespace). For example, to
2937 to the manager (stored in IPython's namespace). For example, to
2933 assign the job manager to the Jobs name, use:
2938 assign the job manager to the Jobs name, use:
2934
2939
2935 Jobs = __builtins__.jobs"""
2940 Jobs = __builtins__.jobs"""
2936
2941
2937 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2942 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2938
2943
2939
2944
2940 def magic_bookmark(self, parameter_s=''):
2945 def magic_bookmark(self, parameter_s=''):
2941 """Manage IPython's bookmark system.
2946 """Manage IPython's bookmark system.
2942
2947
2943 %bookmark <name> - set bookmark to current dir
2948 %bookmark <name> - set bookmark to current dir
2944 %bookmark <name> <dir> - set bookmark to <dir>
2949 %bookmark <name> <dir> - set bookmark to <dir>
2945 %bookmark -l - list all bookmarks
2950 %bookmark -l - list all bookmarks
2946 %bookmark -d <name> - remove bookmark
2951 %bookmark -d <name> - remove bookmark
2947 %bookmark -r - remove all bookmarks
2952 %bookmark -r - remove all bookmarks
2948
2953
2949 You can later on access a bookmarked folder with:
2954 You can later on access a bookmarked folder with:
2950 %cd -b <name>
2955 %cd -b <name>
2951 or simply '%cd <name>' if there is no directory called <name> AND
2956 or simply '%cd <name>' if there is no directory called <name> AND
2952 there is such a bookmark defined.
2957 there is such a bookmark defined.
2953
2958
2954 Your bookmarks persist through IPython sessions, but they are
2959 Your bookmarks persist through IPython sessions, but they are
2955 associated with each profile."""
2960 associated with each profile."""
2956
2961
2957 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2962 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2958 if len(args) > 2:
2963 if len(args) > 2:
2959 error('You can only give at most two arguments')
2964 error('You can only give at most two arguments')
2960 return
2965 return
2961
2966
2962 bkms = self.db.get('bookmarks',{})
2967 bkms = self.db.get('bookmarks',{})
2963
2968
2964 if opts.has_key('d'):
2969 if opts.has_key('d'):
2965 try:
2970 try:
2966 todel = args[0]
2971 todel = args[0]
2967 except IndexError:
2972 except IndexError:
2968 error('You must provide a bookmark to delete')
2973 error('You must provide a bookmark to delete')
2969 else:
2974 else:
2970 try:
2975 try:
2971 del bkms[todel]
2976 del bkms[todel]
2972 except:
2977 except:
2973 error("Can't delete bookmark '%s'" % todel)
2978 error("Can't delete bookmark '%s'" % todel)
2974 elif opts.has_key('r'):
2979 elif opts.has_key('r'):
2975 bkms = {}
2980 bkms = {}
2976 elif opts.has_key('l'):
2981 elif opts.has_key('l'):
2977 bks = bkms.keys()
2982 bks = bkms.keys()
2978 bks.sort()
2983 bks.sort()
2979 if bks:
2984 if bks:
2980 size = max(map(len,bks))
2985 size = max(map(len,bks))
2981 else:
2986 else:
2982 size = 0
2987 size = 0
2983 fmt = '%-'+str(size)+'s -> %s'
2988 fmt = '%-'+str(size)+'s -> %s'
2984 print 'Current bookmarks:'
2989 print 'Current bookmarks:'
2985 for bk in bks:
2990 for bk in bks:
2986 print fmt % (bk,bkms[bk])
2991 print fmt % (bk,bkms[bk])
2987 else:
2992 else:
2988 if not args:
2993 if not args:
2989 error("You must specify the bookmark name")
2994 error("You must specify the bookmark name")
2990 elif len(args)==1:
2995 elif len(args)==1:
2991 bkms[args[0]] = os.getcwd()
2996 bkms[args[0]] = os.getcwd()
2992 elif len(args)==2:
2997 elif len(args)==2:
2993 bkms[args[0]] = args[1]
2998 bkms[args[0]] = args[1]
2994 self.db['bookmarks'] = bkms
2999 self.db['bookmarks'] = bkms
2995
3000
2996 def magic_pycat(self, parameter_s=''):
3001 def magic_pycat(self, parameter_s=''):
2997 """Show a syntax-highlighted file through a pager.
3002 """Show a syntax-highlighted file through a pager.
2998
3003
2999 This magic is similar to the cat utility, but it will assume the file
3004 This magic is similar to the cat utility, but it will assume the file
3000 to be Python source and will show it with syntax highlighting. """
3005 to be Python source and will show it with syntax highlighting. """
3001
3006
3002 try:
3007 try:
3003 filename = get_py_filename(parameter_s)
3008 filename = get_py_filename(parameter_s)
3004 cont = file_read(filename)
3009 cont = file_read(filename)
3005 except IOError:
3010 except IOError:
3006 try:
3011 try:
3007 cont = eval(parameter_s,self.user_ns)
3012 cont = eval(parameter_s,self.user_ns)
3008 except NameError:
3013 except NameError:
3009 cont = None
3014 cont = None
3010 if cont is None:
3015 if cont is None:
3011 print "Error: no such file or variable"
3016 print "Error: no such file or variable"
3012 return
3017 return
3013
3018
3014 page(self.shell.pycolorize(cont),
3019 page(self.shell.pycolorize(cont),
3015 screen_lines=self.shell.rc.screen_length)
3020 screen_lines=self.shell.rc.screen_length)
3016
3021
3017 def magic_cpaste(self, parameter_s=''):
3022 def magic_cpaste(self, parameter_s=''):
3018 """Allows you to paste & execute a pre-formatted code block from clipboard
3023 """Allows you to paste & execute a pre-formatted code block from clipboard
3019
3024
3020 You must terminate the block with '--' (two minus-signs) alone on the
3025 You must terminate the block with '--' (two minus-signs) alone on the
3021 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
3026 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
3022 is the new sentinel for this operation)
3027 is the new sentinel for this operation)
3023
3028
3024 The block is dedented prior to execution to enable execution of
3029 The block is dedented prior to execution to enable execution of
3025 method definitions. '>' characters at the beginning of a line is
3030 method definitions. '>' characters at the beginning of a line is
3026 ignored, to allow pasting directly from e-mails. The executed block
3031 ignored, to allow pasting directly from e-mails. The executed block
3027 is also assigned to variable named 'pasted_block' for later editing
3032 is also assigned to variable named 'pasted_block' for later editing
3028 with '%edit pasted_block'.
3033 with '%edit pasted_block'.
3029
3034
3030 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
3035 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
3031 This assigns the pasted block to variable 'foo' as string, without
3036 This assigns the pasted block to variable 'foo' as string, without
3032 dedenting or executing it.
3037 dedenting or executing it.
3033
3038
3034 Do not be alarmed by garbled output on Windows (it's a readline bug).
3039 Do not be alarmed by garbled output on Windows (it's a readline bug).
3035 Just press enter and type -- (and press enter again) and the block
3040 Just press enter and type -- (and press enter again) and the block
3036 will be what was just pasted.
3041 will be what was just pasted.
3037
3042
3038 IPython statements (magics, shell escapes) are not supported (yet).
3043 IPython statements (magics, shell escapes) are not supported (yet).
3039 """
3044 """
3040 opts,args = self.parse_options(parameter_s,'s:',mode='string')
3045 opts,args = self.parse_options(parameter_s,'s:',mode='string')
3041 par = args.strip()
3046 par = args.strip()
3042 sentinel = opts.get('s','--')
3047 sentinel = opts.get('s','--')
3043
3048
3044 from IPython import iplib
3049 from IPython import iplib
3045 lines = []
3050 lines = []
3046 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
3051 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
3047 while 1:
3052 while 1:
3048 l = iplib.raw_input_original(':')
3053 l = iplib.raw_input_original(':')
3049 if l ==sentinel:
3054 if l ==sentinel:
3050 break
3055 break
3051 lines.append(l.lstrip('>'))
3056 lines.append(l.lstrip('>'))
3052 block = "\n".join(lines) + '\n'
3057 block = "\n".join(lines) + '\n'
3053 #print "block:\n",block
3058 #print "block:\n",block
3054 if not par:
3059 if not par:
3055 b = textwrap.dedent(block)
3060 b = textwrap.dedent(block)
3056 exec b in self.user_ns
3061 exec b in self.user_ns
3057 self.user_ns['pasted_block'] = b
3062 self.user_ns['pasted_block'] = b
3058 else:
3063 else:
3059 self.user_ns[par] = block
3064 self.user_ns[par] = block
3060 print "Block assigned to '%s'" % par
3065 print "Block assigned to '%s'" % par
3061
3066
3062 def magic_quickref(self,arg):
3067 def magic_quickref(self,arg):
3063 """ Show a quick reference sheet """
3068 """ Show a quick reference sheet """
3064 import IPython.usage
3069 import IPython.usage
3065 qr = IPython.usage.quick_reference + self.magic_magic('-brief')
3070 qr = IPython.usage.quick_reference + self.magic_magic('-brief')
3066
3071
3067 page(qr)
3072 page(qr)
3068
3073
3069 def magic_upgrade(self,arg):
3074 def magic_upgrade(self,arg):
3070 """ Upgrade your IPython installation
3075 """ Upgrade your IPython installation
3071
3076
3072 This will copy the config files that don't yet exist in your
3077 This will copy the config files that don't yet exist in your
3073 ipython dir from the system config dir. Use this after upgrading
3078 ipython dir from the system config dir. Use this after upgrading
3074 IPython if you don't wish to delete your .ipython dir.
3079 IPython if you don't wish to delete your .ipython dir.
3075
3080
3076 Call with -nolegacy to get rid of ipythonrc* files (recommended for
3081 Call with -nolegacy to get rid of ipythonrc* files (recommended for
3077 new users)
3082 new users)
3078
3083
3079 """
3084 """
3080 ip = self.getapi()
3085 ip = self.getapi()
3081 ipinstallation = path(IPython.__file__).dirname()
3086 ipinstallation = path(IPython.__file__).dirname()
3082 upgrade_script = '%s "%s"' % (sys.executable,ipinstallation / 'upgrade_dir.py')
3087 upgrade_script = '%s "%s"' % (sys.executable,ipinstallation / 'upgrade_dir.py')
3083 src_config = ipinstallation / 'UserConfig'
3088 src_config = ipinstallation / 'UserConfig'
3084 userdir = path(ip.options.ipythondir)
3089 userdir = path(ip.options.ipythondir)
3085 cmd = '%s "%s" "%s"' % (upgrade_script, src_config, userdir)
3090 cmd = '%s "%s" "%s"' % (upgrade_script, src_config, userdir)
3086 print ">",cmd
3091 print ">",cmd
3087 shell(cmd)
3092 shell(cmd)
3088 if arg == '-nolegacy':
3093 if arg == '-nolegacy':
3089 legacy = userdir.files('ipythonrc*')
3094 legacy = userdir.files('ipythonrc*')
3090 print "Nuking legacy files:",legacy
3095 print "Nuking legacy files:",legacy
3091
3096
3092 [p.remove() for p in legacy]
3097 [p.remove() for p in legacy]
3093 suffix = (sys.platform == 'win32' and '.ini' or '')
3098 suffix = (sys.platform == 'win32' and '.ini' or '')
3094 (userdir / ('ipythonrc' + suffix)).write_text('# Empty, see ipy_user_conf.py\n')
3099 (userdir / ('ipythonrc' + suffix)).write_text('# Empty, see ipy_user_conf.py\n')
3095
3100
3096 # end Magic
3101 # end Magic
@@ -1,2578 +1,2579 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 2173 2007-03-23 14:26:16Z vivainio $
9 $Id: iplib.py 2187 2007-03-30 04:56:40Z fperez $
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 self.line_split = re.compile(r'^(\s*[,;/]?\s*)'
490 self.line_split = re.compile(r'^(\s*[,;/]?\s*)'
491 r'([\?\w\.]+\w*\s*)'
491 r'([\?\w\.]+\w*\s*)'
492 r'(\(?.*$)')
492 r'(\(?.*$)')
493
493
494 self.shell_line_split = re.compile(r'^(\s*)'
494 self.shell_line_split = re.compile(r'^(\s*)'
495 r'(\S*\s*)'
495 r'(\S*\s*)'
496 r'(\(?.*$)')
496 r'(\(?.*$)')
497
497
498
498
499 # A simpler regexp used as a fallback if the above doesn't work. This
499 # A simpler regexp used as a fallback if the above doesn't work. This
500 # one is more conservative in how it partitions the input. This code
500 # one is more conservative in how it partitions the input. This code
501 # can probably be cleaned up to do everything with just one regexp, but
501 # can probably be cleaned up to do everything with just one regexp, but
502 # I'm afraid of breaking something; do it once the unit tests are in
502 # I'm afraid of breaking something; do it once the unit tests are in
503 # place.
503 # place.
504 self.line_split_fallback = re.compile(r'^(\s*)'
504 self.line_split_fallback = re.compile(r'^(\s*)'
505 r'([%\!\?\w\.]*)'
505 r'([%\!\?\w\.]*)'
506 r'(.*)')
506 r'(.*)')
507
507
508 # Original re, keep around for a while in case changes break something
508 # Original re, keep around for a while in case changes break something
509 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
509 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
510 # r'(\s*[\?\w\.]+\w*\s*)'
510 # r'(\s*[\?\w\.]+\w*\s*)'
511 # r'(\(?.*$)')
511 # r'(\(?.*$)')
512
512
513 # RegExp to identify potential function names
513 # RegExp to identify potential function names
514 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
514 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
515
515
516 # RegExp to exclude strings with this start from autocalling. In
516 # RegExp to exclude strings with this start from autocalling. In
517 # particular, all binary operators should be excluded, so that if foo
517 # particular, all binary operators should be excluded, so that if foo
518 # is callable, foo OP bar doesn't become foo(OP bar), which is
518 # is callable, foo OP bar doesn't become foo(OP bar), which is
519 # invalid. The characters '!=()' don't need to be checked for, as the
519 # invalid. The characters '!=()' don't need to be checked for, as the
520 # _prefilter routine explicitely does so, to catch direct calls and
520 # _prefilter routine explicitely does so, to catch direct calls and
521 # rebindings of existing names.
521 # rebindings of existing names.
522
522
523 # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise
523 # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise
524 # it affects the rest of the group in square brackets.
524 # it affects the rest of the group in square brackets.
525 self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]'
525 self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]'
526 '|^is |^not |^in |^and |^or ')
526 '|^is |^not |^in |^and |^or ')
527
527
528 # try to catch also methods for stuff in lists/tuples/dicts: off
528 # try to catch also methods for stuff in lists/tuples/dicts: off
529 # (experimental). For this to work, the line_split regexp would need
529 # (experimental). For this to work, the line_split regexp would need
530 # to be modified so it wouldn't break things at '['. That line is
530 # to be modified so it wouldn't break things at '['. That line is
531 # nasty enough that I shouldn't change it until I can test it _well_.
531 # nasty enough that I shouldn't change it until I can test it _well_.
532 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
532 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
533
533
534 # keep track of where we started running (mainly for crash post-mortem)
534 # keep track of where we started running (mainly for crash post-mortem)
535 self.starting_dir = os.getcwd()
535 self.starting_dir = os.getcwd()
536
536
537 # Various switches which can be set
537 # Various switches which can be set
538 self.CACHELENGTH = 5000 # this is cheap, it's just text
538 self.CACHELENGTH = 5000 # this is cheap, it's just text
539 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
539 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
540 self.banner2 = banner2
540 self.banner2 = banner2
541
541
542 # TraceBack handlers:
542 # TraceBack handlers:
543
543
544 # Syntax error handler.
544 # Syntax error handler.
545 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
545 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
546
546
547 # The interactive one is initialized with an offset, meaning we always
547 # The interactive one is initialized with an offset, meaning we always
548 # want to remove the topmost item in the traceback, which is our own
548 # want to remove the topmost item in the traceback, which is our own
549 # internal code. Valid modes: ['Plain','Context','Verbose']
549 # internal code. Valid modes: ['Plain','Context','Verbose']
550 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
550 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
551 color_scheme='NoColor',
551 color_scheme='NoColor',
552 tb_offset = 1)
552 tb_offset = 1)
553
553
554 # IPython itself shouldn't crash. This will produce a detailed
554 # IPython itself shouldn't crash. This will produce a detailed
555 # post-mortem if it does. But we only install the crash handler for
555 # post-mortem if it does. But we only install the crash handler for
556 # non-threaded shells, the threaded ones use a normal verbose reporter
556 # non-threaded shells, the threaded ones use a normal verbose reporter
557 # and lose the crash handler. This is because exceptions in the main
557 # and lose the crash handler. This is because exceptions in the main
558 # thread (such as in GUI code) propagate directly to sys.excepthook,
558 # thread (such as in GUI code) propagate directly to sys.excepthook,
559 # and there's no point in printing crash dumps for every user exception.
559 # and there's no point in printing crash dumps for every user exception.
560 if self.isthreaded:
560 if self.isthreaded:
561 ipCrashHandler = ultraTB.FormattedTB()
561 ipCrashHandler = ultraTB.FormattedTB()
562 else:
562 else:
563 from IPython import CrashHandler
563 from IPython import CrashHandler
564 ipCrashHandler = CrashHandler.IPythonCrashHandler(self)
564 ipCrashHandler = CrashHandler.IPythonCrashHandler(self)
565 self.set_crash_handler(ipCrashHandler)
565 self.set_crash_handler(ipCrashHandler)
566
566
567 # and add any custom exception handlers the user may have specified
567 # and add any custom exception handlers the user may have specified
568 self.set_custom_exc(*custom_exceptions)
568 self.set_custom_exc(*custom_exceptions)
569
569
570 # indentation management
570 # indentation management
571 self.autoindent = False
571 self.autoindent = False
572 self.indent_current_nsp = 0
572 self.indent_current_nsp = 0
573
573
574 # Make some aliases automatically
574 # Make some aliases automatically
575 # Prepare list of shell aliases to auto-define
575 # Prepare list of shell aliases to auto-define
576 if os.name == 'posix':
576 if os.name == 'posix':
577 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
577 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
578 'mv mv -i','rm rm -i','cp cp -i',
578 'mv mv -i','rm rm -i','cp cp -i',
579 'cat cat','less less','clear clear',
579 'cat cat','less less','clear clear',
580 # a better ls
580 # a better ls
581 'ls ls -F',
581 'ls ls -F',
582 # long ls
582 # long ls
583 'll ls -lF')
583 'll ls -lF')
584 # Extra ls aliases with color, which need special treatment on BSD
584 # Extra ls aliases with color, which need special treatment on BSD
585 # variants
585 # variants
586 ls_extra = ( # color ls
586 ls_extra = ( # color ls
587 'lc ls -F -o --color',
587 'lc ls -F -o --color',
588 # ls normal files only
588 # ls normal files only
589 'lf ls -F -o --color %l | grep ^-',
589 'lf ls -F -o --color %l | grep ^-',
590 # ls symbolic links
590 # ls symbolic links
591 'lk ls -F -o --color %l | grep ^l',
591 'lk ls -F -o --color %l | grep ^l',
592 # directories or links to directories,
592 # directories or links to directories,
593 'ldir ls -F -o --color %l | grep /$',
593 'ldir ls -F -o --color %l | grep /$',
594 # things which are executable
594 # things which are executable
595 'lx ls -F -o --color %l | grep ^-..x',
595 'lx ls -F -o --color %l | grep ^-..x',
596 )
596 )
597 # The BSDs don't ship GNU ls, so they don't understand the
597 # The BSDs don't ship GNU ls, so they don't understand the
598 # --color switch out of the box
598 # --color switch out of the box
599 if 'bsd' in sys.platform:
599 if 'bsd' in sys.platform:
600 ls_extra = ( # ls normal files only
600 ls_extra = ( # ls normal files only
601 'lf ls -lF | grep ^-',
601 'lf ls -lF | grep ^-',
602 # ls symbolic links
602 # ls symbolic links
603 'lk ls -lF | grep ^l',
603 'lk ls -lF | grep ^l',
604 # directories or links to directories,
604 # directories or links to directories,
605 'ldir ls -lF | grep /$',
605 'ldir ls -lF | grep /$',
606 # things which are executable
606 # things which are executable
607 'lx ls -lF | grep ^-..x',
607 'lx ls -lF | grep ^-..x',
608 )
608 )
609 auto_alias = auto_alias + ls_extra
609 auto_alias = auto_alias + ls_extra
610 elif os.name in ['nt','dos']:
610 elif os.name in ['nt','dos']:
611 auto_alias = ('dir dir /on', 'ls dir /on',
611 auto_alias = ('dir dir /on', 'ls dir /on',
612 'ddir dir /ad /on', 'ldir dir /ad /on',
612 'ddir dir /ad /on', 'ldir dir /ad /on',
613 'mkdir mkdir','rmdir rmdir','echo echo',
613 'mkdir mkdir','rmdir rmdir','echo echo',
614 'ren ren','cls cls','copy copy')
614 'ren ren','cls cls','copy copy')
615 else:
615 else:
616 auto_alias = ()
616 auto_alias = ()
617 self.auto_alias = [s.split(None,1) for s in auto_alias]
617 self.auto_alias = [s.split(None,1) for s in auto_alias]
618 # Call the actual (public) initializer
618 # Call the actual (public) initializer
619 self.init_auto_alias()
619 self.init_auto_alias()
620
620
621 # Produce a public API instance
621 # Produce a public API instance
622 self.api = IPython.ipapi.IPApi(self)
622 self.api = IPython.ipapi.IPApi(self)
623
623
624 # track which builtins we add, so we can clean up later
624 # track which builtins we add, so we can clean up later
625 self.builtins_added = {}
625 self.builtins_added = {}
626 # This method will add the necessary builtins for operation, but
626 # This method will add the necessary builtins for operation, but
627 # tracking what it did via the builtins_added dict.
627 # tracking what it did via the builtins_added dict.
628 self.add_builtins()
628 self.add_builtins()
629
629
630 # end __init__
630 # end __init__
631
631
632 def var_expand(self,cmd,depth=0):
632 def var_expand(self,cmd,depth=0):
633 """Expand python variables in a string.
633 """Expand python variables in a string.
634
634
635 The depth argument indicates how many frames above the caller should
635 The depth argument indicates how many frames above the caller should
636 be walked to look for the local namespace where to expand variables.
636 be walked to look for the local namespace where to expand variables.
637
637
638 The global namespace for expansion is always the user's interactive
638 The global namespace for expansion is always the user's interactive
639 namespace.
639 namespace.
640 """
640 """
641
641
642 return str(ItplNS(cmd.replace('#','\#'),
642 return str(ItplNS(cmd.replace('#','\#'),
643 self.user_ns, # globals
643 self.user_ns, # globals
644 # Skip our own frame in searching for locals:
644 # Skip our own frame in searching for locals:
645 sys._getframe(depth+1).f_locals # locals
645 sys._getframe(depth+1).f_locals # locals
646 ))
646 ))
647
647
648 def pre_config_initialization(self):
648 def pre_config_initialization(self):
649 """Pre-configuration init method
649 """Pre-configuration init method
650
650
651 This is called before the configuration files are processed to
651 This is called before the configuration files are processed to
652 prepare the services the config files might need.
652 prepare the services the config files might need.
653
653
654 self.rc already has reasonable default values at this point.
654 self.rc already has reasonable default values at this point.
655 """
655 """
656 rc = self.rc
656 rc = self.rc
657
657
658 self.db = pickleshare.PickleShareDB(rc.ipythondir + "/db")
658 self.db = pickleshare.PickleShareDB(rc.ipythondir + "/db")
659
659
660 def post_config_initialization(self):
660 def post_config_initialization(self):
661 """Post configuration init method
661 """Post configuration init method
662
662
663 This is called after the configuration files have been processed to
663 This is called after the configuration files have been processed to
664 'finalize' the initialization."""
664 'finalize' the initialization."""
665
665
666 rc = self.rc
666 rc = self.rc
667
667
668 # Object inspector
668 # Object inspector
669 self.inspector = OInspect.Inspector(OInspect.InspectColors,
669 self.inspector = OInspect.Inspector(OInspect.InspectColors,
670 PyColorize.ANSICodeColors,
670 PyColorize.ANSICodeColors,
671 'NoColor',
671 'NoColor',
672 rc.object_info_string_level)
672 rc.object_info_string_level)
673
673
674 # Load readline proper
674 # Load readline proper
675 if rc.readline:
675 if rc.readline:
676 self.init_readline()
676 self.init_readline()
677
677
678 # local shortcut, this is used a LOT
678 # local shortcut, this is used a LOT
679 self.log = self.logger.log
679 self.log = self.logger.log
680
680
681 # Initialize cache, set in/out prompts and printing system
681 # Initialize cache, set in/out prompts and printing system
682 self.outputcache = CachedOutput(self,
682 self.outputcache = CachedOutput(self,
683 rc.cache_size,
683 rc.cache_size,
684 rc.pprint,
684 rc.pprint,
685 input_sep = rc.separate_in,
685 input_sep = rc.separate_in,
686 output_sep = rc.separate_out,
686 output_sep = rc.separate_out,
687 output_sep2 = rc.separate_out2,
687 output_sep2 = rc.separate_out2,
688 ps1 = rc.prompt_in1,
688 ps1 = rc.prompt_in1,
689 ps2 = rc.prompt_in2,
689 ps2 = rc.prompt_in2,
690 ps_out = rc.prompt_out,
690 ps_out = rc.prompt_out,
691 pad_left = rc.prompts_pad_left)
691 pad_left = rc.prompts_pad_left)
692
692
693 # user may have over-ridden the default print hook:
693 # user may have over-ridden the default print hook:
694 try:
694 try:
695 self.outputcache.__class__.display = self.hooks.display
695 self.outputcache.__class__.display = self.hooks.display
696 except AttributeError:
696 except AttributeError:
697 pass
697 pass
698
698
699 # I don't like assigning globally to sys, because it means when
699 # I don't like assigning globally to sys, because it means when
700 # embedding instances, each embedded instance overrides the previous
700 # embedding instances, each embedded instance overrides the previous
701 # choice. But sys.displayhook seems to be called internally by exec,
701 # choice. But sys.displayhook seems to be called internally by exec,
702 # so I don't see a way around it. We first save the original and then
702 # so I don't see a way around it. We first save the original and then
703 # overwrite it.
703 # overwrite it.
704 self.sys_displayhook = sys.displayhook
704 self.sys_displayhook = sys.displayhook
705 sys.displayhook = self.outputcache
705 sys.displayhook = self.outputcache
706
706
707 # Set user colors (don't do it in the constructor above so that it
707 # Set user colors (don't do it in the constructor above so that it
708 # doesn't crash if colors option is invalid)
708 # doesn't crash if colors option is invalid)
709 self.magic_colors(rc.colors)
709 self.magic_colors(rc.colors)
710
710
711 # Set calling of pdb on exceptions
711 # Set calling of pdb on exceptions
712 self.call_pdb = rc.pdb
712 self.call_pdb = rc.pdb
713
713
714 # Load user aliases
714 # Load user aliases
715 for alias in rc.alias:
715 for alias in rc.alias:
716 self.magic_alias(alias)
716 self.magic_alias(alias)
717 self.hooks.late_startup_hook()
717 self.hooks.late_startup_hook()
718
718
719 batchrun = False
719 batchrun = False
720 for batchfile in [path(arg) for arg in self.rc.args
720 for batchfile in [path(arg) for arg in self.rc.args
721 if arg.lower().endswith('.ipy')]:
721 if arg.lower().endswith('.ipy')]:
722 if not batchfile.isfile():
722 if not batchfile.isfile():
723 print "No such batch file:", batchfile
723 print "No such batch file:", batchfile
724 continue
724 continue
725 self.api.runlines(batchfile.text())
725 self.api.runlines(batchfile.text())
726 batchrun = True
726 batchrun = True
727 if batchrun:
727 if batchrun:
728 self.exit_now = True
728 self.exit_now = True
729
729
730 def add_builtins(self):
730 def add_builtins(self):
731 """Store ipython references into the builtin namespace.
731 """Store ipython references into the builtin namespace.
732
732
733 Some parts of ipython operate via builtins injected here, which hold a
733 Some parts of ipython operate via builtins injected here, which hold a
734 reference to IPython itself."""
734 reference to IPython itself."""
735
735
736 # TODO: deprecate all except _ip; 'jobs' should be installed
736 # TODO: deprecate all except _ip; 'jobs' should be installed
737 # by an extension and the rest are under _ip, ipalias is redundant
737 # by an extension and the rest are under _ip, ipalias is redundant
738 builtins_new = dict(__IPYTHON__ = self,
738 builtins_new = dict(__IPYTHON__ = self,
739 ip_set_hook = self.set_hook,
739 ip_set_hook = self.set_hook,
740 jobs = self.jobs,
740 jobs = self.jobs,
741 ipmagic = wrap_deprecated(self.ipmagic,'_ip.magic()'),
741 ipmagic = wrap_deprecated(self.ipmagic,'_ip.magic()'),
742 ipalias = wrap_deprecated(self.ipalias),
742 ipalias = wrap_deprecated(self.ipalias),
743 ipsystem = wrap_deprecated(self.ipsystem,'_ip.system()'),
743 ipsystem = wrap_deprecated(self.ipsystem,'_ip.system()'),
744 _ip = self.api
744 _ip = self.api
745 )
745 )
746 for biname,bival in builtins_new.items():
746 for biname,bival in builtins_new.items():
747 try:
747 try:
748 # store the orignal value so we can restore it
748 # store the orignal value so we can restore it
749 self.builtins_added[biname] = __builtin__.__dict__[biname]
749 self.builtins_added[biname] = __builtin__.__dict__[biname]
750 except KeyError:
750 except KeyError:
751 # or mark that it wasn't defined, and we'll just delete it at
751 # or mark that it wasn't defined, and we'll just delete it at
752 # cleanup
752 # cleanup
753 self.builtins_added[biname] = Undefined
753 self.builtins_added[biname] = Undefined
754 __builtin__.__dict__[biname] = bival
754 __builtin__.__dict__[biname] = bival
755
755
756 # Keep in the builtins a flag for when IPython is active. We set it
756 # Keep in the builtins a flag for when IPython is active. We set it
757 # with setdefault so that multiple nested IPythons don't clobber one
757 # with setdefault so that multiple nested IPythons don't clobber one
758 # another. Each will increase its value by one upon being activated,
758 # another. Each will increase its value by one upon being activated,
759 # which also gives us a way to determine the nesting level.
759 # which also gives us a way to determine the nesting level.
760 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
760 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
761
761
762 def clean_builtins(self):
762 def clean_builtins(self):
763 """Remove any builtins which might have been added by add_builtins, or
763 """Remove any builtins which might have been added by add_builtins, or
764 restore overwritten ones to their previous values."""
764 restore overwritten ones to their previous values."""
765 for biname,bival in self.builtins_added.items():
765 for biname,bival in self.builtins_added.items():
766 if bival is Undefined:
766 if bival is Undefined:
767 del __builtin__.__dict__[biname]
767 del __builtin__.__dict__[biname]
768 else:
768 else:
769 __builtin__.__dict__[biname] = bival
769 __builtin__.__dict__[biname] = bival
770 self.builtins_added.clear()
770 self.builtins_added.clear()
771
771
772 def set_hook(self,name,hook, priority = 50, str_key = None, re_key = None):
772 def set_hook(self,name,hook, priority = 50, str_key = None, re_key = None):
773 """set_hook(name,hook) -> sets an internal IPython hook.
773 """set_hook(name,hook) -> sets an internal IPython hook.
774
774
775 IPython exposes some of its internal API as user-modifiable hooks. By
775 IPython exposes some of its internal API as user-modifiable hooks. By
776 adding your function to one of these hooks, you can modify IPython's
776 adding your function to one of these hooks, you can modify IPython's
777 behavior to call at runtime your own routines."""
777 behavior to call at runtime your own routines."""
778
778
779 # At some point in the future, this should validate the hook before it
779 # At some point in the future, this should validate the hook before it
780 # accepts it. Probably at least check that the hook takes the number
780 # accepts it. Probably at least check that the hook takes the number
781 # of args it's supposed to.
781 # of args it's supposed to.
782
782
783 f = new.instancemethod(hook,self,self.__class__)
783 f = new.instancemethod(hook,self,self.__class__)
784
784
785 # check if the hook is for strdispatcher first
785 # check if the hook is for strdispatcher first
786 if str_key is not None:
786 if str_key is not None:
787 sdp = self.strdispatchers.get(name, StrDispatch())
787 sdp = self.strdispatchers.get(name, StrDispatch())
788 sdp.add_s(str_key, f, priority )
788 sdp.add_s(str_key, f, priority )
789 self.strdispatchers[name] = sdp
789 self.strdispatchers[name] = sdp
790 return
790 return
791 if re_key is not None:
791 if re_key is not None:
792 sdp = self.strdispatchers.get(name, StrDispatch())
792 sdp = self.strdispatchers.get(name, StrDispatch())
793 sdp.add_re(re.compile(re_key), f, priority )
793 sdp.add_re(re.compile(re_key), f, priority )
794 self.strdispatchers[name] = sdp
794 self.strdispatchers[name] = sdp
795 return
795 return
796
796
797 dp = getattr(self.hooks, name, None)
797 dp = getattr(self.hooks, name, None)
798 if name not in IPython.hooks.__all__:
798 if name not in IPython.hooks.__all__:
799 print "Warning! Hook '%s' is not one of %s" % (name, IPython.hooks.__all__ )
799 print "Warning! Hook '%s' is not one of %s" % (name, IPython.hooks.__all__ )
800 if not dp:
800 if not dp:
801 dp = IPython.hooks.CommandChainDispatcher()
801 dp = IPython.hooks.CommandChainDispatcher()
802
802
803 try:
803 try:
804 dp.add(f,priority)
804 dp.add(f,priority)
805 except AttributeError:
805 except AttributeError:
806 # it was not commandchain, plain old func - replace
806 # it was not commandchain, plain old func - replace
807 dp = f
807 dp = f
808
808
809 setattr(self.hooks,name, dp)
809 setattr(self.hooks,name, dp)
810
810
811
811
812 #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
812 #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
813
813
814 def set_crash_handler(self,crashHandler):
814 def set_crash_handler(self,crashHandler):
815 """Set the IPython crash handler.
815 """Set the IPython crash handler.
816
816
817 This must be a callable with a signature suitable for use as
817 This must be a callable with a signature suitable for use as
818 sys.excepthook."""
818 sys.excepthook."""
819
819
820 # Install the given crash handler as the Python exception hook
820 # Install the given crash handler as the Python exception hook
821 sys.excepthook = crashHandler
821 sys.excepthook = crashHandler
822
822
823 # The instance will store a pointer to this, so that runtime code
823 # The instance will store a pointer to this, so that runtime code
824 # (such as magics) can access it. This is because during the
824 # (such as magics) can access it. This is because during the
825 # read-eval loop, it gets temporarily overwritten (to deal with GUI
825 # read-eval loop, it gets temporarily overwritten (to deal with GUI
826 # frameworks).
826 # frameworks).
827 self.sys_excepthook = sys.excepthook
827 self.sys_excepthook = sys.excepthook
828
828
829
829
830 def set_custom_exc(self,exc_tuple,handler):
830 def set_custom_exc(self,exc_tuple,handler):
831 """set_custom_exc(exc_tuple,handler)
831 """set_custom_exc(exc_tuple,handler)
832
832
833 Set a custom exception handler, which will be called if any of the
833 Set a custom exception handler, which will be called if any of the
834 exceptions in exc_tuple occur in the mainloop (specifically, in the
834 exceptions in exc_tuple occur in the mainloop (specifically, in the
835 runcode() method.
835 runcode() method.
836
836
837 Inputs:
837 Inputs:
838
838
839 - exc_tuple: a *tuple* of valid exceptions to call the defined
839 - exc_tuple: a *tuple* of valid exceptions to call the defined
840 handler for. It is very important that you use a tuple, and NOT A
840 handler for. It is very important that you use a tuple, and NOT A
841 LIST here, because of the way Python's except statement works. If
841 LIST here, because of the way Python's except statement works. If
842 you only want to trap a single exception, use a singleton tuple:
842 you only want to trap a single exception, use a singleton tuple:
843
843
844 exc_tuple == (MyCustomException,)
844 exc_tuple == (MyCustomException,)
845
845
846 - handler: this must be defined as a function with the following
846 - handler: this must be defined as a function with the following
847 basic interface: def my_handler(self,etype,value,tb).
847 basic interface: def my_handler(self,etype,value,tb).
848
848
849 This will be made into an instance method (via new.instancemethod)
849 This will be made into an instance method (via new.instancemethod)
850 of IPython itself, and it will be called if any of the exceptions
850 of IPython itself, and it will be called if any of the exceptions
851 listed in the exc_tuple are caught. If the handler is None, an
851 listed in the exc_tuple are caught. If the handler is None, an
852 internal basic one is used, which just prints basic info.
852 internal basic one is used, which just prints basic info.
853
853
854 WARNING: by putting in your own exception handler into IPython's main
854 WARNING: by putting in your own exception handler into IPython's main
855 execution loop, you run a very good chance of nasty crashes. This
855 execution loop, you run a very good chance of nasty crashes. This
856 facility should only be used if you really know what you are doing."""
856 facility should only be used if you really know what you are doing."""
857
857
858 assert type(exc_tuple)==type(()) , \
858 assert type(exc_tuple)==type(()) , \
859 "The custom exceptions must be given AS A TUPLE."
859 "The custom exceptions must be given AS A TUPLE."
860
860
861 def dummy_handler(self,etype,value,tb):
861 def dummy_handler(self,etype,value,tb):
862 print '*** Simple custom exception handler ***'
862 print '*** Simple custom exception handler ***'
863 print 'Exception type :',etype
863 print 'Exception type :',etype
864 print 'Exception value:',value
864 print 'Exception value:',value
865 print 'Traceback :',tb
865 print 'Traceback :',tb
866 print 'Source code :','\n'.join(self.buffer)
866 print 'Source code :','\n'.join(self.buffer)
867
867
868 if handler is None: handler = dummy_handler
868 if handler is None: handler = dummy_handler
869
869
870 self.CustomTB = new.instancemethod(handler,self,self.__class__)
870 self.CustomTB = new.instancemethod(handler,self,self.__class__)
871 self.custom_exceptions = exc_tuple
871 self.custom_exceptions = exc_tuple
872
872
873 def set_custom_completer(self,completer,pos=0):
873 def set_custom_completer(self,completer,pos=0):
874 """set_custom_completer(completer,pos=0)
874 """set_custom_completer(completer,pos=0)
875
875
876 Adds a new custom completer function.
876 Adds a new custom completer function.
877
877
878 The position argument (defaults to 0) is the index in the completers
878 The position argument (defaults to 0) is the index in the completers
879 list where you want the completer to be inserted."""
879 list where you want the completer to be inserted."""
880
880
881 newcomp = new.instancemethod(completer,self.Completer,
881 newcomp = new.instancemethod(completer,self.Completer,
882 self.Completer.__class__)
882 self.Completer.__class__)
883 self.Completer.matchers.insert(pos,newcomp)
883 self.Completer.matchers.insert(pos,newcomp)
884
884
885 def _get_call_pdb(self):
885 def _get_call_pdb(self):
886 return self._call_pdb
886 return self._call_pdb
887
887
888 def _set_call_pdb(self,val):
888 def _set_call_pdb(self,val):
889
889
890 if val not in (0,1,False,True):
890 if val not in (0,1,False,True):
891 raise ValueError,'new call_pdb value must be boolean'
891 raise ValueError,'new call_pdb value must be boolean'
892
892
893 # store value in instance
893 # store value in instance
894 self._call_pdb = val
894 self._call_pdb = val
895
895
896 # notify the actual exception handlers
896 # notify the actual exception handlers
897 self.InteractiveTB.call_pdb = val
897 self.InteractiveTB.call_pdb = val
898 if self.isthreaded:
898 if self.isthreaded:
899 try:
899 try:
900 self.sys_excepthook.call_pdb = val
900 self.sys_excepthook.call_pdb = val
901 except:
901 except:
902 warn('Failed to activate pdb for threaded exception handler')
902 warn('Failed to activate pdb for threaded exception handler')
903
903
904 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
904 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
905 'Control auto-activation of pdb at exceptions')
905 'Control auto-activation of pdb at exceptions')
906
906
907
907
908 # These special functions get installed in the builtin namespace, to
908 # These special functions get installed in the builtin namespace, to
909 # provide programmatic (pure python) access to magics, aliases and system
909 # provide programmatic (pure python) access to magics, aliases and system
910 # calls. This is important for logging, user scripting, and more.
910 # calls. This is important for logging, user scripting, and more.
911
911
912 # We are basically exposing, via normal python functions, the three
912 # We are basically exposing, via normal python functions, the three
913 # mechanisms in which ipython offers special call modes (magics for
913 # mechanisms in which ipython offers special call modes (magics for
914 # internal control, aliases for direct system access via pre-selected
914 # internal control, aliases for direct system access via pre-selected
915 # names, and !cmd for calling arbitrary system commands).
915 # names, and !cmd for calling arbitrary system commands).
916
916
917 def ipmagic(self,arg_s):
917 def ipmagic(self,arg_s):
918 """Call a magic function by name.
918 """Call a magic function by name.
919
919
920 Input: a string containing the name of the magic function to call and any
920 Input: a string containing the name of the magic function to call and any
921 additional arguments to be passed to the magic.
921 additional arguments to be passed to the magic.
922
922
923 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
923 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
924 prompt:
924 prompt:
925
925
926 In[1]: %name -opt foo bar
926 In[1]: %name -opt foo bar
927
927
928 To call a magic without arguments, simply use ipmagic('name').
928 To call a magic without arguments, simply use ipmagic('name').
929
929
930 This provides a proper Python function to call IPython's magics in any
930 This provides a proper Python function to call IPython's magics in any
931 valid Python code you can type at the interpreter, including loops and
931 valid Python code you can type at the interpreter, including loops and
932 compound statements. It is added by IPython to the Python builtin
932 compound statements. It is added by IPython to the Python builtin
933 namespace upon initialization."""
933 namespace upon initialization."""
934
934
935 args = arg_s.split(' ',1)
935 args = arg_s.split(' ',1)
936 magic_name = args[0]
936 magic_name = args[0]
937 magic_name = magic_name.lstrip(self.ESC_MAGIC)
937 magic_name = magic_name.lstrip(self.ESC_MAGIC)
938
938
939 try:
939 try:
940 magic_args = args[1]
940 magic_args = args[1]
941 except IndexError:
941 except IndexError:
942 magic_args = ''
942 magic_args = ''
943 fn = getattr(self,'magic_'+magic_name,None)
943 fn = getattr(self,'magic_'+magic_name,None)
944 if fn is None:
944 if fn is None:
945 error("Magic function `%s` not found." % magic_name)
945 error("Magic function `%s` not found." % magic_name)
946 else:
946 else:
947 magic_args = self.var_expand(magic_args,1)
947 magic_args = self.var_expand(magic_args,1)
948 return fn(magic_args)
948 return fn(magic_args)
949
949
950 def ipalias(self,arg_s):
950 def ipalias(self,arg_s):
951 """Call an alias by name.
951 """Call an alias by name.
952
952
953 Input: a string containing the name of the alias to call and any
953 Input: a string containing the name of the alias to call and any
954 additional arguments to be passed to the magic.
954 additional arguments to be passed to the magic.
955
955
956 ipalias('name -opt foo bar') is equivalent to typing at the ipython
956 ipalias('name -opt foo bar') is equivalent to typing at the ipython
957 prompt:
957 prompt:
958
958
959 In[1]: name -opt foo bar
959 In[1]: name -opt foo bar
960
960
961 To call an alias without arguments, simply use ipalias('name').
961 To call an alias without arguments, simply use ipalias('name').
962
962
963 This provides a proper Python function to call IPython's aliases in any
963 This provides a proper Python function to call IPython's aliases in any
964 valid Python code you can type at the interpreter, including loops and
964 valid Python code you can type at the interpreter, including loops and
965 compound statements. It is added by IPython to the Python builtin
965 compound statements. It is added by IPython to the Python builtin
966 namespace upon initialization."""
966 namespace upon initialization."""
967
967
968 args = arg_s.split(' ',1)
968 args = arg_s.split(' ',1)
969 alias_name = args[0]
969 alias_name = args[0]
970 try:
970 try:
971 alias_args = args[1]
971 alias_args = args[1]
972 except IndexError:
972 except IndexError:
973 alias_args = ''
973 alias_args = ''
974 if alias_name in self.alias_table:
974 if alias_name in self.alias_table:
975 self.call_alias(alias_name,alias_args)
975 self.call_alias(alias_name,alias_args)
976 else:
976 else:
977 error("Alias `%s` not found." % alias_name)
977 error("Alias `%s` not found." % alias_name)
978
978
979 def ipsystem(self,arg_s):
979 def ipsystem(self,arg_s):
980 """Make a system call, using IPython."""
980 """Make a system call, using IPython."""
981
981
982 self.system(arg_s)
982 self.system(arg_s)
983
983
984 def complete(self,text):
984 def complete(self,text):
985 """Return a sorted list of all possible completions on text.
985 """Return a sorted list of all possible completions on text.
986
986
987 Inputs:
987 Inputs:
988
988
989 - text: a string of text to be completed on.
989 - text: a string of text to be completed on.
990
990
991 This is a wrapper around the completion mechanism, similar to what
991 This is a wrapper around the completion mechanism, similar to what
992 readline does at the command line when the TAB key is hit. By
992 readline does at the command line when the TAB key is hit. By
993 exposing it as a method, it can be used by other non-readline
993 exposing it as a method, it can be used by other non-readline
994 environments (such as GUIs) for text completion.
994 environments (such as GUIs) for text completion.
995
995
996 Simple usage example:
996 Simple usage example:
997
997
998 In [1]: x = 'hello'
998 In [1]: x = 'hello'
999
999
1000 In [2]: __IP.complete('x.l')
1000 In [2]: __IP.complete('x.l')
1001 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
1001 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
1002
1002
1003 complete = self.Completer.complete
1003 complete = self.Completer.complete
1004 state = 0
1004 state = 0
1005 # use a dict so we get unique keys, since ipyhton's multiple
1005 # use a dict so we get unique keys, since ipyhton's multiple
1006 # completers can return duplicates.
1006 # completers can return duplicates.
1007 comps = {}
1007 comps = {}
1008 while True:
1008 while True:
1009 newcomp = complete(text,state)
1009 newcomp = complete(text,state)
1010 if newcomp is None:
1010 if newcomp is None:
1011 break
1011 break
1012 comps[newcomp] = 1
1012 comps[newcomp] = 1
1013 state += 1
1013 state += 1
1014 outcomps = comps.keys()
1014 outcomps = comps.keys()
1015 outcomps.sort()
1015 outcomps.sort()
1016 return outcomps
1016 return outcomps
1017
1017
1018 def set_completer_frame(self, frame=None):
1018 def set_completer_frame(self, frame=None):
1019 if frame:
1019 if frame:
1020 self.Completer.namespace = frame.f_locals
1020 self.Completer.namespace = frame.f_locals
1021 self.Completer.global_namespace = frame.f_globals
1021 self.Completer.global_namespace = frame.f_globals
1022 else:
1022 else:
1023 self.Completer.namespace = self.user_ns
1023 self.Completer.namespace = self.user_ns
1024 self.Completer.global_namespace = self.user_global_ns
1024 self.Completer.global_namespace = self.user_global_ns
1025
1025
1026 def init_auto_alias(self):
1026 def init_auto_alias(self):
1027 """Define some aliases automatically.
1027 """Define some aliases automatically.
1028
1028
1029 These are ALL parameter-less aliases"""
1029 These are ALL parameter-less aliases"""
1030
1030
1031 for alias,cmd in self.auto_alias:
1031 for alias,cmd in self.auto_alias:
1032 self.alias_table[alias] = (0,cmd)
1032 self.alias_table[alias] = (0,cmd)
1033
1033
1034 def alias_table_validate(self,verbose=0):
1034 def alias_table_validate(self,verbose=0):
1035 """Update information about the alias table.
1035 """Update information about the alias table.
1036
1036
1037 In particular, make sure no Python keywords/builtins are in it."""
1037 In particular, make sure no Python keywords/builtins are in it."""
1038
1038
1039 no_alias = self.no_alias
1039 no_alias = self.no_alias
1040 for k in self.alias_table.keys():
1040 for k in self.alias_table.keys():
1041 if k in no_alias:
1041 if k in no_alias:
1042 del self.alias_table[k]
1042 del self.alias_table[k]
1043 if verbose:
1043 if verbose:
1044 print ("Deleting alias <%s>, it's a Python "
1044 print ("Deleting alias <%s>, it's a Python "
1045 "keyword or builtin." % k)
1045 "keyword or builtin." % k)
1046
1046
1047 def set_autoindent(self,value=None):
1047 def set_autoindent(self,value=None):
1048 """Set the autoindent flag, checking for readline support.
1048 """Set the autoindent flag, checking for readline support.
1049
1049
1050 If called with no arguments, it acts as a toggle."""
1050 If called with no arguments, it acts as a toggle."""
1051
1051
1052 if not self.has_readline:
1052 if not self.has_readline:
1053 if os.name == 'posix':
1053 if os.name == 'posix':
1054 warn("The auto-indent feature requires the readline library")
1054 warn("The auto-indent feature requires the readline library")
1055 self.autoindent = 0
1055 self.autoindent = 0
1056 return
1056 return
1057 if value is None:
1057 if value is None:
1058 self.autoindent = not self.autoindent
1058 self.autoindent = not self.autoindent
1059 else:
1059 else:
1060 self.autoindent = value
1060 self.autoindent = value
1061
1061
1062 def rc_set_toggle(self,rc_field,value=None):
1062 def rc_set_toggle(self,rc_field,value=None):
1063 """Set or toggle a field in IPython's rc config. structure.
1063 """Set or toggle a field in IPython's rc config. structure.
1064
1064
1065 If called with no arguments, it acts as a toggle.
1065 If called with no arguments, it acts as a toggle.
1066
1066
1067 If called with a non-existent field, the resulting AttributeError
1067 If called with a non-existent field, the resulting AttributeError
1068 exception will propagate out."""
1068 exception will propagate out."""
1069
1069
1070 rc_val = getattr(self.rc,rc_field)
1070 rc_val = getattr(self.rc,rc_field)
1071 if value is None:
1071 if value is None:
1072 value = not rc_val
1072 value = not rc_val
1073 setattr(self.rc,rc_field,value)
1073 setattr(self.rc,rc_field,value)
1074
1074
1075 def user_setup(self,ipythondir,rc_suffix,mode='install'):
1075 def user_setup(self,ipythondir,rc_suffix,mode='install'):
1076 """Install the user configuration directory.
1076 """Install the user configuration directory.
1077
1077
1078 Can be called when running for the first time or to upgrade the user's
1078 Can be called when running for the first time or to upgrade the user's
1079 .ipython/ directory with the mode parameter. Valid modes are 'install'
1079 .ipython/ directory with the mode parameter. Valid modes are 'install'
1080 and 'upgrade'."""
1080 and 'upgrade'."""
1081
1081
1082 def wait():
1082 def wait():
1083 try:
1083 try:
1084 raw_input("Please press <RETURN> to start IPython.")
1084 raw_input("Please press <RETURN> to start IPython.")
1085 except EOFError:
1085 except EOFError:
1086 print >> Term.cout
1086 print >> Term.cout
1087 print '*'*70
1087 print '*'*70
1088
1088
1089 cwd = os.getcwd() # remember where we started
1089 cwd = os.getcwd() # remember where we started
1090 glb = glob.glob
1090 glb = glob.glob
1091 print '*'*70
1091 print '*'*70
1092 if mode == 'install':
1092 if mode == 'install':
1093 print \
1093 print \
1094 """Welcome to IPython. I will try to create a personal configuration directory
1094 """Welcome to IPython. I will try to create a personal configuration directory
1095 where you can customize many aspects of IPython's functionality in:\n"""
1095 where you can customize many aspects of IPython's functionality in:\n"""
1096 else:
1096 else:
1097 print 'I am going to upgrade your configuration in:'
1097 print 'I am going to upgrade your configuration in:'
1098
1098
1099 print ipythondir
1099 print ipythondir
1100
1100
1101 rcdirend = os.path.join('IPython','UserConfig')
1101 rcdirend = os.path.join('IPython','UserConfig')
1102 cfg = lambda d: os.path.join(d,rcdirend)
1102 cfg = lambda d: os.path.join(d,rcdirend)
1103 try:
1103 try:
1104 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1104 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1105 except IOError:
1105 except IOError:
1106 warning = """
1106 warning = """
1107 Installation error. IPython's directory was not found.
1107 Installation error. IPython's directory was not found.
1108
1108
1109 Check the following:
1109 Check the following:
1110
1110
1111 The ipython/IPython directory should be in a directory belonging to your
1111 The ipython/IPython directory should be in a directory belonging to your
1112 PYTHONPATH environment variable (that is, it should be in a directory
1112 PYTHONPATH environment variable (that is, it should be in a directory
1113 belonging to sys.path). You can copy it explicitly there or just link to it.
1113 belonging to sys.path). You can copy it explicitly there or just link to it.
1114
1114
1115 IPython will proceed with builtin defaults.
1115 IPython will proceed with builtin defaults.
1116 """
1116 """
1117 warn(warning)
1117 warn(warning)
1118 wait()
1118 wait()
1119 return
1119 return
1120
1120
1121 if mode == 'install':
1121 if mode == 'install':
1122 try:
1122 try:
1123 shutil.copytree(rcdir,ipythondir)
1123 shutil.copytree(rcdir,ipythondir)
1124 os.chdir(ipythondir)
1124 os.chdir(ipythondir)
1125 rc_files = glb("ipythonrc*")
1125 rc_files = glb("ipythonrc*")
1126 for rc_file in rc_files:
1126 for rc_file in rc_files:
1127 os.rename(rc_file,rc_file+rc_suffix)
1127 os.rename(rc_file,rc_file+rc_suffix)
1128 except:
1128 except:
1129 warning = """
1129 warning = """
1130
1130
1131 There was a problem with the installation:
1131 There was a problem with the installation:
1132 %s
1132 %s
1133 Try to correct it or contact the developers if you think it's a bug.
1133 Try to correct it or contact the developers if you think it's a bug.
1134 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1134 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1135 warn(warning)
1135 warn(warning)
1136 wait()
1136 wait()
1137 return
1137 return
1138
1138
1139 elif mode == 'upgrade':
1139 elif mode == 'upgrade':
1140 try:
1140 try:
1141 os.chdir(ipythondir)
1141 os.chdir(ipythondir)
1142 except:
1142 except:
1143 print """
1143 print """
1144 Can not upgrade: changing to directory %s failed. Details:
1144 Can not upgrade: changing to directory %s failed. Details:
1145 %s
1145 %s
1146 """ % (ipythondir,sys.exc_info()[1])
1146 """ % (ipythondir,sys.exc_info()[1])
1147 wait()
1147 wait()
1148 return
1148 return
1149 else:
1149 else:
1150 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1150 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1151 for new_full_path in sources:
1151 for new_full_path in sources:
1152 new_filename = os.path.basename(new_full_path)
1152 new_filename = os.path.basename(new_full_path)
1153 if new_filename.startswith('ipythonrc'):
1153 if new_filename.startswith('ipythonrc'):
1154 new_filename = new_filename + rc_suffix
1154 new_filename = new_filename + rc_suffix
1155 # The config directory should only contain files, skip any
1155 # The config directory should only contain files, skip any
1156 # directories which may be there (like CVS)
1156 # directories which may be there (like CVS)
1157 if os.path.isdir(new_full_path):
1157 if os.path.isdir(new_full_path):
1158 continue
1158 continue
1159 if os.path.exists(new_filename):
1159 if os.path.exists(new_filename):
1160 old_file = new_filename+'.old'
1160 old_file = new_filename+'.old'
1161 if os.path.exists(old_file):
1161 if os.path.exists(old_file):
1162 os.remove(old_file)
1162 os.remove(old_file)
1163 os.rename(new_filename,old_file)
1163 os.rename(new_filename,old_file)
1164 shutil.copy(new_full_path,new_filename)
1164 shutil.copy(new_full_path,new_filename)
1165 else:
1165 else:
1166 raise ValueError,'unrecognized mode for install:',`mode`
1166 raise ValueError,'unrecognized mode for install:',`mode`
1167
1167
1168 # Fix line-endings to those native to each platform in the config
1168 # Fix line-endings to those native to each platform in the config
1169 # directory.
1169 # directory.
1170 try:
1170 try:
1171 os.chdir(ipythondir)
1171 os.chdir(ipythondir)
1172 except:
1172 except:
1173 print """
1173 print """
1174 Problem: changing to directory %s failed.
1174 Problem: changing to directory %s failed.
1175 Details:
1175 Details:
1176 %s
1176 %s
1177
1177
1178 Some configuration files may have incorrect line endings. This should not
1178 Some configuration files may have incorrect line endings. This should not
1179 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1179 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1180 wait()
1180 wait()
1181 else:
1181 else:
1182 for fname in glb('ipythonrc*'):
1182 for fname in glb('ipythonrc*'):
1183 try:
1183 try:
1184 native_line_ends(fname,backup=0)
1184 native_line_ends(fname,backup=0)
1185 except IOError:
1185 except IOError:
1186 pass
1186 pass
1187
1187
1188 if mode == 'install':
1188 if mode == 'install':
1189 print """
1189 print """
1190 Successful installation!
1190 Successful installation!
1191
1191
1192 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1192 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1193 IPython manual (there are both HTML and PDF versions supplied with the
1193 IPython manual (there are both HTML and PDF versions supplied with the
1194 distribution) to make sure that your system environment is properly configured
1194 distribution) to make sure that your system environment is properly configured
1195 to take advantage of IPython's features.
1195 to take advantage of IPython's features.
1196
1196
1197 Important note: the configuration system has changed! The old system is
1197 Important note: the configuration system has changed! The old system is
1198 still in place, but its setting may be partly overridden by the settings in
1198 still in place, but its setting may be partly overridden by the settings in
1199 "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file
1199 "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file
1200 if some of the new settings bother you.
1200 if some of the new settings bother you.
1201
1201
1202 """
1202 """
1203 else:
1203 else:
1204 print """
1204 print """
1205 Successful upgrade!
1205 Successful upgrade!
1206
1206
1207 All files in your directory:
1207 All files in your directory:
1208 %(ipythondir)s
1208 %(ipythondir)s
1209 which would have been overwritten by the upgrade were backed up with a .old
1209 which would have been overwritten by the upgrade were backed up with a .old
1210 extension. If you had made particular customizations in those files you may
1210 extension. If you had made particular customizations in those files you may
1211 want to merge them back into the new files.""" % locals()
1211 want to merge them back into the new files.""" % locals()
1212 wait()
1212 wait()
1213 os.chdir(cwd)
1213 os.chdir(cwd)
1214 # end user_setup()
1214 # end user_setup()
1215
1215
1216 def atexit_operations(self):
1216 def atexit_operations(self):
1217 """This will be executed at the time of exit.
1217 """This will be executed at the time of exit.
1218
1218
1219 Saving of persistent data should be performed here. """
1219 Saving of persistent data should be performed here. """
1220
1220
1221 #print '*** IPython exit cleanup ***' # dbg
1221 #print '*** IPython exit cleanup ***' # dbg
1222 # input history
1222 # input history
1223 self.savehist()
1223 self.savehist()
1224
1224
1225 # Cleanup all tempfiles left around
1225 # Cleanup all tempfiles left around
1226 for tfile in self.tempfiles:
1226 for tfile in self.tempfiles:
1227 try:
1227 try:
1228 os.unlink(tfile)
1228 os.unlink(tfile)
1229 except OSError:
1229 except OSError:
1230 pass
1230 pass
1231
1231
1232 # save the "persistent data" catch-all dictionary
1232 # save the "persistent data" catch-all dictionary
1233 self.hooks.shutdown_hook()
1233 self.hooks.shutdown_hook()
1234
1234
1235 def savehist(self):
1235 def savehist(self):
1236 """Save input history to a file (via readline library)."""
1236 """Save input history to a file (via readline library)."""
1237 try:
1237 try:
1238 self.readline.write_history_file(self.histfile)
1238 self.readline.write_history_file(self.histfile)
1239 except:
1239 except:
1240 print 'Unable to save IPython command history to file: ' + \
1240 print 'Unable to save IPython command history to file: ' + \
1241 `self.histfile`
1241 `self.histfile`
1242
1242
1243 def history_saving_wrapper(self, func):
1243 def history_saving_wrapper(self, func):
1244 """ Wrap func for readline history saving
1244 """ Wrap func for readline history saving
1245
1245
1246 Convert func into callable that saves & restores
1246 Convert func into callable that saves & restores
1247 history around the call """
1247 history around the call """
1248
1248
1249 if not self.has_readline:
1249 if not self.has_readline:
1250 return func
1250 return func
1251
1251
1252 def wrapper():
1252 def wrapper():
1253 self.savehist()
1253 self.savehist()
1254 try:
1254 try:
1255 func()
1255 func()
1256 finally:
1256 finally:
1257 readline.read_history_file(self.histfile)
1257 readline.read_history_file(self.histfile)
1258 return wrapper
1258 return wrapper
1259
1259
1260
1260
1261 def pre_readline(self):
1261 def pre_readline(self):
1262 """readline hook to be used at the start of each line.
1262 """readline hook to be used at the start of each line.
1263
1263
1264 Currently it handles auto-indent only."""
1264 Currently it handles auto-indent only."""
1265
1265
1266 #debugx('self.indent_current_nsp','pre_readline:')
1266 #debugx('self.indent_current_nsp','pre_readline:')
1267 self.readline.insert_text(self.indent_current_str())
1267 self.readline.insert_text(self.indent_current_str())
1268
1268
1269 def init_readline(self):
1269 def init_readline(self):
1270 """Command history completion/saving/reloading."""
1270 """Command history completion/saving/reloading."""
1271
1271
1272 import IPython.rlineimpl as readline
1272 import IPython.rlineimpl as readline
1273 if not readline.have_readline:
1273 if not readline.have_readline:
1274 self.has_readline = 0
1274 self.has_readline = 0
1275 self.readline = None
1275 self.readline = None
1276 # no point in bugging windows users with this every time:
1276 # no point in bugging windows users with this every time:
1277 warn('Readline services not available on this platform.')
1277 warn('Readline services not available on this platform.')
1278 else:
1278 else:
1279 sys.modules['readline'] = readline
1279 sys.modules['readline'] = readline
1280 import atexit
1280 import atexit
1281 from IPython.completer import IPCompleter
1281 from IPython.completer import IPCompleter
1282 self.Completer = IPCompleter(self,
1282 self.Completer = IPCompleter(self,
1283 self.user_ns,
1283 self.user_ns,
1284 self.user_global_ns,
1284 self.user_global_ns,
1285 self.rc.readline_omit__names,
1285 self.rc.readline_omit__names,
1286 self.alias_table)
1286 self.alias_table)
1287 sdisp = self.strdispatchers.get('complete_command', StrDispatch())
1287 sdisp = self.strdispatchers.get('complete_command', StrDispatch())
1288 self.strdispatchers['complete_command'] = sdisp
1288 self.strdispatchers['complete_command'] = sdisp
1289 self.Completer.custom_completers = sdisp
1289 self.Completer.custom_completers = sdisp
1290 # Platform-specific configuration
1290 # Platform-specific configuration
1291 if os.name == 'nt':
1291 if os.name == 'nt':
1292 self.readline_startup_hook = readline.set_pre_input_hook
1292 self.readline_startup_hook = readline.set_pre_input_hook
1293 else:
1293 else:
1294 self.readline_startup_hook = readline.set_startup_hook
1294 self.readline_startup_hook = readline.set_startup_hook
1295
1295
1296 # Load user's initrc file (readline config)
1296 # Load user's initrc file (readline config)
1297 inputrc_name = os.environ.get('INPUTRC')
1297 inputrc_name = os.environ.get('INPUTRC')
1298 if inputrc_name is None:
1298 if inputrc_name is None:
1299 home_dir = get_home_dir()
1299 home_dir = get_home_dir()
1300 if home_dir is not None:
1300 if home_dir is not None:
1301 inputrc_name = os.path.join(home_dir,'.inputrc')
1301 inputrc_name = os.path.join(home_dir,'.inputrc')
1302 if os.path.isfile(inputrc_name):
1302 if os.path.isfile(inputrc_name):
1303 try:
1303 try:
1304 readline.read_init_file(inputrc_name)
1304 readline.read_init_file(inputrc_name)
1305 except:
1305 except:
1306 warn('Problems reading readline initialization file <%s>'
1306 warn('Problems reading readline initialization file <%s>'
1307 % inputrc_name)
1307 % inputrc_name)
1308
1308
1309 self.has_readline = 1
1309 self.has_readline = 1
1310 self.readline = readline
1310 self.readline = readline
1311 # save this in sys so embedded copies can restore it properly
1311 # save this in sys so embedded copies can restore it properly
1312 sys.ipcompleter = self.Completer.complete
1312 sys.ipcompleter = self.Completer.complete
1313 readline.set_completer(self.Completer.complete)
1313 readline.set_completer(self.Completer.complete)
1314
1314
1315 # Configure readline according to user's prefs
1315 # Configure readline according to user's prefs
1316 for rlcommand in self.rc.readline_parse_and_bind:
1316 for rlcommand in self.rc.readline_parse_and_bind:
1317 readline.parse_and_bind(rlcommand)
1317 readline.parse_and_bind(rlcommand)
1318
1318
1319 # remove some chars from the delimiters list
1319 # remove some chars from the delimiters list
1320 delims = readline.get_completer_delims()
1320 delims = readline.get_completer_delims()
1321 delims = delims.translate(string._idmap,
1321 delims = delims.translate(string._idmap,
1322 self.rc.readline_remove_delims)
1322 self.rc.readline_remove_delims)
1323 readline.set_completer_delims(delims)
1323 readline.set_completer_delims(delims)
1324 # otherwise we end up with a monster history after a while:
1324 # otherwise we end up with a monster history after a while:
1325 readline.set_history_length(1000)
1325 readline.set_history_length(1000)
1326 try:
1326 try:
1327 #print '*** Reading readline history' # dbg
1327 #print '*** Reading readline history' # dbg
1328 readline.read_history_file(self.histfile)
1328 readline.read_history_file(self.histfile)
1329 except IOError:
1329 except IOError:
1330 pass # It doesn't exist yet.
1330 pass # It doesn't exist yet.
1331
1331
1332 atexit.register(self.atexit_operations)
1332 atexit.register(self.atexit_operations)
1333 del atexit
1333 del atexit
1334
1334
1335 # Configure auto-indent for all platforms
1335 # Configure auto-indent for all platforms
1336 self.set_autoindent(self.rc.autoindent)
1336 self.set_autoindent(self.rc.autoindent)
1337
1337
1338 def ask_yes_no(self,prompt,default=True):
1338 def ask_yes_no(self,prompt,default=True):
1339 if self.rc.quiet:
1339 if self.rc.quiet:
1340 return True
1340 return True
1341 return ask_yes_no(prompt,default)
1341 return ask_yes_no(prompt,default)
1342
1342
1343 def _should_recompile(self,e):
1343 def _should_recompile(self,e):
1344 """Utility routine for edit_syntax_error"""
1344 """Utility routine for edit_syntax_error"""
1345
1345
1346 if e.filename in ('<ipython console>','<input>','<string>',
1346 if e.filename in ('<ipython console>','<input>','<string>',
1347 '<console>','<BackgroundJob compilation>',
1347 '<console>','<BackgroundJob compilation>',
1348 None):
1348 None):
1349
1349
1350 return False
1350 return False
1351 try:
1351 try:
1352 if (self.rc.autoedit_syntax and
1352 if (self.rc.autoedit_syntax and
1353 not self.ask_yes_no('Return to editor to correct syntax error? '
1353 not self.ask_yes_no('Return to editor to correct syntax error? '
1354 '[Y/n] ','y')):
1354 '[Y/n] ','y')):
1355 return False
1355 return False
1356 except EOFError:
1356 except EOFError:
1357 return False
1357 return False
1358
1358
1359 def int0(x):
1359 def int0(x):
1360 try:
1360 try:
1361 return int(x)
1361 return int(x)
1362 except TypeError:
1362 except TypeError:
1363 return 0
1363 return 0
1364 # always pass integer line and offset values to editor hook
1364 # always pass integer line and offset values to editor hook
1365 self.hooks.fix_error_editor(e.filename,
1365 self.hooks.fix_error_editor(e.filename,
1366 int0(e.lineno),int0(e.offset),e.msg)
1366 int0(e.lineno),int0(e.offset),e.msg)
1367 return True
1367 return True
1368
1368
1369 def edit_syntax_error(self):
1369 def edit_syntax_error(self):
1370 """The bottom half of the syntax error handler called in the main loop.
1370 """The bottom half of the syntax error handler called in the main loop.
1371
1371
1372 Loop until syntax error is fixed or user cancels.
1372 Loop until syntax error is fixed or user cancels.
1373 """
1373 """
1374
1374
1375 while self.SyntaxTB.last_syntax_error:
1375 while self.SyntaxTB.last_syntax_error:
1376 # copy and clear last_syntax_error
1376 # copy and clear last_syntax_error
1377 err = self.SyntaxTB.clear_err_state()
1377 err = self.SyntaxTB.clear_err_state()
1378 if not self._should_recompile(err):
1378 if not self._should_recompile(err):
1379 return
1379 return
1380 try:
1380 try:
1381 # may set last_syntax_error again if a SyntaxError is raised
1381 # may set last_syntax_error again if a SyntaxError is raised
1382 self.safe_execfile(err.filename,self.user_ns)
1382 self.safe_execfile(err.filename,self.user_ns)
1383 except:
1383 except:
1384 self.showtraceback()
1384 self.showtraceback()
1385 else:
1385 else:
1386 try:
1386 try:
1387 f = file(err.filename)
1387 f = file(err.filename)
1388 try:
1388 try:
1389 sys.displayhook(f.read())
1389 sys.displayhook(f.read())
1390 finally:
1390 finally:
1391 f.close()
1391 f.close()
1392 except:
1392 except:
1393 self.showtraceback()
1393 self.showtraceback()
1394
1394
1395 def showsyntaxerror(self, filename=None):
1395 def showsyntaxerror(self, filename=None):
1396 """Display the syntax error that just occurred.
1396 """Display the syntax error that just occurred.
1397
1397
1398 This doesn't display a stack trace because there isn't one.
1398 This doesn't display a stack trace because there isn't one.
1399
1399
1400 If a filename is given, it is stuffed in the exception instead
1400 If a filename is given, it is stuffed in the exception instead
1401 of what was there before (because Python's parser always uses
1401 of what was there before (because Python's parser always uses
1402 "<string>" when reading from a string).
1402 "<string>" when reading from a string).
1403 """
1403 """
1404 etype, value, last_traceback = sys.exc_info()
1404 etype, value, last_traceback = sys.exc_info()
1405
1405
1406 # See note about these variables in showtraceback() below
1406 # See note about these variables in showtraceback() below
1407 sys.last_type = etype
1407 sys.last_type = etype
1408 sys.last_value = value
1408 sys.last_value = value
1409 sys.last_traceback = last_traceback
1409 sys.last_traceback = last_traceback
1410
1410
1411 if filename and etype is SyntaxError:
1411 if filename and etype is SyntaxError:
1412 # Work hard to stuff the correct filename in the exception
1412 # Work hard to stuff the correct filename in the exception
1413 try:
1413 try:
1414 msg, (dummy_filename, lineno, offset, line) = value
1414 msg, (dummy_filename, lineno, offset, line) = value
1415 except:
1415 except:
1416 # Not the format we expect; leave it alone
1416 # Not the format we expect; leave it alone
1417 pass
1417 pass
1418 else:
1418 else:
1419 # Stuff in the right filename
1419 # Stuff in the right filename
1420 try:
1420 try:
1421 # Assume SyntaxError is a class exception
1421 # Assume SyntaxError is a class exception
1422 value = SyntaxError(msg, (filename, lineno, offset, line))
1422 value = SyntaxError(msg, (filename, lineno, offset, line))
1423 except:
1423 except:
1424 # If that failed, assume SyntaxError is a string
1424 # If that failed, assume SyntaxError is a string
1425 value = msg, (filename, lineno, offset, line)
1425 value = msg, (filename, lineno, offset, line)
1426 self.SyntaxTB(etype,value,[])
1426 self.SyntaxTB(etype,value,[])
1427
1427
1428 def debugger(self,force=False):
1428 def debugger(self,force=False):
1429 """Call the pydb/pdb debugger.
1429 """Call the pydb/pdb debugger.
1430
1430
1431 Keywords:
1431 Keywords:
1432
1432
1433 - force(False): by default, this routine checks the instance call_pdb
1433 - force(False): by default, this routine checks the instance call_pdb
1434 flag and does not actually invoke the debugger if the flag is false.
1434 flag and does not actually invoke the debugger if the flag is false.
1435 The 'force' option forces the debugger to activate even if the flag
1435 The 'force' option forces the debugger to activate even if the flag
1436 is false.
1436 is false.
1437 """
1437 """
1438
1438
1439 if not (force or self.call_pdb):
1439 if not (force or self.call_pdb):
1440 return
1440 return
1441
1441
1442 if not hasattr(sys,'last_traceback'):
1442 if not hasattr(sys,'last_traceback'):
1443 error('No traceback has been produced, nothing to debug.')
1443 error('No traceback has been produced, nothing to debug.')
1444 return
1444 return
1445
1445
1446 have_pydb = False
1446 have_pydb = False
1447 # use pydb if available
1447 # use pydb if available
1448 try:
1448 try:
1449 from pydb import pm
1449 from pydb import pm
1450 have_pydb = True
1450 have_pydb = True
1451 except ImportError:
1451 except ImportError:
1452 pass
1452 pass
1453 if not have_pydb:
1453 if not have_pydb:
1454 # fallback to our internal debugger
1454 # fallback to our internal debugger
1455 pm = lambda : self.InteractiveTB.debugger(force=True)
1455 pm = lambda : self.InteractiveTB.debugger(force=True)
1456 self.history_saving_wrapper(pm)()
1456 self.history_saving_wrapper(pm)()
1457
1457
1458 def showtraceback(self,exc_tuple = None,filename=None,tb_offset=None):
1458 def showtraceback(self,exc_tuple = None,filename=None,tb_offset=None):
1459 """Display the exception that just occurred.
1459 """Display the exception that just occurred.
1460
1460
1461 If nothing is known about the exception, this is the method which
1461 If nothing is known about the exception, this is the method which
1462 should be used throughout the code for presenting user tracebacks,
1462 should be used throughout the code for presenting user tracebacks,
1463 rather than directly invoking the InteractiveTB object.
1463 rather than directly invoking the InteractiveTB object.
1464
1464
1465 A specific showsyntaxerror() also exists, but this method can take
1465 A specific showsyntaxerror() also exists, but this method can take
1466 care of calling it if needed, so unless you are explicitly catching a
1466 care of calling it if needed, so unless you are explicitly catching a
1467 SyntaxError exception, don't try to analyze the stack manually and
1467 SyntaxError exception, don't try to analyze the stack manually and
1468 simply call this method."""
1468 simply call this method."""
1469
1469
1470 # Though this won't be called by syntax errors in the input line,
1470 # Though this won't be called by syntax errors in the input line,
1471 # there may be SyntaxError cases whith imported code.
1471 # there may be SyntaxError cases whith imported code.
1472 if exc_tuple is None:
1472 if exc_tuple is None:
1473 etype, value, tb = sys.exc_info()
1473 etype, value, tb = sys.exc_info()
1474 else:
1474 else:
1475 etype, value, tb = exc_tuple
1475 etype, value, tb = exc_tuple
1476
1476
1477 if etype is SyntaxError:
1477 if etype is SyntaxError:
1478 self.showsyntaxerror(filename)
1478 self.showsyntaxerror(filename)
1479 else:
1479 else:
1480 # WARNING: these variables are somewhat deprecated and not
1480 # WARNING: these variables are somewhat deprecated and not
1481 # necessarily safe to use in a threaded environment, but tools
1481 # necessarily safe to use in a threaded environment, but tools
1482 # like pdb depend on their existence, so let's set them. If we
1482 # like pdb depend on their existence, so let's set them. If we
1483 # find problems in the field, we'll need to revisit their use.
1483 # find problems in the field, we'll need to revisit their use.
1484 sys.last_type = etype
1484 sys.last_type = etype
1485 sys.last_value = value
1485 sys.last_value = value
1486 sys.last_traceback = tb
1486 sys.last_traceback = tb
1487
1487
1488 if etype in self.custom_exceptions:
1488 if etype in self.custom_exceptions:
1489 self.CustomTB(etype,value,tb)
1489 self.CustomTB(etype,value,tb)
1490 else:
1490 else:
1491 self.InteractiveTB(etype,value,tb,tb_offset=tb_offset)
1491 self.InteractiveTB(etype,value,tb,tb_offset=tb_offset)
1492 if self.InteractiveTB.call_pdb and self.has_readline:
1492 if self.InteractiveTB.call_pdb and self.has_readline:
1493 # pdb mucks up readline, fix it back
1493 # pdb mucks up readline, fix it back
1494 self.readline.set_completer(self.Completer.complete)
1494 self.readline.set_completer(self.Completer.complete)
1495
1495
1496 def mainloop(self,banner=None):
1496 def mainloop(self,banner=None):
1497 """Creates the local namespace and starts the mainloop.
1497 """Creates the local namespace and starts the mainloop.
1498
1498
1499 If an optional banner argument is given, it will override the
1499 If an optional banner argument is given, it will override the
1500 internally created default banner."""
1500 internally created default banner."""
1501
1501
1502 if self.rc.c: # Emulate Python's -c option
1502 if self.rc.c: # Emulate Python's -c option
1503 self.exec_init_cmd()
1503 self.exec_init_cmd()
1504 if banner is None:
1504 if banner is None:
1505 if not self.rc.banner:
1505 if not self.rc.banner:
1506 banner = ''
1506 banner = ''
1507 # banner is string? Use it directly!
1507 # banner is string? Use it directly!
1508 elif isinstance(self.rc.banner,basestring):
1508 elif isinstance(self.rc.banner,basestring):
1509 banner = self.rc.banner
1509 banner = self.rc.banner
1510 else:
1510 else:
1511 banner = self.BANNER+self.banner2
1511 banner = self.BANNER+self.banner2
1512
1512
1513 self.interact(banner)
1513 self.interact(banner)
1514
1514
1515 def exec_init_cmd(self):
1515 def exec_init_cmd(self):
1516 """Execute a command given at the command line.
1516 """Execute a command given at the command line.
1517
1517
1518 This emulates Python's -c option."""
1518 This emulates Python's -c option."""
1519
1519
1520 #sys.argv = ['-c']
1520 #sys.argv = ['-c']
1521 self.push(self.rc.c)
1521 self.push(self.rc.c)
1522
1522
1523 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1523 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1524 """Embeds IPython into a running python program.
1524 """Embeds IPython into a running python program.
1525
1525
1526 Input:
1526 Input:
1527
1527
1528 - header: An optional header message can be specified.
1528 - header: An optional header message can be specified.
1529
1529
1530 - local_ns, global_ns: working namespaces. If given as None, the
1530 - local_ns, global_ns: working namespaces. If given as None, the
1531 IPython-initialized one is updated with __main__.__dict__, so that
1531 IPython-initialized one is updated with __main__.__dict__, so that
1532 program variables become visible but user-specific configuration
1532 program variables become visible but user-specific configuration
1533 remains possible.
1533 remains possible.
1534
1534
1535 - stack_depth: specifies how many levels in the stack to go to
1535 - stack_depth: specifies how many levels in the stack to go to
1536 looking for namespaces (when local_ns and global_ns are None). This
1536 looking for namespaces (when local_ns and global_ns are None). This
1537 allows an intermediate caller to make sure that this function gets
1537 allows an intermediate caller to make sure that this function gets
1538 the namespace from the intended level in the stack. By default (0)
1538 the namespace from the intended level in the stack. By default (0)
1539 it will get its locals and globals from the immediate caller.
1539 it will get its locals and globals from the immediate caller.
1540
1540
1541 Warning: it's possible to use this in a program which is being run by
1541 Warning: it's possible to use this in a program which is being run by
1542 IPython itself (via %run), but some funny things will happen (a few
1542 IPython itself (via %run), but some funny things will happen (a few
1543 globals get overwritten). In the future this will be cleaned up, as
1543 globals get overwritten). In the future this will be cleaned up, as
1544 there is no fundamental reason why it can't work perfectly."""
1544 there is no fundamental reason why it can't work perfectly."""
1545
1545
1546 # Get locals and globals from caller
1546 # Get locals and globals from caller
1547 if local_ns is None or global_ns is None:
1547 if local_ns is None or global_ns is None:
1548 call_frame = sys._getframe(stack_depth).f_back
1548 call_frame = sys._getframe(stack_depth).f_back
1549
1549
1550 if local_ns is None:
1550 if local_ns is None:
1551 local_ns = call_frame.f_locals
1551 local_ns = call_frame.f_locals
1552 if global_ns is None:
1552 if global_ns is None:
1553 global_ns = call_frame.f_globals
1553 global_ns = call_frame.f_globals
1554
1554
1555 # Update namespaces and fire up interpreter
1555 # Update namespaces and fire up interpreter
1556
1556
1557 # The global one is easy, we can just throw it in
1557 # The global one is easy, we can just throw it in
1558 self.user_global_ns = global_ns
1558 self.user_global_ns = global_ns
1559
1559
1560 # but the user/local one is tricky: ipython needs it to store internal
1560 # but the user/local one is tricky: ipython needs it to store internal
1561 # data, but we also need the locals. We'll copy locals in the user
1561 # data, but we also need the locals. We'll copy locals in the user
1562 # one, but will track what got copied so we can delete them at exit.
1562 # one, but will track what got copied so we can delete them at exit.
1563 # This is so that a later embedded call doesn't see locals from a
1563 # This is so that a later embedded call doesn't see locals from a
1564 # previous call (which most likely existed in a separate scope).
1564 # previous call (which most likely existed in a separate scope).
1565 local_varnames = local_ns.keys()
1565 local_varnames = local_ns.keys()
1566 self.user_ns.update(local_ns)
1566 self.user_ns.update(local_ns)
1567
1567
1568 # Patch for global embedding to make sure that things don't overwrite
1568 # Patch for global embedding to make sure that things don't overwrite
1569 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1569 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1570 # FIXME. Test this a bit more carefully (the if.. is new)
1570 # FIXME. Test this a bit more carefully (the if.. is new)
1571 if local_ns is None and global_ns is None:
1571 if local_ns is None and global_ns is None:
1572 self.user_global_ns.update(__main__.__dict__)
1572 self.user_global_ns.update(__main__.__dict__)
1573
1573
1574 # make sure the tab-completer has the correct frame information, so it
1574 # make sure the tab-completer has the correct frame information, so it
1575 # actually completes using the frame's locals/globals
1575 # actually completes using the frame's locals/globals
1576 self.set_completer_frame()
1576 self.set_completer_frame()
1577
1577
1578 # before activating the interactive mode, we need to make sure that
1578 # before activating the interactive mode, we need to make sure that
1579 # all names in the builtin namespace needed by ipython point to
1579 # all names in the builtin namespace needed by ipython point to
1580 # ourselves, and not to other instances.
1580 # ourselves, and not to other instances.
1581 self.add_builtins()
1581 self.add_builtins()
1582
1582
1583 self.interact(header)
1583 self.interact(header)
1584
1584
1585 # now, purge out the user namespace from anything we might have added
1585 # now, purge out the user namespace from anything we might have added
1586 # from the caller's local namespace
1586 # from the caller's local namespace
1587 delvar = self.user_ns.pop
1587 delvar = self.user_ns.pop
1588 for var in local_varnames:
1588 for var in local_varnames:
1589 delvar(var,None)
1589 delvar(var,None)
1590 # and clean builtins we may have overridden
1590 # and clean builtins we may have overridden
1591 self.clean_builtins()
1591 self.clean_builtins()
1592
1592
1593 def interact(self, banner=None):
1593 def interact(self, banner=None):
1594 """Closely emulate the interactive Python console.
1594 """Closely emulate the interactive Python console.
1595
1595
1596 The optional banner argument specify the banner to print
1596 The optional banner argument specify the banner to print
1597 before the first interaction; by default it prints a banner
1597 before the first interaction; by default it prints a banner
1598 similar to the one printed by the real Python interpreter,
1598 similar to the one printed by the real Python interpreter,
1599 followed by the current class name in parentheses (so as not
1599 followed by the current class name in parentheses (so as not
1600 to confuse this with the real interpreter -- since it's so
1600 to confuse this with the real interpreter -- since it's so
1601 close!).
1601 close!).
1602
1602
1603 """
1603 """
1604
1604
1605 if self.exit_now:
1605 if self.exit_now:
1606 # batch run -> do not interact
1606 # batch run -> do not interact
1607 return
1607 return
1608 cprt = 'Type "copyright", "credits" or "license" for more information.'
1608 cprt = 'Type "copyright", "credits" or "license" for more information.'
1609 if banner is None:
1609 if banner is None:
1610 self.write("Python %s on %s\n%s\n(%s)\n" %
1610 self.write("Python %s on %s\n%s\n(%s)\n" %
1611 (sys.version, sys.platform, cprt,
1611 (sys.version, sys.platform, cprt,
1612 self.__class__.__name__))
1612 self.__class__.__name__))
1613 else:
1613 else:
1614 self.write(banner)
1614 self.write(banner)
1615
1615
1616 more = 0
1616 more = 0
1617
1617
1618 # Mark activity in the builtins
1618 # Mark activity in the builtins
1619 __builtin__.__dict__['__IPYTHON__active'] += 1
1619 __builtin__.__dict__['__IPYTHON__active'] += 1
1620
1620
1621 # exit_now is set by a call to %Exit or %Quit
1621 # exit_now is set by a call to %Exit or %Quit
1622 while not self.exit_now:
1622 while not self.exit_now:
1623 if more:
1623 if more:
1624 prompt = self.hooks.generate_prompt(True)
1624 prompt = self.hooks.generate_prompt(True)
1625 if self.autoindent:
1625 if self.autoindent:
1626 self.readline_startup_hook(self.pre_readline)
1626 self.readline_startup_hook(self.pre_readline)
1627 else:
1627 else:
1628 prompt = self.hooks.generate_prompt(False)
1628 prompt = self.hooks.generate_prompt(False)
1629 try:
1629 try:
1630 line = self.raw_input(prompt,more)
1630 line = self.raw_input(prompt,more)
1631 if self.exit_now:
1631 if self.exit_now:
1632 # quick exit on sys.std[in|out] close
1632 # quick exit on sys.std[in|out] close
1633 break
1633 break
1634 if self.autoindent:
1634 if self.autoindent:
1635 self.readline_startup_hook(None)
1635 self.readline_startup_hook(None)
1636 except KeyboardInterrupt:
1636 except KeyboardInterrupt:
1637 self.write('\nKeyboardInterrupt\n')
1637 self.write('\nKeyboardInterrupt\n')
1638 self.resetbuffer()
1638 self.resetbuffer()
1639 # keep cache in sync with the prompt counter:
1639 # keep cache in sync with the prompt counter:
1640 self.outputcache.prompt_count -= 1
1640 self.outputcache.prompt_count -= 1
1641
1641
1642 if self.autoindent:
1642 if self.autoindent:
1643 self.indent_current_nsp = 0
1643 self.indent_current_nsp = 0
1644 more = 0
1644 more = 0
1645 except EOFError:
1645 except EOFError:
1646 if self.autoindent:
1646 if self.autoindent:
1647 self.readline_startup_hook(None)
1647 self.readline_startup_hook(None)
1648 self.write('\n')
1648 self.write('\n')
1649 self.exit()
1649 self.exit()
1650 except bdb.BdbQuit:
1650 except bdb.BdbQuit:
1651 warn('The Python debugger has exited with a BdbQuit exception.\n'
1651 warn('The Python debugger has exited with a BdbQuit exception.\n'
1652 'Because of how pdb handles the stack, it is impossible\n'
1652 'Because of how pdb handles the stack, it is impossible\n'
1653 'for IPython to properly format this particular exception.\n'
1653 'for IPython to properly format this particular exception.\n'
1654 'IPython will resume normal operation.')
1654 'IPython will resume normal operation.')
1655 except:
1655 except:
1656 # exceptions here are VERY RARE, but they can be triggered
1656 # exceptions here are VERY RARE, but they can be triggered
1657 # asynchronously by signal handlers, for example.
1657 # asynchronously by signal handlers, for example.
1658 self.showtraceback()
1658 self.showtraceback()
1659 else:
1659 else:
1660 more = self.push(line)
1660 more = self.push(line)
1661 if (self.SyntaxTB.last_syntax_error and
1661 if (self.SyntaxTB.last_syntax_error and
1662 self.rc.autoedit_syntax):
1662 self.rc.autoedit_syntax):
1663 self.edit_syntax_error()
1663 self.edit_syntax_error()
1664
1664
1665 # We are off again...
1665 # We are off again...
1666 __builtin__.__dict__['__IPYTHON__active'] -= 1
1666 __builtin__.__dict__['__IPYTHON__active'] -= 1
1667
1667
1668 def excepthook(self, etype, value, tb):
1668 def excepthook(self, etype, value, tb):
1669 """One more defense for GUI apps that call sys.excepthook.
1669 """One more defense for GUI apps that call sys.excepthook.
1670
1670
1671 GUI frameworks like wxPython trap exceptions and call
1671 GUI frameworks like wxPython trap exceptions and call
1672 sys.excepthook themselves. I guess this is a feature that
1672 sys.excepthook themselves. I guess this is a feature that
1673 enables them to keep running after exceptions that would
1673 enables them to keep running after exceptions that would
1674 otherwise kill their mainloop. This is a bother for IPython
1674 otherwise kill their mainloop. This is a bother for IPython
1675 which excepts to catch all of the program exceptions with a try:
1675 which excepts to catch all of the program exceptions with a try:
1676 except: statement.
1676 except: statement.
1677
1677
1678 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1678 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1679 any app directly invokes sys.excepthook, it will look to the user like
1679 any app directly invokes sys.excepthook, it will look to the user like
1680 IPython crashed. In order to work around this, we can disable the
1680 IPython crashed. In order to work around this, we can disable the
1681 CrashHandler and replace it with this excepthook instead, which prints a
1681 CrashHandler and replace it with this excepthook instead, which prints a
1682 regular traceback using our InteractiveTB. In this fashion, apps which
1682 regular traceback using our InteractiveTB. In this fashion, apps which
1683 call sys.excepthook will generate a regular-looking exception from
1683 call sys.excepthook will generate a regular-looking exception from
1684 IPython, and the CrashHandler will only be triggered by real IPython
1684 IPython, and the CrashHandler will only be triggered by real IPython
1685 crashes.
1685 crashes.
1686
1686
1687 This hook should be used sparingly, only in places which are not likely
1687 This hook should be used sparingly, only in places which are not likely
1688 to be true IPython errors.
1688 to be true IPython errors.
1689 """
1689 """
1690 self.showtraceback((etype,value,tb),tb_offset=0)
1690 self.showtraceback((etype,value,tb),tb_offset=0)
1691
1691
1692 def expand_aliases(self,fn,rest):
1692 def expand_aliases(self,fn,rest):
1693 """ Expand multiple levels of aliases:
1693 """ Expand multiple levels of aliases:
1694
1694
1695 if:
1695 if:
1696
1696
1697 alias foo bar /tmp
1697 alias foo bar /tmp
1698 alias baz foo
1698 alias baz foo
1699
1699
1700 then:
1700 then:
1701
1701
1702 baz huhhahhei -> bar /tmp huhhahhei
1702 baz huhhahhei -> bar /tmp huhhahhei
1703
1703
1704 """
1704 """
1705 line = fn + " " + rest
1705 line = fn + " " + rest
1706
1706
1707 done = Set()
1707 done = Set()
1708 while 1:
1708 while 1:
1709 pre,fn,rest = self.split_user_input(line, pattern = self.shell_line_split)
1709 pre,fn,rest = self.split_user_input(line, pattern = self.shell_line_split)
1710 # print "!",fn,"!",rest # dbg
1710 # print "!",fn,"!",rest # dbg
1711 if fn in self.alias_table:
1711 if fn in self.alias_table:
1712 if fn in done:
1712 if fn in done:
1713 warn("Cyclic alias definition, repeated '%s'" % fn)
1713 warn("Cyclic alias definition, repeated '%s'" % fn)
1714 return ""
1714 return ""
1715 done.add(fn)
1715 done.add(fn)
1716
1716
1717 l2 = self.transform_alias(fn,rest)
1717 l2 = self.transform_alias(fn,rest)
1718 # dir -> dir
1718 # dir -> dir
1719 # print "alias",line, "->",l2 #dbg
1719 # print "alias",line, "->",l2 #dbg
1720 if l2 == line:
1720 if l2 == line:
1721 break
1721 break
1722 # ls -> ls -F should not recurse forever
1722 # ls -> ls -F should not recurse forever
1723 if l2.split(None,1)[0] == line.split(None,1)[0]:
1723 if l2.split(None,1)[0] == line.split(None,1)[0]:
1724 line = l2
1724 line = l2
1725 break
1725 break
1726
1726
1727 line=l2
1727 line=l2
1728
1728
1729
1729
1730 # print "al expand to",line #dbg
1730 # print "al expand to",line #dbg
1731 else:
1731 else:
1732 break
1732 break
1733
1733
1734 return line
1734 return line
1735
1735
1736 def transform_alias(self, alias,rest=''):
1736 def transform_alias(self, alias,rest=''):
1737 """ Transform alias to system command string.
1737 """ Transform alias to system command string.
1738 """
1738 """
1739 nargs,cmd = self.alias_table[alias]
1739 nargs,cmd = self.alias_table[alias]
1740 if ' ' in cmd and os.path.isfile(cmd):
1740 if ' ' in cmd and os.path.isfile(cmd):
1741 cmd = '"%s"' % cmd
1741 cmd = '"%s"' % cmd
1742
1742
1743 # Expand the %l special to be the user's input line
1743 # Expand the %l special to be the user's input line
1744 if cmd.find('%l') >= 0:
1744 if cmd.find('%l') >= 0:
1745 cmd = cmd.replace('%l',rest)
1745 cmd = cmd.replace('%l',rest)
1746 rest = ''
1746 rest = ''
1747 if nargs==0:
1747 if nargs==0:
1748 # Simple, argument-less aliases
1748 # Simple, argument-less aliases
1749 cmd = '%s %s' % (cmd,rest)
1749 cmd = '%s %s' % (cmd,rest)
1750 else:
1750 else:
1751 # Handle aliases with positional arguments
1751 # Handle aliases with positional arguments
1752 args = rest.split(None,nargs)
1752 args = rest.split(None,nargs)
1753 if len(args)< nargs:
1753 if len(args)< nargs:
1754 error('Alias <%s> requires %s arguments, %s given.' %
1754 error('Alias <%s> requires %s arguments, %s given.' %
1755 (alias,nargs,len(args)))
1755 (alias,nargs,len(args)))
1756 return None
1756 return None
1757 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1757 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1758 # Now call the macro, evaluating in the user's namespace
1758 # Now call the macro, evaluating in the user's namespace
1759 #print 'new command: <%r>' % cmd # dbg
1759 #print 'new command: <%r>' % cmd # dbg
1760 return cmd
1760 return cmd
1761
1761
1762 def call_alias(self,alias,rest=''):
1762 def call_alias(self,alias,rest=''):
1763 """Call an alias given its name and the rest of the line.
1763 """Call an alias given its name and the rest of the line.
1764
1764
1765 This is only used to provide backwards compatibility for users of
1765 This is only used to provide backwards compatibility for users of
1766 ipalias(), use of which is not recommended for anymore."""
1766 ipalias(), use of which is not recommended for anymore."""
1767
1767
1768 # Now call the macro, evaluating in the user's namespace
1768 # Now call the macro, evaluating in the user's namespace
1769 cmd = self.transform_alias(alias, rest)
1769 cmd = self.transform_alias(alias, rest)
1770 try:
1770 try:
1771 self.system(cmd)
1771 self.system(cmd)
1772 except:
1772 except:
1773 self.showtraceback()
1773 self.showtraceback()
1774
1774
1775 def indent_current_str(self):
1775 def indent_current_str(self):
1776 """return the current level of indentation as a string"""
1776 """return the current level of indentation as a string"""
1777 return self.indent_current_nsp * ' '
1777 return self.indent_current_nsp * ' '
1778
1778
1779 def autoindent_update(self,line):
1779 def autoindent_update(self,line):
1780 """Keep track of the indent level."""
1780 """Keep track of the indent level."""
1781
1781
1782 #debugx('line')
1782 #debugx('line')
1783 #debugx('self.indent_current_nsp')
1783 #debugx('self.indent_current_nsp')
1784 if self.autoindent:
1784 if self.autoindent:
1785 if line:
1785 if line:
1786 inisp = num_ini_spaces(line)
1786 inisp = num_ini_spaces(line)
1787 if inisp < self.indent_current_nsp:
1787 if inisp < self.indent_current_nsp:
1788 self.indent_current_nsp = inisp
1788 self.indent_current_nsp = inisp
1789
1789
1790 if line[-1] == ':':
1790 if line[-1] == ':':
1791 self.indent_current_nsp += 4
1791 self.indent_current_nsp += 4
1792 elif dedent_re.match(line):
1792 elif dedent_re.match(line):
1793 self.indent_current_nsp -= 4
1793 self.indent_current_nsp -= 4
1794 else:
1794 else:
1795 self.indent_current_nsp = 0
1795 self.indent_current_nsp = 0
1796
1796
1797 def runlines(self,lines):
1797 def runlines(self,lines):
1798 """Run a string of one or more lines of source.
1798 """Run a string of one or more lines of source.
1799
1799
1800 This method is capable of running a string containing multiple source
1800 This method is capable of running a string containing multiple source
1801 lines, as if they had been entered at the IPython prompt. Since it
1801 lines, as if they had been entered at the IPython prompt. Since it
1802 exposes IPython's processing machinery, the given strings can contain
1802 exposes IPython's processing machinery, the given strings can contain
1803 magic calls (%magic), special shell access (!cmd), etc."""
1803 magic calls (%magic), special shell access (!cmd), etc."""
1804
1804
1805 # We must start with a clean buffer, in case this is run from an
1805 # We must start with a clean buffer, in case this is run from an
1806 # interactive IPython session (via a magic, for example).
1806 # interactive IPython session (via a magic, for example).
1807 self.resetbuffer()
1807 self.resetbuffer()
1808 lines = lines.split('\n')
1808 lines = lines.split('\n')
1809 more = 0
1809 more = 0
1810 for line in lines:
1810 for line in lines:
1811 # skip blank lines so we don't mess up the prompt counter, but do
1811 # skip blank lines so we don't mess up the prompt counter, but do
1812 # NOT skip even a blank line if we are in a code block (more is
1812 # NOT skip even a blank line if we are in a code block (more is
1813 # true)
1813 # true)
1814 if line or more:
1814 if line or more:
1815 more = self.push(self.prefilter(line,more))
1815 more = self.push(self.prefilter(line,more))
1816 # IPython's runsource returns None if there was an error
1816 # IPython's runsource returns None if there was an error
1817 # compiling the code. This allows us to stop processing right
1817 # compiling the code. This allows us to stop processing right
1818 # away, so the user gets the error message at the right place.
1818 # away, so the user gets the error message at the right place.
1819 if more is None:
1819 if more is None:
1820 break
1820 break
1821 # final newline in case the input didn't have it, so that the code
1821 # final newline in case the input didn't have it, so that the code
1822 # actually does get executed
1822 # actually does get executed
1823 if more:
1823 if more:
1824 self.push('\n')
1824 self.push('\n')
1825
1825
1826 def runsource(self, source, filename='<input>', symbol='single'):
1826 def runsource(self, source, filename='<input>', symbol='single'):
1827 """Compile and run some source in the interpreter.
1827 """Compile and run some source in the interpreter.
1828
1828
1829 Arguments are as for compile_command().
1829 Arguments are as for compile_command().
1830
1830
1831 One several things can happen:
1831 One several things can happen:
1832
1832
1833 1) The input is incorrect; compile_command() raised an
1833 1) The input is incorrect; compile_command() raised an
1834 exception (SyntaxError or OverflowError). A syntax traceback
1834 exception (SyntaxError or OverflowError). A syntax traceback
1835 will be printed by calling the showsyntaxerror() method.
1835 will be printed by calling the showsyntaxerror() method.
1836
1836
1837 2) The input is incomplete, and more input is required;
1837 2) The input is incomplete, and more input is required;
1838 compile_command() returned None. Nothing happens.
1838 compile_command() returned None. Nothing happens.
1839
1839
1840 3) The input is complete; compile_command() returned a code
1840 3) The input is complete; compile_command() returned a code
1841 object. The code is executed by calling self.runcode() (which
1841 object. The code is executed by calling self.runcode() (which
1842 also handles run-time exceptions, except for SystemExit).
1842 also handles run-time exceptions, except for SystemExit).
1843
1843
1844 The return value is:
1844 The return value is:
1845
1845
1846 - True in case 2
1846 - True in case 2
1847
1847
1848 - False in the other cases, unless an exception is raised, where
1848 - False in the other cases, unless an exception is raised, where
1849 None is returned instead. This can be used by external callers to
1849 None is returned instead. This can be used by external callers to
1850 know whether to continue feeding input or not.
1850 know whether to continue feeding input or not.
1851
1851
1852 The return value can be used to decide whether to use sys.ps1 or
1852 The return value can be used to decide whether to use sys.ps1 or
1853 sys.ps2 to prompt the next line."""
1853 sys.ps2 to prompt the next line."""
1854
1854
1855 # if the source code has leading blanks, add 'if 1:\n' to it
1855 # if the source code has leading blanks, add 'if 1:\n' to it
1856 # this allows execution of indented pasted code. It is tempting
1856 # this allows execution of indented pasted code. It is tempting
1857 # to add '\n' at the end of source to run commands like ' a=1'
1857 # to add '\n' at the end of source to run commands like ' a=1'
1858 # directly, but this fails for more complicated scenarios
1858 # directly, but this fails for more complicated scenarios
1859 if source[:1] in [' ', '\t']:
1859 if source[:1] in [' ', '\t']:
1860 source = 'if 1:\n%s' % source
1860 source = 'if 1:\n%s' % source
1861
1861
1862 try:
1862 try:
1863 code = self.compile(source,filename,symbol)
1863 code = self.compile(source,filename,symbol)
1864 except (OverflowError, SyntaxError, ValueError):
1864 except (OverflowError, SyntaxError, ValueError):
1865 # Case 1
1865 # Case 1
1866 self.showsyntaxerror(filename)
1866 self.showsyntaxerror(filename)
1867 return None
1867 return None
1868
1868
1869 if code is None:
1869 if code is None:
1870 # Case 2
1870 # Case 2
1871 return True
1871 return True
1872
1872
1873 # Case 3
1873 # Case 3
1874 # We store the code object so that threaded shells and
1874 # We store the code object so that threaded shells and
1875 # custom exception handlers can access all this info if needed.
1875 # custom exception handlers can access all this info if needed.
1876 # The source corresponding to this can be obtained from the
1876 # The source corresponding to this can be obtained from the
1877 # buffer attribute as '\n'.join(self.buffer).
1877 # buffer attribute as '\n'.join(self.buffer).
1878 self.code_to_run = code
1878 self.code_to_run = code
1879 # now actually execute the code object
1879 # now actually execute the code object
1880 if self.runcode(code) == 0:
1880 if self.runcode(code) == 0:
1881 return False
1881 return False
1882 else:
1882 else:
1883 return None
1883 return None
1884
1884
1885 def runcode(self,code_obj):
1885 def runcode(self,code_obj):
1886 """Execute a code object.
1886 """Execute a code object.
1887
1887
1888 When an exception occurs, self.showtraceback() is called to display a
1888 When an exception occurs, self.showtraceback() is called to display a
1889 traceback.
1889 traceback.
1890
1890
1891 Return value: a flag indicating whether the code to be run completed
1891 Return value: a flag indicating whether the code to be run completed
1892 successfully:
1892 successfully:
1893
1893
1894 - 0: successful execution.
1894 - 0: successful execution.
1895 - 1: an error occurred.
1895 - 1: an error occurred.
1896 """
1896 """
1897
1897
1898 # Set our own excepthook in case the user code tries to call it
1898 # Set our own excepthook in case the user code tries to call it
1899 # directly, so that the IPython crash handler doesn't get triggered
1899 # directly, so that the IPython crash handler doesn't get triggered
1900 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1900 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1901
1901
1902 # we save the original sys.excepthook in the instance, in case config
1902 # we save the original sys.excepthook in the instance, in case config
1903 # code (such as magics) needs access to it.
1903 # code (such as magics) needs access to it.
1904 self.sys_excepthook = old_excepthook
1904 self.sys_excepthook = old_excepthook
1905 outflag = 1 # happens in more places, so it's easier as default
1905 outflag = 1 # happens in more places, so it's easier as default
1906 try:
1906 try:
1907 try:
1907 try:
1908 # Embedded instances require separate global/local namespaces
1908 # Embedded instances require separate global/local namespaces
1909 # so they can see both the surrounding (local) namespace and
1909 # so they can see both the surrounding (local) namespace and
1910 # the module-level globals when called inside another function.
1910 # the module-level globals when called inside another function.
1911 if self.embedded:
1911 if self.embedded:
1912 exec code_obj in self.user_global_ns, self.user_ns
1912 exec code_obj in self.user_global_ns, self.user_ns
1913 # Normal (non-embedded) instances should only have a single
1913 # Normal (non-embedded) instances should only have a single
1914 # namespace for user code execution, otherwise functions won't
1914 # namespace for user code execution, otherwise functions won't
1915 # see interactive top-level globals.
1915 # see interactive top-level globals.
1916 else:
1916 else:
1917 exec code_obj in self.user_ns
1917 exec code_obj in self.user_ns
1918 finally:
1918 finally:
1919 # Reset our crash handler in place
1919 # Reset our crash handler in place
1920 sys.excepthook = old_excepthook
1920 sys.excepthook = old_excepthook
1921 except SystemExit:
1921 except SystemExit:
1922 self.resetbuffer()
1922 self.resetbuffer()
1923 self.showtraceback()
1923 self.showtraceback()
1924 warn("Type %exit or %quit to exit IPython "
1924 warn("Type %exit or %quit to exit IPython "
1925 "(%Exit or %Quit do so unconditionally).",level=1)
1925 "(%Exit or %Quit do so unconditionally).",level=1)
1926 except self.custom_exceptions:
1926 except self.custom_exceptions:
1927 etype,value,tb = sys.exc_info()
1927 etype,value,tb = sys.exc_info()
1928 self.CustomTB(etype,value,tb)
1928 self.CustomTB(etype,value,tb)
1929 except:
1929 except:
1930 self.showtraceback()
1930 self.showtraceback()
1931 else:
1931 else:
1932 outflag = 0
1932 outflag = 0
1933 if softspace(sys.stdout, 0):
1933 if softspace(sys.stdout, 0):
1934 print
1934 print
1935 # Flush out code object which has been run (and source)
1935 # Flush out code object which has been run (and source)
1936 self.code_to_run = None
1936 self.code_to_run = None
1937 return outflag
1937 return outflag
1938
1938
1939 def push(self, line):
1939 def push(self, line):
1940 """Push a line to the interpreter.
1940 """Push a line to the interpreter.
1941
1941
1942 The line should not have a trailing newline; it may have
1942 The line should not have a trailing newline; it may have
1943 internal newlines. The line is appended to a buffer and the
1943 internal newlines. The line is appended to a buffer and the
1944 interpreter's runsource() method is called with the
1944 interpreter's runsource() method is called with the
1945 concatenated contents of the buffer as source. If this
1945 concatenated contents of the buffer as source. If this
1946 indicates that the command was executed or invalid, the buffer
1946 indicates that the command was executed or invalid, the buffer
1947 is reset; otherwise, the command is incomplete, and the buffer
1947 is reset; otherwise, the command is incomplete, and the buffer
1948 is left as it was after the line was appended. The return
1948 is left as it was after the line was appended. The return
1949 value is 1 if more input is required, 0 if the line was dealt
1949 value is 1 if more input is required, 0 if the line was dealt
1950 with in some way (this is the same as runsource()).
1950 with in some way (this is the same as runsource()).
1951 """
1951 """
1952
1952
1953 # autoindent management should be done here, and not in the
1953 # autoindent management should be done here, and not in the
1954 # interactive loop, since that one is only seen by keyboard input. We
1954 # interactive loop, since that one is only seen by keyboard input. We
1955 # need this done correctly even for code run via runlines (which uses
1955 # need this done correctly even for code run via runlines (which uses
1956 # push).
1956 # push).
1957
1957
1958 #print 'push line: <%s>' % line # dbg
1958 #print 'push line: <%s>' % line # dbg
1959 for subline in line.splitlines():
1959 for subline in line.splitlines():
1960 self.autoindent_update(subline)
1960 self.autoindent_update(subline)
1961 self.buffer.append(line)
1961 self.buffer.append(line)
1962 more = self.runsource('\n'.join(self.buffer), self.filename)
1962 more = self.runsource('\n'.join(self.buffer), self.filename)
1963 if not more:
1963 if not more:
1964 self.resetbuffer()
1964 self.resetbuffer()
1965 return more
1965 return more
1966
1966
1967 def resetbuffer(self):
1967 def resetbuffer(self):
1968 """Reset the input buffer."""
1968 """Reset the input buffer."""
1969 self.buffer[:] = []
1969 self.buffer[:] = []
1970
1970
1971 def raw_input(self,prompt='',continue_prompt=False):
1971 def raw_input(self,prompt='',continue_prompt=False):
1972 """Write a prompt and read a line.
1972 """Write a prompt and read a line.
1973
1973
1974 The returned line does not include the trailing newline.
1974 The returned line does not include the trailing newline.
1975 When the user enters the EOF key sequence, EOFError is raised.
1975 When the user enters the EOF key sequence, EOFError is raised.
1976
1976
1977 Optional inputs:
1977 Optional inputs:
1978
1978
1979 - prompt(''): a string to be printed to prompt the user.
1979 - prompt(''): a string to be printed to prompt the user.
1980
1980
1981 - continue_prompt(False): whether this line is the first one or a
1981 - continue_prompt(False): whether this line is the first one or a
1982 continuation in a sequence of inputs.
1982 continuation in a sequence of inputs.
1983 """
1983 """
1984
1984
1985 try:
1985 try:
1986 line = raw_input_original(prompt).decode(sys.stdin.encoding)
1986 line = raw_input_original(prompt).decode(sys.stdin.encoding)
1987 except ValueError:
1987 except ValueError:
1988 warn("\n********\nYou or a %run:ed script called sys.stdin.close() or sys.stdout.close()!\nExiting IPython!")
1988 warn("\n********\nYou or a %run:ed script called sys.stdin.close() or sys.stdout.close()!\nExiting IPython!")
1989 self.exit_now = True
1989 self.exit_now = True
1990 return ""
1990 return ""
1991
1991
1992
1992
1993 # Try to be reasonably smart about not re-indenting pasted input more
1993 # Try to be reasonably smart about not re-indenting pasted input more
1994 # than necessary. We do this by trimming out the auto-indent initial
1994 # than necessary. We do this by trimming out the auto-indent initial
1995 # spaces, if the user's actual input started itself with whitespace.
1995 # spaces, if the user's actual input started itself with whitespace.
1996 #debugx('self.buffer[-1]')
1996 #debugx('self.buffer[-1]')
1997
1997
1998 if self.autoindent:
1998 if self.autoindent:
1999 if num_ini_spaces(line) > self.indent_current_nsp:
1999 if num_ini_spaces(line) > self.indent_current_nsp:
2000 line = line[self.indent_current_nsp:]
2000 line = line[self.indent_current_nsp:]
2001 self.indent_current_nsp = 0
2001 self.indent_current_nsp = 0
2002
2002
2003 # store the unfiltered input before the user has any chance to modify
2003 # store the unfiltered input before the user has any chance to modify
2004 # it.
2004 # it.
2005 if line.strip():
2005 if line.strip():
2006 if continue_prompt:
2006 if continue_prompt:
2007 self.input_hist_raw[-1] += '%s\n' % line
2007 self.input_hist_raw[-1] += '%s\n' % line
2008 if self.has_readline: # and some config option is set?
2008 if self.has_readline: # and some config option is set?
2009 try:
2009 try:
2010 histlen = self.readline.get_current_history_length()
2010 histlen = self.readline.get_current_history_length()
2011 newhist = self.input_hist_raw[-1].rstrip()
2011 newhist = self.input_hist_raw[-1].rstrip()
2012 self.readline.remove_history_item(histlen-1)
2012 self.readline.remove_history_item(histlen-1)
2013 self.readline.replace_history_item(histlen-2,newhist)
2013 self.readline.replace_history_item(histlen-2,newhist)
2014 except AttributeError:
2014 except AttributeError:
2015 pass # re{move,place}_history_item are new in 2.4.
2015 pass # re{move,place}_history_item are new in 2.4.
2016 else:
2016 else:
2017 self.input_hist_raw.append('%s\n' % line)
2017 self.input_hist_raw.append('%s\n' % line)
2018
2018
2019 try:
2019 try:
2020 lineout = self.prefilter(line,continue_prompt)
2020 lineout = self.prefilter(line,continue_prompt)
2021 except:
2021 except:
2022 # blanket except, in case a user-defined prefilter crashes, so it
2022 # blanket except, in case a user-defined prefilter crashes, so it
2023 # can't take all of ipython with it.
2023 # can't take all of ipython with it.
2024 self.showtraceback()
2024 self.showtraceback()
2025 return ''
2025 return ''
2026 else:
2026 else:
2027 return lineout
2027 return lineout
2028
2028
2029 def split_user_input(self,line, pattern = None):
2029 def split_user_input(self,line, pattern = None):
2030 """Split user input into pre-char, function part and rest."""
2030 """Split user input into pre-char, function part and rest."""
2031
2031
2032 if pattern is None:
2032 if pattern is None:
2033 pattern = self.line_split
2033 pattern = self.line_split
2034
2034
2035 lsplit = pattern.match(line)
2035 lsplit = pattern.match(line)
2036 if lsplit is None: # no regexp match returns None
2036 if lsplit is None: # no regexp match returns None
2037 #print "match failed for line '%s'" % line # dbg
2037 #print "match failed for line '%s'" % line # dbg
2038 try:
2038 try:
2039 iFun,theRest = line.split(None,1)
2039 iFun,theRest = line.split(None,1)
2040 except ValueError:
2040 except ValueError:
2041 #print "split failed for line '%s'" % line # dbg
2041 #print "split failed for line '%s'" % line # dbg
2042 iFun,theRest = line,''
2042 iFun,theRest = line,''
2043 pre = re.match('^(\s*)(.*)',line).groups()[0]
2043 pre = re.match('^(\s*)(.*)',line).groups()[0]
2044 else:
2044 else:
2045 pre,iFun,theRest = lsplit.groups()
2045 pre,iFun,theRest = lsplit.groups()
2046
2046
2047 #print 'line:<%s>' % line # dbg
2047 #print 'line:<%s>' % line # dbg
2048 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
2048 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
2049 return pre,iFun.strip(),theRest
2049 return pre,iFun.strip(),theRest
2050
2050
2051 # THIS VERSION IS BROKEN!!! It was intended to prevent spurious attribute
2051 # THIS VERSION IS BROKEN!!! It was intended to prevent spurious attribute
2052 # accesses with a more stringent check of inputs, but it introduced other
2052 # accesses with a more stringent check of inputs, but it introduced other
2053 # bugs. Disable it for now until I can properly fix it.
2053 # bugs. Disable it for now until I can properly fix it.
2054 def split_user_inputBROKEN(self,line):
2054 def split_user_inputBROKEN(self,line):
2055 """Split user input into pre-char, function part and rest."""
2055 """Split user input into pre-char, function part and rest."""
2056
2056
2057 lsplit = self.line_split.match(line)
2057 lsplit = self.line_split.match(line)
2058 if lsplit is None: # no regexp match returns None
2058 if lsplit is None: # no regexp match returns None
2059 lsplit = self.line_split_fallback.match(line)
2059 lsplit = self.line_split_fallback.match(line)
2060
2060
2061 #pre,iFun,theRest = lsplit.groups() # dbg
2061 #pre,iFun,theRest = lsplit.groups() # dbg
2062 #print 'line:<%s>' % line # dbg
2062 #print 'line:<%s>' % line # dbg
2063 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
2063 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
2064 #return pre,iFun.strip(),theRest # dbg
2064 #return pre,iFun.strip(),theRest # dbg
2065
2065
2066 return lsplit.groups()
2066 return lsplit.groups()
2067
2067
2068 def _prefilter(self, line, continue_prompt):
2068 def _prefilter(self, line, continue_prompt):
2069 """Calls different preprocessors, depending on the form of line."""
2069 """Calls different preprocessors, depending on the form of line."""
2070
2070
2071 # All handlers *must* return a value, even if it's blank ('').
2071 # All handlers *must* return a value, even if it's blank ('').
2072
2072
2073 # Lines are NOT logged here. Handlers should process the line as
2073 # Lines are NOT logged here. Handlers should process the line as
2074 # needed, update the cache AND log it (so that the input cache array
2074 # needed, update the cache AND log it (so that the input cache array
2075 # stays synced).
2075 # stays synced).
2076
2076
2077 # This function is _very_ delicate, and since it's also the one which
2077 # This function is _very_ delicate, and since it's also the one which
2078 # determines IPython's response to user input, it must be as efficient
2078 # determines IPython's response to user input, it must be as efficient
2079 # as possible. For this reason it has _many_ returns in it, trying
2079 # as possible. For this reason it has _many_ returns in it, trying
2080 # always to exit as quickly as it can figure out what it needs to do.
2080 # always to exit as quickly as it can figure out what it needs to do.
2081
2081
2082 # This function is the main responsible for maintaining IPython's
2082 # This function is the main responsible for maintaining IPython's
2083 # behavior respectful of Python's semantics. So be _very_ careful if
2083 # behavior respectful of Python's semantics. So be _very_ careful if
2084 # making changes to anything here.
2084 # making changes to anything here.
2085
2085
2086 #.....................................................................
2086 #.....................................................................
2087 # Code begins
2087 # Code begins
2088
2088
2089 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
2089 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
2090
2090
2091 # save the line away in case we crash, so the post-mortem handler can
2091 # save the line away in case we crash, so the post-mortem handler can
2092 # record it
2092 # record it
2093 self._last_input_line = line
2093 self._last_input_line = line
2094
2094
2095 #print '***line: <%s>' % line # dbg
2095 #print '***line: <%s>' % line # dbg
2096
2096
2097 # the input history needs to track even empty lines
2097 # the input history needs to track even empty lines
2098 stripped = line.strip()
2098 stripped = line.strip()
2099
2099
2100 if not stripped:
2100 if not stripped:
2101 if not continue_prompt:
2101 if not continue_prompt:
2102 self.outputcache.prompt_count -= 1
2102 self.outputcache.prompt_count -= 1
2103 return self.handle_normal(line,continue_prompt)
2103 return self.handle_normal(line,continue_prompt)
2104 #return self.handle_normal('',continue_prompt)
2104 #return self.handle_normal('',continue_prompt)
2105
2105
2106 # print '***cont',continue_prompt # dbg
2106 # print '***cont',continue_prompt # dbg
2107 # special handlers are only allowed for single line statements
2107 # special handlers are only allowed for single line statements
2108 if continue_prompt and not self.rc.multi_line_specials:
2108 if continue_prompt and not self.rc.multi_line_specials:
2109 return self.handle_normal(line,continue_prompt)
2109 return self.handle_normal(line,continue_prompt)
2110
2110
2111
2111
2112 # For the rest, we need the structure of the input
2112 # For the rest, we need the structure of the input
2113 pre,iFun,theRest = self.split_user_input(line)
2113 pre,iFun,theRest = self.split_user_input(line)
2114
2114
2115 # See whether any pre-existing handler can take care of it
2115 # See whether any pre-existing handler can take care of it
2116
2116
2117 rewritten = self.hooks.input_prefilter(stripped)
2117 rewritten = self.hooks.input_prefilter(stripped)
2118 if rewritten != stripped: # ok, some prefilter did something
2118 if rewritten != stripped: # ok, some prefilter did something
2119 rewritten = pre + rewritten # add indentation
2119 rewritten = pre + rewritten # add indentation
2120 return self.handle_normal(rewritten)
2120 return self.handle_normal(rewritten)
2121
2121
2122 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2122 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2123
2123
2124 # Next, check if we can automatically execute this thing
2124 # Next, check if we can automatically execute this thing
2125
2125
2126 # Allow ! in multi-line statements if multi_line_specials is on:
2126 # Allow ! in multi-line statements if multi_line_specials is on:
2127 if continue_prompt and self.rc.multi_line_specials and \
2127 if continue_prompt and self.rc.multi_line_specials and \
2128 iFun.startswith(self.ESC_SHELL):
2128 iFun.startswith(self.ESC_SHELL):
2129 return self.handle_shell_escape(line,continue_prompt,
2129 return self.handle_shell_escape(line,continue_prompt,
2130 pre=pre,iFun=iFun,
2130 pre=pre,iFun=iFun,
2131 theRest=theRest)
2131 theRest=theRest)
2132
2132
2133 # First check for explicit escapes in the last/first character
2133 # First check for explicit escapes in the last/first character
2134 handler = None
2134 handler = None
2135 if line[-1] == self.ESC_HELP:
2135 if line[-1] == self.ESC_HELP:
2136 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
2136 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
2137 if handler is None:
2137 if handler is None:
2138 # look at the first character of iFun, NOT of line, so we skip
2138 # look at the first character of iFun, NOT of line, so we skip
2139 # leading whitespace in multiline input
2139 # leading whitespace in multiline input
2140 handler = self.esc_handlers.get(iFun[0:1])
2140 handler = self.esc_handlers.get(iFun[0:1])
2141 if handler is not None:
2141 if handler is not None:
2142 return handler(line,continue_prompt,pre,iFun,theRest)
2142 return handler(line,continue_prompt,pre,iFun,theRest)
2143 # Emacs ipython-mode tags certain input lines
2143 # Emacs ipython-mode tags certain input lines
2144 if line.endswith('# PYTHON-MODE'):
2144 if line.endswith('# PYTHON-MODE'):
2145 return self.handle_emacs(line,continue_prompt)
2145 return self.handle_emacs(line,continue_prompt)
2146
2146
2147 # Let's try to find if the input line is a magic fn
2147 # Let's try to find if the input line is a magic fn
2148 oinfo = None
2148 oinfo = None
2149 if hasattr(self,'magic_'+iFun):
2149 if hasattr(self,'magic_'+iFun):
2150 # WARNING: _ofind uses getattr(), so it can consume generators and
2150 # WARNING: _ofind uses getattr(), so it can consume generators and
2151 # cause other side effects.
2151 # cause other side effects.
2152 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2152 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2153 if oinfo['ismagic']:
2153 if oinfo['ismagic']:
2154 # Be careful not to call magics when a variable assignment is
2154 # Be careful not to call magics when a variable assignment is
2155 # being made (ls='hi', for example)
2155 # being made (ls='hi', for example)
2156 if self.rc.automagic and \
2156 if self.rc.automagic and \
2157 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
2157 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
2158 (self.rc.multi_line_specials or not continue_prompt):
2158 (self.rc.multi_line_specials or not continue_prompt):
2159 return self.handle_magic(line,continue_prompt,
2159 return self.handle_magic(line,continue_prompt,
2160 pre,iFun,theRest)
2160 pre,iFun,theRest)
2161 else:
2161 else:
2162 return self.handle_normal(line,continue_prompt)
2162 return self.handle_normal(line,continue_prompt)
2163
2163
2164 # If the rest of the line begins with an (in)equality, assginment or
2164 # If the rest of the line begins with an (in)equality, assginment or
2165 # function call, we should not call _ofind but simply execute it.
2165 # function call, we should not call _ofind but simply execute it.
2166 # This avoids spurious geattr() accesses on objects upon assignment.
2166 # This avoids spurious geattr() accesses on objects upon assignment.
2167 #
2167 #
2168 # It also allows users to assign to either alias or magic names true
2168 # It also allows users to assign to either alias or magic names true
2169 # python variables (the magic/alias systems always take second seat to
2169 # python variables (the magic/alias systems always take second seat to
2170 # true python code).
2170 # true python code).
2171 if theRest and theRest[0] in '!=()':
2171 if theRest and theRest[0] in '!=()':
2172 return self.handle_normal(line,continue_prompt)
2172 return self.handle_normal(line,continue_prompt)
2173
2173
2174 if oinfo is None:
2174 if oinfo is None:
2175 # let's try to ensure that _oinfo is ONLY called when autocall is
2175 # let's try to ensure that _oinfo is ONLY called when autocall is
2176 # on. Since it has inevitable potential side effects, at least
2176 # on. Since it has inevitable potential side effects, at least
2177 # having autocall off should be a guarantee to the user that no
2177 # having autocall off should be a guarantee to the user that no
2178 # weird things will happen.
2178 # weird things will happen.
2179
2179
2180 if self.rc.autocall:
2180 if self.rc.autocall:
2181 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2181 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2182 else:
2182 else:
2183 # in this case, all that's left is either an alias or
2183 # in this case, all that's left is either an alias or
2184 # processing the line normally.
2184 # processing the line normally.
2185 if iFun in self.alias_table:
2185 if iFun in self.alias_table:
2186 # if autocall is off, by not running _ofind we won't know
2186 # if autocall is off, by not running _ofind we won't know
2187 # whether the given name may also exist in one of the
2187 # whether the given name may also exist in one of the
2188 # user's namespace. At this point, it's best to do a
2188 # user's namespace. At this point, it's best to do a
2189 # quick check just to be sure that we don't let aliases
2189 # quick check just to be sure that we don't let aliases
2190 # shadow variables.
2190 # shadow variables.
2191 head = iFun.split('.',1)[0]
2191 head = iFun.split('.',1)[0]
2192 if head in self.user_ns or head in self.internal_ns \
2192 if head in self.user_ns or head in self.internal_ns \
2193 or head in __builtin__.__dict__:
2193 or head in __builtin__.__dict__:
2194 return self.handle_normal(line,continue_prompt)
2194 return self.handle_normal(line,continue_prompt)
2195 else:
2195 else:
2196 return self.handle_alias(line,continue_prompt,
2196 return self.handle_alias(line,continue_prompt,
2197 pre,iFun,theRest)
2197 pre,iFun,theRest)
2198
2198
2199 else:
2199 else:
2200 return self.handle_normal(line,continue_prompt)
2200 return self.handle_normal(line,continue_prompt)
2201
2201
2202 if not oinfo['found']:
2202 if not oinfo['found']:
2203 return self.handle_normal(line,continue_prompt)
2203 return self.handle_normal(line,continue_prompt)
2204 else:
2204 else:
2205 #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2205 #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2206 if oinfo['isalias']:
2206 if oinfo['isalias']:
2207 return self.handle_alias(line,continue_prompt,
2207 return self.handle_alias(line,continue_prompt,
2208 pre,iFun,theRest)
2208 pre,iFun,theRest)
2209
2209
2210 if (self.rc.autocall
2210 if (self.rc.autocall
2211 and
2211 and
2212 (
2212 (
2213 #only consider exclusion re if not "," or ";" autoquoting
2213 #only consider exclusion re if not "," or ";" autoquoting
2214 (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2
2214 (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2
2215 or pre == self.ESC_PAREN) or
2215 or pre == self.ESC_PAREN) or
2216 (not self.re_exclude_auto.match(theRest)))
2216 (not self.re_exclude_auto.match(theRest)))
2217 and
2217 and
2218 self.re_fun_name.match(iFun) and
2218 self.re_fun_name.match(iFun) and
2219 callable(oinfo['obj'])) :
2219 callable(oinfo['obj'])) :
2220 #print 'going auto' # dbg
2220 #print 'going auto' # dbg
2221 return self.handle_auto(line,continue_prompt,
2221 return self.handle_auto(line,continue_prompt,
2222 pre,iFun,theRest,oinfo['obj'])
2222 pre,iFun,theRest,oinfo['obj'])
2223 else:
2223 else:
2224 #print 'was callable?', callable(oinfo['obj']) # dbg
2224 #print 'was callable?', callable(oinfo['obj']) # dbg
2225 return self.handle_normal(line,continue_prompt)
2225 return self.handle_normal(line,continue_prompt)
2226
2226
2227 # If we get here, we have a normal Python line. Log and return.
2227 # If we get here, we have a normal Python line. Log and return.
2228 return self.handle_normal(line,continue_prompt)
2228 return self.handle_normal(line,continue_prompt)
2229
2229
2230 def _prefilter_dumb(self, line, continue_prompt):
2230 def _prefilter_dumb(self, line, continue_prompt):
2231 """simple prefilter function, for debugging"""
2231 """simple prefilter function, for debugging"""
2232 return self.handle_normal(line,continue_prompt)
2232 return self.handle_normal(line,continue_prompt)
2233
2233
2234
2234
2235 def multiline_prefilter(self, line, continue_prompt):
2235 def multiline_prefilter(self, line, continue_prompt):
2236 """ Run _prefilter for each line of input
2236 """ Run _prefilter for each line of input
2237
2237
2238 Covers cases where there are multiple lines in the user entry,
2238 Covers cases where there are multiple lines in the user entry,
2239 which is the case when the user goes back to a multiline history
2239 which is the case when the user goes back to a multiline history
2240 entry and presses enter.
2240 entry and presses enter.
2241
2241
2242 """
2242 """
2243 out = []
2243 out = []
2244 for l in line.rstrip('\n').split('\n'):
2244 for l in line.rstrip('\n').split('\n'):
2245 out.append(self._prefilter(l, continue_prompt))
2245 out.append(self._prefilter(l, continue_prompt))
2246 return '\n'.join(out)
2246 return '\n'.join(out)
2247
2247
2248 # Set the default prefilter() function (this can be user-overridden)
2248 # Set the default prefilter() function (this can be user-overridden)
2249 prefilter = multiline_prefilter
2249 prefilter = multiline_prefilter
2250
2250
2251 def handle_normal(self,line,continue_prompt=None,
2251 def handle_normal(self,line,continue_prompt=None,
2252 pre=None,iFun=None,theRest=None):
2252 pre=None,iFun=None,theRest=None):
2253 """Handle normal input lines. Use as a template for handlers."""
2253 """Handle normal input lines. Use as a template for handlers."""
2254
2254
2255 # With autoindent on, we need some way to exit the input loop, and I
2255 # With autoindent on, we need some way to exit the input loop, and I
2256 # don't want to force the user to have to backspace all the way to
2256 # don't want to force the user to have to backspace all the way to
2257 # clear the line. The rule will be in this case, that either two
2257 # clear the line. The rule will be in this case, that either two
2258 # lines of pure whitespace in a row, or a line of pure whitespace but
2258 # lines of pure whitespace in a row, or a line of pure whitespace but
2259 # of a size different to the indent level, will exit the input loop.
2259 # of a size different to the indent level, will exit the input loop.
2260
2260
2261 if (continue_prompt and self.autoindent and line.isspace() and
2261 if (continue_prompt and self.autoindent and line.isspace() and
2262 (0 < abs(len(line) - self.indent_current_nsp) <= 2 or
2262 (0 < abs(len(line) - self.indent_current_nsp) <= 2 or
2263 (self.buffer[-1]).isspace() )):
2263 (self.buffer[-1]).isspace() )):
2264 line = ''
2264 line = ''
2265
2265
2266 self.log(line,line,continue_prompt)
2266 self.log(line,line,continue_prompt)
2267 return line
2267 return line
2268
2268
2269 def handle_alias(self,line,continue_prompt=None,
2269 def handle_alias(self,line,continue_prompt=None,
2270 pre=None,iFun=None,theRest=None):
2270 pre=None,iFun=None,theRest=None):
2271 """Handle alias input lines. """
2271 """Handle alias input lines. """
2272
2272
2273 # pre is needed, because it carries the leading whitespace. Otherwise
2273 # pre is needed, because it carries the leading whitespace. Otherwise
2274 # aliases won't work in indented sections.
2274 # aliases won't work in indented sections.
2275 transformed = self.expand_aliases(iFun, theRest)
2275 transformed = self.expand_aliases(iFun, theRest)
2276 line_out = '%s_ip.system(%s)' % (pre, make_quoted_expr( transformed ))
2276 line_out = '%s_ip.system(%s)' % (pre, make_quoted_expr( transformed ))
2277 self.log(line,line_out,continue_prompt)
2277 self.log(line,line_out,continue_prompt)
2278 #print 'line out:',line_out # dbg
2278 #print 'line out:',line_out # dbg
2279 return line_out
2279 return line_out
2280
2280
2281 def handle_shell_escape(self, line, continue_prompt=None,
2281 def handle_shell_escape(self, line, continue_prompt=None,
2282 pre=None,iFun=None,theRest=None):
2282 pre=None,iFun=None,theRest=None):
2283 """Execute the line in a shell, empty return value"""
2283 """Execute the line in a shell, empty return value"""
2284
2284
2285 #print 'line in :', `line` # dbg
2285 #print 'line in :', `line` # dbg
2286 # Example of a special handler. Others follow a similar pattern.
2286 # Example of a special handler. Others follow a similar pattern.
2287 if line.lstrip().startswith('!!'):
2287 if line.lstrip().startswith('!!'):
2288 # rewrite iFun/theRest to properly hold the call to %sx and
2288 # rewrite iFun/theRest to properly hold the call to %sx and
2289 # the actual command to be executed, so handle_magic can work
2289 # the actual command to be executed, so handle_magic can work
2290 # correctly
2290 # correctly
2291 theRest = '%s %s' % (iFun[2:],theRest)
2291 theRest = '%s %s' % (iFun[2:],theRest)
2292 iFun = 'sx'
2292 iFun = 'sx'
2293 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,
2293 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,
2294 line.lstrip()[2:]),
2294 line.lstrip()[2:]),
2295 continue_prompt,pre,iFun,theRest)
2295 continue_prompt,pre,iFun,theRest)
2296 else:
2296 else:
2297 cmd=line.lstrip().lstrip('!')
2297 cmd=line.lstrip().lstrip('!')
2298 line_out = '%s_ip.system(%s)' % (pre,make_quoted_expr(cmd))
2298 line_out = '%s_ip.system(%s)' % (pre,make_quoted_expr(cmd))
2299 # update cache/log and return
2299 # update cache/log and return
2300 self.log(line,line_out,continue_prompt)
2300 self.log(line,line_out,continue_prompt)
2301 return line_out
2301 return line_out
2302
2302
2303 def handle_magic(self, line, continue_prompt=None,
2303 def handle_magic(self, line, continue_prompt=None,
2304 pre=None,iFun=None,theRest=None):
2304 pre=None,iFun=None,theRest=None):
2305 """Execute magic functions."""
2305 """Execute magic functions."""
2306
2306
2307
2307
2308 cmd = '%s_ip.magic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
2308 cmd = '%s_ip.magic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
2309 self.log(line,cmd,continue_prompt)
2309 self.log(line,cmd,continue_prompt)
2310 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
2310 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
2311 return cmd
2311 return cmd
2312
2312
2313 def handle_auto(self, line, continue_prompt=None,
2313 def handle_auto(self, line, continue_prompt=None,
2314 pre=None,iFun=None,theRest=None,obj=None):
2314 pre=None,iFun=None,theRest=None,obj=None):
2315 """Hande lines which can be auto-executed, quoting if requested."""
2315 """Hande lines which can be auto-executed, quoting if requested."""
2316
2316
2317 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2317 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2318
2318
2319 # This should only be active for single-line input!
2319 # This should only be active for single-line input!
2320 if continue_prompt:
2320 if continue_prompt:
2321 self.log(line,line,continue_prompt)
2321 self.log(line,line,continue_prompt)
2322 return line
2322 return line
2323
2323
2324 auto_rewrite = True
2324 auto_rewrite = True
2325
2325
2326 if pre == self.ESC_QUOTE:
2326 if pre == self.ESC_QUOTE:
2327 # Auto-quote splitting on whitespace
2327 # Auto-quote splitting on whitespace
2328 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
2328 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
2329 elif pre == self.ESC_QUOTE2:
2329 elif pre == self.ESC_QUOTE2:
2330 # Auto-quote whole string
2330 # Auto-quote whole string
2331 newcmd = '%s("%s")' % (iFun,theRest)
2331 newcmd = '%s("%s")' % (iFun,theRest)
2332 elif pre == self.ESC_PAREN:
2332 elif pre == self.ESC_PAREN:
2333 newcmd = '%s(%s)' % (iFun,",".join(theRest.split()))
2333 newcmd = '%s(%s)' % (iFun,",".join(theRest.split()))
2334 else:
2334 else:
2335 # Auto-paren.
2335 # Auto-paren.
2336 # We only apply it to argument-less calls if the autocall
2336 # We only apply it to argument-less calls if the autocall
2337 # parameter is set to 2. We only need to check that autocall is <
2337 # parameter is set to 2. We only need to check that autocall is <
2338 # 2, since this function isn't called unless it's at least 1.
2338 # 2, since this function isn't called unless it's at least 1.
2339 if not theRest and (self.rc.autocall < 2):
2339 if not theRest and (self.rc.autocall < 2):
2340 newcmd = '%s %s' % (iFun,theRest)
2340 newcmd = '%s %s' % (iFun,theRest)
2341 auto_rewrite = False
2341 auto_rewrite = False
2342 else:
2342 else:
2343 if theRest.startswith('['):
2343 if theRest.startswith('['):
2344 if hasattr(obj,'__getitem__'):
2344 if hasattr(obj,'__getitem__'):
2345 # Don't autocall in this case: item access for an object
2345 # Don't autocall in this case: item access for an object
2346 # which is BOTH callable and implements __getitem__.
2346 # which is BOTH callable and implements __getitem__.
2347 newcmd = '%s %s' % (iFun,theRest)
2347 newcmd = '%s %s' % (iFun,theRest)
2348 auto_rewrite = False
2348 auto_rewrite = False
2349 else:
2349 else:
2350 # if the object doesn't support [] access, go ahead and
2350 # if the object doesn't support [] access, go ahead and
2351 # autocall
2351 # autocall
2352 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2352 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2353 elif theRest.endswith(';'):
2353 elif theRest.endswith(';'):
2354 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
2354 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
2355 else:
2355 else:
2356 newcmd = '%s(%s)' % (iFun.rstrip(), theRest)
2356 newcmd = '%s(%s)' % (iFun.rstrip(), theRest)
2357
2357
2358 if auto_rewrite:
2358 if auto_rewrite:
2359 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
2359 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
2360 # log what is now valid Python, not the actual user input (without the
2360 # log what is now valid Python, not the actual user input (without the
2361 # final newline)
2361 # final newline)
2362 self.log(line,newcmd,continue_prompt)
2362 self.log(line,newcmd,continue_prompt)
2363 return newcmd
2363 return newcmd
2364
2364
2365 def handle_help(self, line, continue_prompt=None,
2365 def handle_help(self, line, continue_prompt=None,
2366 pre=None,iFun=None,theRest=None):
2366 pre=None,iFun=None,theRest=None):
2367 """Try to get some help for the object.
2367 """Try to get some help for the object.
2368
2368
2369 obj? or ?obj -> basic information.
2369 obj? or ?obj -> basic information.
2370 obj?? or ??obj -> more details.
2370 obj?? or ??obj -> more details.
2371 """
2371 """
2372
2372
2373 # We need to make sure that we don't process lines which would be
2373 # We need to make sure that we don't process lines which would be
2374 # otherwise valid python, such as "x=1 # what?"
2374 # otherwise valid python, such as "x=1 # what?"
2375 try:
2375 try:
2376 codeop.compile_command(line)
2376 codeop.compile_command(line)
2377 except SyntaxError:
2377 except SyntaxError:
2378 # We should only handle as help stuff which is NOT valid syntax
2378 # We should only handle as help stuff which is NOT valid syntax
2379 if line[0]==self.ESC_HELP:
2379 if line[0]==self.ESC_HELP:
2380 line = line[1:]
2380 line = line[1:]
2381 elif line[-1]==self.ESC_HELP:
2381 elif line[-1]==self.ESC_HELP:
2382 line = line[:-1]
2382 line = line[:-1]
2383 self.log(line,'#?'+line,continue_prompt)
2383 self.log(line,'#?'+line,continue_prompt)
2384 if line:
2384 if line:
2385 #print 'line:<%r>' % line # dbg
2385 self.magic_pinfo(line)
2386 self.magic_pinfo(line)
2386 else:
2387 else:
2387 page(self.usage,screen_lines=self.rc.screen_length)
2388 page(self.usage,screen_lines=self.rc.screen_length)
2388 return '' # Empty string is needed here!
2389 return '' # Empty string is needed here!
2389 except:
2390 except:
2390 # Pass any other exceptions through to the normal handler
2391 # Pass any other exceptions through to the normal handler
2391 return self.handle_normal(line,continue_prompt)
2392 return self.handle_normal(line,continue_prompt)
2392 else:
2393 else:
2393 # If the code compiles ok, we should handle it normally
2394 # If the code compiles ok, we should handle it normally
2394 return self.handle_normal(line,continue_prompt)
2395 return self.handle_normal(line,continue_prompt)
2395
2396
2396 def getapi(self):
2397 def getapi(self):
2397 """ Get an IPApi object for this shell instance
2398 """ Get an IPApi object for this shell instance
2398
2399
2399 Getting an IPApi object is always preferable to accessing the shell
2400 Getting an IPApi object is always preferable to accessing the shell
2400 directly, but this holds true especially for extensions.
2401 directly, but this holds true especially for extensions.
2401
2402
2402 It should always be possible to implement an extension with IPApi
2403 It should always be possible to implement an extension with IPApi
2403 alone. If not, contact maintainer to request an addition.
2404 alone. If not, contact maintainer to request an addition.
2404
2405
2405 """
2406 """
2406 return self.api
2407 return self.api
2407
2408
2408 def handle_emacs(self,line,continue_prompt=None,
2409 def handle_emacs(self,line,continue_prompt=None,
2409 pre=None,iFun=None,theRest=None):
2410 pre=None,iFun=None,theRest=None):
2410 """Handle input lines marked by python-mode."""
2411 """Handle input lines marked by python-mode."""
2411
2412
2412 # Currently, nothing is done. Later more functionality can be added
2413 # Currently, nothing is done. Later more functionality can be added
2413 # here if needed.
2414 # here if needed.
2414
2415
2415 # The input cache shouldn't be updated
2416 # The input cache shouldn't be updated
2416
2417
2417 return line
2418 return line
2418
2419
2419 def mktempfile(self,data=None):
2420 def mktempfile(self,data=None):
2420 """Make a new tempfile and return its filename.
2421 """Make a new tempfile and return its filename.
2421
2422
2422 This makes a call to tempfile.mktemp, but it registers the created
2423 This makes a call to tempfile.mktemp, but it registers the created
2423 filename internally so ipython cleans it up at exit time.
2424 filename internally so ipython cleans it up at exit time.
2424
2425
2425 Optional inputs:
2426 Optional inputs:
2426
2427
2427 - data(None): if data is given, it gets written out to the temp file
2428 - data(None): if data is given, it gets written out to the temp file
2428 immediately, and the file is closed again."""
2429 immediately, and the file is closed again."""
2429
2430
2430 filename = tempfile.mktemp('.py','ipython_edit_')
2431 filename = tempfile.mktemp('.py','ipython_edit_')
2431 self.tempfiles.append(filename)
2432 self.tempfiles.append(filename)
2432
2433
2433 if data:
2434 if data:
2434 tmp_file = open(filename,'w')
2435 tmp_file = open(filename,'w')
2435 tmp_file.write(data)
2436 tmp_file.write(data)
2436 tmp_file.close()
2437 tmp_file.close()
2437 return filename
2438 return filename
2438
2439
2439 def write(self,data):
2440 def write(self,data):
2440 """Write a string to the default output"""
2441 """Write a string to the default output"""
2441 Term.cout.write(data)
2442 Term.cout.write(data)
2442
2443
2443 def write_err(self,data):
2444 def write_err(self,data):
2444 """Write a string to the default error output"""
2445 """Write a string to the default error output"""
2445 Term.cerr.write(data)
2446 Term.cerr.write(data)
2446
2447
2447 def exit(self):
2448 def exit(self):
2448 """Handle interactive exit.
2449 """Handle interactive exit.
2449
2450
2450 This method sets the exit_now attribute."""
2451 This method sets the exit_now attribute."""
2451
2452
2452 if self.rc.confirm_exit:
2453 if self.rc.confirm_exit:
2453 if self.ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2454 if self.ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2454 self.exit_now = True
2455 self.exit_now = True
2455 else:
2456 else:
2456 self.exit_now = True
2457 self.exit_now = True
2457
2458
2458 def safe_execfile(self,fname,*where,**kw):
2459 def safe_execfile(self,fname,*where,**kw):
2459 """A safe version of the builtin execfile().
2460 """A safe version of the builtin execfile().
2460
2461
2461 This version will never throw an exception, and knows how to handle
2462 This version will never throw an exception, and knows how to handle
2462 ipython logs as well."""
2463 ipython logs as well."""
2463
2464
2464 def syspath_cleanup():
2465 def syspath_cleanup():
2465 """Internal cleanup routine for sys.path."""
2466 """Internal cleanup routine for sys.path."""
2466 if add_dname:
2467 if add_dname:
2467 try:
2468 try:
2468 sys.path.remove(dname)
2469 sys.path.remove(dname)
2469 except ValueError:
2470 except ValueError:
2470 # For some reason the user has already removed it, ignore.
2471 # For some reason the user has already removed it, ignore.
2471 pass
2472 pass
2472
2473
2473 fname = os.path.expanduser(fname)
2474 fname = os.path.expanduser(fname)
2474
2475
2475 # Find things also in current directory. This is needed to mimic the
2476 # Find things also in current directory. This is needed to mimic the
2476 # behavior of running a script from the system command line, where
2477 # behavior of running a script from the system command line, where
2477 # Python inserts the script's directory into sys.path
2478 # Python inserts the script's directory into sys.path
2478 dname = os.path.dirname(os.path.abspath(fname))
2479 dname = os.path.dirname(os.path.abspath(fname))
2479 add_dname = False
2480 add_dname = False
2480 if dname not in sys.path:
2481 if dname not in sys.path:
2481 sys.path.insert(0,dname)
2482 sys.path.insert(0,dname)
2482 add_dname = True
2483 add_dname = True
2483
2484
2484 try:
2485 try:
2485 xfile = open(fname)
2486 xfile = open(fname)
2486 except:
2487 except:
2487 print >> Term.cerr, \
2488 print >> Term.cerr, \
2488 'Could not open file <%s> for safe execution.' % fname
2489 'Could not open file <%s> for safe execution.' % fname
2489 syspath_cleanup()
2490 syspath_cleanup()
2490 return None
2491 return None
2491
2492
2492 kw.setdefault('islog',0)
2493 kw.setdefault('islog',0)
2493 kw.setdefault('quiet',1)
2494 kw.setdefault('quiet',1)
2494 kw.setdefault('exit_ignore',0)
2495 kw.setdefault('exit_ignore',0)
2495 first = xfile.readline()
2496 first = xfile.readline()
2496 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2497 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2497 xfile.close()
2498 xfile.close()
2498 # line by line execution
2499 # line by line execution
2499 if first.startswith(loghead) or kw['islog']:
2500 if first.startswith(loghead) or kw['islog']:
2500 print 'Loading log file <%s> one line at a time...' % fname
2501 print 'Loading log file <%s> one line at a time...' % fname
2501 if kw['quiet']:
2502 if kw['quiet']:
2502 stdout_save = sys.stdout
2503 stdout_save = sys.stdout
2503 sys.stdout = StringIO.StringIO()
2504 sys.stdout = StringIO.StringIO()
2504 try:
2505 try:
2505 globs,locs = where[0:2]
2506 globs,locs = where[0:2]
2506 except:
2507 except:
2507 try:
2508 try:
2508 globs = locs = where[0]
2509 globs = locs = where[0]
2509 except:
2510 except:
2510 globs = locs = globals()
2511 globs = locs = globals()
2511 badblocks = []
2512 badblocks = []
2512
2513
2513 # we also need to identify indented blocks of code when replaying
2514 # we also need to identify indented blocks of code when replaying
2514 # logs and put them together before passing them to an exec
2515 # logs and put them together before passing them to an exec
2515 # statement. This takes a bit of regexp and look-ahead work in the
2516 # statement. This takes a bit of regexp and look-ahead work in the
2516 # file. It's easiest if we swallow the whole thing in memory
2517 # file. It's easiest if we swallow the whole thing in memory
2517 # first, and manually walk through the lines list moving the
2518 # first, and manually walk through the lines list moving the
2518 # counter ourselves.
2519 # counter ourselves.
2519 indent_re = re.compile('\s+\S')
2520 indent_re = re.compile('\s+\S')
2520 xfile = open(fname)
2521 xfile = open(fname)
2521 filelines = xfile.readlines()
2522 filelines = xfile.readlines()
2522 xfile.close()
2523 xfile.close()
2523 nlines = len(filelines)
2524 nlines = len(filelines)
2524 lnum = 0
2525 lnum = 0
2525 while lnum < nlines:
2526 while lnum < nlines:
2526 line = filelines[lnum]
2527 line = filelines[lnum]
2527 lnum += 1
2528 lnum += 1
2528 # don't re-insert logger status info into cache
2529 # don't re-insert logger status info into cache
2529 if line.startswith('#log#'):
2530 if line.startswith('#log#'):
2530 continue
2531 continue
2531 else:
2532 else:
2532 # build a block of code (maybe a single line) for execution
2533 # build a block of code (maybe a single line) for execution
2533 block = line
2534 block = line
2534 try:
2535 try:
2535 next = filelines[lnum] # lnum has already incremented
2536 next = filelines[lnum] # lnum has already incremented
2536 except:
2537 except:
2537 next = None
2538 next = None
2538 while next and indent_re.match(next):
2539 while next and indent_re.match(next):
2539 block += next
2540 block += next
2540 lnum += 1
2541 lnum += 1
2541 try:
2542 try:
2542 next = filelines[lnum]
2543 next = filelines[lnum]
2543 except:
2544 except:
2544 next = None
2545 next = None
2545 # now execute the block of one or more lines
2546 # now execute the block of one or more lines
2546 try:
2547 try:
2547 exec block in globs,locs
2548 exec block in globs,locs
2548 except SystemExit:
2549 except SystemExit:
2549 pass
2550 pass
2550 except:
2551 except:
2551 badblocks.append(block.rstrip())
2552 badblocks.append(block.rstrip())
2552 if kw['quiet']: # restore stdout
2553 if kw['quiet']: # restore stdout
2553 sys.stdout.close()
2554 sys.stdout.close()
2554 sys.stdout = stdout_save
2555 sys.stdout = stdout_save
2555 print 'Finished replaying log file <%s>' % fname
2556 print 'Finished replaying log file <%s>' % fname
2556 if badblocks:
2557 if badblocks:
2557 print >> sys.stderr, ('\nThe following lines/blocks in file '
2558 print >> sys.stderr, ('\nThe following lines/blocks in file '
2558 '<%s> reported errors:' % fname)
2559 '<%s> reported errors:' % fname)
2559
2560
2560 for badline in badblocks:
2561 for badline in badblocks:
2561 print >> sys.stderr, badline
2562 print >> sys.stderr, badline
2562 else: # regular file execution
2563 else: # regular file execution
2563 try:
2564 try:
2564 execfile(fname,*where)
2565 execfile(fname,*where)
2565 except SyntaxError:
2566 except SyntaxError:
2566 self.showsyntaxerror()
2567 self.showsyntaxerror()
2567 warn('Failure executing file: <%s>' % fname)
2568 warn('Failure executing file: <%s>' % fname)
2568 except SystemExit,status:
2569 except SystemExit,status:
2569 if not kw['exit_ignore']:
2570 if not kw['exit_ignore']:
2570 self.showtraceback()
2571 self.showtraceback()
2571 warn('Failure executing file: <%s>' % fname)
2572 warn('Failure executing file: <%s>' % fname)
2572 except:
2573 except:
2573 self.showtraceback()
2574 self.showtraceback()
2574 warn('Failure executing file: <%s>' % fname)
2575 warn('Failure executing file: <%s>' % fname)
2575
2576
2576 syspath_cleanup()
2577 syspath_cleanup()
2577
2578
2578 #************************* end of file <iplib.py> *****************************
2579 #************************* end of file <iplib.py> *****************************
@@ -1,6401 +1,6408 b''
1 2007-03-29 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/Magic.py (_inspect): convert unicode input into ascii
4 before trying to evaluate it as a Python identifier. This fixes a
5 problem that the new unicode support had introduced when analyzing
6 long definition lines for functions.
7
1 2007-03-24 Walter Doerwald <walter@livinglogic.de>
8 2007-03-24 Walter Doerwald <walter@livinglogic.de>
2
9
3 * IPython/Extensions/igrid.py: Fix picking. Using
10 * IPython/Extensions/igrid.py: Fix picking. Using
4 igrid with wxPython 2.6 and -wthread should work now.
11 igrid with wxPython 2.6 and -wthread should work now.
5 igrid.display() simply tries to create a frame without
12 igrid.display() simply tries to create a frame without
6 an application. Only if this fails an application is created.
13 an application. Only if this fails an application is created.
7
14
8 2007-03-23 Walter Doerwald <walter@livinglogic.de>
15 2007-03-23 Walter Doerwald <walter@livinglogic.de>
9
16
10 * IPython/Extensions/path.py: Updated to version 2.2.
17 * IPython/Extensions/path.py: Updated to version 2.2.
11
18
12 2007-03-23 Ville Vainio <vivainio@gmail.com>
19 2007-03-23 Ville Vainio <vivainio@gmail.com>
13
20
14 * iplib.py: recursive alias expansion now works better, so that
21 * iplib.py: recursive alias expansion now works better, so that
15 cases like 'top' -> 'd:/cygwin/top' -> 'ls :/cygwin/top'
22 cases like 'top' -> 'd:/cygwin/top' -> 'ls :/cygwin/top'
16 doesn't trip up the process, if 'd' has been aliased to 'ls'.
23 doesn't trip up the process, if 'd' has been aliased to 'ls'.
17
24
18 * Extensions/ipy_gnuglobal.py added, provides %global magic
25 * Extensions/ipy_gnuglobal.py added, provides %global magic
19 for users of http://www.gnu.org/software/global
26 for users of http://www.gnu.org/software/global
20
27
21 * iplib.py: '!command /?' now doesn't invoke IPython's help system.
28 * iplib.py: '!command /?' now doesn't invoke IPython's help system.
22 Closes #52. Patch by Stefan van der Walt.
29 Closes #52. Patch by Stefan van der Walt.
23
30
24 2007-03-23 Fernando Perez <Fernando.Perez@colorado.edu>
31 2007-03-23 Fernando Perez <Fernando.Perez@colorado.edu>
25
32
26 * IPython/FakeModule.py (FakeModule.__init__): Small fix to
33 * IPython/FakeModule.py (FakeModule.__init__): Small fix to
27 respect the __file__ attribute when using %run. Thanks to a bug
34 respect the __file__ attribute when using %run. Thanks to a bug
28 report by Sebastian Rooks <sebastian.rooks-AT-free.fr>.
35 report by Sebastian Rooks <sebastian.rooks-AT-free.fr>.
29
36
30 2007-03-22 Fernando Perez <Fernando.Perez@colorado.edu>
37 2007-03-22 Fernando Perez <Fernando.Perez@colorado.edu>
31
38
32 * IPython/iplib.py (raw_input): Fix mishandling of unicode at
39 * IPython/iplib.py (raw_input): Fix mishandling of unicode at
33 input. Patch sent by Stefan.
40 input. Patch sent by Stefan.
34
41
35 2007-03-20 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
42 2007-03-20 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
36 * IPython/Extensions/ipy_stock_completer.py
43 * IPython/Extensions/ipy_stock_completer.py
37 shlex_split, fix bug in shlex_split. len function
44 shlex_split, fix bug in shlex_split. len function
38 call was missing in if statement. Caused shlex_split to
45 call was missing in if statement. Caused shlex_split to
39 sometimes return "" as last element.
46 sometimes return "" as last element.
40
47
41 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu>
48 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu>
42
49
43 * IPython/completer.py
50 * IPython/completer.py
44 (IPCompleter.file_matches.single_dir_expand): fix a problem
51 (IPCompleter.file_matches.single_dir_expand): fix a problem
45 reported by Stefan, where directories containign a single subdir
52 reported by Stefan, where directories containign a single subdir
46 would be completed too early.
53 would be completed too early.
47
54
48 * IPython/Shell.py (_load_pylab): Make the execution of 'from
55 * IPython/Shell.py (_load_pylab): Make the execution of 'from
49 pylab import *' when -pylab is given be optional. A new flag,
56 pylab import *' when -pylab is given be optional. A new flag,
50 pylab_import_all controls this behavior, the default is True for
57 pylab_import_all controls this behavior, the default is True for
51 backwards compatibility.
58 backwards compatibility.
52
59
53 * IPython/ultraTB.py (_formatTracebackLines): Added (slightly
60 * IPython/ultraTB.py (_formatTracebackLines): Added (slightly
54 modified) R. Bernstein's patch for fully syntax highlighted
61 modified) R. Bernstein's patch for fully syntax highlighted
55 tracebacks. The functionality is also available under ultraTB for
62 tracebacks. The functionality is also available under ultraTB for
56 non-ipython users (someone using ultraTB but outside an ipython
63 non-ipython users (someone using ultraTB but outside an ipython
57 session). They can select the color scheme by setting the
64 session). They can select the color scheme by setting the
58 module-level global DEFAULT_SCHEME. The highlight functionality
65 module-level global DEFAULT_SCHEME. The highlight functionality
59 also works when debugging.
66 also works when debugging.
60
67
61 * IPython/genutils.py (IOStream.close): small patch by
68 * IPython/genutils.py (IOStream.close): small patch by
62 R. Bernstein for improved pydb support.
69 R. Bernstein for improved pydb support.
63
70
64 * IPython/Debugger.py (Pdb.format_stack_entry): Added patch by
71 * IPython/Debugger.py (Pdb.format_stack_entry): Added patch by
65 DaveS <davls@telus.net> to improve support of debugging under
72 DaveS <davls@telus.net> to improve support of debugging under
66 NTEmacs, including improved pydb behavior.
73 NTEmacs, including improved pydb behavior.
67
74
68 * IPython/Magic.py (magic_prun): Fix saving of profile info for
75 * IPython/Magic.py (magic_prun): Fix saving of profile info for
69 Python 2.5, where the stats object API changed a little. Thanks
76 Python 2.5, where the stats object API changed a little. Thanks
70 to a bug report by Paul Smith <paul.smith-AT-catugmt.com>.
77 to a bug report by Paul Smith <paul.smith-AT-catugmt.com>.
71
78
72 * IPython/ColorANSI.py (InputTermColors.Normal): applied Nicolas
79 * IPython/ColorANSI.py (InputTermColors.Normal): applied Nicolas
73 Pernetty's patch to improve support for (X)Emacs under Win32.
80 Pernetty's patch to improve support for (X)Emacs under Win32.
74
81
75 2007-03-17 Fernando Perez <Fernando.Perez@colorado.edu>
82 2007-03-17 Fernando Perez <Fernando.Perez@colorado.edu>
76
83
77 * IPython/Shell.py (hijack_wx): ipmort WX with current semantics
84 * IPython/Shell.py (hijack_wx): ipmort WX with current semantics
78 to quiet a deprecation warning that fires with Wx 2.8. Thanks to
85 to quiet a deprecation warning that fires with Wx 2.8. Thanks to
79 a report by Nik Tautenhahn.
86 a report by Nik Tautenhahn.
80
87
81 2007-03-16 Walter Doerwald <walter@livinglogic.de>
88 2007-03-16 Walter Doerwald <walter@livinglogic.de>
82
89
83 * setup.py: Add the igrid help files to the list of data files
90 * setup.py: Add the igrid help files to the list of data files
84 to be installed alongside igrid.
91 to be installed alongside igrid.
85 * IPython/Extensions/igrid.py: (Patch by Nik Tautenhahn)
92 * IPython/Extensions/igrid.py: (Patch by Nik Tautenhahn)
86 Show the input object of the igrid browser as the window tile.
93 Show the input object of the igrid browser as the window tile.
87 Show the object the cursor is on in the statusbar.
94 Show the object the cursor is on in the statusbar.
88
95
89 2007-03-15 Ville Vainio <vivainio@gmail.com>
96 2007-03-15 Ville Vainio <vivainio@gmail.com>
90
97
91 * Extensions/ipy_stock_completers.py: Fixed exception
98 * Extensions/ipy_stock_completers.py: Fixed exception
92 on mismatching quotes in %run completer. Patch by
99 on mismatching quotes in %run completer. Patch by
93 JοΏ½rgen Stenarson. Closes #127.
100 JοΏ½rgen Stenarson. Closes #127.
94
101
95 2007-03-14 Ville Vainio <vivainio@gmail.com>
102 2007-03-14 Ville Vainio <vivainio@gmail.com>
96
103
97 * Extensions/ext_rehashdir.py: Do not do auto_alias
104 * Extensions/ext_rehashdir.py: Do not do auto_alias
98 in %rehashdir, it clobbers %store'd aliases.
105 in %rehashdir, it clobbers %store'd aliases.
99
106
100 * UserConfig/ipy_profile_sh.py: envpersist.py extension
107 * UserConfig/ipy_profile_sh.py: envpersist.py extension
101 (beefed up %env) imported for sh profile.
108 (beefed up %env) imported for sh profile.
102
109
103 2007-03-10 Walter Doerwald <walter@livinglogic.de>
110 2007-03-10 Walter Doerwald <walter@livinglogic.de>
104
111
105 * IPython/Extensions/ipipe.py: Prefer ibrowse over igrid
112 * IPython/Extensions/ipipe.py: Prefer ibrowse over igrid
106 as the default browser.
113 as the default browser.
107 * IPython/Extensions/igrid.py: Make a few igrid attributes private.
114 * IPython/Extensions/igrid.py: Make a few igrid attributes private.
108 As igrid displays all attributes it ever encounters, fetch() (which has
115 As igrid displays all attributes it ever encounters, fetch() (which has
109 been renamed to _fetch()) doesn't have to recalculate the display attributes
116 been renamed to _fetch()) doesn't have to recalculate the display attributes
110 every time a new item is fetched. This should speed up scrolling.
117 every time a new item is fetched. This should speed up scrolling.
111
118
112 2007-03-10 Fernando Perez <Fernando.Perez@colorado.edu>
119 2007-03-10 Fernando Perez <Fernando.Perez@colorado.edu>
113
120
114 * IPython/iplib.py (InteractiveShell.__init__): fix for Alex
121 * IPython/iplib.py (InteractiveShell.__init__): fix for Alex
115 Schmolck's recently reported tab-completion bug (my previous one
122 Schmolck's recently reported tab-completion bug (my previous one
116 had a problem). Patch by Dan Milstein <danmil-AT-comcast.net>.
123 had a problem). Patch by Dan Milstein <danmil-AT-comcast.net>.
117
124
118 2007-03-09 Walter Doerwald <walter@livinglogic.de>
125 2007-03-09 Walter Doerwald <walter@livinglogic.de>
119
126
120 * IPython/Extensions/igrid.py: Patch by Nik Tautenhahn:
127 * IPython/Extensions/igrid.py: Patch by Nik Tautenhahn:
121 Close help window if exiting igrid.
128 Close help window if exiting igrid.
122
129
123 2007-03-02 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
130 2007-03-02 JοΏ½rgen Stenarson <jorgen.stenarson@bostream.nu>
124
131
125 * IPython/Extensions/ipy_defaults.py: Check if readline is available
132 * IPython/Extensions/ipy_defaults.py: Check if readline is available
126 before calling functions from readline.
133 before calling functions from readline.
127
134
128 2007-03-02 Walter Doerwald <walter@livinglogic.de>
135 2007-03-02 Walter Doerwald <walter@livinglogic.de>
129
136
130 * IPython/Extensions/igrid.py: Add Nik Tautenhahns igrid extension.
137 * IPython/Extensions/igrid.py: Add Nik Tautenhahns igrid extension.
131 igrid is a wxPython-based display object for ipipe. If your system has
138 igrid is a wxPython-based display object for ipipe. If your system has
132 wx installed igrid will be the default display. Without wx ipipe falls
139 wx installed igrid will be the default display. Without wx ipipe falls
133 back to ibrowse (which needs curses). If no curses is installed ipipe
140 back to ibrowse (which needs curses). If no curses is installed ipipe
134 falls back to idump.
141 falls back to idump.
135
142
136 2007-03-01 Fernando Perez <Fernando.Perez@colorado.edu>
143 2007-03-01 Fernando Perez <Fernando.Perez@colorado.edu>
137
144
138 * IPython/iplib.py (split_user_inputBROKEN): temporarily disable
145 * IPython/iplib.py (split_user_inputBROKEN): temporarily disable
139 my changes from yesterday, they introduced bugs. Will reactivate
146 my changes from yesterday, they introduced bugs. Will reactivate
140 once I get a correct solution, which will be much easier thanks to
147 once I get a correct solution, which will be much easier thanks to
141 Dan Milstein's new prefilter test suite.
148 Dan Milstein's new prefilter test suite.
142
149
143 2007-02-28 Fernando Perez <Fernando.Perez@colorado.edu>
150 2007-02-28 Fernando Perez <Fernando.Perez@colorado.edu>
144
151
145 * IPython/iplib.py (split_user_input): fix input splitting so we
152 * IPython/iplib.py (split_user_input): fix input splitting so we
146 don't attempt attribute accesses on things that can't possibly be
153 don't attempt attribute accesses on things that can't possibly be
147 valid Python attributes. After a bug report by Alex Schmolck.
154 valid Python attributes. After a bug report by Alex Schmolck.
148 (InteractiveShell.__init__): brown-paper bag fix; regexp broke
155 (InteractiveShell.__init__): brown-paper bag fix; regexp broke
149 %magic with explicit % prefix.
156 %magic with explicit % prefix.
150
157
151 2007-02-27 Fernando Perez <Fernando.Perez@colorado.edu>
158 2007-02-27 Fernando Perez <Fernando.Perez@colorado.edu>
152
159
153 * IPython/Shell.py (IPShellGTK.mainloop): update threads calls to
160 * IPython/Shell.py (IPShellGTK.mainloop): update threads calls to
154 avoid a DeprecationWarning from GTK.
161 avoid a DeprecationWarning from GTK.
155
162
156 2007-02-22 Fernando Perez <Fernando.Perez@colorado.edu>
163 2007-02-22 Fernando Perez <Fernando.Perez@colorado.edu>
157
164
158 * IPython/genutils.py (clock): I modified clock() to return total
165 * IPython/genutils.py (clock): I modified clock() to return total
159 time, user+system. This is a more commonly needed metric. I also
166 time, user+system. This is a more commonly needed metric. I also
160 introduced the new clocku/clocks to get only user/system time if
167 introduced the new clocku/clocks to get only user/system time if
161 one wants those instead.
168 one wants those instead.
162
169
163 ***WARNING: API CHANGE*** clock() used to return only user time,
170 ***WARNING: API CHANGE*** clock() used to return only user time,
164 so if you want exactly the same results as before, use clocku
171 so if you want exactly the same results as before, use clocku
165 instead.
172 instead.
166
173
167 2007-02-22 Ville Vainio <vivainio@gmail.com>
174 2007-02-22 Ville Vainio <vivainio@gmail.com>
168
175
169 * IPython/Extensions/ipy_p4.py: Extension for improved
176 * IPython/Extensions/ipy_p4.py: Extension for improved
170 p4 (perforce version control system) experience.
177 p4 (perforce version control system) experience.
171 Adds %p4 magic with p4 command completion and
178 Adds %p4 magic with p4 command completion and
172 automatic -G argument (marshall output as python dict)
179 automatic -G argument (marshall output as python dict)
173
180
174 2007-02-19 Fernando Perez <Fernando.Perez@colorado.edu>
181 2007-02-19 Fernando Perez <Fernando.Perez@colorado.edu>
175
182
176 * IPython/demo.py (Demo.re_stop): make dashes optional in demo
183 * IPython/demo.py (Demo.re_stop): make dashes optional in demo
177 stop marks.
184 stop marks.
178 (ClearingMixin): a simple mixin to easily make a Demo class clear
185 (ClearingMixin): a simple mixin to easily make a Demo class clear
179 the screen in between blocks and have empty marquees. The
186 the screen in between blocks and have empty marquees. The
180 ClearDemo and ClearIPDemo classes that use it are included.
187 ClearDemo and ClearIPDemo classes that use it are included.
181
188
182 2007-02-18 Fernando Perez <Fernando.Perez@colorado.edu>
189 2007-02-18 Fernando Perez <Fernando.Perez@colorado.edu>
183
190
184 * IPython/irunner.py (pexpect_monkeypatch): patch pexpect to
191 * IPython/irunner.py (pexpect_monkeypatch): patch pexpect to
185 protect against exceptions at Python shutdown time. Patch
192 protect against exceptions at Python shutdown time. Patch
186 sumbmitted to upstream.
193 sumbmitted to upstream.
187
194
188 2007-02-14 Walter Doerwald <walter@livinglogic.de>
195 2007-02-14 Walter Doerwald <walter@livinglogic.de>
189
196
190 * IPython/Extensions/ibrowse.py: If entering the first object level
197 * IPython/Extensions/ibrowse.py: If entering the first object level
191 (i.e. the object for which the browser has been started) fails,
198 (i.e. the object for which the browser has been started) fails,
192 now the error is raised directly (aborting the browser) instead of
199 now the error is raised directly (aborting the browser) instead of
193 running into an empty levels list later.
200 running into an empty levels list later.
194
201
195 2007-02-03 Walter Doerwald <walter@livinglogic.de>
202 2007-02-03 Walter Doerwald <walter@livinglogic.de>
196
203
197 * IPython/Extensions/ipipe.py: Add an xrepr implementation
204 * IPython/Extensions/ipipe.py: Add an xrepr implementation
198 for the noitem object.
205 for the noitem object.
199
206
200 2007-01-31 Fernando Perez <Fernando.Perez@colorado.edu>
207 2007-01-31 Fernando Perez <Fernando.Perez@colorado.edu>
201
208
202 * IPython/completer.py (Completer.attr_matches): Fix small
209 * IPython/completer.py (Completer.attr_matches): Fix small
203 tab-completion bug with Enthought Traits objects with units.
210 tab-completion bug with Enthought Traits objects with units.
204 Thanks to a bug report by Tom Denniston
211 Thanks to a bug report by Tom Denniston
205 <tom.denniston-AT-alum.dartmouth.org>.
212 <tom.denniston-AT-alum.dartmouth.org>.
206
213
207 2007-01-27 Fernando Perez <Fernando.Perez@colorado.edu>
214 2007-01-27 Fernando Perez <Fernando.Perez@colorado.edu>
208
215
209 * IPython/Extensions/ipy_stock_completers.py (runlistpy): fix a
216 * IPython/Extensions/ipy_stock_completers.py (runlistpy): fix a
210 bug where only .ipy or .py would be completed. Once the first
217 bug where only .ipy or .py would be completed. Once the first
211 argument to %run has been given, all completions are valid because
218 argument to %run has been given, all completions are valid because
212 they are the arguments to the script, which may well be non-python
219 they are the arguments to the script, which may well be non-python
213 filenames.
220 filenames.
214
221
215 * IPython/irunner.py (InteractiveRunner.run_source): major updates
222 * IPython/irunner.py (InteractiveRunner.run_source): major updates
216 to irunner to allow it to correctly support real doctesting of
223 to irunner to allow it to correctly support real doctesting of
217 out-of-process ipython code.
224 out-of-process ipython code.
218
225
219 * IPython/Magic.py (magic_cd): Make the setting of the terminal
226 * IPython/Magic.py (magic_cd): Make the setting of the terminal
220 title an option (-noterm_title) because it completely breaks
227 title an option (-noterm_title) because it completely breaks
221 doctesting.
228 doctesting.
222
229
223 * IPython/demo.py: fix IPythonDemo class that was not actually working.
230 * IPython/demo.py: fix IPythonDemo class that was not actually working.
224
231
225 2007-01-24 Fernando Perez <Fernando.Perez@colorado.edu>
232 2007-01-24 Fernando Perez <Fernando.Perez@colorado.edu>
226
233
227 * IPython/irunner.py (main): fix small bug where extensions were
234 * IPython/irunner.py (main): fix small bug where extensions were
228 not being correctly recognized.
235 not being correctly recognized.
229
236
230 2007-01-23 Walter Doerwald <walter@livinglogic.de>
237 2007-01-23 Walter Doerwald <walter@livinglogic.de>
231
238
232 * IPython/Extensions/ipipe.py (xiter): Make sure that iterating
239 * IPython/Extensions/ipipe.py (xiter): Make sure that iterating
233 a string containing a single line yields the string itself as the
240 a string containing a single line yields the string itself as the
234 only item.
241 only item.
235
242
236 * IPython/Extensions/ibrowse.py (ibrowse): Avoid entering an
243 * IPython/Extensions/ibrowse.py (ibrowse): Avoid entering an
237 object if it's the same as the one on the last level (This avoids
244 object if it's the same as the one on the last level (This avoids
238 infinite recursion for one line strings).
245 infinite recursion for one line strings).
239
246
240 2007-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
247 2007-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
241
248
242 * IPython/ultraTB.py (AutoFormattedTB.__call__): properly flush
249 * IPython/ultraTB.py (AutoFormattedTB.__call__): properly flush
243 all output streams before printing tracebacks. This ensures that
250 all output streams before printing tracebacks. This ensures that
244 user output doesn't end up interleaved with traceback output.
251 user output doesn't end up interleaved with traceback output.
245
252
246 2007-01-10 Ville Vainio <vivainio@gmail.com>
253 2007-01-10 Ville Vainio <vivainio@gmail.com>
247
254
248 * Extensions/envpersist.py: Turbocharged %env that remembers
255 * Extensions/envpersist.py: Turbocharged %env that remembers
249 env vars across sessions; e.g. "%env PATH+=;/opt/scripts" or
256 env vars across sessions; e.g. "%env PATH+=;/opt/scripts" or
250 "%env VISUAL=jed".
257 "%env VISUAL=jed".
251
258
252 2007-01-05 Fernando Perez <Fernando.Perez@colorado.edu>
259 2007-01-05 Fernando Perez <Fernando.Perez@colorado.edu>
253
260
254 * IPython/iplib.py (showtraceback): ensure that we correctly call
261 * IPython/iplib.py (showtraceback): ensure that we correctly call
255 custom handlers in all cases (some with pdb were slipping through,
262 custom handlers in all cases (some with pdb were slipping through,
256 but I'm not exactly sure why).
263 but I'm not exactly sure why).
257
264
258 * IPython/Debugger.py (Tracer.__init__): added new class to
265 * IPython/Debugger.py (Tracer.__init__): added new class to
259 support set_trace-like usage of IPython's enhanced debugger.
266 support set_trace-like usage of IPython's enhanced debugger.
260
267
261 2006-12-24 Ville Vainio <vivainio@gmail.com>
268 2006-12-24 Ville Vainio <vivainio@gmail.com>
262
269
263 * ipmaker.py: more informative message when ipy_user_conf
270 * ipmaker.py: more informative message when ipy_user_conf
264 import fails (suggest running %upgrade).
271 import fails (suggest running %upgrade).
265
272
266 * tools/run_ipy_in_profiler.py: Utility to see where
273 * tools/run_ipy_in_profiler.py: Utility to see where
267 the time during IPython startup is spent.
274 the time during IPython startup is spent.
268
275
269 2006-12-20 Ville Vainio <vivainio@gmail.com>
276 2006-12-20 Ville Vainio <vivainio@gmail.com>
270
277
271 * 0.7.3 is out - merge all from 0.7.3 branch to trunk
278 * 0.7.3 is out - merge all from 0.7.3 branch to trunk
272
279
273 * ipapi.py: Add new ipapi method, expand_alias.
280 * ipapi.py: Add new ipapi method, expand_alias.
274
281
275 * Release.py: Bump up version to 0.7.4.svn
282 * Release.py: Bump up version to 0.7.4.svn
276
283
277 2006-12-17 Ville Vainio <vivainio@gmail.com>
284 2006-12-17 Ville Vainio <vivainio@gmail.com>
278
285
279 * Extensions/jobctrl.py: Fixed &cmd arg arg...
286 * Extensions/jobctrl.py: Fixed &cmd arg arg...
280 to work properly on posix too
287 to work properly on posix too
281
288
282 * Release.py: Update revnum (version is still just 0.7.3).
289 * Release.py: Update revnum (version is still just 0.7.3).
283
290
284 2006-12-15 Ville Vainio <vivainio@gmail.com>
291 2006-12-15 Ville Vainio <vivainio@gmail.com>
285
292
286 * scripts/ipython_win_post_install: create ipython.py in
293 * scripts/ipython_win_post_install: create ipython.py in
287 prefix + "/scripts".
294 prefix + "/scripts".
288
295
289 * Release.py: Update version to 0.7.3.
296 * Release.py: Update version to 0.7.3.
290
297
291 2006-12-14 Ville Vainio <vivainio@gmail.com>
298 2006-12-14 Ville Vainio <vivainio@gmail.com>
292
299
293 * scripts/ipython_win_post_install: Overwrite old shortcuts
300 * scripts/ipython_win_post_install: Overwrite old shortcuts
294 if they already exist
301 if they already exist
295
302
296 * Release.py: release 0.7.3rc2
303 * Release.py: release 0.7.3rc2
297
304
298 2006-12-13 Ville Vainio <vivainio@gmail.com>
305 2006-12-13 Ville Vainio <vivainio@gmail.com>
299
306
300 * Branch and update Release.py for 0.7.3rc1
307 * Branch and update Release.py for 0.7.3rc1
301
308
302 2006-12-13 Fernando Perez <Fernando.Perez@colorado.edu>
309 2006-12-13 Fernando Perez <Fernando.Perez@colorado.edu>
303
310
304 * IPython/Shell.py (IPShellWX): update for current WX naming
311 * IPython/Shell.py (IPShellWX): update for current WX naming
305 conventions, to avoid a deprecation warning with current WX
312 conventions, to avoid a deprecation warning with current WX
306 versions. Thanks to a report by Danny Shevitz.
313 versions. Thanks to a report by Danny Shevitz.
307
314
308 2006-12-12 Ville Vainio <vivainio@gmail.com>
315 2006-12-12 Ville Vainio <vivainio@gmail.com>
309
316
310 * ipmaker.py: apply david cournapeau's patch to make
317 * ipmaker.py: apply david cournapeau's patch to make
311 import_some work properly even when ipythonrc does
318 import_some work properly even when ipythonrc does
312 import_some on empty list (it was an old bug!).
319 import_some on empty list (it was an old bug!).
313
320
314 * UserConfig/ipy_user_conf.py, UserConfig/ipythonrc:
321 * UserConfig/ipy_user_conf.py, UserConfig/ipythonrc:
315 Add deprecation note to ipythonrc and a url to wiki
322 Add deprecation note to ipythonrc and a url to wiki
316 in ipy_user_conf.py
323 in ipy_user_conf.py
317
324
318
325
319 * Magic.py (%run): %run myscript.ipy now runs myscript.ipy
326 * Magic.py (%run): %run myscript.ipy now runs myscript.ipy
320 as if it was typed on IPython command prompt, i.e.
327 as if it was typed on IPython command prompt, i.e.
321 as IPython script.
328 as IPython script.
322
329
323 * example-magic.py, magic_grepl.py: remove outdated examples
330 * example-magic.py, magic_grepl.py: remove outdated examples
324
331
325 2006-12-11 Fernando Perez <Fernando.Perez@colorado.edu>
332 2006-12-11 Fernando Perez <Fernando.Perez@colorado.edu>
326
333
327 * IPython/iplib.py (debugger): prevent a nasty traceback if %debug
334 * IPython/iplib.py (debugger): prevent a nasty traceback if %debug
328 is called before any exception has occurred.
335 is called before any exception has occurred.
329
336
330 2006-12-08 Ville Vainio <vivainio@gmail.com>
337 2006-12-08 Ville Vainio <vivainio@gmail.com>
331
338
332 * Extensions/ipy_stock_completers.py: fix cd completer
339 * Extensions/ipy_stock_completers.py: fix cd completer
333 to translate /'s to \'s again.
340 to translate /'s to \'s again.
334
341
335 * completer.py: prevent traceback on file completions w/
342 * completer.py: prevent traceback on file completions w/
336 backslash.
343 backslash.
337
344
338 * Release.py: Update release number to 0.7.3b3 for release
345 * Release.py: Update release number to 0.7.3b3 for release
339
346
340 2006-12-07 Ville Vainio <vivainio@gmail.com>
347 2006-12-07 Ville Vainio <vivainio@gmail.com>
341
348
342 * Extensions/ipy_signals.py: Ignore ctrl+C in IPython process
349 * Extensions/ipy_signals.py: Ignore ctrl+C in IPython process
343 while executing external code. Provides more shell-like behaviour
350 while executing external code. Provides more shell-like behaviour
344 and overall better response to ctrl + C / ctrl + break.
351 and overall better response to ctrl + C / ctrl + break.
345
352
346 * tools/make_tarball.py: new script to create tarball straight from svn
353 * tools/make_tarball.py: new script to create tarball straight from svn
347 (setup.py sdist doesn't work on win32).
354 (setup.py sdist doesn't work on win32).
348
355
349 * Extensions/ipy_stock_completers.py: fix cd completer to give up
356 * Extensions/ipy_stock_completers.py: fix cd completer to give up
350 on dirnames with spaces and use the default completer instead.
357 on dirnames with spaces and use the default completer instead.
351
358
352 * Revision.py: Change version to 0.7.3b2 for release.
359 * Revision.py: Change version to 0.7.3b2 for release.
353
360
354 2006-12-05 Ville Vainio <vivainio@gmail.com>
361 2006-12-05 Ville Vainio <vivainio@gmail.com>
355
362
356 * Magic.py, iplib.py, completer.py: Apply R. Bernstein's
363 * Magic.py, iplib.py, completer.py: Apply R. Bernstein's
357 pydb patch 4 (rm debug printing, py 2.5 checking)
364 pydb patch 4 (rm debug printing, py 2.5 checking)
358
365
359 2006-11-30 Walter Doerwald <walter@livinglogic.de>
366 2006-11-30 Walter Doerwald <walter@livinglogic.de>
360 * IPython/Extensions/ibrowse.py: Add two new commands to ibrowse:
367 * IPython/Extensions/ibrowse.py: Add two new commands to ibrowse:
361 "refresh" (mapped to "r") refreshes the screen by restarting the iterator.
368 "refresh" (mapped to "r") refreshes the screen by restarting the iterator.
362 "refreshfind" (mapped to "R") does the same but tries to go back to the same
369 "refreshfind" (mapped to "R") does the same but tries to go back to the same
363 object the cursor was on before the refresh. The command "markrange" is
370 object the cursor was on before the refresh. The command "markrange" is
364 mapped to "%" now.
371 mapped to "%" now.
365 * IPython/Extensions/ibrowse.py: Make igrpentry and ipwdentry comparable.
372 * IPython/Extensions/ibrowse.py: Make igrpentry and ipwdentry comparable.
366
373
367 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu>
374 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu>
368
375
369 * IPython/Magic.py (magic_debug): new %debug magic to activate the
376 * IPython/Magic.py (magic_debug): new %debug magic to activate the
370 interactive debugger on the last traceback, without having to call
377 interactive debugger on the last traceback, without having to call
371 %pdb and rerun your code. Made minor changes in various modules,
378 %pdb and rerun your code. Made minor changes in various modules,
372 should automatically recognize pydb if available.
379 should automatically recognize pydb if available.
373
380
374 2006-11-28 Ville Vainio <vivainio@gmail.com>
381 2006-11-28 Ville Vainio <vivainio@gmail.com>
375
382
376 * completer.py: If the text start with !, show file completions
383 * completer.py: If the text start with !, show file completions
377 properly. This helps when trying to complete command name
384 properly. This helps when trying to complete command name
378 for shell escapes.
385 for shell escapes.
379
386
380 2006-11-27 Ville Vainio <vivainio@gmail.com>
387 2006-11-27 Ville Vainio <vivainio@gmail.com>
381
388
382 * ipy_stock_completers.py: bzr completer submitted by Stefan van
389 * ipy_stock_completers.py: bzr completer submitted by Stefan van
383 der Walt. Clean up svn and hg completers by using a common
390 der Walt. Clean up svn and hg completers by using a common
384 vcs_completer.
391 vcs_completer.
385
392
386 2006-11-26 Ville Vainio <vivainio@gmail.com>
393 2006-11-26 Ville Vainio <vivainio@gmail.com>
387
394
388 * Remove ipconfig and %config; you should use _ip.options structure
395 * Remove ipconfig and %config; you should use _ip.options structure
389 directly instead!
396 directly instead!
390
397
391 * genutils.py: add wrap_deprecated function for deprecating callables
398 * genutils.py: add wrap_deprecated function for deprecating callables
392
399
393 * iplib.py: deprecate ipmagic, ipsystem, ipalias. Use _ip.magic and
400 * iplib.py: deprecate ipmagic, ipsystem, ipalias. Use _ip.magic and
394 _ip.system instead. ipalias is redundant.
401 _ip.system instead. ipalias is redundant.
395
402
396 * Magic.py: %rehashdir no longer aliases 'cmdname' to 'cmdname.exe' on
403 * Magic.py: %rehashdir no longer aliases 'cmdname' to 'cmdname.exe' on
397 win32, but just 'cmdname'. Other extensions (non-'exe') are still made
404 win32, but just 'cmdname'. Other extensions (non-'exe') are still made
398 explicit.
405 explicit.
399
406
400 * ipy_stock_completers.py: 'hg' (mercurial VCS) now has a custom
407 * ipy_stock_completers.py: 'hg' (mercurial VCS) now has a custom
401 completer. Try it by entering 'hg ' and pressing tab.
408 completer. Try it by entering 'hg ' and pressing tab.
402
409
403 * macro.py: Give Macro a useful __repr__ method
410 * macro.py: Give Macro a useful __repr__ method
404
411
405 * Magic.py: %whos abbreviates the typename of Macro for brevity.
412 * Magic.py: %whos abbreviates the typename of Macro for brevity.
406
413
407 2006-11-24 Walter Doerwald <walter@livinglogic.de>
414 2006-11-24 Walter Doerwald <walter@livinglogic.de>
408 * IPython/Extensions/astyle.py: Do a relative import of ipipe, so that
415 * IPython/Extensions/astyle.py: Do a relative import of ipipe, so that
409 we don't get a duplicate ipipe module, where registration of the xrepr
416 we don't get a duplicate ipipe module, where registration of the xrepr
410 implementation for Text is useless.
417 implementation for Text is useless.
411
418
412 * IPython/Extensions/ipipe.py: Fix __xrepr__() implementation for ils.
419 * IPython/Extensions/ipipe.py: Fix __xrepr__() implementation for ils.
413
420
414 * IPython/Extensions/ibrowse.py: Fix keymapping for the enter command.
421 * IPython/Extensions/ibrowse.py: Fix keymapping for the enter command.
415
422
416 2006-11-24 Ville Vainio <vivainio@gmail.com>
423 2006-11-24 Ville Vainio <vivainio@gmail.com>
417
424
418 * Magic.py, manual_base.lyx: Kirill Smelkov patch:
425 * Magic.py, manual_base.lyx: Kirill Smelkov patch:
419 try to use "cProfile" instead of the slower pure python
426 try to use "cProfile" instead of the slower pure python
420 "profile"
427 "profile"
421
428
422 2006-11-23 Ville Vainio <vivainio@gmail.com>
429 2006-11-23 Ville Vainio <vivainio@gmail.com>
423
430
424 * manual_base.lyx: Kirill Smelkov patch: Fix wrong
431 * manual_base.lyx: Kirill Smelkov patch: Fix wrong
425 Qt+IPython+Designer link in documentation.
432 Qt+IPython+Designer link in documentation.
426
433
427 * Extensions/ipy_pydb.py: R. Bernstein's patch for passing
434 * Extensions/ipy_pydb.py: R. Bernstein's patch for passing
428 correct Pdb object to %pydb.
435 correct Pdb object to %pydb.
429
436
430
437
431 2006-11-22 Walter Doerwald <walter@livinglogic.de>
438 2006-11-22 Walter Doerwald <walter@livinglogic.de>
432 * IPython/Extensions/astyle.py: Text needs it's own implemenation of the
439 * IPython/Extensions/astyle.py: Text needs it's own implemenation of the
433 generic xrepr(), otherwise the list implementation would kick in.
440 generic xrepr(), otherwise the list implementation would kick in.
434
441
435 2006-11-21 Ville Vainio <vivainio@gmail.com>
442 2006-11-21 Ville Vainio <vivainio@gmail.com>
436
443
437 * upgrade_dir.py: Now actually overwrites a nonmodified user file
444 * upgrade_dir.py: Now actually overwrites a nonmodified user file
438 with one from UserConfig.
445 with one from UserConfig.
439
446
440 * ipy_profile_sh.py: Add dummy "depth" to var_expand lambda,
447 * ipy_profile_sh.py: Add dummy "depth" to var_expand lambda,
441 it was missing which broke the sh profile.
448 it was missing which broke the sh profile.
442
449
443 * completer.py: file completer now uses explicit '/' instead
450 * completer.py: file completer now uses explicit '/' instead
444 of os.path.join, expansion of 'foo' was broken on win32
451 of os.path.join, expansion of 'foo' was broken on win32
445 if there was one directory with name 'foobar'.
452 if there was one directory with name 'foobar'.
446
453
447 * A bunch of patches from Kirill Smelkov:
454 * A bunch of patches from Kirill Smelkov:
448
455
449 * [patch 9/9] doc: point bug-tracker URL to IPythons trac-tickets.
456 * [patch 9/9] doc: point bug-tracker URL to IPythons trac-tickets.
450
457
451 * [patch 7/9] Implement %page -r (page in raw mode) -
458 * [patch 7/9] Implement %page -r (page in raw mode) -
452
459
453 * [patch 5/9] ScientificPython webpage has moved
460 * [patch 5/9] ScientificPython webpage has moved
454
461
455 * [patch 4/9] The manual mentions %ds, should be %dhist
462 * [patch 4/9] The manual mentions %ds, should be %dhist
456
463
457 * [patch 3/9] Kill old bits from %prun doc.
464 * [patch 3/9] Kill old bits from %prun doc.
458
465
459 * [patch 1/9] Fix typos here and there.
466 * [patch 1/9] Fix typos here and there.
460
467
461 2006-11-08 Ville Vainio <vivainio@gmail.com>
468 2006-11-08 Ville Vainio <vivainio@gmail.com>
462
469
463 * completer.py (attr_matches): catch all exceptions raised
470 * completer.py (attr_matches): catch all exceptions raised
464 by eval of expr with dots.
471 by eval of expr with dots.
465
472
466 2006-11-07 Fernando Perez <Fernando.Perez@colorado.edu>
473 2006-11-07 Fernando Perez <Fernando.Perez@colorado.edu>
467
474
468 * IPython/iplib.py (runsource): Prepend an 'if 1:' to the user
475 * IPython/iplib.py (runsource): Prepend an 'if 1:' to the user
469 input if it starts with whitespace. This allows you to paste
476 input if it starts with whitespace. This allows you to paste
470 indented input from any editor without manually having to type in
477 indented input from any editor without manually having to type in
471 the 'if 1:', which is convenient when working interactively.
478 the 'if 1:', which is convenient when working interactively.
472 Slightly modifed version of a patch by Bo Peng
479 Slightly modifed version of a patch by Bo Peng
473 <bpeng-AT-rice.edu>.
480 <bpeng-AT-rice.edu>.
474
481
475 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
482 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
476
483
477 * IPython/irunner.py (main): modified irunner so it automatically
484 * IPython/irunner.py (main): modified irunner so it automatically
478 recognizes the right runner to use based on the extension (.py for
485 recognizes the right runner to use based on the extension (.py for
479 python, .ipy for ipython and .sage for sage).
486 python, .ipy for ipython and .sage for sage).
480
487
481 * IPython/iplib.py (InteractiveShell.ipconfig): new builtin, also
488 * IPython/iplib.py (InteractiveShell.ipconfig): new builtin, also
482 visible in ipapi as ip.config(), to programatically control the
489 visible in ipapi as ip.config(), to programatically control the
483 internal rc object. There's an accompanying %config magic for
490 internal rc object. There's an accompanying %config magic for
484 interactive use, which has been enhanced to match the
491 interactive use, which has been enhanced to match the
485 funtionality in ipconfig.
492 funtionality in ipconfig.
486
493
487 * IPython/Magic.py (magic_system_verbose): Change %system_verbose
494 * IPython/Magic.py (magic_system_verbose): Change %system_verbose
488 so it's not just a toggle, it now takes an argument. Add support
495 so it's not just a toggle, it now takes an argument. Add support
489 for a customizable header when making system calls, as the new
496 for a customizable header when making system calls, as the new
490 system_header variable in the ipythonrc file.
497 system_header variable in the ipythonrc file.
491
498
492 2006-11-03 Walter Doerwald <walter@livinglogic.de>
499 2006-11-03 Walter Doerwald <walter@livinglogic.de>
493
500
494 * IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now
501 * IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now
495 generic functions (using Philip J. Eby's simplegeneric package).
502 generic functions (using Philip J. Eby's simplegeneric package).
496 This makes it possible to customize the display of third-party classes
503 This makes it possible to customize the display of third-party classes
497 without having to monkeypatch them. xiter() no longer supports a mode
504 without having to monkeypatch them. xiter() no longer supports a mode
498 argument and the XMode class has been removed. The same functionality can
505 argument and the XMode class has been removed. The same functionality can
499 be implemented via IterAttributeDescriptor and IterMethodDescriptor.
506 be implemented via IterAttributeDescriptor and IterMethodDescriptor.
500 One consequence of the switch to generic functions is that xrepr() and
507 One consequence of the switch to generic functions is that xrepr() and
501 xattrs() implementation must define the default value for the mode
508 xattrs() implementation must define the default value for the mode
502 argument themselves and xattrs() implementations must return real
509 argument themselves and xattrs() implementations must return real
503 descriptors.
510 descriptors.
504
511
505 * IPython/external: This new subpackage will contain all third-party
512 * IPython/external: This new subpackage will contain all third-party
506 packages that are bundled with IPython. (The first one is simplegeneric).
513 packages that are bundled with IPython. (The first one is simplegeneric).
507
514
508 * IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent
515 * IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent
509 directory which as been dropped in r1703.
516 directory which as been dropped in r1703.
510
517
511 * IPython/Extensions/ipipe.py (iless): Fixed.
518 * IPython/Extensions/ipipe.py (iless): Fixed.
512
519
513 * IPython/Extensions/ibrowse: Fixed sorting under Python 2.3.
520 * IPython/Extensions/ibrowse: Fixed sorting under Python 2.3.
514
521
515 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
522 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
516
523
517 * IPython/iplib.py (InteractiveShell.var_expand): fix stack
524 * IPython/iplib.py (InteractiveShell.var_expand): fix stack
518 handling in variable expansion so that shells and magics recognize
525 handling in variable expansion so that shells and magics recognize
519 function local scopes correctly. Bug reported by Brian.
526 function local scopes correctly. Bug reported by Brian.
520
527
521 * scripts/ipython: remove the very first entry in sys.path which
528 * scripts/ipython: remove the very first entry in sys.path which
522 Python auto-inserts for scripts, so that sys.path under IPython is
529 Python auto-inserts for scripts, so that sys.path under IPython is
523 as similar as possible to that under plain Python.
530 as similar as possible to that under plain Python.
524
531
525 * IPython/completer.py (IPCompleter.file_matches): Fix
532 * IPython/completer.py (IPCompleter.file_matches): Fix
526 tab-completion so that quotes are not closed unless the completion
533 tab-completion so that quotes are not closed unless the completion
527 is unambiguous. After a request by Stefan. Minor cleanups in
534 is unambiguous. After a request by Stefan. Minor cleanups in
528 ipy_stock_completers.
535 ipy_stock_completers.
529
536
530 2006-11-02 Ville Vainio <vivainio@gmail.com>
537 2006-11-02 Ville Vainio <vivainio@gmail.com>
531
538
532 * ipy_stock_completers.py: Add %run and %cd completers.
539 * ipy_stock_completers.py: Add %run and %cd completers.
533
540
534 * completer.py: Try running custom completer for both
541 * completer.py: Try running custom completer for both
535 "foo" and "%foo" if the command is just "foo". Ignore case
542 "foo" and "%foo" if the command is just "foo". Ignore case
536 when filtering possible completions.
543 when filtering possible completions.
537
544
538 * UserConfig/ipy_user_conf.py: install stock completers as default
545 * UserConfig/ipy_user_conf.py: install stock completers as default
539
546
540 * iplib.py (history_saving_wrapper), debugger(), ipy_pydb.py:
547 * iplib.py (history_saving_wrapper), debugger(), ipy_pydb.py:
541 simplified readline history save / restore through a wrapper
548 simplified readline history save / restore through a wrapper
542 function
549 function
543
550
544
551
545 2006-10-31 Ville Vainio <vivainio@gmail.com>
552 2006-10-31 Ville Vainio <vivainio@gmail.com>
546
553
547 * strdispatch.py, completer.py, ipy_stock_completers.py:
554 * strdispatch.py, completer.py, ipy_stock_completers.py:
548 Allow str_key ("command") in completer hooks. Implement
555 Allow str_key ("command") in completer hooks. Implement
549 trivial completer for 'import' (stdlib modules only). Rename
556 trivial completer for 'import' (stdlib modules only). Rename
550 ipy_linux_package_managers.py to ipy_stock_completers.py.
557 ipy_linux_package_managers.py to ipy_stock_completers.py.
551 SVN completer.
558 SVN completer.
552
559
553 * Extensions/ledit.py: %magic line editor for easily and
560 * Extensions/ledit.py: %magic line editor for easily and
554 incrementally manipulating lists of strings. The magic command
561 incrementally manipulating lists of strings. The magic command
555 name is %led.
562 name is %led.
556
563
557 2006-10-30 Ville Vainio <vivainio@gmail.com>
564 2006-10-30 Ville Vainio <vivainio@gmail.com>
558
565
559 * Debugger.py, iplib.py (debugger()): Add last set of Rocky
566 * Debugger.py, iplib.py (debugger()): Add last set of Rocky
560 Bernsteins's patches for pydb integration.
567 Bernsteins's patches for pydb integration.
561 http://bashdb.sourceforge.net/pydb/
568 http://bashdb.sourceforge.net/pydb/
562
569
563 * strdispatch.py, iplib.py, completer.py, IPython/__init__.py,
570 * strdispatch.py, iplib.py, completer.py, IPython/__init__.py,
564 Extensions/ipy_linux_package_managers.py, hooks.py: Implement
571 Extensions/ipy_linux_package_managers.py, hooks.py: Implement
565 custom completer hook to allow the users to implement their own
572 custom completer hook to allow the users to implement their own
566 completers. See ipy_linux_package_managers.py for example. The
573 completers. See ipy_linux_package_managers.py for example. The
567 hook name is 'complete_command'.
574 hook name is 'complete_command'.
568
575
569 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
576 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
570
577
571 * IPython/UserConfig/ipythonrc-scipy: minor cleanups to remove old
578 * IPython/UserConfig/ipythonrc-scipy: minor cleanups to remove old
572 Numeric leftovers.
579 Numeric leftovers.
573
580
574 * ipython.el (py-execute-region): apply Stefan's patch to fix
581 * ipython.el (py-execute-region): apply Stefan's patch to fix
575 garbled results if the python shell hasn't been previously started.
582 garbled results if the python shell hasn't been previously started.
576
583
577 * IPython/genutils.py (arg_split): moved to genutils, since it's a
584 * IPython/genutils.py (arg_split): moved to genutils, since it's a
578 pretty generic function and useful for other things.
585 pretty generic function and useful for other things.
579
586
580 * IPython/OInspect.py (getsource): Add customizable source
587 * IPython/OInspect.py (getsource): Add customizable source
581 extractor. After a request/patch form W. Stein (SAGE).
588 extractor. After a request/patch form W. Stein (SAGE).
582
589
583 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
590 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
584 window size to a more reasonable value from what pexpect does,
591 window size to a more reasonable value from what pexpect does,
585 since their choice causes wrapping bugs with long input lines.
592 since their choice causes wrapping bugs with long input lines.
586
593
587 2006-10-28 Ville Vainio <vivainio@gmail.com>
594 2006-10-28 Ville Vainio <vivainio@gmail.com>
588
595
589 * Magic.py (%run): Save and restore the readline history from
596 * Magic.py (%run): Save and restore the readline history from
590 file around %run commands to prevent side effects from
597 file around %run commands to prevent side effects from
591 %runned programs that might use readline (e.g. pydb).
598 %runned programs that might use readline (e.g. pydb).
592
599
593 * extensions/ipy_pydb.py: Adds %pydb magic when imported, for
600 * extensions/ipy_pydb.py: Adds %pydb magic when imported, for
594 invoking the pydb enhanced debugger.
601 invoking the pydb enhanced debugger.
595
602
596 2006-10-23 Walter Doerwald <walter@livinglogic.de>
603 2006-10-23 Walter Doerwald <walter@livinglogic.de>
597
604
598 * IPython/Extensions/ipipe.py (ifile): Remove all methods that
605 * IPython/Extensions/ipipe.py (ifile): Remove all methods that
599 call the base class method and propagate the return value to
606 call the base class method and propagate the return value to
600 ifile. This is now done by path itself.
607 ifile. This is now done by path itself.
601
608
602 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
609 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
603
610
604 * IPython/ipapi.py (IPApi.__init__): Added new entry to public
611 * IPython/ipapi.py (IPApi.__init__): Added new entry to public
605 api: set_crash_handler(), to expose the ability to change the
612 api: set_crash_handler(), to expose the ability to change the
606 internal crash handler.
613 internal crash handler.
607
614
608 * IPython/CrashHandler.py (CrashHandler.__init__): abstract out
615 * IPython/CrashHandler.py (CrashHandler.__init__): abstract out
609 the various parameters of the crash handler so that apps using
616 the various parameters of the crash handler so that apps using
610 IPython as their engine can customize crash handling. Ipmlemented
617 IPython as their engine can customize crash handling. Ipmlemented
611 at the request of SAGE.
618 at the request of SAGE.
612
619
613 2006-10-14 Ville Vainio <vivainio@gmail.com>
620 2006-10-14 Ville Vainio <vivainio@gmail.com>
614
621
615 * Magic.py, ipython.el: applied first "safe" part of Rocky
622 * Magic.py, ipython.el: applied first "safe" part of Rocky
616 Bernstein's patch set for pydb integration.
623 Bernstein's patch set for pydb integration.
617
624
618 * Magic.py (%unalias, %alias): %store'd aliases can now be
625 * Magic.py (%unalias, %alias): %store'd aliases can now be
619 removed with '%unalias'. %alias w/o args now shows most
626 removed with '%unalias'. %alias w/o args now shows most
620 interesting (stored / manually defined) aliases last
627 interesting (stored / manually defined) aliases last
621 where they catch the eye w/o scrolling.
628 where they catch the eye w/o scrolling.
622
629
623 * Magic.py (%rehashx), ext_rehashdir.py: files with
630 * Magic.py (%rehashx), ext_rehashdir.py: files with
624 'py' extension are always considered executable, even
631 'py' extension are always considered executable, even
625 when not in PATHEXT environment variable.
632 when not in PATHEXT environment variable.
626
633
627 2006-10-12 Ville Vainio <vivainio@gmail.com>
634 2006-10-12 Ville Vainio <vivainio@gmail.com>
628
635
629 * jobctrl.py: Add new "jobctrl" extension for spawning background
636 * jobctrl.py: Add new "jobctrl" extension for spawning background
630 processes with "&find /". 'import jobctrl' to try it out. Requires
637 processes with "&find /". 'import jobctrl' to try it out. Requires
631 'subprocess' module, standard in python 2.4+.
638 'subprocess' module, standard in python 2.4+.
632
639
633 * iplib.py (expand_aliases, handle_alias): Aliases expand transitively,
640 * iplib.py (expand_aliases, handle_alias): Aliases expand transitively,
634 so if foo -> bar and bar -> baz, then foo -> baz.
641 so if foo -> bar and bar -> baz, then foo -> baz.
635
642
636 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
643 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
637
644
638 * IPython/Magic.py (Magic.parse_options): add a new posix option
645 * IPython/Magic.py (Magic.parse_options): add a new posix option
639 to allow parsing of input args in magics that doesn't strip quotes
646 to allow parsing of input args in magics that doesn't strip quotes
640 (if posix=False). This also closes %timeit bug reported by
647 (if posix=False). This also closes %timeit bug reported by
641 Stefan.
648 Stefan.
642
649
643 2006-10-03 Ville Vainio <vivainio@gmail.com>
650 2006-10-03 Ville Vainio <vivainio@gmail.com>
644
651
645 * iplib.py (raw_input, interact): Return ValueError catching for
652 * iplib.py (raw_input, interact): Return ValueError catching for
646 raw_input. Fixes infinite loop for sys.stdin.close() or
653 raw_input. Fixes infinite loop for sys.stdin.close() or
647 sys.stdout.close().
654 sys.stdout.close().
648
655
649 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
656 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
650
657
651 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
658 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
652 to help in handling doctests. irunner is now pretty useful for
659 to help in handling doctests. irunner is now pretty useful for
653 running standalone scripts and simulate a full interactive session
660 running standalone scripts and simulate a full interactive session
654 in a format that can be then pasted as a doctest.
661 in a format that can be then pasted as a doctest.
655
662
656 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
663 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
657 on top of the default (useless) ones. This also fixes the nasty
664 on top of the default (useless) ones. This also fixes the nasty
658 way in which 2.5's Quitter() exits (reverted [1785]).
665 way in which 2.5's Quitter() exits (reverted [1785]).
659
666
660 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
667 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
661 2.5.
668 2.5.
662
669
663 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
670 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
664 color scheme is updated as well when color scheme is changed
671 color scheme is updated as well when color scheme is changed
665 interactively.
672 interactively.
666
673
667 2006-09-27 Ville Vainio <vivainio@gmail.com>
674 2006-09-27 Ville Vainio <vivainio@gmail.com>
668
675
669 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
676 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
670 infinite loop and just exit. It's a hack, but will do for a while.
677 infinite loop and just exit. It's a hack, but will do for a while.
671
678
672 2006-08-25 Walter Doerwald <walter@livinglogic.de>
679 2006-08-25 Walter Doerwald <walter@livinglogic.de>
673
680
674 * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to
681 * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to
675 the constructor, this makes it possible to get a list of only directories
682 the constructor, this makes it possible to get a list of only directories
676 or only files.
683 or only files.
677
684
678 2006-08-12 Ville Vainio <vivainio@gmail.com>
685 2006-08-12 Ville Vainio <vivainio@gmail.com>
679
686
680 * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,
687 * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,
681 they broke unittest
688 they broke unittest
682
689
683 2006-08-11 Ville Vainio <vivainio@gmail.com>
690 2006-08-11 Ville Vainio <vivainio@gmail.com>
684
691
685 * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch
692 * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch
686 by resolving issue properly, i.e. by inheriting FakeModule
693 by resolving issue properly, i.e. by inheriting FakeModule
687 from types.ModuleType. Pickling ipython interactive data
694 from types.ModuleType. Pickling ipython interactive data
688 should still work as usual (testing appreciated).
695 should still work as usual (testing appreciated).
689
696
690 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
697 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
691
698
692 * IPython/OInspect.py: monkeypatch inspect from the stdlib if
699 * IPython/OInspect.py: monkeypatch inspect from the stdlib if
693 running under python 2.3 with code from 2.4 to fix a bug with
700 running under python 2.3 with code from 2.4 to fix a bug with
694 help(). Reported by the Debian maintainers, Norbert Tretkowski
701 help(). Reported by the Debian maintainers, Norbert Tretkowski
695 <norbert-AT-tretkowski.de> and Alexandre Fayolle
702 <norbert-AT-tretkowski.de> and Alexandre Fayolle
696 <afayolle-AT-debian.org>.
703 <afayolle-AT-debian.org>.
697
704
698 2006-08-04 Walter Doerwald <walter@livinglogic.de>
705 2006-08-04 Walter Doerwald <walter@livinglogic.de>
699
706
700 * IPython/Extensions/ibrowse.py: Fixed the help message in the footer
707 * IPython/Extensions/ibrowse.py: Fixed the help message in the footer
701 (which was displaying "quit" twice).
708 (which was displaying "quit" twice).
702
709
703 2006-07-28 Walter Doerwald <walter@livinglogic.de>
710 2006-07-28 Walter Doerwald <walter@livinglogic.de>
704
711
705 * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using
712 * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using
706 the mode argument).
713 the mode argument).
707
714
708 2006-07-27 Walter Doerwald <walter@livinglogic.de>
715 2006-07-27 Walter Doerwald <walter@livinglogic.de>
709
716
710 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
717 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
711 not running under IPython.
718 not running under IPython.
712
719
713 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
720 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
714 and make it iterable (iterating over the attribute itself). Add two new
721 and make it iterable (iterating over the attribute itself). Add two new
715 magic strings for __xattrs__(): If the string starts with "-", the attribute
722 magic strings for __xattrs__(): If the string starts with "-", the attribute
716 will not be displayed in ibrowse's detail view (but it can still be
723 will not be displayed in ibrowse's detail view (but it can still be
717 iterated over). This makes it possible to add attributes that are large
724 iterated over). This makes it possible to add attributes that are large
718 lists or generator methods to the detail view. Replace magic attribute names
725 lists or generator methods to the detail view. Replace magic attribute names
719 and _attrname() and _getattr() with "descriptors": For each type of magic
726 and _attrname() and _getattr() with "descriptors": For each type of magic
720 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
727 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
721 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
728 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
722 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
729 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
723 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
730 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
724 are still supported.
731 are still supported.
725
732
726 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
733 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
727 fails in ibrowse.fetch(), the exception object is added as the last item
734 fails in ibrowse.fetch(), the exception object is added as the last item
728 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
735 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
729 a generator throws an exception midway through execution.
736 a generator throws an exception midway through execution.
730
737
731 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
738 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
732 encoding into methods.
739 encoding into methods.
733
740
734 2006-07-26 Ville Vainio <vivainio@gmail.com>
741 2006-07-26 Ville Vainio <vivainio@gmail.com>
735
742
736 * iplib.py: history now stores multiline input as single
743 * iplib.py: history now stores multiline input as single
737 history entries. Patch by Jorgen Cederlof.
744 history entries. Patch by Jorgen Cederlof.
738
745
739 2006-07-18 Walter Doerwald <walter@livinglogic.de>
746 2006-07-18 Walter Doerwald <walter@livinglogic.de>
740
747
741 * IPython/Extensions/ibrowse.py: Make cursor visible over
748 * IPython/Extensions/ibrowse.py: Make cursor visible over
742 non existing attributes.
749 non existing attributes.
743
750
744 2006-07-14 Walter Doerwald <walter@livinglogic.de>
751 2006-07-14 Walter Doerwald <walter@livinglogic.de>
745
752
746 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
753 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
747 error output of the running command doesn't mess up the screen.
754 error output of the running command doesn't mess up the screen.
748
755
749 2006-07-13 Walter Doerwald <walter@livinglogic.de>
756 2006-07-13 Walter Doerwald <walter@livinglogic.de>
750
757
751 * IPython/Extensions/ipipe.py (isort): Make isort usable without
758 * IPython/Extensions/ipipe.py (isort): Make isort usable without
752 argument. This sorts the items themselves.
759 argument. This sorts the items themselves.
753
760
754 2006-07-12 Walter Doerwald <walter@livinglogic.de>
761 2006-07-12 Walter Doerwald <walter@livinglogic.de>
755
762
756 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
763 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
757 Compile expression strings into code objects. This should speed
764 Compile expression strings into code objects. This should speed
758 up ifilter and friends somewhat.
765 up ifilter and friends somewhat.
759
766
760 2006-07-08 Ville Vainio <vivainio@gmail.com>
767 2006-07-08 Ville Vainio <vivainio@gmail.com>
761
768
762 * Magic.py: %cpaste now strips > from the beginning of lines
769 * Magic.py: %cpaste now strips > from the beginning of lines
763 to ease pasting quoted code from emails. Contributed by
770 to ease pasting quoted code from emails. Contributed by
764 Stefan van der Walt.
771 Stefan van der Walt.
765
772
766 2006-06-29 Ville Vainio <vivainio@gmail.com>
773 2006-06-29 Ville Vainio <vivainio@gmail.com>
767
774
768 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
775 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
769 mode, patch contributed by Darren Dale. NEEDS TESTING!
776 mode, patch contributed by Darren Dale. NEEDS TESTING!
770
777
771 2006-06-28 Walter Doerwald <walter@livinglogic.de>
778 2006-06-28 Walter Doerwald <walter@livinglogic.de>
772
779
773 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
780 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
774 a blue background. Fix fetching new display rows when the browser
781 a blue background. Fix fetching new display rows when the browser
775 scrolls more than a screenful (e.g. by using the goto command).
782 scrolls more than a screenful (e.g. by using the goto command).
776
783
777 2006-06-27 Ville Vainio <vivainio@gmail.com>
784 2006-06-27 Ville Vainio <vivainio@gmail.com>
778
785
779 * Magic.py (_inspect, _ofind) Apply David Huard's
786 * Magic.py (_inspect, _ofind) Apply David Huard's
780 patch for displaying the correct docstring for 'property'
787 patch for displaying the correct docstring for 'property'
781 attributes.
788 attributes.
782
789
783 2006-06-23 Walter Doerwald <walter@livinglogic.de>
790 2006-06-23 Walter Doerwald <walter@livinglogic.de>
784
791
785 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
792 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
786 commands into the methods implementing them.
793 commands into the methods implementing them.
787
794
788 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
795 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
789
796
790 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
797 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
791 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
798 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
792 autoindent support was authored by Jin Liu.
799 autoindent support was authored by Jin Liu.
793
800
794 2006-06-22 Walter Doerwald <walter@livinglogic.de>
801 2006-06-22 Walter Doerwald <walter@livinglogic.de>
795
802
796 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
803 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
797 for keymaps with a custom class that simplifies handling.
804 for keymaps with a custom class that simplifies handling.
798
805
799 2006-06-19 Walter Doerwald <walter@livinglogic.de>
806 2006-06-19 Walter Doerwald <walter@livinglogic.de>
800
807
801 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
808 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
802 resizing. This requires Python 2.5 to work.
809 resizing. This requires Python 2.5 to work.
803
810
804 2006-06-16 Walter Doerwald <walter@livinglogic.de>
811 2006-06-16 Walter Doerwald <walter@livinglogic.de>
805
812
806 * IPython/Extensions/ibrowse.py: Add two new commands to
813 * IPython/Extensions/ibrowse.py: Add two new commands to
807 ibrowse: "hideattr" (mapped to "h") hides the attribute under
814 ibrowse: "hideattr" (mapped to "h") hides the attribute under
808 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
815 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
809 attributes again. Remapped the help command to "?". Display
816 attributes again. Remapped the help command to "?". Display
810 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
817 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
811 as keys for the "home" and "end" commands. Add three new commands
818 as keys for the "home" and "end" commands. Add three new commands
812 to the input mode for "find" and friends: "delend" (CTRL-K)
819 to the input mode for "find" and friends: "delend" (CTRL-K)
813 deletes to the end of line. "incsearchup" searches upwards in the
820 deletes to the end of line. "incsearchup" searches upwards in the
814 command history for an input that starts with the text before the cursor.
821 command history for an input that starts with the text before the cursor.
815 "incsearchdown" does the same downwards. Removed a bogus mapping of
822 "incsearchdown" does the same downwards. Removed a bogus mapping of
816 the x key to "delete".
823 the x key to "delete".
817
824
818 2006-06-15 Ville Vainio <vivainio@gmail.com>
825 2006-06-15 Ville Vainio <vivainio@gmail.com>
819
826
820 * iplib.py, hooks.py: Added new generate_prompt hook that can be
827 * iplib.py, hooks.py: Added new generate_prompt hook that can be
821 used to create prompts dynamically, instead of the "old" way of
828 used to create prompts dynamically, instead of the "old" way of
822 assigning "magic" strings to prompt_in1 and prompt_in2. The old
829 assigning "magic" strings to prompt_in1 and prompt_in2. The old
823 way still works (it's invoked by the default hook), of course.
830 way still works (it's invoked by the default hook), of course.
824
831
825 * Prompts.py: added generate_output_prompt hook for altering output
832 * Prompts.py: added generate_output_prompt hook for altering output
826 prompt
833 prompt
827
834
828 * Release.py: Changed version string to 0.7.3.svn.
835 * Release.py: Changed version string to 0.7.3.svn.
829
836
830 2006-06-15 Walter Doerwald <walter@livinglogic.de>
837 2006-06-15 Walter Doerwald <walter@livinglogic.de>
831
838
832 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
839 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
833 the call to fetch() always tries to fetch enough data for at least one
840 the call to fetch() always tries to fetch enough data for at least one
834 full screen. This makes it possible to simply call moveto(0,0,True) in
841 full screen. This makes it possible to simply call moveto(0,0,True) in
835 the constructor. Fix typos and removed the obsolete goto attribute.
842 the constructor. Fix typos and removed the obsolete goto attribute.
836
843
837 2006-06-12 Ville Vainio <vivainio@gmail.com>
844 2006-06-12 Ville Vainio <vivainio@gmail.com>
838
845
839 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
846 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
840 allowing $variable interpolation within multiline statements,
847 allowing $variable interpolation within multiline statements,
841 though so far only with "sh" profile for a testing period.
848 though so far only with "sh" profile for a testing period.
842 The patch also enables splitting long commands with \ but it
849 The patch also enables splitting long commands with \ but it
843 doesn't work properly yet.
850 doesn't work properly yet.
844
851
845 2006-06-12 Walter Doerwald <walter@livinglogic.de>
852 2006-06-12 Walter Doerwald <walter@livinglogic.de>
846
853
847 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
854 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
848 input history and the position of the cursor in the input history for
855 input history and the position of the cursor in the input history for
849 the find, findbackwards and goto command.
856 the find, findbackwards and goto command.
850
857
851 2006-06-10 Walter Doerwald <walter@livinglogic.de>
858 2006-06-10 Walter Doerwald <walter@livinglogic.de>
852
859
853 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
860 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
854 implements the basic functionality of browser commands that require
861 implements the basic functionality of browser commands that require
855 input. Reimplement the goto, find and findbackwards commands as
862 input. Reimplement the goto, find and findbackwards commands as
856 subclasses of _CommandInput. Add an input history and keymaps to those
863 subclasses of _CommandInput. Add an input history and keymaps to those
857 commands. Add "\r" as a keyboard shortcut for the enterdefault and
864 commands. Add "\r" as a keyboard shortcut for the enterdefault and
858 execute commands.
865 execute commands.
859
866
860 2006-06-07 Ville Vainio <vivainio@gmail.com>
867 2006-06-07 Ville Vainio <vivainio@gmail.com>
861
868
862 * iplib.py: ipython mybatch.ipy exits ipython immediately after
869 * iplib.py: ipython mybatch.ipy exits ipython immediately after
863 running the batch files instead of leaving the session open.
870 running the batch files instead of leaving the session open.
864
871
865 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
872 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
866
873
867 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
874 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
868 the original fix was incomplete. Patch submitted by W. Maier.
875 the original fix was incomplete. Patch submitted by W. Maier.
869
876
870 2006-06-07 Ville Vainio <vivainio@gmail.com>
877 2006-06-07 Ville Vainio <vivainio@gmail.com>
871
878
872 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
879 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
873 Confirmation prompts can be supressed by 'quiet' option.
880 Confirmation prompts can be supressed by 'quiet' option.
874 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
881 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
875
882
876 2006-06-06 *** Released version 0.7.2
883 2006-06-06 *** Released version 0.7.2
877
884
878 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
885 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
879
886
880 * IPython/Release.py (version): Made 0.7.2 final for release.
887 * IPython/Release.py (version): Made 0.7.2 final for release.
881 Repo tagged and release cut.
888 Repo tagged and release cut.
882
889
883 2006-06-05 Ville Vainio <vivainio@gmail.com>
890 2006-06-05 Ville Vainio <vivainio@gmail.com>
884
891
885 * Magic.py (magic_rehashx): Honor no_alias list earlier in
892 * Magic.py (magic_rehashx): Honor no_alias list earlier in
886 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
893 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
887
894
888 * upgrade_dir.py: try import 'path' module a bit harder
895 * upgrade_dir.py: try import 'path' module a bit harder
889 (for %upgrade)
896 (for %upgrade)
890
897
891 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
898 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
892
899
893 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
900 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
894 instead of looping 20 times.
901 instead of looping 20 times.
895
902
896 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
903 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
897 correctly at initialization time. Bug reported by Krishna Mohan
904 correctly at initialization time. Bug reported by Krishna Mohan
898 Gundu <gkmohan-AT-gmail.com> on the user list.
905 Gundu <gkmohan-AT-gmail.com> on the user list.
899
906
900 * IPython/Release.py (version): Mark 0.7.2 version to start
907 * IPython/Release.py (version): Mark 0.7.2 version to start
901 testing for release on 06/06.
908 testing for release on 06/06.
902
909
903 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
910 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
904
911
905 * scripts/irunner: thin script interface so users don't have to
912 * scripts/irunner: thin script interface so users don't have to
906 find the module and call it as an executable, since modules rarely
913 find the module and call it as an executable, since modules rarely
907 live in people's PATH.
914 live in people's PATH.
908
915
909 * IPython/irunner.py (InteractiveRunner.__init__): added
916 * IPython/irunner.py (InteractiveRunner.__init__): added
910 delaybeforesend attribute to control delays with newer versions of
917 delaybeforesend attribute to control delays with newer versions of
911 pexpect. Thanks to detailed help from pexpect's author, Noah
918 pexpect. Thanks to detailed help from pexpect's author, Noah
912 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
919 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
913 correctly (it works in NoColor mode).
920 correctly (it works in NoColor mode).
914
921
915 * IPython/iplib.py (handle_normal): fix nasty crash reported on
922 * IPython/iplib.py (handle_normal): fix nasty crash reported on
916 SAGE list, from improper log() calls.
923 SAGE list, from improper log() calls.
917
924
918 2006-05-31 Ville Vainio <vivainio@gmail.com>
925 2006-05-31 Ville Vainio <vivainio@gmail.com>
919
926
920 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
927 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
921 with args in parens to work correctly with dirs that have spaces.
928 with args in parens to work correctly with dirs that have spaces.
922
929
923 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
930 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
924
931
925 * IPython/Logger.py (Logger.logstart): add option to log raw input
932 * IPython/Logger.py (Logger.logstart): add option to log raw input
926 instead of the processed one. A -r flag was added to the
933 instead of the processed one. A -r flag was added to the
927 %logstart magic used for controlling logging.
934 %logstart magic used for controlling logging.
928
935
929 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
936 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
930
937
931 * IPython/iplib.py (InteractiveShell.__init__): add check for the
938 * IPython/iplib.py (InteractiveShell.__init__): add check for the
932 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
939 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
933 recognize the option. After a bug report by Will Maier. This
940 recognize the option. After a bug report by Will Maier. This
934 closes #64 (will do it after confirmation from W. Maier).
941 closes #64 (will do it after confirmation from W. Maier).
935
942
936 * IPython/irunner.py: New module to run scripts as if manually
943 * IPython/irunner.py: New module to run scripts as if manually
937 typed into an interactive environment, based on pexpect. After a
944 typed into an interactive environment, based on pexpect. After a
938 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
945 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
939 ipython-user list. Simple unittests in the tests/ directory.
946 ipython-user list. Simple unittests in the tests/ directory.
940
947
941 * tools/release: add Will Maier, OpenBSD port maintainer, to
948 * tools/release: add Will Maier, OpenBSD port maintainer, to
942 recepients list. We are now officially part of the OpenBSD ports:
949 recepients list. We are now officially part of the OpenBSD ports:
943 http://www.openbsd.org/ports.html ! Many thanks to Will for the
950 http://www.openbsd.org/ports.html ! Many thanks to Will for the
944 work.
951 work.
945
952
946 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
953 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
947
954
948 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
955 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
949 so that it doesn't break tkinter apps.
956 so that it doesn't break tkinter apps.
950
957
951 * IPython/iplib.py (_prefilter): fix bug where aliases would
958 * IPython/iplib.py (_prefilter): fix bug where aliases would
952 shadow variables when autocall was fully off. Reported by SAGE
959 shadow variables when autocall was fully off. Reported by SAGE
953 author William Stein.
960 author William Stein.
954
961
955 * IPython/OInspect.py (Inspector.__init__): add a flag to control
962 * IPython/OInspect.py (Inspector.__init__): add a flag to control
956 at what detail level strings are computed when foo? is requested.
963 at what detail level strings are computed when foo? is requested.
957 This allows users to ask for example that the string form of an
964 This allows users to ask for example that the string form of an
958 object is only computed when foo?? is called, or even never, by
965 object is only computed when foo?? is called, or even never, by
959 setting the object_info_string_level >= 2 in the configuration
966 setting the object_info_string_level >= 2 in the configuration
960 file. This new option has been added and documented. After a
967 file. This new option has been added and documented. After a
961 request by SAGE to be able to control the printing of very large
968 request by SAGE to be able to control the printing of very large
962 objects more easily.
969 objects more easily.
963
970
964 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
971 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
965
972
966 * IPython/ipmaker.py (make_IPython): remove the ipython call path
973 * IPython/ipmaker.py (make_IPython): remove the ipython call path
967 from sys.argv, to be 100% consistent with how Python itself works
974 from sys.argv, to be 100% consistent with how Python itself works
968 (as seen for example with python -i file.py). After a bug report
975 (as seen for example with python -i file.py). After a bug report
969 by Jeffrey Collins.
976 by Jeffrey Collins.
970
977
971 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
978 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
972 nasty bug which was preventing custom namespaces with -pylab,
979 nasty bug which was preventing custom namespaces with -pylab,
973 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
980 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
974 compatibility (long gone from mpl).
981 compatibility (long gone from mpl).
975
982
976 * IPython/ipapi.py (make_session): name change: create->make. We
983 * IPython/ipapi.py (make_session): name change: create->make. We
977 use make in other places (ipmaker,...), it's shorter and easier to
984 use make in other places (ipmaker,...), it's shorter and easier to
978 type and say, etc. I'm trying to clean things before 0.7.2 so
985 type and say, etc. I'm trying to clean things before 0.7.2 so
979 that I can keep things stable wrt to ipapi in the chainsaw branch.
986 that I can keep things stable wrt to ipapi in the chainsaw branch.
980
987
981 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
988 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
982 python-mode recognizes our debugger mode. Add support for
989 python-mode recognizes our debugger mode. Add support for
983 autoindent inside (X)emacs. After a patch sent in by Jin Liu
990 autoindent inside (X)emacs. After a patch sent in by Jin Liu
984 <m.liu.jin-AT-gmail.com> originally written by
991 <m.liu.jin-AT-gmail.com> originally written by
985 doxgen-AT-newsmth.net (with minor modifications for xemacs
992 doxgen-AT-newsmth.net (with minor modifications for xemacs
986 compatibility)
993 compatibility)
987
994
988 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
995 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
989 tracebacks when walking the stack so that the stack tracking system
996 tracebacks when walking the stack so that the stack tracking system
990 in emacs' python-mode can identify the frames correctly.
997 in emacs' python-mode can identify the frames correctly.
991
998
992 * IPython/ipmaker.py (make_IPython): make the internal (and
999 * IPython/ipmaker.py (make_IPython): make the internal (and
993 default config) autoedit_syntax value false by default. Too many
1000 default config) autoedit_syntax value false by default. Too many
994 users have complained to me (both on and off-list) about problems
1001 users have complained to me (both on and off-list) about problems
995 with this option being on by default, so I'm making it default to
1002 with this option being on by default, so I'm making it default to
996 off. It can still be enabled by anyone via the usual mechanisms.
1003 off. It can still be enabled by anyone via the usual mechanisms.
997
1004
998 * IPython/completer.py (Completer.attr_matches): add support for
1005 * IPython/completer.py (Completer.attr_matches): add support for
999 PyCrust-style _getAttributeNames magic method. Patch contributed
1006 PyCrust-style _getAttributeNames magic method. Patch contributed
1000 by <mscott-AT-goldenspud.com>. Closes #50.
1007 by <mscott-AT-goldenspud.com>. Closes #50.
1001
1008
1002 * IPython/iplib.py (InteractiveShell.__init__): remove the
1009 * IPython/iplib.py (InteractiveShell.__init__): remove the
1003 deletion of exit/quit from __builtin__, which can break
1010 deletion of exit/quit from __builtin__, which can break
1004 third-party tools like the Zope debugging console. The
1011 third-party tools like the Zope debugging console. The
1005 %exit/%quit magics remain. In general, it's probably a good idea
1012 %exit/%quit magics remain. In general, it's probably a good idea
1006 not to delete anything from __builtin__, since we never know what
1013 not to delete anything from __builtin__, since we never know what
1007 that will break. In any case, python now (for 2.5) will support
1014 that will break. In any case, python now (for 2.5) will support
1008 'real' exit/quit, so this issue is moot. Closes #55.
1015 'real' exit/quit, so this issue is moot. Closes #55.
1009
1016
1010 * IPython/genutils.py (with_obj): rename the 'with' function to
1017 * IPython/genutils.py (with_obj): rename the 'with' function to
1011 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
1018 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
1012 becomes a language keyword. Closes #53.
1019 becomes a language keyword. Closes #53.
1013
1020
1014 * IPython/FakeModule.py (FakeModule.__init__): add a proper
1021 * IPython/FakeModule.py (FakeModule.__init__): add a proper
1015 __file__ attribute to this so it fools more things into thinking
1022 __file__ attribute to this so it fools more things into thinking
1016 it is a real module. Closes #59.
1023 it is a real module. Closes #59.
1017
1024
1018 * IPython/Magic.py (magic_edit): add -n option to open the editor
1025 * IPython/Magic.py (magic_edit): add -n option to open the editor
1019 at a specific line number. After a patch by Stefan van der Walt.
1026 at a specific line number. After a patch by Stefan van der Walt.
1020
1027
1021 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
1028 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
1022
1029
1023 * IPython/iplib.py (edit_syntax_error): fix crash when for some
1030 * IPython/iplib.py (edit_syntax_error): fix crash when for some
1024 reason the file could not be opened. After automatic crash
1031 reason the file could not be opened. After automatic crash
1025 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
1032 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
1026 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
1033 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
1027 (_should_recompile): Don't fire editor if using %bg, since there
1034 (_should_recompile): Don't fire editor if using %bg, since there
1028 is no file in the first place. From the same report as above.
1035 is no file in the first place. From the same report as above.
1029 (raw_input): protect against faulty third-party prefilters. After
1036 (raw_input): protect against faulty third-party prefilters. After
1030 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
1037 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
1031 while running under SAGE.
1038 while running under SAGE.
1032
1039
1033 2006-05-23 Ville Vainio <vivainio@gmail.com>
1040 2006-05-23 Ville Vainio <vivainio@gmail.com>
1034
1041
1035 * ipapi.py: Stripped down ip.to_user_ns() to work only as
1042 * ipapi.py: Stripped down ip.to_user_ns() to work only as
1036 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
1043 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
1037 now returns None (again), unless dummy is specifically allowed by
1044 now returns None (again), unless dummy is specifically allowed by
1038 ipapi.get(allow_dummy=True).
1045 ipapi.get(allow_dummy=True).
1039
1046
1040 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
1047 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
1041
1048
1042 * IPython: remove all 2.2-compatibility objects and hacks from
1049 * IPython: remove all 2.2-compatibility objects and hacks from
1043 everywhere, since we only support 2.3 at this point. Docs
1050 everywhere, since we only support 2.3 at this point. Docs
1044 updated.
1051 updated.
1045
1052
1046 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
1053 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
1047 Anything requiring extra validation can be turned into a Python
1054 Anything requiring extra validation can be turned into a Python
1048 property in the future. I used a property for the db one b/c
1055 property in the future. I used a property for the db one b/c
1049 there was a nasty circularity problem with the initialization
1056 there was a nasty circularity problem with the initialization
1050 order, which right now I don't have time to clean up.
1057 order, which right now I don't have time to clean up.
1051
1058
1052 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
1059 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
1053 another locking bug reported by Jorgen. I'm not 100% sure though,
1060 another locking bug reported by Jorgen. I'm not 100% sure though,
1054 so more testing is needed...
1061 so more testing is needed...
1055
1062
1056 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
1063 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
1057
1064
1058 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
1065 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
1059 local variables from any routine in user code (typically executed
1066 local variables from any routine in user code (typically executed
1060 with %run) directly into the interactive namespace. Very useful
1067 with %run) directly into the interactive namespace. Very useful
1061 when doing complex debugging.
1068 when doing complex debugging.
1062 (IPythonNotRunning): Changed the default None object to a dummy
1069 (IPythonNotRunning): Changed the default None object to a dummy
1063 whose attributes can be queried as well as called without
1070 whose attributes can be queried as well as called without
1064 exploding, to ease writing code which works transparently both in
1071 exploding, to ease writing code which works transparently both in
1065 and out of ipython and uses some of this API.
1072 and out of ipython and uses some of this API.
1066
1073
1067 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
1074 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
1068
1075
1069 * IPython/hooks.py (result_display): Fix the fact that our display
1076 * IPython/hooks.py (result_display): Fix the fact that our display
1070 hook was using str() instead of repr(), as the default python
1077 hook was using str() instead of repr(), as the default python
1071 console does. This had gone unnoticed b/c it only happened if
1078 console does. This had gone unnoticed b/c it only happened if
1072 %Pprint was off, but the inconsistency was there.
1079 %Pprint was off, but the inconsistency was there.
1073
1080
1074 2006-05-15 Ville Vainio <vivainio@gmail.com>
1081 2006-05-15 Ville Vainio <vivainio@gmail.com>
1075
1082
1076 * Oinspect.py: Only show docstring for nonexisting/binary files
1083 * Oinspect.py: Only show docstring for nonexisting/binary files
1077 when doing object??, closing ticket #62
1084 when doing object??, closing ticket #62
1078
1085
1079 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
1086 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
1080
1087
1081 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
1088 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
1082 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
1089 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
1083 was being released in a routine which hadn't checked if it had
1090 was being released in a routine which hadn't checked if it had
1084 been the one to acquire it.
1091 been the one to acquire it.
1085
1092
1086 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
1093 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
1087
1094
1088 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
1095 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
1089
1096
1090 2006-04-11 Ville Vainio <vivainio@gmail.com>
1097 2006-04-11 Ville Vainio <vivainio@gmail.com>
1091
1098
1092 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
1099 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
1093 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
1100 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
1094 prefilters, allowing stuff like magics and aliases in the file.
1101 prefilters, allowing stuff like magics and aliases in the file.
1095
1102
1096 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
1103 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
1097 added. Supported now are "%clear in" and "%clear out" (clear input and
1104 added. Supported now are "%clear in" and "%clear out" (clear input and
1098 output history, respectively). Also fixed CachedOutput.flush to
1105 output history, respectively). Also fixed CachedOutput.flush to
1099 properly flush the output cache.
1106 properly flush the output cache.
1100
1107
1101 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
1108 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
1102 half-success (and fail explicitly).
1109 half-success (and fail explicitly).
1103
1110
1104 2006-03-28 Ville Vainio <vivainio@gmail.com>
1111 2006-03-28 Ville Vainio <vivainio@gmail.com>
1105
1112
1106 * iplib.py: Fix quoting of aliases so that only argless ones
1113 * iplib.py: Fix quoting of aliases so that only argless ones
1107 are quoted
1114 are quoted
1108
1115
1109 2006-03-28 Ville Vainio <vivainio@gmail.com>
1116 2006-03-28 Ville Vainio <vivainio@gmail.com>
1110
1117
1111 * iplib.py: Quote aliases with spaces in the name.
1118 * iplib.py: Quote aliases with spaces in the name.
1112 "c:\program files\blah\bin" is now legal alias target.
1119 "c:\program files\blah\bin" is now legal alias target.
1113
1120
1114 * ext_rehashdir.py: Space no longer allowed as arg
1121 * ext_rehashdir.py: Space no longer allowed as arg
1115 separator, since space is legal in path names.
1122 separator, since space is legal in path names.
1116
1123
1117 2006-03-16 Ville Vainio <vivainio@gmail.com>
1124 2006-03-16 Ville Vainio <vivainio@gmail.com>
1118
1125
1119 * upgrade_dir.py: Take path.py from Extensions, correcting
1126 * upgrade_dir.py: Take path.py from Extensions, correcting
1120 %upgrade magic
1127 %upgrade magic
1121
1128
1122 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
1129 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
1123
1130
1124 * hooks.py: Only enclose editor binary in quotes if legal and
1131 * hooks.py: Only enclose editor binary in quotes if legal and
1125 necessary (space in the name, and is an existing file). Fixes a bug
1132 necessary (space in the name, and is an existing file). Fixes a bug
1126 reported by Zachary Pincus.
1133 reported by Zachary Pincus.
1127
1134
1128 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
1135 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
1129
1136
1130 * Manual: thanks to a tip on proper color handling for Emacs, by
1137 * Manual: thanks to a tip on proper color handling for Emacs, by
1131 Eric J Haywiser <ejh1-AT-MIT.EDU>.
1138 Eric J Haywiser <ejh1-AT-MIT.EDU>.
1132
1139
1133 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
1140 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
1134 by applying the provided patch. Thanks to Liu Jin
1141 by applying the provided patch. Thanks to Liu Jin
1135 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
1142 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
1136 XEmacs/Linux, I'm trusting the submitter that it actually helps
1143 XEmacs/Linux, I'm trusting the submitter that it actually helps
1137 under win32/GNU Emacs. Will revisit if any problems are reported.
1144 under win32/GNU Emacs. Will revisit if any problems are reported.
1138
1145
1139 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1146 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1140
1147
1141 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
1148 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
1142 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
1149 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
1143
1150
1144 2006-03-12 Ville Vainio <vivainio@gmail.com>
1151 2006-03-12 Ville Vainio <vivainio@gmail.com>
1145
1152
1146 * Magic.py (magic_timeit): Added %timeit magic, contributed by
1153 * Magic.py (magic_timeit): Added %timeit magic, contributed by
1147 Torsten Marek.
1154 Torsten Marek.
1148
1155
1149 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1156 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1150
1157
1151 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
1158 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
1152 line ranges works again.
1159 line ranges works again.
1153
1160
1154 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
1161 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
1155
1162
1156 * IPython/iplib.py (showtraceback): add back sys.last_traceback
1163 * IPython/iplib.py (showtraceback): add back sys.last_traceback
1157 and friends, after a discussion with Zach Pincus on ipython-user.
1164 and friends, after a discussion with Zach Pincus on ipython-user.
1158 I'm not 100% sure, but after thinking about it quite a bit, it may
1165 I'm not 100% sure, but after thinking about it quite a bit, it may
1159 be OK. Testing with the multithreaded shells didn't reveal any
1166 be OK. Testing with the multithreaded shells didn't reveal any
1160 problems, but let's keep an eye out.
1167 problems, but let's keep an eye out.
1161
1168
1162 In the process, I fixed a few things which were calling
1169 In the process, I fixed a few things which were calling
1163 self.InteractiveTB() directly (like safe_execfile), which is a
1170 self.InteractiveTB() directly (like safe_execfile), which is a
1164 mistake: ALL exception reporting should be done by calling
1171 mistake: ALL exception reporting should be done by calling
1165 self.showtraceback(), which handles state and tab-completion and
1172 self.showtraceback(), which handles state and tab-completion and
1166 more.
1173 more.
1167
1174
1168 2006-03-01 Ville Vainio <vivainio@gmail.com>
1175 2006-03-01 Ville Vainio <vivainio@gmail.com>
1169
1176
1170 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
1177 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
1171 To use, do "from ipipe import *".
1178 To use, do "from ipipe import *".
1172
1179
1173 2006-02-24 Ville Vainio <vivainio@gmail.com>
1180 2006-02-24 Ville Vainio <vivainio@gmail.com>
1174
1181
1175 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
1182 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
1176 "cleanly" and safely than the older upgrade mechanism.
1183 "cleanly" and safely than the older upgrade mechanism.
1177
1184
1178 2006-02-21 Ville Vainio <vivainio@gmail.com>
1185 2006-02-21 Ville Vainio <vivainio@gmail.com>
1179
1186
1180 * Magic.py: %save works again.
1187 * Magic.py: %save works again.
1181
1188
1182 2006-02-15 Ville Vainio <vivainio@gmail.com>
1189 2006-02-15 Ville Vainio <vivainio@gmail.com>
1183
1190
1184 * Magic.py: %Pprint works again
1191 * Magic.py: %Pprint works again
1185
1192
1186 * Extensions/ipy_sane_defaults.py: Provide everything provided
1193 * Extensions/ipy_sane_defaults.py: Provide everything provided
1187 in default ipythonrc, to make it possible to have a completely empty
1194 in default ipythonrc, to make it possible to have a completely empty
1188 ipythonrc (and thus completely rc-file free configuration)
1195 ipythonrc (and thus completely rc-file free configuration)
1189
1196
1190 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
1197 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
1191
1198
1192 * IPython/hooks.py (editor): quote the call to the editor command,
1199 * IPython/hooks.py (editor): quote the call to the editor command,
1193 to allow commands with spaces in them. Problem noted by watching
1200 to allow commands with spaces in them. Problem noted by watching
1194 Ian Oswald's video about textpad under win32 at
1201 Ian Oswald's video about textpad under win32 at
1195 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
1202 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
1196
1203
1197 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
1204 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
1198 describing magics (we haven't used @ for a loong time).
1205 describing magics (we haven't used @ for a loong time).
1199
1206
1200 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
1207 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
1201 contributed by marienz to close
1208 contributed by marienz to close
1202 http://www.scipy.net/roundup/ipython/issue53.
1209 http://www.scipy.net/roundup/ipython/issue53.
1203
1210
1204 2006-02-10 Ville Vainio <vivainio@gmail.com>
1211 2006-02-10 Ville Vainio <vivainio@gmail.com>
1205
1212
1206 * genutils.py: getoutput now works in win32 too
1213 * genutils.py: getoutput now works in win32 too
1207
1214
1208 * completer.py: alias and magic completion only invoked
1215 * completer.py: alias and magic completion only invoked
1209 at the first "item" in the line, to avoid "cd %store"
1216 at the first "item" in the line, to avoid "cd %store"
1210 nonsense.
1217 nonsense.
1211
1218
1212 2006-02-09 Ville Vainio <vivainio@gmail.com>
1219 2006-02-09 Ville Vainio <vivainio@gmail.com>
1213
1220
1214 * test/*: Added a unit testing framework (finally).
1221 * test/*: Added a unit testing framework (finally).
1215 '%run runtests.py' to run test_*.
1222 '%run runtests.py' to run test_*.
1216
1223
1217 * ipapi.py: Exposed runlines and set_custom_exc
1224 * ipapi.py: Exposed runlines and set_custom_exc
1218
1225
1219 2006-02-07 Ville Vainio <vivainio@gmail.com>
1226 2006-02-07 Ville Vainio <vivainio@gmail.com>
1220
1227
1221 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
1228 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
1222 instead use "f(1 2)" as before.
1229 instead use "f(1 2)" as before.
1223
1230
1224 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
1231 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
1225
1232
1226 * IPython/demo.py (IPythonDemo): Add new classes to the demo
1233 * IPython/demo.py (IPythonDemo): Add new classes to the demo
1227 facilities, for demos processed by the IPython input filter
1234 facilities, for demos processed by the IPython input filter
1228 (IPythonDemo), and for running a script one-line-at-a-time as a
1235 (IPythonDemo), and for running a script one-line-at-a-time as a
1229 demo, both for pure Python (LineDemo) and for IPython-processed
1236 demo, both for pure Python (LineDemo) and for IPython-processed
1230 input (IPythonLineDemo). After a request by Dave Kohel, from the
1237 input (IPythonLineDemo). After a request by Dave Kohel, from the
1231 SAGE team.
1238 SAGE team.
1232 (Demo.edit): added an edit() method to the demo objects, to edit
1239 (Demo.edit): added an edit() method to the demo objects, to edit
1233 the in-memory copy of the last executed block.
1240 the in-memory copy of the last executed block.
1234
1241
1235 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
1242 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
1236 processing to %edit, %macro and %save. These commands can now be
1243 processing to %edit, %macro and %save. These commands can now be
1237 invoked on the unprocessed input as it was typed by the user
1244 invoked on the unprocessed input as it was typed by the user
1238 (without any prefilters applied). After requests by the SAGE team
1245 (without any prefilters applied). After requests by the SAGE team
1239 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
1246 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
1240
1247
1241 2006-02-01 Ville Vainio <vivainio@gmail.com>
1248 2006-02-01 Ville Vainio <vivainio@gmail.com>
1242
1249
1243 * setup.py, eggsetup.py: easy_install ipython==dev works
1250 * setup.py, eggsetup.py: easy_install ipython==dev works
1244 correctly now (on Linux)
1251 correctly now (on Linux)
1245
1252
1246 * ipy_user_conf,ipmaker: user config changes, removed spurious
1253 * ipy_user_conf,ipmaker: user config changes, removed spurious
1247 warnings
1254 warnings
1248
1255
1249 * iplib: if rc.banner is string, use it as is.
1256 * iplib: if rc.banner is string, use it as is.
1250
1257
1251 * Magic: %pycat accepts a string argument and pages it's contents.
1258 * Magic: %pycat accepts a string argument and pages it's contents.
1252
1259
1253
1260
1254 2006-01-30 Ville Vainio <vivainio@gmail.com>
1261 2006-01-30 Ville Vainio <vivainio@gmail.com>
1255
1262
1256 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
1263 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
1257 Now %store and bookmarks work through PickleShare, meaning that
1264 Now %store and bookmarks work through PickleShare, meaning that
1258 concurrent access is possible and all ipython sessions see the
1265 concurrent access is possible and all ipython sessions see the
1259 same database situation all the time, instead of snapshot of
1266 same database situation all the time, instead of snapshot of
1260 the situation when the session was started. Hence, %bookmark
1267 the situation when the session was started. Hence, %bookmark
1261 results are immediately accessible from othes sessions. The database
1268 results are immediately accessible from othes sessions. The database
1262 is also available for use by user extensions. See:
1269 is also available for use by user extensions. See:
1263 http://www.python.org/pypi/pickleshare
1270 http://www.python.org/pypi/pickleshare
1264
1271
1265 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
1272 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
1266
1273
1267 * aliases can now be %store'd
1274 * aliases can now be %store'd
1268
1275
1269 * path.py moved to Extensions so that pickleshare does not need
1276 * path.py moved to Extensions so that pickleshare does not need
1270 IPython-specific import. Extensions added to pythonpath right
1277 IPython-specific import. Extensions added to pythonpath right
1271 at __init__.
1278 at __init__.
1272
1279
1273 * iplib.py: ipalias deprecated/redundant; aliases are converted and
1280 * iplib.py: ipalias deprecated/redundant; aliases are converted and
1274 called with _ip.system and the pre-transformed command string.
1281 called with _ip.system and the pre-transformed command string.
1275
1282
1276 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
1283 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
1277
1284
1278 * IPython/iplib.py (interact): Fix that we were not catching
1285 * IPython/iplib.py (interact): Fix that we were not catching
1279 KeyboardInterrupt exceptions properly. I'm not quite sure why the
1286 KeyboardInterrupt exceptions properly. I'm not quite sure why the
1280 logic here had to change, but it's fixed now.
1287 logic here had to change, but it's fixed now.
1281
1288
1282 2006-01-29 Ville Vainio <vivainio@gmail.com>
1289 2006-01-29 Ville Vainio <vivainio@gmail.com>
1283
1290
1284 * iplib.py: Try to import pyreadline on Windows.
1291 * iplib.py: Try to import pyreadline on Windows.
1285
1292
1286 2006-01-27 Ville Vainio <vivainio@gmail.com>
1293 2006-01-27 Ville Vainio <vivainio@gmail.com>
1287
1294
1288 * iplib.py: Expose ipapi as _ip in builtin namespace.
1295 * iplib.py: Expose ipapi as _ip in builtin namespace.
1289 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
1296 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
1290 and ip_set_hook (-> _ip.set_hook) redundant. % and !
1297 and ip_set_hook (-> _ip.set_hook) redundant. % and !
1291 syntax now produce _ip.* variant of the commands.
1298 syntax now produce _ip.* variant of the commands.
1292
1299
1293 * "_ip.options().autoedit_syntax = 2" automatically throws
1300 * "_ip.options().autoedit_syntax = 2" automatically throws
1294 user to editor for syntax error correction without prompting.
1301 user to editor for syntax error correction without prompting.
1295
1302
1296 2006-01-27 Ville Vainio <vivainio@gmail.com>
1303 2006-01-27 Ville Vainio <vivainio@gmail.com>
1297
1304
1298 * ipmaker.py: Give "realistic" sys.argv for scripts (without
1305 * ipmaker.py: Give "realistic" sys.argv for scripts (without
1299 'ipython' at argv[0]) executed through command line.
1306 'ipython' at argv[0]) executed through command line.
1300 NOTE: this DEPRECATES calling ipython with multiple scripts
1307 NOTE: this DEPRECATES calling ipython with multiple scripts
1301 ("ipython a.py b.py c.py")
1308 ("ipython a.py b.py c.py")
1302
1309
1303 * iplib.py, hooks.py: Added configurable input prefilter,
1310 * iplib.py, hooks.py: Added configurable input prefilter,
1304 named 'input_prefilter'. See ext_rescapture.py for example
1311 named 'input_prefilter'. See ext_rescapture.py for example
1305 usage.
1312 usage.
1306
1313
1307 * ext_rescapture.py, Magic.py: Better system command output capture
1314 * ext_rescapture.py, Magic.py: Better system command output capture
1308 through 'var = !ls' (deprecates user-visible %sc). Same notation
1315 through 'var = !ls' (deprecates user-visible %sc). Same notation
1309 applies for magics, 'var = %alias' assigns alias list to var.
1316 applies for magics, 'var = %alias' assigns alias list to var.
1310
1317
1311 * ipapi.py: added meta() for accessing extension-usable data store.
1318 * ipapi.py: added meta() for accessing extension-usable data store.
1312
1319
1313 * iplib.py: added InteractiveShell.getapi(). New magics should be
1320 * iplib.py: added InteractiveShell.getapi(). New magics should be
1314 written doing self.getapi() instead of using the shell directly.
1321 written doing self.getapi() instead of using the shell directly.
1315
1322
1316 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
1323 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
1317 %store foo >> ~/myfoo.txt to store variables to files (in clean
1324 %store foo >> ~/myfoo.txt to store variables to files (in clean
1318 textual form, not a restorable pickle).
1325 textual form, not a restorable pickle).
1319
1326
1320 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
1327 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
1321
1328
1322 * usage.py, Magic.py: added %quickref
1329 * usage.py, Magic.py: added %quickref
1323
1330
1324 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
1331 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
1325
1332
1326 * GetoptErrors when invoking magics etc. with wrong args
1333 * GetoptErrors when invoking magics etc. with wrong args
1327 are now more helpful:
1334 are now more helpful:
1328 GetoptError: option -l not recognized (allowed: "qb" )
1335 GetoptError: option -l not recognized (allowed: "qb" )
1329
1336
1330 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
1337 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
1331
1338
1332 * IPython/demo.py (Demo.show): Flush stdout after each block, so
1339 * IPython/demo.py (Demo.show): Flush stdout after each block, so
1333 computationally intensive blocks don't appear to stall the demo.
1340 computationally intensive blocks don't appear to stall the demo.
1334
1341
1335 2006-01-24 Ville Vainio <vivainio@gmail.com>
1342 2006-01-24 Ville Vainio <vivainio@gmail.com>
1336
1343
1337 * iplib.py, hooks.py: 'result_display' hook can return a non-None
1344 * iplib.py, hooks.py: 'result_display' hook can return a non-None
1338 value to manipulate resulting history entry.
1345 value to manipulate resulting history entry.
1339
1346
1340 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
1347 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
1341 to instance methods of IPApi class, to make extending an embedded
1348 to instance methods of IPApi class, to make extending an embedded
1342 IPython feasible. See ext_rehashdir.py for example usage.
1349 IPython feasible. See ext_rehashdir.py for example usage.
1343
1350
1344 * Merged 1071-1076 from branches/0.7.1
1351 * Merged 1071-1076 from branches/0.7.1
1345
1352
1346
1353
1347 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
1354 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
1348
1355
1349 * tools/release (daystamp): Fix build tools to use the new
1356 * tools/release (daystamp): Fix build tools to use the new
1350 eggsetup.py script to build lightweight eggs.
1357 eggsetup.py script to build lightweight eggs.
1351
1358
1352 * Applied changesets 1062 and 1064 before 0.7.1 release.
1359 * Applied changesets 1062 and 1064 before 0.7.1 release.
1353
1360
1354 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
1361 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
1355 see the raw input history (without conversions like %ls ->
1362 see the raw input history (without conversions like %ls ->
1356 ipmagic("ls")). After a request from W. Stein, SAGE
1363 ipmagic("ls")). After a request from W. Stein, SAGE
1357 (http://modular.ucsd.edu/sage) developer. This information is
1364 (http://modular.ucsd.edu/sage) developer. This information is
1358 stored in the input_hist_raw attribute of the IPython instance, so
1365 stored in the input_hist_raw attribute of the IPython instance, so
1359 developers can access it if needed (it's an InputList instance).
1366 developers can access it if needed (it's an InputList instance).
1360
1367
1361 * Versionstring = 0.7.2.svn
1368 * Versionstring = 0.7.2.svn
1362
1369
1363 * eggsetup.py: A separate script for constructing eggs, creates
1370 * eggsetup.py: A separate script for constructing eggs, creates
1364 proper launch scripts even on Windows (an .exe file in
1371 proper launch scripts even on Windows (an .exe file in
1365 \python24\scripts).
1372 \python24\scripts).
1366
1373
1367 * ipapi.py: launch_new_instance, launch entry point needed for the
1374 * ipapi.py: launch_new_instance, launch entry point needed for the
1368 egg.
1375 egg.
1369
1376
1370 2006-01-23 Ville Vainio <vivainio@gmail.com>
1377 2006-01-23 Ville Vainio <vivainio@gmail.com>
1371
1378
1372 * Added %cpaste magic for pasting python code
1379 * Added %cpaste magic for pasting python code
1373
1380
1374 2006-01-22 Ville Vainio <vivainio@gmail.com>
1381 2006-01-22 Ville Vainio <vivainio@gmail.com>
1375
1382
1376 * Merge from branches/0.7.1 into trunk, revs 1052-1057
1383 * Merge from branches/0.7.1 into trunk, revs 1052-1057
1377
1384
1378 * Versionstring = 0.7.2.svn
1385 * Versionstring = 0.7.2.svn
1379
1386
1380 * eggsetup.py: A separate script for constructing eggs, creates
1387 * eggsetup.py: A separate script for constructing eggs, creates
1381 proper launch scripts even on Windows (an .exe file in
1388 proper launch scripts even on Windows (an .exe file in
1382 \python24\scripts).
1389 \python24\scripts).
1383
1390
1384 * ipapi.py: launch_new_instance, launch entry point needed for the
1391 * ipapi.py: launch_new_instance, launch entry point needed for the
1385 egg.
1392 egg.
1386
1393
1387 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
1394 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
1388
1395
1389 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
1396 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
1390 %pfile foo would print the file for foo even if it was a binary.
1397 %pfile foo would print the file for foo even if it was a binary.
1391 Now, extensions '.so' and '.dll' are skipped.
1398 Now, extensions '.so' and '.dll' are skipped.
1392
1399
1393 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
1400 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
1394 bug, where macros would fail in all threaded modes. I'm not 100%
1401 bug, where macros would fail in all threaded modes. I'm not 100%
1395 sure, so I'm going to put out an rc instead of making a release
1402 sure, so I'm going to put out an rc instead of making a release
1396 today, and wait for feedback for at least a few days.
1403 today, and wait for feedback for at least a few days.
1397
1404
1398 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
1405 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
1399 it...) the handling of pasting external code with autoindent on.
1406 it...) the handling of pasting external code with autoindent on.
1400 To get out of a multiline input, the rule will appear for most
1407 To get out of a multiline input, the rule will appear for most
1401 users unchanged: two blank lines or change the indent level
1408 users unchanged: two blank lines or change the indent level
1402 proposed by IPython. But there is a twist now: you can
1409 proposed by IPython. But there is a twist now: you can
1403 add/subtract only *one or two spaces*. If you add/subtract three
1410 add/subtract only *one or two spaces*. If you add/subtract three
1404 or more (unless you completely delete the line), IPython will
1411 or more (unless you completely delete the line), IPython will
1405 accept that line, and you'll need to enter a second one of pure
1412 accept that line, and you'll need to enter a second one of pure
1406 whitespace. I know it sounds complicated, but I can't find a
1413 whitespace. I know it sounds complicated, but I can't find a
1407 different solution that covers all the cases, with the right
1414 different solution that covers all the cases, with the right
1408 heuristics. Hopefully in actual use, nobody will really notice
1415 heuristics. Hopefully in actual use, nobody will really notice
1409 all these strange rules and things will 'just work'.
1416 all these strange rules and things will 'just work'.
1410
1417
1411 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
1418 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
1412
1419
1413 * IPython/iplib.py (interact): catch exceptions which can be
1420 * IPython/iplib.py (interact): catch exceptions which can be
1414 triggered asynchronously by signal handlers. Thanks to an
1421 triggered asynchronously by signal handlers. Thanks to an
1415 automatic crash report, submitted by Colin Kingsley
1422 automatic crash report, submitted by Colin Kingsley
1416 <tercel-AT-gentoo.org>.
1423 <tercel-AT-gentoo.org>.
1417
1424
1418 2006-01-20 Ville Vainio <vivainio@gmail.com>
1425 2006-01-20 Ville Vainio <vivainio@gmail.com>
1419
1426
1420 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
1427 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
1421 (%rehashdir, very useful, try it out) of how to extend ipython
1428 (%rehashdir, very useful, try it out) of how to extend ipython
1422 with new magics. Also added Extensions dir to pythonpath to make
1429 with new magics. Also added Extensions dir to pythonpath to make
1423 importing extensions easy.
1430 importing extensions easy.
1424
1431
1425 * %store now complains when trying to store interactively declared
1432 * %store now complains when trying to store interactively declared
1426 classes / instances of those classes.
1433 classes / instances of those classes.
1427
1434
1428 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
1435 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
1429 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
1436 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
1430 if they exist, and ipy_user_conf.py with some defaults is created for
1437 if they exist, and ipy_user_conf.py with some defaults is created for
1431 the user.
1438 the user.
1432
1439
1433 * Startup rehashing done by the config file, not InterpreterExec.
1440 * Startup rehashing done by the config file, not InterpreterExec.
1434 This means system commands are available even without selecting the
1441 This means system commands are available even without selecting the
1435 pysh profile. It's the sensible default after all.
1442 pysh profile. It's the sensible default after all.
1436
1443
1437 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
1444 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
1438
1445
1439 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
1446 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
1440 multiline code with autoindent on working. But I am really not
1447 multiline code with autoindent on working. But I am really not
1441 sure, so this needs more testing. Will commit a debug-enabled
1448 sure, so this needs more testing. Will commit a debug-enabled
1442 version for now, while I test it some more, so that Ville and
1449 version for now, while I test it some more, so that Ville and
1443 others may also catch any problems. Also made
1450 others may also catch any problems. Also made
1444 self.indent_current_str() a method, to ensure that there's no
1451 self.indent_current_str() a method, to ensure that there's no
1445 chance of the indent space count and the corresponding string
1452 chance of the indent space count and the corresponding string
1446 falling out of sync. All code needing the string should just call
1453 falling out of sync. All code needing the string should just call
1447 the method.
1454 the method.
1448
1455
1449 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
1456 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
1450
1457
1451 * IPython/Magic.py (magic_edit): fix check for when users don't
1458 * IPython/Magic.py (magic_edit): fix check for when users don't
1452 save their output files, the try/except was in the wrong section.
1459 save their output files, the try/except was in the wrong section.
1453
1460
1454 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
1461 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
1455
1462
1456 * IPython/Magic.py (magic_run): fix __file__ global missing from
1463 * IPython/Magic.py (magic_run): fix __file__ global missing from
1457 script's namespace when executed via %run. After a report by
1464 script's namespace when executed via %run. After a report by
1458 Vivian.
1465 Vivian.
1459
1466
1460 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
1467 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
1461 when using python 2.4. The parent constructor changed in 2.4, and
1468 when using python 2.4. The parent constructor changed in 2.4, and
1462 we need to track it directly (we can't call it, as it messes up
1469 we need to track it directly (we can't call it, as it messes up
1463 readline and tab-completion inside our pdb would stop working).
1470 readline and tab-completion inside our pdb would stop working).
1464 After a bug report by R. Bernstein <rocky-AT-panix.com>.
1471 After a bug report by R. Bernstein <rocky-AT-panix.com>.
1465
1472
1466 2006-01-16 Ville Vainio <vivainio@gmail.com>
1473 2006-01-16 Ville Vainio <vivainio@gmail.com>
1467
1474
1468 * Ipython/magic.py: Reverted back to old %edit functionality
1475 * Ipython/magic.py: Reverted back to old %edit functionality
1469 that returns file contents on exit.
1476 that returns file contents on exit.
1470
1477
1471 * IPython/path.py: Added Jason Orendorff's "path" module to
1478 * IPython/path.py: Added Jason Orendorff's "path" module to
1472 IPython tree, http://www.jorendorff.com/articles/python/path/.
1479 IPython tree, http://www.jorendorff.com/articles/python/path/.
1473 You can get path objects conveniently through %sc, and !!, e.g.:
1480 You can get path objects conveniently through %sc, and !!, e.g.:
1474 sc files=ls
1481 sc files=ls
1475 for p in files.paths: # or files.p
1482 for p in files.paths: # or files.p
1476 print p,p.mtime
1483 print p,p.mtime
1477
1484
1478 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
1485 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
1479 now work again without considering the exclusion regexp -
1486 now work again without considering the exclusion regexp -
1480 hence, things like ',foo my/path' turn to 'foo("my/path")'
1487 hence, things like ',foo my/path' turn to 'foo("my/path")'
1481 instead of syntax error.
1488 instead of syntax error.
1482
1489
1483
1490
1484 2006-01-14 Ville Vainio <vivainio@gmail.com>
1491 2006-01-14 Ville Vainio <vivainio@gmail.com>
1485
1492
1486 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
1493 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
1487 ipapi decorators for python 2.4 users, options() provides access to rc
1494 ipapi decorators for python 2.4 users, options() provides access to rc
1488 data.
1495 data.
1489
1496
1490 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
1497 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
1491 as path separators (even on Linux ;-). Space character after
1498 as path separators (even on Linux ;-). Space character after
1492 backslash (as yielded by tab completer) is still space;
1499 backslash (as yielded by tab completer) is still space;
1493 "%cd long\ name" works as expected.
1500 "%cd long\ name" works as expected.
1494
1501
1495 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
1502 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
1496 as "chain of command", with priority. API stays the same,
1503 as "chain of command", with priority. API stays the same,
1497 TryNext exception raised by a hook function signals that
1504 TryNext exception raised by a hook function signals that
1498 current hook failed and next hook should try handling it, as
1505 current hook failed and next hook should try handling it, as
1499 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
1506 suggested by Walter DΓΆrwald <walter@livinglogic.de>. Walter also
1500 requested configurable display hook, which is now implemented.
1507 requested configurable display hook, which is now implemented.
1501
1508
1502 2006-01-13 Ville Vainio <vivainio@gmail.com>
1509 2006-01-13 Ville Vainio <vivainio@gmail.com>
1503
1510
1504 * IPython/platutils*.py: platform specific utility functions,
1511 * IPython/platutils*.py: platform specific utility functions,
1505 so far only set_term_title is implemented (change terminal
1512 so far only set_term_title is implemented (change terminal
1506 label in windowing systems). %cd now changes the title to
1513 label in windowing systems). %cd now changes the title to
1507 current dir.
1514 current dir.
1508
1515
1509 * IPython/Release.py: Added myself to "authors" list,
1516 * IPython/Release.py: Added myself to "authors" list,
1510 had to create new files.
1517 had to create new files.
1511
1518
1512 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
1519 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
1513 shell escape; not a known bug but had potential to be one in the
1520 shell escape; not a known bug but had potential to be one in the
1514 future.
1521 future.
1515
1522
1516 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
1523 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
1517 extension API for IPython! See the module for usage example. Fix
1524 extension API for IPython! See the module for usage example. Fix
1518 OInspect for docstring-less magic functions.
1525 OInspect for docstring-less magic functions.
1519
1526
1520
1527
1521 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
1528 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
1522
1529
1523 * IPython/iplib.py (raw_input): temporarily deactivate all
1530 * IPython/iplib.py (raw_input): temporarily deactivate all
1524 attempts at allowing pasting of code with autoindent on. It
1531 attempts at allowing pasting of code with autoindent on. It
1525 introduced bugs (reported by Prabhu) and I can't seem to find a
1532 introduced bugs (reported by Prabhu) and I can't seem to find a
1526 robust combination which works in all cases. Will have to revisit
1533 robust combination which works in all cases. Will have to revisit
1527 later.
1534 later.
1528
1535
1529 * IPython/genutils.py: remove isspace() function. We've dropped
1536 * IPython/genutils.py: remove isspace() function. We've dropped
1530 2.2 compatibility, so it's OK to use the string method.
1537 2.2 compatibility, so it's OK to use the string method.
1531
1538
1532 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1539 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1533
1540
1534 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
1541 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
1535 matching what NOT to autocall on, to include all python binary
1542 matching what NOT to autocall on, to include all python binary
1536 operators (including things like 'and', 'or', 'is' and 'in').
1543 operators (including things like 'and', 'or', 'is' and 'in').
1537 Prompted by a bug report on 'foo & bar', but I realized we had
1544 Prompted by a bug report on 'foo & bar', but I realized we had
1538 many more potential bug cases with other operators. The regexp is
1545 many more potential bug cases with other operators. The regexp is
1539 self.re_exclude_auto, it's fairly commented.
1546 self.re_exclude_auto, it's fairly commented.
1540
1547
1541 2006-01-12 Ville Vainio <vivainio@gmail.com>
1548 2006-01-12 Ville Vainio <vivainio@gmail.com>
1542
1549
1543 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
1550 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
1544 Prettified and hardened string/backslash quoting with ipsystem(),
1551 Prettified and hardened string/backslash quoting with ipsystem(),
1545 ipalias() and ipmagic(). Now even \ characters are passed to
1552 ipalias() and ipmagic(). Now even \ characters are passed to
1546 %magics, !shell escapes and aliases exactly as they are in the
1553 %magics, !shell escapes and aliases exactly as they are in the
1547 ipython command line. Should improve backslash experience,
1554 ipython command line. Should improve backslash experience,
1548 particularly in Windows (path delimiter for some commands that
1555 particularly in Windows (path delimiter for some commands that
1549 won't understand '/'), but Unix benefits as well (regexps). %cd
1556 won't understand '/'), but Unix benefits as well (regexps). %cd
1550 magic still doesn't support backslash path delimiters, though. Also
1557 magic still doesn't support backslash path delimiters, though. Also
1551 deleted all pretense of supporting multiline command strings in
1558 deleted all pretense of supporting multiline command strings in
1552 !system or %magic commands. Thanks to Jerry McRae for suggestions.
1559 !system or %magic commands. Thanks to Jerry McRae for suggestions.
1553
1560
1554 * doc/build_doc_instructions.txt added. Documentation on how to
1561 * doc/build_doc_instructions.txt added. Documentation on how to
1555 use doc/update_manual.py, added yesterday. Both files contributed
1562 use doc/update_manual.py, added yesterday. Both files contributed
1556 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
1563 by JΓΆrgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
1557 doc/*.sh for deprecation at a later date.
1564 doc/*.sh for deprecation at a later date.
1558
1565
1559 * /ipython.py Added ipython.py to root directory for
1566 * /ipython.py Added ipython.py to root directory for
1560 zero-installation (tar xzvf ipython.tgz; cd ipython; python
1567 zero-installation (tar xzvf ipython.tgz; cd ipython; python
1561 ipython.py) and development convenience (no need to keep doing
1568 ipython.py) and development convenience (no need to keep doing
1562 "setup.py install" between changes).
1569 "setup.py install" between changes).
1563
1570
1564 * Made ! and !! shell escapes work (again) in multiline expressions:
1571 * Made ! and !! shell escapes work (again) in multiline expressions:
1565 if 1:
1572 if 1:
1566 !ls
1573 !ls
1567 !!ls
1574 !!ls
1568
1575
1569 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1576 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1570
1577
1571 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
1578 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
1572 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
1579 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
1573 module in case-insensitive installation. Was causing crashes
1580 module in case-insensitive installation. Was causing crashes
1574 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
1581 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
1575
1582
1576 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
1583 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
1577 <marienz-AT-gentoo.org>, closes
1584 <marienz-AT-gentoo.org>, closes
1578 http://www.scipy.net/roundup/ipython/issue51.
1585 http://www.scipy.net/roundup/ipython/issue51.
1579
1586
1580 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
1587 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
1581
1588
1582 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
1589 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
1583 problem of excessive CPU usage under *nix and keyboard lag under
1590 problem of excessive CPU usage under *nix and keyboard lag under
1584 win32.
1591 win32.
1585
1592
1586 2006-01-10 *** Released version 0.7.0
1593 2006-01-10 *** Released version 0.7.0
1587
1594
1588 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
1595 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
1589
1596
1590 * IPython/Release.py (revision): tag version number to 0.7.0,
1597 * IPython/Release.py (revision): tag version number to 0.7.0,
1591 ready for release.
1598 ready for release.
1592
1599
1593 * IPython/Magic.py (magic_edit): Add print statement to %edit so
1600 * IPython/Magic.py (magic_edit): Add print statement to %edit so
1594 it informs the user of the name of the temp. file used. This can
1601 it informs the user of the name of the temp. file used. This can
1595 help if you decide later to reuse that same file, so you know
1602 help if you decide later to reuse that same file, so you know
1596 where to copy the info from.
1603 where to copy the info from.
1597
1604
1598 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
1605 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
1599
1606
1600 * setup_bdist_egg.py: little script to build an egg. Added
1607 * setup_bdist_egg.py: little script to build an egg. Added
1601 support in the release tools as well.
1608 support in the release tools as well.
1602
1609
1603 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
1610 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
1604
1611
1605 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
1612 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
1606 version selection (new -wxversion command line and ipythonrc
1613 version selection (new -wxversion command line and ipythonrc
1607 parameter). Patch contributed by Arnd Baecker
1614 parameter). Patch contributed by Arnd Baecker
1608 <arnd.baecker-AT-web.de>.
1615 <arnd.baecker-AT-web.de>.
1609
1616
1610 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1617 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1611 embedded instances, for variables defined at the interactive
1618 embedded instances, for variables defined at the interactive
1612 prompt of the embedded ipython. Reported by Arnd.
1619 prompt of the embedded ipython. Reported by Arnd.
1613
1620
1614 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
1621 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
1615 it can be used as a (stateful) toggle, or with a direct parameter.
1622 it can be used as a (stateful) toggle, or with a direct parameter.
1616
1623
1617 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
1624 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
1618 could be triggered in certain cases and cause the traceback
1625 could be triggered in certain cases and cause the traceback
1619 printer not to work.
1626 printer not to work.
1620
1627
1621 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
1628 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
1622
1629
1623 * IPython/iplib.py (_should_recompile): Small fix, closes
1630 * IPython/iplib.py (_should_recompile): Small fix, closes
1624 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
1631 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
1625
1632
1626 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
1633 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
1627
1634
1628 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
1635 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
1629 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
1636 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
1630 Moad for help with tracking it down.
1637 Moad for help with tracking it down.
1631
1638
1632 * IPython/iplib.py (handle_auto): fix autocall handling for
1639 * IPython/iplib.py (handle_auto): fix autocall handling for
1633 objects which support BOTH __getitem__ and __call__ (so that f [x]
1640 objects which support BOTH __getitem__ and __call__ (so that f [x]
1634 is left alone, instead of becoming f([x]) automatically).
1641 is left alone, instead of becoming f([x]) automatically).
1635
1642
1636 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
1643 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
1637 Ville's patch.
1644 Ville's patch.
1638
1645
1639 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
1646 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
1640
1647
1641 * IPython/iplib.py (handle_auto): changed autocall semantics to
1648 * IPython/iplib.py (handle_auto): changed autocall semantics to
1642 include 'smart' mode, where the autocall transformation is NOT
1649 include 'smart' mode, where the autocall transformation is NOT
1643 applied if there are no arguments on the line. This allows you to
1650 applied if there are no arguments on the line. This allows you to
1644 just type 'foo' if foo is a callable to see its internal form,
1651 just type 'foo' if foo is a callable to see its internal form,
1645 instead of having it called with no arguments (typically a
1652 instead of having it called with no arguments (typically a
1646 mistake). The old 'full' autocall still exists: for that, you
1653 mistake). The old 'full' autocall still exists: for that, you
1647 need to set the 'autocall' parameter to 2 in your ipythonrc file.
1654 need to set the 'autocall' parameter to 2 in your ipythonrc file.
1648
1655
1649 * IPython/completer.py (Completer.attr_matches): add
1656 * IPython/completer.py (Completer.attr_matches): add
1650 tab-completion support for Enthoughts' traits. After a report by
1657 tab-completion support for Enthoughts' traits. After a report by
1651 Arnd and a patch by Prabhu.
1658 Arnd and a patch by Prabhu.
1652
1659
1653 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
1660 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
1654
1661
1655 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
1662 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
1656 Schmolck's patch to fix inspect.getinnerframes().
1663 Schmolck's patch to fix inspect.getinnerframes().
1657
1664
1658 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
1665 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
1659 for embedded instances, regarding handling of namespaces and items
1666 for embedded instances, regarding handling of namespaces and items
1660 added to the __builtin__ one. Multiple embedded instances and
1667 added to the __builtin__ one. Multiple embedded instances and
1661 recursive embeddings should work better now (though I'm not sure
1668 recursive embeddings should work better now (though I'm not sure
1662 I've got all the corner cases fixed, that code is a bit of a brain
1669 I've got all the corner cases fixed, that code is a bit of a brain
1663 twister).
1670 twister).
1664
1671
1665 * IPython/Magic.py (magic_edit): added support to edit in-memory
1672 * IPython/Magic.py (magic_edit): added support to edit in-memory
1666 macros (automatically creates the necessary temp files). %edit
1673 macros (automatically creates the necessary temp files). %edit
1667 also doesn't return the file contents anymore, it's just noise.
1674 also doesn't return the file contents anymore, it's just noise.
1668
1675
1669 * IPython/completer.py (Completer.attr_matches): revert change to
1676 * IPython/completer.py (Completer.attr_matches): revert change to
1670 complete only on attributes listed in __all__. I realized it
1677 complete only on attributes listed in __all__. I realized it
1671 cripples the tab-completion system as a tool for exploring the
1678 cripples the tab-completion system as a tool for exploring the
1672 internals of unknown libraries (it renders any non-__all__
1679 internals of unknown libraries (it renders any non-__all__
1673 attribute off-limits). I got bit by this when trying to see
1680 attribute off-limits). I got bit by this when trying to see
1674 something inside the dis module.
1681 something inside the dis module.
1675
1682
1676 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
1683 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
1677
1684
1678 * IPython/iplib.py (InteractiveShell.__init__): add .meta
1685 * IPython/iplib.py (InteractiveShell.__init__): add .meta
1679 namespace for users and extension writers to hold data in. This
1686 namespace for users and extension writers to hold data in. This
1680 follows the discussion in
1687 follows the discussion in
1681 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
1688 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
1682
1689
1683 * IPython/completer.py (IPCompleter.complete): small patch to help
1690 * IPython/completer.py (IPCompleter.complete): small patch to help
1684 tab-completion under Emacs, after a suggestion by John Barnard
1691 tab-completion under Emacs, after a suggestion by John Barnard
1685 <barnarj-AT-ccf.org>.
1692 <barnarj-AT-ccf.org>.
1686
1693
1687 * IPython/Magic.py (Magic.extract_input_slices): added support for
1694 * IPython/Magic.py (Magic.extract_input_slices): added support for
1688 the slice notation in magics to use N-M to represent numbers N...M
1695 the slice notation in magics to use N-M to represent numbers N...M
1689 (closed endpoints). This is used by %macro and %save.
1696 (closed endpoints). This is used by %macro and %save.
1690
1697
1691 * IPython/completer.py (Completer.attr_matches): for modules which
1698 * IPython/completer.py (Completer.attr_matches): for modules which
1692 define __all__, complete only on those. After a patch by Jeffrey
1699 define __all__, complete only on those. After a patch by Jeffrey
1693 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
1700 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
1694 speed up this routine.
1701 speed up this routine.
1695
1702
1696 * IPython/Logger.py (Logger.log): fix a history handling bug. I
1703 * IPython/Logger.py (Logger.log): fix a history handling bug. I
1697 don't know if this is the end of it, but the behavior now is
1704 don't know if this is the end of it, but the behavior now is
1698 certainly much more correct. Note that coupled with macros,
1705 certainly much more correct. Note that coupled with macros,
1699 slightly surprising (at first) behavior may occur: a macro will in
1706 slightly surprising (at first) behavior may occur: a macro will in
1700 general expand to multiple lines of input, so upon exiting, the
1707 general expand to multiple lines of input, so upon exiting, the
1701 in/out counters will both be bumped by the corresponding amount
1708 in/out counters will both be bumped by the corresponding amount
1702 (as if the macro's contents had been typed interactively). Typing
1709 (as if the macro's contents had been typed interactively). Typing
1703 %hist will reveal the intermediate (silently processed) lines.
1710 %hist will reveal the intermediate (silently processed) lines.
1704
1711
1705 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
1712 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
1706 pickle to fail (%run was overwriting __main__ and not restoring
1713 pickle to fail (%run was overwriting __main__ and not restoring
1707 it, but pickle relies on __main__ to operate).
1714 it, but pickle relies on __main__ to operate).
1708
1715
1709 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
1716 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
1710 using properties, but forgot to make the main InteractiveShell
1717 using properties, but forgot to make the main InteractiveShell
1711 class a new-style class. Properties fail silently, and
1718 class a new-style class. Properties fail silently, and
1712 mysteriously, with old-style class (getters work, but
1719 mysteriously, with old-style class (getters work, but
1713 setters don't do anything).
1720 setters don't do anything).
1714
1721
1715 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
1722 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
1716
1723
1717 * IPython/Magic.py (magic_history): fix history reporting bug (I
1724 * IPython/Magic.py (magic_history): fix history reporting bug (I
1718 know some nasties are still there, I just can't seem to find a
1725 know some nasties are still there, I just can't seem to find a
1719 reproducible test case to track them down; the input history is
1726 reproducible test case to track them down; the input history is
1720 falling out of sync...)
1727 falling out of sync...)
1721
1728
1722 * IPython/iplib.py (handle_shell_escape): fix bug where both
1729 * IPython/iplib.py (handle_shell_escape): fix bug where both
1723 aliases and system accesses where broken for indented code (such
1730 aliases and system accesses where broken for indented code (such
1724 as loops).
1731 as loops).
1725
1732
1726 * IPython/genutils.py (shell): fix small but critical bug for
1733 * IPython/genutils.py (shell): fix small but critical bug for
1727 win32 system access.
1734 win32 system access.
1728
1735
1729 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
1736 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
1730
1737
1731 * IPython/iplib.py (showtraceback): remove use of the
1738 * IPython/iplib.py (showtraceback): remove use of the
1732 sys.last_{type/value/traceback} structures, which are non
1739 sys.last_{type/value/traceback} structures, which are non
1733 thread-safe.
1740 thread-safe.
1734 (_prefilter): change control flow to ensure that we NEVER
1741 (_prefilter): change control flow to ensure that we NEVER
1735 introspect objects when autocall is off. This will guarantee that
1742 introspect objects when autocall is off. This will guarantee that
1736 having an input line of the form 'x.y', where access to attribute
1743 having an input line of the form 'x.y', where access to attribute
1737 'y' has side effects, doesn't trigger the side effect TWICE. It
1744 'y' has side effects, doesn't trigger the side effect TWICE. It
1738 is important to note that, with autocall on, these side effects
1745 is important to note that, with autocall on, these side effects
1739 can still happen.
1746 can still happen.
1740 (ipsystem): new builtin, to complete the ip{magic/alias/system}
1747 (ipsystem): new builtin, to complete the ip{magic/alias/system}
1741 trio. IPython offers these three kinds of special calls which are
1748 trio. IPython offers these three kinds of special calls which are
1742 not python code, and it's a good thing to have their call method
1749 not python code, and it's a good thing to have their call method
1743 be accessible as pure python functions (not just special syntax at
1750 be accessible as pure python functions (not just special syntax at
1744 the command line). It gives us a better internal implementation
1751 the command line). It gives us a better internal implementation
1745 structure, as well as exposing these for user scripting more
1752 structure, as well as exposing these for user scripting more
1746 cleanly.
1753 cleanly.
1747
1754
1748 * IPython/macro.py (Macro.__init__): moved macros to a standalone
1755 * IPython/macro.py (Macro.__init__): moved macros to a standalone
1749 file. Now that they'll be more likely to be used with the
1756 file. Now that they'll be more likely to be used with the
1750 persistance system (%store), I want to make sure their module path
1757 persistance system (%store), I want to make sure their module path
1751 doesn't change in the future, so that we don't break things for
1758 doesn't change in the future, so that we don't break things for
1752 users' persisted data.
1759 users' persisted data.
1753
1760
1754 * IPython/iplib.py (autoindent_update): move indentation
1761 * IPython/iplib.py (autoindent_update): move indentation
1755 management into the _text_ processing loop, not the keyboard
1762 management into the _text_ processing loop, not the keyboard
1756 interactive one. This is necessary to correctly process non-typed
1763 interactive one. This is necessary to correctly process non-typed
1757 multiline input (such as macros).
1764 multiline input (such as macros).
1758
1765
1759 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
1766 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
1760 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
1767 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
1761 which was producing problems in the resulting manual.
1768 which was producing problems in the resulting manual.
1762 (magic_whos): improve reporting of instances (show their class,
1769 (magic_whos): improve reporting of instances (show their class,
1763 instead of simply printing 'instance' which isn't terribly
1770 instead of simply printing 'instance' which isn't terribly
1764 informative).
1771 informative).
1765
1772
1766 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
1773 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
1767 (minor mods) to support network shares under win32.
1774 (minor mods) to support network shares under win32.
1768
1775
1769 * IPython/winconsole.py (get_console_size): add new winconsole
1776 * IPython/winconsole.py (get_console_size): add new winconsole
1770 module and fixes to page_dumb() to improve its behavior under
1777 module and fixes to page_dumb() to improve its behavior under
1771 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
1778 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
1772
1779
1773 * IPython/Magic.py (Macro): simplified Macro class to just
1780 * IPython/Magic.py (Macro): simplified Macro class to just
1774 subclass list. We've had only 2.2 compatibility for a very long
1781 subclass list. We've had only 2.2 compatibility for a very long
1775 time, yet I was still avoiding subclassing the builtin types. No
1782 time, yet I was still avoiding subclassing the builtin types. No
1776 more (I'm also starting to use properties, though I won't shift to
1783 more (I'm also starting to use properties, though I won't shift to
1777 2.3-specific features quite yet).
1784 2.3-specific features quite yet).
1778 (magic_store): added Ville's patch for lightweight variable
1785 (magic_store): added Ville's patch for lightweight variable
1779 persistence, after a request on the user list by Matt Wilkie
1786 persistence, after a request on the user list by Matt Wilkie
1780 <maphew-AT-gmail.com>. The new %store magic's docstring has full
1787 <maphew-AT-gmail.com>. The new %store magic's docstring has full
1781 details.
1788 details.
1782
1789
1783 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1790 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1784 changed the default logfile name from 'ipython.log' to
1791 changed the default logfile name from 'ipython.log' to
1785 'ipython_log.py'. These logs are real python files, and now that
1792 'ipython_log.py'. These logs are real python files, and now that
1786 we have much better multiline support, people are more likely to
1793 we have much better multiline support, people are more likely to
1787 want to use them as such. Might as well name them correctly.
1794 want to use them as such. Might as well name them correctly.
1788
1795
1789 * IPython/Magic.py: substantial cleanup. While we can't stop
1796 * IPython/Magic.py: substantial cleanup. While we can't stop
1790 using magics as mixins, due to the existing customizations 'out
1797 using magics as mixins, due to the existing customizations 'out
1791 there' which rely on the mixin naming conventions, at least I
1798 there' which rely on the mixin naming conventions, at least I
1792 cleaned out all cross-class name usage. So once we are OK with
1799 cleaned out all cross-class name usage. So once we are OK with
1793 breaking compatibility, the two systems can be separated.
1800 breaking compatibility, the two systems can be separated.
1794
1801
1795 * IPython/Logger.py: major cleanup. This one is NOT a mixin
1802 * IPython/Logger.py: major cleanup. This one is NOT a mixin
1796 anymore, and the class is a fair bit less hideous as well. New
1803 anymore, and the class is a fair bit less hideous as well. New
1797 features were also introduced: timestamping of input, and logging
1804 features were also introduced: timestamping of input, and logging
1798 of output results. These are user-visible with the -t and -o
1805 of output results. These are user-visible with the -t and -o
1799 options to %logstart. Closes
1806 options to %logstart. Closes
1800 http://www.scipy.net/roundup/ipython/issue11 and a request by
1807 http://www.scipy.net/roundup/ipython/issue11 and a request by
1801 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
1808 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
1802
1809
1803 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
1810 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
1804
1811
1805 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
1812 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
1806 better handle backslashes in paths. See the thread 'More Windows
1813 better handle backslashes in paths. See the thread 'More Windows
1807 questions part 2 - \/ characters revisited' on the iypthon user
1814 questions part 2 - \/ characters revisited' on the iypthon user
1808 list:
1815 list:
1809 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
1816 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
1810
1817
1811 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
1818 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
1812
1819
1813 (InteractiveShell.__init__): change threaded shells to not use the
1820 (InteractiveShell.__init__): change threaded shells to not use the
1814 ipython crash handler. This was causing more problems than not,
1821 ipython crash handler. This was causing more problems than not,
1815 as exceptions in the main thread (GUI code, typically) would
1822 as exceptions in the main thread (GUI code, typically) would
1816 always show up as a 'crash', when they really weren't.
1823 always show up as a 'crash', when they really weren't.
1817
1824
1818 The colors and exception mode commands (%colors/%xmode) have been
1825 The colors and exception mode commands (%colors/%xmode) have been
1819 synchronized to also take this into account, so users can get
1826 synchronized to also take this into account, so users can get
1820 verbose exceptions for their threaded code as well. I also added
1827 verbose exceptions for their threaded code as well. I also added
1821 support for activating pdb inside this exception handler as well,
1828 support for activating pdb inside this exception handler as well,
1822 so now GUI authors can use IPython's enhanced pdb at runtime.
1829 so now GUI authors can use IPython's enhanced pdb at runtime.
1823
1830
1824 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
1831 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
1825 true by default, and add it to the shipped ipythonrc file. Since
1832 true by default, and add it to the shipped ipythonrc file. Since
1826 this asks the user before proceeding, I think it's OK to make it
1833 this asks the user before proceeding, I think it's OK to make it
1827 true by default.
1834 true by default.
1828
1835
1829 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
1836 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
1830 of the previous special-casing of input in the eval loop. I think
1837 of the previous special-casing of input in the eval loop. I think
1831 this is cleaner, as they really are commands and shouldn't have
1838 this is cleaner, as they really are commands and shouldn't have
1832 a special role in the middle of the core code.
1839 a special role in the middle of the core code.
1833
1840
1834 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
1841 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
1835
1842
1836 * IPython/iplib.py (edit_syntax_error): added support for
1843 * IPython/iplib.py (edit_syntax_error): added support for
1837 automatically reopening the editor if the file had a syntax error
1844 automatically reopening the editor if the file had a syntax error
1838 in it. Thanks to scottt who provided the patch at:
1845 in it. Thanks to scottt who provided the patch at:
1839 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
1846 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
1840 version committed).
1847 version committed).
1841
1848
1842 * IPython/iplib.py (handle_normal): add suport for multi-line
1849 * IPython/iplib.py (handle_normal): add suport for multi-line
1843 input with emtpy lines. This fixes
1850 input with emtpy lines. This fixes
1844 http://www.scipy.net/roundup/ipython/issue43 and a similar
1851 http://www.scipy.net/roundup/ipython/issue43 and a similar
1845 discussion on the user list.
1852 discussion on the user list.
1846
1853
1847 WARNING: a behavior change is necessarily introduced to support
1854 WARNING: a behavior change is necessarily introduced to support
1848 blank lines: now a single blank line with whitespace does NOT
1855 blank lines: now a single blank line with whitespace does NOT
1849 break the input loop, which means that when autoindent is on, by
1856 break the input loop, which means that when autoindent is on, by
1850 default hitting return on the next (indented) line does NOT exit.
1857 default hitting return on the next (indented) line does NOT exit.
1851
1858
1852 Instead, to exit a multiline input you can either have:
1859 Instead, to exit a multiline input you can either have:
1853
1860
1854 - TWO whitespace lines (just hit return again), or
1861 - TWO whitespace lines (just hit return again), or
1855 - a single whitespace line of a different length than provided
1862 - a single whitespace line of a different length than provided
1856 by the autoindent (add or remove a space).
1863 by the autoindent (add or remove a space).
1857
1864
1858 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
1865 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
1859 module to better organize all readline-related functionality.
1866 module to better organize all readline-related functionality.
1860 I've deleted FlexCompleter and put all completion clases here.
1867 I've deleted FlexCompleter and put all completion clases here.
1861
1868
1862 * IPython/iplib.py (raw_input): improve indentation management.
1869 * IPython/iplib.py (raw_input): improve indentation management.
1863 It is now possible to paste indented code with autoindent on, and
1870 It is now possible to paste indented code with autoindent on, and
1864 the code is interpreted correctly (though it still looks bad on
1871 the code is interpreted correctly (though it still looks bad on
1865 screen, due to the line-oriented nature of ipython).
1872 screen, due to the line-oriented nature of ipython).
1866 (MagicCompleter.complete): change behavior so that a TAB key on an
1873 (MagicCompleter.complete): change behavior so that a TAB key on an
1867 otherwise empty line actually inserts a tab, instead of completing
1874 otherwise empty line actually inserts a tab, instead of completing
1868 on the entire global namespace. This makes it easier to use the
1875 on the entire global namespace. This makes it easier to use the
1869 TAB key for indentation. After a request by Hans Meine
1876 TAB key for indentation. After a request by Hans Meine
1870 <hans_meine-AT-gmx.net>
1877 <hans_meine-AT-gmx.net>
1871 (_prefilter): add support so that typing plain 'exit' or 'quit'
1878 (_prefilter): add support so that typing plain 'exit' or 'quit'
1872 does a sensible thing. Originally I tried to deviate as little as
1879 does a sensible thing. Originally I tried to deviate as little as
1873 possible from the default python behavior, but even that one may
1880 possible from the default python behavior, but even that one may
1874 change in this direction (thread on python-dev to that effect).
1881 change in this direction (thread on python-dev to that effect).
1875 Regardless, ipython should do the right thing even if CPython's
1882 Regardless, ipython should do the right thing even if CPython's
1876 '>>>' prompt doesn't.
1883 '>>>' prompt doesn't.
1877 (InteractiveShell): removed subclassing code.InteractiveConsole
1884 (InteractiveShell): removed subclassing code.InteractiveConsole
1878 class. By now we'd overridden just about all of its methods: I've
1885 class. By now we'd overridden just about all of its methods: I've
1879 copied the remaining two over, and now ipython is a standalone
1886 copied the remaining two over, and now ipython is a standalone
1880 class. This will provide a clearer picture for the chainsaw
1887 class. This will provide a clearer picture for the chainsaw
1881 branch refactoring.
1888 branch refactoring.
1882
1889
1883 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
1890 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
1884
1891
1885 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
1892 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
1886 failures for objects which break when dir() is called on them.
1893 failures for objects which break when dir() is called on them.
1887
1894
1888 * IPython/FlexCompleter.py (Completer.__init__): Added support for
1895 * IPython/FlexCompleter.py (Completer.__init__): Added support for
1889 distinct local and global namespaces in the completer API. This
1896 distinct local and global namespaces in the completer API. This
1890 change allows us to properly handle completion with distinct
1897 change allows us to properly handle completion with distinct
1891 scopes, including in embedded instances (this had never really
1898 scopes, including in embedded instances (this had never really
1892 worked correctly).
1899 worked correctly).
1893
1900
1894 Note: this introduces a change in the constructor for
1901 Note: this introduces a change in the constructor for
1895 MagicCompleter, as a new global_namespace parameter is now the
1902 MagicCompleter, as a new global_namespace parameter is now the
1896 second argument (the others were bumped one position).
1903 second argument (the others were bumped one position).
1897
1904
1898 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
1905 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
1899
1906
1900 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1907 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1901 embedded instances (which can be done now thanks to Vivian's
1908 embedded instances (which can be done now thanks to Vivian's
1902 frame-handling fixes for pdb).
1909 frame-handling fixes for pdb).
1903 (InteractiveShell.__init__): Fix namespace handling problem in
1910 (InteractiveShell.__init__): Fix namespace handling problem in
1904 embedded instances. We were overwriting __main__ unconditionally,
1911 embedded instances. We were overwriting __main__ unconditionally,
1905 and this should only be done for 'full' (non-embedded) IPython;
1912 and this should only be done for 'full' (non-embedded) IPython;
1906 embedded instances must respect the caller's __main__. Thanks to
1913 embedded instances must respect the caller's __main__. Thanks to
1907 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
1914 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
1908
1915
1909 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
1916 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
1910
1917
1911 * setup.py: added download_url to setup(). This registers the
1918 * setup.py: added download_url to setup(). This registers the
1912 download address at PyPI, which is not only useful to humans
1919 download address at PyPI, which is not only useful to humans
1913 browsing the site, but is also picked up by setuptools (the Eggs
1920 browsing the site, but is also picked up by setuptools (the Eggs
1914 machinery). Thanks to Ville and R. Kern for the info/discussion
1921 machinery). Thanks to Ville and R. Kern for the info/discussion
1915 on this.
1922 on this.
1916
1923
1917 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
1924 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
1918
1925
1919 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
1926 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
1920 This brings a lot of nice functionality to the pdb mode, which now
1927 This brings a lot of nice functionality to the pdb mode, which now
1921 has tab-completion, syntax highlighting, and better stack handling
1928 has tab-completion, syntax highlighting, and better stack handling
1922 than before. Many thanks to Vivian De Smedt
1929 than before. Many thanks to Vivian De Smedt
1923 <vivian-AT-vdesmedt.com> for the original patches.
1930 <vivian-AT-vdesmedt.com> for the original patches.
1924
1931
1925 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
1932 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
1926
1933
1927 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
1934 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
1928 sequence to consistently accept the banner argument. The
1935 sequence to consistently accept the banner argument. The
1929 inconsistency was tripping SAGE, thanks to Gary Zablackis
1936 inconsistency was tripping SAGE, thanks to Gary Zablackis
1930 <gzabl-AT-yahoo.com> for the report.
1937 <gzabl-AT-yahoo.com> for the report.
1931
1938
1932 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1939 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1933
1940
1934 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1941 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1935 Fix bug where a naked 'alias' call in the ipythonrc file would
1942 Fix bug where a naked 'alias' call in the ipythonrc file would
1936 cause a crash. Bug reported by Jorgen Stenarson.
1943 cause a crash. Bug reported by Jorgen Stenarson.
1937
1944
1938 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1945 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
1939
1946
1940 * IPython/ipmaker.py (make_IPython): cleanups which should improve
1947 * IPython/ipmaker.py (make_IPython): cleanups which should improve
1941 startup time.
1948 startup time.
1942
1949
1943 * IPython/iplib.py (runcode): my globals 'fix' for embedded
1950 * IPython/iplib.py (runcode): my globals 'fix' for embedded
1944 instances had introduced a bug with globals in normal code. Now
1951 instances had introduced a bug with globals in normal code. Now
1945 it's working in all cases.
1952 it's working in all cases.
1946
1953
1947 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
1954 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
1948 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
1955 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
1949 has been introduced to set the default case sensitivity of the
1956 has been introduced to set the default case sensitivity of the
1950 searches. Users can still select either mode at runtime on a
1957 searches. Users can still select either mode at runtime on a
1951 per-search basis.
1958 per-search basis.
1952
1959
1953 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
1960 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
1954
1961
1955 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
1962 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
1956 attributes in wildcard searches for subclasses. Modified version
1963 attributes in wildcard searches for subclasses. Modified version
1957 of a patch by Jorgen.
1964 of a patch by Jorgen.
1958
1965
1959 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
1966 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
1960
1967
1961 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
1968 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
1962 embedded instances. I added a user_global_ns attribute to the
1969 embedded instances. I added a user_global_ns attribute to the
1963 InteractiveShell class to handle this.
1970 InteractiveShell class to handle this.
1964
1971
1965 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
1972 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
1966
1973
1967 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
1974 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
1968 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
1975 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
1969 (reported under win32, but may happen also in other platforms).
1976 (reported under win32, but may happen also in other platforms).
1970 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
1977 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
1971
1978
1972 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
1979 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
1973
1980
1974 * IPython/Magic.py (magic_psearch): new support for wildcard
1981 * IPython/Magic.py (magic_psearch): new support for wildcard
1975 patterns. Now, typing ?a*b will list all names which begin with a
1982 patterns. Now, typing ?a*b will list all names which begin with a
1976 and end in b, for example. The %psearch magic has full
1983 and end in b, for example. The %psearch magic has full
1977 docstrings. Many thanks to JΓΆrgen Stenarson
1984 docstrings. Many thanks to JΓΆrgen Stenarson
1978 <jorgen.stenarson-AT-bostream.nu>, author of the patches
1985 <jorgen.stenarson-AT-bostream.nu>, author of the patches
1979 implementing this functionality.
1986 implementing this functionality.
1980
1987
1981 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1988 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1982
1989
1983 * Manual: fixed long-standing annoyance of double-dashes (as in
1990 * Manual: fixed long-standing annoyance of double-dashes (as in
1984 --prefix=~, for example) being stripped in the HTML version. This
1991 --prefix=~, for example) being stripped in the HTML version. This
1985 is a latex2html bug, but a workaround was provided. Many thanks
1992 is a latex2html bug, but a workaround was provided. Many thanks
1986 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
1993 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
1987 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
1994 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
1988 rolling. This seemingly small issue had tripped a number of users
1995 rolling. This seemingly small issue had tripped a number of users
1989 when first installing, so I'm glad to see it gone.
1996 when first installing, so I'm glad to see it gone.
1990
1997
1991 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1998 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
1992
1999
1993 * IPython/Extensions/numeric_formats.py: fix missing import,
2000 * IPython/Extensions/numeric_formats.py: fix missing import,
1994 reported by Stephen Walton.
2001 reported by Stephen Walton.
1995
2002
1996 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
2003 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
1997
2004
1998 * IPython/demo.py: finish demo module, fully documented now.
2005 * IPython/demo.py: finish demo module, fully documented now.
1999
2006
2000 * IPython/genutils.py (file_read): simple little utility to read a
2007 * IPython/genutils.py (file_read): simple little utility to read a
2001 file and ensure it's closed afterwards.
2008 file and ensure it's closed afterwards.
2002
2009
2003 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
2010 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
2004
2011
2005 * IPython/demo.py (Demo.__init__): added support for individually
2012 * IPython/demo.py (Demo.__init__): added support for individually
2006 tagging blocks for automatic execution.
2013 tagging blocks for automatic execution.
2007
2014
2008 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
2015 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
2009 syntax-highlighted python sources, requested by John.
2016 syntax-highlighted python sources, requested by John.
2010
2017
2011 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
2018 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
2012
2019
2013 * IPython/demo.py (Demo.again): fix bug where again() blocks after
2020 * IPython/demo.py (Demo.again): fix bug where again() blocks after
2014 finishing.
2021 finishing.
2015
2022
2016 * IPython/genutils.py (shlex_split): moved from Magic to here,
2023 * IPython/genutils.py (shlex_split): moved from Magic to here,
2017 where all 2.2 compatibility stuff lives. I needed it for demo.py.
2024 where all 2.2 compatibility stuff lives. I needed it for demo.py.
2018
2025
2019 * IPython/demo.py (Demo.__init__): added support for silent
2026 * IPython/demo.py (Demo.__init__): added support for silent
2020 blocks, improved marks as regexps, docstrings written.
2027 blocks, improved marks as regexps, docstrings written.
2021 (Demo.__init__): better docstring, added support for sys.argv.
2028 (Demo.__init__): better docstring, added support for sys.argv.
2022
2029
2023 * IPython/genutils.py (marquee): little utility used by the demo
2030 * IPython/genutils.py (marquee): little utility used by the demo
2024 code, handy in general.
2031 code, handy in general.
2025
2032
2026 * IPython/demo.py (Demo.__init__): new class for interactive
2033 * IPython/demo.py (Demo.__init__): new class for interactive
2027 demos. Not documented yet, I just wrote it in a hurry for
2034 demos. Not documented yet, I just wrote it in a hurry for
2028 scipy'05. Will docstring later.
2035 scipy'05. Will docstring later.
2029
2036
2030 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
2037 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
2031
2038
2032 * IPython/Shell.py (sigint_handler): Drastic simplification which
2039 * IPython/Shell.py (sigint_handler): Drastic simplification which
2033 also seems to make Ctrl-C work correctly across threads! This is
2040 also seems to make Ctrl-C work correctly across threads! This is
2034 so simple, that I can't beleive I'd missed it before. Needs more
2041 so simple, that I can't beleive I'd missed it before. Needs more
2035 testing, though.
2042 testing, though.
2036 (KBINT): Never mind, revert changes. I'm sure I'd tried something
2043 (KBINT): Never mind, revert changes. I'm sure I'd tried something
2037 like this before...
2044 like this before...
2038
2045
2039 * IPython/genutils.py (get_home_dir): add protection against
2046 * IPython/genutils.py (get_home_dir): add protection against
2040 non-dirs in win32 registry.
2047 non-dirs in win32 registry.
2041
2048
2042 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
2049 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
2043 bug where dict was mutated while iterating (pysh crash).
2050 bug where dict was mutated while iterating (pysh crash).
2044
2051
2045 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
2052 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
2046
2053
2047 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
2054 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
2048 spurious newlines added by this routine. After a report by
2055 spurious newlines added by this routine. After a report by
2049 F. Mantegazza.
2056 F. Mantegazza.
2050
2057
2051 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
2058 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
2052
2059
2053 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
2060 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
2054 calls. These were a leftover from the GTK 1.x days, and can cause
2061 calls. These were a leftover from the GTK 1.x days, and can cause
2055 problems in certain cases (after a report by John Hunter).
2062 problems in certain cases (after a report by John Hunter).
2056
2063
2057 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
2064 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
2058 os.getcwd() fails at init time. Thanks to patch from David Remahl
2065 os.getcwd() fails at init time. Thanks to patch from David Remahl
2059 <chmod007-AT-mac.com>.
2066 <chmod007-AT-mac.com>.
2060 (InteractiveShell.__init__): prevent certain special magics from
2067 (InteractiveShell.__init__): prevent certain special magics from
2061 being shadowed by aliases. Closes
2068 being shadowed by aliases. Closes
2062 http://www.scipy.net/roundup/ipython/issue41.
2069 http://www.scipy.net/roundup/ipython/issue41.
2063
2070
2064 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
2071 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
2065
2072
2066 * IPython/iplib.py (InteractiveShell.complete): Added new
2073 * IPython/iplib.py (InteractiveShell.complete): Added new
2067 top-level completion method to expose the completion mechanism
2074 top-level completion method to expose the completion mechanism
2068 beyond readline-based environments.
2075 beyond readline-based environments.
2069
2076
2070 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
2077 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
2071
2078
2072 * tools/ipsvnc (svnversion): fix svnversion capture.
2079 * tools/ipsvnc (svnversion): fix svnversion capture.
2073
2080
2074 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
2081 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
2075 attribute to self, which was missing. Before, it was set by a
2082 attribute to self, which was missing. Before, it was set by a
2076 routine which in certain cases wasn't being called, so the
2083 routine which in certain cases wasn't being called, so the
2077 instance could end up missing the attribute. This caused a crash.
2084 instance could end up missing the attribute. This caused a crash.
2078 Closes http://www.scipy.net/roundup/ipython/issue40.
2085 Closes http://www.scipy.net/roundup/ipython/issue40.
2079
2086
2080 2005-08-16 Fernando Perez <fperez@colorado.edu>
2087 2005-08-16 Fernando Perez <fperez@colorado.edu>
2081
2088
2082 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
2089 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
2083 contains non-string attribute. Closes
2090 contains non-string attribute. Closes
2084 http://www.scipy.net/roundup/ipython/issue38.
2091 http://www.scipy.net/roundup/ipython/issue38.
2085
2092
2086 2005-08-14 Fernando Perez <fperez@colorado.edu>
2093 2005-08-14 Fernando Perez <fperez@colorado.edu>
2087
2094
2088 * tools/ipsvnc: Minor improvements, to add changeset info.
2095 * tools/ipsvnc: Minor improvements, to add changeset info.
2089
2096
2090 2005-08-12 Fernando Perez <fperez@colorado.edu>
2097 2005-08-12 Fernando Perez <fperez@colorado.edu>
2091
2098
2092 * IPython/iplib.py (runsource): remove self.code_to_run_src
2099 * IPython/iplib.py (runsource): remove self.code_to_run_src
2093 attribute. I realized this is nothing more than
2100 attribute. I realized this is nothing more than
2094 '\n'.join(self.buffer), and having the same data in two different
2101 '\n'.join(self.buffer), and having the same data in two different
2095 places is just asking for synchronization bugs. This may impact
2102 places is just asking for synchronization bugs. This may impact
2096 people who have custom exception handlers, so I need to warn
2103 people who have custom exception handlers, so I need to warn
2097 ipython-dev about it (F. Mantegazza may use them).
2104 ipython-dev about it (F. Mantegazza may use them).
2098
2105
2099 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
2106 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
2100
2107
2101 * IPython/genutils.py: fix 2.2 compatibility (generators)
2108 * IPython/genutils.py: fix 2.2 compatibility (generators)
2102
2109
2103 2005-07-18 Fernando Perez <fperez@colorado.edu>
2110 2005-07-18 Fernando Perez <fperez@colorado.edu>
2104
2111
2105 * IPython/genutils.py (get_home_dir): fix to help users with
2112 * IPython/genutils.py (get_home_dir): fix to help users with
2106 invalid $HOME under win32.
2113 invalid $HOME under win32.
2107
2114
2108 2005-07-17 Fernando Perez <fperez@colorado.edu>
2115 2005-07-17 Fernando Perez <fperez@colorado.edu>
2109
2116
2110 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
2117 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
2111 some old hacks and clean up a bit other routines; code should be
2118 some old hacks and clean up a bit other routines; code should be
2112 simpler and a bit faster.
2119 simpler and a bit faster.
2113
2120
2114 * IPython/iplib.py (interact): removed some last-resort attempts
2121 * IPython/iplib.py (interact): removed some last-resort attempts
2115 to survive broken stdout/stderr. That code was only making it
2122 to survive broken stdout/stderr. That code was only making it
2116 harder to abstract out the i/o (necessary for gui integration),
2123 harder to abstract out the i/o (necessary for gui integration),
2117 and the crashes it could prevent were extremely rare in practice
2124 and the crashes it could prevent were extremely rare in practice
2118 (besides being fully user-induced in a pretty violent manner).
2125 (besides being fully user-induced in a pretty violent manner).
2119
2126
2120 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
2127 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
2121 Nothing major yet, but the code is simpler to read; this should
2128 Nothing major yet, but the code is simpler to read; this should
2122 make it easier to do more serious modifications in the future.
2129 make it easier to do more serious modifications in the future.
2123
2130
2124 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
2131 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
2125 which broke in .15 (thanks to a report by Ville).
2132 which broke in .15 (thanks to a report by Ville).
2126
2133
2127 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
2134 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
2128 be quite correct, I know next to nothing about unicode). This
2135 be quite correct, I know next to nothing about unicode). This
2129 will allow unicode strings to be used in prompts, amongst other
2136 will allow unicode strings to be used in prompts, amongst other
2130 cases. It also will prevent ipython from crashing when unicode
2137 cases. It also will prevent ipython from crashing when unicode
2131 shows up unexpectedly in many places. If ascii encoding fails, we
2138 shows up unexpectedly in many places. If ascii encoding fails, we
2132 assume utf_8. Currently the encoding is not a user-visible
2139 assume utf_8. Currently the encoding is not a user-visible
2133 setting, though it could be made so if there is demand for it.
2140 setting, though it could be made so if there is demand for it.
2134
2141
2135 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
2142 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
2136
2143
2137 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
2144 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
2138
2145
2139 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
2146 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
2140
2147
2141 * IPython/genutils.py: Add 2.2 compatibility here, so all other
2148 * IPython/genutils.py: Add 2.2 compatibility here, so all other
2142 code can work transparently for 2.2/2.3.
2149 code can work transparently for 2.2/2.3.
2143
2150
2144 2005-07-16 Fernando Perez <fperez@colorado.edu>
2151 2005-07-16 Fernando Perez <fperez@colorado.edu>
2145
2152
2146 * IPython/ultraTB.py (ExceptionColors): Make a global variable
2153 * IPython/ultraTB.py (ExceptionColors): Make a global variable
2147 out of the color scheme table used for coloring exception
2154 out of the color scheme table used for coloring exception
2148 tracebacks. This allows user code to add new schemes at runtime.
2155 tracebacks. This allows user code to add new schemes at runtime.
2149 This is a minimally modified version of the patch at
2156 This is a minimally modified version of the patch at
2150 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
2157 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
2151 for the contribution.
2158 for the contribution.
2152
2159
2153 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
2160 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
2154 slightly modified version of the patch in
2161 slightly modified version of the patch in
2155 http://www.scipy.net/roundup/ipython/issue34, which also allows me
2162 http://www.scipy.net/roundup/ipython/issue34, which also allows me
2156 to remove the previous try/except solution (which was costlier).
2163 to remove the previous try/except solution (which was costlier).
2157 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
2164 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
2158
2165
2159 2005-06-08 Fernando Perez <fperez@colorado.edu>
2166 2005-06-08 Fernando Perez <fperez@colorado.edu>
2160
2167
2161 * IPython/iplib.py (write/write_err): Add methods to abstract all
2168 * IPython/iplib.py (write/write_err): Add methods to abstract all
2162 I/O a bit more.
2169 I/O a bit more.
2163
2170
2164 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
2171 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
2165 warning, reported by Aric Hagberg, fix by JD Hunter.
2172 warning, reported by Aric Hagberg, fix by JD Hunter.
2166
2173
2167 2005-06-02 *** Released version 0.6.15
2174 2005-06-02 *** Released version 0.6.15
2168
2175
2169 2005-06-01 Fernando Perez <fperez@colorado.edu>
2176 2005-06-01 Fernando Perez <fperez@colorado.edu>
2170
2177
2171 * IPython/iplib.py (MagicCompleter.file_matches): Fix
2178 * IPython/iplib.py (MagicCompleter.file_matches): Fix
2172 tab-completion of filenames within open-quoted strings. Note that
2179 tab-completion of filenames within open-quoted strings. Note that
2173 this requires that in ~/.ipython/ipythonrc, users change the
2180 this requires that in ~/.ipython/ipythonrc, users change the
2174 readline delimiters configuration to read:
2181 readline delimiters configuration to read:
2175
2182
2176 readline_remove_delims -/~
2183 readline_remove_delims -/~
2177
2184
2178
2185
2179 2005-05-31 *** Released version 0.6.14
2186 2005-05-31 *** Released version 0.6.14
2180
2187
2181 2005-05-29 Fernando Perez <fperez@colorado.edu>
2188 2005-05-29 Fernando Perez <fperez@colorado.edu>
2182
2189
2183 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
2190 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
2184 with files not on the filesystem. Reported by Eliyahu Sandler
2191 with files not on the filesystem. Reported by Eliyahu Sandler
2185 <eli@gondolin.net>
2192 <eli@gondolin.net>
2186
2193
2187 2005-05-22 Fernando Perez <fperez@colorado.edu>
2194 2005-05-22 Fernando Perez <fperez@colorado.edu>
2188
2195
2189 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
2196 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
2190 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
2197 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
2191
2198
2192 2005-05-19 Fernando Perez <fperez@colorado.edu>
2199 2005-05-19 Fernando Perez <fperez@colorado.edu>
2193
2200
2194 * IPython/iplib.py (safe_execfile): close a file which could be
2201 * IPython/iplib.py (safe_execfile): close a file which could be
2195 left open (causing problems in win32, which locks open files).
2202 left open (causing problems in win32, which locks open files).
2196 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
2203 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
2197
2204
2198 2005-05-18 Fernando Perez <fperez@colorado.edu>
2205 2005-05-18 Fernando Perez <fperez@colorado.edu>
2199
2206
2200 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
2207 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
2201 keyword arguments correctly to safe_execfile().
2208 keyword arguments correctly to safe_execfile().
2202
2209
2203 2005-05-13 Fernando Perez <fperez@colorado.edu>
2210 2005-05-13 Fernando Perez <fperez@colorado.edu>
2204
2211
2205 * ipython.1: Added info about Qt to manpage, and threads warning
2212 * ipython.1: Added info about Qt to manpage, and threads warning
2206 to usage page (invoked with --help).
2213 to usage page (invoked with --help).
2207
2214
2208 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
2215 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
2209 new matcher (it goes at the end of the priority list) to do
2216 new matcher (it goes at the end of the priority list) to do
2210 tab-completion on named function arguments. Submitted by George
2217 tab-completion on named function arguments. Submitted by George
2211 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
2218 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
2212 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
2219 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
2213 for more details.
2220 for more details.
2214
2221
2215 * IPython/Magic.py (magic_run): Added new -e flag to ignore
2222 * IPython/Magic.py (magic_run): Added new -e flag to ignore
2216 SystemExit exceptions in the script being run. Thanks to a report
2223 SystemExit exceptions in the script being run. Thanks to a report
2217 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
2224 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
2218 producing very annoying behavior when running unit tests.
2225 producing very annoying behavior when running unit tests.
2219
2226
2220 2005-05-12 Fernando Perez <fperez@colorado.edu>
2227 2005-05-12 Fernando Perez <fperez@colorado.edu>
2221
2228
2222 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
2229 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
2223 which I'd broken (again) due to a changed regexp. In the process,
2230 which I'd broken (again) due to a changed regexp. In the process,
2224 added ';' as an escape to auto-quote the whole line without
2231 added ';' as an escape to auto-quote the whole line without
2225 splitting its arguments. Thanks to a report by Jerry McRae
2232 splitting its arguments. Thanks to a report by Jerry McRae
2226 <qrs0xyc02-AT-sneakemail.com>.
2233 <qrs0xyc02-AT-sneakemail.com>.
2227
2234
2228 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
2235 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
2229 possible crashes caused by a TokenError. Reported by Ed Schofield
2236 possible crashes caused by a TokenError. Reported by Ed Schofield
2230 <schofield-AT-ftw.at>.
2237 <schofield-AT-ftw.at>.
2231
2238
2232 2005-05-06 Fernando Perez <fperez@colorado.edu>
2239 2005-05-06 Fernando Perez <fperez@colorado.edu>
2233
2240
2234 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
2241 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
2235
2242
2236 2005-04-29 Fernando Perez <fperez@colorado.edu>
2243 2005-04-29 Fernando Perez <fperez@colorado.edu>
2237
2244
2238 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
2245 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
2239 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
2246 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
2240 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
2247 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
2241 which provides support for Qt interactive usage (similar to the
2248 which provides support for Qt interactive usage (similar to the
2242 existing one for WX and GTK). This had been often requested.
2249 existing one for WX and GTK). This had been often requested.
2243
2250
2244 2005-04-14 *** Released version 0.6.13
2251 2005-04-14 *** Released version 0.6.13
2245
2252
2246 2005-04-08 Fernando Perez <fperez@colorado.edu>
2253 2005-04-08 Fernando Perez <fperez@colorado.edu>
2247
2254
2248 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
2255 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
2249 from _ofind, which gets called on almost every input line. Now,
2256 from _ofind, which gets called on almost every input line. Now,
2250 we only try to get docstrings if they are actually going to be
2257 we only try to get docstrings if they are actually going to be
2251 used (the overhead of fetching unnecessary docstrings can be
2258 used (the overhead of fetching unnecessary docstrings can be
2252 noticeable for certain objects, such as Pyro proxies).
2259 noticeable for certain objects, such as Pyro proxies).
2253
2260
2254 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
2261 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
2255 for completers. For some reason I had been passing them the state
2262 for completers. For some reason I had been passing them the state
2256 variable, which completers never actually need, and was in
2263 variable, which completers never actually need, and was in
2257 conflict with the rlcompleter API. Custom completers ONLY need to
2264 conflict with the rlcompleter API. Custom completers ONLY need to
2258 take the text parameter.
2265 take the text parameter.
2259
2266
2260 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
2267 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
2261 work correctly in pysh. I've also moved all the logic which used
2268 work correctly in pysh. I've also moved all the logic which used
2262 to be in pysh.py here, which will prevent problems with future
2269 to be in pysh.py here, which will prevent problems with future
2263 upgrades. However, this time I must warn users to update their
2270 upgrades. However, this time I must warn users to update their
2264 pysh profile to include the line
2271 pysh profile to include the line
2265
2272
2266 import_all IPython.Extensions.InterpreterExec
2273 import_all IPython.Extensions.InterpreterExec
2267
2274
2268 because otherwise things won't work for them. They MUST also
2275 because otherwise things won't work for them. They MUST also
2269 delete pysh.py and the line
2276 delete pysh.py and the line
2270
2277
2271 execfile pysh.py
2278 execfile pysh.py
2272
2279
2273 from their ipythonrc-pysh.
2280 from their ipythonrc-pysh.
2274
2281
2275 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
2282 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
2276 robust in the face of objects whose dir() returns non-strings
2283 robust in the face of objects whose dir() returns non-strings
2277 (which it shouldn't, but some broken libs like ITK do). Thanks to
2284 (which it shouldn't, but some broken libs like ITK do). Thanks to
2278 a patch by John Hunter (implemented differently, though). Also
2285 a patch by John Hunter (implemented differently, though). Also
2279 minor improvements by using .extend instead of + on lists.
2286 minor improvements by using .extend instead of + on lists.
2280
2287
2281 * pysh.py:
2288 * pysh.py:
2282
2289
2283 2005-04-06 Fernando Perez <fperez@colorado.edu>
2290 2005-04-06 Fernando Perez <fperez@colorado.edu>
2284
2291
2285 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
2292 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
2286 by default, so that all users benefit from it. Those who don't
2293 by default, so that all users benefit from it. Those who don't
2287 want it can still turn it off.
2294 want it can still turn it off.
2288
2295
2289 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
2296 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
2290 config file, I'd forgotten about this, so users were getting it
2297 config file, I'd forgotten about this, so users were getting it
2291 off by default.
2298 off by default.
2292
2299
2293 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
2300 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
2294 consistency. Now magics can be called in multiline statements,
2301 consistency. Now magics can be called in multiline statements,
2295 and python variables can be expanded in magic calls via $var.
2302 and python variables can be expanded in magic calls via $var.
2296 This makes the magic system behave just like aliases or !system
2303 This makes the magic system behave just like aliases or !system
2297 calls.
2304 calls.
2298
2305
2299 2005-03-28 Fernando Perez <fperez@colorado.edu>
2306 2005-03-28 Fernando Perez <fperez@colorado.edu>
2300
2307
2301 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
2308 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
2302 expensive string additions for building command. Add support for
2309 expensive string additions for building command. Add support for
2303 trailing ';' when autocall is used.
2310 trailing ';' when autocall is used.
2304
2311
2305 2005-03-26 Fernando Perez <fperez@colorado.edu>
2312 2005-03-26 Fernando Perez <fperez@colorado.edu>
2306
2313
2307 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
2314 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
2308 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
2315 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
2309 ipython.el robust against prompts with any number of spaces
2316 ipython.el robust against prompts with any number of spaces
2310 (including 0) after the ':' character.
2317 (including 0) after the ':' character.
2311
2318
2312 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
2319 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
2313 continuation prompt, which misled users to think the line was
2320 continuation prompt, which misled users to think the line was
2314 already indented. Closes debian Bug#300847, reported to me by
2321 already indented. Closes debian Bug#300847, reported to me by
2315 Norbert Tretkowski <tretkowski-AT-inittab.de>.
2322 Norbert Tretkowski <tretkowski-AT-inittab.de>.
2316
2323
2317 2005-03-23 Fernando Perez <fperez@colorado.edu>
2324 2005-03-23 Fernando Perez <fperez@colorado.edu>
2318
2325
2319 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
2326 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
2320 properly aligned if they have embedded newlines.
2327 properly aligned if they have embedded newlines.
2321
2328
2322 * IPython/iplib.py (runlines): Add a public method to expose
2329 * IPython/iplib.py (runlines): Add a public method to expose
2323 IPython's code execution machinery, so that users can run strings
2330 IPython's code execution machinery, so that users can run strings
2324 as if they had been typed at the prompt interactively.
2331 as if they had been typed at the prompt interactively.
2325 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
2332 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
2326 methods which can call the system shell, but with python variable
2333 methods which can call the system shell, but with python variable
2327 expansion. The three such methods are: __IPYTHON__.system,
2334 expansion. The three such methods are: __IPYTHON__.system,
2328 .getoutput and .getoutputerror. These need to be documented in a
2335 .getoutput and .getoutputerror. These need to be documented in a
2329 'public API' section (to be written) of the manual.
2336 'public API' section (to be written) of the manual.
2330
2337
2331 2005-03-20 Fernando Perez <fperez@colorado.edu>
2338 2005-03-20 Fernando Perez <fperez@colorado.edu>
2332
2339
2333 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
2340 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
2334 for custom exception handling. This is quite powerful, and it
2341 for custom exception handling. This is quite powerful, and it
2335 allows for user-installable exception handlers which can trap
2342 allows for user-installable exception handlers which can trap
2336 custom exceptions at runtime and treat them separately from
2343 custom exceptions at runtime and treat them separately from
2337 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
2344 IPython's default mechanisms. At the request of FrΓ©dΓ©ric
2338 Mantegazza <mantegazza-AT-ill.fr>.
2345 Mantegazza <mantegazza-AT-ill.fr>.
2339 (InteractiveShell.set_custom_completer): public API function to
2346 (InteractiveShell.set_custom_completer): public API function to
2340 add new completers at runtime.
2347 add new completers at runtime.
2341
2348
2342 2005-03-19 Fernando Perez <fperez@colorado.edu>
2349 2005-03-19 Fernando Perez <fperez@colorado.edu>
2343
2350
2344 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
2351 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
2345 allow objects which provide their docstrings via non-standard
2352 allow objects which provide their docstrings via non-standard
2346 mechanisms (like Pyro proxies) to still be inspected by ipython's
2353 mechanisms (like Pyro proxies) to still be inspected by ipython's
2347 ? system.
2354 ? system.
2348
2355
2349 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
2356 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
2350 automatic capture system. I tried quite hard to make it work
2357 automatic capture system. I tried quite hard to make it work
2351 reliably, and simply failed. I tried many combinations with the
2358 reliably, and simply failed. I tried many combinations with the
2352 subprocess module, but eventually nothing worked in all needed
2359 subprocess module, but eventually nothing worked in all needed
2353 cases (not blocking stdin for the child, duplicating stdout
2360 cases (not blocking stdin for the child, duplicating stdout
2354 without blocking, etc). The new %sc/%sx still do capture to these
2361 without blocking, etc). The new %sc/%sx still do capture to these
2355 magical list/string objects which make shell use much more
2362 magical list/string objects which make shell use much more
2356 conveninent, so not all is lost.
2363 conveninent, so not all is lost.
2357
2364
2358 XXX - FIX MANUAL for the change above!
2365 XXX - FIX MANUAL for the change above!
2359
2366
2360 (runsource): I copied code.py's runsource() into ipython to modify
2367 (runsource): I copied code.py's runsource() into ipython to modify
2361 it a bit. Now the code object and source to be executed are
2368 it a bit. Now the code object and source to be executed are
2362 stored in ipython. This makes this info accessible to third-party
2369 stored in ipython. This makes this info accessible to third-party
2363 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
2370 tools, like custom exception handlers. After a request by FrΓ©dΓ©ric
2364 Mantegazza <mantegazza-AT-ill.fr>.
2371 Mantegazza <mantegazza-AT-ill.fr>.
2365
2372
2366 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
2373 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
2367 history-search via readline (like C-p/C-n). I'd wanted this for a
2374 history-search via readline (like C-p/C-n). I'd wanted this for a
2368 long time, but only recently found out how to do it. For users
2375 long time, but only recently found out how to do it. For users
2369 who already have their ipythonrc files made and want this, just
2376 who already have their ipythonrc files made and want this, just
2370 add:
2377 add:
2371
2378
2372 readline_parse_and_bind "\e[A": history-search-backward
2379 readline_parse_and_bind "\e[A": history-search-backward
2373 readline_parse_and_bind "\e[B": history-search-forward
2380 readline_parse_and_bind "\e[B": history-search-forward
2374
2381
2375 2005-03-18 Fernando Perez <fperez@colorado.edu>
2382 2005-03-18 Fernando Perez <fperez@colorado.edu>
2376
2383
2377 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
2384 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
2378 LSString and SList classes which allow transparent conversions
2385 LSString and SList classes which allow transparent conversions
2379 between list mode and whitespace-separated string.
2386 between list mode and whitespace-separated string.
2380 (magic_r): Fix recursion problem in %r.
2387 (magic_r): Fix recursion problem in %r.
2381
2388
2382 * IPython/genutils.py (LSString): New class to be used for
2389 * IPython/genutils.py (LSString): New class to be used for
2383 automatic storage of the results of all alias/system calls in _o
2390 automatic storage of the results of all alias/system calls in _o
2384 and _e (stdout/err). These provide a .l/.list attribute which
2391 and _e (stdout/err). These provide a .l/.list attribute which
2385 does automatic splitting on newlines. This means that for most
2392 does automatic splitting on newlines. This means that for most
2386 uses, you'll never need to do capturing of output with %sc/%sx
2393 uses, you'll never need to do capturing of output with %sc/%sx
2387 anymore, since ipython keeps this always done for you. Note that
2394 anymore, since ipython keeps this always done for you. Note that
2388 only the LAST results are stored, the _o/e variables are
2395 only the LAST results are stored, the _o/e variables are
2389 overwritten on each call. If you need to save their contents
2396 overwritten on each call. If you need to save their contents
2390 further, simply bind them to any other name.
2397 further, simply bind them to any other name.
2391
2398
2392 2005-03-17 Fernando Perez <fperez@colorado.edu>
2399 2005-03-17 Fernando Perez <fperez@colorado.edu>
2393
2400
2394 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
2401 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
2395 prompt namespace handling.
2402 prompt namespace handling.
2396
2403
2397 2005-03-16 Fernando Perez <fperez@colorado.edu>
2404 2005-03-16 Fernando Perez <fperez@colorado.edu>
2398
2405
2399 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
2406 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
2400 classic prompts to be '>>> ' (final space was missing, and it
2407 classic prompts to be '>>> ' (final space was missing, and it
2401 trips the emacs python mode).
2408 trips the emacs python mode).
2402 (BasePrompt.__str__): Added safe support for dynamic prompt
2409 (BasePrompt.__str__): Added safe support for dynamic prompt
2403 strings. Now you can set your prompt string to be '$x', and the
2410 strings. Now you can set your prompt string to be '$x', and the
2404 value of x will be printed from your interactive namespace. The
2411 value of x will be printed from your interactive namespace. The
2405 interpolation syntax includes the full Itpl support, so
2412 interpolation syntax includes the full Itpl support, so
2406 ${foo()+x+bar()} is a valid prompt string now, and the function
2413 ${foo()+x+bar()} is a valid prompt string now, and the function
2407 calls will be made at runtime.
2414 calls will be made at runtime.
2408
2415
2409 2005-03-15 Fernando Perez <fperez@colorado.edu>
2416 2005-03-15 Fernando Perez <fperez@colorado.edu>
2410
2417
2411 * IPython/Magic.py (magic_history): renamed %hist to %history, to
2418 * IPython/Magic.py (magic_history): renamed %hist to %history, to
2412 avoid name clashes in pylab. %hist still works, it just forwards
2419 avoid name clashes in pylab. %hist still works, it just forwards
2413 the call to %history.
2420 the call to %history.
2414
2421
2415 2005-03-02 *** Released version 0.6.12
2422 2005-03-02 *** Released version 0.6.12
2416
2423
2417 2005-03-02 Fernando Perez <fperez@colorado.edu>
2424 2005-03-02 Fernando Perez <fperez@colorado.edu>
2418
2425
2419 * IPython/iplib.py (handle_magic): log magic calls properly as
2426 * IPython/iplib.py (handle_magic): log magic calls properly as
2420 ipmagic() function calls.
2427 ipmagic() function calls.
2421
2428
2422 * IPython/Magic.py (magic_time): Improved %time to support
2429 * IPython/Magic.py (magic_time): Improved %time to support
2423 statements and provide wall-clock as well as CPU time.
2430 statements and provide wall-clock as well as CPU time.
2424
2431
2425 2005-02-27 Fernando Perez <fperez@colorado.edu>
2432 2005-02-27 Fernando Perez <fperez@colorado.edu>
2426
2433
2427 * IPython/hooks.py: New hooks module, to expose user-modifiable
2434 * IPython/hooks.py: New hooks module, to expose user-modifiable
2428 IPython functionality in a clean manner. For now only the editor
2435 IPython functionality in a clean manner. For now only the editor
2429 hook is actually written, and other thigns which I intend to turn
2436 hook is actually written, and other thigns which I intend to turn
2430 into proper hooks aren't yet there. The display and prefilter
2437 into proper hooks aren't yet there. The display and prefilter
2431 stuff, for example, should be hooks. But at least now the
2438 stuff, for example, should be hooks. But at least now the
2432 framework is in place, and the rest can be moved here with more
2439 framework is in place, and the rest can be moved here with more
2433 time later. IPython had had a .hooks variable for a long time for
2440 time later. IPython had had a .hooks variable for a long time for
2434 this purpose, but I'd never actually used it for anything.
2441 this purpose, but I'd never actually used it for anything.
2435
2442
2436 2005-02-26 Fernando Perez <fperez@colorado.edu>
2443 2005-02-26 Fernando Perez <fperez@colorado.edu>
2437
2444
2438 * IPython/ipmaker.py (make_IPython): make the default ipython
2445 * IPython/ipmaker.py (make_IPython): make the default ipython
2439 directory be called _ipython under win32, to follow more the
2446 directory be called _ipython under win32, to follow more the
2440 naming peculiarities of that platform (where buggy software like
2447 naming peculiarities of that platform (where buggy software like
2441 Visual Sourcesafe breaks with .named directories). Reported by
2448 Visual Sourcesafe breaks with .named directories). Reported by
2442 Ville Vainio.
2449 Ville Vainio.
2443
2450
2444 2005-02-23 Fernando Perez <fperez@colorado.edu>
2451 2005-02-23 Fernando Perez <fperez@colorado.edu>
2445
2452
2446 * IPython/iplib.py (InteractiveShell.__init__): removed a few
2453 * IPython/iplib.py (InteractiveShell.__init__): removed a few
2447 auto_aliases for win32 which were causing problems. Users can
2454 auto_aliases for win32 which were causing problems. Users can
2448 define the ones they personally like.
2455 define the ones they personally like.
2449
2456
2450 2005-02-21 Fernando Perez <fperez@colorado.edu>
2457 2005-02-21 Fernando Perez <fperez@colorado.edu>
2451
2458
2452 * IPython/Magic.py (magic_time): new magic to time execution of
2459 * IPython/Magic.py (magic_time): new magic to time execution of
2453 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
2460 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
2454
2461
2455 2005-02-19 Fernando Perez <fperez@colorado.edu>
2462 2005-02-19 Fernando Perez <fperez@colorado.edu>
2456
2463
2457 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
2464 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
2458 into keys (for prompts, for example).
2465 into keys (for prompts, for example).
2459
2466
2460 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
2467 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
2461 prompts in case users want them. This introduces a small behavior
2468 prompts in case users want them. This introduces a small behavior
2462 change: ipython does not automatically add a space to all prompts
2469 change: ipython does not automatically add a space to all prompts
2463 anymore. To get the old prompts with a space, users should add it
2470 anymore. To get the old prompts with a space, users should add it
2464 manually to their ipythonrc file, so for example prompt_in1 should
2471 manually to their ipythonrc file, so for example prompt_in1 should
2465 now read 'In [\#]: ' instead of 'In [\#]:'.
2472 now read 'In [\#]: ' instead of 'In [\#]:'.
2466 (BasePrompt.__init__): New option prompts_pad_left (only in rc
2473 (BasePrompt.__init__): New option prompts_pad_left (only in rc
2467 file) to control left-padding of secondary prompts.
2474 file) to control left-padding of secondary prompts.
2468
2475
2469 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
2476 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
2470 the profiler can't be imported. Fix for Debian, which removed
2477 the profiler can't be imported. Fix for Debian, which removed
2471 profile.py because of License issues. I applied a slightly
2478 profile.py because of License issues. I applied a slightly
2472 modified version of the original Debian patch at
2479 modified version of the original Debian patch at
2473 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
2480 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
2474
2481
2475 2005-02-17 Fernando Perez <fperez@colorado.edu>
2482 2005-02-17 Fernando Perez <fperez@colorado.edu>
2476
2483
2477 * IPython/genutils.py (native_line_ends): Fix bug which would
2484 * IPython/genutils.py (native_line_ends): Fix bug which would
2478 cause improper line-ends under win32 b/c I was not opening files
2485 cause improper line-ends under win32 b/c I was not opening files
2479 in binary mode. Bug report and fix thanks to Ville.
2486 in binary mode. Bug report and fix thanks to Ville.
2480
2487
2481 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
2488 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
2482 trying to catch spurious foo[1] autocalls. My fix actually broke
2489 trying to catch spurious foo[1] autocalls. My fix actually broke
2483 ',/' autoquote/call with explicit escape (bad regexp).
2490 ',/' autoquote/call with explicit escape (bad regexp).
2484
2491
2485 2005-02-15 *** Released version 0.6.11
2492 2005-02-15 *** Released version 0.6.11
2486
2493
2487 2005-02-14 Fernando Perez <fperez@colorado.edu>
2494 2005-02-14 Fernando Perez <fperez@colorado.edu>
2488
2495
2489 * IPython/background_jobs.py: New background job management
2496 * IPython/background_jobs.py: New background job management
2490 subsystem. This is implemented via a new set of classes, and
2497 subsystem. This is implemented via a new set of classes, and
2491 IPython now provides a builtin 'jobs' object for background job
2498 IPython now provides a builtin 'jobs' object for background job
2492 execution. A convenience %bg magic serves as a lightweight
2499 execution. A convenience %bg magic serves as a lightweight
2493 frontend for starting the more common type of calls. This was
2500 frontend for starting the more common type of calls. This was
2494 inspired by discussions with B. Granger and the BackgroundCommand
2501 inspired by discussions with B. Granger and the BackgroundCommand
2495 class described in the book Python Scripting for Computational
2502 class described in the book Python Scripting for Computational
2496 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
2503 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
2497 (although ultimately no code from this text was used, as IPython's
2504 (although ultimately no code from this text was used, as IPython's
2498 system is a separate implementation).
2505 system is a separate implementation).
2499
2506
2500 * IPython/iplib.py (MagicCompleter.python_matches): add new option
2507 * IPython/iplib.py (MagicCompleter.python_matches): add new option
2501 to control the completion of single/double underscore names
2508 to control the completion of single/double underscore names
2502 separately. As documented in the example ipytonrc file, the
2509 separately. As documented in the example ipytonrc file, the
2503 readline_omit__names variable can now be set to 2, to omit even
2510 readline_omit__names variable can now be set to 2, to omit even
2504 single underscore names. Thanks to a patch by Brian Wong
2511 single underscore names. Thanks to a patch by Brian Wong
2505 <BrianWong-AT-AirgoNetworks.Com>.
2512 <BrianWong-AT-AirgoNetworks.Com>.
2506 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
2513 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
2507 be autocalled as foo([1]) if foo were callable. A problem for
2514 be autocalled as foo([1]) if foo were callable. A problem for
2508 things which are both callable and implement __getitem__.
2515 things which are both callable and implement __getitem__.
2509 (init_readline): Fix autoindentation for win32. Thanks to a patch
2516 (init_readline): Fix autoindentation for win32. Thanks to a patch
2510 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
2517 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
2511
2518
2512 2005-02-12 Fernando Perez <fperez@colorado.edu>
2519 2005-02-12 Fernando Perez <fperez@colorado.edu>
2513
2520
2514 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
2521 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
2515 which I had written long ago to sort out user error messages which
2522 which I had written long ago to sort out user error messages which
2516 may occur during startup. This seemed like a good idea initially,
2523 may occur during startup. This seemed like a good idea initially,
2517 but it has proven a disaster in retrospect. I don't want to
2524 but it has proven a disaster in retrospect. I don't want to
2518 change much code for now, so my fix is to set the internal 'debug'
2525 change much code for now, so my fix is to set the internal 'debug'
2519 flag to true everywhere, whose only job was precisely to control
2526 flag to true everywhere, whose only job was precisely to control
2520 this subsystem. This closes issue 28 (as well as avoiding all
2527 this subsystem. This closes issue 28 (as well as avoiding all
2521 sorts of strange hangups which occur from time to time).
2528 sorts of strange hangups which occur from time to time).
2522
2529
2523 2005-02-07 Fernando Perez <fperez@colorado.edu>
2530 2005-02-07 Fernando Perez <fperez@colorado.edu>
2524
2531
2525 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
2532 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
2526 previous call produced a syntax error.
2533 previous call produced a syntax error.
2527
2534
2528 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2535 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2529 classes without constructor.
2536 classes without constructor.
2530
2537
2531 2005-02-06 Fernando Perez <fperez@colorado.edu>
2538 2005-02-06 Fernando Perez <fperez@colorado.edu>
2532
2539
2533 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
2540 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
2534 completions with the results of each matcher, so we return results
2541 completions with the results of each matcher, so we return results
2535 to the user from all namespaces. This breaks with ipython
2542 to the user from all namespaces. This breaks with ipython
2536 tradition, but I think it's a nicer behavior. Now you get all
2543 tradition, but I think it's a nicer behavior. Now you get all
2537 possible completions listed, from all possible namespaces (python,
2544 possible completions listed, from all possible namespaces (python,
2538 filesystem, magics...) After a request by John Hunter
2545 filesystem, magics...) After a request by John Hunter
2539 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2546 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2540
2547
2541 2005-02-05 Fernando Perez <fperez@colorado.edu>
2548 2005-02-05 Fernando Perez <fperez@colorado.edu>
2542
2549
2543 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
2550 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
2544 the call had quote characters in it (the quotes were stripped).
2551 the call had quote characters in it (the quotes were stripped).
2545
2552
2546 2005-01-31 Fernando Perez <fperez@colorado.edu>
2553 2005-01-31 Fernando Perez <fperez@colorado.edu>
2547
2554
2548 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
2555 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
2549 Itpl.itpl() to make the code more robust against psyco
2556 Itpl.itpl() to make the code more robust against psyco
2550 optimizations.
2557 optimizations.
2551
2558
2552 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
2559 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
2553 of causing an exception. Quicker, cleaner.
2560 of causing an exception. Quicker, cleaner.
2554
2561
2555 2005-01-28 Fernando Perez <fperez@colorado.edu>
2562 2005-01-28 Fernando Perez <fperez@colorado.edu>
2556
2563
2557 * scripts/ipython_win_post_install.py (install): hardcode
2564 * scripts/ipython_win_post_install.py (install): hardcode
2558 sys.prefix+'python.exe' as the executable path. It turns out that
2565 sys.prefix+'python.exe' as the executable path. It turns out that
2559 during the post-installation run, sys.executable resolves to the
2566 during the post-installation run, sys.executable resolves to the
2560 name of the binary installer! I should report this as a distutils
2567 name of the binary installer! I should report this as a distutils
2561 bug, I think. I updated the .10 release with this tiny fix, to
2568 bug, I think. I updated the .10 release with this tiny fix, to
2562 avoid annoying the lists further.
2569 avoid annoying the lists further.
2563
2570
2564 2005-01-27 *** Released version 0.6.10
2571 2005-01-27 *** Released version 0.6.10
2565
2572
2566 2005-01-27 Fernando Perez <fperez@colorado.edu>
2573 2005-01-27 Fernando Perez <fperez@colorado.edu>
2567
2574
2568 * IPython/numutils.py (norm): Added 'inf' as optional name for
2575 * IPython/numutils.py (norm): Added 'inf' as optional name for
2569 L-infinity norm, included references to mathworld.com for vector
2576 L-infinity norm, included references to mathworld.com for vector
2570 norm definitions.
2577 norm definitions.
2571 (amin/amax): added amin/amax for array min/max. Similar to what
2578 (amin/amax): added amin/amax for array min/max. Similar to what
2572 pylab ships with after the recent reorganization of names.
2579 pylab ships with after the recent reorganization of names.
2573 (spike/spike_odd): removed deprecated spike/spike_odd functions.
2580 (spike/spike_odd): removed deprecated spike/spike_odd functions.
2574
2581
2575 * ipython.el: committed Alex's recent fixes and improvements.
2582 * ipython.el: committed Alex's recent fixes and improvements.
2576 Tested with python-mode from CVS, and it looks excellent. Since
2583 Tested with python-mode from CVS, and it looks excellent. Since
2577 python-mode hasn't released anything in a while, I'm temporarily
2584 python-mode hasn't released anything in a while, I'm temporarily
2578 putting a copy of today's CVS (v 4.70) of python-mode in:
2585 putting a copy of today's CVS (v 4.70) of python-mode in:
2579 http://ipython.scipy.org/tmp/python-mode.el
2586 http://ipython.scipy.org/tmp/python-mode.el
2580
2587
2581 * scripts/ipython_win_post_install.py (install): Win32 fix to use
2588 * scripts/ipython_win_post_install.py (install): Win32 fix to use
2582 sys.executable for the executable name, instead of assuming it's
2589 sys.executable for the executable name, instead of assuming it's
2583 called 'python.exe' (the post-installer would have produced broken
2590 called 'python.exe' (the post-installer would have produced broken
2584 setups on systems with a differently named python binary).
2591 setups on systems with a differently named python binary).
2585
2592
2586 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
2593 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
2587 references to os.linesep, to make the code more
2594 references to os.linesep, to make the code more
2588 platform-independent. This is also part of the win32 coloring
2595 platform-independent. This is also part of the win32 coloring
2589 fixes.
2596 fixes.
2590
2597
2591 * IPython/genutils.py (page_dumb): Remove attempts to chop long
2598 * IPython/genutils.py (page_dumb): Remove attempts to chop long
2592 lines, which actually cause coloring bugs because the length of
2599 lines, which actually cause coloring bugs because the length of
2593 the line is very difficult to correctly compute with embedded
2600 the line is very difficult to correctly compute with embedded
2594 escapes. This was the source of all the coloring problems under
2601 escapes. This was the source of all the coloring problems under
2595 Win32. I think that _finally_, Win32 users have a properly
2602 Win32. I think that _finally_, Win32 users have a properly
2596 working ipython in all respects. This would never have happened
2603 working ipython in all respects. This would never have happened
2597 if not for Gary Bishop and Viktor Ransmayr's great help and work.
2604 if not for Gary Bishop and Viktor Ransmayr's great help and work.
2598
2605
2599 2005-01-26 *** Released version 0.6.9
2606 2005-01-26 *** Released version 0.6.9
2600
2607
2601 2005-01-25 Fernando Perez <fperez@colorado.edu>
2608 2005-01-25 Fernando Perez <fperez@colorado.edu>
2602
2609
2603 * setup.py: finally, we have a true Windows installer, thanks to
2610 * setup.py: finally, we have a true Windows installer, thanks to
2604 the excellent work of Viktor Ransmayr
2611 the excellent work of Viktor Ransmayr
2605 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
2612 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
2606 Windows users. The setup routine is quite a bit cleaner thanks to
2613 Windows users. The setup routine is quite a bit cleaner thanks to
2607 this, and the post-install script uses the proper functions to
2614 this, and the post-install script uses the proper functions to
2608 allow a clean de-installation using the standard Windows Control
2615 allow a clean de-installation using the standard Windows Control
2609 Panel.
2616 Panel.
2610
2617
2611 * IPython/genutils.py (get_home_dir): changed to use the $HOME
2618 * IPython/genutils.py (get_home_dir): changed to use the $HOME
2612 environment variable under all OSes (including win32) if
2619 environment variable under all OSes (including win32) if
2613 available. This will give consistency to win32 users who have set
2620 available. This will give consistency to win32 users who have set
2614 this variable for any reason. If os.environ['HOME'] fails, the
2621 this variable for any reason. If os.environ['HOME'] fails, the
2615 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
2622 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
2616
2623
2617 2005-01-24 Fernando Perez <fperez@colorado.edu>
2624 2005-01-24 Fernando Perez <fperez@colorado.edu>
2618
2625
2619 * IPython/numutils.py (empty_like): add empty_like(), similar to
2626 * IPython/numutils.py (empty_like): add empty_like(), similar to
2620 zeros_like() but taking advantage of the new empty() Numeric routine.
2627 zeros_like() but taking advantage of the new empty() Numeric routine.
2621
2628
2622 2005-01-23 *** Released version 0.6.8
2629 2005-01-23 *** Released version 0.6.8
2623
2630
2624 2005-01-22 Fernando Perez <fperez@colorado.edu>
2631 2005-01-22 Fernando Perez <fperez@colorado.edu>
2625
2632
2626 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
2633 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
2627 automatic show() calls. After discussing things with JDH, it
2634 automatic show() calls. After discussing things with JDH, it
2628 turns out there are too many corner cases where this can go wrong.
2635 turns out there are too many corner cases where this can go wrong.
2629 It's best not to try to be 'too smart', and simply have ipython
2636 It's best not to try to be 'too smart', and simply have ipython
2630 reproduce as much as possible the default behavior of a normal
2637 reproduce as much as possible the default behavior of a normal
2631 python shell.
2638 python shell.
2632
2639
2633 * IPython/iplib.py (InteractiveShell.__init__): Modified the
2640 * IPython/iplib.py (InteractiveShell.__init__): Modified the
2634 line-splitting regexp and _prefilter() to avoid calling getattr()
2641 line-splitting regexp and _prefilter() to avoid calling getattr()
2635 on assignments. This closes
2642 on assignments. This closes
2636 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
2643 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
2637 readline uses getattr(), so a simple <TAB> keypress is still
2644 readline uses getattr(), so a simple <TAB> keypress is still
2638 enough to trigger getattr() calls on an object.
2645 enough to trigger getattr() calls on an object.
2639
2646
2640 2005-01-21 Fernando Perez <fperez@colorado.edu>
2647 2005-01-21 Fernando Perez <fperez@colorado.edu>
2641
2648
2642 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
2649 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
2643 docstring under pylab so it doesn't mask the original.
2650 docstring under pylab so it doesn't mask the original.
2644
2651
2645 2005-01-21 *** Released version 0.6.7
2652 2005-01-21 *** Released version 0.6.7
2646
2653
2647 2005-01-21 Fernando Perez <fperez@colorado.edu>
2654 2005-01-21 Fernando Perez <fperez@colorado.edu>
2648
2655
2649 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
2656 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
2650 signal handling for win32 users in multithreaded mode.
2657 signal handling for win32 users in multithreaded mode.
2651
2658
2652 2005-01-17 Fernando Perez <fperez@colorado.edu>
2659 2005-01-17 Fernando Perez <fperez@colorado.edu>
2653
2660
2654 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2661 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2655 instances with no __init__. After a crash report by Norbert Nemec
2662 instances with no __init__. After a crash report by Norbert Nemec
2656 <Norbert-AT-nemec-online.de>.
2663 <Norbert-AT-nemec-online.de>.
2657
2664
2658 2005-01-14 Fernando Perez <fperez@colorado.edu>
2665 2005-01-14 Fernando Perez <fperez@colorado.edu>
2659
2666
2660 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
2667 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
2661 names for verbose exceptions, when multiple dotted names and the
2668 names for verbose exceptions, when multiple dotted names and the
2662 'parent' object were present on the same line.
2669 'parent' object were present on the same line.
2663
2670
2664 2005-01-11 Fernando Perez <fperez@colorado.edu>
2671 2005-01-11 Fernando Perez <fperez@colorado.edu>
2665
2672
2666 * IPython/genutils.py (flag_calls): new utility to trap and flag
2673 * IPython/genutils.py (flag_calls): new utility to trap and flag
2667 calls in functions. I need it to clean up matplotlib support.
2674 calls in functions. I need it to clean up matplotlib support.
2668 Also removed some deprecated code in genutils.
2675 Also removed some deprecated code in genutils.
2669
2676
2670 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
2677 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
2671 that matplotlib scripts called with %run, which don't call show()
2678 that matplotlib scripts called with %run, which don't call show()
2672 themselves, still have their plotting windows open.
2679 themselves, still have their plotting windows open.
2673
2680
2674 2005-01-05 Fernando Perez <fperez@colorado.edu>
2681 2005-01-05 Fernando Perez <fperez@colorado.edu>
2675
2682
2676 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
2683 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
2677 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
2684 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
2678
2685
2679 2004-12-19 Fernando Perez <fperez@colorado.edu>
2686 2004-12-19 Fernando Perez <fperez@colorado.edu>
2680
2687
2681 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
2688 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
2682 parent_runcode, which was an eyesore. The same result can be
2689 parent_runcode, which was an eyesore. The same result can be
2683 obtained with Python's regular superclass mechanisms.
2690 obtained with Python's regular superclass mechanisms.
2684
2691
2685 2004-12-17 Fernando Perez <fperez@colorado.edu>
2692 2004-12-17 Fernando Perez <fperez@colorado.edu>
2686
2693
2687 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
2694 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
2688 reported by Prabhu.
2695 reported by Prabhu.
2689 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
2696 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
2690 sys.stderr) instead of explicitly calling sys.stderr. This helps
2697 sys.stderr) instead of explicitly calling sys.stderr. This helps
2691 maintain our I/O abstractions clean, for future GUI embeddings.
2698 maintain our I/O abstractions clean, for future GUI embeddings.
2692
2699
2693 * IPython/genutils.py (info): added new utility for sys.stderr
2700 * IPython/genutils.py (info): added new utility for sys.stderr
2694 unified info message handling (thin wrapper around warn()).
2701 unified info message handling (thin wrapper around warn()).
2695
2702
2696 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
2703 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
2697 composite (dotted) names on verbose exceptions.
2704 composite (dotted) names on verbose exceptions.
2698 (VerboseTB.nullrepr): harden against another kind of errors which
2705 (VerboseTB.nullrepr): harden against another kind of errors which
2699 Python's inspect module can trigger, and which were crashing
2706 Python's inspect module can trigger, and which were crashing
2700 IPython. Thanks to a report by Marco Lombardi
2707 IPython. Thanks to a report by Marco Lombardi
2701 <mlombard-AT-ma010192.hq.eso.org>.
2708 <mlombard-AT-ma010192.hq.eso.org>.
2702
2709
2703 2004-12-13 *** Released version 0.6.6
2710 2004-12-13 *** Released version 0.6.6
2704
2711
2705 2004-12-12 Fernando Perez <fperez@colorado.edu>
2712 2004-12-12 Fernando Perez <fperez@colorado.edu>
2706
2713
2707 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
2714 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
2708 generated by pygtk upon initialization if it was built without
2715 generated by pygtk upon initialization if it was built without
2709 threads (for matplotlib users). After a crash reported by
2716 threads (for matplotlib users). After a crash reported by
2710 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
2717 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
2711
2718
2712 * IPython/ipmaker.py (make_IPython): fix small bug in the
2719 * IPython/ipmaker.py (make_IPython): fix small bug in the
2713 import_some parameter for multiple imports.
2720 import_some parameter for multiple imports.
2714
2721
2715 * IPython/iplib.py (ipmagic): simplified the interface of
2722 * IPython/iplib.py (ipmagic): simplified the interface of
2716 ipmagic() to take a single string argument, just as it would be
2723 ipmagic() to take a single string argument, just as it would be
2717 typed at the IPython cmd line.
2724 typed at the IPython cmd line.
2718 (ipalias): Added new ipalias() with an interface identical to
2725 (ipalias): Added new ipalias() with an interface identical to
2719 ipmagic(). This completes exposing a pure python interface to the
2726 ipmagic(). This completes exposing a pure python interface to the
2720 alias and magic system, which can be used in loops or more complex
2727 alias and magic system, which can be used in loops or more complex
2721 code where IPython's automatic line mangling is not active.
2728 code where IPython's automatic line mangling is not active.
2722
2729
2723 * IPython/genutils.py (timing): changed interface of timing to
2730 * IPython/genutils.py (timing): changed interface of timing to
2724 simply run code once, which is the most common case. timings()
2731 simply run code once, which is the most common case. timings()
2725 remains unchanged, for the cases where you want multiple runs.
2732 remains unchanged, for the cases where you want multiple runs.
2726
2733
2727 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
2734 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
2728 bug where Python2.2 crashes with exec'ing code which does not end
2735 bug where Python2.2 crashes with exec'ing code which does not end
2729 in a single newline. Python 2.3 is OK, so I hadn't noticed this
2736 in a single newline. Python 2.3 is OK, so I hadn't noticed this
2730 before.
2737 before.
2731
2738
2732 2004-12-10 Fernando Perez <fperez@colorado.edu>
2739 2004-12-10 Fernando Perez <fperez@colorado.edu>
2733
2740
2734 * IPython/Magic.py (Magic.magic_prun): changed name of option from
2741 * IPython/Magic.py (Magic.magic_prun): changed name of option from
2735 -t to -T, to accomodate the new -t flag in %run (the %run and
2742 -t to -T, to accomodate the new -t flag in %run (the %run and
2736 %prun options are kind of intermixed, and it's not easy to change
2743 %prun options are kind of intermixed, and it's not easy to change
2737 this with the limitations of python's getopt).
2744 this with the limitations of python's getopt).
2738
2745
2739 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
2746 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
2740 the execution of scripts. It's not as fine-tuned as timeit.py,
2747 the execution of scripts. It's not as fine-tuned as timeit.py,
2741 but it works from inside ipython (and under 2.2, which lacks
2748 but it works from inside ipython (and under 2.2, which lacks
2742 timeit.py). Optionally a number of runs > 1 can be given for
2749 timeit.py). Optionally a number of runs > 1 can be given for
2743 timing very short-running code.
2750 timing very short-running code.
2744
2751
2745 * IPython/genutils.py (uniq_stable): new routine which returns a
2752 * IPython/genutils.py (uniq_stable): new routine which returns a
2746 list of unique elements in any iterable, but in stable order of
2753 list of unique elements in any iterable, but in stable order of
2747 appearance. I needed this for the ultraTB fixes, and it's a handy
2754 appearance. I needed this for the ultraTB fixes, and it's a handy
2748 utility.
2755 utility.
2749
2756
2750 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
2757 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
2751 dotted names in Verbose exceptions. This had been broken since
2758 dotted names in Verbose exceptions. This had been broken since
2752 the very start, now x.y will properly be printed in a Verbose
2759 the very start, now x.y will properly be printed in a Verbose
2753 traceback, instead of x being shown and y appearing always as an
2760 traceback, instead of x being shown and y appearing always as an
2754 'undefined global'. Getting this to work was a bit tricky,
2761 'undefined global'. Getting this to work was a bit tricky,
2755 because by default python tokenizers are stateless. Saved by
2762 because by default python tokenizers are stateless. Saved by
2756 python's ability to easily add a bit of state to an arbitrary
2763 python's ability to easily add a bit of state to an arbitrary
2757 function (without needing to build a full-blown callable object).
2764 function (without needing to build a full-blown callable object).
2758
2765
2759 Also big cleanup of this code, which had horrendous runtime
2766 Also big cleanup of this code, which had horrendous runtime
2760 lookups of zillions of attributes for colorization. Moved all
2767 lookups of zillions of attributes for colorization. Moved all
2761 this code into a few templates, which make it cleaner and quicker.
2768 this code into a few templates, which make it cleaner and quicker.
2762
2769
2763 Printout quality was also improved for Verbose exceptions: one
2770 Printout quality was also improved for Verbose exceptions: one
2764 variable per line, and memory addresses are printed (this can be
2771 variable per line, and memory addresses are printed (this can be
2765 quite handy in nasty debugging situations, which is what Verbose
2772 quite handy in nasty debugging situations, which is what Verbose
2766 is for).
2773 is for).
2767
2774
2768 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
2775 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
2769 the command line as scripts to be loaded by embedded instances.
2776 the command line as scripts to be loaded by embedded instances.
2770 Doing so has the potential for an infinite recursion if there are
2777 Doing so has the potential for an infinite recursion if there are
2771 exceptions thrown in the process. This fixes a strange crash
2778 exceptions thrown in the process. This fixes a strange crash
2772 reported by Philippe MULLER <muller-AT-irit.fr>.
2779 reported by Philippe MULLER <muller-AT-irit.fr>.
2773
2780
2774 2004-12-09 Fernando Perez <fperez@colorado.edu>
2781 2004-12-09 Fernando Perez <fperez@colorado.edu>
2775
2782
2776 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
2783 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
2777 to reflect new names in matplotlib, which now expose the
2784 to reflect new names in matplotlib, which now expose the
2778 matlab-compatible interface via a pylab module instead of the
2785 matlab-compatible interface via a pylab module instead of the
2779 'matlab' name. The new code is backwards compatible, so users of
2786 'matlab' name. The new code is backwards compatible, so users of
2780 all matplotlib versions are OK. Patch by J. Hunter.
2787 all matplotlib versions are OK. Patch by J. Hunter.
2781
2788
2782 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
2789 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
2783 of __init__ docstrings for instances (class docstrings are already
2790 of __init__ docstrings for instances (class docstrings are already
2784 automatically printed). Instances with customized docstrings
2791 automatically printed). Instances with customized docstrings
2785 (indep. of the class) are also recognized and all 3 separate
2792 (indep. of the class) are also recognized and all 3 separate
2786 docstrings are printed (instance, class, constructor). After some
2793 docstrings are printed (instance, class, constructor). After some
2787 comments/suggestions by J. Hunter.
2794 comments/suggestions by J. Hunter.
2788
2795
2789 2004-12-05 Fernando Perez <fperez@colorado.edu>
2796 2004-12-05 Fernando Perez <fperez@colorado.edu>
2790
2797
2791 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
2798 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
2792 warnings when tab-completion fails and triggers an exception.
2799 warnings when tab-completion fails and triggers an exception.
2793
2800
2794 2004-12-03 Fernando Perez <fperez@colorado.edu>
2801 2004-12-03 Fernando Perez <fperez@colorado.edu>
2795
2802
2796 * IPython/Magic.py (magic_prun): Fix bug where an exception would
2803 * IPython/Magic.py (magic_prun): Fix bug where an exception would
2797 be triggered when using 'run -p'. An incorrect option flag was
2804 be triggered when using 'run -p'. An incorrect option flag was
2798 being set ('d' instead of 'D').
2805 being set ('d' instead of 'D').
2799 (manpage): fix missing escaped \- sign.
2806 (manpage): fix missing escaped \- sign.
2800
2807
2801 2004-11-30 *** Released version 0.6.5
2808 2004-11-30 *** Released version 0.6.5
2802
2809
2803 2004-11-30 Fernando Perez <fperez@colorado.edu>
2810 2004-11-30 Fernando Perez <fperez@colorado.edu>
2804
2811
2805 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
2812 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
2806 setting with -d option.
2813 setting with -d option.
2807
2814
2808 * setup.py (docfiles): Fix problem where the doc glob I was using
2815 * setup.py (docfiles): Fix problem where the doc glob I was using
2809 was COMPLETELY BROKEN. It was giving the right files by pure
2816 was COMPLETELY BROKEN. It was giving the right files by pure
2810 accident, but failed once I tried to include ipython.el. Note:
2817 accident, but failed once I tried to include ipython.el. Note:
2811 glob() does NOT allow you to do exclusion on multiple endings!
2818 glob() does NOT allow you to do exclusion on multiple endings!
2812
2819
2813 2004-11-29 Fernando Perez <fperez@colorado.edu>
2820 2004-11-29 Fernando Perez <fperez@colorado.edu>
2814
2821
2815 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
2822 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
2816 the manpage as the source. Better formatting & consistency.
2823 the manpage as the source. Better formatting & consistency.
2817
2824
2818 * IPython/Magic.py (magic_run): Added new -d option, to run
2825 * IPython/Magic.py (magic_run): Added new -d option, to run
2819 scripts under the control of the python pdb debugger. Note that
2826 scripts under the control of the python pdb debugger. Note that
2820 this required changing the %prun option -d to -D, to avoid a clash
2827 this required changing the %prun option -d to -D, to avoid a clash
2821 (since %run must pass options to %prun, and getopt is too dumb to
2828 (since %run must pass options to %prun, and getopt is too dumb to
2822 handle options with string values with embedded spaces). Thanks
2829 handle options with string values with embedded spaces). Thanks
2823 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
2830 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
2824 (magic_who_ls): added type matching to %who and %whos, so that one
2831 (magic_who_ls): added type matching to %who and %whos, so that one
2825 can filter their output to only include variables of certain
2832 can filter their output to only include variables of certain
2826 types. Another suggestion by Matthew.
2833 types. Another suggestion by Matthew.
2827 (magic_whos): Added memory summaries in kb and Mb for arrays.
2834 (magic_whos): Added memory summaries in kb and Mb for arrays.
2828 (magic_who): Improve formatting (break lines every 9 vars).
2835 (magic_who): Improve formatting (break lines every 9 vars).
2829
2836
2830 2004-11-28 Fernando Perez <fperez@colorado.edu>
2837 2004-11-28 Fernando Perez <fperez@colorado.edu>
2831
2838
2832 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
2839 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
2833 cache when empty lines were present.
2840 cache when empty lines were present.
2834
2841
2835 2004-11-24 Fernando Perez <fperez@colorado.edu>
2842 2004-11-24 Fernando Perez <fperez@colorado.edu>
2836
2843
2837 * IPython/usage.py (__doc__): document the re-activated threading
2844 * IPython/usage.py (__doc__): document the re-activated threading
2838 options for WX and GTK.
2845 options for WX and GTK.
2839
2846
2840 2004-11-23 Fernando Perez <fperez@colorado.edu>
2847 2004-11-23 Fernando Perez <fperez@colorado.edu>
2841
2848
2842 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
2849 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
2843 the -wthread and -gthread options, along with a new -tk one to try
2850 the -wthread and -gthread options, along with a new -tk one to try
2844 and coordinate Tk threading with wx/gtk. The tk support is very
2851 and coordinate Tk threading with wx/gtk. The tk support is very
2845 platform dependent, since it seems to require Tcl and Tk to be
2852 platform dependent, since it seems to require Tcl and Tk to be
2846 built with threads (Fedora1/2 appears NOT to have it, but in
2853 built with threads (Fedora1/2 appears NOT to have it, but in
2847 Prabhu's Debian boxes it works OK). But even with some Tk
2854 Prabhu's Debian boxes it works OK). But even with some Tk
2848 limitations, this is a great improvement.
2855 limitations, this is a great improvement.
2849
2856
2850 * IPython/Prompts.py (prompt_specials_color): Added \t for time
2857 * IPython/Prompts.py (prompt_specials_color): Added \t for time
2851 info in user prompts. Patch by Prabhu.
2858 info in user prompts. Patch by Prabhu.
2852
2859
2853 2004-11-18 Fernando Perez <fperez@colorado.edu>
2860 2004-11-18 Fernando Perez <fperez@colorado.edu>
2854
2861
2855 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
2862 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
2856 EOFErrors and bail, to avoid infinite loops if a non-terminating
2863 EOFErrors and bail, to avoid infinite loops if a non-terminating
2857 file is fed into ipython. Patch submitted in issue 19 by user,
2864 file is fed into ipython. Patch submitted in issue 19 by user,
2858 many thanks.
2865 many thanks.
2859
2866
2860 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
2867 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
2861 autoquote/parens in continuation prompts, which can cause lots of
2868 autoquote/parens in continuation prompts, which can cause lots of
2862 problems. Closes roundup issue 20.
2869 problems. Closes roundup issue 20.
2863
2870
2864 2004-11-17 Fernando Perez <fperez@colorado.edu>
2871 2004-11-17 Fernando Perez <fperez@colorado.edu>
2865
2872
2866 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
2873 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
2867 reported as debian bug #280505. I'm not sure my local changelog
2874 reported as debian bug #280505. I'm not sure my local changelog
2868 entry has the proper debian format (Jack?).
2875 entry has the proper debian format (Jack?).
2869
2876
2870 2004-11-08 *** Released version 0.6.4
2877 2004-11-08 *** Released version 0.6.4
2871
2878
2872 2004-11-08 Fernando Perez <fperez@colorado.edu>
2879 2004-11-08 Fernando Perez <fperez@colorado.edu>
2873
2880
2874 * IPython/iplib.py (init_readline): Fix exit message for Windows
2881 * IPython/iplib.py (init_readline): Fix exit message for Windows
2875 when readline is active. Thanks to a report by Eric Jones
2882 when readline is active. Thanks to a report by Eric Jones
2876 <eric-AT-enthought.com>.
2883 <eric-AT-enthought.com>.
2877
2884
2878 2004-11-07 Fernando Perez <fperez@colorado.edu>
2885 2004-11-07 Fernando Perez <fperez@colorado.edu>
2879
2886
2880 * IPython/genutils.py (page): Add a trap for OSError exceptions,
2887 * IPython/genutils.py (page): Add a trap for OSError exceptions,
2881 sometimes seen by win2k/cygwin users.
2888 sometimes seen by win2k/cygwin users.
2882
2889
2883 2004-11-06 Fernando Perez <fperez@colorado.edu>
2890 2004-11-06 Fernando Perez <fperez@colorado.edu>
2884
2891
2885 * IPython/iplib.py (interact): Change the handling of %Exit from
2892 * IPython/iplib.py (interact): Change the handling of %Exit from
2886 trying to propagate a SystemExit to an internal ipython flag.
2893 trying to propagate a SystemExit to an internal ipython flag.
2887 This is less elegant than using Python's exception mechanism, but
2894 This is less elegant than using Python's exception mechanism, but
2888 I can't get that to work reliably with threads, so under -pylab
2895 I can't get that to work reliably with threads, so under -pylab
2889 %Exit was hanging IPython. Cross-thread exception handling is
2896 %Exit was hanging IPython. Cross-thread exception handling is
2890 really a bitch. Thaks to a bug report by Stephen Walton
2897 really a bitch. Thaks to a bug report by Stephen Walton
2891 <stephen.walton-AT-csun.edu>.
2898 <stephen.walton-AT-csun.edu>.
2892
2899
2893 2004-11-04 Fernando Perez <fperez@colorado.edu>
2900 2004-11-04 Fernando Perez <fperez@colorado.edu>
2894
2901
2895 * IPython/iplib.py (raw_input_original): store a pointer to the
2902 * IPython/iplib.py (raw_input_original): store a pointer to the
2896 true raw_input to harden against code which can modify it
2903 true raw_input to harden against code which can modify it
2897 (wx.py.PyShell does this and would otherwise crash ipython).
2904 (wx.py.PyShell does this and would otherwise crash ipython).
2898 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
2905 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
2899
2906
2900 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
2907 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
2901 Ctrl-C problem, which does not mess up the input line.
2908 Ctrl-C problem, which does not mess up the input line.
2902
2909
2903 2004-11-03 Fernando Perez <fperez@colorado.edu>
2910 2004-11-03 Fernando Perez <fperez@colorado.edu>
2904
2911
2905 * IPython/Release.py: Changed licensing to BSD, in all files.
2912 * IPython/Release.py: Changed licensing to BSD, in all files.
2906 (name): lowercase name for tarball/RPM release.
2913 (name): lowercase name for tarball/RPM release.
2907
2914
2908 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
2915 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
2909 use throughout ipython.
2916 use throughout ipython.
2910
2917
2911 * IPython/Magic.py (Magic._ofind): Switch to using the new
2918 * IPython/Magic.py (Magic._ofind): Switch to using the new
2912 OInspect.getdoc() function.
2919 OInspect.getdoc() function.
2913
2920
2914 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
2921 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
2915 of the line currently being canceled via Ctrl-C. It's extremely
2922 of the line currently being canceled via Ctrl-C. It's extremely
2916 ugly, but I don't know how to do it better (the problem is one of
2923 ugly, but I don't know how to do it better (the problem is one of
2917 handling cross-thread exceptions).
2924 handling cross-thread exceptions).
2918
2925
2919 2004-10-28 Fernando Perez <fperez@colorado.edu>
2926 2004-10-28 Fernando Perez <fperez@colorado.edu>
2920
2927
2921 * IPython/Shell.py (signal_handler): add signal handlers to trap
2928 * IPython/Shell.py (signal_handler): add signal handlers to trap
2922 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
2929 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
2923 report by Francesc Alted.
2930 report by Francesc Alted.
2924
2931
2925 2004-10-21 Fernando Perez <fperez@colorado.edu>
2932 2004-10-21 Fernando Perez <fperez@colorado.edu>
2926
2933
2927 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
2934 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
2928 to % for pysh syntax extensions.
2935 to % for pysh syntax extensions.
2929
2936
2930 2004-10-09 Fernando Perez <fperez@colorado.edu>
2937 2004-10-09 Fernando Perez <fperez@colorado.edu>
2931
2938
2932 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
2939 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
2933 arrays to print a more useful summary, without calling str(arr).
2940 arrays to print a more useful summary, without calling str(arr).
2934 This avoids the problem of extremely lengthy computations which
2941 This avoids the problem of extremely lengthy computations which
2935 occur if arr is large, and appear to the user as a system lockup
2942 occur if arr is large, and appear to the user as a system lockup
2936 with 100% cpu activity. After a suggestion by Kristian Sandberg
2943 with 100% cpu activity. After a suggestion by Kristian Sandberg
2937 <Kristian.Sandberg@colorado.edu>.
2944 <Kristian.Sandberg@colorado.edu>.
2938 (Magic.__init__): fix bug in global magic escapes not being
2945 (Magic.__init__): fix bug in global magic escapes not being
2939 correctly set.
2946 correctly set.
2940
2947
2941 2004-10-08 Fernando Perez <fperez@colorado.edu>
2948 2004-10-08 Fernando Perez <fperez@colorado.edu>
2942
2949
2943 * IPython/Magic.py (__license__): change to absolute imports of
2950 * IPython/Magic.py (__license__): change to absolute imports of
2944 ipython's own internal packages, to start adapting to the absolute
2951 ipython's own internal packages, to start adapting to the absolute
2945 import requirement of PEP-328.
2952 import requirement of PEP-328.
2946
2953
2947 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
2954 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
2948 files, and standardize author/license marks through the Release
2955 files, and standardize author/license marks through the Release
2949 module instead of having per/file stuff (except for files with
2956 module instead of having per/file stuff (except for files with
2950 particular licenses, like the MIT/PSF-licensed codes).
2957 particular licenses, like the MIT/PSF-licensed codes).
2951
2958
2952 * IPython/Debugger.py: remove dead code for python 2.1
2959 * IPython/Debugger.py: remove dead code for python 2.1
2953
2960
2954 2004-10-04 Fernando Perez <fperez@colorado.edu>
2961 2004-10-04 Fernando Perez <fperez@colorado.edu>
2955
2962
2956 * IPython/iplib.py (ipmagic): New function for accessing magics
2963 * IPython/iplib.py (ipmagic): New function for accessing magics
2957 via a normal python function call.
2964 via a normal python function call.
2958
2965
2959 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
2966 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
2960 from '@' to '%', to accomodate the new @decorator syntax of python
2967 from '@' to '%', to accomodate the new @decorator syntax of python
2961 2.4.
2968 2.4.
2962
2969
2963 2004-09-29 Fernando Perez <fperez@colorado.edu>
2970 2004-09-29 Fernando Perez <fperez@colorado.edu>
2964
2971
2965 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
2972 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
2966 matplotlib.use to prevent running scripts which try to switch
2973 matplotlib.use to prevent running scripts which try to switch
2967 interactive backends from within ipython. This will just crash
2974 interactive backends from within ipython. This will just crash
2968 the python interpreter, so we can't allow it (but a detailed error
2975 the python interpreter, so we can't allow it (but a detailed error
2969 is given to the user).
2976 is given to the user).
2970
2977
2971 2004-09-28 Fernando Perez <fperez@colorado.edu>
2978 2004-09-28 Fernando Perez <fperez@colorado.edu>
2972
2979
2973 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
2980 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
2974 matplotlib-related fixes so that using @run with non-matplotlib
2981 matplotlib-related fixes so that using @run with non-matplotlib
2975 scripts doesn't pop up spurious plot windows. This requires
2982 scripts doesn't pop up spurious plot windows. This requires
2976 matplotlib >= 0.63, where I had to make some changes as well.
2983 matplotlib >= 0.63, where I had to make some changes as well.
2977
2984
2978 * IPython/ipmaker.py (make_IPython): update version requirement to
2985 * IPython/ipmaker.py (make_IPython): update version requirement to
2979 python 2.2.
2986 python 2.2.
2980
2987
2981 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
2988 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
2982 banner arg for embedded customization.
2989 banner arg for embedded customization.
2983
2990
2984 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
2991 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
2985 explicit uses of __IP as the IPython's instance name. Now things
2992 explicit uses of __IP as the IPython's instance name. Now things
2986 are properly handled via the shell.name value. The actual code
2993 are properly handled via the shell.name value. The actual code
2987 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
2994 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
2988 is much better than before. I'll clean things completely when the
2995 is much better than before. I'll clean things completely when the
2989 magic stuff gets a real overhaul.
2996 magic stuff gets a real overhaul.
2990
2997
2991 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
2998 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
2992 minor changes to debian dir.
2999 minor changes to debian dir.
2993
3000
2994 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
3001 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
2995 pointer to the shell itself in the interactive namespace even when
3002 pointer to the shell itself in the interactive namespace even when
2996 a user-supplied dict is provided. This is needed for embedding
3003 a user-supplied dict is provided. This is needed for embedding
2997 purposes (found by tests with Michel Sanner).
3004 purposes (found by tests with Michel Sanner).
2998
3005
2999 2004-09-27 Fernando Perez <fperez@colorado.edu>
3006 2004-09-27 Fernando Perez <fperez@colorado.edu>
3000
3007
3001 * IPython/UserConfig/ipythonrc: remove []{} from
3008 * IPython/UserConfig/ipythonrc: remove []{} from
3002 readline_remove_delims, so that things like [modname.<TAB> do
3009 readline_remove_delims, so that things like [modname.<TAB> do
3003 proper completion. This disables [].TAB, but that's a less common
3010 proper completion. This disables [].TAB, but that's a less common
3004 case than module names in list comprehensions, for example.
3011 case than module names in list comprehensions, for example.
3005 Thanks to a report by Andrea Riciputi.
3012 Thanks to a report by Andrea Riciputi.
3006
3013
3007 2004-09-09 Fernando Perez <fperez@colorado.edu>
3014 2004-09-09 Fernando Perez <fperez@colorado.edu>
3008
3015
3009 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
3016 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
3010 blocking problems in win32 and osx. Fix by John.
3017 blocking problems in win32 and osx. Fix by John.
3011
3018
3012 2004-09-08 Fernando Perez <fperez@colorado.edu>
3019 2004-09-08 Fernando Perez <fperez@colorado.edu>
3013
3020
3014 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
3021 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
3015 for Win32 and OSX. Fix by John Hunter.
3022 for Win32 and OSX. Fix by John Hunter.
3016
3023
3017 2004-08-30 *** Released version 0.6.3
3024 2004-08-30 *** Released version 0.6.3
3018
3025
3019 2004-08-30 Fernando Perez <fperez@colorado.edu>
3026 2004-08-30 Fernando Perez <fperez@colorado.edu>
3020
3027
3021 * setup.py (isfile): Add manpages to list of dependent files to be
3028 * setup.py (isfile): Add manpages to list of dependent files to be
3022 updated.
3029 updated.
3023
3030
3024 2004-08-27 Fernando Perez <fperez@colorado.edu>
3031 2004-08-27 Fernando Perez <fperez@colorado.edu>
3025
3032
3026 * IPython/Shell.py (start): I've disabled -wthread and -gthread
3033 * IPython/Shell.py (start): I've disabled -wthread and -gthread
3027 for now. They don't really work with standalone WX/GTK code
3034 for now. They don't really work with standalone WX/GTK code
3028 (though matplotlib IS working fine with both of those backends).
3035 (though matplotlib IS working fine with both of those backends).
3029 This will neeed much more testing. I disabled most things with
3036 This will neeed much more testing. I disabled most things with
3030 comments, so turning it back on later should be pretty easy.
3037 comments, so turning it back on later should be pretty easy.
3031
3038
3032 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
3039 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
3033 autocalling of expressions like r'foo', by modifying the line
3040 autocalling of expressions like r'foo', by modifying the line
3034 split regexp. Closes
3041 split regexp. Closes
3035 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
3042 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
3036 Riley <ipythonbugs-AT-sabi.net>.
3043 Riley <ipythonbugs-AT-sabi.net>.
3037 (InteractiveShell.mainloop): honor --nobanner with banner
3044 (InteractiveShell.mainloop): honor --nobanner with banner
3038 extensions.
3045 extensions.
3039
3046
3040 * IPython/Shell.py: Significant refactoring of all classes, so
3047 * IPython/Shell.py: Significant refactoring of all classes, so
3041 that we can really support ALL matplotlib backends and threading
3048 that we can really support ALL matplotlib backends and threading
3042 models (John spotted a bug with Tk which required this). Now we
3049 models (John spotted a bug with Tk which required this). Now we
3043 should support single-threaded, WX-threads and GTK-threads, both
3050 should support single-threaded, WX-threads and GTK-threads, both
3044 for generic code and for matplotlib.
3051 for generic code and for matplotlib.
3045
3052
3046 * IPython/ipmaker.py (__call__): Changed -mpthread option to
3053 * IPython/ipmaker.py (__call__): Changed -mpthread option to
3047 -pylab, to simplify things for users. Will also remove the pylab
3054 -pylab, to simplify things for users. Will also remove the pylab
3048 profile, since now all of matplotlib configuration is directly
3055 profile, since now all of matplotlib configuration is directly
3049 handled here. This also reduces startup time.
3056 handled here. This also reduces startup time.
3050
3057
3051 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
3058 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
3052 shell wasn't being correctly called. Also in IPShellWX.
3059 shell wasn't being correctly called. Also in IPShellWX.
3053
3060
3054 * IPython/iplib.py (InteractiveShell.__init__): Added option to
3061 * IPython/iplib.py (InteractiveShell.__init__): Added option to
3055 fine-tune banner.
3062 fine-tune banner.
3056
3063
3057 * IPython/numutils.py (spike): Deprecate these spike functions,
3064 * IPython/numutils.py (spike): Deprecate these spike functions,
3058 delete (long deprecated) gnuplot_exec handler.
3065 delete (long deprecated) gnuplot_exec handler.
3059
3066
3060 2004-08-26 Fernando Perez <fperez@colorado.edu>
3067 2004-08-26 Fernando Perez <fperez@colorado.edu>
3061
3068
3062 * ipython.1: Update for threading options, plus some others which
3069 * ipython.1: Update for threading options, plus some others which
3063 were missing.
3070 were missing.
3064
3071
3065 * IPython/ipmaker.py (__call__): Added -wthread option for
3072 * IPython/ipmaker.py (__call__): Added -wthread option for
3066 wxpython thread handling. Make sure threading options are only
3073 wxpython thread handling. Make sure threading options are only
3067 valid at the command line.
3074 valid at the command line.
3068
3075
3069 * scripts/ipython: moved shell selection into a factory function
3076 * scripts/ipython: moved shell selection into a factory function
3070 in Shell.py, to keep the starter script to a minimum.
3077 in Shell.py, to keep the starter script to a minimum.
3071
3078
3072 2004-08-25 Fernando Perez <fperez@colorado.edu>
3079 2004-08-25 Fernando Perez <fperez@colorado.edu>
3073
3080
3074 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
3081 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
3075 John. Along with some recent changes he made to matplotlib, the
3082 John. Along with some recent changes he made to matplotlib, the
3076 next versions of both systems should work very well together.
3083 next versions of both systems should work very well together.
3077
3084
3078 2004-08-24 Fernando Perez <fperez@colorado.edu>
3085 2004-08-24 Fernando Perez <fperez@colorado.edu>
3079
3086
3080 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
3087 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
3081 tried to switch the profiling to using hotshot, but I'm getting
3088 tried to switch the profiling to using hotshot, but I'm getting
3082 strange errors from prof.runctx() there. I may be misreading the
3089 strange errors from prof.runctx() there. I may be misreading the
3083 docs, but it looks weird. For now the profiling code will
3090 docs, but it looks weird. For now the profiling code will
3084 continue to use the standard profiler.
3091 continue to use the standard profiler.
3085
3092
3086 2004-08-23 Fernando Perez <fperez@colorado.edu>
3093 2004-08-23 Fernando Perez <fperez@colorado.edu>
3087
3094
3088 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
3095 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
3089 threaded shell, by John Hunter. It's not quite ready yet, but
3096 threaded shell, by John Hunter. It's not quite ready yet, but
3090 close.
3097 close.
3091
3098
3092 2004-08-22 Fernando Perez <fperez@colorado.edu>
3099 2004-08-22 Fernando Perez <fperez@colorado.edu>
3093
3100
3094 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
3101 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
3095 in Magic and ultraTB.
3102 in Magic and ultraTB.
3096
3103
3097 * ipython.1: document threading options in manpage.
3104 * ipython.1: document threading options in manpage.
3098
3105
3099 * scripts/ipython: Changed name of -thread option to -gthread,
3106 * scripts/ipython: Changed name of -thread option to -gthread,
3100 since this is GTK specific. I want to leave the door open for a
3107 since this is GTK specific. I want to leave the door open for a
3101 -wthread option for WX, which will most likely be necessary. This
3108 -wthread option for WX, which will most likely be necessary. This
3102 change affects usage and ipmaker as well.
3109 change affects usage and ipmaker as well.
3103
3110
3104 * IPython/Shell.py (matplotlib_shell): Add a factory function to
3111 * IPython/Shell.py (matplotlib_shell): Add a factory function to
3105 handle the matplotlib shell issues. Code by John Hunter
3112 handle the matplotlib shell issues. Code by John Hunter
3106 <jdhunter-AT-nitace.bsd.uchicago.edu>.
3113 <jdhunter-AT-nitace.bsd.uchicago.edu>.
3107 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
3114 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
3108 broken (and disabled for end users) for now, but it puts the
3115 broken (and disabled for end users) for now, but it puts the
3109 infrastructure in place.
3116 infrastructure in place.
3110
3117
3111 2004-08-21 Fernando Perez <fperez@colorado.edu>
3118 2004-08-21 Fernando Perez <fperez@colorado.edu>
3112
3119
3113 * ipythonrc-pylab: Add matplotlib support.
3120 * ipythonrc-pylab: Add matplotlib support.
3114
3121
3115 * matplotlib_config.py: new files for matplotlib support, part of
3122 * matplotlib_config.py: new files for matplotlib support, part of
3116 the pylab profile.
3123 the pylab profile.
3117
3124
3118 * IPython/usage.py (__doc__): documented the threading options.
3125 * IPython/usage.py (__doc__): documented the threading options.
3119
3126
3120 2004-08-20 Fernando Perez <fperez@colorado.edu>
3127 2004-08-20 Fernando Perez <fperez@colorado.edu>
3121
3128
3122 * ipython: Modified the main calling routine to handle the -thread
3129 * ipython: Modified the main calling routine to handle the -thread
3123 and -mpthread options. This needs to be done as a top-level hack,
3130 and -mpthread options. This needs to be done as a top-level hack,
3124 because it determines which class to instantiate for IPython
3131 because it determines which class to instantiate for IPython
3125 itself.
3132 itself.
3126
3133
3127 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
3134 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
3128 classes to support multithreaded GTK operation without blocking,
3135 classes to support multithreaded GTK operation without blocking,
3129 and matplotlib with all backends. This is a lot of still very
3136 and matplotlib with all backends. This is a lot of still very
3130 experimental code, and threads are tricky. So it may still have a
3137 experimental code, and threads are tricky. So it may still have a
3131 few rough edges... This code owes a lot to
3138 few rough edges... This code owes a lot to
3132 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
3139 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
3133 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
3140 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
3134 to John Hunter for all the matplotlib work.
3141 to John Hunter for all the matplotlib work.
3135
3142
3136 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
3143 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
3137 options for gtk thread and matplotlib support.
3144 options for gtk thread and matplotlib support.
3138
3145
3139 2004-08-16 Fernando Perez <fperez@colorado.edu>
3146 2004-08-16 Fernando Perez <fperez@colorado.edu>
3140
3147
3141 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
3148 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
3142 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
3149 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
3143 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
3150 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
3144
3151
3145 2004-08-11 Fernando Perez <fperez@colorado.edu>
3152 2004-08-11 Fernando Perez <fperez@colorado.edu>
3146
3153
3147 * setup.py (isfile): Fix build so documentation gets updated for
3154 * setup.py (isfile): Fix build so documentation gets updated for
3148 rpms (it was only done for .tgz builds).
3155 rpms (it was only done for .tgz builds).
3149
3156
3150 2004-08-10 Fernando Perez <fperez@colorado.edu>
3157 2004-08-10 Fernando Perez <fperez@colorado.edu>
3151
3158
3152 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
3159 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
3153
3160
3154 * iplib.py : Silence syntax error exceptions in tab-completion.
3161 * iplib.py : Silence syntax error exceptions in tab-completion.
3155
3162
3156 2004-08-05 Fernando Perez <fperez@colorado.edu>
3163 2004-08-05 Fernando Perez <fperez@colorado.edu>
3157
3164
3158 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
3165 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
3159 'color off' mark for continuation prompts. This was causing long
3166 'color off' mark for continuation prompts. This was causing long
3160 continuation lines to mis-wrap.
3167 continuation lines to mis-wrap.
3161
3168
3162 2004-08-01 Fernando Perez <fperez@colorado.edu>
3169 2004-08-01 Fernando Perez <fperez@colorado.edu>
3163
3170
3164 * IPython/ipmaker.py (make_IPython): Allow the shell class used
3171 * IPython/ipmaker.py (make_IPython): Allow the shell class used
3165 for building ipython to be a parameter. All this is necessary
3172 for building ipython to be a parameter. All this is necessary
3166 right now to have a multithreaded version, but this insane
3173 right now to have a multithreaded version, but this insane
3167 non-design will be cleaned up soon. For now, it's a hack that
3174 non-design will be cleaned up soon. For now, it's a hack that
3168 works.
3175 works.
3169
3176
3170 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
3177 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
3171 args in various places. No bugs so far, but it's a dangerous
3178 args in various places. No bugs so far, but it's a dangerous
3172 practice.
3179 practice.
3173
3180
3174 2004-07-31 Fernando Perez <fperez@colorado.edu>
3181 2004-07-31 Fernando Perez <fperez@colorado.edu>
3175
3182
3176 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
3183 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
3177 fix completion of files with dots in their names under most
3184 fix completion of files with dots in their names under most
3178 profiles (pysh was OK because the completion order is different).
3185 profiles (pysh was OK because the completion order is different).
3179
3186
3180 2004-07-27 Fernando Perez <fperez@colorado.edu>
3187 2004-07-27 Fernando Perez <fperez@colorado.edu>
3181
3188
3182 * IPython/iplib.py (InteractiveShell.__init__): build dict of
3189 * IPython/iplib.py (InteractiveShell.__init__): build dict of
3183 keywords manually, b/c the one in keyword.py was removed in python
3190 keywords manually, b/c the one in keyword.py was removed in python
3184 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
3191 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
3185 This is NOT a bug under python 2.3 and earlier.
3192 This is NOT a bug under python 2.3 and earlier.
3186
3193
3187 2004-07-26 Fernando Perez <fperez@colorado.edu>
3194 2004-07-26 Fernando Perez <fperez@colorado.edu>
3188
3195
3189 * IPython/ultraTB.py (VerboseTB.text): Add another
3196 * IPython/ultraTB.py (VerboseTB.text): Add another
3190 linecache.checkcache() call to try to prevent inspect.py from
3197 linecache.checkcache() call to try to prevent inspect.py from
3191 crashing under python 2.3. I think this fixes
3198 crashing under python 2.3. I think this fixes
3192 http://www.scipy.net/roundup/ipython/issue17.
3199 http://www.scipy.net/roundup/ipython/issue17.
3193
3200
3194 2004-07-26 *** Released version 0.6.2
3201 2004-07-26 *** Released version 0.6.2
3195
3202
3196 2004-07-26 Fernando Perez <fperez@colorado.edu>
3203 2004-07-26 Fernando Perez <fperez@colorado.edu>
3197
3204
3198 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
3205 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
3199 fail for any number.
3206 fail for any number.
3200 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
3207 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
3201 empty bookmarks.
3208 empty bookmarks.
3202
3209
3203 2004-07-26 *** Released version 0.6.1
3210 2004-07-26 *** Released version 0.6.1
3204
3211
3205 2004-07-26 Fernando Perez <fperez@colorado.edu>
3212 2004-07-26 Fernando Perez <fperez@colorado.edu>
3206
3213
3207 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
3214 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
3208
3215
3209 * IPython/iplib.py (protect_filename): Applied Ville's patch for
3216 * IPython/iplib.py (protect_filename): Applied Ville's patch for
3210 escaping '()[]{}' in filenames.
3217 escaping '()[]{}' in filenames.
3211
3218
3212 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
3219 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
3213 Python 2.2 users who lack a proper shlex.split.
3220 Python 2.2 users who lack a proper shlex.split.
3214
3221
3215 2004-07-19 Fernando Perez <fperez@colorado.edu>
3222 2004-07-19 Fernando Perez <fperez@colorado.edu>
3216
3223
3217 * IPython/iplib.py (InteractiveShell.init_readline): Add support
3224 * IPython/iplib.py (InteractiveShell.init_readline): Add support
3218 for reading readline's init file. I follow the normal chain:
3225 for reading readline's init file. I follow the normal chain:
3219 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
3226 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
3220 report by Mike Heeter. This closes
3227 report by Mike Heeter. This closes
3221 http://www.scipy.net/roundup/ipython/issue16.
3228 http://www.scipy.net/roundup/ipython/issue16.
3222
3229
3223 2004-07-18 Fernando Perez <fperez@colorado.edu>
3230 2004-07-18 Fernando Perez <fperez@colorado.edu>
3224
3231
3225 * IPython/iplib.py (__init__): Add better handling of '\' under
3232 * IPython/iplib.py (__init__): Add better handling of '\' under
3226 Win32 for filenames. After a patch by Ville.
3233 Win32 for filenames. After a patch by Ville.
3227
3234
3228 2004-07-17 Fernando Perez <fperez@colorado.edu>
3235 2004-07-17 Fernando Perez <fperez@colorado.edu>
3229
3236
3230 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3237 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3231 autocalling would be triggered for 'foo is bar' if foo is
3238 autocalling would be triggered for 'foo is bar' if foo is
3232 callable. I also cleaned up the autocall detection code to use a
3239 callable. I also cleaned up the autocall detection code to use a
3233 regexp, which is faster. Bug reported by Alexander Schmolck.
3240 regexp, which is faster. Bug reported by Alexander Schmolck.
3234
3241
3235 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
3242 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
3236 '?' in them would confuse the help system. Reported by Alex
3243 '?' in them would confuse the help system. Reported by Alex
3237 Schmolck.
3244 Schmolck.
3238
3245
3239 2004-07-16 Fernando Perez <fperez@colorado.edu>
3246 2004-07-16 Fernando Perez <fperez@colorado.edu>
3240
3247
3241 * IPython/GnuplotInteractive.py (__all__): added plot2.
3248 * IPython/GnuplotInteractive.py (__all__): added plot2.
3242
3249
3243 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
3250 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
3244 plotting dictionaries, lists or tuples of 1d arrays.
3251 plotting dictionaries, lists or tuples of 1d arrays.
3245
3252
3246 * IPython/Magic.py (Magic.magic_hist): small clenaups and
3253 * IPython/Magic.py (Magic.magic_hist): small clenaups and
3247 optimizations.
3254 optimizations.
3248
3255
3249 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
3256 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
3250 the information which was there from Janko's original IPP code:
3257 the information which was there from Janko's original IPP code:
3251
3258
3252 03.05.99 20:53 porto.ifm.uni-kiel.de
3259 03.05.99 20:53 porto.ifm.uni-kiel.de
3253 --Started changelog.
3260 --Started changelog.
3254 --make clear do what it say it does
3261 --make clear do what it say it does
3255 --added pretty output of lines from inputcache
3262 --added pretty output of lines from inputcache
3256 --Made Logger a mixin class, simplifies handling of switches
3263 --Made Logger a mixin class, simplifies handling of switches
3257 --Added own completer class. .string<TAB> expands to last history
3264 --Added own completer class. .string<TAB> expands to last history
3258 line which starts with string. The new expansion is also present
3265 line which starts with string. The new expansion is also present
3259 with Ctrl-r from the readline library. But this shows, who this
3266 with Ctrl-r from the readline library. But this shows, who this
3260 can be done for other cases.
3267 can be done for other cases.
3261 --Added convention that all shell functions should accept a
3268 --Added convention that all shell functions should accept a
3262 parameter_string This opens the door for different behaviour for
3269 parameter_string This opens the door for different behaviour for
3263 each function. @cd is a good example of this.
3270 each function. @cd is a good example of this.
3264
3271
3265 04.05.99 12:12 porto.ifm.uni-kiel.de
3272 04.05.99 12:12 porto.ifm.uni-kiel.de
3266 --added logfile rotation
3273 --added logfile rotation
3267 --added new mainloop method which freezes first the namespace
3274 --added new mainloop method which freezes first the namespace
3268
3275
3269 07.05.99 21:24 porto.ifm.uni-kiel.de
3276 07.05.99 21:24 porto.ifm.uni-kiel.de
3270 --added the docreader classes. Now there is a help system.
3277 --added the docreader classes. Now there is a help system.
3271 -This is only a first try. Currently it's not easy to put new
3278 -This is only a first try. Currently it's not easy to put new
3272 stuff in the indices. But this is the way to go. Info would be
3279 stuff in the indices. But this is the way to go. Info would be
3273 better, but HTML is every where and not everybody has an info
3280 better, but HTML is every where and not everybody has an info
3274 system installed and it's not so easy to change html-docs to info.
3281 system installed and it's not so easy to change html-docs to info.
3275 --added global logfile option
3282 --added global logfile option
3276 --there is now a hook for object inspection method pinfo needs to
3283 --there is now a hook for object inspection method pinfo needs to
3277 be provided for this. Can be reached by two '??'.
3284 be provided for this. Can be reached by two '??'.
3278
3285
3279 08.05.99 20:51 porto.ifm.uni-kiel.de
3286 08.05.99 20:51 porto.ifm.uni-kiel.de
3280 --added a README
3287 --added a README
3281 --bug in rc file. Something has changed so functions in the rc
3288 --bug in rc file. Something has changed so functions in the rc
3282 file need to reference the shell and not self. Not clear if it's a
3289 file need to reference the shell and not self. Not clear if it's a
3283 bug or feature.
3290 bug or feature.
3284 --changed rc file for new behavior
3291 --changed rc file for new behavior
3285
3292
3286 2004-07-15 Fernando Perez <fperez@colorado.edu>
3293 2004-07-15 Fernando Perez <fperez@colorado.edu>
3287
3294
3288 * IPython/Logger.py (Logger.log): fixed recent bug where the input
3295 * IPython/Logger.py (Logger.log): fixed recent bug where the input
3289 cache was falling out of sync in bizarre manners when multi-line
3296 cache was falling out of sync in bizarre manners when multi-line
3290 input was present. Minor optimizations and cleanup.
3297 input was present. Minor optimizations and cleanup.
3291
3298
3292 (Logger): Remove old Changelog info for cleanup. This is the
3299 (Logger): Remove old Changelog info for cleanup. This is the
3293 information which was there from Janko's original code:
3300 information which was there from Janko's original code:
3294
3301
3295 Changes to Logger: - made the default log filename a parameter
3302 Changes to Logger: - made the default log filename a parameter
3296
3303
3297 - put a check for lines beginning with !@? in log(). Needed
3304 - put a check for lines beginning with !@? in log(). Needed
3298 (even if the handlers properly log their lines) for mid-session
3305 (even if the handlers properly log their lines) for mid-session
3299 logging activation to work properly. Without this, lines logged
3306 logging activation to work properly. Without this, lines logged
3300 in mid session, which get read from the cache, would end up
3307 in mid session, which get read from the cache, would end up
3301 'bare' (with !@? in the open) in the log. Now they are caught
3308 'bare' (with !@? in the open) in the log. Now they are caught
3302 and prepended with a #.
3309 and prepended with a #.
3303
3310
3304 * IPython/iplib.py (InteractiveShell.init_readline): added check
3311 * IPython/iplib.py (InteractiveShell.init_readline): added check
3305 in case MagicCompleter fails to be defined, so we don't crash.
3312 in case MagicCompleter fails to be defined, so we don't crash.
3306
3313
3307 2004-07-13 Fernando Perez <fperez@colorado.edu>
3314 2004-07-13 Fernando Perez <fperez@colorado.edu>
3308
3315
3309 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
3316 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
3310 of EPS if the requested filename ends in '.eps'.
3317 of EPS if the requested filename ends in '.eps'.
3311
3318
3312 2004-07-04 Fernando Perez <fperez@colorado.edu>
3319 2004-07-04 Fernando Perez <fperez@colorado.edu>
3313
3320
3314 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
3321 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
3315 escaping of quotes when calling the shell.
3322 escaping of quotes when calling the shell.
3316
3323
3317 2004-07-02 Fernando Perez <fperez@colorado.edu>
3324 2004-07-02 Fernando Perez <fperez@colorado.edu>
3318
3325
3319 * IPython/Prompts.py (CachedOutput.update): Fix problem with
3326 * IPython/Prompts.py (CachedOutput.update): Fix problem with
3320 gettext not working because we were clobbering '_'. Fixes
3327 gettext not working because we were clobbering '_'. Fixes
3321 http://www.scipy.net/roundup/ipython/issue6.
3328 http://www.scipy.net/roundup/ipython/issue6.
3322
3329
3323 2004-07-01 Fernando Perez <fperez@colorado.edu>
3330 2004-07-01 Fernando Perez <fperez@colorado.edu>
3324
3331
3325 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
3332 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
3326 into @cd. Patch by Ville.
3333 into @cd. Patch by Ville.
3327
3334
3328 * IPython/iplib.py (InteractiveShell.post_config_initialization):
3335 * IPython/iplib.py (InteractiveShell.post_config_initialization):
3329 new function to store things after ipmaker runs. Patch by Ville.
3336 new function to store things after ipmaker runs. Patch by Ville.
3330 Eventually this will go away once ipmaker is removed and the class
3337 Eventually this will go away once ipmaker is removed and the class
3331 gets cleaned up, but for now it's ok. Key functionality here is
3338 gets cleaned up, but for now it's ok. Key functionality here is
3332 the addition of the persistent storage mechanism, a dict for
3339 the addition of the persistent storage mechanism, a dict for
3333 keeping data across sessions (for now just bookmarks, but more can
3340 keeping data across sessions (for now just bookmarks, but more can
3334 be implemented later).
3341 be implemented later).
3335
3342
3336 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
3343 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
3337 persistent across sections. Patch by Ville, I modified it
3344 persistent across sections. Patch by Ville, I modified it
3338 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
3345 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
3339 added a '-l' option to list all bookmarks.
3346 added a '-l' option to list all bookmarks.
3340
3347
3341 * IPython/iplib.py (InteractiveShell.atexit_operations): new
3348 * IPython/iplib.py (InteractiveShell.atexit_operations): new
3342 center for cleanup. Registered with atexit.register(). I moved
3349 center for cleanup. Registered with atexit.register(). I moved
3343 here the old exit_cleanup(). After a patch by Ville.
3350 here the old exit_cleanup(). After a patch by Ville.
3344
3351
3345 * IPython/Magic.py (get_py_filename): added '~' to the accepted
3352 * IPython/Magic.py (get_py_filename): added '~' to the accepted
3346 characters in the hacked shlex_split for python 2.2.
3353 characters in the hacked shlex_split for python 2.2.
3347
3354
3348 * IPython/iplib.py (file_matches): more fixes to filenames with
3355 * IPython/iplib.py (file_matches): more fixes to filenames with
3349 whitespace in them. It's not perfect, but limitations in python's
3356 whitespace in them. It's not perfect, but limitations in python's
3350 readline make it impossible to go further.
3357 readline make it impossible to go further.
3351
3358
3352 2004-06-29 Fernando Perez <fperez@colorado.edu>
3359 2004-06-29 Fernando Perez <fperez@colorado.edu>
3353
3360
3354 * IPython/iplib.py (file_matches): escape whitespace correctly in
3361 * IPython/iplib.py (file_matches): escape whitespace correctly in
3355 filename completions. Bug reported by Ville.
3362 filename completions. Bug reported by Ville.
3356
3363
3357 2004-06-28 Fernando Perez <fperez@colorado.edu>
3364 2004-06-28 Fernando Perez <fperez@colorado.edu>
3358
3365
3359 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
3366 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
3360 the history file will be called 'history-PROFNAME' (or just
3367 the history file will be called 'history-PROFNAME' (or just
3361 'history' if no profile is loaded). I was getting annoyed at
3368 'history' if no profile is loaded). I was getting annoyed at
3362 getting my Numerical work history clobbered by pysh sessions.
3369 getting my Numerical work history clobbered by pysh sessions.
3363
3370
3364 * IPython/iplib.py (InteractiveShell.__init__): Internal
3371 * IPython/iplib.py (InteractiveShell.__init__): Internal
3365 getoutputerror() function so that we can honor the system_verbose
3372 getoutputerror() function so that we can honor the system_verbose
3366 flag for _all_ system calls. I also added escaping of #
3373 flag for _all_ system calls. I also added escaping of #
3367 characters here to avoid confusing Itpl.
3374 characters here to avoid confusing Itpl.
3368
3375
3369 * IPython/Magic.py (shlex_split): removed call to shell in
3376 * IPython/Magic.py (shlex_split): removed call to shell in
3370 parse_options and replaced it with shlex.split(). The annoying
3377 parse_options and replaced it with shlex.split(). The annoying
3371 part was that in Python 2.2, shlex.split() doesn't exist, so I had
3378 part was that in Python 2.2, shlex.split() doesn't exist, so I had
3372 to backport it from 2.3, with several frail hacks (the shlex
3379 to backport it from 2.3, with several frail hacks (the shlex
3373 module is rather limited in 2.2). Thanks to a suggestion by Ville
3380 module is rather limited in 2.2). Thanks to a suggestion by Ville
3374 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
3381 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
3375 problem.
3382 problem.
3376
3383
3377 (Magic.magic_system_verbose): new toggle to print the actual
3384 (Magic.magic_system_verbose): new toggle to print the actual
3378 system calls made by ipython. Mainly for debugging purposes.
3385 system calls made by ipython. Mainly for debugging purposes.
3379
3386
3380 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
3387 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
3381 doesn't support persistence. Reported (and fix suggested) by
3388 doesn't support persistence. Reported (and fix suggested) by
3382 Travis Caldwell <travis_caldwell2000@yahoo.com>.
3389 Travis Caldwell <travis_caldwell2000@yahoo.com>.
3383
3390
3384 2004-06-26 Fernando Perez <fperez@colorado.edu>
3391 2004-06-26 Fernando Perez <fperez@colorado.edu>
3385
3392
3386 * IPython/Logger.py (Logger.log): fix to handle correctly empty
3393 * IPython/Logger.py (Logger.log): fix to handle correctly empty
3387 continue prompts.
3394 continue prompts.
3388
3395
3389 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
3396 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
3390 function (basically a big docstring) and a few more things here to
3397 function (basically a big docstring) and a few more things here to
3391 speedup startup. pysh.py is now very lightweight. We want because
3398 speedup startup. pysh.py is now very lightweight. We want because
3392 it gets execfile'd, while InterpreterExec gets imported, so
3399 it gets execfile'd, while InterpreterExec gets imported, so
3393 byte-compilation saves time.
3400 byte-compilation saves time.
3394
3401
3395 2004-06-25 Fernando Perez <fperez@colorado.edu>
3402 2004-06-25 Fernando Perez <fperez@colorado.edu>
3396
3403
3397 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
3404 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
3398 -NUM', which was recently broken.
3405 -NUM', which was recently broken.
3399
3406
3400 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
3407 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
3401 in multi-line input (but not !!, which doesn't make sense there).
3408 in multi-line input (but not !!, which doesn't make sense there).
3402
3409
3403 * IPython/UserConfig/ipythonrc: made autoindent on by default.
3410 * IPython/UserConfig/ipythonrc: made autoindent on by default.
3404 It's just too useful, and people can turn it off in the less
3411 It's just too useful, and people can turn it off in the less
3405 common cases where it's a problem.
3412 common cases where it's a problem.
3406
3413
3407 2004-06-24 Fernando Perez <fperez@colorado.edu>
3414 2004-06-24 Fernando Perez <fperez@colorado.edu>
3408
3415
3409 * IPython/iplib.py (InteractiveShell._prefilter): big change -
3416 * IPython/iplib.py (InteractiveShell._prefilter): big change -
3410 special syntaxes (like alias calling) is now allied in multi-line
3417 special syntaxes (like alias calling) is now allied in multi-line
3411 input. This is still _very_ experimental, but it's necessary for
3418 input. This is still _very_ experimental, but it's necessary for
3412 efficient shell usage combining python looping syntax with system
3419 efficient shell usage combining python looping syntax with system
3413 calls. For now it's restricted to aliases, I don't think it
3420 calls. For now it's restricted to aliases, I don't think it
3414 really even makes sense to have this for magics.
3421 really even makes sense to have this for magics.
3415
3422
3416 2004-06-23 Fernando Perez <fperez@colorado.edu>
3423 2004-06-23 Fernando Perez <fperez@colorado.edu>
3417
3424
3418 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
3425 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
3419 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
3426 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
3420
3427
3421 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
3428 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
3422 extensions under Windows (after code sent by Gary Bishop). The
3429 extensions under Windows (after code sent by Gary Bishop). The
3423 extensions considered 'executable' are stored in IPython's rc
3430 extensions considered 'executable' are stored in IPython's rc
3424 structure as win_exec_ext.
3431 structure as win_exec_ext.
3425
3432
3426 * IPython/genutils.py (shell): new function, like system() but
3433 * IPython/genutils.py (shell): new function, like system() but
3427 without return value. Very useful for interactive shell work.
3434 without return value. Very useful for interactive shell work.
3428
3435
3429 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
3436 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
3430 delete aliases.
3437 delete aliases.
3431
3438
3432 * IPython/iplib.py (InteractiveShell.alias_table_update): make
3439 * IPython/iplib.py (InteractiveShell.alias_table_update): make
3433 sure that the alias table doesn't contain python keywords.
3440 sure that the alias table doesn't contain python keywords.
3434
3441
3435 2004-06-21 Fernando Perez <fperez@colorado.edu>
3442 2004-06-21 Fernando Perez <fperez@colorado.edu>
3436
3443
3437 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
3444 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
3438 non-existent items are found in $PATH. Reported by Thorsten.
3445 non-existent items are found in $PATH. Reported by Thorsten.
3439
3446
3440 2004-06-20 Fernando Perez <fperez@colorado.edu>
3447 2004-06-20 Fernando Perez <fperez@colorado.edu>
3441
3448
3442 * IPython/iplib.py (complete): modified the completer so that the
3449 * IPython/iplib.py (complete): modified the completer so that the
3443 order of priorities can be easily changed at runtime.
3450 order of priorities can be easily changed at runtime.
3444
3451
3445 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
3452 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
3446 Modified to auto-execute all lines beginning with '~', '/' or '.'.
3453 Modified to auto-execute all lines beginning with '~', '/' or '.'.
3447
3454
3448 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
3455 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
3449 expand Python variables prepended with $ in all system calls. The
3456 expand Python variables prepended with $ in all system calls. The
3450 same was done to InteractiveShell.handle_shell_escape. Now all
3457 same was done to InteractiveShell.handle_shell_escape. Now all
3451 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
3458 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
3452 expansion of python variables and expressions according to the
3459 expansion of python variables and expressions according to the
3453 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
3460 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
3454
3461
3455 Though PEP-215 has been rejected, a similar (but simpler) one
3462 Though PEP-215 has been rejected, a similar (but simpler) one
3456 seems like it will go into Python 2.4, PEP-292 -
3463 seems like it will go into Python 2.4, PEP-292 -
3457 http://www.python.org/peps/pep-0292.html.
3464 http://www.python.org/peps/pep-0292.html.
3458
3465
3459 I'll keep the full syntax of PEP-215, since IPython has since the
3466 I'll keep the full syntax of PEP-215, since IPython has since the
3460 start used Ka-Ping Yee's reference implementation discussed there
3467 start used Ka-Ping Yee's reference implementation discussed there
3461 (Itpl), and I actually like the powerful semantics it offers.
3468 (Itpl), and I actually like the powerful semantics it offers.
3462
3469
3463 In order to access normal shell variables, the $ has to be escaped
3470 In order to access normal shell variables, the $ has to be escaped
3464 via an extra $. For example:
3471 via an extra $. For example:
3465
3472
3466 In [7]: PATH='a python variable'
3473 In [7]: PATH='a python variable'
3467
3474
3468 In [8]: !echo $PATH
3475 In [8]: !echo $PATH
3469 a python variable
3476 a python variable
3470
3477
3471 In [9]: !echo $$PATH
3478 In [9]: !echo $$PATH
3472 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
3479 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
3473
3480
3474 (Magic.parse_options): escape $ so the shell doesn't evaluate
3481 (Magic.parse_options): escape $ so the shell doesn't evaluate
3475 things prematurely.
3482 things prematurely.
3476
3483
3477 * IPython/iplib.py (InteractiveShell.call_alias): added the
3484 * IPython/iplib.py (InteractiveShell.call_alias): added the
3478 ability for aliases to expand python variables via $.
3485 ability for aliases to expand python variables via $.
3479
3486
3480 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
3487 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
3481 system, now there's a @rehash/@rehashx pair of magics. These work
3488 system, now there's a @rehash/@rehashx pair of magics. These work
3482 like the csh rehash command, and can be invoked at any time. They
3489 like the csh rehash command, and can be invoked at any time. They
3483 build a table of aliases to everything in the user's $PATH
3490 build a table of aliases to everything in the user's $PATH
3484 (@rehash uses everything, @rehashx is slower but only adds
3491 (@rehash uses everything, @rehashx is slower but only adds
3485 executable files). With this, the pysh.py-based shell profile can
3492 executable files). With this, the pysh.py-based shell profile can
3486 now simply call rehash upon startup, and full access to all
3493 now simply call rehash upon startup, and full access to all
3487 programs in the user's path is obtained.
3494 programs in the user's path is obtained.
3488
3495
3489 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
3496 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
3490 functionality is now fully in place. I removed the old dynamic
3497 functionality is now fully in place. I removed the old dynamic
3491 code generation based approach, in favor of a much lighter one
3498 code generation based approach, in favor of a much lighter one
3492 based on a simple dict. The advantage is that this allows me to
3499 based on a simple dict. The advantage is that this allows me to
3493 now have thousands of aliases with negligible cost (unthinkable
3500 now have thousands of aliases with negligible cost (unthinkable
3494 with the old system).
3501 with the old system).
3495
3502
3496 2004-06-19 Fernando Perez <fperez@colorado.edu>
3503 2004-06-19 Fernando Perez <fperez@colorado.edu>
3497
3504
3498 * IPython/iplib.py (__init__): extended MagicCompleter class to
3505 * IPython/iplib.py (__init__): extended MagicCompleter class to
3499 also complete (last in priority) on user aliases.
3506 also complete (last in priority) on user aliases.
3500
3507
3501 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
3508 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
3502 call to eval.
3509 call to eval.
3503 (ItplNS.__init__): Added a new class which functions like Itpl,
3510 (ItplNS.__init__): Added a new class which functions like Itpl,
3504 but allows configuring the namespace for the evaluation to occur
3511 but allows configuring the namespace for the evaluation to occur
3505 in.
3512 in.
3506
3513
3507 2004-06-18 Fernando Perez <fperez@colorado.edu>
3514 2004-06-18 Fernando Perez <fperez@colorado.edu>
3508
3515
3509 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
3516 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
3510 better message when 'exit' or 'quit' are typed (a common newbie
3517 better message when 'exit' or 'quit' are typed (a common newbie
3511 confusion).
3518 confusion).
3512
3519
3513 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
3520 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
3514 check for Windows users.
3521 check for Windows users.
3515
3522
3516 * IPython/iplib.py (InteractiveShell.user_setup): removed
3523 * IPython/iplib.py (InteractiveShell.user_setup): removed
3517 disabling of colors for Windows. I'll test at runtime and issue a
3524 disabling of colors for Windows. I'll test at runtime and issue a
3518 warning if Gary's readline isn't found, as to nudge users to
3525 warning if Gary's readline isn't found, as to nudge users to
3519 download it.
3526 download it.
3520
3527
3521 2004-06-16 Fernando Perez <fperez@colorado.edu>
3528 2004-06-16 Fernando Perez <fperez@colorado.edu>
3522
3529
3523 * IPython/genutils.py (Stream.__init__): changed to print errors
3530 * IPython/genutils.py (Stream.__init__): changed to print errors
3524 to sys.stderr. I had a circular dependency here. Now it's
3531 to sys.stderr. I had a circular dependency here. Now it's
3525 possible to run ipython as IDLE's shell (consider this pre-alpha,
3532 possible to run ipython as IDLE's shell (consider this pre-alpha,
3526 since true stdout things end up in the starting terminal instead
3533 since true stdout things end up in the starting terminal instead
3527 of IDLE's out).
3534 of IDLE's out).
3528
3535
3529 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
3536 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
3530 users who haven't # updated their prompt_in2 definitions. Remove
3537 users who haven't # updated their prompt_in2 definitions. Remove
3531 eventually.
3538 eventually.
3532 (multiple_replace): added credit to original ASPN recipe.
3539 (multiple_replace): added credit to original ASPN recipe.
3533
3540
3534 2004-06-15 Fernando Perez <fperez@colorado.edu>
3541 2004-06-15 Fernando Perez <fperez@colorado.edu>
3535
3542
3536 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
3543 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
3537 list of auto-defined aliases.
3544 list of auto-defined aliases.
3538
3545
3539 2004-06-13 Fernando Perez <fperez@colorado.edu>
3546 2004-06-13 Fernando Perez <fperez@colorado.edu>
3540
3547
3541 * setup.py (scriptfiles): Don't trigger win_post_install unless an
3548 * setup.py (scriptfiles): Don't trigger win_post_install unless an
3542 install was really requested (so setup.py can be used for other
3549 install was really requested (so setup.py can be used for other
3543 things under Windows).
3550 things under Windows).
3544
3551
3545 2004-06-10 Fernando Perez <fperez@colorado.edu>
3552 2004-06-10 Fernando Perez <fperez@colorado.edu>
3546
3553
3547 * IPython/Logger.py (Logger.create_log): Manually remove any old
3554 * IPython/Logger.py (Logger.create_log): Manually remove any old
3548 backup, since os.remove may fail under Windows. Fixes bug
3555 backup, since os.remove may fail under Windows. Fixes bug
3549 reported by Thorsten.
3556 reported by Thorsten.
3550
3557
3551 2004-06-09 Fernando Perez <fperez@colorado.edu>
3558 2004-06-09 Fernando Perez <fperez@colorado.edu>
3552
3559
3553 * examples/example-embed.py: fixed all references to %n (replaced
3560 * examples/example-embed.py: fixed all references to %n (replaced
3554 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
3561 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
3555 for all examples and the manual as well.
3562 for all examples and the manual as well.
3556
3563
3557 2004-06-08 Fernando Perez <fperez@colorado.edu>
3564 2004-06-08 Fernando Perez <fperez@colorado.edu>
3558
3565
3559 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
3566 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
3560 alignment and color management. All 3 prompt subsystems now
3567 alignment and color management. All 3 prompt subsystems now
3561 inherit from BasePrompt.
3568 inherit from BasePrompt.
3562
3569
3563 * tools/release: updates for windows installer build and tag rpms
3570 * tools/release: updates for windows installer build and tag rpms
3564 with python version (since paths are fixed).
3571 with python version (since paths are fixed).
3565
3572
3566 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
3573 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
3567 which will become eventually obsolete. Also fixed the default
3574 which will become eventually obsolete. Also fixed the default
3568 prompt_in2 to use \D, so at least new users start with the correct
3575 prompt_in2 to use \D, so at least new users start with the correct
3569 defaults.
3576 defaults.
3570 WARNING: Users with existing ipythonrc files will need to apply
3577 WARNING: Users with existing ipythonrc files will need to apply
3571 this fix manually!
3578 this fix manually!
3572
3579
3573 * setup.py: make windows installer (.exe). This is finally the
3580 * setup.py: make windows installer (.exe). This is finally the
3574 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
3581 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
3575 which I hadn't included because it required Python 2.3 (or recent
3582 which I hadn't included because it required Python 2.3 (or recent
3576 distutils).
3583 distutils).
3577
3584
3578 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
3585 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
3579 usage of new '\D' escape.
3586 usage of new '\D' escape.
3580
3587
3581 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
3588 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
3582 lacks os.getuid())
3589 lacks os.getuid())
3583 (CachedOutput.set_colors): Added the ability to turn coloring
3590 (CachedOutput.set_colors): Added the ability to turn coloring
3584 on/off with @colors even for manually defined prompt colors. It
3591 on/off with @colors even for manually defined prompt colors. It
3585 uses a nasty global, but it works safely and via the generic color
3592 uses a nasty global, but it works safely and via the generic color
3586 handling mechanism.
3593 handling mechanism.
3587 (Prompt2.__init__): Introduced new escape '\D' for continuation
3594 (Prompt2.__init__): Introduced new escape '\D' for continuation
3588 prompts. It represents the counter ('\#') as dots.
3595 prompts. It represents the counter ('\#') as dots.
3589 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
3596 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
3590 need to update their ipythonrc files and replace '%n' with '\D' in
3597 need to update their ipythonrc files and replace '%n' with '\D' in
3591 their prompt_in2 settings everywhere. Sorry, but there's
3598 their prompt_in2 settings everywhere. Sorry, but there's
3592 otherwise no clean way to get all prompts to properly align. The
3599 otherwise no clean way to get all prompts to properly align. The
3593 ipythonrc shipped with IPython has been updated.
3600 ipythonrc shipped with IPython has been updated.
3594
3601
3595 2004-06-07 Fernando Perez <fperez@colorado.edu>
3602 2004-06-07 Fernando Perez <fperez@colorado.edu>
3596
3603
3597 * setup.py (isfile): Pass local_icons option to latex2html, so the
3604 * setup.py (isfile): Pass local_icons option to latex2html, so the
3598 resulting HTML file is self-contained. Thanks to
3605 resulting HTML file is self-contained. Thanks to
3599 dryice-AT-liu.com.cn for the tip.
3606 dryice-AT-liu.com.cn for the tip.
3600
3607
3601 * pysh.py: I created a new profile 'shell', which implements a
3608 * pysh.py: I created a new profile 'shell', which implements a
3602 _rudimentary_ IPython-based shell. This is in NO WAY a realy
3609 _rudimentary_ IPython-based shell. This is in NO WAY a realy
3603 system shell, nor will it become one anytime soon. It's mainly
3610 system shell, nor will it become one anytime soon. It's mainly
3604 meant to illustrate the use of the new flexible bash-like prompts.
3611 meant to illustrate the use of the new flexible bash-like prompts.
3605 I guess it could be used by hardy souls for true shell management,
3612 I guess it could be used by hardy souls for true shell management,
3606 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
3613 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
3607 profile. This uses the InterpreterExec extension provided by
3614 profile. This uses the InterpreterExec extension provided by
3608 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
3615 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
3609
3616
3610 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
3617 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
3611 auto-align itself with the length of the previous input prompt
3618 auto-align itself with the length of the previous input prompt
3612 (taking into account the invisible color escapes).
3619 (taking into account the invisible color escapes).
3613 (CachedOutput.__init__): Large restructuring of this class. Now
3620 (CachedOutput.__init__): Large restructuring of this class. Now
3614 all three prompts (primary1, primary2, output) are proper objects,
3621 all three prompts (primary1, primary2, output) are proper objects,
3615 managed by the 'parent' CachedOutput class. The code is still a
3622 managed by the 'parent' CachedOutput class. The code is still a
3616 bit hackish (all prompts share state via a pointer to the cache),
3623 bit hackish (all prompts share state via a pointer to the cache),
3617 but it's overall far cleaner than before.
3624 but it's overall far cleaner than before.
3618
3625
3619 * IPython/genutils.py (getoutputerror): modified to add verbose,
3626 * IPython/genutils.py (getoutputerror): modified to add verbose,
3620 debug and header options. This makes the interface of all getout*
3627 debug and header options. This makes the interface of all getout*
3621 functions uniform.
3628 functions uniform.
3622 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
3629 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
3623
3630
3624 * IPython/Magic.py (Magic.default_option): added a function to
3631 * IPython/Magic.py (Magic.default_option): added a function to
3625 allow registering default options for any magic command. This
3632 allow registering default options for any magic command. This
3626 makes it easy to have profiles which customize the magics globally
3633 makes it easy to have profiles which customize the magics globally
3627 for a certain use. The values set through this function are
3634 for a certain use. The values set through this function are
3628 picked up by the parse_options() method, which all magics should
3635 picked up by the parse_options() method, which all magics should
3629 use to parse their options.
3636 use to parse their options.
3630
3637
3631 * IPython/genutils.py (warn): modified the warnings framework to
3638 * IPython/genutils.py (warn): modified the warnings framework to
3632 use the Term I/O class. I'm trying to slowly unify all of
3639 use the Term I/O class. I'm trying to slowly unify all of
3633 IPython's I/O operations to pass through Term.
3640 IPython's I/O operations to pass through Term.
3634
3641
3635 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
3642 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
3636 the secondary prompt to correctly match the length of the primary
3643 the secondary prompt to correctly match the length of the primary
3637 one for any prompt. Now multi-line code will properly line up
3644 one for any prompt. Now multi-line code will properly line up
3638 even for path dependent prompts, such as the new ones available
3645 even for path dependent prompts, such as the new ones available
3639 via the prompt_specials.
3646 via the prompt_specials.
3640
3647
3641 2004-06-06 Fernando Perez <fperez@colorado.edu>
3648 2004-06-06 Fernando Perez <fperez@colorado.edu>
3642
3649
3643 * IPython/Prompts.py (prompt_specials): Added the ability to have
3650 * IPython/Prompts.py (prompt_specials): Added the ability to have
3644 bash-like special sequences in the prompts, which get
3651 bash-like special sequences in the prompts, which get
3645 automatically expanded. Things like hostname, current working
3652 automatically expanded. Things like hostname, current working
3646 directory and username are implemented already, but it's easy to
3653 directory and username are implemented already, but it's easy to
3647 add more in the future. Thanks to a patch by W.J. van der Laan
3654 add more in the future. Thanks to a patch by W.J. van der Laan
3648 <gnufnork-AT-hetdigitalegat.nl>
3655 <gnufnork-AT-hetdigitalegat.nl>
3649 (prompt_specials): Added color support for prompt strings, so
3656 (prompt_specials): Added color support for prompt strings, so
3650 users can define arbitrary color setups for their prompts.
3657 users can define arbitrary color setups for their prompts.
3651
3658
3652 2004-06-05 Fernando Perez <fperez@colorado.edu>
3659 2004-06-05 Fernando Perez <fperez@colorado.edu>
3653
3660
3654 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
3661 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
3655 code to load Gary Bishop's readline and configure it
3662 code to load Gary Bishop's readline and configure it
3656 automatically. Thanks to Gary for help on this.
3663 automatically. Thanks to Gary for help on this.
3657
3664
3658 2004-06-01 Fernando Perez <fperez@colorado.edu>
3665 2004-06-01 Fernando Perez <fperez@colorado.edu>
3659
3666
3660 * IPython/Logger.py (Logger.create_log): fix bug for logging
3667 * IPython/Logger.py (Logger.create_log): fix bug for logging
3661 with no filename (previous fix was incomplete).
3668 with no filename (previous fix was incomplete).
3662
3669
3663 2004-05-25 Fernando Perez <fperez@colorado.edu>
3670 2004-05-25 Fernando Perez <fperez@colorado.edu>
3664
3671
3665 * IPython/Magic.py (Magic.parse_options): fix bug where naked
3672 * IPython/Magic.py (Magic.parse_options): fix bug where naked
3666 parens would get passed to the shell.
3673 parens would get passed to the shell.
3667
3674
3668 2004-05-20 Fernando Perez <fperez@colorado.edu>
3675 2004-05-20 Fernando Perez <fperez@colorado.edu>
3669
3676
3670 * IPython/Magic.py (Magic.magic_prun): changed default profile
3677 * IPython/Magic.py (Magic.magic_prun): changed default profile
3671 sort order to 'time' (the more common profiling need).
3678 sort order to 'time' (the more common profiling need).
3672
3679
3673 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
3680 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
3674 so that source code shown is guaranteed in sync with the file on
3681 so that source code shown is guaranteed in sync with the file on
3675 disk (also changed in psource). Similar fix to the one for
3682 disk (also changed in psource). Similar fix to the one for
3676 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
3683 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
3677 <yann.ledu-AT-noos.fr>.
3684 <yann.ledu-AT-noos.fr>.
3678
3685
3679 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
3686 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
3680 with a single option would not be correctly parsed. Closes
3687 with a single option would not be correctly parsed. Closes
3681 http://www.scipy.net/roundup/ipython/issue14. This bug had been
3688 http://www.scipy.net/roundup/ipython/issue14. This bug had been
3682 introduced in 0.6.0 (on 2004-05-06).
3689 introduced in 0.6.0 (on 2004-05-06).
3683
3690
3684 2004-05-13 *** Released version 0.6.0
3691 2004-05-13 *** Released version 0.6.0
3685
3692
3686 2004-05-13 Fernando Perez <fperez@colorado.edu>
3693 2004-05-13 Fernando Perez <fperez@colorado.edu>
3687
3694
3688 * debian/: Added debian/ directory to CVS, so that debian support
3695 * debian/: Added debian/ directory to CVS, so that debian support
3689 is publicly accessible. The debian package is maintained by Jack
3696 is publicly accessible. The debian package is maintained by Jack
3690 Moffit <jack-AT-xiph.org>.
3697 Moffit <jack-AT-xiph.org>.
3691
3698
3692 * Documentation: included the notes about an ipython-based system
3699 * Documentation: included the notes about an ipython-based system
3693 shell (the hypothetical 'pysh') into the new_design.pdf document,
3700 shell (the hypothetical 'pysh') into the new_design.pdf document,
3694 so that these ideas get distributed to users along with the
3701 so that these ideas get distributed to users along with the
3695 official documentation.
3702 official documentation.
3696
3703
3697 2004-05-10 Fernando Perez <fperez@colorado.edu>
3704 2004-05-10 Fernando Perez <fperez@colorado.edu>
3698
3705
3699 * IPython/Logger.py (Logger.create_log): fix recently introduced
3706 * IPython/Logger.py (Logger.create_log): fix recently introduced
3700 bug (misindented line) where logstart would fail when not given an
3707 bug (misindented line) where logstart would fail when not given an
3701 explicit filename.
3708 explicit filename.
3702
3709
3703 2004-05-09 Fernando Perez <fperez@colorado.edu>
3710 2004-05-09 Fernando Perez <fperez@colorado.edu>
3704
3711
3705 * IPython/Magic.py (Magic.parse_options): skip system call when
3712 * IPython/Magic.py (Magic.parse_options): skip system call when
3706 there are no options to look for. Faster, cleaner for the common
3713 there are no options to look for. Faster, cleaner for the common
3707 case.
3714 case.
3708
3715
3709 * Documentation: many updates to the manual: describing Windows
3716 * Documentation: many updates to the manual: describing Windows
3710 support better, Gnuplot updates, credits, misc small stuff. Also
3717 support better, Gnuplot updates, credits, misc small stuff. Also
3711 updated the new_design doc a bit.
3718 updated the new_design doc a bit.
3712
3719
3713 2004-05-06 *** Released version 0.6.0.rc1
3720 2004-05-06 *** Released version 0.6.0.rc1
3714
3721
3715 2004-05-06 Fernando Perez <fperez@colorado.edu>
3722 2004-05-06 Fernando Perez <fperez@colorado.edu>
3716
3723
3717 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
3724 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
3718 operations to use the vastly more efficient list/''.join() method.
3725 operations to use the vastly more efficient list/''.join() method.
3719 (FormattedTB.text): Fix
3726 (FormattedTB.text): Fix
3720 http://www.scipy.net/roundup/ipython/issue12 - exception source
3727 http://www.scipy.net/roundup/ipython/issue12 - exception source
3721 extract not updated after reload. Thanks to Mike Salib
3728 extract not updated after reload. Thanks to Mike Salib
3722 <msalib-AT-mit.edu> for pinning the source of the problem.
3729 <msalib-AT-mit.edu> for pinning the source of the problem.
3723 Fortunately, the solution works inside ipython and doesn't require
3730 Fortunately, the solution works inside ipython and doesn't require
3724 any changes to python proper.
3731 any changes to python proper.
3725
3732
3726 * IPython/Magic.py (Magic.parse_options): Improved to process the
3733 * IPython/Magic.py (Magic.parse_options): Improved to process the
3727 argument list as a true shell would (by actually using the
3734 argument list as a true shell would (by actually using the
3728 underlying system shell). This way, all @magics automatically get
3735 underlying system shell). This way, all @magics automatically get
3729 shell expansion for variables. Thanks to a comment by Alex
3736 shell expansion for variables. Thanks to a comment by Alex
3730 Schmolck.
3737 Schmolck.
3731
3738
3732 2004-04-04 Fernando Perez <fperez@colorado.edu>
3739 2004-04-04 Fernando Perez <fperez@colorado.edu>
3733
3740
3734 * IPython/iplib.py (InteractiveShell.interact): Added a special
3741 * IPython/iplib.py (InteractiveShell.interact): Added a special
3735 trap for a debugger quit exception, which is basically impossible
3742 trap for a debugger quit exception, which is basically impossible
3736 to handle by normal mechanisms, given what pdb does to the stack.
3743 to handle by normal mechanisms, given what pdb does to the stack.
3737 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
3744 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
3738
3745
3739 2004-04-03 Fernando Perez <fperez@colorado.edu>
3746 2004-04-03 Fernando Perez <fperez@colorado.edu>
3740
3747
3741 * IPython/genutils.py (Term): Standardized the names of the Term
3748 * IPython/genutils.py (Term): Standardized the names of the Term
3742 class streams to cin/cout/cerr, following C++ naming conventions
3749 class streams to cin/cout/cerr, following C++ naming conventions
3743 (I can't use in/out/err because 'in' is not a valid attribute
3750 (I can't use in/out/err because 'in' is not a valid attribute
3744 name).
3751 name).
3745
3752
3746 * IPython/iplib.py (InteractiveShell.interact): don't increment
3753 * IPython/iplib.py (InteractiveShell.interact): don't increment
3747 the prompt if there's no user input. By Daniel 'Dang' Griffith
3754 the prompt if there's no user input. By Daniel 'Dang' Griffith
3748 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
3755 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
3749 Francois Pinard.
3756 Francois Pinard.
3750
3757
3751 2004-04-02 Fernando Perez <fperez@colorado.edu>
3758 2004-04-02 Fernando Perez <fperez@colorado.edu>
3752
3759
3753 * IPython/genutils.py (Stream.__init__): Modified to survive at
3760 * IPython/genutils.py (Stream.__init__): Modified to survive at
3754 least importing in contexts where stdin/out/err aren't true file
3761 least importing in contexts where stdin/out/err aren't true file
3755 objects, such as PyCrust (they lack fileno() and mode). However,
3762 objects, such as PyCrust (they lack fileno() and mode). However,
3756 the recovery facilities which rely on these things existing will
3763 the recovery facilities which rely on these things existing will
3757 not work.
3764 not work.
3758
3765
3759 2004-04-01 Fernando Perez <fperez@colorado.edu>
3766 2004-04-01 Fernando Perez <fperez@colorado.edu>
3760
3767
3761 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
3768 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
3762 use the new getoutputerror() function, so it properly
3769 use the new getoutputerror() function, so it properly
3763 distinguishes stdout/err.
3770 distinguishes stdout/err.
3764
3771
3765 * IPython/genutils.py (getoutputerror): added a function to
3772 * IPython/genutils.py (getoutputerror): added a function to
3766 capture separately the standard output and error of a command.
3773 capture separately the standard output and error of a command.
3767 After a comment from dang on the mailing lists. This code is
3774 After a comment from dang on the mailing lists. This code is
3768 basically a modified version of commands.getstatusoutput(), from
3775 basically a modified version of commands.getstatusoutput(), from
3769 the standard library.
3776 the standard library.
3770
3777
3771 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
3778 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
3772 '!!' as a special syntax (shorthand) to access @sx.
3779 '!!' as a special syntax (shorthand) to access @sx.
3773
3780
3774 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
3781 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
3775 command and return its output as a list split on '\n'.
3782 command and return its output as a list split on '\n'.
3776
3783
3777 2004-03-31 Fernando Perez <fperez@colorado.edu>
3784 2004-03-31 Fernando Perez <fperez@colorado.edu>
3778
3785
3779 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
3786 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
3780 method to dictionaries used as FakeModule instances if they lack
3787 method to dictionaries used as FakeModule instances if they lack
3781 it. At least pydoc in python2.3 breaks for runtime-defined
3788 it. At least pydoc in python2.3 breaks for runtime-defined
3782 functions without this hack. At some point I need to _really_
3789 functions without this hack. At some point I need to _really_
3783 understand what FakeModule is doing, because it's a gross hack.
3790 understand what FakeModule is doing, because it's a gross hack.
3784 But it solves Arnd's problem for now...
3791 But it solves Arnd's problem for now...
3785
3792
3786 2004-02-27 Fernando Perez <fperez@colorado.edu>
3793 2004-02-27 Fernando Perez <fperez@colorado.edu>
3787
3794
3788 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
3795 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
3789 mode would behave erratically. Also increased the number of
3796 mode would behave erratically. Also increased the number of
3790 possible logs in rotate mod to 999. Thanks to Rod Holland
3797 possible logs in rotate mod to 999. Thanks to Rod Holland
3791 <rhh@StructureLABS.com> for the report and fixes.
3798 <rhh@StructureLABS.com> for the report and fixes.
3792
3799
3793 2004-02-26 Fernando Perez <fperez@colorado.edu>
3800 2004-02-26 Fernando Perez <fperez@colorado.edu>
3794
3801
3795 * IPython/genutils.py (page): Check that the curses module really
3802 * IPython/genutils.py (page): Check that the curses module really
3796 has the initscr attribute before trying to use it. For some
3803 has the initscr attribute before trying to use it. For some
3797 reason, the Solaris curses module is missing this. I think this
3804 reason, the Solaris curses module is missing this. I think this
3798 should be considered a Solaris python bug, but I'm not sure.
3805 should be considered a Solaris python bug, but I'm not sure.
3799
3806
3800 2004-01-17 Fernando Perez <fperez@colorado.edu>
3807 2004-01-17 Fernando Perez <fperez@colorado.edu>
3801
3808
3802 * IPython/genutils.py (Stream.__init__): Changes to try to make
3809 * IPython/genutils.py (Stream.__init__): Changes to try to make
3803 ipython robust against stdin/out/err being closed by the user.
3810 ipython robust against stdin/out/err being closed by the user.
3804 This is 'user error' (and blocks a normal python session, at least
3811 This is 'user error' (and blocks a normal python session, at least
3805 the stdout case). However, Ipython should be able to survive such
3812 the stdout case). However, Ipython should be able to survive such
3806 instances of abuse as gracefully as possible. To simplify the
3813 instances of abuse as gracefully as possible. To simplify the
3807 coding and maintain compatibility with Gary Bishop's Term
3814 coding and maintain compatibility with Gary Bishop's Term
3808 contributions, I've made use of classmethods for this. I think
3815 contributions, I've made use of classmethods for this. I think
3809 this introduces a dependency on python 2.2.
3816 this introduces a dependency on python 2.2.
3810
3817
3811 2004-01-13 Fernando Perez <fperez@colorado.edu>
3818 2004-01-13 Fernando Perez <fperez@colorado.edu>
3812
3819
3813 * IPython/numutils.py (exp_safe): simplified the code a bit and
3820 * IPython/numutils.py (exp_safe): simplified the code a bit and
3814 removed the need for importing the kinds module altogether.
3821 removed the need for importing the kinds module altogether.
3815
3822
3816 2004-01-06 Fernando Perez <fperez@colorado.edu>
3823 2004-01-06 Fernando Perez <fperez@colorado.edu>
3817
3824
3818 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
3825 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
3819 a magic function instead, after some community feedback. No
3826 a magic function instead, after some community feedback. No
3820 special syntax will exist for it, but its name is deliberately
3827 special syntax will exist for it, but its name is deliberately
3821 very short.
3828 very short.
3822
3829
3823 2003-12-20 Fernando Perez <fperez@colorado.edu>
3830 2003-12-20 Fernando Perez <fperez@colorado.edu>
3824
3831
3825 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
3832 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
3826 new functionality, to automagically assign the result of a shell
3833 new functionality, to automagically assign the result of a shell
3827 command to a variable. I'll solicit some community feedback on
3834 command to a variable. I'll solicit some community feedback on
3828 this before making it permanent.
3835 this before making it permanent.
3829
3836
3830 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
3837 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
3831 requested about callables for which inspect couldn't obtain a
3838 requested about callables for which inspect couldn't obtain a
3832 proper argspec. Thanks to a crash report sent by Etienne
3839 proper argspec. Thanks to a crash report sent by Etienne
3833 Posthumus <etienne-AT-apple01.cs.vu.nl>.
3840 Posthumus <etienne-AT-apple01.cs.vu.nl>.
3834
3841
3835 2003-12-09 Fernando Perez <fperez@colorado.edu>
3842 2003-12-09 Fernando Perez <fperez@colorado.edu>
3836
3843
3837 * IPython/genutils.py (page): patch for the pager to work across
3844 * IPython/genutils.py (page): patch for the pager to work across
3838 various versions of Windows. By Gary Bishop.
3845 various versions of Windows. By Gary Bishop.
3839
3846
3840 2003-12-04 Fernando Perez <fperez@colorado.edu>
3847 2003-12-04 Fernando Perez <fperez@colorado.edu>
3841
3848
3842 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
3849 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
3843 Gnuplot.py version 1.7, whose internal names changed quite a bit.
3850 Gnuplot.py version 1.7, whose internal names changed quite a bit.
3844 While I tested this and it looks ok, there may still be corner
3851 While I tested this and it looks ok, there may still be corner
3845 cases I've missed.
3852 cases I've missed.
3846
3853
3847 2003-12-01 Fernando Perez <fperez@colorado.edu>
3854 2003-12-01 Fernando Perez <fperez@colorado.edu>
3848
3855
3849 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
3856 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
3850 where a line like 'p,q=1,2' would fail because the automagic
3857 where a line like 'p,q=1,2' would fail because the automagic
3851 system would be triggered for @p.
3858 system would be triggered for @p.
3852
3859
3853 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
3860 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
3854 cleanups, code unmodified.
3861 cleanups, code unmodified.
3855
3862
3856 * IPython/genutils.py (Term): added a class for IPython to handle
3863 * IPython/genutils.py (Term): added a class for IPython to handle
3857 output. In most cases it will just be a proxy for stdout/err, but
3864 output. In most cases it will just be a proxy for stdout/err, but
3858 having this allows modifications to be made for some platforms,
3865 having this allows modifications to be made for some platforms,
3859 such as handling color escapes under Windows. All of this code
3866 such as handling color escapes under Windows. All of this code
3860 was contributed by Gary Bishop, with minor modifications by me.
3867 was contributed by Gary Bishop, with minor modifications by me.
3861 The actual changes affect many files.
3868 The actual changes affect many files.
3862
3869
3863 2003-11-30 Fernando Perez <fperez@colorado.edu>
3870 2003-11-30 Fernando Perez <fperez@colorado.edu>
3864
3871
3865 * IPython/iplib.py (file_matches): new completion code, courtesy
3872 * IPython/iplib.py (file_matches): new completion code, courtesy
3866 of Jeff Collins. This enables filename completion again under
3873 of Jeff Collins. This enables filename completion again under
3867 python 2.3, which disabled it at the C level.
3874 python 2.3, which disabled it at the C level.
3868
3875
3869 2003-11-11 Fernando Perez <fperez@colorado.edu>
3876 2003-11-11 Fernando Perez <fperez@colorado.edu>
3870
3877
3871 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
3878 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
3872 for Numeric.array(map(...)), but often convenient.
3879 for Numeric.array(map(...)), but often convenient.
3873
3880
3874 2003-11-05 Fernando Perez <fperez@colorado.edu>
3881 2003-11-05 Fernando Perez <fperez@colorado.edu>
3875
3882
3876 * IPython/numutils.py (frange): Changed a call from int() to
3883 * IPython/numutils.py (frange): Changed a call from int() to
3877 int(round()) to prevent a problem reported with arange() in the
3884 int(round()) to prevent a problem reported with arange() in the
3878 numpy list.
3885 numpy list.
3879
3886
3880 2003-10-06 Fernando Perez <fperez@colorado.edu>
3887 2003-10-06 Fernando Perez <fperez@colorado.edu>
3881
3888
3882 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
3889 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
3883 prevent crashes if sys lacks an argv attribute (it happens with
3890 prevent crashes if sys lacks an argv attribute (it happens with
3884 embedded interpreters which build a bare-bones sys module).
3891 embedded interpreters which build a bare-bones sys module).
3885 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
3892 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
3886
3893
3887 2003-09-24 Fernando Perez <fperez@colorado.edu>
3894 2003-09-24 Fernando Perez <fperez@colorado.edu>
3888
3895
3889 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
3896 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
3890 to protect against poorly written user objects where __getattr__
3897 to protect against poorly written user objects where __getattr__
3891 raises exceptions other than AttributeError. Thanks to a bug
3898 raises exceptions other than AttributeError. Thanks to a bug
3892 report by Oliver Sander <osander-AT-gmx.de>.
3899 report by Oliver Sander <osander-AT-gmx.de>.
3893
3900
3894 * IPython/FakeModule.py (FakeModule.__repr__): this method was
3901 * IPython/FakeModule.py (FakeModule.__repr__): this method was
3895 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
3902 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
3896
3903
3897 2003-09-09 Fernando Perez <fperez@colorado.edu>
3904 2003-09-09 Fernando Perez <fperez@colorado.edu>
3898
3905
3899 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3906 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3900 unpacking a list whith a callable as first element would
3907 unpacking a list whith a callable as first element would
3901 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
3908 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
3902 Collins.
3909 Collins.
3903
3910
3904 2003-08-25 *** Released version 0.5.0
3911 2003-08-25 *** Released version 0.5.0
3905
3912
3906 2003-08-22 Fernando Perez <fperez@colorado.edu>
3913 2003-08-22 Fernando Perez <fperez@colorado.edu>
3907
3914
3908 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
3915 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
3909 improperly defined user exceptions. Thanks to feedback from Mark
3916 improperly defined user exceptions. Thanks to feedback from Mark
3910 Russell <mrussell-AT-verio.net>.
3917 Russell <mrussell-AT-verio.net>.
3911
3918
3912 2003-08-20 Fernando Perez <fperez@colorado.edu>
3919 2003-08-20 Fernando Perez <fperez@colorado.edu>
3913
3920
3914 * IPython/OInspect.py (Inspector.pinfo): changed String Form
3921 * IPython/OInspect.py (Inspector.pinfo): changed String Form
3915 printing so that it would print multi-line string forms starting
3922 printing so that it would print multi-line string forms starting
3916 with a new line. This way the formatting is better respected for
3923 with a new line. This way the formatting is better respected for
3917 objects which work hard to make nice string forms.
3924 objects which work hard to make nice string forms.
3918
3925
3919 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
3926 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
3920 autocall would overtake data access for objects with both
3927 autocall would overtake data access for objects with both
3921 __getitem__ and __call__.
3928 __getitem__ and __call__.
3922
3929
3923 2003-08-19 *** Released version 0.5.0-rc1
3930 2003-08-19 *** Released version 0.5.0-rc1
3924
3931
3925 2003-08-19 Fernando Perez <fperez@colorado.edu>
3932 2003-08-19 Fernando Perez <fperez@colorado.edu>
3926
3933
3927 * IPython/deep_reload.py (load_tail): single tiny change here
3934 * IPython/deep_reload.py (load_tail): single tiny change here
3928 seems to fix the long-standing bug of dreload() failing to work
3935 seems to fix the long-standing bug of dreload() failing to work
3929 for dotted names. But this module is pretty tricky, so I may have
3936 for dotted names. But this module is pretty tricky, so I may have
3930 missed some subtlety. Needs more testing!.
3937 missed some subtlety. Needs more testing!.
3931
3938
3932 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
3939 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
3933 exceptions which have badly implemented __str__ methods.
3940 exceptions which have badly implemented __str__ methods.
3934 (VerboseTB.text): harden against inspect.getinnerframes crashing,
3941 (VerboseTB.text): harden against inspect.getinnerframes crashing,
3935 which I've been getting reports about from Python 2.3 users. I
3942 which I've been getting reports about from Python 2.3 users. I
3936 wish I had a simple test case to reproduce the problem, so I could
3943 wish I had a simple test case to reproduce the problem, so I could
3937 either write a cleaner workaround or file a bug report if
3944 either write a cleaner workaround or file a bug report if
3938 necessary.
3945 necessary.
3939
3946
3940 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
3947 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
3941 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
3948 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
3942 a bug report by Tjabo Kloppenburg.
3949 a bug report by Tjabo Kloppenburg.
3943
3950
3944 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
3951 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
3945 crashes. Wrapped the pdb call in a blanket try/except, since pdb
3952 crashes. Wrapped the pdb call in a blanket try/except, since pdb
3946 seems rather unstable. Thanks to a bug report by Tjabo
3953 seems rather unstable. Thanks to a bug report by Tjabo
3947 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
3954 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
3948
3955
3949 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
3956 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
3950 this out soon because of the critical fixes in the inner loop for
3957 this out soon because of the critical fixes in the inner loop for
3951 generators.
3958 generators.
3952
3959
3953 * IPython/Magic.py (Magic.getargspec): removed. This (and
3960 * IPython/Magic.py (Magic.getargspec): removed. This (and
3954 _get_def) have been obsoleted by OInspect for a long time, I
3961 _get_def) have been obsoleted by OInspect for a long time, I
3955 hadn't noticed that they were dead code.
3962 hadn't noticed that they were dead code.
3956 (Magic._ofind): restored _ofind functionality for a few literals
3963 (Magic._ofind): restored _ofind functionality for a few literals
3957 (those in ["''",'""','[]','{}','()']). But it won't work anymore
3964 (those in ["''",'""','[]','{}','()']). But it won't work anymore
3958 for things like "hello".capitalize?, since that would require a
3965 for things like "hello".capitalize?, since that would require a
3959 potentially dangerous eval() again.
3966 potentially dangerous eval() again.
3960
3967
3961 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
3968 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
3962 logic a bit more to clean up the escapes handling and minimize the
3969 logic a bit more to clean up the escapes handling and minimize the
3963 use of _ofind to only necessary cases. The interactive 'feel' of
3970 use of _ofind to only necessary cases. The interactive 'feel' of
3964 IPython should have improved quite a bit with the changes in
3971 IPython should have improved quite a bit with the changes in
3965 _prefilter and _ofind (besides being far safer than before).
3972 _prefilter and _ofind (besides being far safer than before).
3966
3973
3967 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
3974 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
3968 obscure, never reported). Edit would fail to find the object to
3975 obscure, never reported). Edit would fail to find the object to
3969 edit under some circumstances.
3976 edit under some circumstances.
3970 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
3977 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
3971 which were causing double-calling of generators. Those eval calls
3978 which were causing double-calling of generators. Those eval calls
3972 were _very_ dangerous, since code with side effects could be
3979 were _very_ dangerous, since code with side effects could be
3973 triggered. As they say, 'eval is evil'... These were the
3980 triggered. As they say, 'eval is evil'... These were the
3974 nastiest evals in IPython. Besides, _ofind is now far simpler,
3981 nastiest evals in IPython. Besides, _ofind is now far simpler,
3975 and it should also be quite a bit faster. Its use of inspect is
3982 and it should also be quite a bit faster. Its use of inspect is
3976 also safer, so perhaps some of the inspect-related crashes I've
3983 also safer, so perhaps some of the inspect-related crashes I've
3977 seen lately with Python 2.3 might be taken care of. That will
3984 seen lately with Python 2.3 might be taken care of. That will
3978 need more testing.
3985 need more testing.
3979
3986
3980 2003-08-17 Fernando Perez <fperez@colorado.edu>
3987 2003-08-17 Fernando Perez <fperez@colorado.edu>
3981
3988
3982 * IPython/iplib.py (InteractiveShell._prefilter): significant
3989 * IPython/iplib.py (InteractiveShell._prefilter): significant
3983 simplifications to the logic for handling user escapes. Faster
3990 simplifications to the logic for handling user escapes. Faster
3984 and simpler code.
3991 and simpler code.
3985
3992
3986 2003-08-14 Fernando Perez <fperez@colorado.edu>
3993 2003-08-14 Fernando Perez <fperez@colorado.edu>
3987
3994
3988 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
3995 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
3989 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
3996 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
3990 but it should be quite a bit faster. And the recursive version
3997 but it should be quite a bit faster. And the recursive version
3991 generated O(log N) intermediate storage for all rank>1 arrays,
3998 generated O(log N) intermediate storage for all rank>1 arrays,
3992 even if they were contiguous.
3999 even if they were contiguous.
3993 (l1norm): Added this function.
4000 (l1norm): Added this function.
3994 (norm): Added this function for arbitrary norms (including
4001 (norm): Added this function for arbitrary norms (including
3995 l-infinity). l1 and l2 are still special cases for convenience
4002 l-infinity). l1 and l2 are still special cases for convenience
3996 and speed.
4003 and speed.
3997
4004
3998 2003-08-03 Fernando Perez <fperez@colorado.edu>
4005 2003-08-03 Fernando Perez <fperez@colorado.edu>
3999
4006
4000 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
4007 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
4001 exceptions, which now raise PendingDeprecationWarnings in Python
4008 exceptions, which now raise PendingDeprecationWarnings in Python
4002 2.3. There were some in Magic and some in Gnuplot2.
4009 2.3. There were some in Magic and some in Gnuplot2.
4003
4010
4004 2003-06-30 Fernando Perez <fperez@colorado.edu>
4011 2003-06-30 Fernando Perez <fperez@colorado.edu>
4005
4012
4006 * IPython/genutils.py (page): modified to call curses only for
4013 * IPython/genutils.py (page): modified to call curses only for
4007 terminals where TERM=='xterm'. After problems under many other
4014 terminals where TERM=='xterm'. After problems under many other
4008 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
4015 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
4009
4016
4010 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
4017 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
4011 would be triggered when readline was absent. This was just an old
4018 would be triggered when readline was absent. This was just an old
4012 debugging statement I'd forgotten to take out.
4019 debugging statement I'd forgotten to take out.
4013
4020
4014 2003-06-20 Fernando Perez <fperez@colorado.edu>
4021 2003-06-20 Fernando Perez <fperez@colorado.edu>
4015
4022
4016 * IPython/genutils.py (clock): modified to return only user time
4023 * IPython/genutils.py (clock): modified to return only user time
4017 (not counting system time), after a discussion on scipy. While
4024 (not counting system time), after a discussion on scipy. While
4018 system time may be a useful quantity occasionally, it may much
4025 system time may be a useful quantity occasionally, it may much
4019 more easily be skewed by occasional swapping or other similar
4026 more easily be skewed by occasional swapping or other similar
4020 activity.
4027 activity.
4021
4028
4022 2003-06-05 Fernando Perez <fperez@colorado.edu>
4029 2003-06-05 Fernando Perez <fperez@colorado.edu>
4023
4030
4024 * IPython/numutils.py (identity): new function, for building
4031 * IPython/numutils.py (identity): new function, for building
4025 arbitrary rank Kronecker deltas (mostly backwards compatible with
4032 arbitrary rank Kronecker deltas (mostly backwards compatible with
4026 Numeric.identity)
4033 Numeric.identity)
4027
4034
4028 2003-06-03 Fernando Perez <fperez@colorado.edu>
4035 2003-06-03 Fernando Perez <fperez@colorado.edu>
4029
4036
4030 * IPython/iplib.py (InteractiveShell.handle_magic): protect
4037 * IPython/iplib.py (InteractiveShell.handle_magic): protect
4031 arguments passed to magics with spaces, to allow trailing '\' to
4038 arguments passed to magics with spaces, to allow trailing '\' to
4032 work normally (mainly for Windows users).
4039 work normally (mainly for Windows users).
4033
4040
4034 2003-05-29 Fernando Perez <fperez@colorado.edu>
4041 2003-05-29 Fernando Perez <fperez@colorado.edu>
4035
4042
4036 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
4043 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
4037 instead of pydoc.help. This fixes a bizarre behavior where
4044 instead of pydoc.help. This fixes a bizarre behavior where
4038 printing '%s' % locals() would trigger the help system. Now
4045 printing '%s' % locals() would trigger the help system. Now
4039 ipython behaves like normal python does.
4046 ipython behaves like normal python does.
4040
4047
4041 Note that if one does 'from pydoc import help', the bizarre
4048 Note that if one does 'from pydoc import help', the bizarre
4042 behavior returns, but this will also happen in normal python, so
4049 behavior returns, but this will also happen in normal python, so
4043 it's not an ipython bug anymore (it has to do with how pydoc.help
4050 it's not an ipython bug anymore (it has to do with how pydoc.help
4044 is implemented).
4051 is implemented).
4045
4052
4046 2003-05-22 Fernando Perez <fperez@colorado.edu>
4053 2003-05-22 Fernando Perez <fperez@colorado.edu>
4047
4054
4048 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
4055 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
4049 return [] instead of None when nothing matches, also match to end
4056 return [] instead of None when nothing matches, also match to end
4050 of line. Patch by Gary Bishop.
4057 of line. Patch by Gary Bishop.
4051
4058
4052 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
4059 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
4053 protection as before, for files passed on the command line. This
4060 protection as before, for files passed on the command line. This
4054 prevents the CrashHandler from kicking in if user files call into
4061 prevents the CrashHandler from kicking in if user files call into
4055 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
4062 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
4056 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
4063 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
4057
4064
4058 2003-05-20 *** Released version 0.4.0
4065 2003-05-20 *** Released version 0.4.0
4059
4066
4060 2003-05-20 Fernando Perez <fperez@colorado.edu>
4067 2003-05-20 Fernando Perez <fperez@colorado.edu>
4061
4068
4062 * setup.py: added support for manpages. It's a bit hackish b/c of
4069 * setup.py: added support for manpages. It's a bit hackish b/c of
4063 a bug in the way the bdist_rpm distutils target handles gzipped
4070 a bug in the way the bdist_rpm distutils target handles gzipped
4064 manpages, but it works. After a patch by Jack.
4071 manpages, but it works. After a patch by Jack.
4065
4072
4066 2003-05-19 Fernando Perez <fperez@colorado.edu>
4073 2003-05-19 Fernando Perez <fperez@colorado.edu>
4067
4074
4068 * IPython/numutils.py: added a mockup of the kinds module, since
4075 * IPython/numutils.py: added a mockup of the kinds module, since
4069 it was recently removed from Numeric. This way, numutils will
4076 it was recently removed from Numeric. This way, numutils will
4070 work for all users even if they are missing kinds.
4077 work for all users even if they are missing kinds.
4071
4078
4072 * IPython/Magic.py (Magic._ofind): Harden against an inspect
4079 * IPython/Magic.py (Magic._ofind): Harden against an inspect
4073 failure, which can occur with SWIG-wrapped extensions. After a
4080 failure, which can occur with SWIG-wrapped extensions. After a
4074 crash report from Prabhu.
4081 crash report from Prabhu.
4075
4082
4076 2003-05-16 Fernando Perez <fperez@colorado.edu>
4083 2003-05-16 Fernando Perez <fperez@colorado.edu>
4077
4084
4078 * IPython/iplib.py (InteractiveShell.excepthook): New method to
4085 * IPython/iplib.py (InteractiveShell.excepthook): New method to
4079 protect ipython from user code which may call directly
4086 protect ipython from user code which may call directly
4080 sys.excepthook (this looks like an ipython crash to the user, even
4087 sys.excepthook (this looks like an ipython crash to the user, even
4081 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4088 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4082 This is especially important to help users of WxWindows, but may
4089 This is especially important to help users of WxWindows, but may
4083 also be useful in other cases.
4090 also be useful in other cases.
4084
4091
4085 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
4092 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
4086 an optional tb_offset to be specified, and to preserve exception
4093 an optional tb_offset to be specified, and to preserve exception
4087 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4094 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4088
4095
4089 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
4096 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
4090
4097
4091 2003-05-15 Fernando Perez <fperez@colorado.edu>
4098 2003-05-15 Fernando Perez <fperez@colorado.edu>
4092
4099
4093 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
4100 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
4094 installing for a new user under Windows.
4101 installing for a new user under Windows.
4095
4102
4096 2003-05-12 Fernando Perez <fperez@colorado.edu>
4103 2003-05-12 Fernando Perez <fperez@colorado.edu>
4097
4104
4098 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
4105 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
4099 handler for Emacs comint-based lines. Currently it doesn't do
4106 handler for Emacs comint-based lines. Currently it doesn't do
4100 much (but importantly, it doesn't update the history cache). In
4107 much (but importantly, it doesn't update the history cache). In
4101 the future it may be expanded if Alex needs more functionality
4108 the future it may be expanded if Alex needs more functionality
4102 there.
4109 there.
4103
4110
4104 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
4111 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
4105 info to crash reports.
4112 info to crash reports.
4106
4113
4107 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
4114 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
4108 just like Python's -c. Also fixed crash with invalid -color
4115 just like Python's -c. Also fixed crash with invalid -color
4109 option value at startup. Thanks to Will French
4116 option value at startup. Thanks to Will French
4110 <wfrench-AT-bestweb.net> for the bug report.
4117 <wfrench-AT-bestweb.net> for the bug report.
4111
4118
4112 2003-05-09 Fernando Perez <fperez@colorado.edu>
4119 2003-05-09 Fernando Perez <fperez@colorado.edu>
4113
4120
4114 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
4121 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
4115 to EvalDict (it's a mapping, after all) and simplified its code
4122 to EvalDict (it's a mapping, after all) and simplified its code
4116 quite a bit, after a nice discussion on c.l.py where Gustavo
4123 quite a bit, after a nice discussion on c.l.py where Gustavo
4117 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
4124 CΓ³rdova <gcordova-AT-sismex.com> suggested the new version.
4118
4125
4119 2003-04-30 Fernando Perez <fperez@colorado.edu>
4126 2003-04-30 Fernando Perez <fperez@colorado.edu>
4120
4127
4121 * IPython/genutils.py (timings_out): modified it to reduce its
4128 * IPython/genutils.py (timings_out): modified it to reduce its
4122 overhead in the common reps==1 case.
4129 overhead in the common reps==1 case.
4123
4130
4124 2003-04-29 Fernando Perez <fperez@colorado.edu>
4131 2003-04-29 Fernando Perez <fperez@colorado.edu>
4125
4132
4126 * IPython/genutils.py (timings_out): Modified to use the resource
4133 * IPython/genutils.py (timings_out): Modified to use the resource
4127 module, which avoids the wraparound problems of time.clock().
4134 module, which avoids the wraparound problems of time.clock().
4128
4135
4129 2003-04-17 *** Released version 0.2.15pre4
4136 2003-04-17 *** Released version 0.2.15pre4
4130
4137
4131 2003-04-17 Fernando Perez <fperez@colorado.edu>
4138 2003-04-17 Fernando Perez <fperez@colorado.edu>
4132
4139
4133 * setup.py (scriptfiles): Split windows-specific stuff over to a
4140 * setup.py (scriptfiles): Split windows-specific stuff over to a
4134 separate file, in an attempt to have a Windows GUI installer.
4141 separate file, in an attempt to have a Windows GUI installer.
4135 That didn't work, but part of the groundwork is done.
4142 That didn't work, but part of the groundwork is done.
4136
4143
4137 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
4144 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
4138 indent/unindent with 4 spaces. Particularly useful in combination
4145 indent/unindent with 4 spaces. Particularly useful in combination
4139 with the new auto-indent option.
4146 with the new auto-indent option.
4140
4147
4141 2003-04-16 Fernando Perez <fperez@colorado.edu>
4148 2003-04-16 Fernando Perez <fperez@colorado.edu>
4142
4149
4143 * IPython/Magic.py: various replacements of self.rc for
4150 * IPython/Magic.py: various replacements of self.rc for
4144 self.shell.rc. A lot more remains to be done to fully disentangle
4151 self.shell.rc. A lot more remains to be done to fully disentangle
4145 this class from the main Shell class.
4152 this class from the main Shell class.
4146
4153
4147 * IPython/GnuplotRuntime.py: added checks for mouse support so
4154 * IPython/GnuplotRuntime.py: added checks for mouse support so
4148 that we don't try to enable it if the current gnuplot doesn't
4155 that we don't try to enable it if the current gnuplot doesn't
4149 really support it. Also added checks so that we don't try to
4156 really support it. Also added checks so that we don't try to
4150 enable persist under Windows (where Gnuplot doesn't recognize the
4157 enable persist under Windows (where Gnuplot doesn't recognize the
4151 option).
4158 option).
4152
4159
4153 * IPython/iplib.py (InteractiveShell.interact): Added optional
4160 * IPython/iplib.py (InteractiveShell.interact): Added optional
4154 auto-indenting code, after a patch by King C. Shu
4161 auto-indenting code, after a patch by King C. Shu
4155 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
4162 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
4156 get along well with pasting indented code. If I ever figure out
4163 get along well with pasting indented code. If I ever figure out
4157 how to make that part go well, it will become on by default.
4164 how to make that part go well, it will become on by default.
4158
4165
4159 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
4166 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
4160 crash ipython if there was an unmatched '%' in the user's prompt
4167 crash ipython if there was an unmatched '%' in the user's prompt
4161 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4168 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4162
4169
4163 * IPython/iplib.py (InteractiveShell.interact): removed the
4170 * IPython/iplib.py (InteractiveShell.interact): removed the
4164 ability to ask the user whether he wants to crash or not at the
4171 ability to ask the user whether he wants to crash or not at the
4165 'last line' exception handler. Calling functions at that point
4172 'last line' exception handler. Calling functions at that point
4166 changes the stack, and the error reports would have incorrect
4173 changes the stack, and the error reports would have incorrect
4167 tracebacks.
4174 tracebacks.
4168
4175
4169 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
4176 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
4170 pass through a peger a pretty-printed form of any object. After a
4177 pass through a peger a pretty-printed form of any object. After a
4171 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
4178 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
4172
4179
4173 2003-04-14 Fernando Perez <fperez@colorado.edu>
4180 2003-04-14 Fernando Perez <fperez@colorado.edu>
4174
4181
4175 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
4182 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
4176 all files in ~ would be modified at first install (instead of
4183 all files in ~ would be modified at first install (instead of
4177 ~/.ipython). This could be potentially disastrous, as the
4184 ~/.ipython). This could be potentially disastrous, as the
4178 modification (make line-endings native) could damage binary files.
4185 modification (make line-endings native) could damage binary files.
4179
4186
4180 2003-04-10 Fernando Perez <fperez@colorado.edu>
4187 2003-04-10 Fernando Perez <fperez@colorado.edu>
4181
4188
4182 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
4189 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
4183 handle only lines which are invalid python. This now means that
4190 handle only lines which are invalid python. This now means that
4184 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
4191 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
4185 for the bug report.
4192 for the bug report.
4186
4193
4187 2003-04-01 Fernando Perez <fperez@colorado.edu>
4194 2003-04-01 Fernando Perez <fperez@colorado.edu>
4188
4195
4189 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
4196 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
4190 where failing to set sys.last_traceback would crash pdb.pm().
4197 where failing to set sys.last_traceback would crash pdb.pm().
4191 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
4198 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
4192 report.
4199 report.
4193
4200
4194 2003-03-25 Fernando Perez <fperez@colorado.edu>
4201 2003-03-25 Fernando Perez <fperez@colorado.edu>
4195
4202
4196 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
4203 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
4197 before printing it (it had a lot of spurious blank lines at the
4204 before printing it (it had a lot of spurious blank lines at the
4198 end).
4205 end).
4199
4206
4200 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
4207 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
4201 output would be sent 21 times! Obviously people don't use this
4208 output would be sent 21 times! Obviously people don't use this
4202 too often, or I would have heard about it.
4209 too often, or I would have heard about it.
4203
4210
4204 2003-03-24 Fernando Perez <fperez@colorado.edu>
4211 2003-03-24 Fernando Perez <fperez@colorado.edu>
4205
4212
4206 * setup.py (scriptfiles): renamed the data_files parameter from
4213 * setup.py (scriptfiles): renamed the data_files parameter from
4207 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
4214 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
4208 for the patch.
4215 for the patch.
4209
4216
4210 2003-03-20 Fernando Perez <fperez@colorado.edu>
4217 2003-03-20 Fernando Perez <fperez@colorado.edu>
4211
4218
4212 * IPython/genutils.py (error): added error() and fatal()
4219 * IPython/genutils.py (error): added error() and fatal()
4213 functions.
4220 functions.
4214
4221
4215 2003-03-18 *** Released version 0.2.15pre3
4222 2003-03-18 *** Released version 0.2.15pre3
4216
4223
4217 2003-03-18 Fernando Perez <fperez@colorado.edu>
4224 2003-03-18 Fernando Perez <fperez@colorado.edu>
4218
4225
4219 * setupext/install_data_ext.py
4226 * setupext/install_data_ext.py
4220 (install_data_ext.initialize_options): Class contributed by Jack
4227 (install_data_ext.initialize_options): Class contributed by Jack
4221 Moffit for fixing the old distutils hack. He is sending this to
4228 Moffit for fixing the old distutils hack. He is sending this to
4222 the distutils folks so in the future we may not need it as a
4229 the distutils folks so in the future we may not need it as a
4223 private fix.
4230 private fix.
4224
4231
4225 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
4232 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
4226 changes for Debian packaging. See his patch for full details.
4233 changes for Debian packaging. See his patch for full details.
4227 The old distutils hack of making the ipythonrc* files carry a
4234 The old distutils hack of making the ipythonrc* files carry a
4228 bogus .py extension is gone, at last. Examples were moved to a
4235 bogus .py extension is gone, at last. Examples were moved to a
4229 separate subdir under doc/, and the separate executable scripts
4236 separate subdir under doc/, and the separate executable scripts
4230 now live in their own directory. Overall a great cleanup. The
4237 now live in their own directory. Overall a great cleanup. The
4231 manual was updated to use the new files, and setup.py has been
4238 manual was updated to use the new files, and setup.py has been
4232 fixed for this setup.
4239 fixed for this setup.
4233
4240
4234 * IPython/PyColorize.py (Parser.usage): made non-executable and
4241 * IPython/PyColorize.py (Parser.usage): made non-executable and
4235 created a pycolor wrapper around it to be included as a script.
4242 created a pycolor wrapper around it to be included as a script.
4236
4243
4237 2003-03-12 *** Released version 0.2.15pre2
4244 2003-03-12 *** Released version 0.2.15pre2
4238
4245
4239 2003-03-12 Fernando Perez <fperez@colorado.edu>
4246 2003-03-12 Fernando Perez <fperez@colorado.edu>
4240
4247
4241 * IPython/ColorANSI.py (make_color_table): Finally fixed the
4248 * IPython/ColorANSI.py (make_color_table): Finally fixed the
4242 long-standing problem with garbage characters in some terminals.
4249 long-standing problem with garbage characters in some terminals.
4243 The issue was really that the \001 and \002 escapes must _only_ be
4250 The issue was really that the \001 and \002 escapes must _only_ be
4244 passed to input prompts (which call readline), but _never_ to
4251 passed to input prompts (which call readline), but _never_ to
4245 normal text to be printed on screen. I changed ColorANSI to have
4252 normal text to be printed on screen. I changed ColorANSI to have
4246 two classes: TermColors and InputTermColors, each with the
4253 two classes: TermColors and InputTermColors, each with the
4247 appropriate escapes for input prompts or normal text. The code in
4254 appropriate escapes for input prompts or normal text. The code in
4248 Prompts.py got slightly more complicated, but this very old and
4255 Prompts.py got slightly more complicated, but this very old and
4249 annoying bug is finally fixed.
4256 annoying bug is finally fixed.
4250
4257
4251 All the credit for nailing down the real origin of this problem
4258 All the credit for nailing down the real origin of this problem
4252 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
4259 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
4253 *Many* thanks to him for spending quite a bit of effort on this.
4260 *Many* thanks to him for spending quite a bit of effort on this.
4254
4261
4255 2003-03-05 *** Released version 0.2.15pre1
4262 2003-03-05 *** Released version 0.2.15pre1
4256
4263
4257 2003-03-03 Fernando Perez <fperez@colorado.edu>
4264 2003-03-03 Fernando Perez <fperez@colorado.edu>
4258
4265
4259 * IPython/FakeModule.py: Moved the former _FakeModule to a
4266 * IPython/FakeModule.py: Moved the former _FakeModule to a
4260 separate file, because it's also needed by Magic (to fix a similar
4267 separate file, because it's also needed by Magic (to fix a similar
4261 pickle-related issue in @run).
4268 pickle-related issue in @run).
4262
4269
4263 2003-03-02 Fernando Perez <fperez@colorado.edu>
4270 2003-03-02 Fernando Perez <fperez@colorado.edu>
4264
4271
4265 * IPython/Magic.py (Magic.magic_autocall): new magic to control
4272 * IPython/Magic.py (Magic.magic_autocall): new magic to control
4266 the autocall option at runtime.
4273 the autocall option at runtime.
4267 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
4274 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
4268 across Magic.py to start separating Magic from InteractiveShell.
4275 across Magic.py to start separating Magic from InteractiveShell.
4269 (Magic._ofind): Fixed to return proper namespace for dotted
4276 (Magic._ofind): Fixed to return proper namespace for dotted
4270 names. Before, a dotted name would always return 'not currently
4277 names. Before, a dotted name would always return 'not currently
4271 defined', because it would find the 'parent'. s.x would be found,
4278 defined', because it would find the 'parent'. s.x would be found,
4272 but since 'x' isn't defined by itself, it would get confused.
4279 but since 'x' isn't defined by itself, it would get confused.
4273 (Magic.magic_run): Fixed pickling problems reported by Ralf
4280 (Magic.magic_run): Fixed pickling problems reported by Ralf
4274 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
4281 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
4275 that I'd used when Mike Heeter reported similar issues at the
4282 that I'd used when Mike Heeter reported similar issues at the
4276 top-level, but now for @run. It boils down to injecting the
4283 top-level, but now for @run. It boils down to injecting the
4277 namespace where code is being executed with something that looks
4284 namespace where code is being executed with something that looks
4278 enough like a module to fool pickle.dump(). Since a pickle stores
4285 enough like a module to fool pickle.dump(). Since a pickle stores
4279 a named reference to the importing module, we need this for
4286 a named reference to the importing module, we need this for
4280 pickles to save something sensible.
4287 pickles to save something sensible.
4281
4288
4282 * IPython/ipmaker.py (make_IPython): added an autocall option.
4289 * IPython/ipmaker.py (make_IPython): added an autocall option.
4283
4290
4284 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
4291 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
4285 the auto-eval code. Now autocalling is an option, and the code is
4292 the auto-eval code. Now autocalling is an option, and the code is
4286 also vastly safer. There is no more eval() involved at all.
4293 also vastly safer. There is no more eval() involved at all.
4287
4294
4288 2003-03-01 Fernando Perez <fperez@colorado.edu>
4295 2003-03-01 Fernando Perez <fperez@colorado.edu>
4289
4296
4290 * IPython/Magic.py (Magic._ofind): Changed interface to return a
4297 * IPython/Magic.py (Magic._ofind): Changed interface to return a
4291 dict with named keys instead of a tuple.
4298 dict with named keys instead of a tuple.
4292
4299
4293 * IPython: Started using CVS for IPython as of 0.2.15pre1.
4300 * IPython: Started using CVS for IPython as of 0.2.15pre1.
4294
4301
4295 * setup.py (make_shortcut): Fixed message about directories
4302 * setup.py (make_shortcut): Fixed message about directories
4296 created during Windows installation (the directories were ok, just
4303 created during Windows installation (the directories were ok, just
4297 the printed message was misleading). Thanks to Chris Liechti
4304 the printed message was misleading). Thanks to Chris Liechti
4298 <cliechti-AT-gmx.net> for the heads up.
4305 <cliechti-AT-gmx.net> for the heads up.
4299
4306
4300 2003-02-21 Fernando Perez <fperez@colorado.edu>
4307 2003-02-21 Fernando Perez <fperez@colorado.edu>
4301
4308
4302 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
4309 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
4303 of ValueError exception when checking for auto-execution. This
4310 of ValueError exception when checking for auto-execution. This
4304 one is raised by things like Numeric arrays arr.flat when the
4311 one is raised by things like Numeric arrays arr.flat when the
4305 array is non-contiguous.
4312 array is non-contiguous.
4306
4313
4307 2003-01-31 Fernando Perez <fperez@colorado.edu>
4314 2003-01-31 Fernando Perez <fperez@colorado.edu>
4308
4315
4309 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
4316 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
4310 not return any value at all (even though the command would get
4317 not return any value at all (even though the command would get
4311 executed).
4318 executed).
4312 (xsys): Flush stdout right after printing the command to ensure
4319 (xsys): Flush stdout right after printing the command to ensure
4313 proper ordering of commands and command output in the total
4320 proper ordering of commands and command output in the total
4314 output.
4321 output.
4315 (SystemExec/xsys/bq): Switched the names of xsys/bq and
4322 (SystemExec/xsys/bq): Switched the names of xsys/bq and
4316 system/getoutput as defaults. The old ones are kept for
4323 system/getoutput as defaults. The old ones are kept for
4317 compatibility reasons, so no code which uses this library needs
4324 compatibility reasons, so no code which uses this library needs
4318 changing.
4325 changing.
4319
4326
4320 2003-01-27 *** Released version 0.2.14
4327 2003-01-27 *** Released version 0.2.14
4321
4328
4322 2003-01-25 Fernando Perez <fperez@colorado.edu>
4329 2003-01-25 Fernando Perez <fperez@colorado.edu>
4323
4330
4324 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
4331 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
4325 functions defined in previous edit sessions could not be re-edited
4332 functions defined in previous edit sessions could not be re-edited
4326 (because the temp files were immediately removed). Now temp files
4333 (because the temp files were immediately removed). Now temp files
4327 are removed only at IPython's exit.
4334 are removed only at IPython's exit.
4328 (Magic.magic_run): Improved @run to perform shell-like expansions
4335 (Magic.magic_run): Improved @run to perform shell-like expansions
4329 on its arguments (~users and $VARS). With this, @run becomes more
4336 on its arguments (~users and $VARS). With this, @run becomes more
4330 like a normal command-line.
4337 like a normal command-line.
4331
4338
4332 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
4339 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
4333 bugs related to embedding and cleaned up that code. A fairly
4340 bugs related to embedding and cleaned up that code. A fairly
4334 important one was the impossibility to access the global namespace
4341 important one was the impossibility to access the global namespace
4335 through the embedded IPython (only local variables were visible).
4342 through the embedded IPython (only local variables were visible).
4336
4343
4337 2003-01-14 Fernando Perez <fperez@colorado.edu>
4344 2003-01-14 Fernando Perez <fperez@colorado.edu>
4338
4345
4339 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
4346 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
4340 auto-calling to be a bit more conservative. Now it doesn't get
4347 auto-calling to be a bit more conservative. Now it doesn't get
4341 triggered if any of '!=()<>' are in the rest of the input line, to
4348 triggered if any of '!=()<>' are in the rest of the input line, to
4342 allow comparing callables. Thanks to Alex for the heads up.
4349 allow comparing callables. Thanks to Alex for the heads up.
4343
4350
4344 2003-01-07 Fernando Perez <fperez@colorado.edu>
4351 2003-01-07 Fernando Perez <fperez@colorado.edu>
4345
4352
4346 * IPython/genutils.py (page): fixed estimation of the number of
4353 * IPython/genutils.py (page): fixed estimation of the number of
4347 lines in a string to be paged to simply count newlines. This
4354 lines in a string to be paged to simply count newlines. This
4348 prevents over-guessing due to embedded escape sequences. A better
4355 prevents over-guessing due to embedded escape sequences. A better
4349 long-term solution would involve stripping out the control chars
4356 long-term solution would involve stripping out the control chars
4350 for the count, but it's potentially so expensive I just don't
4357 for the count, but it's potentially so expensive I just don't
4351 think it's worth doing.
4358 think it's worth doing.
4352
4359
4353 2002-12-19 *** Released version 0.2.14pre50
4360 2002-12-19 *** Released version 0.2.14pre50
4354
4361
4355 2002-12-19 Fernando Perez <fperez@colorado.edu>
4362 2002-12-19 Fernando Perez <fperez@colorado.edu>
4356
4363
4357 * tools/release (version): Changed release scripts to inform
4364 * tools/release (version): Changed release scripts to inform
4358 Andrea and build a NEWS file with a list of recent changes.
4365 Andrea and build a NEWS file with a list of recent changes.
4359
4366
4360 * IPython/ColorANSI.py (__all__): changed terminal detection
4367 * IPython/ColorANSI.py (__all__): changed terminal detection
4361 code. Seems to work better for xterms without breaking
4368 code. Seems to work better for xterms without breaking
4362 konsole. Will need more testing to determine if WinXP and Mac OSX
4369 konsole. Will need more testing to determine if WinXP and Mac OSX
4363 also work ok.
4370 also work ok.
4364
4371
4365 2002-12-18 *** Released version 0.2.14pre49
4372 2002-12-18 *** Released version 0.2.14pre49
4366
4373
4367 2002-12-18 Fernando Perez <fperez@colorado.edu>
4374 2002-12-18 Fernando Perez <fperez@colorado.edu>
4368
4375
4369 * Docs: added new info about Mac OSX, from Andrea.
4376 * Docs: added new info about Mac OSX, from Andrea.
4370
4377
4371 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
4378 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
4372 allow direct plotting of python strings whose format is the same
4379 allow direct plotting of python strings whose format is the same
4373 of gnuplot data files.
4380 of gnuplot data files.
4374
4381
4375 2002-12-16 Fernando Perez <fperez@colorado.edu>
4382 2002-12-16 Fernando Perez <fperez@colorado.edu>
4376
4383
4377 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
4384 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
4378 value of exit question to be acknowledged.
4385 value of exit question to be acknowledged.
4379
4386
4380 2002-12-03 Fernando Perez <fperez@colorado.edu>
4387 2002-12-03 Fernando Perez <fperez@colorado.edu>
4381
4388
4382 * IPython/ipmaker.py: removed generators, which had been added
4389 * IPython/ipmaker.py: removed generators, which had been added
4383 by mistake in an earlier debugging run. This was causing trouble
4390 by mistake in an earlier debugging run. This was causing trouble
4384 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
4391 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
4385 for pointing this out.
4392 for pointing this out.
4386
4393
4387 2002-11-17 Fernando Perez <fperez@colorado.edu>
4394 2002-11-17 Fernando Perez <fperez@colorado.edu>
4388
4395
4389 * Manual: updated the Gnuplot section.
4396 * Manual: updated the Gnuplot section.
4390
4397
4391 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
4398 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
4392 a much better split of what goes in Runtime and what goes in
4399 a much better split of what goes in Runtime and what goes in
4393 Interactive.
4400 Interactive.
4394
4401
4395 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
4402 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
4396 being imported from iplib.
4403 being imported from iplib.
4397
4404
4398 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
4405 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
4399 for command-passing. Now the global Gnuplot instance is called
4406 for command-passing. Now the global Gnuplot instance is called
4400 'gp' instead of 'g', which was really a far too fragile and
4407 'gp' instead of 'g', which was really a far too fragile and
4401 common name.
4408 common name.
4402
4409
4403 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
4410 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
4404 bounding boxes generated by Gnuplot for square plots.
4411 bounding boxes generated by Gnuplot for square plots.
4405
4412
4406 * IPython/genutils.py (popkey): new function added. I should
4413 * IPython/genutils.py (popkey): new function added. I should
4407 suggest this on c.l.py as a dict method, it seems useful.
4414 suggest this on c.l.py as a dict method, it seems useful.
4408
4415
4409 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
4416 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
4410 to transparently handle PostScript generation. MUCH better than
4417 to transparently handle PostScript generation. MUCH better than
4411 the previous plot_eps/replot_eps (which I removed now). The code
4418 the previous plot_eps/replot_eps (which I removed now). The code
4412 is also fairly clean and well documented now (including
4419 is also fairly clean and well documented now (including
4413 docstrings).
4420 docstrings).
4414
4421
4415 2002-11-13 Fernando Perez <fperez@colorado.edu>
4422 2002-11-13 Fernando Perez <fperez@colorado.edu>
4416
4423
4417 * IPython/Magic.py (Magic.magic_edit): fixed docstring
4424 * IPython/Magic.py (Magic.magic_edit): fixed docstring
4418 (inconsistent with options).
4425 (inconsistent with options).
4419
4426
4420 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
4427 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
4421 manually disabled, I don't know why. Fixed it.
4428 manually disabled, I don't know why. Fixed it.
4422 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
4429 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
4423 eps output.
4430 eps output.
4424
4431
4425 2002-11-12 Fernando Perez <fperez@colorado.edu>
4432 2002-11-12 Fernando Perez <fperez@colorado.edu>
4426
4433
4427 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
4434 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
4428 don't propagate up to caller. Fixes crash reported by François
4435 don't propagate up to caller. Fixes crash reported by François
4429 Pinard.
4436 Pinard.
4430
4437
4431 2002-11-09 Fernando Perez <fperez@colorado.edu>
4438 2002-11-09 Fernando Perez <fperez@colorado.edu>
4432
4439
4433 * IPython/ipmaker.py (make_IPython): fixed problem with writing
4440 * IPython/ipmaker.py (make_IPython): fixed problem with writing
4434 history file for new users.
4441 history file for new users.
4435 (make_IPython): fixed bug where initial install would leave the
4442 (make_IPython): fixed bug where initial install would leave the
4436 user running in the .ipython dir.
4443 user running in the .ipython dir.
4437 (make_IPython): fixed bug where config dir .ipython would be
4444 (make_IPython): fixed bug where config dir .ipython would be
4438 created regardless of the given -ipythondir option. Thanks to Cory
4445 created regardless of the given -ipythondir option. Thanks to Cory
4439 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
4446 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
4440
4447
4441 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
4448 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
4442 type confirmations. Will need to use it in all of IPython's code
4449 type confirmations. Will need to use it in all of IPython's code
4443 consistently.
4450 consistently.
4444
4451
4445 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
4452 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
4446 context to print 31 lines instead of the default 5. This will make
4453 context to print 31 lines instead of the default 5. This will make
4447 the crash reports extremely detailed in case the problem is in
4454 the crash reports extremely detailed in case the problem is in
4448 libraries I don't have access to.
4455 libraries I don't have access to.
4449
4456
4450 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
4457 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
4451 line of defense' code to still crash, but giving users fair
4458 line of defense' code to still crash, but giving users fair
4452 warning. I don't want internal errors to go unreported: if there's
4459 warning. I don't want internal errors to go unreported: if there's
4453 an internal problem, IPython should crash and generate a full
4460 an internal problem, IPython should crash and generate a full
4454 report.
4461 report.
4455
4462
4456 2002-11-08 Fernando Perez <fperez@colorado.edu>
4463 2002-11-08 Fernando Perez <fperez@colorado.edu>
4457
4464
4458 * IPython/iplib.py (InteractiveShell.interact): added code to trap
4465 * IPython/iplib.py (InteractiveShell.interact): added code to trap
4459 otherwise uncaught exceptions which can appear if people set
4466 otherwise uncaught exceptions which can appear if people set
4460 sys.stdout to something badly broken. Thanks to a crash report
4467 sys.stdout to something badly broken. Thanks to a crash report
4461 from henni-AT-mail.brainbot.com.
4468 from henni-AT-mail.brainbot.com.
4462
4469
4463 2002-11-04 Fernando Perez <fperez@colorado.edu>
4470 2002-11-04 Fernando Perez <fperez@colorado.edu>
4464
4471
4465 * IPython/iplib.py (InteractiveShell.interact): added
4472 * IPython/iplib.py (InteractiveShell.interact): added
4466 __IPYTHON__active to the builtins. It's a flag which goes on when
4473 __IPYTHON__active to the builtins. It's a flag which goes on when
4467 the interaction starts and goes off again when it stops. This
4474 the interaction starts and goes off again when it stops. This
4468 allows embedding code to detect being inside IPython. Before this
4475 allows embedding code to detect being inside IPython. Before this
4469 was done via __IPYTHON__, but that only shows that an IPython
4476 was done via __IPYTHON__, but that only shows that an IPython
4470 instance has been created.
4477 instance has been created.
4471
4478
4472 * IPython/Magic.py (Magic.magic_env): I realized that in a
4479 * IPython/Magic.py (Magic.magic_env): I realized that in a
4473 UserDict, instance.data holds the data as a normal dict. So I
4480 UserDict, instance.data holds the data as a normal dict. So I
4474 modified @env to return os.environ.data instead of rebuilding a
4481 modified @env to return os.environ.data instead of rebuilding a
4475 dict by hand.
4482 dict by hand.
4476
4483
4477 2002-11-02 Fernando Perez <fperez@colorado.edu>
4484 2002-11-02 Fernando Perez <fperez@colorado.edu>
4478
4485
4479 * IPython/genutils.py (warn): changed so that level 1 prints no
4486 * IPython/genutils.py (warn): changed so that level 1 prints no
4480 header. Level 2 is now the default (with 'WARNING' header, as
4487 header. Level 2 is now the default (with 'WARNING' header, as
4481 before). I think I tracked all places where changes were needed in
4488 before). I think I tracked all places where changes were needed in
4482 IPython, but outside code using the old level numbering may have
4489 IPython, but outside code using the old level numbering may have
4483 broken.
4490 broken.
4484
4491
4485 * IPython/iplib.py (InteractiveShell.runcode): added this to
4492 * IPython/iplib.py (InteractiveShell.runcode): added this to
4486 handle the tracebacks in SystemExit traps correctly. The previous
4493 handle the tracebacks in SystemExit traps correctly. The previous
4487 code (through interact) was printing more of the stack than
4494 code (through interact) was printing more of the stack than
4488 necessary, showing IPython internal code to the user.
4495 necessary, showing IPython internal code to the user.
4489
4496
4490 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
4497 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
4491 default. Now that the default at the confirmation prompt is yes,
4498 default. Now that the default at the confirmation prompt is yes,
4492 it's not so intrusive. François' argument that ipython sessions
4499 it's not so intrusive. François' argument that ipython sessions
4493 tend to be complex enough not to lose them from an accidental C-d,
4500 tend to be complex enough not to lose them from an accidental C-d,
4494 is a valid one.
4501 is a valid one.
4495
4502
4496 * IPython/iplib.py (InteractiveShell.interact): added a
4503 * IPython/iplib.py (InteractiveShell.interact): added a
4497 showtraceback() call to the SystemExit trap, and modified the exit
4504 showtraceback() call to the SystemExit trap, and modified the exit
4498 confirmation to have yes as the default.
4505 confirmation to have yes as the default.
4499
4506
4500 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
4507 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
4501 this file. It's been gone from the code for a long time, this was
4508 this file. It's been gone from the code for a long time, this was
4502 simply leftover junk.
4509 simply leftover junk.
4503
4510
4504 2002-11-01 Fernando Perez <fperez@colorado.edu>
4511 2002-11-01 Fernando Perez <fperez@colorado.edu>
4505
4512
4506 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
4513 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
4507 added. If set, IPython now traps EOF and asks for
4514 added. If set, IPython now traps EOF and asks for
4508 confirmation. After a request by François Pinard.
4515 confirmation. After a request by François Pinard.
4509
4516
4510 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
4517 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
4511 of @abort, and with a new (better) mechanism for handling the
4518 of @abort, and with a new (better) mechanism for handling the
4512 exceptions.
4519 exceptions.
4513
4520
4514 2002-10-27 Fernando Perez <fperez@colorado.edu>
4521 2002-10-27 Fernando Perez <fperez@colorado.edu>
4515
4522
4516 * IPython/usage.py (__doc__): updated the --help information and
4523 * IPython/usage.py (__doc__): updated the --help information and
4517 the ipythonrc file to indicate that -log generates
4524 the ipythonrc file to indicate that -log generates
4518 ./ipython.log. Also fixed the corresponding info in @logstart.
4525 ./ipython.log. Also fixed the corresponding info in @logstart.
4519 This and several other fixes in the manuals thanks to reports by
4526 This and several other fixes in the manuals thanks to reports by
4520 François Pinard <pinard-AT-iro.umontreal.ca>.
4527 François Pinard <pinard-AT-iro.umontreal.ca>.
4521
4528
4522 * IPython/Logger.py (Logger.switch_log): Fixed error message to
4529 * IPython/Logger.py (Logger.switch_log): Fixed error message to
4523 refer to @logstart (instead of @log, which doesn't exist).
4530 refer to @logstart (instead of @log, which doesn't exist).
4524
4531
4525 * IPython/iplib.py (InteractiveShell._prefilter): fixed
4532 * IPython/iplib.py (InteractiveShell._prefilter): fixed
4526 AttributeError crash. Thanks to Christopher Armstrong
4533 AttributeError crash. Thanks to Christopher Armstrong
4527 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
4534 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
4528 introduced recently (in 0.2.14pre37) with the fix to the eval
4535 introduced recently (in 0.2.14pre37) with the fix to the eval
4529 problem mentioned below.
4536 problem mentioned below.
4530
4537
4531 2002-10-17 Fernando Perez <fperez@colorado.edu>
4538 2002-10-17 Fernando Perez <fperez@colorado.edu>
4532
4539
4533 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
4540 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
4534 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
4541 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
4535
4542
4536 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
4543 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
4537 this function to fix a problem reported by Alex Schmolck. He saw
4544 this function to fix a problem reported by Alex Schmolck. He saw
4538 it with list comprehensions and generators, which were getting
4545 it with list comprehensions and generators, which were getting
4539 called twice. The real problem was an 'eval' call in testing for
4546 called twice. The real problem was an 'eval' call in testing for
4540 automagic which was evaluating the input line silently.
4547 automagic which was evaluating the input line silently.
4541
4548
4542 This is a potentially very nasty bug, if the input has side
4549 This is a potentially very nasty bug, if the input has side
4543 effects which must not be repeated. The code is much cleaner now,
4550 effects which must not be repeated. The code is much cleaner now,
4544 without any blanket 'except' left and with a regexp test for
4551 without any blanket 'except' left and with a regexp test for
4545 actual function names.
4552 actual function names.
4546
4553
4547 But an eval remains, which I'm not fully comfortable with. I just
4554 But an eval remains, which I'm not fully comfortable with. I just
4548 don't know how to find out if an expression could be a callable in
4555 don't know how to find out if an expression could be a callable in
4549 the user's namespace without doing an eval on the string. However
4556 the user's namespace without doing an eval on the string. However
4550 that string is now much more strictly checked so that no code
4557 that string is now much more strictly checked so that no code
4551 slips by, so the eval should only happen for things that can
4558 slips by, so the eval should only happen for things that can
4552 really be only function/method names.
4559 really be only function/method names.
4553
4560
4554 2002-10-15 Fernando Perez <fperez@colorado.edu>
4561 2002-10-15 Fernando Perez <fperez@colorado.edu>
4555
4562
4556 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
4563 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
4557 OSX information to main manual, removed README_Mac_OSX file from
4564 OSX information to main manual, removed README_Mac_OSX file from
4558 distribution. Also updated credits for recent additions.
4565 distribution. Also updated credits for recent additions.
4559
4566
4560 2002-10-10 Fernando Perez <fperez@colorado.edu>
4567 2002-10-10 Fernando Perez <fperez@colorado.edu>
4561
4568
4562 * README_Mac_OSX: Added a README for Mac OSX users for fixing
4569 * README_Mac_OSX: Added a README for Mac OSX users for fixing
4563 terminal-related issues. Many thanks to Andrea Riciputi
4570 terminal-related issues. Many thanks to Andrea Riciputi
4564 <andrea.riciputi-AT-libero.it> for writing it.
4571 <andrea.riciputi-AT-libero.it> for writing it.
4565
4572
4566 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
4573 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
4567 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4574 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4568
4575
4569 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
4576 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
4570 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
4577 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
4571 <syver-en-AT-online.no> who both submitted patches for this problem.
4578 <syver-en-AT-online.no> who both submitted patches for this problem.
4572
4579
4573 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
4580 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
4574 global embedding to make sure that things don't overwrite user
4581 global embedding to make sure that things don't overwrite user
4575 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
4582 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
4576
4583
4577 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
4584 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
4578 compatibility. Thanks to Hayden Callow
4585 compatibility. Thanks to Hayden Callow
4579 <h.callow-AT-elec.canterbury.ac.nz>
4586 <h.callow-AT-elec.canterbury.ac.nz>
4580
4587
4581 2002-10-04 Fernando Perez <fperez@colorado.edu>
4588 2002-10-04 Fernando Perez <fperez@colorado.edu>
4582
4589
4583 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
4590 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
4584 Gnuplot.File objects.
4591 Gnuplot.File objects.
4585
4592
4586 2002-07-23 Fernando Perez <fperez@colorado.edu>
4593 2002-07-23 Fernando Perez <fperez@colorado.edu>
4587
4594
4588 * IPython/genutils.py (timing): Added timings() and timing() for
4595 * IPython/genutils.py (timing): Added timings() and timing() for
4589 quick access to the most commonly needed data, the execution
4596 quick access to the most commonly needed data, the execution
4590 times. Old timing() renamed to timings_out().
4597 times. Old timing() renamed to timings_out().
4591
4598
4592 2002-07-18 Fernando Perez <fperez@colorado.edu>
4599 2002-07-18 Fernando Perez <fperez@colorado.edu>
4593
4600
4594 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
4601 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
4595 bug with nested instances disrupting the parent's tab completion.
4602 bug with nested instances disrupting the parent's tab completion.
4596
4603
4597 * IPython/iplib.py (all_completions): Added Alex Schmolck's
4604 * IPython/iplib.py (all_completions): Added Alex Schmolck's
4598 all_completions code to begin the emacs integration.
4605 all_completions code to begin the emacs integration.
4599
4606
4600 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
4607 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
4601 argument to allow titling individual arrays when plotting.
4608 argument to allow titling individual arrays when plotting.
4602
4609
4603 2002-07-15 Fernando Perez <fperez@colorado.edu>
4610 2002-07-15 Fernando Perez <fperez@colorado.edu>
4604
4611
4605 * setup.py (make_shortcut): changed to retrieve the value of
4612 * setup.py (make_shortcut): changed to retrieve the value of
4606 'Program Files' directory from the registry (this value changes in
4613 'Program Files' directory from the registry (this value changes in
4607 non-english versions of Windows). Thanks to Thomas Fanslau
4614 non-english versions of Windows). Thanks to Thomas Fanslau
4608 <tfanslau-AT-gmx.de> for the report.
4615 <tfanslau-AT-gmx.de> for the report.
4609
4616
4610 2002-07-10 Fernando Perez <fperez@colorado.edu>
4617 2002-07-10 Fernando Perez <fperez@colorado.edu>
4611
4618
4612 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
4619 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
4613 a bug in pdb, which crashes if a line with only whitespace is
4620 a bug in pdb, which crashes if a line with only whitespace is
4614 entered. Bug report submitted to sourceforge.
4621 entered. Bug report submitted to sourceforge.
4615
4622
4616 2002-07-09 Fernando Perez <fperez@colorado.edu>
4623 2002-07-09 Fernando Perez <fperez@colorado.edu>
4617
4624
4618 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
4625 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
4619 reporting exceptions (it's a bug in inspect.py, I just set a
4626 reporting exceptions (it's a bug in inspect.py, I just set a
4620 workaround).
4627 workaround).
4621
4628
4622 2002-07-08 Fernando Perez <fperez@colorado.edu>
4629 2002-07-08 Fernando Perez <fperez@colorado.edu>
4623
4630
4624 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
4631 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
4625 __IPYTHON__ in __builtins__ to show up in user_ns.
4632 __IPYTHON__ in __builtins__ to show up in user_ns.
4626
4633
4627 2002-07-03 Fernando Perez <fperez@colorado.edu>
4634 2002-07-03 Fernando Perez <fperez@colorado.edu>
4628
4635
4629 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
4636 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
4630 name from @gp_set_instance to @gp_set_default.
4637 name from @gp_set_instance to @gp_set_default.
4631
4638
4632 * IPython/ipmaker.py (make_IPython): default editor value set to
4639 * IPython/ipmaker.py (make_IPython): default editor value set to
4633 '0' (a string), to match the rc file. Otherwise will crash when
4640 '0' (a string), to match the rc file. Otherwise will crash when
4634 .strip() is called on it.
4641 .strip() is called on it.
4635
4642
4636
4643
4637 2002-06-28 Fernando Perez <fperez@colorado.edu>
4644 2002-06-28 Fernando Perez <fperez@colorado.edu>
4638
4645
4639 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
4646 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
4640 of files in current directory when a file is executed via
4647 of files in current directory when a file is executed via
4641 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
4648 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
4642
4649
4643 * setup.py (manfiles): fix for rpm builds, submitted by RA
4650 * setup.py (manfiles): fix for rpm builds, submitted by RA
4644 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
4651 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
4645
4652
4646 * IPython/ipmaker.py (make_IPython): fixed lookup of default
4653 * IPython/ipmaker.py (make_IPython): fixed lookup of default
4647 editor when set to '0'. Problem was, '0' evaluates to True (it's a
4654 editor when set to '0'. Problem was, '0' evaluates to True (it's a
4648 string!). A. Schmolck caught this one.
4655 string!). A. Schmolck caught this one.
4649
4656
4650 2002-06-27 Fernando Perez <fperez@colorado.edu>
4657 2002-06-27 Fernando Perez <fperez@colorado.edu>
4651
4658
4652 * IPython/ipmaker.py (make_IPython): fixed bug when running user
4659 * IPython/ipmaker.py (make_IPython): fixed bug when running user
4653 defined files at the cmd line. __name__ wasn't being set to
4660 defined files at the cmd line. __name__ wasn't being set to
4654 __main__.
4661 __main__.
4655
4662
4656 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
4663 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
4657 regular lists and tuples besides Numeric arrays.
4664 regular lists and tuples besides Numeric arrays.
4658
4665
4659 * IPython/Prompts.py (CachedOutput.__call__): Added output
4666 * IPython/Prompts.py (CachedOutput.__call__): Added output
4660 supression for input ending with ';'. Similar to Mathematica and
4667 supression for input ending with ';'. Similar to Mathematica and
4661 Matlab. The _* vars and Out[] list are still updated, just like
4668 Matlab. The _* vars and Out[] list are still updated, just like
4662 Mathematica behaves.
4669 Mathematica behaves.
4663
4670
4664 2002-06-25 Fernando Perez <fperez@colorado.edu>
4671 2002-06-25 Fernando Perez <fperez@colorado.edu>
4665
4672
4666 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
4673 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
4667 .ini extensions for profiels under Windows.
4674 .ini extensions for profiels under Windows.
4668
4675
4669 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
4676 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
4670 string form. Fix contributed by Alexander Schmolck
4677 string form. Fix contributed by Alexander Schmolck
4671 <a.schmolck-AT-gmx.net>
4678 <a.schmolck-AT-gmx.net>
4672
4679
4673 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
4680 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
4674 pre-configured Gnuplot instance.
4681 pre-configured Gnuplot instance.
4675
4682
4676 2002-06-21 Fernando Perez <fperez@colorado.edu>
4683 2002-06-21 Fernando Perez <fperez@colorado.edu>
4677
4684
4678 * IPython/numutils.py (exp_safe): new function, works around the
4685 * IPython/numutils.py (exp_safe): new function, works around the
4679 underflow problems in Numeric.
4686 underflow problems in Numeric.
4680 (log2): New fn. Safe log in base 2: returns exact integer answer
4687 (log2): New fn. Safe log in base 2: returns exact integer answer
4681 for exact integer powers of 2.
4688 for exact integer powers of 2.
4682
4689
4683 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
4690 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
4684 properly.
4691 properly.
4685
4692
4686 2002-06-20 Fernando Perez <fperez@colorado.edu>
4693 2002-06-20 Fernando Perez <fperez@colorado.edu>
4687
4694
4688 * IPython/genutils.py (timing): new function like
4695 * IPython/genutils.py (timing): new function like
4689 Mathematica's. Similar to time_test, but returns more info.
4696 Mathematica's. Similar to time_test, but returns more info.
4690
4697
4691 2002-06-18 Fernando Perez <fperez@colorado.edu>
4698 2002-06-18 Fernando Perez <fperez@colorado.edu>
4692
4699
4693 * IPython/Magic.py (Magic.magic_save): modified @save and @r
4700 * IPython/Magic.py (Magic.magic_save): modified @save and @r
4694 according to Mike Heeter's suggestions.
4701 according to Mike Heeter's suggestions.
4695
4702
4696 2002-06-16 Fernando Perez <fperez@colorado.edu>
4703 2002-06-16 Fernando Perez <fperez@colorado.edu>
4697
4704
4698 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
4705 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
4699 system. GnuplotMagic is gone as a user-directory option. New files
4706 system. GnuplotMagic is gone as a user-directory option. New files
4700 make it easier to use all the gnuplot stuff both from external
4707 make it easier to use all the gnuplot stuff both from external
4701 programs as well as from IPython. Had to rewrite part of
4708 programs as well as from IPython. Had to rewrite part of
4702 hardcopy() b/c of a strange bug: often the ps files simply don't
4709 hardcopy() b/c of a strange bug: often the ps files simply don't
4703 get created, and require a repeat of the command (often several
4710 get created, and require a repeat of the command (often several
4704 times).
4711 times).
4705
4712
4706 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
4713 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
4707 resolve output channel at call time, so that if sys.stderr has
4714 resolve output channel at call time, so that if sys.stderr has
4708 been redirected by user this gets honored.
4715 been redirected by user this gets honored.
4709
4716
4710 2002-06-13 Fernando Perez <fperez@colorado.edu>
4717 2002-06-13 Fernando Perez <fperez@colorado.edu>
4711
4718
4712 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
4719 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
4713 IPShell. Kept a copy with the old names to avoid breaking people's
4720 IPShell. Kept a copy with the old names to avoid breaking people's
4714 embedded code.
4721 embedded code.
4715
4722
4716 * IPython/ipython: simplified it to the bare minimum after
4723 * IPython/ipython: simplified it to the bare minimum after
4717 Holger's suggestions. Added info about how to use it in
4724 Holger's suggestions. Added info about how to use it in
4718 PYTHONSTARTUP.
4725 PYTHONSTARTUP.
4719
4726
4720 * IPython/Shell.py (IPythonShell): changed the options passing
4727 * IPython/Shell.py (IPythonShell): changed the options passing
4721 from a string with funky %s replacements to a straight list. Maybe
4728 from a string with funky %s replacements to a straight list. Maybe
4722 a bit more typing, but it follows sys.argv conventions, so there's
4729 a bit more typing, but it follows sys.argv conventions, so there's
4723 less special-casing to remember.
4730 less special-casing to remember.
4724
4731
4725 2002-06-12 Fernando Perez <fperez@colorado.edu>
4732 2002-06-12 Fernando Perez <fperez@colorado.edu>
4726
4733
4727 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
4734 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
4728 command. Thanks to a suggestion by Mike Heeter.
4735 command. Thanks to a suggestion by Mike Heeter.
4729 (Magic.magic_pfile): added behavior to look at filenames if given
4736 (Magic.magic_pfile): added behavior to look at filenames if given
4730 arg is not a defined object.
4737 arg is not a defined object.
4731 (Magic.magic_save): New @save function to save code snippets. Also
4738 (Magic.magic_save): New @save function to save code snippets. Also
4732 a Mike Heeter idea.
4739 a Mike Heeter idea.
4733
4740
4734 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
4741 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
4735 plot() and replot(). Much more convenient now, especially for
4742 plot() and replot(). Much more convenient now, especially for
4736 interactive use.
4743 interactive use.
4737
4744
4738 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
4745 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
4739 filenames.
4746 filenames.
4740
4747
4741 2002-06-02 Fernando Perez <fperez@colorado.edu>
4748 2002-06-02 Fernando Perez <fperez@colorado.edu>
4742
4749
4743 * IPython/Struct.py (Struct.__init__): modified to admit
4750 * IPython/Struct.py (Struct.__init__): modified to admit
4744 initialization via another struct.
4751 initialization via another struct.
4745
4752
4746 * IPython/genutils.py (SystemExec.__init__): New stateful
4753 * IPython/genutils.py (SystemExec.__init__): New stateful
4747 interface to xsys and bq. Useful for writing system scripts.
4754 interface to xsys and bq. Useful for writing system scripts.
4748
4755
4749 2002-05-30 Fernando Perez <fperez@colorado.edu>
4756 2002-05-30 Fernando Perez <fperez@colorado.edu>
4750
4757
4751 * MANIFEST.in: Changed docfile selection to exclude all the lyx
4758 * MANIFEST.in: Changed docfile selection to exclude all the lyx
4752 documents. This will make the user download smaller (it's getting
4759 documents. This will make the user download smaller (it's getting
4753 too big).
4760 too big).
4754
4761
4755 2002-05-29 Fernando Perez <fperez@colorado.edu>
4762 2002-05-29 Fernando Perez <fperez@colorado.edu>
4756
4763
4757 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
4764 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
4758 fix problems with shelve and pickle. Seems to work, but I don't
4765 fix problems with shelve and pickle. Seems to work, but I don't
4759 know if corner cases break it. Thanks to Mike Heeter
4766 know if corner cases break it. Thanks to Mike Heeter
4760 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
4767 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
4761
4768
4762 2002-05-24 Fernando Perez <fperez@colorado.edu>
4769 2002-05-24 Fernando Perez <fperez@colorado.edu>
4763
4770
4764 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
4771 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
4765 macros having broken.
4772 macros having broken.
4766
4773
4767 2002-05-21 Fernando Perez <fperez@colorado.edu>
4774 2002-05-21 Fernando Perez <fperez@colorado.edu>
4768
4775
4769 * IPython/Magic.py (Magic.magic_logstart): fixed recently
4776 * IPython/Magic.py (Magic.magic_logstart): fixed recently
4770 introduced logging bug: all history before logging started was
4777 introduced logging bug: all history before logging started was
4771 being written one character per line! This came from the redesign
4778 being written one character per line! This came from the redesign
4772 of the input history as a special list which slices to strings,
4779 of the input history as a special list which slices to strings,
4773 not to lists.
4780 not to lists.
4774
4781
4775 2002-05-20 Fernando Perez <fperez@colorado.edu>
4782 2002-05-20 Fernando Perez <fperez@colorado.edu>
4776
4783
4777 * IPython/Prompts.py (CachedOutput.__init__): made the color table
4784 * IPython/Prompts.py (CachedOutput.__init__): made the color table
4778 be an attribute of all classes in this module. The design of these
4785 be an attribute of all classes in this module. The design of these
4779 classes needs some serious overhauling.
4786 classes needs some serious overhauling.
4780
4787
4781 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
4788 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
4782 which was ignoring '_' in option names.
4789 which was ignoring '_' in option names.
4783
4790
4784 * IPython/ultraTB.py (FormattedTB.__init__): Changed
4791 * IPython/ultraTB.py (FormattedTB.__init__): Changed
4785 'Verbose_novars' to 'Context' and made it the new default. It's a
4792 'Verbose_novars' to 'Context' and made it the new default. It's a
4786 bit more readable and also safer than verbose.
4793 bit more readable and also safer than verbose.
4787
4794
4788 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
4795 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
4789 triple-quoted strings.
4796 triple-quoted strings.
4790
4797
4791 * IPython/OInspect.py (__all__): new module exposing the object
4798 * IPython/OInspect.py (__all__): new module exposing the object
4792 introspection facilities. Now the corresponding magics are dummy
4799 introspection facilities. Now the corresponding magics are dummy
4793 wrappers around this. Having this module will make it much easier
4800 wrappers around this. Having this module will make it much easier
4794 to put these functions into our modified pdb.
4801 to put these functions into our modified pdb.
4795 This new object inspector system uses the new colorizing module,
4802 This new object inspector system uses the new colorizing module,
4796 so source code and other things are nicely syntax highlighted.
4803 so source code and other things are nicely syntax highlighted.
4797
4804
4798 2002-05-18 Fernando Perez <fperez@colorado.edu>
4805 2002-05-18 Fernando Perez <fperez@colorado.edu>
4799
4806
4800 * IPython/ColorANSI.py: Split the coloring tools into a separate
4807 * IPython/ColorANSI.py: Split the coloring tools into a separate
4801 module so I can use them in other code easier (they were part of
4808 module so I can use them in other code easier (they were part of
4802 ultraTB).
4809 ultraTB).
4803
4810
4804 2002-05-17 Fernando Perez <fperez@colorado.edu>
4811 2002-05-17 Fernando Perez <fperez@colorado.edu>
4805
4812
4806 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4813 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4807 fixed it to set the global 'g' also to the called instance, as
4814 fixed it to set the global 'g' also to the called instance, as
4808 long as 'g' was still a gnuplot instance (so it doesn't overwrite
4815 long as 'g' was still a gnuplot instance (so it doesn't overwrite
4809 user's 'g' variables).
4816 user's 'g' variables).
4810
4817
4811 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
4818 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
4812 global variables (aliases to _ih,_oh) so that users which expect
4819 global variables (aliases to _ih,_oh) so that users which expect
4813 In[5] or Out[7] to work aren't unpleasantly surprised.
4820 In[5] or Out[7] to work aren't unpleasantly surprised.
4814 (InputList.__getslice__): new class to allow executing slices of
4821 (InputList.__getslice__): new class to allow executing slices of
4815 input history directly. Very simple class, complements the use of
4822 input history directly. Very simple class, complements the use of
4816 macros.
4823 macros.
4817
4824
4818 2002-05-16 Fernando Perez <fperez@colorado.edu>
4825 2002-05-16 Fernando Perez <fperez@colorado.edu>
4819
4826
4820 * setup.py (docdirbase): make doc directory be just doc/IPython
4827 * setup.py (docdirbase): make doc directory be just doc/IPython
4821 without version numbers, it will reduce clutter for users.
4828 without version numbers, it will reduce clutter for users.
4822
4829
4823 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
4830 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
4824 execfile call to prevent possible memory leak. See for details:
4831 execfile call to prevent possible memory leak. See for details:
4825 http://mail.python.org/pipermail/python-list/2002-February/088476.html
4832 http://mail.python.org/pipermail/python-list/2002-February/088476.html
4826
4833
4827 2002-05-15 Fernando Perez <fperez@colorado.edu>
4834 2002-05-15 Fernando Perez <fperez@colorado.edu>
4828
4835
4829 * IPython/Magic.py (Magic.magic_psource): made the object
4836 * IPython/Magic.py (Magic.magic_psource): made the object
4830 introspection names be more standard: pdoc, pdef, pfile and
4837 introspection names be more standard: pdoc, pdef, pfile and
4831 psource. They all print/page their output, and it makes
4838 psource. They all print/page their output, and it makes
4832 remembering them easier. Kept old names for compatibility as
4839 remembering them easier. Kept old names for compatibility as
4833 aliases.
4840 aliases.
4834
4841
4835 2002-05-14 Fernando Perez <fperez@colorado.edu>
4842 2002-05-14 Fernando Perez <fperez@colorado.edu>
4836
4843
4837 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
4844 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
4838 what the mouse problem was. The trick is to use gnuplot with temp
4845 what the mouse problem was. The trick is to use gnuplot with temp
4839 files and NOT with pipes (for data communication), because having
4846 files and NOT with pipes (for data communication), because having
4840 both pipes and the mouse on is bad news.
4847 both pipes and the mouse on is bad news.
4841
4848
4842 2002-05-13 Fernando Perez <fperez@colorado.edu>
4849 2002-05-13 Fernando Perez <fperez@colorado.edu>
4843
4850
4844 * IPython/Magic.py (Magic._ofind): fixed namespace order search
4851 * IPython/Magic.py (Magic._ofind): fixed namespace order search
4845 bug. Information would be reported about builtins even when
4852 bug. Information would be reported about builtins even when
4846 user-defined functions overrode them.
4853 user-defined functions overrode them.
4847
4854
4848 2002-05-11 Fernando Perez <fperez@colorado.edu>
4855 2002-05-11 Fernando Perez <fperez@colorado.edu>
4849
4856
4850 * IPython/__init__.py (__all__): removed FlexCompleter from
4857 * IPython/__init__.py (__all__): removed FlexCompleter from
4851 __all__ so that things don't fail in platforms without readline.
4858 __all__ so that things don't fail in platforms without readline.
4852
4859
4853 2002-05-10 Fernando Perez <fperez@colorado.edu>
4860 2002-05-10 Fernando Perez <fperez@colorado.edu>
4854
4861
4855 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
4862 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
4856 it requires Numeric, effectively making Numeric a dependency for
4863 it requires Numeric, effectively making Numeric a dependency for
4857 IPython.
4864 IPython.
4858
4865
4859 * Released 0.2.13
4866 * Released 0.2.13
4860
4867
4861 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
4868 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
4862 profiler interface. Now all the major options from the profiler
4869 profiler interface. Now all the major options from the profiler
4863 module are directly supported in IPython, both for single
4870 module are directly supported in IPython, both for single
4864 expressions (@prun) and for full programs (@run -p).
4871 expressions (@prun) and for full programs (@run -p).
4865
4872
4866 2002-05-09 Fernando Perez <fperez@colorado.edu>
4873 2002-05-09 Fernando Perez <fperez@colorado.edu>
4867
4874
4868 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
4875 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
4869 magic properly formatted for screen.
4876 magic properly formatted for screen.
4870
4877
4871 * setup.py (make_shortcut): Changed things to put pdf version in
4878 * setup.py (make_shortcut): Changed things to put pdf version in
4872 doc/ instead of doc/manual (had to change lyxport a bit).
4879 doc/ instead of doc/manual (had to change lyxport a bit).
4873
4880
4874 * IPython/Magic.py (Profile.string_stats): made profile runs go
4881 * IPython/Magic.py (Profile.string_stats): made profile runs go
4875 through pager (they are long and a pager allows searching, saving,
4882 through pager (they are long and a pager allows searching, saving,
4876 etc.)
4883 etc.)
4877
4884
4878 2002-05-08 Fernando Perez <fperez@colorado.edu>
4885 2002-05-08 Fernando Perez <fperez@colorado.edu>
4879
4886
4880 * Released 0.2.12
4887 * Released 0.2.12
4881
4888
4882 2002-05-06 Fernando Perez <fperez@colorado.edu>
4889 2002-05-06 Fernando Perez <fperez@colorado.edu>
4883
4890
4884 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
4891 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
4885 introduced); 'hist n1 n2' was broken.
4892 introduced); 'hist n1 n2' was broken.
4886 (Magic.magic_pdb): added optional on/off arguments to @pdb
4893 (Magic.magic_pdb): added optional on/off arguments to @pdb
4887 (Magic.magic_run): added option -i to @run, which executes code in
4894 (Magic.magic_run): added option -i to @run, which executes code in
4888 the IPython namespace instead of a clean one. Also added @irun as
4895 the IPython namespace instead of a clean one. Also added @irun as
4889 an alias to @run -i.
4896 an alias to @run -i.
4890
4897
4891 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4898 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4892 fixed (it didn't really do anything, the namespaces were wrong).
4899 fixed (it didn't really do anything, the namespaces were wrong).
4893
4900
4894 * IPython/Debugger.py (__init__): Added workaround for python 2.1
4901 * IPython/Debugger.py (__init__): Added workaround for python 2.1
4895
4902
4896 * IPython/__init__.py (__all__): Fixed package namespace, now
4903 * IPython/__init__.py (__all__): Fixed package namespace, now
4897 'import IPython' does give access to IPython.<all> as
4904 'import IPython' does give access to IPython.<all> as
4898 expected. Also renamed __release__ to Release.
4905 expected. Also renamed __release__ to Release.
4899
4906
4900 * IPython/Debugger.py (__license__): created new Pdb class which
4907 * IPython/Debugger.py (__license__): created new Pdb class which
4901 functions like a drop-in for the normal pdb.Pdb but does NOT
4908 functions like a drop-in for the normal pdb.Pdb but does NOT
4902 import readline by default. This way it doesn't muck up IPython's
4909 import readline by default. This way it doesn't muck up IPython's
4903 readline handling, and now tab-completion finally works in the
4910 readline handling, and now tab-completion finally works in the
4904 debugger -- sort of. It completes things globally visible, but the
4911 debugger -- sort of. It completes things globally visible, but the
4905 completer doesn't track the stack as pdb walks it. That's a bit
4912 completer doesn't track the stack as pdb walks it. That's a bit
4906 tricky, and I'll have to implement it later.
4913 tricky, and I'll have to implement it later.
4907
4914
4908 2002-05-05 Fernando Perez <fperez@colorado.edu>
4915 2002-05-05 Fernando Perez <fperez@colorado.edu>
4909
4916
4910 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
4917 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
4911 magic docstrings when printed via ? (explicit \'s were being
4918 magic docstrings when printed via ? (explicit \'s were being
4912 printed).
4919 printed).
4913
4920
4914 * IPython/ipmaker.py (make_IPython): fixed namespace
4921 * IPython/ipmaker.py (make_IPython): fixed namespace
4915 identification bug. Now variables loaded via logs or command-line
4922 identification bug. Now variables loaded via logs or command-line
4916 files are recognized in the interactive namespace by @who.
4923 files are recognized in the interactive namespace by @who.
4917
4924
4918 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
4925 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
4919 log replay system stemming from the string form of Structs.
4926 log replay system stemming from the string form of Structs.
4920
4927
4921 * IPython/Magic.py (Macro.__init__): improved macros to properly
4928 * IPython/Magic.py (Macro.__init__): improved macros to properly
4922 handle magic commands in them.
4929 handle magic commands in them.
4923 (Magic.magic_logstart): usernames are now expanded so 'logstart
4930 (Magic.magic_logstart): usernames are now expanded so 'logstart
4924 ~/mylog' now works.
4931 ~/mylog' now works.
4925
4932
4926 * IPython/iplib.py (complete): fixed bug where paths starting with
4933 * IPython/iplib.py (complete): fixed bug where paths starting with
4927 '/' would be completed as magic names.
4934 '/' would be completed as magic names.
4928
4935
4929 2002-05-04 Fernando Perez <fperez@colorado.edu>
4936 2002-05-04 Fernando Perez <fperez@colorado.edu>
4930
4937
4931 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
4938 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
4932 allow running full programs under the profiler's control.
4939 allow running full programs under the profiler's control.
4933
4940
4934 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
4941 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
4935 mode to report exceptions verbosely but without formatting
4942 mode to report exceptions verbosely but without formatting
4936 variables. This addresses the issue of ipython 'freezing' (it's
4943 variables. This addresses the issue of ipython 'freezing' (it's
4937 not frozen, but caught in an expensive formatting loop) when huge
4944 not frozen, but caught in an expensive formatting loop) when huge
4938 variables are in the context of an exception.
4945 variables are in the context of an exception.
4939 (VerboseTB.text): Added '--->' markers at line where exception was
4946 (VerboseTB.text): Added '--->' markers at line where exception was
4940 triggered. Much clearer to read, especially in NoColor modes.
4947 triggered. Much clearer to read, especially in NoColor modes.
4941
4948
4942 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
4949 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
4943 implemented in reverse when changing to the new parse_options().
4950 implemented in reverse when changing to the new parse_options().
4944
4951
4945 2002-05-03 Fernando Perez <fperez@colorado.edu>
4952 2002-05-03 Fernando Perez <fperez@colorado.edu>
4946
4953
4947 * IPython/Magic.py (Magic.parse_options): new function so that
4954 * IPython/Magic.py (Magic.parse_options): new function so that
4948 magics can parse options easier.
4955 magics can parse options easier.
4949 (Magic.magic_prun): new function similar to profile.run(),
4956 (Magic.magic_prun): new function similar to profile.run(),
4950 suggested by Chris Hart.
4957 suggested by Chris Hart.
4951 (Magic.magic_cd): fixed behavior so that it only changes if
4958 (Magic.magic_cd): fixed behavior so that it only changes if
4952 directory actually is in history.
4959 directory actually is in history.
4953
4960
4954 * IPython/usage.py (__doc__): added information about potential
4961 * IPython/usage.py (__doc__): added information about potential
4955 slowness of Verbose exception mode when there are huge data
4962 slowness of Verbose exception mode when there are huge data
4956 structures to be formatted (thanks to Archie Paulson).
4963 structures to be formatted (thanks to Archie Paulson).
4957
4964
4958 * IPython/ipmaker.py (make_IPython): Changed default logging
4965 * IPython/ipmaker.py (make_IPython): Changed default logging
4959 (when simply called with -log) to use curr_dir/ipython.log in
4966 (when simply called with -log) to use curr_dir/ipython.log in
4960 rotate mode. Fixed crash which was occuring with -log before
4967 rotate mode. Fixed crash which was occuring with -log before
4961 (thanks to Jim Boyle).
4968 (thanks to Jim Boyle).
4962
4969
4963 2002-05-01 Fernando Perez <fperez@colorado.edu>
4970 2002-05-01 Fernando Perez <fperez@colorado.edu>
4964
4971
4965 * Released 0.2.11 for these fixes (mainly the ultraTB one which
4972 * Released 0.2.11 for these fixes (mainly the ultraTB one which
4966 was nasty -- though somewhat of a corner case).
4973 was nasty -- though somewhat of a corner case).
4967
4974
4968 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
4975 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
4969 text (was a bug).
4976 text (was a bug).
4970
4977
4971 2002-04-30 Fernando Perez <fperez@colorado.edu>
4978 2002-04-30 Fernando Perez <fperez@colorado.edu>
4972
4979
4973 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
4980 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
4974 a print after ^D or ^C from the user so that the In[] prompt
4981 a print after ^D or ^C from the user so that the In[] prompt
4975 doesn't over-run the gnuplot one.
4982 doesn't over-run the gnuplot one.
4976
4983
4977 2002-04-29 Fernando Perez <fperez@colorado.edu>
4984 2002-04-29 Fernando Perez <fperez@colorado.edu>
4978
4985
4979 * Released 0.2.10
4986 * Released 0.2.10
4980
4987
4981 * IPython/__release__.py (version): get date dynamically.
4988 * IPython/__release__.py (version): get date dynamically.
4982
4989
4983 * Misc. documentation updates thanks to Arnd's comments. Also ran
4990 * Misc. documentation updates thanks to Arnd's comments. Also ran
4984 a full spellcheck on the manual (hadn't been done in a while).
4991 a full spellcheck on the manual (hadn't been done in a while).
4985
4992
4986 2002-04-27 Fernando Perez <fperez@colorado.edu>
4993 2002-04-27 Fernando Perez <fperez@colorado.edu>
4987
4994
4988 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
4995 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
4989 starting a log in mid-session would reset the input history list.
4996 starting a log in mid-session would reset the input history list.
4990
4997
4991 2002-04-26 Fernando Perez <fperez@colorado.edu>
4998 2002-04-26 Fernando Perez <fperez@colorado.edu>
4992
4999
4993 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
5000 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
4994 all files were being included in an update. Now anything in
5001 all files were being included in an update. Now anything in
4995 UserConfig that matches [A-Za-z]*.py will go (this excludes
5002 UserConfig that matches [A-Za-z]*.py will go (this excludes
4996 __init__.py)
5003 __init__.py)
4997
5004
4998 2002-04-25 Fernando Perez <fperez@colorado.edu>
5005 2002-04-25 Fernando Perez <fperez@colorado.edu>
4999
5006
5000 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
5007 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
5001 to __builtins__ so that any form of embedded or imported code can
5008 to __builtins__ so that any form of embedded or imported code can
5002 test for being inside IPython.
5009 test for being inside IPython.
5003
5010
5004 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
5011 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
5005 changed to GnuplotMagic because it's now an importable module,
5012 changed to GnuplotMagic because it's now an importable module,
5006 this makes the name follow that of the standard Gnuplot module.
5013 this makes the name follow that of the standard Gnuplot module.
5007 GnuplotMagic can now be loaded at any time in mid-session.
5014 GnuplotMagic can now be loaded at any time in mid-session.
5008
5015
5009 2002-04-24 Fernando Perez <fperez@colorado.edu>
5016 2002-04-24 Fernando Perez <fperez@colorado.edu>
5010
5017
5011 * IPython/numutils.py: removed SIUnits. It doesn't properly set
5018 * IPython/numutils.py: removed SIUnits. It doesn't properly set
5012 the globals (IPython has its own namespace) and the
5019 the globals (IPython has its own namespace) and the
5013 PhysicalQuantity stuff is much better anyway.
5020 PhysicalQuantity stuff is much better anyway.
5014
5021
5015 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
5022 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
5016 embedding example to standard user directory for
5023 embedding example to standard user directory for
5017 distribution. Also put it in the manual.
5024 distribution. Also put it in the manual.
5018
5025
5019 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
5026 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
5020 instance as first argument (so it doesn't rely on some obscure
5027 instance as first argument (so it doesn't rely on some obscure
5021 hidden global).
5028 hidden global).
5022
5029
5023 * IPython/UserConfig/ipythonrc.py: put () back in accepted
5030 * IPython/UserConfig/ipythonrc.py: put () back in accepted
5024 delimiters. While it prevents ().TAB from working, it allows
5031 delimiters. While it prevents ().TAB from working, it allows
5025 completions in open (... expressions. This is by far a more common
5032 completions in open (... expressions. This is by far a more common
5026 case.
5033 case.
5027
5034
5028 2002-04-23 Fernando Perez <fperez@colorado.edu>
5035 2002-04-23 Fernando Perez <fperez@colorado.edu>
5029
5036
5030 * IPython/Extensions/InterpreterPasteInput.py: new
5037 * IPython/Extensions/InterpreterPasteInput.py: new
5031 syntax-processing module for pasting lines with >>> or ... at the
5038 syntax-processing module for pasting lines with >>> or ... at the
5032 start.
5039 start.
5033
5040
5034 * IPython/Extensions/PhysicalQ_Interactive.py
5041 * IPython/Extensions/PhysicalQ_Interactive.py
5035 (PhysicalQuantityInteractive.__int__): fixed to work with either
5042 (PhysicalQuantityInteractive.__int__): fixed to work with either
5036 Numeric or math.
5043 Numeric or math.
5037
5044
5038 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
5045 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
5039 provided profiles. Now we have:
5046 provided profiles. Now we have:
5040 -math -> math module as * and cmath with its own namespace.
5047 -math -> math module as * and cmath with its own namespace.
5041 -numeric -> Numeric as *, plus gnuplot & grace
5048 -numeric -> Numeric as *, plus gnuplot & grace
5042 -physics -> same as before
5049 -physics -> same as before
5043
5050
5044 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
5051 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
5045 user-defined magics wouldn't be found by @magic if they were
5052 user-defined magics wouldn't be found by @magic if they were
5046 defined as class methods. Also cleaned up the namespace search
5053 defined as class methods. Also cleaned up the namespace search
5047 logic and the string building (to use %s instead of many repeated
5054 logic and the string building (to use %s instead of many repeated
5048 string adds).
5055 string adds).
5049
5056
5050 * IPython/UserConfig/example-magic.py (magic_foo): updated example
5057 * IPython/UserConfig/example-magic.py (magic_foo): updated example
5051 of user-defined magics to operate with class methods (cleaner, in
5058 of user-defined magics to operate with class methods (cleaner, in
5052 line with the gnuplot code).
5059 line with the gnuplot code).
5053
5060
5054 2002-04-22 Fernando Perez <fperez@colorado.edu>
5061 2002-04-22 Fernando Perez <fperez@colorado.edu>
5055
5062
5056 * setup.py: updated dependency list so that manual is updated when
5063 * setup.py: updated dependency list so that manual is updated when
5057 all included files change.
5064 all included files change.
5058
5065
5059 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
5066 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
5060 the delimiter removal option (the fix is ugly right now).
5067 the delimiter removal option (the fix is ugly right now).
5061
5068
5062 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
5069 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
5063 all of the math profile (quicker loading, no conflict between
5070 all of the math profile (quicker loading, no conflict between
5064 g-9.8 and g-gnuplot).
5071 g-9.8 and g-gnuplot).
5065
5072
5066 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
5073 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
5067 name of post-mortem files to IPython_crash_report.txt.
5074 name of post-mortem files to IPython_crash_report.txt.
5068
5075
5069 * Cleanup/update of the docs. Added all the new readline info and
5076 * Cleanup/update of the docs. Added all the new readline info and
5070 formatted all lists as 'real lists'.
5077 formatted all lists as 'real lists'.
5071
5078
5072 * IPython/ipmaker.py (make_IPython): removed now-obsolete
5079 * IPython/ipmaker.py (make_IPython): removed now-obsolete
5073 tab-completion options, since the full readline parse_and_bind is
5080 tab-completion options, since the full readline parse_and_bind is
5074 now accessible.
5081 now accessible.
5075
5082
5076 * IPython/iplib.py (InteractiveShell.init_readline): Changed
5083 * IPython/iplib.py (InteractiveShell.init_readline): Changed
5077 handling of readline options. Now users can specify any string to
5084 handling of readline options. Now users can specify any string to
5078 be passed to parse_and_bind(), as well as the delimiters to be
5085 be passed to parse_and_bind(), as well as the delimiters to be
5079 removed.
5086 removed.
5080 (InteractiveShell.__init__): Added __name__ to the global
5087 (InteractiveShell.__init__): Added __name__ to the global
5081 namespace so that things like Itpl which rely on its existence
5088 namespace so that things like Itpl which rely on its existence
5082 don't crash.
5089 don't crash.
5083 (InteractiveShell._prefilter): Defined the default with a _ so
5090 (InteractiveShell._prefilter): Defined the default with a _ so
5084 that prefilter() is easier to override, while the default one
5091 that prefilter() is easier to override, while the default one
5085 remains available.
5092 remains available.
5086
5093
5087 2002-04-18 Fernando Perez <fperez@colorado.edu>
5094 2002-04-18 Fernando Perez <fperez@colorado.edu>
5088
5095
5089 * Added information about pdb in the docs.
5096 * Added information about pdb in the docs.
5090
5097
5091 2002-04-17 Fernando Perez <fperez@colorado.edu>
5098 2002-04-17 Fernando Perez <fperez@colorado.edu>
5092
5099
5093 * IPython/ipmaker.py (make_IPython): added rc_override option to
5100 * IPython/ipmaker.py (make_IPython): added rc_override option to
5094 allow passing config options at creation time which may override
5101 allow passing config options at creation time which may override
5095 anything set in the config files or command line. This is
5102 anything set in the config files or command line. This is
5096 particularly useful for configuring embedded instances.
5103 particularly useful for configuring embedded instances.
5097
5104
5098 2002-04-15 Fernando Perez <fperez@colorado.edu>
5105 2002-04-15 Fernando Perez <fperez@colorado.edu>
5099
5106
5100 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
5107 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
5101 crash embedded instances because of the input cache falling out of
5108 crash embedded instances because of the input cache falling out of
5102 sync with the output counter.
5109 sync with the output counter.
5103
5110
5104 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
5111 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
5105 mode which calls pdb after an uncaught exception in IPython itself.
5112 mode which calls pdb after an uncaught exception in IPython itself.
5106
5113
5107 2002-04-14 Fernando Perez <fperez@colorado.edu>
5114 2002-04-14 Fernando Perez <fperez@colorado.edu>
5108
5115
5109 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
5116 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
5110 readline, fix it back after each call.
5117 readline, fix it back after each call.
5111
5118
5112 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
5119 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
5113 method to force all access via __call__(), which guarantees that
5120 method to force all access via __call__(), which guarantees that
5114 traceback references are properly deleted.
5121 traceback references are properly deleted.
5115
5122
5116 * IPython/Prompts.py (CachedOutput._display): minor fixes to
5123 * IPython/Prompts.py (CachedOutput._display): minor fixes to
5117 improve printing when pprint is in use.
5124 improve printing when pprint is in use.
5118
5125
5119 2002-04-13 Fernando Perez <fperez@colorado.edu>
5126 2002-04-13 Fernando Perez <fperez@colorado.edu>
5120
5127
5121 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
5128 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
5122 exceptions aren't caught anymore. If the user triggers one, he
5129 exceptions aren't caught anymore. If the user triggers one, he
5123 should know why he's doing it and it should go all the way up,
5130 should know why he's doing it and it should go all the way up,
5124 just like any other exception. So now @abort will fully kill the
5131 just like any other exception. So now @abort will fully kill the
5125 embedded interpreter and the embedding code (unless that happens
5132 embedded interpreter and the embedding code (unless that happens
5126 to catch SystemExit).
5133 to catch SystemExit).
5127
5134
5128 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
5135 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
5129 and a debugger() method to invoke the interactive pdb debugger
5136 and a debugger() method to invoke the interactive pdb debugger
5130 after printing exception information. Also added the corresponding
5137 after printing exception information. Also added the corresponding
5131 -pdb option and @pdb magic to control this feature, and updated
5138 -pdb option and @pdb magic to control this feature, and updated
5132 the docs. After a suggestion from Christopher Hart
5139 the docs. After a suggestion from Christopher Hart
5133 (hart-AT-caltech.edu).
5140 (hart-AT-caltech.edu).
5134
5141
5135 2002-04-12 Fernando Perez <fperez@colorado.edu>
5142 2002-04-12 Fernando Perez <fperez@colorado.edu>
5136
5143
5137 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
5144 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
5138 the exception handlers defined by the user (not the CrashHandler)
5145 the exception handlers defined by the user (not the CrashHandler)
5139 so that user exceptions don't trigger an ipython bug report.
5146 so that user exceptions don't trigger an ipython bug report.
5140
5147
5141 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
5148 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
5142 configurable (it should have always been so).
5149 configurable (it should have always been so).
5143
5150
5144 2002-03-26 Fernando Perez <fperez@colorado.edu>
5151 2002-03-26 Fernando Perez <fperez@colorado.edu>
5145
5152
5146 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
5153 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
5147 and there to fix embedding namespace issues. This should all be
5154 and there to fix embedding namespace issues. This should all be
5148 done in a more elegant way.
5155 done in a more elegant way.
5149
5156
5150 2002-03-25 Fernando Perez <fperez@colorado.edu>
5157 2002-03-25 Fernando Perez <fperez@colorado.edu>
5151
5158
5152 * IPython/genutils.py (get_home_dir): Try to make it work under
5159 * IPython/genutils.py (get_home_dir): Try to make it work under
5153 win9x also.
5160 win9x also.
5154
5161
5155 2002-03-20 Fernando Perez <fperez@colorado.edu>
5162 2002-03-20 Fernando Perez <fperez@colorado.edu>
5156
5163
5157 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
5164 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
5158 sys.displayhook untouched upon __init__.
5165 sys.displayhook untouched upon __init__.
5159
5166
5160 2002-03-19 Fernando Perez <fperez@colorado.edu>
5167 2002-03-19 Fernando Perez <fperez@colorado.edu>
5161
5168
5162 * Released 0.2.9 (for embedding bug, basically).
5169 * Released 0.2.9 (for embedding bug, basically).
5163
5170
5164 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
5171 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
5165 exceptions so that enclosing shell's state can be restored.
5172 exceptions so that enclosing shell's state can be restored.
5166
5173
5167 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
5174 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
5168 naming conventions in the .ipython/ dir.
5175 naming conventions in the .ipython/ dir.
5169
5176
5170 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
5177 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
5171 from delimiters list so filenames with - in them get expanded.
5178 from delimiters list so filenames with - in them get expanded.
5172
5179
5173 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
5180 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
5174 sys.displayhook not being properly restored after an embedded call.
5181 sys.displayhook not being properly restored after an embedded call.
5175
5182
5176 2002-03-18 Fernando Perez <fperez@colorado.edu>
5183 2002-03-18 Fernando Perez <fperez@colorado.edu>
5177
5184
5178 * Released 0.2.8
5185 * Released 0.2.8
5179
5186
5180 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
5187 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
5181 some files weren't being included in a -upgrade.
5188 some files weren't being included in a -upgrade.
5182 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
5189 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
5183 on' so that the first tab completes.
5190 on' so that the first tab completes.
5184 (InteractiveShell.handle_magic): fixed bug with spaces around
5191 (InteractiveShell.handle_magic): fixed bug with spaces around
5185 quotes breaking many magic commands.
5192 quotes breaking many magic commands.
5186
5193
5187 * setup.py: added note about ignoring the syntax error messages at
5194 * setup.py: added note about ignoring the syntax error messages at
5188 installation.
5195 installation.
5189
5196
5190 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
5197 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
5191 streamlining the gnuplot interface, now there's only one magic @gp.
5198 streamlining the gnuplot interface, now there's only one magic @gp.
5192
5199
5193 2002-03-17 Fernando Perez <fperez@colorado.edu>
5200 2002-03-17 Fernando Perez <fperez@colorado.edu>
5194
5201
5195 * IPython/UserConfig/magic_gnuplot.py: new name for the
5202 * IPython/UserConfig/magic_gnuplot.py: new name for the
5196 example-magic_pm.py file. Much enhanced system, now with a shell
5203 example-magic_pm.py file. Much enhanced system, now with a shell
5197 for communicating directly with gnuplot, one command at a time.
5204 for communicating directly with gnuplot, one command at a time.
5198
5205
5199 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
5206 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
5200 setting __name__=='__main__'.
5207 setting __name__=='__main__'.
5201
5208
5202 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
5209 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
5203 mini-shell for accessing gnuplot from inside ipython. Should
5210 mini-shell for accessing gnuplot from inside ipython. Should
5204 extend it later for grace access too. Inspired by Arnd's
5211 extend it later for grace access too. Inspired by Arnd's
5205 suggestion.
5212 suggestion.
5206
5213
5207 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
5214 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
5208 calling magic functions with () in their arguments. Thanks to Arnd
5215 calling magic functions with () in their arguments. Thanks to Arnd
5209 Baecker for pointing this to me.
5216 Baecker for pointing this to me.
5210
5217
5211 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
5218 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
5212 infinitely for integer or complex arrays (only worked with floats).
5219 infinitely for integer or complex arrays (only worked with floats).
5213
5220
5214 2002-03-16 Fernando Perez <fperez@colorado.edu>
5221 2002-03-16 Fernando Perez <fperez@colorado.edu>
5215
5222
5216 * setup.py: Merged setup and setup_windows into a single script
5223 * setup.py: Merged setup and setup_windows into a single script
5217 which properly handles things for windows users.
5224 which properly handles things for windows users.
5218
5225
5219 2002-03-15 Fernando Perez <fperez@colorado.edu>
5226 2002-03-15 Fernando Perez <fperez@colorado.edu>
5220
5227
5221 * Big change to the manual: now the magics are all automatically
5228 * Big change to the manual: now the magics are all automatically
5222 documented. This information is generated from their docstrings
5229 documented. This information is generated from their docstrings
5223 and put in a latex file included by the manual lyx file. This way
5230 and put in a latex file included by the manual lyx file. This way
5224 we get always up to date information for the magics. The manual
5231 we get always up to date information for the magics. The manual
5225 now also has proper version information, also auto-synced.
5232 now also has proper version information, also auto-synced.
5226
5233
5227 For this to work, an undocumented --magic_docstrings option was added.
5234 For this to work, an undocumented --magic_docstrings option was added.
5228
5235
5229 2002-03-13 Fernando Perez <fperez@colorado.edu>
5236 2002-03-13 Fernando Perez <fperez@colorado.edu>
5230
5237
5231 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
5238 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
5232 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
5239 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
5233
5240
5234 2002-03-12 Fernando Perez <fperez@colorado.edu>
5241 2002-03-12 Fernando Perez <fperez@colorado.edu>
5235
5242
5236 * IPython/ultraTB.py (TermColors): changed color escapes again to
5243 * IPython/ultraTB.py (TermColors): changed color escapes again to
5237 fix the (old, reintroduced) line-wrapping bug. Basically, if
5244 fix the (old, reintroduced) line-wrapping bug. Basically, if
5238 \001..\002 aren't given in the color escapes, lines get wrapped
5245 \001..\002 aren't given in the color escapes, lines get wrapped
5239 weirdly. But giving those screws up old xterms and emacs terms. So
5246 weirdly. But giving those screws up old xterms and emacs terms. So
5240 I added some logic for emacs terms to be ok, but I can't identify old
5247 I added some logic for emacs terms to be ok, but I can't identify old
5241 xterms separately ($TERM=='xterm' for many terminals, like konsole).
5248 xterms separately ($TERM=='xterm' for many terminals, like konsole).
5242
5249
5243 2002-03-10 Fernando Perez <fperez@colorado.edu>
5250 2002-03-10 Fernando Perez <fperez@colorado.edu>
5244
5251
5245 * IPython/usage.py (__doc__): Various documentation cleanups and
5252 * IPython/usage.py (__doc__): Various documentation cleanups and
5246 updates, both in usage docstrings and in the manual.
5253 updates, both in usage docstrings and in the manual.
5247
5254
5248 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
5255 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
5249 handling of caching. Set minimum acceptabe value for having a
5256 handling of caching. Set minimum acceptabe value for having a
5250 cache at 20 values.
5257 cache at 20 values.
5251
5258
5252 * IPython/iplib.py (InteractiveShell.user_setup): moved the
5259 * IPython/iplib.py (InteractiveShell.user_setup): moved the
5253 install_first_time function to a method, renamed it and added an
5260 install_first_time function to a method, renamed it and added an
5254 'upgrade' mode. Now people can update their config directory with
5261 'upgrade' mode. Now people can update their config directory with
5255 a simple command line switch (-upgrade, also new).
5262 a simple command line switch (-upgrade, also new).
5256
5263
5257 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
5264 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
5258 @file (convenient for automagic users under Python >= 2.2).
5265 @file (convenient for automagic users under Python >= 2.2).
5259 Removed @files (it seemed more like a plural than an abbrev. of
5266 Removed @files (it seemed more like a plural than an abbrev. of
5260 'file show').
5267 'file show').
5261
5268
5262 * IPython/iplib.py (install_first_time): Fixed crash if there were
5269 * IPython/iplib.py (install_first_time): Fixed crash if there were
5263 backup files ('~') in .ipython/ install directory.
5270 backup files ('~') in .ipython/ install directory.
5264
5271
5265 * IPython/ipmaker.py (make_IPython): fixes for new prompt
5272 * IPython/ipmaker.py (make_IPython): fixes for new prompt
5266 system. Things look fine, but these changes are fairly
5273 system. Things look fine, but these changes are fairly
5267 intrusive. Test them for a few days.
5274 intrusive. Test them for a few days.
5268
5275
5269 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
5276 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
5270 the prompts system. Now all in/out prompt strings are user
5277 the prompts system. Now all in/out prompt strings are user
5271 controllable. This is particularly useful for embedding, as one
5278 controllable. This is particularly useful for embedding, as one
5272 can tag embedded instances with particular prompts.
5279 can tag embedded instances with particular prompts.
5273
5280
5274 Also removed global use of sys.ps1/2, which now allows nested
5281 Also removed global use of sys.ps1/2, which now allows nested
5275 embeddings without any problems. Added command-line options for
5282 embeddings without any problems. Added command-line options for
5276 the prompt strings.
5283 the prompt strings.
5277
5284
5278 2002-03-08 Fernando Perez <fperez@colorado.edu>
5285 2002-03-08 Fernando Perez <fperez@colorado.edu>
5279
5286
5280 * IPython/UserConfig/example-embed-short.py (ipshell): added
5287 * IPython/UserConfig/example-embed-short.py (ipshell): added
5281 example file with the bare minimum code for embedding.
5288 example file with the bare minimum code for embedding.
5282
5289
5283 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
5290 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
5284 functionality for the embeddable shell to be activated/deactivated
5291 functionality for the embeddable shell to be activated/deactivated
5285 either globally or at each call.
5292 either globally or at each call.
5286
5293
5287 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
5294 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
5288 rewriting the prompt with '--->' for auto-inputs with proper
5295 rewriting the prompt with '--->' for auto-inputs with proper
5289 coloring. Now the previous UGLY hack in handle_auto() is gone, and
5296 coloring. Now the previous UGLY hack in handle_auto() is gone, and
5290 this is handled by the prompts class itself, as it should.
5297 this is handled by the prompts class itself, as it should.
5291
5298
5292 2002-03-05 Fernando Perez <fperez@colorado.edu>
5299 2002-03-05 Fernando Perez <fperez@colorado.edu>
5293
5300
5294 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
5301 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
5295 @logstart to avoid name clashes with the math log function.
5302 @logstart to avoid name clashes with the math log function.
5296
5303
5297 * Big updates to X/Emacs section of the manual.
5304 * Big updates to X/Emacs section of the manual.
5298
5305
5299 * Removed ipython_emacs. Milan explained to me how to pass
5306 * Removed ipython_emacs. Milan explained to me how to pass
5300 arguments to ipython through Emacs. Some day I'm going to end up
5307 arguments to ipython through Emacs. Some day I'm going to end up
5301 learning some lisp...
5308 learning some lisp...
5302
5309
5303 2002-03-04 Fernando Perez <fperez@colorado.edu>
5310 2002-03-04 Fernando Perez <fperez@colorado.edu>
5304
5311
5305 * IPython/ipython_emacs: Created script to be used as the
5312 * IPython/ipython_emacs: Created script to be used as the
5306 py-python-command Emacs variable so we can pass IPython
5313 py-python-command Emacs variable so we can pass IPython
5307 parameters. I can't figure out how to tell Emacs directly to pass
5314 parameters. I can't figure out how to tell Emacs directly to pass
5308 parameters to IPython, so a dummy shell script will do it.
5315 parameters to IPython, so a dummy shell script will do it.
5309
5316
5310 Other enhancements made for things to work better under Emacs'
5317 Other enhancements made for things to work better under Emacs'
5311 various types of terminals. Many thanks to Milan Zamazal
5318 various types of terminals. Many thanks to Milan Zamazal
5312 <pdm-AT-zamazal.org> for all the suggestions and pointers.
5319 <pdm-AT-zamazal.org> for all the suggestions and pointers.
5313
5320
5314 2002-03-01 Fernando Perez <fperez@colorado.edu>
5321 2002-03-01 Fernando Perez <fperez@colorado.edu>
5315
5322
5316 * IPython/ipmaker.py (make_IPython): added a --readline! option so
5323 * IPython/ipmaker.py (make_IPython): added a --readline! option so
5317 that loading of readline is now optional. This gives better
5324 that loading of readline is now optional. This gives better
5318 control to emacs users.
5325 control to emacs users.
5319
5326
5320 * IPython/ultraTB.py (__date__): Modified color escape sequences
5327 * IPython/ultraTB.py (__date__): Modified color escape sequences
5321 and now things work fine under xterm and in Emacs' term buffers
5328 and now things work fine under xterm and in Emacs' term buffers
5322 (though not shell ones). Well, in emacs you get colors, but all
5329 (though not shell ones). Well, in emacs you get colors, but all
5323 seem to be 'light' colors (no difference between dark and light
5330 seem to be 'light' colors (no difference between dark and light
5324 ones). But the garbage chars are gone, and also in xterms. It
5331 ones). But the garbage chars are gone, and also in xterms. It
5325 seems that now I'm using 'cleaner' ansi sequences.
5332 seems that now I'm using 'cleaner' ansi sequences.
5326
5333
5327 2002-02-21 Fernando Perez <fperez@colorado.edu>
5334 2002-02-21 Fernando Perez <fperez@colorado.edu>
5328
5335
5329 * Released 0.2.7 (mainly to publish the scoping fix).
5336 * Released 0.2.7 (mainly to publish the scoping fix).
5330
5337
5331 * IPython/Logger.py (Logger.logstate): added. A corresponding
5338 * IPython/Logger.py (Logger.logstate): added. A corresponding
5332 @logstate magic was created.
5339 @logstate magic was created.
5333
5340
5334 * IPython/Magic.py: fixed nested scoping problem under Python
5341 * IPython/Magic.py: fixed nested scoping problem under Python
5335 2.1.x (automagic wasn't working).
5342 2.1.x (automagic wasn't working).
5336
5343
5337 2002-02-20 Fernando Perez <fperez@colorado.edu>
5344 2002-02-20 Fernando Perez <fperez@colorado.edu>
5338
5345
5339 * Released 0.2.6.
5346 * Released 0.2.6.
5340
5347
5341 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
5348 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
5342 option so that logs can come out without any headers at all.
5349 option so that logs can come out without any headers at all.
5343
5350
5344 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
5351 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
5345 SciPy.
5352 SciPy.
5346
5353
5347 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
5354 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
5348 that embedded IPython calls don't require vars() to be explicitly
5355 that embedded IPython calls don't require vars() to be explicitly
5349 passed. Now they are extracted from the caller's frame (code
5356 passed. Now they are extracted from the caller's frame (code
5350 snatched from Eric Jones' weave). Added better documentation to
5357 snatched from Eric Jones' weave). Added better documentation to
5351 the section on embedding and the example file.
5358 the section on embedding and the example file.
5352
5359
5353 * IPython/genutils.py (page): Changed so that under emacs, it just
5360 * IPython/genutils.py (page): Changed so that under emacs, it just
5354 prints the string. You can then page up and down in the emacs
5361 prints the string. You can then page up and down in the emacs
5355 buffer itself. This is how the builtin help() works.
5362 buffer itself. This is how the builtin help() works.
5356
5363
5357 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
5364 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
5358 macro scoping: macros need to be executed in the user's namespace
5365 macro scoping: macros need to be executed in the user's namespace
5359 to work as if they had been typed by the user.
5366 to work as if they had been typed by the user.
5360
5367
5361 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
5368 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
5362 execute automatically (no need to type 'exec...'). They then
5369 execute automatically (no need to type 'exec...'). They then
5363 behave like 'true macros'. The printing system was also modified
5370 behave like 'true macros'. The printing system was also modified
5364 for this to work.
5371 for this to work.
5365
5372
5366 2002-02-19 Fernando Perez <fperez@colorado.edu>
5373 2002-02-19 Fernando Perez <fperez@colorado.edu>
5367
5374
5368 * IPython/genutils.py (page_file): new function for paging files
5375 * IPython/genutils.py (page_file): new function for paging files
5369 in an OS-independent way. Also necessary for file viewing to work
5376 in an OS-independent way. Also necessary for file viewing to work
5370 well inside Emacs buffers.
5377 well inside Emacs buffers.
5371 (page): Added checks for being in an emacs buffer.
5378 (page): Added checks for being in an emacs buffer.
5372 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
5379 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
5373 same bug in iplib.
5380 same bug in iplib.
5374
5381
5375 2002-02-18 Fernando Perez <fperez@colorado.edu>
5382 2002-02-18 Fernando Perez <fperez@colorado.edu>
5376
5383
5377 * IPython/iplib.py (InteractiveShell.init_readline): modified use
5384 * IPython/iplib.py (InteractiveShell.init_readline): modified use
5378 of readline so that IPython can work inside an Emacs buffer.
5385 of readline so that IPython can work inside an Emacs buffer.
5379
5386
5380 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
5387 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
5381 method signatures (they weren't really bugs, but it looks cleaner
5388 method signatures (they weren't really bugs, but it looks cleaner
5382 and keeps PyChecker happy).
5389 and keeps PyChecker happy).
5383
5390
5384 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
5391 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
5385 for implementing various user-defined hooks. Currently only
5392 for implementing various user-defined hooks. Currently only
5386 display is done.
5393 display is done.
5387
5394
5388 * IPython/Prompts.py (CachedOutput._display): changed display
5395 * IPython/Prompts.py (CachedOutput._display): changed display
5389 functions so that they can be dynamically changed by users easily.
5396 functions so that they can be dynamically changed by users easily.
5390
5397
5391 * IPython/Extensions/numeric_formats.py (num_display): added an
5398 * IPython/Extensions/numeric_formats.py (num_display): added an
5392 extension for printing NumPy arrays in flexible manners. It
5399 extension for printing NumPy arrays in flexible manners. It
5393 doesn't do anything yet, but all the structure is in
5400 doesn't do anything yet, but all the structure is in
5394 place. Ultimately the plan is to implement output format control
5401 place. Ultimately the plan is to implement output format control
5395 like in Octave.
5402 like in Octave.
5396
5403
5397 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
5404 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
5398 methods are found at run-time by all the automatic machinery.
5405 methods are found at run-time by all the automatic machinery.
5399
5406
5400 2002-02-17 Fernando Perez <fperez@colorado.edu>
5407 2002-02-17 Fernando Perez <fperez@colorado.edu>
5401
5408
5402 * setup_Windows.py (make_shortcut): documented. Cleaned up the
5409 * setup_Windows.py (make_shortcut): documented. Cleaned up the
5403 whole file a little.
5410 whole file a little.
5404
5411
5405 * ToDo: closed this document. Now there's a new_design.lyx
5412 * ToDo: closed this document. Now there's a new_design.lyx
5406 document for all new ideas. Added making a pdf of it for the
5413 document for all new ideas. Added making a pdf of it for the
5407 end-user distro.
5414 end-user distro.
5408
5415
5409 * IPython/Logger.py (Logger.switch_log): Created this to replace
5416 * IPython/Logger.py (Logger.switch_log): Created this to replace
5410 logon() and logoff(). It also fixes a nasty crash reported by
5417 logon() and logoff(). It also fixes a nasty crash reported by
5411 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
5418 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
5412
5419
5413 * IPython/iplib.py (complete): got auto-completion to work with
5420 * IPython/iplib.py (complete): got auto-completion to work with
5414 automagic (I had wanted this for a long time).
5421 automagic (I had wanted this for a long time).
5415
5422
5416 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
5423 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
5417 to @file, since file() is now a builtin and clashes with automagic
5424 to @file, since file() is now a builtin and clashes with automagic
5418 for @file.
5425 for @file.
5419
5426
5420 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
5427 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
5421 of this was previously in iplib, which had grown to more than 2000
5428 of this was previously in iplib, which had grown to more than 2000
5422 lines, way too long. No new functionality, but it makes managing
5429 lines, way too long. No new functionality, but it makes managing
5423 the code a bit easier.
5430 the code a bit easier.
5424
5431
5425 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
5432 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
5426 information to crash reports.
5433 information to crash reports.
5427
5434
5428 2002-02-12 Fernando Perez <fperez@colorado.edu>
5435 2002-02-12 Fernando Perez <fperez@colorado.edu>
5429
5436
5430 * Released 0.2.5.
5437 * Released 0.2.5.
5431
5438
5432 2002-02-11 Fernando Perez <fperez@colorado.edu>
5439 2002-02-11 Fernando Perez <fperez@colorado.edu>
5433
5440
5434 * Wrote a relatively complete Windows installer. It puts
5441 * Wrote a relatively complete Windows installer. It puts
5435 everything in place, creates Start Menu entries and fixes the
5442 everything in place, creates Start Menu entries and fixes the
5436 color issues. Nothing fancy, but it works.
5443 color issues. Nothing fancy, but it works.
5437
5444
5438 2002-02-10 Fernando Perez <fperez@colorado.edu>
5445 2002-02-10 Fernando Perez <fperez@colorado.edu>
5439
5446
5440 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
5447 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
5441 os.path.expanduser() call so that we can type @run ~/myfile.py and
5448 os.path.expanduser() call so that we can type @run ~/myfile.py and
5442 have thigs work as expected.
5449 have thigs work as expected.
5443
5450
5444 * IPython/genutils.py (page): fixed exception handling so things
5451 * IPython/genutils.py (page): fixed exception handling so things
5445 work both in Unix and Windows correctly. Quitting a pager triggers
5452 work both in Unix and Windows correctly. Quitting a pager triggers
5446 an IOError/broken pipe in Unix, and in windows not finding a pager
5453 an IOError/broken pipe in Unix, and in windows not finding a pager
5447 is also an IOError, so I had to actually look at the return value
5454 is also an IOError, so I had to actually look at the return value
5448 of the exception, not just the exception itself. Should be ok now.
5455 of the exception, not just the exception itself. Should be ok now.
5449
5456
5450 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
5457 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
5451 modified to allow case-insensitive color scheme changes.
5458 modified to allow case-insensitive color scheme changes.
5452
5459
5453 2002-02-09 Fernando Perez <fperez@colorado.edu>
5460 2002-02-09 Fernando Perez <fperez@colorado.edu>
5454
5461
5455 * IPython/genutils.py (native_line_ends): new function to leave
5462 * IPython/genutils.py (native_line_ends): new function to leave
5456 user config files with os-native line-endings.
5463 user config files with os-native line-endings.
5457
5464
5458 * README and manual updates.
5465 * README and manual updates.
5459
5466
5460 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
5467 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
5461 instead of StringType to catch Unicode strings.
5468 instead of StringType to catch Unicode strings.
5462
5469
5463 * IPython/genutils.py (filefind): fixed bug for paths with
5470 * IPython/genutils.py (filefind): fixed bug for paths with
5464 embedded spaces (very common in Windows).
5471 embedded spaces (very common in Windows).
5465
5472
5466 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
5473 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
5467 files under Windows, so that they get automatically associated
5474 files under Windows, so that they get automatically associated
5468 with a text editor. Windows makes it a pain to handle
5475 with a text editor. Windows makes it a pain to handle
5469 extension-less files.
5476 extension-less files.
5470
5477
5471 * IPython/iplib.py (InteractiveShell.init_readline): Made the
5478 * IPython/iplib.py (InteractiveShell.init_readline): Made the
5472 warning about readline only occur for Posix. In Windows there's no
5479 warning about readline only occur for Posix. In Windows there's no
5473 way to get readline, so why bother with the warning.
5480 way to get readline, so why bother with the warning.
5474
5481
5475 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
5482 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
5476 for __str__ instead of dir(self), since dir() changed in 2.2.
5483 for __str__ instead of dir(self), since dir() changed in 2.2.
5477
5484
5478 * Ported to Windows! Tested on XP, I suspect it should work fine
5485 * Ported to Windows! Tested on XP, I suspect it should work fine
5479 on NT/2000, but I don't think it will work on 98 et al. That
5486 on NT/2000, but I don't think it will work on 98 et al. That
5480 series of Windows is such a piece of junk anyway that I won't try
5487 series of Windows is such a piece of junk anyway that I won't try
5481 porting it there. The XP port was straightforward, showed a few
5488 porting it there. The XP port was straightforward, showed a few
5482 bugs here and there (fixed all), in particular some string
5489 bugs here and there (fixed all), in particular some string
5483 handling stuff which required considering Unicode strings (which
5490 handling stuff which required considering Unicode strings (which
5484 Windows uses). This is good, but hasn't been too tested :) No
5491 Windows uses). This is good, but hasn't been too tested :) No
5485 fancy installer yet, I'll put a note in the manual so people at
5492 fancy installer yet, I'll put a note in the manual so people at
5486 least make manually a shortcut.
5493 least make manually a shortcut.
5487
5494
5488 * IPython/iplib.py (Magic.magic_colors): Unified the color options
5495 * IPython/iplib.py (Magic.magic_colors): Unified the color options
5489 into a single one, "colors". This now controls both prompt and
5496 into a single one, "colors". This now controls both prompt and
5490 exception color schemes, and can be changed both at startup
5497 exception color schemes, and can be changed both at startup
5491 (either via command-line switches or via ipythonrc files) and at
5498 (either via command-line switches or via ipythonrc files) and at
5492 runtime, with @colors.
5499 runtime, with @colors.
5493 (Magic.magic_run): renamed @prun to @run and removed the old
5500 (Magic.magic_run): renamed @prun to @run and removed the old
5494 @run. The two were too similar to warrant keeping both.
5501 @run. The two were too similar to warrant keeping both.
5495
5502
5496 2002-02-03 Fernando Perez <fperez@colorado.edu>
5503 2002-02-03 Fernando Perez <fperez@colorado.edu>
5497
5504
5498 * IPython/iplib.py (install_first_time): Added comment on how to
5505 * IPython/iplib.py (install_first_time): Added comment on how to
5499 configure the color options for first-time users. Put a <return>
5506 configure the color options for first-time users. Put a <return>
5500 request at the end so that small-terminal users get a chance to
5507 request at the end so that small-terminal users get a chance to
5501 read the startup info.
5508 read the startup info.
5502
5509
5503 2002-01-23 Fernando Perez <fperez@colorado.edu>
5510 2002-01-23 Fernando Perez <fperez@colorado.edu>
5504
5511
5505 * IPython/iplib.py (CachedOutput.update): Changed output memory
5512 * IPython/iplib.py (CachedOutput.update): Changed output memory
5506 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
5513 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
5507 input history we still use _i. Did this b/c these variable are
5514 input history we still use _i. Did this b/c these variable are
5508 very commonly used in interactive work, so the less we need to
5515 very commonly used in interactive work, so the less we need to
5509 type the better off we are.
5516 type the better off we are.
5510 (Magic.magic_prun): updated @prun to better handle the namespaces
5517 (Magic.magic_prun): updated @prun to better handle the namespaces
5511 the file will run in, including a fix for __name__ not being set
5518 the file will run in, including a fix for __name__ not being set
5512 before.
5519 before.
5513
5520
5514 2002-01-20 Fernando Perez <fperez@colorado.edu>
5521 2002-01-20 Fernando Perez <fperez@colorado.edu>
5515
5522
5516 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
5523 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
5517 extra garbage for Python 2.2. Need to look more carefully into
5524 extra garbage for Python 2.2. Need to look more carefully into
5518 this later.
5525 this later.
5519
5526
5520 2002-01-19 Fernando Perez <fperez@colorado.edu>
5527 2002-01-19 Fernando Perez <fperez@colorado.edu>
5521
5528
5522 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
5529 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
5523 display SyntaxError exceptions properly formatted when they occur
5530 display SyntaxError exceptions properly formatted when they occur
5524 (they can be triggered by imported code).
5531 (they can be triggered by imported code).
5525
5532
5526 2002-01-18 Fernando Perez <fperez@colorado.edu>
5533 2002-01-18 Fernando Perez <fperez@colorado.edu>
5527
5534
5528 * IPython/iplib.py (InteractiveShell.safe_execfile): now
5535 * IPython/iplib.py (InteractiveShell.safe_execfile): now
5529 SyntaxError exceptions are reported nicely formatted, instead of
5536 SyntaxError exceptions are reported nicely formatted, instead of
5530 spitting out only offset information as before.
5537 spitting out only offset information as before.
5531 (Magic.magic_prun): Added the @prun function for executing
5538 (Magic.magic_prun): Added the @prun function for executing
5532 programs with command line args inside IPython.
5539 programs with command line args inside IPython.
5533
5540
5534 2002-01-16 Fernando Perez <fperez@colorado.edu>
5541 2002-01-16 Fernando Perez <fperez@colorado.edu>
5535
5542
5536 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
5543 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
5537 to *not* include the last item given in a range. This brings their
5544 to *not* include the last item given in a range. This brings their
5538 behavior in line with Python's slicing:
5545 behavior in line with Python's slicing:
5539 a[n1:n2] -> a[n1]...a[n2-1]
5546 a[n1:n2] -> a[n1]...a[n2-1]
5540 It may be a bit less convenient, but I prefer to stick to Python's
5547 It may be a bit less convenient, but I prefer to stick to Python's
5541 conventions *everywhere*, so users never have to wonder.
5548 conventions *everywhere*, so users never have to wonder.
5542 (Magic.magic_macro): Added @macro function to ease the creation of
5549 (Magic.magic_macro): Added @macro function to ease the creation of
5543 macros.
5550 macros.
5544
5551
5545 2002-01-05 Fernando Perez <fperez@colorado.edu>
5552 2002-01-05 Fernando Perez <fperez@colorado.edu>
5546
5553
5547 * Released 0.2.4.
5554 * Released 0.2.4.
5548
5555
5549 * IPython/iplib.py (Magic.magic_pdef):
5556 * IPython/iplib.py (Magic.magic_pdef):
5550 (InteractiveShell.safe_execfile): report magic lines and error
5557 (InteractiveShell.safe_execfile): report magic lines and error
5551 lines without line numbers so one can easily copy/paste them for
5558 lines without line numbers so one can easily copy/paste them for
5552 re-execution.
5559 re-execution.
5553
5560
5554 * Updated manual with recent changes.
5561 * Updated manual with recent changes.
5555
5562
5556 * IPython/iplib.py (Magic.magic_oinfo): added constructor
5563 * IPython/iplib.py (Magic.magic_oinfo): added constructor
5557 docstring printing when class? is called. Very handy for knowing
5564 docstring printing when class? is called. Very handy for knowing
5558 how to create class instances (as long as __init__ is well
5565 how to create class instances (as long as __init__ is well
5559 documented, of course :)
5566 documented, of course :)
5560 (Magic.magic_doc): print both class and constructor docstrings.
5567 (Magic.magic_doc): print both class and constructor docstrings.
5561 (Magic.magic_pdef): give constructor info if passed a class and
5568 (Magic.magic_pdef): give constructor info if passed a class and
5562 __call__ info for callable object instances.
5569 __call__ info for callable object instances.
5563
5570
5564 2002-01-04 Fernando Perez <fperez@colorado.edu>
5571 2002-01-04 Fernando Perez <fperez@colorado.edu>
5565
5572
5566 * Made deep_reload() off by default. It doesn't always work
5573 * Made deep_reload() off by default. It doesn't always work
5567 exactly as intended, so it's probably safer to have it off. It's
5574 exactly as intended, so it's probably safer to have it off. It's
5568 still available as dreload() anyway, so nothing is lost.
5575 still available as dreload() anyway, so nothing is lost.
5569
5576
5570 2002-01-02 Fernando Perez <fperez@colorado.edu>
5577 2002-01-02 Fernando Perez <fperez@colorado.edu>
5571
5578
5572 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
5579 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
5573 so I wanted an updated release).
5580 so I wanted an updated release).
5574
5581
5575 2001-12-27 Fernando Perez <fperez@colorado.edu>
5582 2001-12-27 Fernando Perez <fperez@colorado.edu>
5576
5583
5577 * IPython/iplib.py (InteractiveShell.interact): Added the original
5584 * IPython/iplib.py (InteractiveShell.interact): Added the original
5578 code from 'code.py' for this module in order to change the
5585 code from 'code.py' for this module in order to change the
5579 handling of a KeyboardInterrupt. This was necessary b/c otherwise
5586 handling of a KeyboardInterrupt. This was necessary b/c otherwise
5580 the history cache would break when the user hit Ctrl-C, and
5587 the history cache would break when the user hit Ctrl-C, and
5581 interact() offers no way to add any hooks to it.
5588 interact() offers no way to add any hooks to it.
5582
5589
5583 2001-12-23 Fernando Perez <fperez@colorado.edu>
5590 2001-12-23 Fernando Perez <fperez@colorado.edu>
5584
5591
5585 * setup.py: added check for 'MANIFEST' before trying to remove
5592 * setup.py: added check for 'MANIFEST' before trying to remove
5586 it. Thanks to Sean Reifschneider.
5593 it. Thanks to Sean Reifschneider.
5587
5594
5588 2001-12-22 Fernando Perez <fperez@colorado.edu>
5595 2001-12-22 Fernando Perez <fperez@colorado.edu>
5589
5596
5590 * Released 0.2.2.
5597 * Released 0.2.2.
5591
5598
5592 * Finished (reasonably) writing the manual. Later will add the
5599 * Finished (reasonably) writing the manual. Later will add the
5593 python-standard navigation stylesheets, but for the time being
5600 python-standard navigation stylesheets, but for the time being
5594 it's fairly complete. Distribution will include html and pdf
5601 it's fairly complete. Distribution will include html and pdf
5595 versions.
5602 versions.
5596
5603
5597 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
5604 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
5598 (MayaVi author).
5605 (MayaVi author).
5599
5606
5600 2001-12-21 Fernando Perez <fperez@colorado.edu>
5607 2001-12-21 Fernando Perez <fperez@colorado.edu>
5601
5608
5602 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
5609 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
5603 good public release, I think (with the manual and the distutils
5610 good public release, I think (with the manual and the distutils
5604 installer). The manual can use some work, but that can go
5611 installer). The manual can use some work, but that can go
5605 slowly. Otherwise I think it's quite nice for end users. Next
5612 slowly. Otherwise I think it's quite nice for end users. Next
5606 summer, rewrite the guts of it...
5613 summer, rewrite the guts of it...
5607
5614
5608 * Changed format of ipythonrc files to use whitespace as the
5615 * Changed format of ipythonrc files to use whitespace as the
5609 separator instead of an explicit '='. Cleaner.
5616 separator instead of an explicit '='. Cleaner.
5610
5617
5611 2001-12-20 Fernando Perez <fperez@colorado.edu>
5618 2001-12-20 Fernando Perez <fperez@colorado.edu>
5612
5619
5613 * Started a manual in LyX. For now it's just a quick merge of the
5620 * Started a manual in LyX. For now it's just a quick merge of the
5614 various internal docstrings and READMEs. Later it may grow into a
5621 various internal docstrings and READMEs. Later it may grow into a
5615 nice, full-blown manual.
5622 nice, full-blown manual.
5616
5623
5617 * Set up a distutils based installer. Installation should now be
5624 * Set up a distutils based installer. Installation should now be
5618 trivially simple for end-users.
5625 trivially simple for end-users.
5619
5626
5620 2001-12-11 Fernando Perez <fperez@colorado.edu>
5627 2001-12-11 Fernando Perez <fperez@colorado.edu>
5621
5628
5622 * Released 0.2.0. First public release, announced it at
5629 * Released 0.2.0. First public release, announced it at
5623 comp.lang.python. From now on, just bugfixes...
5630 comp.lang.python. From now on, just bugfixes...
5624
5631
5625 * Went through all the files, set copyright/license notices and
5632 * Went through all the files, set copyright/license notices and
5626 cleaned up things. Ready for release.
5633 cleaned up things. Ready for release.
5627
5634
5628 2001-12-10 Fernando Perez <fperez@colorado.edu>
5635 2001-12-10 Fernando Perez <fperez@colorado.edu>
5629
5636
5630 * Changed the first-time installer not to use tarfiles. It's more
5637 * Changed the first-time installer not to use tarfiles. It's more
5631 robust now and less unix-dependent. Also makes it easier for
5638 robust now and less unix-dependent. Also makes it easier for
5632 people to later upgrade versions.
5639 people to later upgrade versions.
5633
5640
5634 * Changed @exit to @abort to reflect the fact that it's pretty
5641 * Changed @exit to @abort to reflect the fact that it's pretty
5635 brutal (a sys.exit()). The difference between @abort and Ctrl-D
5642 brutal (a sys.exit()). The difference between @abort and Ctrl-D
5636 becomes significant only when IPyhton is embedded: in that case,
5643 becomes significant only when IPyhton is embedded: in that case,
5637 C-D closes IPython only, but @abort kills the enclosing program
5644 C-D closes IPython only, but @abort kills the enclosing program
5638 too (unless it had called IPython inside a try catching
5645 too (unless it had called IPython inside a try catching
5639 SystemExit).
5646 SystemExit).
5640
5647
5641 * Created Shell module which exposes the actuall IPython Shell
5648 * Created Shell module which exposes the actuall IPython Shell
5642 classes, currently the normal and the embeddable one. This at
5649 classes, currently the normal and the embeddable one. This at
5643 least offers a stable interface we won't need to change when
5650 least offers a stable interface we won't need to change when
5644 (later) the internals are rewritten. That rewrite will be confined
5651 (later) the internals are rewritten. That rewrite will be confined
5645 to iplib and ipmaker, but the Shell interface should remain as is.
5652 to iplib and ipmaker, but the Shell interface should remain as is.
5646
5653
5647 * Added embed module which offers an embeddable IPShell object,
5654 * Added embed module which offers an embeddable IPShell object,
5648 useful to fire up IPython *inside* a running program. Great for
5655 useful to fire up IPython *inside* a running program. Great for
5649 debugging or dynamical data analysis.
5656 debugging or dynamical data analysis.
5650
5657
5651 2001-12-08 Fernando Perez <fperez@colorado.edu>
5658 2001-12-08 Fernando Perez <fperez@colorado.edu>
5652
5659
5653 * Fixed small bug preventing seeing info from methods of defined
5660 * Fixed small bug preventing seeing info from methods of defined
5654 objects (incorrect namespace in _ofind()).
5661 objects (incorrect namespace in _ofind()).
5655
5662
5656 * Documentation cleanup. Moved the main usage docstrings to a
5663 * Documentation cleanup. Moved the main usage docstrings to a
5657 separate file, usage.py (cleaner to maintain, and hopefully in the
5664 separate file, usage.py (cleaner to maintain, and hopefully in the
5658 future some perlpod-like way of producing interactive, man and
5665 future some perlpod-like way of producing interactive, man and
5659 html docs out of it will be found).
5666 html docs out of it will be found).
5660
5667
5661 * Added @profile to see your profile at any time.
5668 * Added @profile to see your profile at any time.
5662
5669
5663 * Added @p as an alias for 'print'. It's especially convenient if
5670 * Added @p as an alias for 'print'. It's especially convenient if
5664 using automagic ('p x' prints x).
5671 using automagic ('p x' prints x).
5665
5672
5666 * Small cleanups and fixes after a pychecker run.
5673 * Small cleanups and fixes after a pychecker run.
5667
5674
5668 * Changed the @cd command to handle @cd - and @cd -<n> for
5675 * Changed the @cd command to handle @cd - and @cd -<n> for
5669 visiting any directory in _dh.
5676 visiting any directory in _dh.
5670
5677
5671 * Introduced _dh, a history of visited directories. @dhist prints
5678 * Introduced _dh, a history of visited directories. @dhist prints
5672 it out with numbers.
5679 it out with numbers.
5673
5680
5674 2001-12-07 Fernando Perez <fperez@colorado.edu>
5681 2001-12-07 Fernando Perez <fperez@colorado.edu>
5675
5682
5676 * Released 0.1.22
5683 * Released 0.1.22
5677
5684
5678 * Made initialization a bit more robust against invalid color
5685 * Made initialization a bit more robust against invalid color
5679 options in user input (exit, not traceback-crash).
5686 options in user input (exit, not traceback-crash).
5680
5687
5681 * Changed the bug crash reporter to write the report only in the
5688 * Changed the bug crash reporter to write the report only in the
5682 user's .ipython directory. That way IPython won't litter people's
5689 user's .ipython directory. That way IPython won't litter people's
5683 hard disks with crash files all over the place. Also print on
5690 hard disks with crash files all over the place. Also print on
5684 screen the necessary mail command.
5691 screen the necessary mail command.
5685
5692
5686 * With the new ultraTB, implemented LightBG color scheme for light
5693 * With the new ultraTB, implemented LightBG color scheme for light
5687 background terminals. A lot of people like white backgrounds, so I
5694 background terminals. A lot of people like white backgrounds, so I
5688 guess we should at least give them something readable.
5695 guess we should at least give them something readable.
5689
5696
5690 2001-12-06 Fernando Perez <fperez@colorado.edu>
5697 2001-12-06 Fernando Perez <fperez@colorado.edu>
5691
5698
5692 * Modified the structure of ultraTB. Now there's a proper class
5699 * Modified the structure of ultraTB. Now there's a proper class
5693 for tables of color schemes which allow adding schemes easily and
5700 for tables of color schemes which allow adding schemes easily and
5694 switching the active scheme without creating a new instance every
5701 switching the active scheme without creating a new instance every
5695 time (which was ridiculous). The syntax for creating new schemes
5702 time (which was ridiculous). The syntax for creating new schemes
5696 is also cleaner. I think ultraTB is finally done, with a clean
5703 is also cleaner. I think ultraTB is finally done, with a clean
5697 class structure. Names are also much cleaner (now there's proper
5704 class structure. Names are also much cleaner (now there's proper
5698 color tables, no need for every variable to also have 'color' in
5705 color tables, no need for every variable to also have 'color' in
5699 its name).
5706 its name).
5700
5707
5701 * Broke down genutils into separate files. Now genutils only
5708 * Broke down genutils into separate files. Now genutils only
5702 contains utility functions, and classes have been moved to their
5709 contains utility functions, and classes have been moved to their
5703 own files (they had enough independent functionality to warrant
5710 own files (they had enough independent functionality to warrant
5704 it): ConfigLoader, OutputTrap, Struct.
5711 it): ConfigLoader, OutputTrap, Struct.
5705
5712
5706 2001-12-05 Fernando Perez <fperez@colorado.edu>
5713 2001-12-05 Fernando Perez <fperez@colorado.edu>
5707
5714
5708 * IPython turns 21! Released version 0.1.21, as a candidate for
5715 * IPython turns 21! Released version 0.1.21, as a candidate for
5709 public consumption. If all goes well, release in a few days.
5716 public consumption. If all goes well, release in a few days.
5710
5717
5711 * Fixed path bug (files in Extensions/ directory wouldn't be found
5718 * Fixed path bug (files in Extensions/ directory wouldn't be found
5712 unless IPython/ was explicitly in sys.path).
5719 unless IPython/ was explicitly in sys.path).
5713
5720
5714 * Extended the FlexCompleter class as MagicCompleter to allow
5721 * Extended the FlexCompleter class as MagicCompleter to allow
5715 completion of @-starting lines.
5722 completion of @-starting lines.
5716
5723
5717 * Created __release__.py file as a central repository for release
5724 * Created __release__.py file as a central repository for release
5718 info that other files can read from.
5725 info that other files can read from.
5719
5726
5720 * Fixed small bug in logging: when logging was turned on in
5727 * Fixed small bug in logging: when logging was turned on in
5721 mid-session, old lines with special meanings (!@?) were being
5728 mid-session, old lines with special meanings (!@?) were being
5722 logged without the prepended comment, which is necessary since
5729 logged without the prepended comment, which is necessary since
5723 they are not truly valid python syntax. This should make session
5730 they are not truly valid python syntax. This should make session
5724 restores produce less errors.
5731 restores produce less errors.
5725
5732
5726 * The namespace cleanup forced me to make a FlexCompleter class
5733 * The namespace cleanup forced me to make a FlexCompleter class
5727 which is nothing but a ripoff of rlcompleter, but with selectable
5734 which is nothing but a ripoff of rlcompleter, but with selectable
5728 namespace (rlcompleter only works in __main__.__dict__). I'll try
5735 namespace (rlcompleter only works in __main__.__dict__). I'll try
5729 to submit a note to the authors to see if this change can be
5736 to submit a note to the authors to see if this change can be
5730 incorporated in future rlcompleter releases (Dec.6: done)
5737 incorporated in future rlcompleter releases (Dec.6: done)
5731
5738
5732 * More fixes to namespace handling. It was a mess! Now all
5739 * More fixes to namespace handling. It was a mess! Now all
5733 explicit references to __main__.__dict__ are gone (except when
5740 explicit references to __main__.__dict__ are gone (except when
5734 really needed) and everything is handled through the namespace
5741 really needed) and everything is handled through the namespace
5735 dicts in the IPython instance. We seem to be getting somewhere
5742 dicts in the IPython instance. We seem to be getting somewhere
5736 with this, finally...
5743 with this, finally...
5737
5744
5738 * Small documentation updates.
5745 * Small documentation updates.
5739
5746
5740 * Created the Extensions directory under IPython (with an
5747 * Created the Extensions directory under IPython (with an
5741 __init__.py). Put the PhysicalQ stuff there. This directory should
5748 __init__.py). Put the PhysicalQ stuff there. This directory should
5742 be used for all special-purpose extensions.
5749 be used for all special-purpose extensions.
5743
5750
5744 * File renaming:
5751 * File renaming:
5745 ipythonlib --> ipmaker
5752 ipythonlib --> ipmaker
5746 ipplib --> iplib
5753 ipplib --> iplib
5747 This makes a bit more sense in terms of what these files actually do.
5754 This makes a bit more sense in terms of what these files actually do.
5748
5755
5749 * Moved all the classes and functions in ipythonlib to ipplib, so
5756 * Moved all the classes and functions in ipythonlib to ipplib, so
5750 now ipythonlib only has make_IPython(). This will ease up its
5757 now ipythonlib only has make_IPython(). This will ease up its
5751 splitting in smaller functional chunks later.
5758 splitting in smaller functional chunks later.
5752
5759
5753 * Cleaned up (done, I think) output of @whos. Better column
5760 * Cleaned up (done, I think) output of @whos. Better column
5754 formatting, and now shows str(var) for as much as it can, which is
5761 formatting, and now shows str(var) for as much as it can, which is
5755 typically what one gets with a 'print var'.
5762 typically what one gets with a 'print var'.
5756
5763
5757 2001-12-04 Fernando Perez <fperez@colorado.edu>
5764 2001-12-04 Fernando Perez <fperez@colorado.edu>
5758
5765
5759 * Fixed namespace problems. Now builtin/IPyhton/user names get
5766 * Fixed namespace problems. Now builtin/IPyhton/user names get
5760 properly reported in their namespace. Internal namespace handling
5767 properly reported in their namespace. Internal namespace handling
5761 is finally getting decent (not perfect yet, but much better than
5768 is finally getting decent (not perfect yet, but much better than
5762 the ad-hoc mess we had).
5769 the ad-hoc mess we had).
5763
5770
5764 * Removed -exit option. If people just want to run a python
5771 * Removed -exit option. If people just want to run a python
5765 script, that's what the normal interpreter is for. Less
5772 script, that's what the normal interpreter is for. Less
5766 unnecessary options, less chances for bugs.
5773 unnecessary options, less chances for bugs.
5767
5774
5768 * Added a crash handler which generates a complete post-mortem if
5775 * Added a crash handler which generates a complete post-mortem if
5769 IPython crashes. This will help a lot in tracking bugs down the
5776 IPython crashes. This will help a lot in tracking bugs down the
5770 road.
5777 road.
5771
5778
5772 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
5779 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
5773 which were boud to functions being reassigned would bypass the
5780 which were boud to functions being reassigned would bypass the
5774 logger, breaking the sync of _il with the prompt counter. This
5781 logger, breaking the sync of _il with the prompt counter. This
5775 would then crash IPython later when a new line was logged.
5782 would then crash IPython later when a new line was logged.
5776
5783
5777 2001-12-02 Fernando Perez <fperez@colorado.edu>
5784 2001-12-02 Fernando Perez <fperez@colorado.edu>
5778
5785
5779 * Made IPython a package. This means people don't have to clutter
5786 * Made IPython a package. This means people don't have to clutter
5780 their sys.path with yet another directory. Changed the INSTALL
5787 their sys.path with yet another directory. Changed the INSTALL
5781 file accordingly.
5788 file accordingly.
5782
5789
5783 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
5790 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
5784 sorts its output (so @who shows it sorted) and @whos formats the
5791 sorts its output (so @who shows it sorted) and @whos formats the
5785 table according to the width of the first column. Nicer, easier to
5792 table according to the width of the first column. Nicer, easier to
5786 read. Todo: write a generic table_format() which takes a list of
5793 read. Todo: write a generic table_format() which takes a list of
5787 lists and prints it nicely formatted, with optional row/column
5794 lists and prints it nicely formatted, with optional row/column
5788 separators and proper padding and justification.
5795 separators and proper padding and justification.
5789
5796
5790 * Released 0.1.20
5797 * Released 0.1.20
5791
5798
5792 * Fixed bug in @log which would reverse the inputcache list (a
5799 * Fixed bug in @log which would reverse the inputcache list (a
5793 copy operation was missing).
5800 copy operation was missing).
5794
5801
5795 * Code cleanup. @config was changed to use page(). Better, since
5802 * Code cleanup. @config was changed to use page(). Better, since
5796 its output is always quite long.
5803 its output is always quite long.
5797
5804
5798 * Itpl is back as a dependency. I was having too many problems
5805 * Itpl is back as a dependency. I was having too many problems
5799 getting the parametric aliases to work reliably, and it's just
5806 getting the parametric aliases to work reliably, and it's just
5800 easier to code weird string operations with it than playing %()s
5807 easier to code weird string operations with it than playing %()s
5801 games. It's only ~6k, so I don't think it's too big a deal.
5808 games. It's only ~6k, so I don't think it's too big a deal.
5802
5809
5803 * Found (and fixed) a very nasty bug with history. !lines weren't
5810 * Found (and fixed) a very nasty bug with history. !lines weren't
5804 getting cached, and the out of sync caches would crash
5811 getting cached, and the out of sync caches would crash
5805 IPython. Fixed it by reorganizing the prefilter/handlers/logger
5812 IPython. Fixed it by reorganizing the prefilter/handlers/logger
5806 division of labor a bit better. Bug fixed, cleaner structure.
5813 division of labor a bit better. Bug fixed, cleaner structure.
5807
5814
5808 2001-12-01 Fernando Perez <fperez@colorado.edu>
5815 2001-12-01 Fernando Perez <fperez@colorado.edu>
5809
5816
5810 * Released 0.1.19
5817 * Released 0.1.19
5811
5818
5812 * Added option -n to @hist to prevent line number printing. Much
5819 * Added option -n to @hist to prevent line number printing. Much
5813 easier to copy/paste code this way.
5820 easier to copy/paste code this way.
5814
5821
5815 * Created global _il to hold the input list. Allows easy
5822 * Created global _il to hold the input list. Allows easy
5816 re-execution of blocks of code by slicing it (inspired by Janko's
5823 re-execution of blocks of code by slicing it (inspired by Janko's
5817 comment on 'macros').
5824 comment on 'macros').
5818
5825
5819 * Small fixes and doc updates.
5826 * Small fixes and doc updates.
5820
5827
5821 * Rewrote @history function (was @h). Renamed it to @hist, @h is
5828 * Rewrote @history function (was @h). Renamed it to @hist, @h is
5822 much too fragile with automagic. Handles properly multi-line
5829 much too fragile with automagic. Handles properly multi-line
5823 statements and takes parameters.
5830 statements and takes parameters.
5824
5831
5825 2001-11-30 Fernando Perez <fperez@colorado.edu>
5832 2001-11-30 Fernando Perez <fperez@colorado.edu>
5826
5833
5827 * Version 0.1.18 released.
5834 * Version 0.1.18 released.
5828
5835
5829 * Fixed nasty namespace bug in initial module imports.
5836 * Fixed nasty namespace bug in initial module imports.
5830
5837
5831 * Added copyright/license notes to all code files (except
5838 * Added copyright/license notes to all code files (except
5832 DPyGetOpt). For the time being, LGPL. That could change.
5839 DPyGetOpt). For the time being, LGPL. That could change.
5833
5840
5834 * Rewrote a much nicer README, updated INSTALL, cleaned up
5841 * Rewrote a much nicer README, updated INSTALL, cleaned up
5835 ipythonrc-* samples.
5842 ipythonrc-* samples.
5836
5843
5837 * Overall code/documentation cleanup. Basically ready for
5844 * Overall code/documentation cleanup. Basically ready for
5838 release. Only remaining thing: licence decision (LGPL?).
5845 release. Only remaining thing: licence decision (LGPL?).
5839
5846
5840 * Converted load_config to a class, ConfigLoader. Now recursion
5847 * Converted load_config to a class, ConfigLoader. Now recursion
5841 control is better organized. Doesn't include the same file twice.
5848 control is better organized. Doesn't include the same file twice.
5842
5849
5843 2001-11-29 Fernando Perez <fperez@colorado.edu>
5850 2001-11-29 Fernando Perez <fperez@colorado.edu>
5844
5851
5845 * Got input history working. Changed output history variables from
5852 * Got input history working. Changed output history variables from
5846 _p to _o so that _i is for input and _o for output. Just cleaner
5853 _p to _o so that _i is for input and _o for output. Just cleaner
5847 convention.
5854 convention.
5848
5855
5849 * Implemented parametric aliases. This pretty much allows the
5856 * Implemented parametric aliases. This pretty much allows the
5850 alias system to offer full-blown shell convenience, I think.
5857 alias system to offer full-blown shell convenience, I think.
5851
5858
5852 * Version 0.1.17 released, 0.1.18 opened.
5859 * Version 0.1.17 released, 0.1.18 opened.
5853
5860
5854 * dot_ipython/ipythonrc (alias): added documentation.
5861 * dot_ipython/ipythonrc (alias): added documentation.
5855 (xcolor): Fixed small bug (xcolors -> xcolor)
5862 (xcolor): Fixed small bug (xcolors -> xcolor)
5856
5863
5857 * Changed the alias system. Now alias is a magic command to define
5864 * Changed the alias system. Now alias is a magic command to define
5858 aliases just like the shell. Rationale: the builtin magics should
5865 aliases just like the shell. Rationale: the builtin magics should
5859 be there for things deeply connected to IPython's
5866 be there for things deeply connected to IPython's
5860 architecture. And this is a much lighter system for what I think
5867 architecture. And this is a much lighter system for what I think
5861 is the really important feature: allowing users to define quickly
5868 is the really important feature: allowing users to define quickly
5862 magics that will do shell things for them, so they can customize
5869 magics that will do shell things for them, so they can customize
5863 IPython easily to match their work habits. If someone is really
5870 IPython easily to match their work habits. If someone is really
5864 desperate to have another name for a builtin alias, they can
5871 desperate to have another name for a builtin alias, they can
5865 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
5872 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
5866 works.
5873 works.
5867
5874
5868 2001-11-28 Fernando Perez <fperez@colorado.edu>
5875 2001-11-28 Fernando Perez <fperez@colorado.edu>
5869
5876
5870 * Changed @file so that it opens the source file at the proper
5877 * Changed @file so that it opens the source file at the proper
5871 line. Since it uses less, if your EDITOR environment is
5878 line. Since it uses less, if your EDITOR environment is
5872 configured, typing v will immediately open your editor of choice
5879 configured, typing v will immediately open your editor of choice
5873 right at the line where the object is defined. Not as quick as
5880 right at the line where the object is defined. Not as quick as
5874 having a direct @edit command, but for all intents and purposes it
5881 having a direct @edit command, but for all intents and purposes it
5875 works. And I don't have to worry about writing @edit to deal with
5882 works. And I don't have to worry about writing @edit to deal with
5876 all the editors, less does that.
5883 all the editors, less does that.
5877
5884
5878 * Version 0.1.16 released, 0.1.17 opened.
5885 * Version 0.1.16 released, 0.1.17 opened.
5879
5886
5880 * Fixed some nasty bugs in the page/page_dumb combo that could
5887 * Fixed some nasty bugs in the page/page_dumb combo that could
5881 crash IPython.
5888 crash IPython.
5882
5889
5883 2001-11-27 Fernando Perez <fperez@colorado.edu>
5890 2001-11-27 Fernando Perez <fperez@colorado.edu>
5884
5891
5885 * Version 0.1.15 released, 0.1.16 opened.
5892 * Version 0.1.15 released, 0.1.16 opened.
5886
5893
5887 * Finally got ? and ?? to work for undefined things: now it's
5894 * Finally got ? and ?? to work for undefined things: now it's
5888 possible to type {}.get? and get information about the get method
5895 possible to type {}.get? and get information about the get method
5889 of dicts, or os.path? even if only os is defined (so technically
5896 of dicts, or os.path? even if only os is defined (so technically
5890 os.path isn't). Works at any level. For example, after import os,
5897 os.path isn't). Works at any level. For example, after import os,
5891 os?, os.path?, os.path.abspath? all work. This is great, took some
5898 os?, os.path?, os.path.abspath? all work. This is great, took some
5892 work in _ofind.
5899 work in _ofind.
5893
5900
5894 * Fixed more bugs with logging. The sanest way to do it was to add
5901 * Fixed more bugs with logging. The sanest way to do it was to add
5895 to @log a 'mode' parameter. Killed two in one shot (this mode
5902 to @log a 'mode' parameter. Killed two in one shot (this mode
5896 option was a request of Janko's). I think it's finally clean
5903 option was a request of Janko's). I think it's finally clean
5897 (famous last words).
5904 (famous last words).
5898
5905
5899 * Added a page_dumb() pager which does a decent job of paging on
5906 * Added a page_dumb() pager which does a decent job of paging on
5900 screen, if better things (like less) aren't available. One less
5907 screen, if better things (like less) aren't available. One less
5901 unix dependency (someday maybe somebody will port this to
5908 unix dependency (someday maybe somebody will port this to
5902 windows).
5909 windows).
5903
5910
5904 * Fixed problem in magic_log: would lock of logging out if log
5911 * Fixed problem in magic_log: would lock of logging out if log
5905 creation failed (because it would still think it had succeeded).
5912 creation failed (because it would still think it had succeeded).
5906
5913
5907 * Improved the page() function using curses to auto-detect screen
5914 * Improved the page() function using curses to auto-detect screen
5908 size. Now it can make a much better decision on whether to print
5915 size. Now it can make a much better decision on whether to print
5909 or page a string. Option screen_length was modified: a value 0
5916 or page a string. Option screen_length was modified: a value 0
5910 means auto-detect, and that's the default now.
5917 means auto-detect, and that's the default now.
5911
5918
5912 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
5919 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
5913 go out. I'll test it for a few days, then talk to Janko about
5920 go out. I'll test it for a few days, then talk to Janko about
5914 licences and announce it.
5921 licences and announce it.
5915
5922
5916 * Fixed the length of the auto-generated ---> prompt which appears
5923 * Fixed the length of the auto-generated ---> prompt which appears
5917 for auto-parens and auto-quotes. Getting this right isn't trivial,
5924 for auto-parens and auto-quotes. Getting this right isn't trivial,
5918 with all the color escapes, different prompt types and optional
5925 with all the color escapes, different prompt types and optional
5919 separators. But it seems to be working in all the combinations.
5926 separators. But it seems to be working in all the combinations.
5920
5927
5921 2001-11-26 Fernando Perez <fperez@colorado.edu>
5928 2001-11-26 Fernando Perez <fperez@colorado.edu>
5922
5929
5923 * Wrote a regexp filter to get option types from the option names
5930 * Wrote a regexp filter to get option types from the option names
5924 string. This eliminates the need to manually keep two duplicate
5931 string. This eliminates the need to manually keep two duplicate
5925 lists.
5932 lists.
5926
5933
5927 * Removed the unneeded check_option_names. Now options are handled
5934 * Removed the unneeded check_option_names. Now options are handled
5928 in a much saner manner and it's easy to visually check that things
5935 in a much saner manner and it's easy to visually check that things
5929 are ok.
5936 are ok.
5930
5937
5931 * Updated version numbers on all files I modified to carry a
5938 * Updated version numbers on all files I modified to carry a
5932 notice so Janko and Nathan have clear version markers.
5939 notice so Janko and Nathan have clear version markers.
5933
5940
5934 * Updated docstring for ultraTB with my changes. I should send
5941 * Updated docstring for ultraTB with my changes. I should send
5935 this to Nathan.
5942 this to Nathan.
5936
5943
5937 * Lots of small fixes. Ran everything through pychecker again.
5944 * Lots of small fixes. Ran everything through pychecker again.
5938
5945
5939 * Made loading of deep_reload an cmd line option. If it's not too
5946 * Made loading of deep_reload an cmd line option. If it's not too
5940 kosher, now people can just disable it. With -nodeep_reload it's
5947 kosher, now people can just disable it. With -nodeep_reload it's
5941 still available as dreload(), it just won't overwrite reload().
5948 still available as dreload(), it just won't overwrite reload().
5942
5949
5943 * Moved many options to the no| form (-opt and -noopt
5950 * Moved many options to the no| form (-opt and -noopt
5944 accepted). Cleaner.
5951 accepted). Cleaner.
5945
5952
5946 * Changed magic_log so that if called with no parameters, it uses
5953 * Changed magic_log so that if called with no parameters, it uses
5947 'rotate' mode. That way auto-generated logs aren't automatically
5954 'rotate' mode. That way auto-generated logs aren't automatically
5948 over-written. For normal logs, now a backup is made if it exists
5955 over-written. For normal logs, now a backup is made if it exists
5949 (only 1 level of backups). A new 'backup' mode was added to the
5956 (only 1 level of backups). A new 'backup' mode was added to the
5950 Logger class to support this. This was a request by Janko.
5957 Logger class to support this. This was a request by Janko.
5951
5958
5952 * Added @logoff/@logon to stop/restart an active log.
5959 * Added @logoff/@logon to stop/restart an active log.
5953
5960
5954 * Fixed a lot of bugs in log saving/replay. It was pretty
5961 * Fixed a lot of bugs in log saving/replay. It was pretty
5955 broken. Now special lines (!@,/) appear properly in the command
5962 broken. Now special lines (!@,/) appear properly in the command
5956 history after a log replay.
5963 history after a log replay.
5957
5964
5958 * Tried and failed to implement full session saving via pickle. My
5965 * Tried and failed to implement full session saving via pickle. My
5959 idea was to pickle __main__.__dict__, but modules can't be
5966 idea was to pickle __main__.__dict__, but modules can't be
5960 pickled. This would be a better alternative to replaying logs, but
5967 pickled. This would be a better alternative to replaying logs, but
5961 seems quite tricky to get to work. Changed -session to be called
5968 seems quite tricky to get to work. Changed -session to be called
5962 -logplay, which more accurately reflects what it does. And if we
5969 -logplay, which more accurately reflects what it does. And if we
5963 ever get real session saving working, -session is now available.
5970 ever get real session saving working, -session is now available.
5964
5971
5965 * Implemented color schemes for prompts also. As for tracebacks,
5972 * Implemented color schemes for prompts also. As for tracebacks,
5966 currently only NoColor and Linux are supported. But now the
5973 currently only NoColor and Linux are supported. But now the
5967 infrastructure is in place, based on a generic ColorScheme
5974 infrastructure is in place, based on a generic ColorScheme
5968 class. So writing and activating new schemes both for the prompts
5975 class. So writing and activating new schemes both for the prompts
5969 and the tracebacks should be straightforward.
5976 and the tracebacks should be straightforward.
5970
5977
5971 * Version 0.1.13 released, 0.1.14 opened.
5978 * Version 0.1.13 released, 0.1.14 opened.
5972
5979
5973 * Changed handling of options for output cache. Now counter is
5980 * Changed handling of options for output cache. Now counter is
5974 hardwired starting at 1 and one specifies the maximum number of
5981 hardwired starting at 1 and one specifies the maximum number of
5975 entries *in the outcache* (not the max prompt counter). This is
5982 entries *in the outcache* (not the max prompt counter). This is
5976 much better, since many statements won't increase the cache
5983 much better, since many statements won't increase the cache
5977 count. It also eliminated some confusing options, now there's only
5984 count. It also eliminated some confusing options, now there's only
5978 one: cache_size.
5985 one: cache_size.
5979
5986
5980 * Added 'alias' magic function and magic_alias option in the
5987 * Added 'alias' magic function and magic_alias option in the
5981 ipythonrc file. Now the user can easily define whatever names he
5988 ipythonrc file. Now the user can easily define whatever names he
5982 wants for the magic functions without having to play weird
5989 wants for the magic functions without having to play weird
5983 namespace games. This gives IPython a real shell-like feel.
5990 namespace games. This gives IPython a real shell-like feel.
5984
5991
5985 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
5992 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
5986 @ or not).
5993 @ or not).
5987
5994
5988 This was one of the last remaining 'visible' bugs (that I know
5995 This was one of the last remaining 'visible' bugs (that I know
5989 of). I think if I can clean up the session loading so it works
5996 of). I think if I can clean up the session loading so it works
5990 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
5997 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
5991 about licensing).
5998 about licensing).
5992
5999
5993 2001-11-25 Fernando Perez <fperez@colorado.edu>
6000 2001-11-25 Fernando Perez <fperez@colorado.edu>
5994
6001
5995 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
6002 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
5996 there's a cleaner distinction between what ? and ?? show.
6003 there's a cleaner distinction between what ? and ?? show.
5997
6004
5998 * Added screen_length option. Now the user can define his own
6005 * Added screen_length option. Now the user can define his own
5999 screen size for page() operations.
6006 screen size for page() operations.
6000
6007
6001 * Implemented magic shell-like functions with automatic code
6008 * Implemented magic shell-like functions with automatic code
6002 generation. Now adding another function is just a matter of adding
6009 generation. Now adding another function is just a matter of adding
6003 an entry to a dict, and the function is dynamically generated at
6010 an entry to a dict, and the function is dynamically generated at
6004 run-time. Python has some really cool features!
6011 run-time. Python has some really cool features!
6005
6012
6006 * Renamed many options to cleanup conventions a little. Now all
6013 * Renamed many options to cleanup conventions a little. Now all
6007 are lowercase, and only underscores where needed. Also in the code
6014 are lowercase, and only underscores where needed. Also in the code
6008 option name tables are clearer.
6015 option name tables are clearer.
6009
6016
6010 * Changed prompts a little. Now input is 'In [n]:' instead of
6017 * Changed prompts a little. Now input is 'In [n]:' instead of
6011 'In[n]:='. This allows it the numbers to be aligned with the
6018 'In[n]:='. This allows it the numbers to be aligned with the
6012 Out[n] numbers, and removes usage of ':=' which doesn't exist in
6019 Out[n] numbers, and removes usage of ':=' which doesn't exist in
6013 Python (it was a Mathematica thing). The '...' continuation prompt
6020 Python (it was a Mathematica thing). The '...' continuation prompt
6014 was also changed a little to align better.
6021 was also changed a little to align better.
6015
6022
6016 * Fixed bug when flushing output cache. Not all _p<n> variables
6023 * Fixed bug when flushing output cache. Not all _p<n> variables
6017 exist, so their deletion needs to be wrapped in a try:
6024 exist, so their deletion needs to be wrapped in a try:
6018
6025
6019 * Figured out how to properly use inspect.formatargspec() (it
6026 * Figured out how to properly use inspect.formatargspec() (it
6020 requires the args preceded by *). So I removed all the code from
6027 requires the args preceded by *). So I removed all the code from
6021 _get_pdef in Magic, which was just replicating that.
6028 _get_pdef in Magic, which was just replicating that.
6022
6029
6023 * Added test to prefilter to allow redefining magic function names
6030 * Added test to prefilter to allow redefining magic function names
6024 as variables. This is ok, since the @ form is always available,
6031 as variables. This is ok, since the @ form is always available,
6025 but whe should allow the user to define a variable called 'ls' if
6032 but whe should allow the user to define a variable called 'ls' if
6026 he needs it.
6033 he needs it.
6027
6034
6028 * Moved the ToDo information from README into a separate ToDo.
6035 * Moved the ToDo information from README into a separate ToDo.
6029
6036
6030 * General code cleanup and small bugfixes. I think it's close to a
6037 * General code cleanup and small bugfixes. I think it's close to a
6031 state where it can be released, obviously with a big 'beta'
6038 state where it can be released, obviously with a big 'beta'
6032 warning on it.
6039 warning on it.
6033
6040
6034 * Got the magic function split to work. Now all magics are defined
6041 * Got the magic function split to work. Now all magics are defined
6035 in a separate class. It just organizes things a bit, and now
6042 in a separate class. It just organizes things a bit, and now
6036 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
6043 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
6037 was too long).
6044 was too long).
6038
6045
6039 * Changed @clear to @reset to avoid potential confusions with
6046 * Changed @clear to @reset to avoid potential confusions with
6040 the shell command clear. Also renamed @cl to @clear, which does
6047 the shell command clear. Also renamed @cl to @clear, which does
6041 exactly what people expect it to from their shell experience.
6048 exactly what people expect it to from their shell experience.
6042
6049
6043 Added a check to the @reset command (since it's so
6050 Added a check to the @reset command (since it's so
6044 destructive, it's probably a good idea to ask for confirmation).
6051 destructive, it's probably a good idea to ask for confirmation).
6045 But now reset only works for full namespace resetting. Since the
6052 But now reset only works for full namespace resetting. Since the
6046 del keyword is already there for deleting a few specific
6053 del keyword is already there for deleting a few specific
6047 variables, I don't see the point of having a redundant magic
6054 variables, I don't see the point of having a redundant magic
6048 function for the same task.
6055 function for the same task.
6049
6056
6050 2001-11-24 Fernando Perez <fperez@colorado.edu>
6057 2001-11-24 Fernando Perez <fperez@colorado.edu>
6051
6058
6052 * Updated the builtin docs (esp. the ? ones).
6059 * Updated the builtin docs (esp. the ? ones).
6053
6060
6054 * Ran all the code through pychecker. Not terribly impressed with
6061 * Ran all the code through pychecker. Not terribly impressed with
6055 it: lots of spurious warnings and didn't really find anything of
6062 it: lots of spurious warnings and didn't really find anything of
6056 substance (just a few modules being imported and not used).
6063 substance (just a few modules being imported and not used).
6057
6064
6058 * Implemented the new ultraTB functionality into IPython. New
6065 * Implemented the new ultraTB functionality into IPython. New
6059 option: xcolors. This chooses color scheme. xmode now only selects
6066 option: xcolors. This chooses color scheme. xmode now only selects
6060 between Plain and Verbose. Better orthogonality.
6067 between Plain and Verbose. Better orthogonality.
6061
6068
6062 * Large rewrite of ultraTB. Much cleaner now, with a separation of
6069 * Large rewrite of ultraTB. Much cleaner now, with a separation of
6063 mode and color scheme for the exception handlers. Now it's
6070 mode and color scheme for the exception handlers. Now it's
6064 possible to have the verbose traceback with no coloring.
6071 possible to have the verbose traceback with no coloring.
6065
6072
6066 2001-11-23 Fernando Perez <fperez@colorado.edu>
6073 2001-11-23 Fernando Perez <fperez@colorado.edu>
6067
6074
6068 * Version 0.1.12 released, 0.1.13 opened.
6075 * Version 0.1.12 released, 0.1.13 opened.
6069
6076
6070 * Removed option to set auto-quote and auto-paren escapes by
6077 * Removed option to set auto-quote and auto-paren escapes by
6071 user. The chances of breaking valid syntax are just too high. If
6078 user. The chances of breaking valid syntax are just too high. If
6072 someone *really* wants, they can always dig into the code.
6079 someone *really* wants, they can always dig into the code.
6073
6080
6074 * Made prompt separators configurable.
6081 * Made prompt separators configurable.
6075
6082
6076 2001-11-22 Fernando Perez <fperez@colorado.edu>
6083 2001-11-22 Fernando Perez <fperez@colorado.edu>
6077
6084
6078 * Small bugfixes in many places.
6085 * Small bugfixes in many places.
6079
6086
6080 * Removed the MyCompleter class from ipplib. It seemed redundant
6087 * Removed the MyCompleter class from ipplib. It seemed redundant
6081 with the C-p,C-n history search functionality. Less code to
6088 with the C-p,C-n history search functionality. Less code to
6082 maintain.
6089 maintain.
6083
6090
6084 * Moved all the original ipython.py code into ipythonlib.py. Right
6091 * Moved all the original ipython.py code into ipythonlib.py. Right
6085 now it's just one big dump into a function called make_IPython, so
6092 now it's just one big dump into a function called make_IPython, so
6086 no real modularity has been gained. But at least it makes the
6093 no real modularity has been gained. But at least it makes the
6087 wrapper script tiny, and since ipythonlib is a module, it gets
6094 wrapper script tiny, and since ipythonlib is a module, it gets
6088 compiled and startup is much faster.
6095 compiled and startup is much faster.
6089
6096
6090 This is a reasobably 'deep' change, so we should test it for a
6097 This is a reasobably 'deep' change, so we should test it for a
6091 while without messing too much more with the code.
6098 while without messing too much more with the code.
6092
6099
6093 2001-11-21 Fernando Perez <fperez@colorado.edu>
6100 2001-11-21 Fernando Perez <fperez@colorado.edu>
6094
6101
6095 * Version 0.1.11 released, 0.1.12 opened for further work.
6102 * Version 0.1.11 released, 0.1.12 opened for further work.
6096
6103
6097 * Removed dependency on Itpl. It was only needed in one place. It
6104 * Removed dependency on Itpl. It was only needed in one place. It
6098 would be nice if this became part of python, though. It makes life
6105 would be nice if this became part of python, though. It makes life
6099 *a lot* easier in some cases.
6106 *a lot* easier in some cases.
6100
6107
6101 * Simplified the prefilter code a bit. Now all handlers are
6108 * Simplified the prefilter code a bit. Now all handlers are
6102 expected to explicitly return a value (at least a blank string).
6109 expected to explicitly return a value (at least a blank string).
6103
6110
6104 * Heavy edits in ipplib. Removed the help system altogether. Now
6111 * Heavy edits in ipplib. Removed the help system altogether. Now
6105 obj?/?? is used for inspecting objects, a magic @doc prints
6112 obj?/?? is used for inspecting objects, a magic @doc prints
6106 docstrings, and full-blown Python help is accessed via the 'help'
6113 docstrings, and full-blown Python help is accessed via the 'help'
6107 keyword. This cleans up a lot of code (less to maintain) and does
6114 keyword. This cleans up a lot of code (less to maintain) and does
6108 the job. Since 'help' is now a standard Python component, might as
6115 the job. Since 'help' is now a standard Python component, might as
6109 well use it and remove duplicate functionality.
6116 well use it and remove duplicate functionality.
6110
6117
6111 Also removed the option to use ipplib as a standalone program. By
6118 Also removed the option to use ipplib as a standalone program. By
6112 now it's too dependent on other parts of IPython to function alone.
6119 now it's too dependent on other parts of IPython to function alone.
6113
6120
6114 * Fixed bug in genutils.pager. It would crash if the pager was
6121 * Fixed bug in genutils.pager. It would crash if the pager was
6115 exited immediately after opening (broken pipe).
6122 exited immediately after opening (broken pipe).
6116
6123
6117 * Trimmed down the VerboseTB reporting a little. The header is
6124 * Trimmed down the VerboseTB reporting a little. The header is
6118 much shorter now and the repeated exception arguments at the end
6125 much shorter now and the repeated exception arguments at the end
6119 have been removed. For interactive use the old header seemed a bit
6126 have been removed. For interactive use the old header seemed a bit
6120 excessive.
6127 excessive.
6121
6128
6122 * Fixed small bug in output of @whos for variables with multi-word
6129 * Fixed small bug in output of @whos for variables with multi-word
6123 types (only first word was displayed).
6130 types (only first word was displayed).
6124
6131
6125 2001-11-17 Fernando Perez <fperez@colorado.edu>
6132 2001-11-17 Fernando Perez <fperez@colorado.edu>
6126
6133
6127 * Version 0.1.10 released, 0.1.11 opened for further work.
6134 * Version 0.1.10 released, 0.1.11 opened for further work.
6128
6135
6129 * Modified dirs and friends. dirs now *returns* the stack (not
6136 * Modified dirs and friends. dirs now *returns* the stack (not
6130 prints), so one can manipulate it as a variable. Convenient to
6137 prints), so one can manipulate it as a variable. Convenient to
6131 travel along many directories.
6138 travel along many directories.
6132
6139
6133 * Fixed bug in magic_pdef: would only work with functions with
6140 * Fixed bug in magic_pdef: would only work with functions with
6134 arguments with default values.
6141 arguments with default values.
6135
6142
6136 2001-11-14 Fernando Perez <fperez@colorado.edu>
6143 2001-11-14 Fernando Perez <fperez@colorado.edu>
6137
6144
6138 * Added the PhysicsInput stuff to dot_ipython so it ships as an
6145 * Added the PhysicsInput stuff to dot_ipython so it ships as an
6139 example with IPython. Various other minor fixes and cleanups.
6146 example with IPython. Various other minor fixes and cleanups.
6140
6147
6141 * Version 0.1.9 released, 0.1.10 opened for further work.
6148 * Version 0.1.9 released, 0.1.10 opened for further work.
6142
6149
6143 * Added sys.path to the list of directories searched in the
6150 * Added sys.path to the list of directories searched in the
6144 execfile= option. It used to be the current directory and the
6151 execfile= option. It used to be the current directory and the
6145 user's IPYTHONDIR only.
6152 user's IPYTHONDIR only.
6146
6153
6147 2001-11-13 Fernando Perez <fperez@colorado.edu>
6154 2001-11-13 Fernando Perez <fperez@colorado.edu>
6148
6155
6149 * Reinstated the raw_input/prefilter separation that Janko had
6156 * Reinstated the raw_input/prefilter separation that Janko had
6150 initially. This gives a more convenient setup for extending the
6157 initially. This gives a more convenient setup for extending the
6151 pre-processor from the outside: raw_input always gets a string,
6158 pre-processor from the outside: raw_input always gets a string,
6152 and prefilter has to process it. We can then redefine prefilter
6159 and prefilter has to process it. We can then redefine prefilter
6153 from the outside and implement extensions for special
6160 from the outside and implement extensions for special
6154 purposes.
6161 purposes.
6155
6162
6156 Today I got one for inputting PhysicalQuantity objects
6163 Today I got one for inputting PhysicalQuantity objects
6157 (from Scientific) without needing any function calls at
6164 (from Scientific) without needing any function calls at
6158 all. Extremely convenient, and it's all done as a user-level
6165 all. Extremely convenient, and it's all done as a user-level
6159 extension (no IPython code was touched). Now instead of:
6166 extension (no IPython code was touched). Now instead of:
6160 a = PhysicalQuantity(4.2,'m/s**2')
6167 a = PhysicalQuantity(4.2,'m/s**2')
6161 one can simply say
6168 one can simply say
6162 a = 4.2 m/s**2
6169 a = 4.2 m/s**2
6163 or even
6170 or even
6164 a = 4.2 m/s^2
6171 a = 4.2 m/s^2
6165
6172
6166 I use this, but it's also a proof of concept: IPython really is
6173 I use this, but it's also a proof of concept: IPython really is
6167 fully user-extensible, even at the level of the parsing of the
6174 fully user-extensible, even at the level of the parsing of the
6168 command line. It's not trivial, but it's perfectly doable.
6175 command line. It's not trivial, but it's perfectly doable.
6169
6176
6170 * Added 'add_flip' method to inclusion conflict resolver. Fixes
6177 * Added 'add_flip' method to inclusion conflict resolver. Fixes
6171 the problem of modules being loaded in the inverse order in which
6178 the problem of modules being loaded in the inverse order in which
6172 they were defined in
6179 they were defined in
6173
6180
6174 * Version 0.1.8 released, 0.1.9 opened for further work.
6181 * Version 0.1.8 released, 0.1.9 opened for further work.
6175
6182
6176 * Added magics pdef, source and file. They respectively show the
6183 * Added magics pdef, source and file. They respectively show the
6177 definition line ('prototype' in C), source code and full python
6184 definition line ('prototype' in C), source code and full python
6178 file for any callable object. The object inspector oinfo uses
6185 file for any callable object. The object inspector oinfo uses
6179 these to show the same information.
6186 these to show the same information.
6180
6187
6181 * Version 0.1.7 released, 0.1.8 opened for further work.
6188 * Version 0.1.7 released, 0.1.8 opened for further work.
6182
6189
6183 * Separated all the magic functions into a class called Magic. The
6190 * Separated all the magic functions into a class called Magic. The
6184 InteractiveShell class was becoming too big for Xemacs to handle
6191 InteractiveShell class was becoming too big for Xemacs to handle
6185 (de-indenting a line would lock it up for 10 seconds while it
6192 (de-indenting a line would lock it up for 10 seconds while it
6186 backtracked on the whole class!)
6193 backtracked on the whole class!)
6187
6194
6188 FIXME: didn't work. It can be done, but right now namespaces are
6195 FIXME: didn't work. It can be done, but right now namespaces are
6189 all messed up. Do it later (reverted it for now, so at least
6196 all messed up. Do it later (reverted it for now, so at least
6190 everything works as before).
6197 everything works as before).
6191
6198
6192 * Got the object introspection system (magic_oinfo) working! I
6199 * Got the object introspection system (magic_oinfo) working! I
6193 think this is pretty much ready for release to Janko, so he can
6200 think this is pretty much ready for release to Janko, so he can
6194 test it for a while and then announce it. Pretty much 100% of what
6201 test it for a while and then announce it. Pretty much 100% of what
6195 I wanted for the 'phase 1' release is ready. Happy, tired.
6202 I wanted for the 'phase 1' release is ready. Happy, tired.
6196
6203
6197 2001-11-12 Fernando Perez <fperez@colorado.edu>
6204 2001-11-12 Fernando Perez <fperez@colorado.edu>
6198
6205
6199 * Version 0.1.6 released, 0.1.7 opened for further work.
6206 * Version 0.1.6 released, 0.1.7 opened for further work.
6200
6207
6201 * Fixed bug in printing: it used to test for truth before
6208 * Fixed bug in printing: it used to test for truth before
6202 printing, so 0 wouldn't print. Now checks for None.
6209 printing, so 0 wouldn't print. Now checks for None.
6203
6210
6204 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
6211 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
6205 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
6212 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
6206 reaches by hand into the outputcache. Think of a better way to do
6213 reaches by hand into the outputcache. Think of a better way to do
6207 this later.
6214 this later.
6208
6215
6209 * Various small fixes thanks to Nathan's comments.
6216 * Various small fixes thanks to Nathan's comments.
6210
6217
6211 * Changed magic_pprint to magic_Pprint. This way it doesn't
6218 * Changed magic_pprint to magic_Pprint. This way it doesn't
6212 collide with pprint() and the name is consistent with the command
6219 collide with pprint() and the name is consistent with the command
6213 line option.
6220 line option.
6214
6221
6215 * Changed prompt counter behavior to be fully like
6222 * Changed prompt counter behavior to be fully like
6216 Mathematica's. That is, even input that doesn't return a result
6223 Mathematica's. That is, even input that doesn't return a result
6217 raises the prompt counter. The old behavior was kind of confusing
6224 raises the prompt counter. The old behavior was kind of confusing
6218 (getting the same prompt number several times if the operation
6225 (getting the same prompt number several times if the operation
6219 didn't return a result).
6226 didn't return a result).
6220
6227
6221 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
6228 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
6222
6229
6223 * Fixed -Classic mode (wasn't working anymore).
6230 * Fixed -Classic mode (wasn't working anymore).
6224
6231
6225 * Added colored prompts using Nathan's new code. Colors are
6232 * Added colored prompts using Nathan's new code. Colors are
6226 currently hardwired, they can be user-configurable. For
6233 currently hardwired, they can be user-configurable. For
6227 developers, they can be chosen in file ipythonlib.py, at the
6234 developers, they can be chosen in file ipythonlib.py, at the
6228 beginning of the CachedOutput class def.
6235 beginning of the CachedOutput class def.
6229
6236
6230 2001-11-11 Fernando Perez <fperez@colorado.edu>
6237 2001-11-11 Fernando Perez <fperez@colorado.edu>
6231
6238
6232 * Version 0.1.5 released, 0.1.6 opened for further work.
6239 * Version 0.1.5 released, 0.1.6 opened for further work.
6233
6240
6234 * Changed magic_env to *return* the environment as a dict (not to
6241 * Changed magic_env to *return* the environment as a dict (not to
6235 print it). This way it prints, but it can also be processed.
6242 print it). This way it prints, but it can also be processed.
6236
6243
6237 * Added Verbose exception reporting to interactive
6244 * Added Verbose exception reporting to interactive
6238 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
6245 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
6239 traceback. Had to make some changes to the ultraTB file. This is
6246 traceback. Had to make some changes to the ultraTB file. This is
6240 probably the last 'big' thing in my mental todo list. This ties
6247 probably the last 'big' thing in my mental todo list. This ties
6241 in with the next entry:
6248 in with the next entry:
6242
6249
6243 * Changed -Xi and -Xf to a single -xmode option. Now all the user
6250 * Changed -Xi and -Xf to a single -xmode option. Now all the user
6244 has to specify is Plain, Color or Verbose for all exception
6251 has to specify is Plain, Color or Verbose for all exception
6245 handling.
6252 handling.
6246
6253
6247 * Removed ShellServices option. All this can really be done via
6254 * Removed ShellServices option. All this can really be done via
6248 the magic system. It's easier to extend, cleaner and has automatic
6255 the magic system. It's easier to extend, cleaner and has automatic
6249 namespace protection and documentation.
6256 namespace protection and documentation.
6250
6257
6251 2001-11-09 Fernando Perez <fperez@colorado.edu>
6258 2001-11-09 Fernando Perez <fperez@colorado.edu>
6252
6259
6253 * Fixed bug in output cache flushing (missing parameter to
6260 * Fixed bug in output cache flushing (missing parameter to
6254 __init__). Other small bugs fixed (found using pychecker).
6261 __init__). Other small bugs fixed (found using pychecker).
6255
6262
6256 * Version 0.1.4 opened for bugfixing.
6263 * Version 0.1.4 opened for bugfixing.
6257
6264
6258 2001-11-07 Fernando Perez <fperez@colorado.edu>
6265 2001-11-07 Fernando Perez <fperez@colorado.edu>
6259
6266
6260 * Version 0.1.3 released, mainly because of the raw_input bug.
6267 * Version 0.1.3 released, mainly because of the raw_input bug.
6261
6268
6262 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
6269 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
6263 and when testing for whether things were callable, a call could
6270 and when testing for whether things were callable, a call could
6264 actually be made to certain functions. They would get called again
6271 actually be made to certain functions. They would get called again
6265 once 'really' executed, with a resulting double call. A disaster
6272 once 'really' executed, with a resulting double call. A disaster
6266 in many cases (list.reverse() would never work!).
6273 in many cases (list.reverse() would never work!).
6267
6274
6268 * Removed prefilter() function, moved its code to raw_input (which
6275 * Removed prefilter() function, moved its code to raw_input (which
6269 after all was just a near-empty caller for prefilter). This saves
6276 after all was just a near-empty caller for prefilter). This saves
6270 a function call on every prompt, and simplifies the class a tiny bit.
6277 a function call on every prompt, and simplifies the class a tiny bit.
6271
6278
6272 * Fix _ip to __ip name in magic example file.
6279 * Fix _ip to __ip name in magic example file.
6273
6280
6274 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
6281 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
6275 work with non-gnu versions of tar.
6282 work with non-gnu versions of tar.
6276
6283
6277 2001-11-06 Fernando Perez <fperez@colorado.edu>
6284 2001-11-06 Fernando Perez <fperez@colorado.edu>
6278
6285
6279 * Version 0.1.2. Just to keep track of the recent changes.
6286 * Version 0.1.2. Just to keep track of the recent changes.
6280
6287
6281 * Fixed nasty bug in output prompt routine. It used to check 'if
6288 * Fixed nasty bug in output prompt routine. It used to check 'if
6282 arg != None...'. Problem is, this fails if arg implements a
6289 arg != None...'. Problem is, this fails if arg implements a
6283 special comparison (__cmp__) which disallows comparing to
6290 special comparison (__cmp__) which disallows comparing to
6284 None. Found it when trying to use the PhysicalQuantity module from
6291 None. Found it when trying to use the PhysicalQuantity module from
6285 ScientificPython.
6292 ScientificPython.
6286
6293
6287 2001-11-05 Fernando Perez <fperez@colorado.edu>
6294 2001-11-05 Fernando Perez <fperez@colorado.edu>
6288
6295
6289 * Also added dirs. Now the pushd/popd/dirs family functions
6296 * Also added dirs. Now the pushd/popd/dirs family functions
6290 basically like the shell, with the added convenience of going home
6297 basically like the shell, with the added convenience of going home
6291 when called with no args.
6298 when called with no args.
6292
6299
6293 * pushd/popd slightly modified to mimic shell behavior more
6300 * pushd/popd slightly modified to mimic shell behavior more
6294 closely.
6301 closely.
6295
6302
6296 * Added env,pushd,popd from ShellServices as magic functions. I
6303 * Added env,pushd,popd from ShellServices as magic functions. I
6297 think the cleanest will be to port all desired functions from
6304 think the cleanest will be to port all desired functions from
6298 ShellServices as magics and remove ShellServices altogether. This
6305 ShellServices as magics and remove ShellServices altogether. This
6299 will provide a single, clean way of adding functionality
6306 will provide a single, clean way of adding functionality
6300 (shell-type or otherwise) to IP.
6307 (shell-type or otherwise) to IP.
6301
6308
6302 2001-11-04 Fernando Perez <fperez@colorado.edu>
6309 2001-11-04 Fernando Perez <fperez@colorado.edu>
6303
6310
6304 * Added .ipython/ directory to sys.path. This way users can keep
6311 * Added .ipython/ directory to sys.path. This way users can keep
6305 customizations there and access them via import.
6312 customizations there and access them via import.
6306
6313
6307 2001-11-03 Fernando Perez <fperez@colorado.edu>
6314 2001-11-03 Fernando Perez <fperez@colorado.edu>
6308
6315
6309 * Opened version 0.1.1 for new changes.
6316 * Opened version 0.1.1 for new changes.
6310
6317
6311 * Changed version number to 0.1.0: first 'public' release, sent to
6318 * Changed version number to 0.1.0: first 'public' release, sent to
6312 Nathan and Janko.
6319 Nathan and Janko.
6313
6320
6314 * Lots of small fixes and tweaks.
6321 * Lots of small fixes and tweaks.
6315
6322
6316 * Minor changes to whos format. Now strings are shown, snipped if
6323 * Minor changes to whos format. Now strings are shown, snipped if
6317 too long.
6324 too long.
6318
6325
6319 * Changed ShellServices to work on __main__ so they show up in @who
6326 * Changed ShellServices to work on __main__ so they show up in @who
6320
6327
6321 * Help also works with ? at the end of a line:
6328 * Help also works with ? at the end of a line:
6322 ?sin and sin?
6329 ?sin and sin?
6323 both produce the same effect. This is nice, as often I use the
6330 both produce the same effect. This is nice, as often I use the
6324 tab-complete to find the name of a method, but I used to then have
6331 tab-complete to find the name of a method, but I used to then have
6325 to go to the beginning of the line to put a ? if I wanted more
6332 to go to the beginning of the line to put a ? if I wanted more
6326 info. Now I can just add the ? and hit return. Convenient.
6333 info. Now I can just add the ? and hit return. Convenient.
6327
6334
6328 2001-11-02 Fernando Perez <fperez@colorado.edu>
6335 2001-11-02 Fernando Perez <fperez@colorado.edu>
6329
6336
6330 * Python version check (>=2.1) added.
6337 * Python version check (>=2.1) added.
6331
6338
6332 * Added LazyPython documentation. At this point the docs are quite
6339 * Added LazyPython documentation. At this point the docs are quite
6333 a mess. A cleanup is in order.
6340 a mess. A cleanup is in order.
6334
6341
6335 * Auto-installer created. For some bizarre reason, the zipfiles
6342 * Auto-installer created. For some bizarre reason, the zipfiles
6336 module isn't working on my system. So I made a tar version
6343 module isn't working on my system. So I made a tar version
6337 (hopefully the command line options in various systems won't kill
6344 (hopefully the command line options in various systems won't kill
6338 me).
6345 me).
6339
6346
6340 * Fixes to Struct in genutils. Now all dictionary-like methods are
6347 * Fixes to Struct in genutils. Now all dictionary-like methods are
6341 protected (reasonably).
6348 protected (reasonably).
6342
6349
6343 * Added pager function to genutils and changed ? to print usage
6350 * Added pager function to genutils and changed ? to print usage
6344 note through it (it was too long).
6351 note through it (it was too long).
6345
6352
6346 * Added the LazyPython functionality. Works great! I changed the
6353 * Added the LazyPython functionality. Works great! I changed the
6347 auto-quote escape to ';', it's on home row and next to '. But
6354 auto-quote escape to ';', it's on home row and next to '. But
6348 both auto-quote and auto-paren (still /) escapes are command-line
6355 both auto-quote and auto-paren (still /) escapes are command-line
6349 parameters.
6356 parameters.
6350
6357
6351
6358
6352 2001-11-01 Fernando Perez <fperez@colorado.edu>
6359 2001-11-01 Fernando Perez <fperez@colorado.edu>
6353
6360
6354 * Version changed to 0.0.7. Fairly large change: configuration now
6361 * Version changed to 0.0.7. Fairly large change: configuration now
6355 is all stored in a directory, by default .ipython. There, all
6362 is all stored in a directory, by default .ipython. There, all
6356 config files have normal looking names (not .names)
6363 config files have normal looking names (not .names)
6357
6364
6358 * Version 0.0.6 Released first to Lucas and Archie as a test
6365 * Version 0.0.6 Released first to Lucas and Archie as a test
6359 run. Since it's the first 'semi-public' release, change version to
6366 run. Since it's the first 'semi-public' release, change version to
6360 > 0.0.6 for any changes now.
6367 > 0.0.6 for any changes now.
6361
6368
6362 * Stuff I had put in the ipplib.py changelog:
6369 * Stuff I had put in the ipplib.py changelog:
6363
6370
6364 Changes to InteractiveShell:
6371 Changes to InteractiveShell:
6365
6372
6366 - Made the usage message a parameter.
6373 - Made the usage message a parameter.
6367
6374
6368 - Require the name of the shell variable to be given. It's a bit
6375 - Require the name of the shell variable to be given. It's a bit
6369 of a hack, but allows the name 'shell' not to be hardwired in the
6376 of a hack, but allows the name 'shell' not to be hardwired in the
6370 magic (@) handler, which is problematic b/c it requires
6377 magic (@) handler, which is problematic b/c it requires
6371 polluting the global namespace with 'shell'. This in turn is
6378 polluting the global namespace with 'shell'. This in turn is
6372 fragile: if a user redefines a variable called shell, things
6379 fragile: if a user redefines a variable called shell, things
6373 break.
6380 break.
6374
6381
6375 - magic @: all functions available through @ need to be defined
6382 - magic @: all functions available through @ need to be defined
6376 as magic_<name>, even though they can be called simply as
6383 as magic_<name>, even though they can be called simply as
6377 @<name>. This allows the special command @magic to gather
6384 @<name>. This allows the special command @magic to gather
6378 information automatically about all existing magic functions,
6385 information automatically about all existing magic functions,
6379 even if they are run-time user extensions, by parsing the shell
6386 even if they are run-time user extensions, by parsing the shell
6380 instance __dict__ looking for special magic_ names.
6387 instance __dict__ looking for special magic_ names.
6381
6388
6382 - mainloop: added *two* local namespace parameters. This allows
6389 - mainloop: added *two* local namespace parameters. This allows
6383 the class to differentiate between parameters which were there
6390 the class to differentiate between parameters which were there
6384 before and after command line initialization was processed. This
6391 before and after command line initialization was processed. This
6385 way, later @who can show things loaded at startup by the
6392 way, later @who can show things loaded at startup by the
6386 user. This trick was necessary to make session saving/reloading
6393 user. This trick was necessary to make session saving/reloading
6387 really work: ideally after saving/exiting/reloading a session,
6394 really work: ideally after saving/exiting/reloading a session,
6388 *everything* should look the same, including the output of @who. I
6395 *everything* should look the same, including the output of @who. I
6389 was only able to make this work with this double namespace
6396 was only able to make this work with this double namespace
6390 trick.
6397 trick.
6391
6398
6392 - added a header to the logfile which allows (almost) full
6399 - added a header to the logfile which allows (almost) full
6393 session restoring.
6400 session restoring.
6394
6401
6395 - prepend lines beginning with @ or !, with a and log
6402 - prepend lines beginning with @ or !, with a and log
6396 them. Why? !lines: may be useful to know what you did @lines:
6403 them. Why? !lines: may be useful to know what you did @lines:
6397 they may affect session state. So when restoring a session, at
6404 they may affect session state. So when restoring a session, at
6398 least inform the user of their presence. I couldn't quite get
6405 least inform the user of their presence. I couldn't quite get
6399 them to properly re-execute, but at least the user is warned.
6406 them to properly re-execute, but at least the user is warned.
6400
6407
6401 * Started ChangeLog.
6408 * Started ChangeLog.
General Comments 0
You need to be logged in to leave comments. Login now