##// END OF EJS Templates
- Final commits for 0.8.0 tag....
jdh2358 -
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -1,3122 +1,3121 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 2221 2007-04-06 02:58:37Z fperez $"""
4 $Id: Magic.py 2225 2007-04-08 02:48:16Z jdh2358 $"""
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 #oname = oname.strip()
675 #print '1- oname: <%r>' % oname # dbg
675 #print '1- oname: <%r>' % oname # dbg
676 try:
676 try:
677 oname = oname.strip().encode('ascii')
677 oname = oname.strip().encode('ascii')
678 #print '2- oname: <%r>' % oname # dbg
678 #print '2- oname: <%r>' % oname # dbg
679 except UnicodeEncodeError:
679 except UnicodeEncodeError:
680 print 'Python identifiers can only contain ascii characters.'
680 print 'Python identifiers can only contain ascii characters.'
681 return 'not found'
681 return 'not found'
682
682
683 info = Struct(self._ofind(oname, namespaces))
683 info = Struct(self._ofind(oname, namespaces))
684
684
685 if info.found:
685 if info.found:
686 # Get the docstring of the class property if it exists.
686 # Get the docstring of the class property if it exists.
687 path = oname.split('.')
687 path = oname.split('.')
688 root = '.'.join(path[:-1])
688 root = '.'.join(path[:-1])
689 if info.parent is not None:
689 if info.parent is not None:
690 try:
690 try:
691 target = getattr(info.parent, '__class__')
691 target = getattr(info.parent, '__class__')
692 # The object belongs to a class instance.
692 # The object belongs to a class instance.
693 try:
693 try:
694 target = getattr(target, path[-1])
694 target = getattr(target, path[-1])
695 # The class defines the object.
695 # The class defines the object.
696 if isinstance(target, property):
696 if isinstance(target, property):
697 oname = root + '.__class__.' + path[-1]
697 oname = root + '.__class__.' + path[-1]
698 info = Struct(self._ofind(oname))
698 info = Struct(self._ofind(oname))
699 except AttributeError: pass
699 except AttributeError: pass
700 except AttributeError: pass
700 except AttributeError: pass
701
701
702 pmethod = getattr(self.shell.inspector,meth)
702 pmethod = getattr(self.shell.inspector,meth)
703 formatter = info.ismagic and self.format_screen or None
703 formatter = info.ismagic and self.format_screen or None
704 if meth == 'pdoc':
704 if meth == 'pdoc':
705 pmethod(info.obj,oname,formatter)
705 pmethod(info.obj,oname,formatter)
706 elif meth == 'pinfo':
706 elif meth == 'pinfo':
707 pmethod(info.obj,oname,formatter,info,**kw)
707 pmethod(info.obj,oname,formatter,info,**kw)
708 else:
708 else:
709 pmethod(info.obj,oname)
709 pmethod(info.obj,oname)
710 else:
710 else:
711 print 'Object `%s` not found.' % oname
711 print 'Object `%s` not found.' % oname
712 return 'not found' # so callers can take other action
712 return 'not found' # so callers can take other action
713
713
714 def magic_pdef(self, parameter_s='', namespaces=None):
714 def magic_pdef(self, parameter_s='', namespaces=None):
715 """Print the definition header for any callable object.
715 """Print the definition header for any callable object.
716
716
717 If the object is a class, print the constructor information."""
717 If the object is a class, print the constructor information."""
718 self._inspect('pdef',parameter_s, namespaces)
718 self._inspect('pdef',parameter_s, namespaces)
719
719
720 def magic_pdoc(self, parameter_s='', namespaces=None):
720 def magic_pdoc(self, parameter_s='', namespaces=None):
721 """Print the docstring for an object.
721 """Print the docstring for an object.
722
722
723 If the given object is a class, it will print both the class and the
723 If the given object is a class, it will print both the class and the
724 constructor docstrings."""
724 constructor docstrings."""
725 self._inspect('pdoc',parameter_s, namespaces)
725 self._inspect('pdoc',parameter_s, namespaces)
726
726
727 def magic_psource(self, parameter_s='', namespaces=None):
727 def magic_psource(self, parameter_s='', namespaces=None):
728 """Print (or run through pager) the source code for an object."""
728 """Print (or run through pager) the source code for an object."""
729 self._inspect('psource',parameter_s, namespaces)
729 self._inspect('psource',parameter_s, namespaces)
730
730
731 def magic_pfile(self, parameter_s=''):
731 def magic_pfile(self, parameter_s=''):
732 """Print (or run through pager) the file where an object is defined.
732 """Print (or run through pager) the file where an object is defined.
733
733
734 The file opens at the line where the object definition begins. IPython
734 The file opens at the line where the object definition begins. IPython
735 will honor the environment variable PAGER if set, and otherwise will
735 will honor the environment variable PAGER if set, and otherwise will
736 do its best to print the file in a convenient form.
736 do its best to print the file in a convenient form.
737
737
738 If the given argument is not an object currently defined, IPython will
738 If the given argument is not an object currently defined, IPython will
739 try to interpret it as a filename (automatically adding a .py extension
739 try to interpret it as a filename (automatically adding a .py extension
740 if needed). You can thus use %pfile as a syntax highlighting code
740 if needed). You can thus use %pfile as a syntax highlighting code
741 viewer."""
741 viewer."""
742
742
743 # first interpret argument as an object name
743 # first interpret argument as an object name
744 out = self._inspect('pfile',parameter_s)
744 out = self._inspect('pfile',parameter_s)
745 # if not, try the input as a filename
745 # if not, try the input as a filename
746 if out == 'not found':
746 if out == 'not found':
747 try:
747 try:
748 filename = get_py_filename(parameter_s)
748 filename = get_py_filename(parameter_s)
749 except IOError,msg:
749 except IOError,msg:
750 print msg
750 print msg
751 return
751 return
752 page(self.shell.inspector.format(file(filename).read()))
752 page(self.shell.inspector.format(file(filename).read()))
753
753
754 def magic_pinfo(self, parameter_s='', namespaces=None):
754 def magic_pinfo(self, parameter_s='', namespaces=None):
755 """Provide detailed information about an object.
755 """Provide detailed information about an object.
756
756
757 '%pinfo object' is just a synonym for object? or ?object."""
757 '%pinfo object' is just a synonym for object? or ?object."""
758
758
759 #print 'pinfo par: <%s>' % parameter_s # dbg
759 #print 'pinfo par: <%s>' % parameter_s # dbg
760
760
761 # detail_level: 0 -> obj? , 1 -> obj??
761 # detail_level: 0 -> obj? , 1 -> obj??
762 detail_level = 0
762 detail_level = 0
763 # We need to detect if we got called as 'pinfo pinfo foo', which can
763 # We need to detect if we got called as 'pinfo pinfo foo', which can
764 # happen if the user types 'pinfo foo?' at the cmd line.
764 # happen if the user types 'pinfo foo?' at the cmd line.
765 pinfo,qmark1,oname,qmark2 = \
765 pinfo,qmark1,oname,qmark2 = \
766 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
766 re.match('(pinfo )?(\?*)(.*?)(\??$)',parameter_s).groups()
767 if pinfo or qmark1 or qmark2:
767 if pinfo or qmark1 or qmark2:
768 detail_level = 1
768 detail_level = 1
769 if "*" in oname:
769 if "*" in oname:
770 self.magic_psearch(oname)
770 self.magic_psearch(oname)
771 else:
771 else:
772 self._inspect('pinfo', oname, detail_level=detail_level,
772 self._inspect('pinfo', oname, detail_level=detail_level,
773 namespaces=namespaces)
773 namespaces=namespaces)
774
774
775 def magic_psearch(self, parameter_s=''):
775 def magic_psearch(self, parameter_s=''):
776 """Search for object in namespaces by wildcard.
776 """Search for object in namespaces by wildcard.
777
777
778 %psearch [options] PATTERN [OBJECT TYPE]
778 %psearch [options] PATTERN [OBJECT TYPE]
779
779
780 Note: ? can be used as a synonym for %psearch, at the beginning or at
780 Note: ? can be used as a synonym for %psearch, at the beginning or at
781 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
781 the end: both a*? and ?a* are equivalent to '%psearch a*'. Still, the
782 rest of the command line must be unchanged (options come first), so
782 rest of the command line must be unchanged (options come first), so
783 for example the following forms are equivalent
783 for example the following forms are equivalent
784
784
785 %psearch -i a* function
785 %psearch -i a* function
786 -i a* function?
786 -i a* function?
787 ?-i a* function
787 ?-i a* function
788
788
789 Arguments:
789 Arguments:
790
790
791 PATTERN
791 PATTERN
792
792
793 where PATTERN is a string containing * as a wildcard similar to its
793 where PATTERN is a string containing * as a wildcard similar to its
794 use in a shell. The pattern is matched in all namespaces on the
794 use in a shell. The pattern is matched in all namespaces on the
795 search path. By default objects starting with a single _ are not
795 search path. By default objects starting with a single _ are not
796 matched, many IPython generated objects have a single
796 matched, many IPython generated objects have a single
797 underscore. The default is case insensitive matching. Matching is
797 underscore. The default is case insensitive matching. Matching is
798 also done on the attributes of objects and not only on the objects
798 also done on the attributes of objects and not only on the objects
799 in a module.
799 in a module.
800
800
801 [OBJECT TYPE]
801 [OBJECT TYPE]
802
802
803 Is the name of a python type from the types module. The name is
803 Is the name of a python type from the types module. The name is
804 given in lowercase without the ending type, ex. StringType is
804 given in lowercase without the ending type, ex. StringType is
805 written string. By adding a type here only objects matching the
805 written string. By adding a type here only objects matching the
806 given type are matched. Using all here makes the pattern match all
806 given type are matched. Using all here makes the pattern match all
807 types (this is the default).
807 types (this is the default).
808
808
809 Options:
809 Options:
810
810
811 -a: makes the pattern match even objects whose names start with a
811 -a: makes the pattern match even objects whose names start with a
812 single underscore. These names are normally ommitted from the
812 single underscore. These names are normally ommitted from the
813 search.
813 search.
814
814
815 -i/-c: make the pattern case insensitive/sensitive. If neither of
815 -i/-c: make the pattern case insensitive/sensitive. If neither of
816 these options is given, the default is read from your ipythonrc
816 these options is given, the default is read from your ipythonrc
817 file. The option name which sets this value is
817 file. The option name which sets this value is
818 'wildcards_case_sensitive'. If this option is not specified in your
818 'wildcards_case_sensitive'. If this option is not specified in your
819 ipythonrc file, IPython's internal default is to do a case sensitive
819 ipythonrc file, IPython's internal default is to do a case sensitive
820 search.
820 search.
821
821
822 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
822 -e/-s NAMESPACE: exclude/search a given namespace. The pattern you
823 specifiy can be searched in any of the following namespaces:
823 specifiy can be searched in any of the following namespaces:
824 'builtin', 'user', 'user_global','internal', 'alias', where
824 'builtin', 'user', 'user_global','internal', 'alias', where
825 'builtin' and 'user' are the search defaults. Note that you should
825 'builtin' and 'user' are the search defaults. Note that you should
826 not use quotes when specifying namespaces.
826 not use quotes when specifying namespaces.
827
827
828 'Builtin' contains the python module builtin, 'user' contains all
828 'Builtin' contains the python module builtin, 'user' contains all
829 user data, 'alias' only contain the shell aliases and no python
829 user data, 'alias' only contain the shell aliases and no python
830 objects, 'internal' contains objects used by IPython. The
830 objects, 'internal' contains objects used by IPython. The
831 'user_global' namespace is only used by embedded IPython instances,
831 'user_global' namespace is only used by embedded IPython instances,
832 and it contains module-level globals. You can add namespaces to the
832 and it contains module-level globals. You can add namespaces to the
833 search with -s or exclude them with -e (these options can be given
833 search with -s or exclude them with -e (these options can be given
834 more than once).
834 more than once).
835
835
836 Examples:
836 Examples:
837
837
838 %psearch a* -> objects beginning with an a
838 %psearch a* -> objects beginning with an a
839 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
839 %psearch -e builtin a* -> objects NOT in the builtin space starting in a
840 %psearch a* function -> all functions beginning with an a
840 %psearch a* function -> all functions beginning with an a
841 %psearch re.e* -> objects beginning with an e in module re
841 %psearch re.e* -> objects beginning with an e in module re
842 %psearch r*.e* -> objects that start with e in modules starting in r
842 %psearch r*.e* -> objects that start with e in modules starting in r
843 %psearch r*.* string -> all strings in modules beginning with r
843 %psearch r*.* string -> all strings in modules beginning with r
844
844
845 Case sensitve search:
845 Case sensitve search:
846
846
847 %psearch -c a* list all object beginning with lower case a
847 %psearch -c a* list all object beginning with lower case a
848
848
849 Show objects beginning with a single _:
849 Show objects beginning with a single _:
850
850
851 %psearch -a _* list objects beginning with a single underscore"""
851 %psearch -a _* list objects beginning with a single underscore"""
852 try:
852 try:
853 parameter_s = parameter_s.encode('ascii')
853 parameter_s = parameter_s.encode('ascii')
854 except UnicodeEncodeError:
854 except UnicodeEncodeError:
855 print 'Python identifiers can only contain ascii characters.'
855 print 'Python identifiers can only contain ascii characters.'
856 return
856 return
857
857
858 # default namespaces to be searched
858 # default namespaces to be searched
859 def_search = ['user','builtin']
859 def_search = ['user','builtin']
860
860
861 # Process options/args
861 # Process options/args
862 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
862 opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True)
863 opt = opts.get
863 opt = opts.get
864 shell = self.shell
864 shell = self.shell
865 psearch = shell.inspector.psearch
865 psearch = shell.inspector.psearch
866
866
867 # select case options
867 # select case options
868 if opts.has_key('i'):
868 if opts.has_key('i'):
869 ignore_case = True
869 ignore_case = True
870 elif opts.has_key('c'):
870 elif opts.has_key('c'):
871 ignore_case = False
871 ignore_case = False
872 else:
872 else:
873 ignore_case = not shell.rc.wildcards_case_sensitive
873 ignore_case = not shell.rc.wildcards_case_sensitive
874
874
875 # Build list of namespaces to search from user options
875 # Build list of namespaces to search from user options
876 def_search.extend(opt('s',[]))
876 def_search.extend(opt('s',[]))
877 ns_exclude = ns_exclude=opt('e',[])
877 ns_exclude = ns_exclude=opt('e',[])
878 ns_search = [nm for nm in def_search if nm not in ns_exclude]
878 ns_search = [nm for nm in def_search if nm not in ns_exclude]
879
879
880 # Call the actual search
880 # Call the actual search
881 try:
881 try:
882 psearch(args,shell.ns_table,ns_search,
882 psearch(args,shell.ns_table,ns_search,
883 show_all=opt('a'),ignore_case=ignore_case)
883 show_all=opt('a'),ignore_case=ignore_case)
884 except:
884 except:
885 shell.showtraceback()
885 shell.showtraceback()
886
886
887 def magic_who_ls(self, parameter_s=''):
887 def magic_who_ls(self, parameter_s=''):
888 """Return a sorted list of all interactive variables.
888 """Return a sorted list of all interactive variables.
889
889
890 If arguments are given, only variables of types matching these
890 If arguments are given, only variables of types matching these
891 arguments are returned."""
891 arguments are returned."""
892
892
893 user_ns = self.shell.user_ns
893 user_ns = self.shell.user_ns
894 internal_ns = self.shell.internal_ns
894 internal_ns = self.shell.internal_ns
895 user_config_ns = self.shell.user_config_ns
895 user_config_ns = self.shell.user_config_ns
896 out = []
896 out = []
897 typelist = parameter_s.split()
897 typelist = parameter_s.split()
898
898
899 for i in user_ns:
899 for i in user_ns:
900 if not (i.startswith('_') or i.startswith('_i')) \
900 if not (i.startswith('_') or i.startswith('_i')) \
901 and not (i in internal_ns or i in user_config_ns):
901 and not (i in internal_ns or i in user_config_ns):
902 if typelist:
902 if typelist:
903 if type(user_ns[i]).__name__ in typelist:
903 if type(user_ns[i]).__name__ in typelist:
904 out.append(i)
904 out.append(i)
905 else:
905 else:
906 out.append(i)
906 out.append(i)
907 out.sort()
907 out.sort()
908 return out
908 return out
909
909
910 def magic_who(self, parameter_s=''):
910 def magic_who(self, parameter_s=''):
911 """Print all interactive variables, with some minimal formatting.
911 """Print all interactive variables, with some minimal formatting.
912
912
913 If any arguments are given, only variables whose type matches one of
913 If any arguments are given, only variables whose type matches one of
914 these are printed. For example:
914 these are printed. For example:
915
915
916 %who function str
916 %who function str
917
917
918 will only list functions and strings, excluding all other types of
918 will only list functions and strings, excluding all other types of
919 variables. To find the proper type names, simply use type(var) at a
919 variables. To find the proper type names, simply use type(var) at a
920 command line to see how python prints type names. For example:
920 command line to see how python prints type names. For example:
921
921
922 In [1]: type('hello')\\
922 In [1]: type('hello')\\
923 Out[1]: <type 'str'>
923 Out[1]: <type 'str'>
924
924
925 indicates that the type name for strings is 'str'.
925 indicates that the type name for strings is 'str'.
926
926
927 %who always excludes executed names loaded through your configuration
927 %who always excludes executed names loaded through your configuration
928 file and things which are internal to IPython.
928 file and things which are internal to IPython.
929
929
930 This is deliberate, as typically you may load many modules and the
930 This is deliberate, as typically you may load many modules and the
931 purpose of %who is to show you only what you've manually defined."""
931 purpose of %who is to show you only what you've manually defined."""
932
932
933 varlist = self.magic_who_ls(parameter_s)
933 varlist = self.magic_who_ls(parameter_s)
934 if not varlist:
934 if not varlist:
935 if parameter_s:
935 if parameter_s:
936 print 'No variables match your requested type.'
936 print 'No variables match your requested type.'
937 else:
937 else:
938 print 'Interactive namespace is empty.'
938 print 'Interactive namespace is empty.'
939 return
939 return
940
940
941 # if we have variables, move on...
941 # if we have variables, move on...
942 count = 0
942 count = 0
943 for i in varlist:
943 for i in varlist:
944 print i+'\t',
944 print i+'\t',
945 count += 1
945 count += 1
946 if count > 8:
946 if count > 8:
947 count = 0
947 count = 0
948 print
948 print
949 print
949 print
950
950
951 def magic_whos(self, parameter_s=''):
951 def magic_whos(self, parameter_s=''):
952 """Like %who, but gives some extra information about each variable.
952 """Like %who, but gives some extra information about each variable.
953
953
954 The same type filtering of %who can be applied here.
954 The same type filtering of %who can be applied here.
955
955
956 For all variables, the type is printed. Additionally it prints:
956 For all variables, the type is printed. Additionally it prints:
957
957
958 - For {},[],(): their length.
958 - For {},[],(): their length.
959
959
960 - For numpy and Numeric arrays, a summary with shape, number of
960 - For numpy and Numeric arrays, a summary with shape, number of
961 elements, typecode and size in memory.
961 elements, typecode and size in memory.
962
962
963 - Everything else: a string representation, snipping their middle if
963 - Everything else: a string representation, snipping their middle if
964 too long."""
964 too long."""
965
965
966 varnames = self.magic_who_ls(parameter_s)
966 varnames = self.magic_who_ls(parameter_s)
967 if not varnames:
967 if not varnames:
968 if parameter_s:
968 if parameter_s:
969 print 'No variables match your requested type.'
969 print 'No variables match your requested type.'
970 else:
970 else:
971 print 'Interactive namespace is empty.'
971 print 'Interactive namespace is empty.'
972 return
972 return
973
973
974 # if we have variables, move on...
974 # if we have variables, move on...
975
975
976 # for these types, show len() instead of data:
976 # for these types, show len() instead of data:
977 seq_types = [types.DictType,types.ListType,types.TupleType]
977 seq_types = [types.DictType,types.ListType,types.TupleType]
978
978
979 # for numpy/Numeric arrays, display summary info
979 # for numpy/Numeric arrays, display summary info
980 try:
980 try:
981 import numpy
981 import numpy
982 except ImportError:
982 except ImportError:
983 ndarray_type = None
983 ndarray_type = None
984 else:
984 else:
985 ndarray_type = numpy.ndarray.__name__
985 ndarray_type = numpy.ndarray.__name__
986 try:
986 try:
987 import Numeric
987 import Numeric
988 except ImportError:
988 except ImportError:
989 array_type = None
989 array_type = None
990 else:
990 else:
991 array_type = Numeric.ArrayType.__name__
991 array_type = Numeric.ArrayType.__name__
992
992
993 # Find all variable names and types so we can figure out column sizes
993 # Find all variable names and types so we can figure out column sizes
994 def get_vars(i):
994 def get_vars(i):
995 return self.shell.user_ns[i]
995 return self.shell.user_ns[i]
996
996
997 # some types are well known and can be shorter
997 # some types are well known and can be shorter
998 abbrevs = {'IPython.macro.Macro' : 'Macro'}
998 abbrevs = {'IPython.macro.Macro' : 'Macro'}
999 def type_name(v):
999 def type_name(v):
1000 tn = type(v).__name__
1000 tn = type(v).__name__
1001 return abbrevs.get(tn,tn)
1001 return abbrevs.get(tn,tn)
1002
1002
1003 varlist = map(get_vars,varnames)
1003 varlist = map(get_vars,varnames)
1004
1004
1005 typelist = []
1005 typelist = []
1006 for vv in varlist:
1006 for vv in varlist:
1007 tt = type_name(vv)
1007 tt = type_name(vv)
1008
1008
1009 if tt=='instance':
1009 if tt=='instance':
1010 typelist.append( abbrevs.get(str(vv.__class__),
1010 typelist.append( abbrevs.get(str(vv.__class__),
1011 str(vv.__class__)))
1011 str(vv.__class__)))
1012 else:
1012 else:
1013 typelist.append(tt)
1013 typelist.append(tt)
1014
1014
1015 # column labels and # of spaces as separator
1015 # column labels and # of spaces as separator
1016 varlabel = 'Variable'
1016 varlabel = 'Variable'
1017 typelabel = 'Type'
1017 typelabel = 'Type'
1018 datalabel = 'Data/Info'
1018 datalabel = 'Data/Info'
1019 colsep = 3
1019 colsep = 3
1020 # variable format strings
1020 # variable format strings
1021 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
1021 vformat = "$vname.ljust(varwidth)$vtype.ljust(typewidth)"
1022 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
1022 vfmt_short = '$vstr[:25]<...>$vstr[-25:]'
1023 aformat = "%s: %s elems, type `%s`, %s bytes"
1023 aformat = "%s: %s elems, type `%s`, %s bytes"
1024 # find the size of the columns to format the output nicely
1024 # find the size of the columns to format the output nicely
1025 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
1025 varwidth = max(max(map(len,varnames)), len(varlabel)) + colsep
1026 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
1026 typewidth = max(max(map(len,typelist)), len(typelabel)) + colsep
1027 # table header
1027 # table header
1028 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
1028 print varlabel.ljust(varwidth) + typelabel.ljust(typewidth) + \
1029 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
1029 ' '+datalabel+'\n' + '-'*(varwidth+typewidth+len(datalabel)+1)
1030 # and the table itself
1030 # and the table itself
1031 kb = 1024
1031 kb = 1024
1032 Mb = 1048576 # kb**2
1032 Mb = 1048576 # kb**2
1033 for vname,var,vtype in zip(varnames,varlist,typelist):
1033 for vname,var,vtype in zip(varnames,varlist,typelist):
1034 print itpl(vformat),
1034 print itpl(vformat),
1035 if vtype in seq_types:
1035 if vtype in seq_types:
1036 print len(var)
1036 print len(var)
1037 elif vtype in [array_type,ndarray_type]:
1037 elif vtype in [array_type,ndarray_type]:
1038 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
1038 vshape = str(var.shape).replace(',','').replace(' ','x')[1:-1]
1039 if vtype==ndarray_type:
1039 if vtype==ndarray_type:
1040 # numpy
1040 # numpy
1041 vsize = var.size
1041 vsize = var.size
1042 vbytes = vsize*var.itemsize
1042 vbytes = vsize*var.itemsize
1043 vdtype = var.dtype
1043 vdtype = var.dtype
1044 else:
1044 else:
1045 # Numeric
1045 # Numeric
1046 vsize = Numeric.size(var)
1046 vsize = Numeric.size(var)
1047 vbytes = vsize*var.itemsize()
1047 vbytes = vsize*var.itemsize()
1048 vdtype = var.typecode()
1048 vdtype = var.typecode()
1049
1049
1050 if vbytes < 100000:
1050 if vbytes < 100000:
1051 print aformat % (vshape,vsize,vdtype,vbytes)
1051 print aformat % (vshape,vsize,vdtype,vbytes)
1052 else:
1052 else:
1053 print aformat % (vshape,vsize,vdtype,vbytes),
1053 print aformat % (vshape,vsize,vdtype,vbytes),
1054 if vbytes < Mb:
1054 if vbytes < Mb:
1055 print '(%s kb)' % (vbytes/kb,)
1055 print '(%s kb)' % (vbytes/kb,)
1056 else:
1056 else:
1057 print '(%s Mb)' % (vbytes/Mb,)
1057 print '(%s Mb)' % (vbytes/Mb,)
1058 else:
1058 else:
1059 vstr = str(var).replace('\n','\\n')
1059 vstr = str(var).replace('\n','\\n')
1060 if len(vstr) < 50:
1060 if len(vstr) < 50:
1061 print vstr
1061 print vstr
1062 else:
1062 else:
1063 printpl(vfmt_short)
1063 printpl(vfmt_short)
1064
1064
1065 def magic_reset(self, parameter_s=''):
1065 def magic_reset(self, parameter_s=''):
1066 """Resets the namespace by removing all names defined by the user.
1066 """Resets the namespace by removing all names defined by the user.
1067
1067
1068 Input/Output history are left around in case you need them."""
1068 Input/Output history are left around in case you need them."""
1069
1069
1070 ans = self.shell.ask_yes_no(
1070 ans = self.shell.ask_yes_no(
1071 "Once deleted, variables cannot be recovered. Proceed (y/[n])? ")
1071 "Once deleted, variables cannot be recovered. Proceed (y/[n])? ")
1072 if not ans:
1072 if not ans:
1073 print 'Nothing done.'
1073 print 'Nothing done.'
1074 return
1074 return
1075 user_ns = self.shell.user_ns
1075 user_ns = self.shell.user_ns
1076 for i in self.magic_who_ls():
1076 for i in self.magic_who_ls():
1077 del(user_ns[i])
1077 del(user_ns[i])
1078
1078
1079 def magic_logstart(self,parameter_s=''):
1079 def magic_logstart(self,parameter_s=''):
1080 """Start logging anywhere in a session.
1080 """Start logging anywhere in a session.
1081
1081
1082 %logstart [-o|-r|-t] [log_name [log_mode]]
1082 %logstart [-o|-r|-t] [log_name [log_mode]]
1083
1083
1084 If no name is given, it defaults to a file named 'ipython_log.py' in your
1084 If no name is given, it defaults to a file named 'ipython_log.py' in your
1085 current directory, in 'rotate' mode (see below).
1085 current directory, in 'rotate' mode (see below).
1086
1086
1087 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
1087 '%logstart name' saves to file 'name' in 'backup' mode. It saves your
1088 history up to that point and then continues logging.
1088 history up to that point and then continues logging.
1089
1089
1090 %logstart takes a second optional parameter: logging mode. This can be one
1090 %logstart takes a second optional parameter: logging mode. This can be one
1091 of (note that the modes are given unquoted):\\
1091 of (note that the modes are given unquoted):\\
1092 append: well, that says it.\\
1092 append: well, that says it.\\
1093 backup: rename (if exists) to name~ and start name.\\
1093 backup: rename (if exists) to name~ and start name.\\
1094 global: single logfile in your home dir, appended to.\\
1094 global: single logfile in your home dir, appended to.\\
1095 over : overwrite existing log.\\
1095 over : overwrite existing log.\\
1096 rotate: create rotating logs name.1~, name.2~, etc.
1096 rotate: create rotating logs name.1~, name.2~, etc.
1097
1097
1098 Options:
1098 Options:
1099
1099
1100 -o: log also IPython's output. In this mode, all commands which
1100 -o: log also IPython's output. In this mode, all commands which
1101 generate an Out[NN] prompt are recorded to the logfile, right after
1101 generate an Out[NN] prompt are recorded to the logfile, right after
1102 their corresponding input line. The output lines are always
1102 their corresponding input line. The output lines are always
1103 prepended with a '#[Out]# ' marker, so that the log remains valid
1103 prepended with a '#[Out]# ' marker, so that the log remains valid
1104 Python code.
1104 Python code.
1105
1105
1106 Since this marker is always the same, filtering only the output from
1106 Since this marker is always the same, filtering only the output from
1107 a log is very easy, using for example a simple awk call:
1107 a log is very easy, using for example a simple awk call:
1108
1108
1109 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
1109 awk -F'#\\[Out\\]# ' '{if($2) {print $2}}' ipython_log.py
1110
1110
1111 -r: log 'raw' input. Normally, IPython's logs contain the processed
1111 -r: log 'raw' input. Normally, IPython's logs contain the processed
1112 input, so that user lines are logged in their final form, converted
1112 input, so that user lines are logged in their final form, converted
1113 into valid Python. For example, %Exit is logged as
1113 into valid Python. For example, %Exit is logged as
1114 '_ip.magic("Exit"). If the -r flag is given, all input is logged
1114 '_ip.magic("Exit"). If the -r flag is given, all input is logged
1115 exactly as typed, with no transformations applied.
1115 exactly as typed, with no transformations applied.
1116
1116
1117 -t: put timestamps before each input line logged (these are put in
1117 -t: put timestamps before each input line logged (these are put in
1118 comments)."""
1118 comments)."""
1119
1119
1120 opts,par = self.parse_options(parameter_s,'ort')
1120 opts,par = self.parse_options(parameter_s,'ort')
1121 log_output = 'o' in opts
1121 log_output = 'o' in opts
1122 log_raw_input = 'r' in opts
1122 log_raw_input = 'r' in opts
1123 timestamp = 't' in opts
1123 timestamp = 't' in opts
1124
1124
1125 rc = self.shell.rc
1125 rc = self.shell.rc
1126 logger = self.shell.logger
1126 logger = self.shell.logger
1127
1127
1128 # if no args are given, the defaults set in the logger constructor by
1128 # if no args are given, the defaults set in the logger constructor by
1129 # ipytohn remain valid
1129 # ipytohn remain valid
1130 if par:
1130 if par:
1131 try:
1131 try:
1132 logfname,logmode = par.split()
1132 logfname,logmode = par.split()
1133 except:
1133 except:
1134 logfname = par
1134 logfname = par
1135 logmode = 'backup'
1135 logmode = 'backup'
1136 else:
1136 else:
1137 logfname = logger.logfname
1137 logfname = logger.logfname
1138 logmode = logger.logmode
1138 logmode = logger.logmode
1139 # put logfname into rc struct as if it had been called on the command
1139 # put logfname into rc struct as if it had been called on the command
1140 # line, so it ends up saved in the log header Save it in case we need
1140 # line, so it ends up saved in the log header Save it in case we need
1141 # to restore it...
1141 # to restore it...
1142 old_logfile = rc.opts.get('logfile','')
1142 old_logfile = rc.opts.get('logfile','')
1143 if logfname:
1143 if logfname:
1144 logfname = os.path.expanduser(logfname)
1144 logfname = os.path.expanduser(logfname)
1145 rc.opts.logfile = logfname
1145 rc.opts.logfile = logfname
1146 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
1146 loghead = self.shell.loghead_tpl % (rc.opts,rc.args)
1147 try:
1147 try:
1148 started = logger.logstart(logfname,loghead,logmode,
1148 started = logger.logstart(logfname,loghead,logmode,
1149 log_output,timestamp,log_raw_input)
1149 log_output,timestamp,log_raw_input)
1150 except:
1150 except:
1151 rc.opts.logfile = old_logfile
1151 rc.opts.logfile = old_logfile
1152 warn("Couldn't start log: %s" % sys.exc_info()[1])
1152 warn("Couldn't start log: %s" % sys.exc_info()[1])
1153 else:
1153 else:
1154 # log input history up to this point, optionally interleaving
1154 # log input history up to this point, optionally interleaving
1155 # output if requested
1155 # output if requested
1156
1156
1157 if timestamp:
1157 if timestamp:
1158 # disable timestamping for the previous history, since we've
1158 # disable timestamping for the previous history, since we've
1159 # lost those already (no time machine here).
1159 # lost those already (no time machine here).
1160 logger.timestamp = False
1160 logger.timestamp = False
1161
1161
1162 if log_raw_input:
1162 if log_raw_input:
1163 input_hist = self.shell.input_hist_raw
1163 input_hist = self.shell.input_hist_raw
1164 else:
1164 else:
1165 input_hist = self.shell.input_hist
1165 input_hist = self.shell.input_hist
1166
1166
1167 if log_output:
1167 if log_output:
1168 log_write = logger.log_write
1168 log_write = logger.log_write
1169 output_hist = self.shell.output_hist
1169 output_hist = self.shell.output_hist
1170 for n in range(1,len(input_hist)-1):
1170 for n in range(1,len(input_hist)-1):
1171 log_write(input_hist[n].rstrip())
1171 log_write(input_hist[n].rstrip())
1172 if n in output_hist:
1172 if n in output_hist:
1173 log_write(repr(output_hist[n]),'output')
1173 log_write(repr(output_hist[n]),'output')
1174 else:
1174 else:
1175 logger.log_write(input_hist[1:])
1175 logger.log_write(input_hist[1:])
1176 if timestamp:
1176 if timestamp:
1177 # re-enable timestamping
1177 # re-enable timestamping
1178 logger.timestamp = True
1178 logger.timestamp = True
1179
1179
1180 print ('Activating auto-logging. '
1180 print ('Activating auto-logging. '
1181 'Current session state plus future input saved.')
1181 'Current session state plus future input saved.')
1182 logger.logstate()
1182 logger.logstate()
1183
1183
1184 def magic_logoff(self,parameter_s=''):
1184 def magic_logoff(self,parameter_s=''):
1185 """Temporarily stop logging.
1185 """Temporarily stop logging.
1186
1186
1187 You must have previously started logging."""
1187 You must have previously started logging."""
1188 self.shell.logger.switch_log(0)
1188 self.shell.logger.switch_log(0)
1189
1189
1190 def magic_logon(self,parameter_s=''):
1190 def magic_logon(self,parameter_s=''):
1191 """Restart logging.
1191 """Restart logging.
1192
1192
1193 This function is for restarting logging which you've temporarily
1193 This function is for restarting logging which you've temporarily
1194 stopped with %logoff. For starting logging for the first time, you
1194 stopped with %logoff. For starting logging for the first time, you
1195 must use the %logstart function, which allows you to specify an
1195 must use the %logstart function, which allows you to specify an
1196 optional log filename."""
1196 optional log filename."""
1197
1197
1198 self.shell.logger.switch_log(1)
1198 self.shell.logger.switch_log(1)
1199
1199
1200 def magic_logstate(self,parameter_s=''):
1200 def magic_logstate(self,parameter_s=''):
1201 """Print the status of the logging system."""
1201 """Print the status of the logging system."""
1202
1202
1203 self.shell.logger.logstate()
1203 self.shell.logger.logstate()
1204
1204
1205 def magic_pdb(self, parameter_s=''):
1205 def magic_pdb(self, parameter_s=''):
1206 """Control the automatic calling of the pdb interactive debugger.
1206 """Control the automatic calling of the pdb interactive debugger.
1207
1207
1208 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1208 Call as '%pdb on', '%pdb 1', '%pdb off' or '%pdb 0'. If called without
1209 argument it works as a toggle.
1209 argument it works as a toggle.
1210
1210
1211 When an exception is triggered, IPython can optionally call the
1211 When an exception is triggered, IPython can optionally call the
1212 interactive pdb debugger after the traceback printout. %pdb toggles
1212 interactive pdb debugger after the traceback printout. %pdb toggles
1213 this feature on and off.
1213 this feature on and off.
1214
1214
1215 The initial state of this feature is set in your ipythonrc
1215 The initial state of this feature is set in your ipythonrc
1216 configuration file (the variable is called 'pdb').
1216 configuration file (the variable is called 'pdb').
1217
1217
1218 If you want to just activate the debugger AFTER an exception has fired,
1218 If you want to just activate the debugger AFTER an exception has fired,
1219 without having to type '%pdb on' and rerunning your code, you can use
1219 without having to type '%pdb on' and rerunning your code, you can use
1220 the %debug magic."""
1220 the %debug magic."""
1221
1221
1222 par = parameter_s.strip().lower()
1222 par = parameter_s.strip().lower()
1223
1223
1224 if par:
1224 if par:
1225 try:
1225 try:
1226 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1226 new_pdb = {'off':0,'0':0,'on':1,'1':1}[par]
1227 except KeyError:
1227 except KeyError:
1228 print ('Incorrect argument. Use on/1, off/0, '
1228 print ('Incorrect argument. Use on/1, off/0, '
1229 'or nothing for a toggle.')
1229 'or nothing for a toggle.')
1230 return
1230 return
1231 else:
1231 else:
1232 # toggle
1232 # toggle
1233 new_pdb = not self.shell.call_pdb
1233 new_pdb = not self.shell.call_pdb
1234
1234
1235 # set on the shell
1235 # set on the shell
1236 self.shell.call_pdb = new_pdb
1236 self.shell.call_pdb = new_pdb
1237 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1237 print 'Automatic pdb calling has been turned',on_off(new_pdb)
1238
1238
1239 def magic_debug(self, parameter_s=''):
1239 def magic_debug(self, parameter_s=''):
1240 """Activate the interactive debugger in post-mortem mode.
1240 """Activate the interactive debugger in post-mortem mode.
1241
1241
1242 If an exception has just occurred, this lets you inspect its stack
1242 If an exception has just occurred, this lets you inspect its stack
1243 frames interactively. Note that this will always work only on the last
1243 frames interactively. Note that this will always work only on the last
1244 traceback that occurred, so you must call this quickly after an
1244 traceback that occurred, so you must call this quickly after an
1245 exception that you wish to inspect has fired, because if another one
1245 exception that you wish to inspect has fired, because if another one
1246 occurs, it clobbers the previous one.
1246 occurs, it clobbers the previous one.
1247
1247
1248 If you want IPython to automatically do this on every exception, see
1248 If you want IPython to automatically do this on every exception, see
1249 the %pdb magic for more details.
1249 the %pdb magic for more details.
1250 """
1250 """
1251
1251
1252 self.shell.debugger(force=True)
1252 self.shell.debugger(force=True)
1253
1253
1254 def magic_prun(self, parameter_s ='',user_mode=1,
1254 def magic_prun(self, parameter_s ='',user_mode=1,
1255 opts=None,arg_lst=None,prog_ns=None):
1255 opts=None,arg_lst=None,prog_ns=None):
1256
1256
1257 """Run a statement through the python code profiler.
1257 """Run a statement through the python code profiler.
1258
1258
1259 Usage:\\
1259 Usage:\\
1260 %prun [options] statement
1260 %prun [options] statement
1261
1261
1262 The given statement (which doesn't require quote marks) is run via the
1262 The given statement (which doesn't require quote marks) is run via the
1263 python profiler in a manner similar to the profile.run() function.
1263 python profiler in a manner similar to the profile.run() function.
1264 Namespaces are internally managed to work correctly; profile.run
1264 Namespaces are internally managed to work correctly; profile.run
1265 cannot be used in IPython because it makes certain assumptions about
1265 cannot be used in IPython because it makes certain assumptions about
1266 namespaces which do not hold under IPython.
1266 namespaces which do not hold under IPython.
1267
1267
1268 Options:
1268 Options:
1269
1269
1270 -l <limit>: you can place restrictions on what or how much of the
1270 -l <limit>: you can place restrictions on what or how much of the
1271 profile gets printed. The limit value can be:
1271 profile gets printed. The limit value can be:
1272
1272
1273 * A string: only information for function names containing this string
1273 * A string: only information for function names containing this string
1274 is printed.
1274 is printed.
1275
1275
1276 * An integer: only these many lines are printed.
1276 * An integer: only these many lines are printed.
1277
1277
1278 * A float (between 0 and 1): this fraction of the report is printed
1278 * A float (between 0 and 1): this fraction of the report is printed
1279 (for example, use a limit of 0.4 to see the topmost 40% only).
1279 (for example, use a limit of 0.4 to see the topmost 40% only).
1280
1280
1281 You can combine several limits with repeated use of the option. For
1281 You can combine several limits with repeated use of the option. For
1282 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1282 example, '-l __init__ -l 5' will print only the topmost 5 lines of
1283 information about class constructors.
1283 information about class constructors.
1284
1284
1285 -r: return the pstats.Stats object generated by the profiling. This
1285 -r: return the pstats.Stats object generated by the profiling. This
1286 object has all the information about the profile in it, and you can
1286 object has all the information about the profile in it, and you can
1287 later use it for further analysis or in other functions.
1287 later use it for further analysis or in other functions.
1288
1288
1289 -s <key>: sort profile by given key. You can provide more than one key
1289 -s <key>: sort profile by given key. You can provide more than one key
1290 by using the option several times: '-s key1 -s key2 -s key3...'. The
1290 by using the option several times: '-s key1 -s key2 -s key3...'. The
1291 default sorting key is 'time'.
1291 default sorting key is 'time'.
1292
1292
1293 The following is copied verbatim from the profile documentation
1293 The following is copied verbatim from the profile documentation
1294 referenced below:
1294 referenced below:
1295
1295
1296 When more than one key is provided, additional keys are used as
1296 When more than one key is provided, additional keys are used as
1297 secondary criteria when the there is equality in all keys selected
1297 secondary criteria when the there is equality in all keys selected
1298 before them.
1298 before them.
1299
1299
1300 Abbreviations can be used for any key names, as long as the
1300 Abbreviations can be used for any key names, as long as the
1301 abbreviation is unambiguous. The following are the keys currently
1301 abbreviation is unambiguous. The following are the keys currently
1302 defined:
1302 defined:
1303
1303
1304 Valid Arg Meaning\\
1304 Valid Arg Meaning\\
1305 "calls" call count\\
1305 "calls" call count\\
1306 "cumulative" cumulative time\\
1306 "cumulative" cumulative time\\
1307 "file" file name\\
1307 "file" file name\\
1308 "module" file name\\
1308 "module" file name\\
1309 "pcalls" primitive call count\\
1309 "pcalls" primitive call count\\
1310 "line" line number\\
1310 "line" line number\\
1311 "name" function name\\
1311 "name" function name\\
1312 "nfl" name/file/line\\
1312 "nfl" name/file/line\\
1313 "stdname" standard name\\
1313 "stdname" standard name\\
1314 "time" internal time
1314 "time" internal time
1315
1315
1316 Note that all sorts on statistics are in descending order (placing
1316 Note that all sorts on statistics are in descending order (placing
1317 most time consuming items first), where as name, file, and line number
1317 most time consuming items first), where as name, file, and line number
1318 searches are in ascending order (i.e., alphabetical). The subtle
1318 searches are in ascending order (i.e., alphabetical). The subtle
1319 distinction between "nfl" and "stdname" is that the standard name is a
1319 distinction between "nfl" and "stdname" is that the standard name is a
1320 sort of the name as printed, which means that the embedded line
1320 sort of the name as printed, which means that the embedded line
1321 numbers get compared in an odd way. For example, lines 3, 20, and 40
1321 numbers get compared in an odd way. For example, lines 3, 20, and 40
1322 would (if the file names were the same) appear in the string order
1322 would (if the file names were the same) appear in the string order
1323 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1323 "20" "3" and "40". In contrast, "nfl" does a numeric compare of the
1324 line numbers. In fact, sort_stats("nfl") is the same as
1324 line numbers. In fact, sort_stats("nfl") is the same as
1325 sort_stats("name", "file", "line").
1325 sort_stats("name", "file", "line").
1326
1326
1327 -T <filename>: save profile results as shown on screen to a text
1327 -T <filename>: save profile results as shown on screen to a text
1328 file. The profile is still shown on screen.
1328 file. The profile is still shown on screen.
1329
1329
1330 -D <filename>: save (via dump_stats) profile statistics to given
1330 -D <filename>: save (via dump_stats) profile statistics to given
1331 filename. This data is in a format understod by the pstats module, and
1331 filename. This data is in a format understod by the pstats module, and
1332 is generated by a call to the dump_stats() method of profile
1332 is generated by a call to the dump_stats() method of profile
1333 objects. The profile is still shown on screen.
1333 objects. The profile is still shown on screen.
1334
1334
1335 If you want to run complete programs under the profiler's control, use
1335 If you want to run complete programs under the profiler's control, use
1336 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1336 '%run -p [prof_opts] filename.py [args to program]' where prof_opts
1337 contains profiler specific options as described here.
1337 contains profiler specific options as described here.
1338
1338
1339 You can read the complete documentation for the profile module with:\\
1339 You can read the complete documentation for the profile module with:\\
1340 In [1]: import profile; profile.help() """
1340 In [1]: import profile; profile.help() """
1341
1341
1342 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1342 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
1343 # protect user quote marks
1343 # protect user quote marks
1344 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1344 parameter_s = parameter_s.replace('"',r'\"').replace("'",r"\'")
1345
1345
1346 if user_mode: # regular user call
1346 if user_mode: # regular user call
1347 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1347 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:',
1348 list_all=1)
1348 list_all=1)
1349 namespace = self.shell.user_ns
1349 namespace = self.shell.user_ns
1350 else: # called to run a program by %run -p
1350 else: # called to run a program by %run -p
1351 try:
1351 try:
1352 filename = get_py_filename(arg_lst[0])
1352 filename = get_py_filename(arg_lst[0])
1353 except IOError,msg:
1353 except IOError,msg:
1354 error(msg)
1354 error(msg)
1355 return
1355 return
1356
1356
1357 arg_str = 'execfile(filename,prog_ns)'
1357 arg_str = 'execfile(filename,prog_ns)'
1358 namespace = locals()
1358 namespace = locals()
1359
1359
1360 opts.merge(opts_def)
1360 opts.merge(opts_def)
1361
1361
1362 prof = profile.Profile()
1362 prof = profile.Profile()
1363 try:
1363 try:
1364 prof = prof.runctx(arg_str,namespace,namespace)
1364 prof = prof.runctx(arg_str,namespace,namespace)
1365 sys_exit = ''
1365 sys_exit = ''
1366 except SystemExit:
1366 except SystemExit:
1367 sys_exit = """*** SystemExit exception caught in code being profiled."""
1367 sys_exit = """*** SystemExit exception caught in code being profiled."""
1368
1368
1369 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1369 stats = pstats.Stats(prof).strip_dirs().sort_stats(*opts.s)
1370
1370
1371 lims = opts.l
1371 lims = opts.l
1372 if lims:
1372 if lims:
1373 lims = [] # rebuild lims with ints/floats/strings
1373 lims = [] # rebuild lims with ints/floats/strings
1374 for lim in opts.l:
1374 for lim in opts.l:
1375 try:
1375 try:
1376 lims.append(int(lim))
1376 lims.append(int(lim))
1377 except ValueError:
1377 except ValueError:
1378 try:
1378 try:
1379 lims.append(float(lim))
1379 lims.append(float(lim))
1380 except ValueError:
1380 except ValueError:
1381 lims.append(lim)
1381 lims.append(lim)
1382
1382
1383 # Trap output.
1383 # Trap output.
1384 stdout_trap = StringIO()
1384 stdout_trap = StringIO()
1385
1385
1386 if hasattr(stats,'stream'):
1386 if hasattr(stats,'stream'):
1387 # In newer versions of python, the stats object has a 'stream'
1387 # In newer versions of python, the stats object has a 'stream'
1388 # attribute to write into.
1388 # attribute to write into.
1389 stats.stream = stdout_trap
1389 stats.stream = stdout_trap
1390 stats.print_stats(*lims)
1390 stats.print_stats(*lims)
1391 else:
1391 else:
1392 # For older versions, we manually redirect stdout during printing
1392 # For older versions, we manually redirect stdout during printing
1393 sys_stdout = sys.stdout
1393 sys_stdout = sys.stdout
1394 try:
1394 try:
1395 sys.stdout = stdout_trap
1395 sys.stdout = stdout_trap
1396 stats.print_stats(*lims)
1396 stats.print_stats(*lims)
1397 finally:
1397 finally:
1398 sys.stdout = sys_stdout
1398 sys.stdout = sys_stdout
1399
1399
1400 output = stdout_trap.getvalue()
1400 output = stdout_trap.getvalue()
1401 output = output.rstrip()
1401 output = output.rstrip()
1402
1402
1403 page(output,screen_lines=self.shell.rc.screen_length)
1403 page(output,screen_lines=self.shell.rc.screen_length)
1404 print sys_exit,
1404 print sys_exit,
1405
1405
1406 dump_file = opts.D[0]
1406 dump_file = opts.D[0]
1407 text_file = opts.T[0]
1407 text_file = opts.T[0]
1408 if dump_file:
1408 if dump_file:
1409 prof.dump_stats(dump_file)
1409 prof.dump_stats(dump_file)
1410 print '\n*** Profile stats marshalled to file',\
1410 print '\n*** Profile stats marshalled to file',\
1411 `dump_file`+'.',sys_exit
1411 `dump_file`+'.',sys_exit
1412 if text_file:
1412 if text_file:
1413 pfile = file(text_file,'w')
1413 pfile = file(text_file,'w')
1414 pfile.write(output)
1414 pfile.write(output)
1415 pfile.close()
1415 pfile.close()
1416 print '\n*** Profile printout saved to text file',\
1416 print '\n*** Profile printout saved to text file',\
1417 `text_file`+'.',sys_exit
1417 `text_file`+'.',sys_exit
1418
1418
1419 if opts.has_key('r'):
1419 if opts.has_key('r'):
1420 return stats
1420 return stats
1421 else:
1421 else:
1422 return None
1422 return None
1423
1423
1424 def magic_run(self, parameter_s ='',runner=None):
1424 def magic_run(self, parameter_s ='',runner=None):
1425 """Run the named file inside IPython as a program.
1425 """Run the named file inside IPython as a program.
1426
1426
1427 Usage:\\
1427 Usage:\\
1428 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1428 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options]] file [args]
1429
1429
1430 Parameters after the filename are passed as command-line arguments to
1430 Parameters after the filename are passed as command-line arguments to
1431 the program (put in sys.argv). Then, control returns to IPython's
1431 the program (put in sys.argv). Then, control returns to IPython's
1432 prompt.
1432 prompt.
1433
1433
1434 This is similar to running at a system prompt:\\
1434 This is similar to running at a system prompt:\\
1435 $ python file args\\
1435 $ python file args\\
1436 but with the advantage of giving you IPython's tracebacks, and of
1436 but with the advantage of giving you IPython's tracebacks, and of
1437 loading all variables into your interactive namespace for further use
1437 loading all variables into your interactive namespace for further use
1438 (unless -p is used, see below).
1438 (unless -p is used, see below).
1439
1439
1440 The file is executed in a namespace initially consisting only of
1440 The file is executed in a namespace initially consisting only of
1441 __name__=='__main__' and sys.argv constructed as indicated. It thus
1441 __name__=='__main__' and sys.argv constructed as indicated. It thus
1442 sees its environment as if it were being run as a stand-alone
1442 sees its environment as if it were being run as a stand-alone
1443 program. But after execution, the IPython interactive namespace gets
1443 program. But after execution, the IPython interactive namespace gets
1444 updated with all variables defined in the program (except for __name__
1444 updated with all variables defined in the program (except for __name__
1445 and sys.argv). This allows for very convenient loading of code for
1445 and sys.argv). This allows for very convenient loading of code for
1446 interactive work, while giving each program a 'clean sheet' to run in.
1446 interactive work, while giving each program a 'clean sheet' to run in.
1447
1447
1448 Options:
1448 Options:
1449
1449
1450 -n: __name__ is NOT set to '__main__', but to the running file's name
1450 -n: __name__ is NOT set to '__main__', but to the running file's name
1451 without extension (as python does under import). This allows running
1451 without extension (as python does under import). This allows running
1452 scripts and reloading the definitions in them without calling code
1452 scripts and reloading the definitions in them without calling code
1453 protected by an ' if __name__ == "__main__" ' clause.
1453 protected by an ' if __name__ == "__main__" ' clause.
1454
1454
1455 -i: run the file in IPython's namespace instead of an empty one. This
1455 -i: run the file in IPython's namespace instead of an empty one. This
1456 is useful if you are experimenting with code written in a text editor
1456 is useful if you are experimenting with code written in a text editor
1457 which depends on variables defined interactively.
1457 which depends on variables defined interactively.
1458
1458
1459 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1459 -e: ignore sys.exit() calls or SystemExit exceptions in the script
1460 being run. This is particularly useful if IPython is being used to
1460 being run. This is particularly useful if IPython is being used to
1461 run unittests, which always exit with a sys.exit() call. In such
1461 run unittests, which always exit with a sys.exit() call. In such
1462 cases you are interested in the output of the test results, not in
1462 cases you are interested in the output of the test results, not in
1463 seeing a traceback of the unittest module.
1463 seeing a traceback of the unittest module.
1464
1464
1465 -t: print timing information at the end of the run. IPython will give
1465 -t: print timing information at the end of the run. IPython will give
1466 you an estimated CPU time consumption for your script, which under
1466 you an estimated CPU time consumption for your script, which under
1467 Unix uses the resource module to avoid the wraparound problems of
1467 Unix uses the resource module to avoid the wraparound problems of
1468 time.clock(). Under Unix, an estimate of time spent on system tasks
1468 time.clock(). Under Unix, an estimate of time spent on system tasks
1469 is also given (for Windows platforms this is reported as 0.0).
1469 is also given (for Windows platforms this is reported as 0.0).
1470
1470
1471 If -t is given, an additional -N<N> option can be given, where <N>
1471 If -t is given, an additional -N<N> option can be given, where <N>
1472 must be an integer indicating how many times you want the script to
1472 must be an integer indicating how many times you want the script to
1473 run. The final timing report will include total and per run results.
1473 run. The final timing report will include total and per run results.
1474
1474
1475 For example (testing the script uniq_stable.py):
1475 For example (testing the script uniq_stable.py):
1476
1476
1477 In [1]: run -t uniq_stable
1477 In [1]: run -t uniq_stable
1478
1478
1479 IPython CPU timings (estimated):\\
1479 IPython CPU timings (estimated):\\
1480 User : 0.19597 s.\\
1480 User : 0.19597 s.\\
1481 System: 0.0 s.\\
1481 System: 0.0 s.\\
1482
1482
1483 In [2]: run -t -N5 uniq_stable
1483 In [2]: run -t -N5 uniq_stable
1484
1484
1485 IPython CPU timings (estimated):\\
1485 IPython CPU timings (estimated):\\
1486 Total runs performed: 5\\
1486 Total runs performed: 5\\
1487 Times : Total Per run\\
1487 Times : Total Per run\\
1488 User : 0.910862 s, 0.1821724 s.\\
1488 User : 0.910862 s, 0.1821724 s.\\
1489 System: 0.0 s, 0.0 s.
1489 System: 0.0 s, 0.0 s.
1490
1490
1491 -d: run your program under the control of pdb, the Python debugger.
1491 -d: run your program under the control of pdb, the Python debugger.
1492 This allows you to execute your program step by step, watch variables,
1492 This allows you to execute your program step by step, watch variables,
1493 etc. Internally, what IPython does is similar to calling:
1493 etc. Internally, what IPython does is similar to calling:
1494
1494
1495 pdb.run('execfile("YOURFILENAME")')
1495 pdb.run('execfile("YOURFILENAME")')
1496
1496
1497 with a breakpoint set on line 1 of your file. You can change the line
1497 with a breakpoint set on line 1 of your file. You can change the line
1498 number for this automatic breakpoint to be <N> by using the -bN option
1498 number for this automatic breakpoint to be <N> by using the -bN option
1499 (where N must be an integer). For example:
1499 (where N must be an integer). For example:
1500
1500
1501 %run -d -b40 myscript
1501 %run -d -b40 myscript
1502
1502
1503 will set the first breakpoint at line 40 in myscript.py. Note that
1503 will set the first breakpoint at line 40 in myscript.py. Note that
1504 the first breakpoint must be set on a line which actually does
1504 the first breakpoint must be set on a line which actually does
1505 something (not a comment or docstring) for it to stop execution.
1505 something (not a comment or docstring) for it to stop execution.
1506
1506
1507 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1507 When the pdb debugger starts, you will see a (Pdb) prompt. You must
1508 first enter 'c' (without qoutes) to start execution up to the first
1508 first enter 'c' (without qoutes) to start execution up to the first
1509 breakpoint.
1509 breakpoint.
1510
1510
1511 Entering 'help' gives information about the use of the debugger. You
1511 Entering 'help' gives information about the use of the debugger. You
1512 can easily see pdb's full documentation with "import pdb;pdb.help()"
1512 can easily see pdb's full documentation with "import pdb;pdb.help()"
1513 at a prompt.
1513 at a prompt.
1514
1514
1515 -p: run program under the control of the Python profiler module (which
1515 -p: run program under the control of the Python profiler module (which
1516 prints a detailed report of execution times, function calls, etc).
1516 prints a detailed report of execution times, function calls, etc).
1517
1517
1518 You can pass other options after -p which affect the behavior of the
1518 You can pass other options after -p which affect the behavior of the
1519 profiler itself. See the docs for %prun for details.
1519 profiler itself. See the docs for %prun for details.
1520
1520
1521 In this mode, the program's variables do NOT propagate back to the
1521 In this mode, the program's variables do NOT propagate back to the
1522 IPython interactive namespace (because they remain in the namespace
1522 IPython interactive namespace (because they remain in the namespace
1523 where the profiler executes them).
1523 where the profiler executes them).
1524
1524
1525 Internally this triggers a call to %prun, see its documentation for
1525 Internally this triggers a call to %prun, see its documentation for
1526 details on the options available specifically for profiling.
1526 details on the options available specifically for profiling.
1527
1527
1528 There is one special usage for which the text above doesn't apply:
1528 There is one special usage for which the text above doesn't apply:
1529 if the filename ends with .ipy, the file is run as ipython script,
1529 if the filename ends with .ipy, the file is run as ipython script,
1530 just as if the commands were written on IPython prompt.
1530 just as if the commands were written on IPython prompt.
1531 """
1531 """
1532
1532
1533 # get arguments and set sys.argv for program to be run.
1533 # get arguments and set sys.argv for program to be run.
1534 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1534 opts,arg_lst = self.parse_options(parameter_s,'nidtN:b:pD:l:rs:T:e',
1535 mode='list',list_all=1)
1535 mode='list',list_all=1)
1536
1536
1537 try:
1537 try:
1538 filename = get_py_filename(arg_lst[0])
1538 filename = get_py_filename(arg_lst[0])
1539 except IndexError:
1539 except IndexError:
1540 warn('you must provide at least a filename.')
1540 warn('you must provide at least a filename.')
1541 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1541 print '\n%run:\n',OInspect.getdoc(self.magic_run)
1542 return
1542 return
1543 except IOError,msg:
1543 except IOError,msg:
1544 error(msg)
1544 error(msg)
1545 return
1545 return
1546
1546
1547 if filename.lower().endswith('.ipy'):
1547 if filename.lower().endswith('.ipy'):
1548 self.api.runlines(open(filename).read())
1548 self.api.runlines(open(filename).read())
1549 return
1549 return
1550
1550
1551 # Control the response to exit() calls made by the script being run
1551 # Control the response to exit() calls made by the script being run
1552 exit_ignore = opts.has_key('e')
1552 exit_ignore = opts.has_key('e')
1553
1553
1554 # Make sure that the running script gets a proper sys.argv as if it
1554 # Make sure that the running script gets a proper sys.argv as if it
1555 # were run from a system shell.
1555 # were run from a system shell.
1556 save_argv = sys.argv # save it for later restoring
1556 save_argv = sys.argv # save it for later restoring
1557 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1557 sys.argv = [filename]+ arg_lst[1:] # put in the proper filename
1558
1558
1559 if opts.has_key('i'):
1559 if opts.has_key('i'):
1560 prog_ns = self.shell.user_ns
1560 prog_ns = self.shell.user_ns
1561 __name__save = self.shell.user_ns['__name__']
1561 __name__save = self.shell.user_ns['__name__']
1562 prog_ns['__name__'] = '__main__'
1562 prog_ns['__name__'] = '__main__'
1563 else:
1563 else:
1564 if opts.has_key('n'):
1564 if opts.has_key('n'):
1565 name = os.path.splitext(os.path.basename(filename))[0]
1565 name = os.path.splitext(os.path.basename(filename))[0]
1566 else:
1566 else:
1567 name = '__main__'
1567 name = '__main__'
1568 prog_ns = {'__name__':name}
1568 prog_ns = {'__name__':name}
1569
1569
1570 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
1570 # Since '%run foo' emulates 'python foo.py' at the cmd line, we must
1571 # set the __file__ global in the script's namespace
1571 # set the __file__ global in the script's namespace
1572 prog_ns['__file__'] = filename
1572 prog_ns['__file__'] = filename
1573
1573
1574 # pickle fix. See iplib for an explanation. But we need to make sure
1574 # pickle fix. See iplib for an explanation. But we need to make sure
1575 # that, if we overwrite __main__, we replace it at the end
1575 # that, if we overwrite __main__, we replace it at the end
1576 if prog_ns['__name__'] == '__main__':
1576 if prog_ns['__name__'] == '__main__':
1577 restore_main = sys.modules['__main__']
1577 restore_main = sys.modules['__main__']
1578 else:
1578 else:
1579 restore_main = False
1579 restore_main = False
1580
1580
1581 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1581 sys.modules[prog_ns['__name__']] = FakeModule(prog_ns)
1582
1582
1583 stats = None
1583 stats = None
1584 try:
1584 try:
1585 if self.shell.has_readline:
1585 if self.shell.has_readline:
1586 self.shell.savehist()
1586 self.shell.savehist()
1587
1587
1588 if opts.has_key('p'):
1588 if opts.has_key('p'):
1589 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1589 stats = self.magic_prun('',0,opts,arg_lst,prog_ns)
1590 else:
1590 else:
1591 if opts.has_key('d'):
1591 if opts.has_key('d'):
1592 deb = Debugger.Pdb(self.shell.rc.colors)
1592 deb = Debugger.Pdb(self.shell.rc.colors)
1593 # reset Breakpoint state, which is moronically kept
1593 # reset Breakpoint state, which is moronically kept
1594 # in a class
1594 # in a class
1595 bdb.Breakpoint.next = 1
1595 bdb.Breakpoint.next = 1
1596 bdb.Breakpoint.bplist = {}
1596 bdb.Breakpoint.bplist = {}
1597 bdb.Breakpoint.bpbynumber = [None]
1597 bdb.Breakpoint.bpbynumber = [None]
1598 # Set an initial breakpoint to stop execution
1598 # Set an initial breakpoint to stop execution
1599 maxtries = 10
1599 maxtries = 10
1600 bp = int(opts.get('b',[1])[0])
1600 bp = int(opts.get('b',[1])[0])
1601 checkline = deb.checkline(filename,bp)
1601 checkline = deb.checkline(filename,bp)
1602 if not checkline:
1602 if not checkline:
1603 for bp in range(bp+1,bp+maxtries+1):
1603 for bp in range(bp+1,bp+maxtries+1):
1604 if deb.checkline(filename,bp):
1604 if deb.checkline(filename,bp):
1605 break
1605 break
1606 else:
1606 else:
1607 msg = ("\nI failed to find a valid line to set "
1607 msg = ("\nI failed to find a valid line to set "
1608 "a breakpoint\n"
1608 "a breakpoint\n"
1609 "after trying up to line: %s.\n"
1609 "after trying up to line: %s.\n"
1610 "Please set a valid breakpoint manually "
1610 "Please set a valid breakpoint manually "
1611 "with the -b option." % bp)
1611 "with the -b option." % bp)
1612 error(msg)
1612 error(msg)
1613 return
1613 return
1614 # if we find a good linenumber, set the breakpoint
1614 # if we find a good linenumber, set the breakpoint
1615 deb.do_break('%s:%s' % (filename,bp))
1615 deb.do_break('%s:%s' % (filename,bp))
1616 # Start file run
1616 # Start file run
1617 print "NOTE: Enter 'c' at the",
1617 print "NOTE: Enter 'c' at the",
1618 print "%s prompt to start your script." % deb.prompt
1618 print "%s prompt to start your script." % deb.prompt
1619 try:
1619 try:
1620 deb.run('execfile("%s")' % filename,prog_ns)
1620 deb.run('execfile("%s")' % filename,prog_ns)
1621
1621
1622 except:
1622 except:
1623 etype, value, tb = sys.exc_info()
1623 etype, value, tb = sys.exc_info()
1624 # Skip three frames in the traceback: the %run one,
1624 # Skip three frames in the traceback: the %run one,
1625 # one inside bdb.py, and the command-line typed by the
1625 # one inside bdb.py, and the command-line typed by the
1626 # user (run by exec in pdb itself).
1626 # user (run by exec in pdb itself).
1627 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1627 self.shell.InteractiveTB(etype,value,tb,tb_offset=3)
1628 else:
1628 else:
1629 if runner is None:
1629 if runner is None:
1630 runner = self.shell.safe_execfile
1630 runner = self.shell.safe_execfile
1631 if opts.has_key('t'):
1631 if opts.has_key('t'):
1632 try:
1632 try:
1633 nruns = int(opts['N'][0])
1633 nruns = int(opts['N'][0])
1634 if nruns < 1:
1634 if nruns < 1:
1635 error('Number of runs must be >=1')
1635 error('Number of runs must be >=1')
1636 return
1636 return
1637 except (KeyError):
1637 except (KeyError):
1638 nruns = 1
1638 nruns = 1
1639 if nruns == 1:
1639 if nruns == 1:
1640 t0 = clock2()
1640 t0 = clock2()
1641 runner(filename,prog_ns,prog_ns,
1641 runner(filename,prog_ns,prog_ns,
1642 exit_ignore=exit_ignore)
1642 exit_ignore=exit_ignore)
1643 t1 = clock2()
1643 t1 = clock2()
1644 t_usr = t1[0]-t0[0]
1644 t_usr = t1[0]-t0[0]
1645 t_sys = t1[1]-t1[1]
1645 t_sys = t1[1]-t1[1]
1646 print "\nIPython CPU timings (estimated):"
1646 print "\nIPython CPU timings (estimated):"
1647 print " User : %10s s." % t_usr
1647 print " User : %10s s." % t_usr
1648 print " System: %10s s." % t_sys
1648 print " System: %10s s." % t_sys
1649 else:
1649 else:
1650 runs = range(nruns)
1650 runs = range(nruns)
1651 t0 = clock2()
1651 t0 = clock2()
1652 for nr in runs:
1652 for nr in runs:
1653 runner(filename,prog_ns,prog_ns,
1653 runner(filename,prog_ns,prog_ns,
1654 exit_ignore=exit_ignore)
1654 exit_ignore=exit_ignore)
1655 t1 = clock2()
1655 t1 = clock2()
1656 t_usr = t1[0]-t0[0]
1656 t_usr = t1[0]-t0[0]
1657 t_sys = t1[1]-t1[1]
1657 t_sys = t1[1]-t1[1]
1658 print "\nIPython CPU timings (estimated):"
1658 print "\nIPython CPU timings (estimated):"
1659 print "Total runs performed:",nruns
1659 print "Total runs performed:",nruns
1660 print " Times : %10s %10s" % ('Total','Per run')
1660 print " Times : %10s %10s" % ('Total','Per run')
1661 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1661 print " User : %10s s, %10s s." % (t_usr,t_usr/nruns)
1662 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1662 print " System: %10s s, %10s s." % (t_sys,t_sys/nruns)
1663
1663
1664 else:
1664 else:
1665 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1665 runner(filename,prog_ns,prog_ns,exit_ignore=exit_ignore)
1666 if opts.has_key('i'):
1666 if opts.has_key('i'):
1667 self.shell.user_ns['__name__'] = __name__save
1667 self.shell.user_ns['__name__'] = __name__save
1668 else:
1668 else:
1669 # update IPython interactive namespace
1669 # update IPython interactive namespace
1670 del prog_ns['__name__']
1670 del prog_ns['__name__']
1671 self.shell.user_ns.update(prog_ns)
1671 self.shell.user_ns.update(prog_ns)
1672 finally:
1672 finally:
1673 sys.argv = save_argv
1673 sys.argv = save_argv
1674 if restore_main:
1674 if restore_main:
1675 sys.modules['__main__'] = restore_main
1675 sys.modules['__main__'] = restore_main
1676 if self.shell.has_readline:
1676 self.shell.reloadhist()
1677 self.shell.readline.read_history_file(self.shell.histfile)
1678
1677
1679 return stats
1678 return stats
1680
1679
1681 def magic_runlog(self, parameter_s =''):
1680 def magic_runlog(self, parameter_s =''):
1682 """Run files as logs.
1681 """Run files as logs.
1683
1682
1684 Usage:\\
1683 Usage:\\
1685 %runlog file1 file2 ...
1684 %runlog file1 file2 ...
1686
1685
1687 Run the named files (treating them as log files) in sequence inside
1686 Run the named files (treating them as log files) in sequence inside
1688 the interpreter, and return to the prompt. This is much slower than
1687 the interpreter, and return to the prompt. This is much slower than
1689 %run because each line is executed in a try/except block, but it
1688 %run because each line is executed in a try/except block, but it
1690 allows running files with syntax errors in them.
1689 allows running files with syntax errors in them.
1691
1690
1692 Normally IPython will guess when a file is one of its own logfiles, so
1691 Normally IPython will guess when a file is one of its own logfiles, so
1693 you can typically use %run even for logs. This shorthand allows you to
1692 you can typically use %run even for logs. This shorthand allows you to
1694 force any file to be treated as a log file."""
1693 force any file to be treated as a log file."""
1695
1694
1696 for f in parameter_s.split():
1695 for f in parameter_s.split():
1697 self.shell.safe_execfile(f,self.shell.user_ns,
1696 self.shell.safe_execfile(f,self.shell.user_ns,
1698 self.shell.user_ns,islog=1)
1697 self.shell.user_ns,islog=1)
1699
1698
1700 def magic_timeit(self, parameter_s =''):
1699 def magic_timeit(self, parameter_s =''):
1701 """Time execution of a Python statement or expression
1700 """Time execution of a Python statement or expression
1702
1701
1703 Usage:\\
1702 Usage:\\
1704 %timeit [-n<N> -r<R> [-t|-c]] statement
1703 %timeit [-n<N> -r<R> [-t|-c]] statement
1705
1704
1706 Time execution of a Python statement or expression using the timeit
1705 Time execution of a Python statement or expression using the timeit
1707 module.
1706 module.
1708
1707
1709 Options:
1708 Options:
1710 -n<N>: execute the given statement <N> times in a loop. If this value
1709 -n<N>: execute the given statement <N> times in a loop. If this value
1711 is not given, a fitting value is chosen.
1710 is not given, a fitting value is chosen.
1712
1711
1713 -r<R>: repeat the loop iteration <R> times and take the best result.
1712 -r<R>: repeat the loop iteration <R> times and take the best result.
1714 Default: 3
1713 Default: 3
1715
1714
1716 -t: use time.time to measure the time, which is the default on Unix.
1715 -t: use time.time to measure the time, which is the default on Unix.
1717 This function measures wall time.
1716 This function measures wall time.
1718
1717
1719 -c: use time.clock to measure the time, which is the default on
1718 -c: use time.clock to measure the time, which is the default on
1720 Windows and measures wall time. On Unix, resource.getrusage is used
1719 Windows and measures wall time. On Unix, resource.getrusage is used
1721 instead and returns the CPU user time.
1720 instead and returns the CPU user time.
1722
1721
1723 -p<P>: use a precision of <P> digits to display the timing result.
1722 -p<P>: use a precision of <P> digits to display the timing result.
1724 Default: 3
1723 Default: 3
1725
1724
1726
1725
1727 Examples:\\
1726 Examples:\\
1728 In [1]: %timeit pass
1727 In [1]: %timeit pass
1729 10000000 loops, best of 3: 53.3 ns per loop
1728 10000000 loops, best of 3: 53.3 ns per loop
1730
1729
1731 In [2]: u = None
1730 In [2]: u = None
1732
1731
1733 In [3]: %timeit u is None
1732 In [3]: %timeit u is None
1734 10000000 loops, best of 3: 184 ns per loop
1733 10000000 loops, best of 3: 184 ns per loop
1735
1734
1736 In [4]: %timeit -r 4 u == None
1735 In [4]: %timeit -r 4 u == None
1737 1000000 loops, best of 4: 242 ns per loop
1736 1000000 loops, best of 4: 242 ns per loop
1738
1737
1739 In [5]: import time
1738 In [5]: import time
1740
1739
1741 In [6]: %timeit -n1 time.sleep(2)
1740 In [6]: %timeit -n1 time.sleep(2)
1742 1 loops, best of 3: 2 s per loop
1741 1 loops, best of 3: 2 s per loop
1743
1742
1744
1743
1745 The times reported by %timeit will be slightly higher than those
1744 The times reported by %timeit will be slightly higher than those
1746 reported by the timeit.py script when variables are accessed. This is
1745 reported by the timeit.py script when variables are accessed. This is
1747 due to the fact that %timeit executes the statement in the namespace
1746 due to the fact that %timeit executes the statement in the namespace
1748 of the shell, compared with timeit.py, which uses a single setup
1747 of the shell, compared with timeit.py, which uses a single setup
1749 statement to import function or create variables. Generally, the bias
1748 statement to import function or create variables. Generally, the bias
1750 does not matter as long as results from timeit.py are not mixed with
1749 does not matter as long as results from timeit.py are not mixed with
1751 those from %timeit."""
1750 those from %timeit."""
1752
1751
1753 import timeit
1752 import timeit
1754 import math
1753 import math
1755
1754
1756 units = ["s", "ms", "\xc2\xb5s", "ns"]
1755 units = ["s", "ms", "\xc2\xb5s", "ns"]
1757 scaling = [1, 1e3, 1e6, 1e9]
1756 scaling = [1, 1e3, 1e6, 1e9]
1758
1757
1759 opts, stmt = self.parse_options(parameter_s,'n:r:tcp:',
1758 opts, stmt = self.parse_options(parameter_s,'n:r:tcp:',
1760 posix=False)
1759 posix=False)
1761 if stmt == "":
1760 if stmt == "":
1762 return
1761 return
1763 timefunc = timeit.default_timer
1762 timefunc = timeit.default_timer
1764 number = int(getattr(opts, "n", 0))
1763 number = int(getattr(opts, "n", 0))
1765 repeat = int(getattr(opts, "r", timeit.default_repeat))
1764 repeat = int(getattr(opts, "r", timeit.default_repeat))
1766 precision = int(getattr(opts, "p", 3))
1765 precision = int(getattr(opts, "p", 3))
1767 if hasattr(opts, "t"):
1766 if hasattr(opts, "t"):
1768 timefunc = time.time
1767 timefunc = time.time
1769 if hasattr(opts, "c"):
1768 if hasattr(opts, "c"):
1770 timefunc = clock
1769 timefunc = clock
1771
1770
1772 timer = timeit.Timer(timer=timefunc)
1771 timer = timeit.Timer(timer=timefunc)
1773 # this code has tight coupling to the inner workings of timeit.Timer,
1772 # this code has tight coupling to the inner workings of timeit.Timer,
1774 # but is there a better way to achieve that the code stmt has access
1773 # but is there a better way to achieve that the code stmt has access
1775 # to the shell namespace?
1774 # to the shell namespace?
1776
1775
1777 src = timeit.template % {'stmt': timeit.reindent(stmt, 8),
1776 src = timeit.template % {'stmt': timeit.reindent(stmt, 8),
1778 'setup': "pass"}
1777 'setup': "pass"}
1779 code = compile(src, "<magic-timeit>", "exec")
1778 code = compile(src, "<magic-timeit>", "exec")
1780 ns = {}
1779 ns = {}
1781 exec code in self.shell.user_ns, ns
1780 exec code in self.shell.user_ns, ns
1782 timer.inner = ns["inner"]
1781 timer.inner = ns["inner"]
1783
1782
1784 if number == 0:
1783 if number == 0:
1785 # determine number so that 0.2 <= total time < 2.0
1784 # determine number so that 0.2 <= total time < 2.0
1786 number = 1
1785 number = 1
1787 for i in range(1, 10):
1786 for i in range(1, 10):
1788 number *= 10
1787 number *= 10
1789 if timer.timeit(number) >= 0.2:
1788 if timer.timeit(number) >= 0.2:
1790 break
1789 break
1791
1790
1792 best = min(timer.repeat(repeat, number)) / number
1791 best = min(timer.repeat(repeat, number)) / number
1793
1792
1794 if best > 0.0:
1793 if best > 0.0:
1795 order = min(-int(math.floor(math.log10(best)) // 3), 3)
1794 order = min(-int(math.floor(math.log10(best)) // 3), 3)
1796 else:
1795 else:
1797 order = 3
1796 order = 3
1798 print "%d loops, best of %d: %.*g %s per loop" % (number, repeat,
1797 print "%d loops, best of %d: %.*g %s per loop" % (number, repeat,
1799 precision,
1798 precision,
1800 best * scaling[order],
1799 best * scaling[order],
1801 units[order])
1800 units[order])
1802
1801
1803 def magic_time(self,parameter_s = ''):
1802 def magic_time(self,parameter_s = ''):
1804 """Time execution of a Python statement or expression.
1803 """Time execution of a Python statement or expression.
1805
1804
1806 The CPU and wall clock times are printed, and the value of the
1805 The CPU and wall clock times are printed, and the value of the
1807 expression (if any) is returned. Note that under Win32, system time
1806 expression (if any) is returned. Note that under Win32, system time
1808 is always reported as 0, since it can not be measured.
1807 is always reported as 0, since it can not be measured.
1809
1808
1810 This function provides very basic timing functionality. In Python
1809 This function provides very basic timing functionality. In Python
1811 2.3, the timeit module offers more control and sophistication, so this
1810 2.3, the timeit module offers more control and sophistication, so this
1812 could be rewritten to use it (patches welcome).
1811 could be rewritten to use it (patches welcome).
1813
1812
1814 Some examples:
1813 Some examples:
1815
1814
1816 In [1]: time 2**128
1815 In [1]: time 2**128
1817 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1816 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1818 Wall time: 0.00
1817 Wall time: 0.00
1819 Out[1]: 340282366920938463463374607431768211456L
1818 Out[1]: 340282366920938463463374607431768211456L
1820
1819
1821 In [2]: n = 1000000
1820 In [2]: n = 1000000
1822
1821
1823 In [3]: time sum(range(n))
1822 In [3]: time sum(range(n))
1824 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1823 CPU times: user 1.20 s, sys: 0.05 s, total: 1.25 s
1825 Wall time: 1.37
1824 Wall time: 1.37
1826 Out[3]: 499999500000L
1825 Out[3]: 499999500000L
1827
1826
1828 In [4]: time print 'hello world'
1827 In [4]: time print 'hello world'
1829 hello world
1828 hello world
1830 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1829 CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
1831 Wall time: 0.00
1830 Wall time: 0.00
1832 """
1831 """
1833
1832
1834 # fail immediately if the given expression can't be compiled
1833 # fail immediately if the given expression can't be compiled
1835 try:
1834 try:
1836 mode = 'eval'
1835 mode = 'eval'
1837 code = compile(parameter_s,'<timed eval>',mode)
1836 code = compile(parameter_s,'<timed eval>',mode)
1838 except SyntaxError:
1837 except SyntaxError:
1839 mode = 'exec'
1838 mode = 'exec'
1840 code = compile(parameter_s,'<timed exec>',mode)
1839 code = compile(parameter_s,'<timed exec>',mode)
1841 # skew measurement as little as possible
1840 # skew measurement as little as possible
1842 glob = self.shell.user_ns
1841 glob = self.shell.user_ns
1843 clk = clock2
1842 clk = clock2
1844 wtime = time.time
1843 wtime = time.time
1845 # time execution
1844 # time execution
1846 wall_st = wtime()
1845 wall_st = wtime()
1847 if mode=='eval':
1846 if mode=='eval':
1848 st = clk()
1847 st = clk()
1849 out = eval(code,glob)
1848 out = eval(code,glob)
1850 end = clk()
1849 end = clk()
1851 else:
1850 else:
1852 st = clk()
1851 st = clk()
1853 exec code in glob
1852 exec code in glob
1854 end = clk()
1853 end = clk()
1855 out = None
1854 out = None
1856 wall_end = wtime()
1855 wall_end = wtime()
1857 # Compute actual times and report
1856 # Compute actual times and report
1858 wall_time = wall_end-wall_st
1857 wall_time = wall_end-wall_st
1859 cpu_user = end[0]-st[0]
1858 cpu_user = end[0]-st[0]
1860 cpu_sys = end[1]-st[1]
1859 cpu_sys = end[1]-st[1]
1861 cpu_tot = cpu_user+cpu_sys
1860 cpu_tot = cpu_user+cpu_sys
1862 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1861 print "CPU times: user %.2f s, sys: %.2f s, total: %.2f s" % \
1863 (cpu_user,cpu_sys,cpu_tot)
1862 (cpu_user,cpu_sys,cpu_tot)
1864 print "Wall time: %.2f" % wall_time
1863 print "Wall time: %.2f" % wall_time
1865 return out
1864 return out
1866
1865
1867 def magic_macro(self,parameter_s = ''):
1866 def magic_macro(self,parameter_s = ''):
1868 """Define a set of input lines as a macro for future re-execution.
1867 """Define a set of input lines as a macro for future re-execution.
1869
1868
1870 Usage:\\
1869 Usage:\\
1871 %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...
1870 %macro [options] name n1-n2 n3-n4 ... n5 .. n6 ...
1872
1871
1873 Options:
1872 Options:
1874
1873
1875 -r: use 'raw' input. By default, the 'processed' history is used,
1874 -r: use 'raw' input. By default, the 'processed' history is used,
1876 so that magics are loaded in their transformed version to valid
1875 so that magics are loaded in their transformed version to valid
1877 Python. If this option is given, the raw input as typed as the
1876 Python. If this option is given, the raw input as typed as the
1878 command line is used instead.
1877 command line is used instead.
1879
1878
1880 This will define a global variable called `name` which is a string
1879 This will define a global variable called `name` which is a string
1881 made of joining the slices and lines you specify (n1,n2,... numbers
1880 made of joining the slices and lines you specify (n1,n2,... numbers
1882 above) from your input history into a single string. This variable
1881 above) from your input history into a single string. This variable
1883 acts like an automatic function which re-executes those lines as if
1882 acts like an automatic function which re-executes those lines as if
1884 you had typed them. You just type 'name' at the prompt and the code
1883 you had typed them. You just type 'name' at the prompt and the code
1885 executes.
1884 executes.
1886
1885
1887 The notation for indicating number ranges is: n1-n2 means 'use line
1886 The notation for indicating number ranges is: n1-n2 means 'use line
1888 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1887 numbers n1,...n2' (the endpoint is included). That is, '5-7' means
1889 using the lines numbered 5,6 and 7.
1888 using the lines numbered 5,6 and 7.
1890
1889
1891 Note: as a 'hidden' feature, you can also use traditional python slice
1890 Note: as a 'hidden' feature, you can also use traditional python slice
1892 notation, where N:M means numbers N through M-1.
1891 notation, where N:M means numbers N through M-1.
1893
1892
1894 For example, if your history contains (%hist prints it):
1893 For example, if your history contains (%hist prints it):
1895
1894
1896 44: x=1\\
1895 44: x=1\\
1897 45: y=3\\
1896 45: y=3\\
1898 46: z=x+y\\
1897 46: z=x+y\\
1899 47: print x\\
1898 47: print x\\
1900 48: a=5\\
1899 48: a=5\\
1901 49: print 'x',x,'y',y\\
1900 49: print 'x',x,'y',y\\
1902
1901
1903 you can create a macro with lines 44 through 47 (included) and line 49
1902 you can create a macro with lines 44 through 47 (included) and line 49
1904 called my_macro with:
1903 called my_macro with:
1905
1904
1906 In [51]: %macro my_macro 44-47 49
1905 In [51]: %macro my_macro 44-47 49
1907
1906
1908 Now, typing `my_macro` (without quotes) will re-execute all this code
1907 Now, typing `my_macro` (without quotes) will re-execute all this code
1909 in one pass.
1908 in one pass.
1910
1909
1911 You don't need to give the line-numbers in order, and any given line
1910 You don't need to give the line-numbers in order, and any given line
1912 number can appear multiple times. You can assemble macros with any
1911 number can appear multiple times. You can assemble macros with any
1913 lines from your input history in any order.
1912 lines from your input history in any order.
1914
1913
1915 The macro is a simple object which holds its value in an attribute,
1914 The macro is a simple object which holds its value in an attribute,
1916 but IPython's display system checks for macros and executes them as
1915 but IPython's display system checks for macros and executes them as
1917 code instead of printing them when you type their name.
1916 code instead of printing them when you type their name.
1918
1917
1919 You can view a macro's contents by explicitly printing it with:
1918 You can view a macro's contents by explicitly printing it with:
1920
1919
1921 'print macro_name'.
1920 'print macro_name'.
1922
1921
1923 For one-off cases which DON'T contain magic function calls in them you
1922 For one-off cases which DON'T contain magic function calls in them you
1924 can obtain similar results by explicitly executing slices from your
1923 can obtain similar results by explicitly executing slices from your
1925 input history with:
1924 input history with:
1926
1925
1927 In [60]: exec In[44:48]+In[49]"""
1926 In [60]: exec In[44:48]+In[49]"""
1928
1927
1929 opts,args = self.parse_options(parameter_s,'r',mode='list')
1928 opts,args = self.parse_options(parameter_s,'r',mode='list')
1930 name,ranges = args[0], args[1:]
1929 name,ranges = args[0], args[1:]
1931 #print 'rng',ranges # dbg
1930 #print 'rng',ranges # dbg
1932 lines = self.extract_input_slices(ranges,opts.has_key('r'))
1931 lines = self.extract_input_slices(ranges,opts.has_key('r'))
1933 macro = Macro(lines)
1932 macro = Macro(lines)
1934 self.shell.user_ns.update({name:macro})
1933 self.shell.user_ns.update({name:macro})
1935 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1934 print 'Macro `%s` created. To execute, type its name (without quotes).' % name
1936 print 'Macro contents:'
1935 print 'Macro contents:'
1937 print macro,
1936 print macro,
1938
1937
1939 def magic_save(self,parameter_s = ''):
1938 def magic_save(self,parameter_s = ''):
1940 """Save a set of lines to a given filename.
1939 """Save a set of lines to a given filename.
1941
1940
1942 Usage:\\
1941 Usage:\\
1943 %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...
1942 %save [options] filename n1-n2 n3-n4 ... n5 .. n6 ...
1944
1943
1945 Options:
1944 Options:
1946
1945
1947 -r: use 'raw' input. By default, the 'processed' history is used,
1946 -r: use 'raw' input. By default, the 'processed' history is used,
1948 so that magics are loaded in their transformed version to valid
1947 so that magics are loaded in their transformed version to valid
1949 Python. If this option is given, the raw input as typed as the
1948 Python. If this option is given, the raw input as typed as the
1950 command line is used instead.
1949 command line is used instead.
1951
1950
1952 This function uses the same syntax as %macro for line extraction, but
1951 This function uses the same syntax as %macro for line extraction, but
1953 instead of creating a macro it saves the resulting string to the
1952 instead of creating a macro it saves the resulting string to the
1954 filename you specify.
1953 filename you specify.
1955
1954
1956 It adds a '.py' extension to the file if you don't do so yourself, and
1955 It adds a '.py' extension to the file if you don't do so yourself, and
1957 it asks for confirmation before overwriting existing files."""
1956 it asks for confirmation before overwriting existing files."""
1958
1957
1959 opts,args = self.parse_options(parameter_s,'r',mode='list')
1958 opts,args = self.parse_options(parameter_s,'r',mode='list')
1960 fname,ranges = args[0], args[1:]
1959 fname,ranges = args[0], args[1:]
1961 if not fname.endswith('.py'):
1960 if not fname.endswith('.py'):
1962 fname += '.py'
1961 fname += '.py'
1963 if os.path.isfile(fname):
1962 if os.path.isfile(fname):
1964 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1963 ans = raw_input('File `%s` exists. Overwrite (y/[N])? ' % fname)
1965 if ans.lower() not in ['y','yes']:
1964 if ans.lower() not in ['y','yes']:
1966 print 'Operation cancelled.'
1965 print 'Operation cancelled.'
1967 return
1966 return
1968 cmds = ''.join(self.extract_input_slices(ranges,opts.has_key('r')))
1967 cmds = ''.join(self.extract_input_slices(ranges,opts.has_key('r')))
1969 f = file(fname,'w')
1968 f = file(fname,'w')
1970 f.write(cmds)
1969 f.write(cmds)
1971 f.close()
1970 f.close()
1972 print 'The following commands were written to file `%s`:' % fname
1971 print 'The following commands were written to file `%s`:' % fname
1973 print cmds
1972 print cmds
1974
1973
1975 def _edit_macro(self,mname,macro):
1974 def _edit_macro(self,mname,macro):
1976 """open an editor with the macro data in a file"""
1975 """open an editor with the macro data in a file"""
1977 filename = self.shell.mktempfile(macro.value)
1976 filename = self.shell.mktempfile(macro.value)
1978 self.shell.hooks.editor(filename)
1977 self.shell.hooks.editor(filename)
1979
1978
1980 # and make a new macro object, to replace the old one
1979 # and make a new macro object, to replace the old one
1981 mfile = open(filename)
1980 mfile = open(filename)
1982 mvalue = mfile.read()
1981 mvalue = mfile.read()
1983 mfile.close()
1982 mfile.close()
1984 self.shell.user_ns[mname] = Macro(mvalue)
1983 self.shell.user_ns[mname] = Macro(mvalue)
1985
1984
1986 def magic_ed(self,parameter_s=''):
1985 def magic_ed(self,parameter_s=''):
1987 """Alias to %edit."""
1986 """Alias to %edit."""
1988 return self.magic_edit(parameter_s)
1987 return self.magic_edit(parameter_s)
1989
1988
1990 def magic_edit(self,parameter_s='',last_call=['','']):
1989 def magic_edit(self,parameter_s='',last_call=['','']):
1991 """Bring up an editor and execute the resulting code.
1990 """Bring up an editor and execute the resulting code.
1992
1991
1993 Usage:
1992 Usage:
1994 %edit [options] [args]
1993 %edit [options] [args]
1995
1994
1996 %edit runs IPython's editor hook. The default version of this hook is
1995 %edit runs IPython's editor hook. The default version of this hook is
1997 set to call the __IPYTHON__.rc.editor command. This is read from your
1996 set to call the __IPYTHON__.rc.editor command. This is read from your
1998 environment variable $EDITOR. If this isn't found, it will default to
1997 environment variable $EDITOR. If this isn't found, it will default to
1999 vi under Linux/Unix and to notepad under Windows. See the end of this
1998 vi under Linux/Unix and to notepad under Windows. See the end of this
2000 docstring for how to change the editor hook.
1999 docstring for how to change the editor hook.
2001
2000
2002 You can also set the value of this editor via the command line option
2001 You can also set the value of this editor via the command line option
2003 '-editor' or in your ipythonrc file. This is useful if you wish to use
2002 '-editor' or in your ipythonrc file. This is useful if you wish to use
2004 specifically for IPython an editor different from your typical default
2003 specifically for IPython an editor different from your typical default
2005 (and for Windows users who typically don't set environment variables).
2004 (and for Windows users who typically don't set environment variables).
2006
2005
2007 This command allows you to conveniently edit multi-line code right in
2006 This command allows you to conveniently edit multi-line code right in
2008 your IPython session.
2007 your IPython session.
2009
2008
2010 If called without arguments, %edit opens up an empty editor with a
2009 If called without arguments, %edit opens up an empty editor with a
2011 temporary file and will execute the contents of this file when you
2010 temporary file and will execute the contents of this file when you
2012 close it (don't forget to save it!).
2011 close it (don't forget to save it!).
2013
2012
2014
2013
2015 Options:
2014 Options:
2016
2015
2017 -n <number>: open the editor at a specified line number. By default,
2016 -n <number>: open the editor at a specified line number. By default,
2018 the IPython editor hook uses the unix syntax 'editor +N filename', but
2017 the IPython editor hook uses the unix syntax 'editor +N filename', but
2019 you can configure this by providing your own modified hook if your
2018 you can configure this by providing your own modified hook if your
2020 favorite editor supports line-number specifications with a different
2019 favorite editor supports line-number specifications with a different
2021 syntax.
2020 syntax.
2022
2021
2023 -p: this will call the editor with the same data as the previous time
2022 -p: this will call the editor with the same data as the previous time
2024 it was used, regardless of how long ago (in your current session) it
2023 it was used, regardless of how long ago (in your current session) it
2025 was.
2024 was.
2026
2025
2027 -r: use 'raw' input. This option only applies to input taken from the
2026 -r: use 'raw' input. This option only applies to input taken from the
2028 user's history. By default, the 'processed' history is used, so that
2027 user's history. By default, the 'processed' history is used, so that
2029 magics are loaded in their transformed version to valid Python. If
2028 magics are loaded in their transformed version to valid Python. If
2030 this option is given, the raw input as typed as the command line is
2029 this option is given, the raw input as typed as the command line is
2031 used instead. When you exit the editor, it will be executed by
2030 used instead. When you exit the editor, it will be executed by
2032 IPython's own processor.
2031 IPython's own processor.
2033
2032
2034 -x: do not execute the edited code immediately upon exit. This is
2033 -x: do not execute the edited code immediately upon exit. This is
2035 mainly useful if you are editing programs which need to be called with
2034 mainly useful if you are editing programs which need to be called with
2036 command line arguments, which you can then do using %run.
2035 command line arguments, which you can then do using %run.
2037
2036
2038
2037
2039 Arguments:
2038 Arguments:
2040
2039
2041 If arguments are given, the following possibilites exist:
2040 If arguments are given, the following possibilites exist:
2042
2041
2043 - The arguments are numbers or pairs of colon-separated numbers (like
2042 - The arguments are numbers or pairs of colon-separated numbers (like
2044 1 4:8 9). These are interpreted as lines of previous input to be
2043 1 4:8 9). These are interpreted as lines of previous input to be
2045 loaded into the editor. The syntax is the same of the %macro command.
2044 loaded into the editor. The syntax is the same of the %macro command.
2046
2045
2047 - If the argument doesn't start with a number, it is evaluated as a
2046 - If the argument doesn't start with a number, it is evaluated as a
2048 variable and its contents loaded into the editor. You can thus edit
2047 variable and its contents loaded into the editor. You can thus edit
2049 any string which contains python code (including the result of
2048 any string which contains python code (including the result of
2050 previous edits).
2049 previous edits).
2051
2050
2052 - If the argument is the name of an object (other than a string),
2051 - If the argument is the name of an object (other than a string),
2053 IPython will try to locate the file where it was defined and open the
2052 IPython will try to locate the file where it was defined and open the
2054 editor at the point where it is defined. You can use `%edit function`
2053 editor at the point where it is defined. You can use `%edit function`
2055 to load an editor exactly at the point where 'function' is defined,
2054 to load an editor exactly at the point where 'function' is defined,
2056 edit it and have the file be executed automatically.
2055 edit it and have the file be executed automatically.
2057
2056
2058 If the object is a macro (see %macro for details), this opens up your
2057 If the object is a macro (see %macro for details), this opens up your
2059 specified editor with a temporary file containing the macro's data.
2058 specified editor with a temporary file containing the macro's data.
2060 Upon exit, the macro is reloaded with the contents of the file.
2059 Upon exit, the macro is reloaded with the contents of the file.
2061
2060
2062 Note: opening at an exact line is only supported under Unix, and some
2061 Note: opening at an exact line is only supported under Unix, and some
2063 editors (like kedit and gedit up to Gnome 2.8) do not understand the
2062 editors (like kedit and gedit up to Gnome 2.8) do not understand the
2064 '+NUMBER' parameter necessary for this feature. Good editors like
2063 '+NUMBER' parameter necessary for this feature. Good editors like
2065 (X)Emacs, vi, jed, pico and joe all do.
2064 (X)Emacs, vi, jed, pico and joe all do.
2066
2065
2067 - If the argument is not found as a variable, IPython will look for a
2066 - If the argument is not found as a variable, IPython will look for a
2068 file with that name (adding .py if necessary) and load it into the
2067 file with that name (adding .py if necessary) and load it into the
2069 editor. It will execute its contents with execfile() when you exit,
2068 editor. It will execute its contents with execfile() when you exit,
2070 loading any code in the file into your interactive namespace.
2069 loading any code in the file into your interactive namespace.
2071
2070
2072 After executing your code, %edit will return as output the code you
2071 After executing your code, %edit will return as output the code you
2073 typed in the editor (except when it was an existing file). This way
2072 typed in the editor (except when it was an existing file). This way
2074 you can reload the code in further invocations of %edit as a variable,
2073 you can reload the code in further invocations of %edit as a variable,
2075 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
2074 via _<NUMBER> or Out[<NUMBER>], where <NUMBER> is the prompt number of
2076 the output.
2075 the output.
2077
2076
2078 Note that %edit is also available through the alias %ed.
2077 Note that %edit is also available through the alias %ed.
2079
2078
2080 This is an example of creating a simple function inside the editor and
2079 This is an example of creating a simple function inside the editor and
2081 then modifying it. First, start up the editor:
2080 then modifying it. First, start up the editor:
2082
2081
2083 In [1]: ed\\
2082 In [1]: ed\\
2084 Editing... done. Executing edited code...\\
2083 Editing... done. Executing edited code...\\
2085 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
2084 Out[1]: 'def foo():\\n print "foo() was defined in an editing session"\\n'
2086
2085
2087 We can then call the function foo():
2086 We can then call the function foo():
2088
2087
2089 In [2]: foo()\\
2088 In [2]: foo()\\
2090 foo() was defined in an editing session
2089 foo() was defined in an editing session
2091
2090
2092 Now we edit foo. IPython automatically loads the editor with the
2091 Now we edit foo. IPython automatically loads the editor with the
2093 (temporary) file where foo() was previously defined:
2092 (temporary) file where foo() was previously defined:
2094
2093
2095 In [3]: ed foo\\
2094 In [3]: ed foo\\
2096 Editing... done. Executing edited code...
2095 Editing... done. Executing edited code...
2097
2096
2098 And if we call foo() again we get the modified version:
2097 And if we call foo() again we get the modified version:
2099
2098
2100 In [4]: foo()\\
2099 In [4]: foo()\\
2101 foo() has now been changed!
2100 foo() has now been changed!
2102
2101
2103 Here is an example of how to edit a code snippet successive
2102 Here is an example of how to edit a code snippet successive
2104 times. First we call the editor:
2103 times. First we call the editor:
2105
2104
2106 In [8]: ed\\
2105 In [8]: ed\\
2107 Editing... done. Executing edited code...\\
2106 Editing... done. Executing edited code...\\
2108 hello\\
2107 hello\\
2109 Out[8]: "print 'hello'\\n"
2108 Out[8]: "print 'hello'\\n"
2110
2109
2111 Now we call it again with the previous output (stored in _):
2110 Now we call it again with the previous output (stored in _):
2112
2111
2113 In [9]: ed _\\
2112 In [9]: ed _\\
2114 Editing... done. Executing edited code...\\
2113 Editing... done. Executing edited code...\\
2115 hello world\\
2114 hello world\\
2116 Out[9]: "print 'hello world'\\n"
2115 Out[9]: "print 'hello world'\\n"
2117
2116
2118 Now we call it with the output #8 (stored in _8, also as Out[8]):
2117 Now we call it with the output #8 (stored in _8, also as Out[8]):
2119
2118
2120 In [10]: ed _8\\
2119 In [10]: ed _8\\
2121 Editing... done. Executing edited code...\\
2120 Editing... done. Executing edited code...\\
2122 hello again\\
2121 hello again\\
2123 Out[10]: "print 'hello again'\\n"
2122 Out[10]: "print 'hello again'\\n"
2124
2123
2125
2124
2126 Changing the default editor hook:
2125 Changing the default editor hook:
2127
2126
2128 If you wish to write your own editor hook, you can put it in a
2127 If you wish to write your own editor hook, you can put it in a
2129 configuration file which you load at startup time. The default hook
2128 configuration file which you load at startup time. The default hook
2130 is defined in the IPython.hooks module, and you can use that as a
2129 is defined in the IPython.hooks module, and you can use that as a
2131 starting example for further modifications. That file also has
2130 starting example for further modifications. That file also has
2132 general instructions on how to set a new hook for use once you've
2131 general instructions on how to set a new hook for use once you've
2133 defined it."""
2132 defined it."""
2134
2133
2135 # FIXME: This function has become a convoluted mess. It needs a
2134 # FIXME: This function has become a convoluted mess. It needs a
2136 # ground-up rewrite with clean, simple logic.
2135 # ground-up rewrite with clean, simple logic.
2137
2136
2138 def make_filename(arg):
2137 def make_filename(arg):
2139 "Make a filename from the given args"
2138 "Make a filename from the given args"
2140 try:
2139 try:
2141 filename = get_py_filename(arg)
2140 filename = get_py_filename(arg)
2142 except IOError:
2141 except IOError:
2143 if args.endswith('.py'):
2142 if args.endswith('.py'):
2144 filename = arg
2143 filename = arg
2145 else:
2144 else:
2146 filename = None
2145 filename = None
2147 return filename
2146 return filename
2148
2147
2149 # custom exceptions
2148 # custom exceptions
2150 class DataIsObject(Exception): pass
2149 class DataIsObject(Exception): pass
2151
2150
2152 opts,args = self.parse_options(parameter_s,'prxn:')
2151 opts,args = self.parse_options(parameter_s,'prxn:')
2153 # Set a few locals from the options for convenience:
2152 # Set a few locals from the options for convenience:
2154 opts_p = opts.has_key('p')
2153 opts_p = opts.has_key('p')
2155 opts_r = opts.has_key('r')
2154 opts_r = opts.has_key('r')
2156
2155
2157 # Default line number value
2156 # Default line number value
2158 lineno = opts.get('n',None)
2157 lineno = opts.get('n',None)
2159
2158
2160 if opts_p:
2159 if opts_p:
2161 args = '_%s' % last_call[0]
2160 args = '_%s' % last_call[0]
2162 if not self.shell.user_ns.has_key(args):
2161 if not self.shell.user_ns.has_key(args):
2163 args = last_call[1]
2162 args = last_call[1]
2164
2163
2165 # use last_call to remember the state of the previous call, but don't
2164 # use last_call to remember the state of the previous call, but don't
2166 # let it be clobbered by successive '-p' calls.
2165 # let it be clobbered by successive '-p' calls.
2167 try:
2166 try:
2168 last_call[0] = self.shell.outputcache.prompt_count
2167 last_call[0] = self.shell.outputcache.prompt_count
2169 if not opts_p:
2168 if not opts_p:
2170 last_call[1] = parameter_s
2169 last_call[1] = parameter_s
2171 except:
2170 except:
2172 pass
2171 pass
2173
2172
2174 # by default this is done with temp files, except when the given
2173 # by default this is done with temp files, except when the given
2175 # arg is a filename
2174 # arg is a filename
2176 use_temp = 1
2175 use_temp = 1
2177
2176
2178 if re.match(r'\d',args):
2177 if re.match(r'\d',args):
2179 # Mode where user specifies ranges of lines, like in %macro.
2178 # Mode where user specifies ranges of lines, like in %macro.
2180 # This means that you can't edit files whose names begin with
2179 # This means that you can't edit files whose names begin with
2181 # numbers this way. Tough.
2180 # numbers this way. Tough.
2182 ranges = args.split()
2181 ranges = args.split()
2183 data = ''.join(self.extract_input_slices(ranges,opts_r))
2182 data = ''.join(self.extract_input_slices(ranges,opts_r))
2184 elif args.endswith('.py'):
2183 elif args.endswith('.py'):
2185 filename = make_filename(args)
2184 filename = make_filename(args)
2186 data = ''
2185 data = ''
2187 use_temp = 0
2186 use_temp = 0
2188 elif args:
2187 elif args:
2189 try:
2188 try:
2190 # Load the parameter given as a variable. If not a string,
2189 # Load the parameter given as a variable. If not a string,
2191 # process it as an object instead (below)
2190 # process it as an object instead (below)
2192
2191
2193 #print '*** args',args,'type',type(args) # dbg
2192 #print '*** args',args,'type',type(args) # dbg
2194 data = eval(args,self.shell.user_ns)
2193 data = eval(args,self.shell.user_ns)
2195 if not type(data) in StringTypes:
2194 if not type(data) in StringTypes:
2196 raise DataIsObject
2195 raise DataIsObject
2197
2196
2198 except (NameError,SyntaxError):
2197 except (NameError,SyntaxError):
2199 # given argument is not a variable, try as a filename
2198 # given argument is not a variable, try as a filename
2200 filename = make_filename(args)
2199 filename = make_filename(args)
2201 if filename is None:
2200 if filename is None:
2202 warn("Argument given (%s) can't be found as a variable "
2201 warn("Argument given (%s) can't be found as a variable "
2203 "or as a filename." % args)
2202 "or as a filename." % args)
2204 return
2203 return
2205
2204
2206 data = ''
2205 data = ''
2207 use_temp = 0
2206 use_temp = 0
2208 except DataIsObject:
2207 except DataIsObject:
2209
2208
2210 # macros have a special edit function
2209 # macros have a special edit function
2211 if isinstance(data,Macro):
2210 if isinstance(data,Macro):
2212 self._edit_macro(args,data)
2211 self._edit_macro(args,data)
2213 return
2212 return
2214
2213
2215 # For objects, try to edit the file where they are defined
2214 # For objects, try to edit the file where they are defined
2216 try:
2215 try:
2217 filename = inspect.getabsfile(data)
2216 filename = inspect.getabsfile(data)
2218 datafile = 1
2217 datafile = 1
2219 except TypeError:
2218 except TypeError:
2220 filename = make_filename(args)
2219 filename = make_filename(args)
2221 datafile = 1
2220 datafile = 1
2222 warn('Could not find file where `%s` is defined.\n'
2221 warn('Could not find file where `%s` is defined.\n'
2223 'Opening a file named `%s`' % (args,filename))
2222 'Opening a file named `%s`' % (args,filename))
2224 # Now, make sure we can actually read the source (if it was in
2223 # Now, make sure we can actually read the source (if it was in
2225 # a temp file it's gone by now).
2224 # a temp file it's gone by now).
2226 if datafile:
2225 if datafile:
2227 try:
2226 try:
2228 if lineno is None:
2227 if lineno is None:
2229 lineno = inspect.getsourcelines(data)[1]
2228 lineno = inspect.getsourcelines(data)[1]
2230 except IOError:
2229 except IOError:
2231 filename = make_filename(args)
2230 filename = make_filename(args)
2232 if filename is None:
2231 if filename is None:
2233 warn('The file `%s` where `%s` was defined cannot '
2232 warn('The file `%s` where `%s` was defined cannot '
2234 'be read.' % (filename,data))
2233 'be read.' % (filename,data))
2235 return
2234 return
2236 use_temp = 0
2235 use_temp = 0
2237 else:
2236 else:
2238 data = ''
2237 data = ''
2239
2238
2240 if use_temp:
2239 if use_temp:
2241 filename = self.shell.mktempfile(data)
2240 filename = self.shell.mktempfile(data)
2242 print 'IPython will make a temporary file named:',filename
2241 print 'IPython will make a temporary file named:',filename
2243
2242
2244 # do actual editing here
2243 # do actual editing here
2245 print 'Editing...',
2244 print 'Editing...',
2246 sys.stdout.flush()
2245 sys.stdout.flush()
2247 self.shell.hooks.editor(filename,lineno)
2246 self.shell.hooks.editor(filename,lineno)
2248 if opts.has_key('x'): # -x prevents actual execution
2247 if opts.has_key('x'): # -x prevents actual execution
2249 print
2248 print
2250 else:
2249 else:
2251 print 'done. Executing edited code...'
2250 print 'done. Executing edited code...'
2252 if opts_r:
2251 if opts_r:
2253 self.shell.runlines(file_read(filename))
2252 self.shell.runlines(file_read(filename))
2254 else:
2253 else:
2255 self.shell.safe_execfile(filename,self.shell.user_ns)
2254 self.shell.safe_execfile(filename,self.shell.user_ns)
2256 if use_temp:
2255 if use_temp:
2257 try:
2256 try:
2258 return open(filename).read()
2257 return open(filename).read()
2259 except IOError,msg:
2258 except IOError,msg:
2260 if msg.filename == filename:
2259 if msg.filename == filename:
2261 warn('File not found. Did you forget to save?')
2260 warn('File not found. Did you forget to save?')
2262 return
2261 return
2263 else:
2262 else:
2264 self.shell.showtraceback()
2263 self.shell.showtraceback()
2265
2264
2266 def magic_xmode(self,parameter_s = ''):
2265 def magic_xmode(self,parameter_s = ''):
2267 """Switch modes for the exception handlers.
2266 """Switch modes for the exception handlers.
2268
2267
2269 Valid modes: Plain, Context and Verbose.
2268 Valid modes: Plain, Context and Verbose.
2270
2269
2271 If called without arguments, acts as a toggle."""
2270 If called without arguments, acts as a toggle."""
2272
2271
2273 def xmode_switch_err(name):
2272 def xmode_switch_err(name):
2274 warn('Error changing %s exception modes.\n%s' %
2273 warn('Error changing %s exception modes.\n%s' %
2275 (name,sys.exc_info()[1]))
2274 (name,sys.exc_info()[1]))
2276
2275
2277 shell = self.shell
2276 shell = self.shell
2278 new_mode = parameter_s.strip().capitalize()
2277 new_mode = parameter_s.strip().capitalize()
2279 try:
2278 try:
2280 shell.InteractiveTB.set_mode(mode=new_mode)
2279 shell.InteractiveTB.set_mode(mode=new_mode)
2281 print 'Exception reporting mode:',shell.InteractiveTB.mode
2280 print 'Exception reporting mode:',shell.InteractiveTB.mode
2282 except:
2281 except:
2283 xmode_switch_err('user')
2282 xmode_switch_err('user')
2284
2283
2285 # threaded shells use a special handler in sys.excepthook
2284 # threaded shells use a special handler in sys.excepthook
2286 if shell.isthreaded:
2285 if shell.isthreaded:
2287 try:
2286 try:
2288 shell.sys_excepthook.set_mode(mode=new_mode)
2287 shell.sys_excepthook.set_mode(mode=new_mode)
2289 except:
2288 except:
2290 xmode_switch_err('threaded')
2289 xmode_switch_err('threaded')
2291
2290
2292 def magic_colors(self,parameter_s = ''):
2291 def magic_colors(self,parameter_s = ''):
2293 """Switch color scheme for prompts, info system and exception handlers.
2292 """Switch color scheme for prompts, info system and exception handlers.
2294
2293
2295 Currently implemented schemes: NoColor, Linux, LightBG.
2294 Currently implemented schemes: NoColor, Linux, LightBG.
2296
2295
2297 Color scheme names are not case-sensitive."""
2296 Color scheme names are not case-sensitive."""
2298
2297
2299 def color_switch_err(name):
2298 def color_switch_err(name):
2300 warn('Error changing %s color schemes.\n%s' %
2299 warn('Error changing %s color schemes.\n%s' %
2301 (name,sys.exc_info()[1]))
2300 (name,sys.exc_info()[1]))
2302
2301
2303
2302
2304 new_scheme = parameter_s.strip()
2303 new_scheme = parameter_s.strip()
2305 if not new_scheme:
2304 if not new_scheme:
2306 print 'You must specify a color scheme.'
2305 print 'You must specify a color scheme.'
2307 return
2306 return
2308 import IPython.rlineimpl as readline
2307 import IPython.rlineimpl as readline
2309 if not readline.have_readline:
2308 if not readline.have_readline:
2310 msg = """\
2309 msg = """\
2311 Proper color support under MS Windows requires the pyreadline library.
2310 Proper color support under MS Windows requires the pyreadline library.
2312 You can find it at:
2311 You can find it at:
2313 http://ipython.scipy.org/moin/PyReadline/Intro
2312 http://ipython.scipy.org/moin/PyReadline/Intro
2314 Gary's readline needs the ctypes module, from:
2313 Gary's readline needs the ctypes module, from:
2315 http://starship.python.net/crew/theller/ctypes
2314 http://starship.python.net/crew/theller/ctypes
2316 (Note that ctypes is already part of Python versions 2.5 and newer).
2315 (Note that ctypes is already part of Python versions 2.5 and newer).
2317
2316
2318 Defaulting color scheme to 'NoColor'"""
2317 Defaulting color scheme to 'NoColor'"""
2319 new_scheme = 'NoColor'
2318 new_scheme = 'NoColor'
2320 warn(msg)
2319 warn(msg)
2321 # local shortcut
2320 # local shortcut
2322 shell = self.shell
2321 shell = self.shell
2323
2322
2324 # Set prompt colors
2323 # Set prompt colors
2325 try:
2324 try:
2326 shell.outputcache.set_colors(new_scheme)
2325 shell.outputcache.set_colors(new_scheme)
2327 except:
2326 except:
2328 color_switch_err('prompt')
2327 color_switch_err('prompt')
2329 else:
2328 else:
2330 shell.rc.colors = \
2329 shell.rc.colors = \
2331 shell.outputcache.color_table.active_scheme_name
2330 shell.outputcache.color_table.active_scheme_name
2332 # Set exception colors
2331 # Set exception colors
2333 try:
2332 try:
2334 shell.InteractiveTB.set_colors(scheme = new_scheme)
2333 shell.InteractiveTB.set_colors(scheme = new_scheme)
2335 shell.SyntaxTB.set_colors(scheme = new_scheme)
2334 shell.SyntaxTB.set_colors(scheme = new_scheme)
2336 except:
2335 except:
2337 color_switch_err('exception')
2336 color_switch_err('exception')
2338
2337
2339 # threaded shells use a verbose traceback in sys.excepthook
2338 # threaded shells use a verbose traceback in sys.excepthook
2340 if shell.isthreaded:
2339 if shell.isthreaded:
2341 try:
2340 try:
2342 shell.sys_excepthook.set_colors(scheme=new_scheme)
2341 shell.sys_excepthook.set_colors(scheme=new_scheme)
2343 except:
2342 except:
2344 color_switch_err('system exception handler')
2343 color_switch_err('system exception handler')
2345
2344
2346 # Set info (for 'object?') colors
2345 # Set info (for 'object?') colors
2347 if shell.rc.color_info:
2346 if shell.rc.color_info:
2348 try:
2347 try:
2349 shell.inspector.set_active_scheme(new_scheme)
2348 shell.inspector.set_active_scheme(new_scheme)
2350 except:
2349 except:
2351 color_switch_err('object inspector')
2350 color_switch_err('object inspector')
2352 else:
2351 else:
2353 shell.inspector.set_active_scheme('NoColor')
2352 shell.inspector.set_active_scheme('NoColor')
2354
2353
2355 def magic_color_info(self,parameter_s = ''):
2354 def magic_color_info(self,parameter_s = ''):
2356 """Toggle color_info.
2355 """Toggle color_info.
2357
2356
2358 The color_info configuration parameter controls whether colors are
2357 The color_info configuration parameter controls whether colors are
2359 used for displaying object details (by things like %psource, %pfile or
2358 used for displaying object details (by things like %psource, %pfile or
2360 the '?' system). This function toggles this value with each call.
2359 the '?' system). This function toggles this value with each call.
2361
2360
2362 Note that unless you have a fairly recent pager (less works better
2361 Note that unless you have a fairly recent pager (less works better
2363 than more) in your system, using colored object information displays
2362 than more) in your system, using colored object information displays
2364 will not work properly. Test it and see."""
2363 will not work properly. Test it and see."""
2365
2364
2366 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2365 self.shell.rc.color_info = 1 - self.shell.rc.color_info
2367 self.magic_colors(self.shell.rc.colors)
2366 self.magic_colors(self.shell.rc.colors)
2368 print 'Object introspection functions have now coloring:',
2367 print 'Object introspection functions have now coloring:',
2369 print ['OFF','ON'][self.shell.rc.color_info]
2368 print ['OFF','ON'][self.shell.rc.color_info]
2370
2369
2371 def magic_Pprint(self, parameter_s=''):
2370 def magic_Pprint(self, parameter_s=''):
2372 """Toggle pretty printing on/off."""
2371 """Toggle pretty printing on/off."""
2373
2372
2374 self.shell.rc.pprint = 1 - self.shell.rc.pprint
2373 self.shell.rc.pprint = 1 - self.shell.rc.pprint
2375 print 'Pretty printing has been turned', \
2374 print 'Pretty printing has been turned', \
2376 ['OFF','ON'][self.shell.rc.pprint]
2375 ['OFF','ON'][self.shell.rc.pprint]
2377
2376
2378 def magic_exit(self, parameter_s=''):
2377 def magic_exit(self, parameter_s=''):
2379 """Exit IPython, confirming if configured to do so.
2378 """Exit IPython, confirming if configured to do so.
2380
2379
2381 You can configure whether IPython asks for confirmation upon exit by
2380 You can configure whether IPython asks for confirmation upon exit by
2382 setting the confirm_exit flag in the ipythonrc file."""
2381 setting the confirm_exit flag in the ipythonrc file."""
2383
2382
2384 self.shell.exit()
2383 self.shell.exit()
2385
2384
2386 def magic_quit(self, parameter_s=''):
2385 def magic_quit(self, parameter_s=''):
2387 """Exit IPython, confirming if configured to do so (like %exit)"""
2386 """Exit IPython, confirming if configured to do so (like %exit)"""
2388
2387
2389 self.shell.exit()
2388 self.shell.exit()
2390
2389
2391 def magic_Exit(self, parameter_s=''):
2390 def magic_Exit(self, parameter_s=''):
2392 """Exit IPython without confirmation."""
2391 """Exit IPython without confirmation."""
2393
2392
2394 self.shell.exit_now = True
2393 self.shell.exit_now = True
2395
2394
2396 def magic_Quit(self, parameter_s=''):
2395 def magic_Quit(self, parameter_s=''):
2397 """Exit IPython without confirmation (like %Exit)."""
2396 """Exit IPython without confirmation (like %Exit)."""
2398
2397
2399 self.shell.exit_now = True
2398 self.shell.exit_now = True
2400
2399
2401 #......................................................................
2400 #......................................................................
2402 # Functions to implement unix shell-type things
2401 # Functions to implement unix shell-type things
2403
2402
2404 def magic_alias(self, parameter_s = ''):
2403 def magic_alias(self, parameter_s = ''):
2405 """Define an alias for a system command.
2404 """Define an alias for a system command.
2406
2405
2407 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2406 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
2408
2407
2409 Then, typing 'alias_name params' will execute the system command 'cmd
2408 Then, typing 'alias_name params' will execute the system command 'cmd
2410 params' (from your underlying operating system).
2409 params' (from your underlying operating system).
2411
2410
2412 Aliases have lower precedence than magic functions and Python normal
2411 Aliases have lower precedence than magic functions and Python normal
2413 variables, so if 'foo' is both a Python variable and an alias, the
2412 variables, so if 'foo' is both a Python variable and an alias, the
2414 alias can not be executed until 'del foo' removes the Python variable.
2413 alias can not be executed until 'del foo' removes the Python variable.
2415
2414
2416 You can use the %l specifier in an alias definition to represent the
2415 You can use the %l specifier in an alias definition to represent the
2417 whole line when the alias is called. For example:
2416 whole line when the alias is called. For example:
2418
2417
2419 In [2]: alias all echo "Input in brackets: <%l>"\\
2418 In [2]: alias all echo "Input in brackets: <%l>"\\
2420 In [3]: all hello world\\
2419 In [3]: all hello world\\
2421 Input in brackets: <hello world>
2420 Input in brackets: <hello world>
2422
2421
2423 You can also define aliases with parameters using %s specifiers (one
2422 You can also define aliases with parameters using %s specifiers (one
2424 per parameter):
2423 per parameter):
2425
2424
2426 In [1]: alias parts echo first %s second %s\\
2425 In [1]: alias parts echo first %s second %s\\
2427 In [2]: %parts A B\\
2426 In [2]: %parts A B\\
2428 first A second B\\
2427 first A second B\\
2429 In [3]: %parts A\\
2428 In [3]: %parts A\\
2430 Incorrect number of arguments: 2 expected.\\
2429 Incorrect number of arguments: 2 expected.\\
2431 parts is an alias to: 'echo first %s second %s'
2430 parts is an alias to: 'echo first %s second %s'
2432
2431
2433 Note that %l and %s are mutually exclusive. You can only use one or
2432 Note that %l and %s are mutually exclusive. You can only use one or
2434 the other in your aliases.
2433 the other in your aliases.
2435
2434
2436 Aliases expand Python variables just like system calls using ! or !!
2435 Aliases expand Python variables just like system calls using ! or !!
2437 do: all expressions prefixed with '$' get expanded. For details of
2436 do: all expressions prefixed with '$' get expanded. For details of
2438 the semantic rules, see PEP-215:
2437 the semantic rules, see PEP-215:
2439 http://www.python.org/peps/pep-0215.html. This is the library used by
2438 http://www.python.org/peps/pep-0215.html. This is the library used by
2440 IPython for variable expansion. If you want to access a true shell
2439 IPython for variable expansion. If you want to access a true shell
2441 variable, an extra $ is necessary to prevent its expansion by IPython:
2440 variable, an extra $ is necessary to prevent its expansion by IPython:
2442
2441
2443 In [6]: alias show echo\\
2442 In [6]: alias show echo\\
2444 In [7]: PATH='A Python string'\\
2443 In [7]: PATH='A Python string'\\
2445 In [8]: show $PATH\\
2444 In [8]: show $PATH\\
2446 A Python string\\
2445 A Python string\\
2447 In [9]: show $$PATH\\
2446 In [9]: show $$PATH\\
2448 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2447 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
2449
2448
2450 You can use the alias facility to acess all of $PATH. See the %rehash
2449 You can use the alias facility to acess all of $PATH. See the %rehash
2451 and %rehashx functions, which automatically create aliases for the
2450 and %rehashx functions, which automatically create aliases for the
2452 contents of your $PATH.
2451 contents of your $PATH.
2453
2452
2454 If called with no parameters, %alias prints the current alias table."""
2453 If called with no parameters, %alias prints the current alias table."""
2455
2454
2456 par = parameter_s.strip()
2455 par = parameter_s.strip()
2457 if not par:
2456 if not par:
2458 stored = self.db.get('stored_aliases', {} )
2457 stored = self.db.get('stored_aliases', {} )
2459 atab = self.shell.alias_table
2458 atab = self.shell.alias_table
2460 aliases = atab.keys()
2459 aliases = atab.keys()
2461 aliases.sort()
2460 aliases.sort()
2462 res = []
2461 res = []
2463 showlast = []
2462 showlast = []
2464 for alias in aliases:
2463 for alias in aliases:
2465 tgt = atab[alias][1]
2464 tgt = atab[alias][1]
2466 # 'interesting' aliases
2465 # 'interesting' aliases
2467 if (alias in stored or
2466 if (alias in stored or
2468 alias != os.path.splitext(tgt)[0] or
2467 alias != os.path.splitext(tgt)[0] or
2469 ' ' in tgt):
2468 ' ' in tgt):
2470 showlast.append((alias, tgt))
2469 showlast.append((alias, tgt))
2471 else:
2470 else:
2472 res.append((alias, tgt ))
2471 res.append((alias, tgt ))
2473
2472
2474 # show most interesting aliases last
2473 # show most interesting aliases last
2475 res.extend(showlast)
2474 res.extend(showlast)
2476 print "Total number of aliases:",len(aliases)
2475 print "Total number of aliases:",len(aliases)
2477 return res
2476 return res
2478 try:
2477 try:
2479 alias,cmd = par.split(None,1)
2478 alias,cmd = par.split(None,1)
2480 except:
2479 except:
2481 print OInspect.getdoc(self.magic_alias)
2480 print OInspect.getdoc(self.magic_alias)
2482 else:
2481 else:
2483 nargs = cmd.count('%s')
2482 nargs = cmd.count('%s')
2484 if nargs>0 and cmd.find('%l')>=0:
2483 if nargs>0 and cmd.find('%l')>=0:
2485 error('The %s and %l specifiers are mutually exclusive '
2484 error('The %s and %l specifiers are mutually exclusive '
2486 'in alias definitions.')
2485 'in alias definitions.')
2487 else: # all looks OK
2486 else: # all looks OK
2488 self.shell.alias_table[alias] = (nargs,cmd)
2487 self.shell.alias_table[alias] = (nargs,cmd)
2489 self.shell.alias_table_validate(verbose=0)
2488 self.shell.alias_table_validate(verbose=0)
2490 # end magic_alias
2489 # end magic_alias
2491
2490
2492 def magic_unalias(self, parameter_s = ''):
2491 def magic_unalias(self, parameter_s = ''):
2493 """Remove an alias"""
2492 """Remove an alias"""
2494
2493
2495 aname = parameter_s.strip()
2494 aname = parameter_s.strip()
2496 if aname in self.shell.alias_table:
2495 if aname in self.shell.alias_table:
2497 del self.shell.alias_table[aname]
2496 del self.shell.alias_table[aname]
2498 stored = self.db.get('stored_aliases', {} )
2497 stored = self.db.get('stored_aliases', {} )
2499 if aname in stored:
2498 if aname in stored:
2500 print "Removing %stored alias",aname
2499 print "Removing %stored alias",aname
2501 del stored[aname]
2500 del stored[aname]
2502 self.db['stored_aliases'] = stored
2501 self.db['stored_aliases'] = stored
2503
2502
2504 def magic_rehash(self, parameter_s = ''):
2503 def magic_rehash(self, parameter_s = ''):
2505 """Update the alias table with all entries in $PATH.
2504 """Update the alias table with all entries in $PATH.
2506
2505
2507 This version does no checks on execute permissions or whether the
2506 This version does no checks on execute permissions or whether the
2508 contents of $PATH are truly files (instead of directories or something
2507 contents of $PATH are truly files (instead of directories or something
2509 else). For such a safer (but slower) version, use %rehashx."""
2508 else). For such a safer (but slower) version, use %rehashx."""
2510
2509
2511 # This function (and rehashx) manipulate the alias_table directly
2510 # This function (and rehashx) manipulate the alias_table directly
2512 # rather than calling magic_alias, for speed reasons. A rehash on a
2511 # rather than calling magic_alias, for speed reasons. A rehash on a
2513 # typical Linux box involves several thousand entries, so efficiency
2512 # typical Linux box involves several thousand entries, so efficiency
2514 # here is a top concern.
2513 # here is a top concern.
2515
2514
2516 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2515 path = filter(os.path.isdir,os.environ['PATH'].split(os.pathsep))
2517 alias_table = self.shell.alias_table
2516 alias_table = self.shell.alias_table
2518 for pdir in path:
2517 for pdir in path:
2519 for ff in os.listdir(pdir):
2518 for ff in os.listdir(pdir):
2520 # each entry in the alias table must be (N,name), where
2519 # each entry in the alias table must be (N,name), where
2521 # N is the number of positional arguments of the alias.
2520 # N is the number of positional arguments of the alias.
2522 alias_table[ff] = (0,ff)
2521 alias_table[ff] = (0,ff)
2523 # Make sure the alias table doesn't contain keywords or builtins
2522 # Make sure the alias table doesn't contain keywords or builtins
2524 self.shell.alias_table_validate()
2523 self.shell.alias_table_validate()
2525 # Call again init_auto_alias() so we get 'rm -i' and other modified
2524 # Call again init_auto_alias() so we get 'rm -i' and other modified
2526 # aliases since %rehash will probably clobber them
2525 # aliases since %rehash will probably clobber them
2527 self.shell.init_auto_alias()
2526 self.shell.init_auto_alias()
2528
2527
2529 def magic_rehashx(self, parameter_s = ''):
2528 def magic_rehashx(self, parameter_s = ''):
2530 """Update the alias table with all executable files in $PATH.
2529 """Update the alias table with all executable files in $PATH.
2531
2530
2532 This version explicitly checks that every entry in $PATH is a file
2531 This version explicitly checks that every entry in $PATH is a file
2533 with execute access (os.X_OK), so it is much slower than %rehash.
2532 with execute access (os.X_OK), so it is much slower than %rehash.
2534
2533
2535 Under Windows, it checks executability as a match agains a
2534 Under Windows, it checks executability as a match agains a
2536 '|'-separated string of extensions, stored in the IPython config
2535 '|'-separated string of extensions, stored in the IPython config
2537 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2536 variable win_exec_ext. This defaults to 'exe|com|bat'. """
2538
2537
2539 path = [os.path.abspath(os.path.expanduser(p)) for p in
2538 path = [os.path.abspath(os.path.expanduser(p)) for p in
2540 os.environ['PATH'].split(os.pathsep)]
2539 os.environ['PATH'].split(os.pathsep)]
2541 path = filter(os.path.isdir,path)
2540 path = filter(os.path.isdir,path)
2542
2541
2543 alias_table = self.shell.alias_table
2542 alias_table = self.shell.alias_table
2544 syscmdlist = []
2543 syscmdlist = []
2545 if os.name == 'posix':
2544 if os.name == 'posix':
2546 isexec = lambda fname:os.path.isfile(fname) and \
2545 isexec = lambda fname:os.path.isfile(fname) and \
2547 os.access(fname,os.X_OK)
2546 os.access(fname,os.X_OK)
2548 else:
2547 else:
2549
2548
2550 try:
2549 try:
2551 winext = os.environ['pathext'].replace(';','|').replace('.','')
2550 winext = os.environ['pathext'].replace(';','|').replace('.','')
2552 except KeyError:
2551 except KeyError:
2553 winext = 'exe|com|bat|py'
2552 winext = 'exe|com|bat|py'
2554 if 'py' not in winext:
2553 if 'py' not in winext:
2555 winext += '|py'
2554 winext += '|py'
2556 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2555 execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
2557 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2556 isexec = lambda fname:os.path.isfile(fname) and execre.match(fname)
2558 savedir = os.getcwd()
2557 savedir = os.getcwd()
2559 try:
2558 try:
2560 # write the whole loop for posix/Windows so we don't have an if in
2559 # write the whole loop for posix/Windows so we don't have an if in
2561 # the innermost part
2560 # the innermost part
2562 if os.name == 'posix':
2561 if os.name == 'posix':
2563 for pdir in path:
2562 for pdir in path:
2564 os.chdir(pdir)
2563 os.chdir(pdir)
2565 for ff in os.listdir(pdir):
2564 for ff in os.listdir(pdir):
2566 if isexec(ff) and ff not in self.shell.no_alias:
2565 if isexec(ff) and ff not in self.shell.no_alias:
2567 # each entry in the alias table must be (N,name),
2566 # each entry in the alias table must be (N,name),
2568 # where N is the number of positional arguments of the
2567 # where N is the number of positional arguments of the
2569 # alias.
2568 # alias.
2570 alias_table[ff] = (0,ff)
2569 alias_table[ff] = (0,ff)
2571 syscmdlist.append(ff)
2570 syscmdlist.append(ff)
2572 else:
2571 else:
2573 for pdir in path:
2572 for pdir in path:
2574 os.chdir(pdir)
2573 os.chdir(pdir)
2575 for ff in os.listdir(pdir):
2574 for ff in os.listdir(pdir):
2576 base, ext = os.path.splitext(ff)
2575 base, ext = os.path.splitext(ff)
2577 if isexec(ff) and base not in self.shell.no_alias:
2576 if isexec(ff) and base not in self.shell.no_alias:
2578 if ext.lower() == '.exe':
2577 if ext.lower() == '.exe':
2579 ff = base
2578 ff = base
2580 alias_table[base] = (0,ff)
2579 alias_table[base] = (0,ff)
2581 syscmdlist.append(ff)
2580 syscmdlist.append(ff)
2582 # Make sure the alias table doesn't contain keywords or builtins
2581 # Make sure the alias table doesn't contain keywords or builtins
2583 self.shell.alias_table_validate()
2582 self.shell.alias_table_validate()
2584 # Call again init_auto_alias() so we get 'rm -i' and other
2583 # Call again init_auto_alias() so we get 'rm -i' and other
2585 # modified aliases since %rehashx will probably clobber them
2584 # modified aliases since %rehashx will probably clobber them
2586 self.shell.init_auto_alias()
2585 self.shell.init_auto_alias()
2587 db = self.getapi().db
2586 db = self.getapi().db
2588 db['syscmdlist'] = syscmdlist
2587 db['syscmdlist'] = syscmdlist
2589 finally:
2588 finally:
2590 os.chdir(savedir)
2589 os.chdir(savedir)
2591
2590
2592 def magic_pwd(self, parameter_s = ''):
2591 def magic_pwd(self, parameter_s = ''):
2593 """Return the current working directory path."""
2592 """Return the current working directory path."""
2594 return os.getcwd()
2593 return os.getcwd()
2595
2594
2596 def magic_cd(self, parameter_s=''):
2595 def magic_cd(self, parameter_s=''):
2597 """Change the current working directory.
2596 """Change the current working directory.
2598
2597
2599 This command automatically maintains an internal list of directories
2598 This command automatically maintains an internal list of directories
2600 you visit during your IPython session, in the variable _dh. The
2599 you visit during your IPython session, in the variable _dh. The
2601 command %dhist shows this history nicely formatted. You can also
2600 command %dhist shows this history nicely formatted. You can also
2602 do 'cd -<tab>' to see directory history conveniently.
2601 do 'cd -<tab>' to see directory history conveniently.
2603
2602
2604 Usage:
2603 Usage:
2605
2604
2606 cd 'dir': changes to directory 'dir'.
2605 cd 'dir': changes to directory 'dir'.
2607
2606
2608 cd -: changes to the last visited directory.
2607 cd -: changes to the last visited directory.
2609
2608
2610 cd -<n>: changes to the n-th directory in the directory history.
2609 cd -<n>: changes to the n-th directory in the directory history.
2611
2610
2612 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2611 cd -b <bookmark_name>: jump to a bookmark set by %bookmark
2613 (note: cd <bookmark_name> is enough if there is no
2612 (note: cd <bookmark_name> is enough if there is no
2614 directory <bookmark_name>, but a bookmark with the name exists.)
2613 directory <bookmark_name>, but a bookmark with the name exists.)
2615 'cd -b <tab>' allows you to tab-complete bookmark names.
2614 'cd -b <tab>' allows you to tab-complete bookmark names.
2616
2615
2617 Options:
2616 Options:
2618
2617
2619 -q: quiet. Do not print the working directory after the cd command is
2618 -q: quiet. Do not print the working directory after the cd command is
2620 executed. By default IPython's cd command does print this directory,
2619 executed. By default IPython's cd command does print this directory,
2621 since the default prompts do not display path information.
2620 since the default prompts do not display path information.
2622
2621
2623 Note that !cd doesn't work for this purpose because the shell where
2622 Note that !cd doesn't work for this purpose because the shell where
2624 !command runs is immediately discarded after executing 'command'."""
2623 !command runs is immediately discarded after executing 'command'."""
2625
2624
2626 parameter_s = parameter_s.strip()
2625 parameter_s = parameter_s.strip()
2627 #bkms = self.shell.persist.get("bookmarks",{})
2626 #bkms = self.shell.persist.get("bookmarks",{})
2628
2627
2629 numcd = re.match(r'(-)(\d+)$',parameter_s)
2628 numcd = re.match(r'(-)(\d+)$',parameter_s)
2630 # jump in directory history by number
2629 # jump in directory history by number
2631 if numcd:
2630 if numcd:
2632 nn = int(numcd.group(2))
2631 nn = int(numcd.group(2))
2633 try:
2632 try:
2634 ps = self.shell.user_ns['_dh'][nn]
2633 ps = self.shell.user_ns['_dh'][nn]
2635 except IndexError:
2634 except IndexError:
2636 print 'The requested directory does not exist in history.'
2635 print 'The requested directory does not exist in history.'
2637 return
2636 return
2638 else:
2637 else:
2639 opts = {}
2638 opts = {}
2640 else:
2639 else:
2641 #turn all non-space-escaping backslashes to slashes,
2640 #turn all non-space-escaping backslashes to slashes,
2642 # for c:\windows\directory\names\
2641 # for c:\windows\directory\names\
2643 parameter_s = re.sub(r'\\(?! )','/', parameter_s)
2642 parameter_s = re.sub(r'\\(?! )','/', parameter_s)
2644 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2643 opts,ps = self.parse_options(parameter_s,'qb',mode='string')
2645 # jump to previous
2644 # jump to previous
2646 if ps == '-':
2645 if ps == '-':
2647 try:
2646 try:
2648 ps = self.shell.user_ns['_dh'][-2]
2647 ps = self.shell.user_ns['_dh'][-2]
2649 except IndexError:
2648 except IndexError:
2650 print 'No previous directory to change to.'
2649 print 'No previous directory to change to.'
2651 return
2650 return
2652 # jump to bookmark if needed
2651 # jump to bookmark if needed
2653 else:
2652 else:
2654 if not os.path.isdir(ps) or opts.has_key('b'):
2653 if not os.path.isdir(ps) or opts.has_key('b'):
2655 bkms = self.db.get('bookmarks', {})
2654 bkms = self.db.get('bookmarks', {})
2656
2655
2657 if bkms.has_key(ps):
2656 if bkms.has_key(ps):
2658 target = bkms[ps]
2657 target = bkms[ps]
2659 print '(bookmark:%s) -> %s' % (ps,target)
2658 print '(bookmark:%s) -> %s' % (ps,target)
2660 ps = target
2659 ps = target
2661 else:
2660 else:
2662 if opts.has_key('b'):
2661 if opts.has_key('b'):
2663 error("Bookmark '%s' not found. "
2662 error("Bookmark '%s' not found. "
2664 "Use '%%bookmark -l' to see your bookmarks." % ps)
2663 "Use '%%bookmark -l' to see your bookmarks." % ps)
2665 return
2664 return
2666
2665
2667 # at this point ps should point to the target dir
2666 # at this point ps should point to the target dir
2668 if ps:
2667 if ps:
2669 try:
2668 try:
2670 os.chdir(os.path.expanduser(ps))
2669 os.chdir(os.path.expanduser(ps))
2671 if self.shell.rc.term_title:
2670 if self.shell.rc.term_title:
2672 #print 'set term title:',self.shell.rc.term_title # dbg
2671 #print 'set term title:',self.shell.rc.term_title # dbg
2673 ttitle = ("IPy:" + (
2672 ttitle = ("IPy:" + (
2674 os.getcwd() == '/' and '/' or \
2673 os.getcwd() == '/' and '/' or \
2675 os.path.basename(os.getcwd())))
2674 os.path.basename(os.getcwd())))
2676 platutils.set_term_title(ttitle)
2675 platutils.set_term_title(ttitle)
2677 except OSError:
2676 except OSError:
2678 print sys.exc_info()[1]
2677 print sys.exc_info()[1]
2679 else:
2678 else:
2680 self.shell.user_ns['_dh'].append(os.getcwd())
2679 self.shell.user_ns['_dh'].append(os.getcwd())
2681 else:
2680 else:
2682 os.chdir(self.shell.home_dir)
2681 os.chdir(self.shell.home_dir)
2683 if self.shell.rc.term_title:
2682 if self.shell.rc.term_title:
2684 platutils.set_term_title("IPy:~")
2683 platutils.set_term_title("IPy:~")
2685 self.shell.user_ns['_dh'].append(os.getcwd())
2684 self.shell.user_ns['_dh'].append(os.getcwd())
2686 if not 'q' in opts:
2685 if not 'q' in opts:
2687 print self.shell.user_ns['_dh'][-1]
2686 print self.shell.user_ns['_dh'][-1]
2688
2687
2689 def magic_dhist(self, parameter_s=''):
2688 def magic_dhist(self, parameter_s=''):
2690 """Print your history of visited directories.
2689 """Print your history of visited directories.
2691
2690
2692 %dhist -> print full history\\
2691 %dhist -> print full history\\
2693 %dhist n -> print last n entries only\\
2692 %dhist n -> print last n entries only\\
2694 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2693 %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\
2695
2694
2696 This history is automatically maintained by the %cd command, and
2695 This history is automatically maintained by the %cd command, and
2697 always available as the global list variable _dh. You can use %cd -<n>
2696 always available as the global list variable _dh. You can use %cd -<n>
2698 to go to directory number <n>."""
2697 to go to directory number <n>."""
2699
2698
2700 dh = self.shell.user_ns['_dh']
2699 dh = self.shell.user_ns['_dh']
2701 if parameter_s:
2700 if parameter_s:
2702 try:
2701 try:
2703 args = map(int,parameter_s.split())
2702 args = map(int,parameter_s.split())
2704 except:
2703 except:
2705 self.arg_err(Magic.magic_dhist)
2704 self.arg_err(Magic.magic_dhist)
2706 return
2705 return
2707 if len(args) == 1:
2706 if len(args) == 1:
2708 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2707 ini,fin = max(len(dh)-(args[0]),0),len(dh)
2709 elif len(args) == 2:
2708 elif len(args) == 2:
2710 ini,fin = args
2709 ini,fin = args
2711 else:
2710 else:
2712 self.arg_err(Magic.magic_dhist)
2711 self.arg_err(Magic.magic_dhist)
2713 return
2712 return
2714 else:
2713 else:
2715 ini,fin = 0,len(dh)
2714 ini,fin = 0,len(dh)
2716 nlprint(dh,
2715 nlprint(dh,
2717 header = 'Directory history (kept in _dh)',
2716 header = 'Directory history (kept in _dh)',
2718 start=ini,stop=fin)
2717 start=ini,stop=fin)
2719
2718
2720 def magic_env(self, parameter_s=''):
2719 def magic_env(self, parameter_s=''):
2721 """List environment variables."""
2720 """List environment variables."""
2722
2721
2723 return os.environ.data
2722 return os.environ.data
2724
2723
2725 def magic_pushd(self, parameter_s=''):
2724 def magic_pushd(self, parameter_s=''):
2726 """Place the current dir on stack and change directory.
2725 """Place the current dir on stack and change directory.
2727
2726
2728 Usage:\\
2727 Usage:\\
2729 %pushd ['dirname']
2728 %pushd ['dirname']
2730
2729
2731 %pushd with no arguments does a %pushd to your home directory.
2730 %pushd with no arguments does a %pushd to your home directory.
2732 """
2731 """
2733 if parameter_s == '': parameter_s = '~'
2732 if parameter_s == '': parameter_s = '~'
2734 dir_s = self.shell.dir_stack
2733 dir_s = self.shell.dir_stack
2735 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2734 if len(dir_s)>0 and os.path.expanduser(parameter_s) != \
2736 os.path.expanduser(self.shell.dir_stack[0]):
2735 os.path.expanduser(self.shell.dir_stack[0]):
2737 try:
2736 try:
2738 self.magic_cd(parameter_s)
2737 self.magic_cd(parameter_s)
2739 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2738 dir_s.insert(0,os.getcwd().replace(self.home_dir,'~'))
2740 self.magic_dirs()
2739 self.magic_dirs()
2741 except:
2740 except:
2742 print 'Invalid directory'
2741 print 'Invalid directory'
2743 else:
2742 else:
2744 print 'You are already there!'
2743 print 'You are already there!'
2745
2744
2746 def magic_popd(self, parameter_s=''):
2745 def magic_popd(self, parameter_s=''):
2747 """Change to directory popped off the top of the stack.
2746 """Change to directory popped off the top of the stack.
2748 """
2747 """
2749 if len (self.shell.dir_stack) > 1:
2748 if len (self.shell.dir_stack) > 1:
2750 self.shell.dir_stack.pop(0)
2749 self.shell.dir_stack.pop(0)
2751 self.magic_cd(self.shell.dir_stack[0])
2750 self.magic_cd(self.shell.dir_stack[0])
2752 print self.shell.dir_stack[0]
2751 print self.shell.dir_stack[0]
2753 else:
2752 else:
2754 print "You can't remove the starting directory from the stack:",\
2753 print "You can't remove the starting directory from the stack:",\
2755 self.shell.dir_stack
2754 self.shell.dir_stack
2756
2755
2757 def magic_dirs(self, parameter_s=''):
2756 def magic_dirs(self, parameter_s=''):
2758 """Return the current directory stack."""
2757 """Return the current directory stack."""
2759
2758
2760 return self.shell.dir_stack[:]
2759 return self.shell.dir_stack[:]
2761
2760
2762 def magic_sc(self, parameter_s=''):
2761 def magic_sc(self, parameter_s=''):
2763 """Shell capture - execute a shell command and capture its output.
2762 """Shell capture - execute a shell command and capture its output.
2764
2763
2765 DEPRECATED. Suboptimal, retained for backwards compatibility.
2764 DEPRECATED. Suboptimal, retained for backwards compatibility.
2766
2765
2767 You should use the form 'var = !command' instead. Example:
2766 You should use the form 'var = !command' instead. Example:
2768
2767
2769 "%sc -l myfiles = ls ~" should now be written as
2768 "%sc -l myfiles = ls ~" should now be written as
2770
2769
2771 "myfiles = !ls ~"
2770 "myfiles = !ls ~"
2772
2771
2773 myfiles.s, myfiles.l and myfiles.n still apply as documented
2772 myfiles.s, myfiles.l and myfiles.n still apply as documented
2774 below.
2773 below.
2775
2774
2776 --
2775 --
2777 %sc [options] varname=command
2776 %sc [options] varname=command
2778
2777
2779 IPython will run the given command using commands.getoutput(), and
2778 IPython will run the given command using commands.getoutput(), and
2780 will then update the user's interactive namespace with a variable
2779 will then update the user's interactive namespace with a variable
2781 called varname, containing the value of the call. Your command can
2780 called varname, containing the value of the call. Your command can
2782 contain shell wildcards, pipes, etc.
2781 contain shell wildcards, pipes, etc.
2783
2782
2784 The '=' sign in the syntax is mandatory, and the variable name you
2783 The '=' sign in the syntax is mandatory, and the variable name you
2785 supply must follow Python's standard conventions for valid names.
2784 supply must follow Python's standard conventions for valid names.
2786
2785
2787 (A special format without variable name exists for internal use)
2786 (A special format without variable name exists for internal use)
2788
2787
2789 Options:
2788 Options:
2790
2789
2791 -l: list output. Split the output on newlines into a list before
2790 -l: list output. Split the output on newlines into a list before
2792 assigning it to the given variable. By default the output is stored
2791 assigning it to the given variable. By default the output is stored
2793 as a single string.
2792 as a single string.
2794
2793
2795 -v: verbose. Print the contents of the variable.
2794 -v: verbose. Print the contents of the variable.
2796
2795
2797 In most cases you should not need to split as a list, because the
2796 In most cases you should not need to split as a list, because the
2798 returned value is a special type of string which can automatically
2797 returned value is a special type of string which can automatically
2799 provide its contents either as a list (split on newlines) or as a
2798 provide its contents either as a list (split on newlines) or as a
2800 space-separated string. These are convenient, respectively, either
2799 space-separated string. These are convenient, respectively, either
2801 for sequential processing or to be passed to a shell command.
2800 for sequential processing or to be passed to a shell command.
2802
2801
2803 For example:
2802 For example:
2804
2803
2805 # Capture into variable a
2804 # Capture into variable a
2806 In [9]: sc a=ls *py
2805 In [9]: sc a=ls *py
2807
2806
2808 # a is a string with embedded newlines
2807 # a is a string with embedded newlines
2809 In [10]: a
2808 In [10]: a
2810 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2809 Out[10]: 'setup.py\nwin32_manual_post_install.py'
2811
2810
2812 # which can be seen as a list:
2811 # which can be seen as a list:
2813 In [11]: a.l
2812 In [11]: a.l
2814 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2813 Out[11]: ['setup.py', 'win32_manual_post_install.py']
2815
2814
2816 # or as a whitespace-separated string:
2815 # or as a whitespace-separated string:
2817 In [12]: a.s
2816 In [12]: a.s
2818 Out[12]: 'setup.py win32_manual_post_install.py'
2817 Out[12]: 'setup.py win32_manual_post_install.py'
2819
2818
2820 # a.s is useful to pass as a single command line:
2819 # a.s is useful to pass as a single command line:
2821 In [13]: !wc -l $a.s
2820 In [13]: !wc -l $a.s
2822 146 setup.py
2821 146 setup.py
2823 130 win32_manual_post_install.py
2822 130 win32_manual_post_install.py
2824 276 total
2823 276 total
2825
2824
2826 # while the list form is useful to loop over:
2825 # while the list form is useful to loop over:
2827 In [14]: for f in a.l:
2826 In [14]: for f in a.l:
2828 ....: !wc -l $f
2827 ....: !wc -l $f
2829 ....:
2828 ....:
2830 146 setup.py
2829 146 setup.py
2831 130 win32_manual_post_install.py
2830 130 win32_manual_post_install.py
2832
2831
2833 Similiarly, the lists returned by the -l option are also special, in
2832 Similiarly, the lists returned by the -l option are also special, in
2834 the sense that you can equally invoke the .s attribute on them to
2833 the sense that you can equally invoke the .s attribute on them to
2835 automatically get a whitespace-separated string from their contents:
2834 automatically get a whitespace-separated string from their contents:
2836
2835
2837 In [1]: sc -l b=ls *py
2836 In [1]: sc -l b=ls *py
2838
2837
2839 In [2]: b
2838 In [2]: b
2840 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2839 Out[2]: ['setup.py', 'win32_manual_post_install.py']
2841
2840
2842 In [3]: b.s
2841 In [3]: b.s
2843 Out[3]: 'setup.py win32_manual_post_install.py'
2842 Out[3]: 'setup.py win32_manual_post_install.py'
2844
2843
2845 In summary, both the lists and strings used for ouptut capture have
2844 In summary, both the lists and strings used for ouptut capture have
2846 the following special attributes:
2845 the following special attributes:
2847
2846
2848 .l (or .list) : value as list.
2847 .l (or .list) : value as list.
2849 .n (or .nlstr): value as newline-separated string.
2848 .n (or .nlstr): value as newline-separated string.
2850 .s (or .spstr): value as space-separated string.
2849 .s (or .spstr): value as space-separated string.
2851 """
2850 """
2852
2851
2853 opts,args = self.parse_options(parameter_s,'lv')
2852 opts,args = self.parse_options(parameter_s,'lv')
2854 # Try to get a variable name and command to run
2853 # Try to get a variable name and command to run
2855 try:
2854 try:
2856 # the variable name must be obtained from the parse_options
2855 # the variable name must be obtained from the parse_options
2857 # output, which uses shlex.split to strip options out.
2856 # output, which uses shlex.split to strip options out.
2858 var,_ = args.split('=',1)
2857 var,_ = args.split('=',1)
2859 var = var.strip()
2858 var = var.strip()
2860 # But the the command has to be extracted from the original input
2859 # But the the command has to be extracted from the original input
2861 # parameter_s, not on what parse_options returns, to avoid the
2860 # parameter_s, not on what parse_options returns, to avoid the
2862 # quote stripping which shlex.split performs on it.
2861 # quote stripping which shlex.split performs on it.
2863 _,cmd = parameter_s.split('=',1)
2862 _,cmd = parameter_s.split('=',1)
2864 except ValueError:
2863 except ValueError:
2865 var,cmd = '',''
2864 var,cmd = '',''
2866 # If all looks ok, proceed
2865 # If all looks ok, proceed
2867 out,err = self.shell.getoutputerror(cmd)
2866 out,err = self.shell.getoutputerror(cmd)
2868 if err:
2867 if err:
2869 print >> Term.cerr,err
2868 print >> Term.cerr,err
2870 if opts.has_key('l'):
2869 if opts.has_key('l'):
2871 out = SList(out.split('\n'))
2870 out = SList(out.split('\n'))
2872 else:
2871 else:
2873 out = LSString(out)
2872 out = LSString(out)
2874 if opts.has_key('v'):
2873 if opts.has_key('v'):
2875 print '%s ==\n%s' % (var,pformat(out))
2874 print '%s ==\n%s' % (var,pformat(out))
2876 if var:
2875 if var:
2877 self.shell.user_ns.update({var:out})
2876 self.shell.user_ns.update({var:out})
2878 else:
2877 else:
2879 return out
2878 return out
2880
2879
2881 def magic_sx(self, parameter_s=''):
2880 def magic_sx(self, parameter_s=''):
2882 """Shell execute - run a shell command and capture its output.
2881 """Shell execute - run a shell command and capture its output.
2883
2882
2884 %sx command
2883 %sx command
2885
2884
2886 IPython will run the given command using commands.getoutput(), and
2885 IPython will run the given command using commands.getoutput(), and
2887 return the result formatted as a list (split on '\\n'). Since the
2886 return the result formatted as a list (split on '\\n'). Since the
2888 output is _returned_, it will be stored in ipython's regular output
2887 output is _returned_, it will be stored in ipython's regular output
2889 cache Out[N] and in the '_N' automatic variables.
2888 cache Out[N] and in the '_N' automatic variables.
2890
2889
2891 Notes:
2890 Notes:
2892
2891
2893 1) If an input line begins with '!!', then %sx is automatically
2892 1) If an input line begins with '!!', then %sx is automatically
2894 invoked. That is, while:
2893 invoked. That is, while:
2895 !ls
2894 !ls
2896 causes ipython to simply issue system('ls'), typing
2895 causes ipython to simply issue system('ls'), typing
2897 !!ls
2896 !!ls
2898 is a shorthand equivalent to:
2897 is a shorthand equivalent to:
2899 %sx ls
2898 %sx ls
2900
2899
2901 2) %sx differs from %sc in that %sx automatically splits into a list,
2900 2) %sx differs from %sc in that %sx automatically splits into a list,
2902 like '%sc -l'. The reason for this is to make it as easy as possible
2901 like '%sc -l'. The reason for this is to make it as easy as possible
2903 to process line-oriented shell output via further python commands.
2902 to process line-oriented shell output via further python commands.
2904 %sc is meant to provide much finer control, but requires more
2903 %sc is meant to provide much finer control, but requires more
2905 typing.
2904 typing.
2906
2905
2907 3) Just like %sc -l, this is a list with special attributes:
2906 3) Just like %sc -l, this is a list with special attributes:
2908
2907
2909 .l (or .list) : value as list.
2908 .l (or .list) : value as list.
2910 .n (or .nlstr): value as newline-separated string.
2909 .n (or .nlstr): value as newline-separated string.
2911 .s (or .spstr): value as whitespace-separated string.
2910 .s (or .spstr): value as whitespace-separated string.
2912
2911
2913 This is very useful when trying to use such lists as arguments to
2912 This is very useful when trying to use such lists as arguments to
2914 system commands."""
2913 system commands."""
2915
2914
2916 if parameter_s:
2915 if parameter_s:
2917 out,err = self.shell.getoutputerror(parameter_s)
2916 out,err = self.shell.getoutputerror(parameter_s)
2918 if err:
2917 if err:
2919 print >> Term.cerr,err
2918 print >> Term.cerr,err
2920 return SList(out.split('\n'))
2919 return SList(out.split('\n'))
2921
2920
2922 def magic_bg(self, parameter_s=''):
2921 def magic_bg(self, parameter_s=''):
2923 """Run a job in the background, in a separate thread.
2922 """Run a job in the background, in a separate thread.
2924
2923
2925 For example,
2924 For example,
2926
2925
2927 %bg myfunc(x,y,z=1)
2926 %bg myfunc(x,y,z=1)
2928
2927
2929 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2928 will execute 'myfunc(x,y,z=1)' in a background thread. As soon as the
2930 execution starts, a message will be printed indicating the job
2929 execution starts, a message will be printed indicating the job
2931 number. If your job number is 5, you can use
2930 number. If your job number is 5, you can use
2932
2931
2933 myvar = jobs.result(5) or myvar = jobs[5].result
2932 myvar = jobs.result(5) or myvar = jobs[5].result
2934
2933
2935 to assign this result to variable 'myvar'.
2934 to assign this result to variable 'myvar'.
2936
2935
2937 IPython has a job manager, accessible via the 'jobs' object. You can
2936 IPython has a job manager, accessible via the 'jobs' object. You can
2938 type jobs? to get more information about it, and use jobs.<TAB> to see
2937 type jobs? to get more information about it, and use jobs.<TAB> to see
2939 its attributes. All attributes not starting with an underscore are
2938 its attributes. All attributes not starting with an underscore are
2940 meant for public use.
2939 meant for public use.
2941
2940
2942 In particular, look at the jobs.new() method, which is used to create
2941 In particular, look at the jobs.new() method, which is used to create
2943 new jobs. This magic %bg function is just a convenience wrapper
2942 new jobs. This magic %bg function is just a convenience wrapper
2944 around jobs.new(), for expression-based jobs. If you want to create a
2943 around jobs.new(), for expression-based jobs. If you want to create a
2945 new job with an explicit function object and arguments, you must call
2944 new job with an explicit function object and arguments, you must call
2946 jobs.new() directly.
2945 jobs.new() directly.
2947
2946
2948 The jobs.new docstring also describes in detail several important
2947 The jobs.new docstring also describes in detail several important
2949 caveats associated with a thread-based model for background job
2948 caveats associated with a thread-based model for background job
2950 execution. Type jobs.new? for details.
2949 execution. Type jobs.new? for details.
2951
2950
2952 You can check the status of all jobs with jobs.status().
2951 You can check the status of all jobs with jobs.status().
2953
2952
2954 The jobs variable is set by IPython into the Python builtin namespace.
2953 The jobs variable is set by IPython into the Python builtin namespace.
2955 If you ever declare a variable named 'jobs', you will shadow this
2954 If you ever declare a variable named 'jobs', you will shadow this
2956 name. You can either delete your global jobs variable to regain
2955 name. You can either delete your global jobs variable to regain
2957 access to the job manager, or make a new name and assign it manually
2956 access to the job manager, or make a new name and assign it manually
2958 to the manager (stored in IPython's namespace). For example, to
2957 to the manager (stored in IPython's namespace). For example, to
2959 assign the job manager to the Jobs name, use:
2958 assign the job manager to the Jobs name, use:
2960
2959
2961 Jobs = __builtins__.jobs"""
2960 Jobs = __builtins__.jobs"""
2962
2961
2963 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2962 self.shell.jobs.new(parameter_s,self.shell.user_ns)
2964
2963
2965
2964
2966 def magic_bookmark(self, parameter_s=''):
2965 def magic_bookmark(self, parameter_s=''):
2967 """Manage IPython's bookmark system.
2966 """Manage IPython's bookmark system.
2968
2967
2969 %bookmark <name> - set bookmark to current dir
2968 %bookmark <name> - set bookmark to current dir
2970 %bookmark <name> <dir> - set bookmark to <dir>
2969 %bookmark <name> <dir> - set bookmark to <dir>
2971 %bookmark -l - list all bookmarks
2970 %bookmark -l - list all bookmarks
2972 %bookmark -d <name> - remove bookmark
2971 %bookmark -d <name> - remove bookmark
2973 %bookmark -r - remove all bookmarks
2972 %bookmark -r - remove all bookmarks
2974
2973
2975 You can later on access a bookmarked folder with:
2974 You can later on access a bookmarked folder with:
2976 %cd -b <name>
2975 %cd -b <name>
2977 or simply '%cd <name>' if there is no directory called <name> AND
2976 or simply '%cd <name>' if there is no directory called <name> AND
2978 there is such a bookmark defined.
2977 there is such a bookmark defined.
2979
2978
2980 Your bookmarks persist through IPython sessions, but they are
2979 Your bookmarks persist through IPython sessions, but they are
2981 associated with each profile."""
2980 associated with each profile."""
2982
2981
2983 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2982 opts,args = self.parse_options(parameter_s,'drl',mode='list')
2984 if len(args) > 2:
2983 if len(args) > 2:
2985 error('You can only give at most two arguments')
2984 error('You can only give at most two arguments')
2986 return
2985 return
2987
2986
2988 bkms = self.db.get('bookmarks',{})
2987 bkms = self.db.get('bookmarks',{})
2989
2988
2990 if opts.has_key('d'):
2989 if opts.has_key('d'):
2991 try:
2990 try:
2992 todel = args[0]
2991 todel = args[0]
2993 except IndexError:
2992 except IndexError:
2994 error('You must provide a bookmark to delete')
2993 error('You must provide a bookmark to delete')
2995 else:
2994 else:
2996 try:
2995 try:
2997 del bkms[todel]
2996 del bkms[todel]
2998 except:
2997 except:
2999 error("Can't delete bookmark '%s'" % todel)
2998 error("Can't delete bookmark '%s'" % todel)
3000 elif opts.has_key('r'):
2999 elif opts.has_key('r'):
3001 bkms = {}
3000 bkms = {}
3002 elif opts.has_key('l'):
3001 elif opts.has_key('l'):
3003 bks = bkms.keys()
3002 bks = bkms.keys()
3004 bks.sort()
3003 bks.sort()
3005 if bks:
3004 if bks:
3006 size = max(map(len,bks))
3005 size = max(map(len,bks))
3007 else:
3006 else:
3008 size = 0
3007 size = 0
3009 fmt = '%-'+str(size)+'s -> %s'
3008 fmt = '%-'+str(size)+'s -> %s'
3010 print 'Current bookmarks:'
3009 print 'Current bookmarks:'
3011 for bk in bks:
3010 for bk in bks:
3012 print fmt % (bk,bkms[bk])
3011 print fmt % (bk,bkms[bk])
3013 else:
3012 else:
3014 if not args:
3013 if not args:
3015 error("You must specify the bookmark name")
3014 error("You must specify the bookmark name")
3016 elif len(args)==1:
3015 elif len(args)==1:
3017 bkms[args[0]] = os.getcwd()
3016 bkms[args[0]] = os.getcwd()
3018 elif len(args)==2:
3017 elif len(args)==2:
3019 bkms[args[0]] = args[1]
3018 bkms[args[0]] = args[1]
3020 self.db['bookmarks'] = bkms
3019 self.db['bookmarks'] = bkms
3021
3020
3022 def magic_pycat(self, parameter_s=''):
3021 def magic_pycat(self, parameter_s=''):
3023 """Show a syntax-highlighted file through a pager.
3022 """Show a syntax-highlighted file through a pager.
3024
3023
3025 This magic is similar to the cat utility, but it will assume the file
3024 This magic is similar to the cat utility, but it will assume the file
3026 to be Python source and will show it with syntax highlighting. """
3025 to be Python source and will show it with syntax highlighting. """
3027
3026
3028 try:
3027 try:
3029 filename = get_py_filename(parameter_s)
3028 filename = get_py_filename(parameter_s)
3030 cont = file_read(filename)
3029 cont = file_read(filename)
3031 except IOError:
3030 except IOError:
3032 try:
3031 try:
3033 cont = eval(parameter_s,self.user_ns)
3032 cont = eval(parameter_s,self.user_ns)
3034 except NameError:
3033 except NameError:
3035 cont = None
3034 cont = None
3036 if cont is None:
3035 if cont is None:
3037 print "Error: no such file or variable"
3036 print "Error: no such file or variable"
3038 return
3037 return
3039
3038
3040 page(self.shell.pycolorize(cont),
3039 page(self.shell.pycolorize(cont),
3041 screen_lines=self.shell.rc.screen_length)
3040 screen_lines=self.shell.rc.screen_length)
3042
3041
3043 def magic_cpaste(self, parameter_s=''):
3042 def magic_cpaste(self, parameter_s=''):
3044 """Allows you to paste & execute a pre-formatted code block from clipboard
3043 """Allows you to paste & execute a pre-formatted code block from clipboard
3045
3044
3046 You must terminate the block with '--' (two minus-signs) alone on the
3045 You must terminate the block with '--' (two minus-signs) alone on the
3047 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
3046 line. You can also provide your own sentinel with '%paste -s %%' ('%%'
3048 is the new sentinel for this operation)
3047 is the new sentinel for this operation)
3049
3048
3050 The block is dedented prior to execution to enable execution of
3049 The block is dedented prior to execution to enable execution of
3051 method definitions. '>' characters at the beginning of a line is
3050 method definitions. '>' characters at the beginning of a line is
3052 ignored, to allow pasting directly from e-mails. The executed block
3051 ignored, to allow pasting directly from e-mails. The executed block
3053 is also assigned to variable named 'pasted_block' for later editing
3052 is also assigned to variable named 'pasted_block' for later editing
3054 with '%edit pasted_block'.
3053 with '%edit pasted_block'.
3055
3054
3056 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
3055 You can also pass a variable name as an argument, e.g. '%cpaste foo'.
3057 This assigns the pasted block to variable 'foo' as string, without
3056 This assigns the pasted block to variable 'foo' as string, without
3058 dedenting or executing it.
3057 dedenting or executing it.
3059
3058
3060 Do not be alarmed by garbled output on Windows (it's a readline bug).
3059 Do not be alarmed by garbled output on Windows (it's a readline bug).
3061 Just press enter and type -- (and press enter again) and the block
3060 Just press enter and type -- (and press enter again) and the block
3062 will be what was just pasted.
3061 will be what was just pasted.
3063
3062
3064 IPython statements (magics, shell escapes) are not supported (yet).
3063 IPython statements (magics, shell escapes) are not supported (yet).
3065 """
3064 """
3066 opts,args = self.parse_options(parameter_s,'s:',mode='string')
3065 opts,args = self.parse_options(parameter_s,'s:',mode='string')
3067 par = args.strip()
3066 par = args.strip()
3068 sentinel = opts.get('s','--')
3067 sentinel = opts.get('s','--')
3069
3068
3070 from IPython import iplib
3069 from IPython import iplib
3071 lines = []
3070 lines = []
3072 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
3071 print "Pasting code; enter '%s' alone on the line to stop." % sentinel
3073 while 1:
3072 while 1:
3074 l = iplib.raw_input_original(':')
3073 l = iplib.raw_input_original(':')
3075 if l ==sentinel:
3074 if l ==sentinel:
3076 break
3075 break
3077 lines.append(l.lstrip('>'))
3076 lines.append(l.lstrip('>'))
3078 block = "\n".join(lines) + '\n'
3077 block = "\n".join(lines) + '\n'
3079 #print "block:\n",block
3078 #print "block:\n",block
3080 if not par:
3079 if not par:
3081 b = textwrap.dedent(block)
3080 b = textwrap.dedent(block)
3082 exec b in self.user_ns
3081 exec b in self.user_ns
3083 self.user_ns['pasted_block'] = b
3082 self.user_ns['pasted_block'] = b
3084 else:
3083 else:
3085 self.user_ns[par] = block
3084 self.user_ns[par] = block
3086 print "Block assigned to '%s'" % par
3085 print "Block assigned to '%s'" % par
3087
3086
3088 def magic_quickref(self,arg):
3087 def magic_quickref(self,arg):
3089 """ Show a quick reference sheet """
3088 """ Show a quick reference sheet """
3090 import IPython.usage
3089 import IPython.usage
3091 qr = IPython.usage.quick_reference + self.magic_magic('-brief')
3090 qr = IPython.usage.quick_reference + self.magic_magic('-brief')
3092
3091
3093 page(qr)
3092 page(qr)
3094
3093
3095 def magic_upgrade(self,arg):
3094 def magic_upgrade(self,arg):
3096 """ Upgrade your IPython installation
3095 """ Upgrade your IPython installation
3097
3096
3098 This will copy the config files that don't yet exist in your
3097 This will copy the config files that don't yet exist in your
3099 ipython dir from the system config dir. Use this after upgrading
3098 ipython dir from the system config dir. Use this after upgrading
3100 IPython if you don't wish to delete your .ipython dir.
3099 IPython if you don't wish to delete your .ipython dir.
3101
3100
3102 Call with -nolegacy to get rid of ipythonrc* files (recommended for
3101 Call with -nolegacy to get rid of ipythonrc* files (recommended for
3103 new users)
3102 new users)
3104
3103
3105 """
3104 """
3106 ip = self.getapi()
3105 ip = self.getapi()
3107 ipinstallation = path(IPython.__file__).dirname()
3106 ipinstallation = path(IPython.__file__).dirname()
3108 upgrade_script = '%s "%s"' % (sys.executable,ipinstallation / 'upgrade_dir.py')
3107 upgrade_script = '%s "%s"' % (sys.executable,ipinstallation / 'upgrade_dir.py')
3109 src_config = ipinstallation / 'UserConfig'
3108 src_config = ipinstallation / 'UserConfig'
3110 userdir = path(ip.options.ipythondir)
3109 userdir = path(ip.options.ipythondir)
3111 cmd = '%s "%s" "%s"' % (upgrade_script, src_config, userdir)
3110 cmd = '%s "%s" "%s"' % (upgrade_script, src_config, userdir)
3112 print ">",cmd
3111 print ">",cmd
3113 shell(cmd)
3112 shell(cmd)
3114 if arg == '-nolegacy':
3113 if arg == '-nolegacy':
3115 legacy = userdir.files('ipythonrc*')
3114 legacy = userdir.files('ipythonrc*')
3116 print "Nuking legacy files:",legacy
3115 print "Nuking legacy files:",legacy
3117
3116
3118 [p.remove() for p in legacy]
3117 [p.remove() for p in legacy]
3119 suffix = (sys.platform == 'win32' and '.ini' or '')
3118 suffix = (sys.platform == 'win32' and '.ini' or '')
3120 (userdir / ('ipythonrc' + suffix)).write_text('# Empty, see ipy_user_conf.py\n')
3119 (userdir / ('ipythonrc' + suffix)).write_text('# Empty, see ipy_user_conf.py\n')
3121
3120
3122 # end Magic
3121 # end Magic
@@ -1,281 +1,282 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 Class and program to colorize python source code for ANSI terminals.
3 Class and program to colorize python source code for ANSI terminals.
4
4
5 Based on an HTML code highlighter by Jurgen Hermann found at:
5 Based on an HTML code highlighter by Jurgen Hermann found at:
6 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52298
6 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52298
7
7
8 Modifications by Fernando Perez (fperez@colorado.edu).
8 Modifications by Fernando Perez (fperez@colorado.edu).
9
9
10 Information on the original HTML highlighter follows:
10 Information on the original HTML highlighter follows:
11
11
12 MoinMoin - Python Source Parser
12 MoinMoin - Python Source Parser
13
13
14 Title:olorize Python source using the built-in tokenizer
14 Title:olorize Python source using the built-in tokenizer
15
15
16 Submitter: Jurgen Hermann
16 Submitter: Jurgen Hermann
17 Last Updated:2001/04/06
17 Last Updated:2001/04/06
18
18
19 Version no:1.2
19 Version no:1.2
20
20
21 Description:
21 Description:
22
22
23 This code is part of MoinMoin (http://moin.sourceforge.net/) and converts
23 This code is part of MoinMoin (http://moin.sourceforge.net/) and converts
24 Python source code to HTML markup, rendering comments, keywords,
24 Python source code to HTML markup, rendering comments, keywords,
25 operators, numeric and string literals in different colors.
25 operators, numeric and string literals in different colors.
26
26
27 It shows how to use the built-in keyword, token and tokenize modules to
27 It shows how to use the built-in keyword, token and tokenize modules to
28 scan Python source code and re-emit it with no changes to its original
28 scan Python source code and re-emit it with no changes to its original
29 formatting (which is the hard part).
29 formatting (which is the hard part).
30
30
31 $Id: PyColorize.py 2205 2007-04-04 06:04:01Z fperez $"""
31 $Id: PyColorize.py 2225 2007-04-08 02:48:16Z jdh2358 $"""
32
32
33 __all__ = ['ANSICodeColors','Parser']
33 __all__ = ['ANSICodeColors','Parser']
34
34
35 _scheme_default = 'Linux'
35 _scheme_default = 'Linux'
36
36
37 # Imports
37 # Imports
38 import cStringIO
38 import cStringIO
39 import keyword
39 import keyword
40 import os
40 import os
41 import string
41 import string
42 import sys
42 import sys
43 import token
43 import token
44 import tokenize
44 import tokenize
45
45
46 from IPython.ColorANSI import *
46 from IPython.ColorANSI import *
47
47
48 #############################################################################
48 #############################################################################
49 ### Python Source Parser (does Hilighting)
49 ### Python Source Parser (does Hilighting)
50 #############################################################################
50 #############################################################################
51
51
52 _KEYWORD = token.NT_OFFSET + 1
52 _KEYWORD = token.NT_OFFSET + 1
53 _TEXT = token.NT_OFFSET + 2
53 _TEXT = token.NT_OFFSET + 2
54
54
55 #****************************************************************************
55 #****************************************************************************
56 # Builtin color schemes
56 # Builtin color schemes
57
57
58 Colors = TermColors # just a shorthand
58 Colors = TermColors # just a shorthand
59
59
60 # Build a few color schemes
60 # Build a few color schemes
61 NoColor = ColorScheme(
61 NoColor = ColorScheme(
62 'NoColor',{
62 'NoColor',{
63 token.NUMBER : Colors.NoColor,
63 token.NUMBER : Colors.NoColor,
64 token.OP : Colors.NoColor,
64 token.OP : Colors.NoColor,
65 token.STRING : Colors.NoColor,
65 token.STRING : Colors.NoColor,
66 tokenize.COMMENT : Colors.NoColor,
66 tokenize.COMMENT : Colors.NoColor,
67 token.NAME : Colors.NoColor,
67 token.NAME : Colors.NoColor,
68 token.ERRORTOKEN : Colors.NoColor,
68 token.ERRORTOKEN : Colors.NoColor,
69
69
70 _KEYWORD : Colors.NoColor,
70 _KEYWORD : Colors.NoColor,
71 _TEXT : Colors.NoColor,
71 _TEXT : Colors.NoColor,
72
72
73 'normal' : Colors.NoColor # color off (usu. Colors.Normal)
73 'normal' : Colors.NoColor # color off (usu. Colors.Normal)
74 } )
74 } )
75
75
76 LinuxColors = ColorScheme(
76 LinuxColors = ColorScheme(
77 'Linux',{
77 'Linux',{
78 token.NUMBER : Colors.LightCyan,
78 token.NUMBER : Colors.LightCyan,
79 token.OP : Colors.Yellow,
79 token.OP : Colors.Yellow,
80 token.STRING : Colors.LightBlue,
80 token.STRING : Colors.LightBlue,
81 tokenize.COMMENT : Colors.LightRed,
81 tokenize.COMMENT : Colors.LightRed,
82 token.NAME : Colors.White,
82 token.NAME : Colors.White,
83 token.ERRORTOKEN : Colors.Red,
83 token.ERRORTOKEN : Colors.Red,
84
84
85 _KEYWORD : Colors.LightGreen,
85 _KEYWORD : Colors.LightGreen,
86 _TEXT : Colors.Yellow,
86 _TEXT : Colors.Yellow,
87
87
88 'normal' : Colors.Normal # color off (usu. Colors.Normal)
88 'normal' : Colors.Normal # color off (usu. Colors.Normal)
89 } )
89 } )
90
90
91 LightBGColors = ColorScheme(
91 LightBGColors = ColorScheme(
92 'LightBG',{
92 'LightBG',{
93 token.NUMBER : Colors.Cyan,
93 token.NUMBER : Colors.Cyan,
94 token.OP : Colors.Blue,
94 token.OP : Colors.Blue,
95 token.STRING : Colors.Blue,
95 token.STRING : Colors.Blue,
96 tokenize.COMMENT : Colors.Red,
96 tokenize.COMMENT : Colors.Red,
97 token.NAME : Colors.Black,
97 token.NAME : Colors.Black,
98 token.ERRORTOKEN : Colors.Red,
98 token.ERRORTOKEN : Colors.Red,
99
99
100 _KEYWORD : Colors.Green,
100 _KEYWORD : Colors.Green,
101 _TEXT : Colors.Blue,
101 _TEXT : Colors.Blue,
102
102
103 'normal' : Colors.Normal # color off (usu. Colors.Normal)
103 'normal' : Colors.Normal # color off (usu. Colors.Normal)
104 } )
104 } )
105
105
106 # Build table of color schemes (needed by the parser)
106 # Build table of color schemes (needed by the parser)
107 ANSICodeColors = ColorSchemeTable([NoColor,LinuxColors,LightBGColors],
107 ANSICodeColors = ColorSchemeTable([NoColor,LinuxColors,LightBGColors],
108 _scheme_default)
108 _scheme_default)
109
109
110 class Parser:
110 class Parser:
111 """ Format colored Python source.
111 """ Format colored Python source.
112 """
112 """
113
113
114 def __init__(self, color_table=None,out = sys.stdout):
114 def __init__(self, color_table=None,out = sys.stdout):
115 """ Create a parser with a specified color table and output channel.
115 """ Create a parser with a specified color table and output channel.
116
116
117 Call format() to process code.
117 Call format() to process code.
118 """
118 """
119 self.color_table = color_table and color_table or ANSICodeColors
119 self.color_table = color_table and color_table or ANSICodeColors
120 self.out = out
120 self.out = out
121
121
122 def format(self, raw, out = None, scheme = ''):
122 def format(self, raw, out = None, scheme = ''):
123 return self.format2(raw, out, scheme)[0]
123 return self.format2(raw, out, scheme)[0]
124
124
125 def format2(self, raw, out = None, scheme = ''):
125 def format2(self, raw, out = None, scheme = ''):
126 """ Parse and send the colored source.
126 """ Parse and send the colored source.
127
127
128 If out and scheme are not specified, the defaults (given to
128 If out and scheme are not specified, the defaults (given to
129 constructor) are used.
129 constructor) are used.
130
130
131 out should be a file-type object. Optionally, out can be given as the
131 out should be a file-type object. Optionally, out can be given as the
132 string 'str' and the parser will automatically return the output in a
132 string 'str' and the parser will automatically return the output in a
133 string."""
133 string."""
134
134
135 string_output = 0
135 string_output = 0
136 if out == 'str' or self.out == 'str':
136 if out == 'str' or self.out == 'str':
137 out_old = self.out
137 out_old = self.out
138 self.out = cStringIO.StringIO()
138 self.out = cStringIO.StringIO()
139 string_output = 1
139 string_output = 1
140 elif out is not None:
140 elif out is not None:
141 self.out = out
141 self.out = out
142
142
143 # Fast return of the unmodified input for NoColor scheme
143 # Fast return of the unmodified input for NoColor scheme
144 if scheme == 'NoColor':
144 if scheme == 'NoColor':
145 error = False
145 error = False
146 self.out.write(raw)
146 self.out.write(raw)
147 if string_output:
147 if string_output:
148 return raw,error
148 return raw,error
149 else:
149 else:
150 return None,error
150 return None,error
151
151
152 # local shorthands
152 # local shorthands
153 colors = self.color_table[scheme].colors
153 colors = self.color_table[scheme].colors
154 self.colors = colors # put in object so __call__ sees it
154 self.colors = colors # put in object so __call__ sees it
155
155
156 # Remove trailing whitespace and normalize tabs
156 # Remove trailing whitespace and normalize tabs
157 self.raw = raw.expandtabs().rstrip()
157 self.raw = raw.expandtabs().rstrip()
158
158 # store line offsets in self.lines
159 # store line offsets in self.lines
159 self.lines = [0, 0]
160 self.lines = [0, 0]
160 pos = 0
161 pos = 0
161 raw_find = raw.find
162 raw_find = self.raw.find
162 lines_append = self.lines.append
163 lines_append = self.lines.append
163 while 1:
164 while 1:
164 pos = raw_find('\n', pos) + 1
165 pos = raw_find('\n', pos) + 1
165 if not pos: break
166 if not pos: break
166 lines_append(pos)
167 lines_append(pos)
167 lines_append(len(self.raw))
168 lines_append(len(self.raw))
168
169
169 # parse the source and write it
170 # parse the source and write it
170 self.pos = 0
171 self.pos = 0
171 text = cStringIO.StringIO(self.raw)
172 text = cStringIO.StringIO(self.raw)
172
173
173 error = False
174 error = False
174 try:
175 try:
175 tokenize.tokenize(text.readline, self)
176 tokenize.tokenize(text.readline, self)
176 except tokenize.TokenError, ex:
177 except tokenize.TokenError, ex:
177 msg = ex[0]
178 msg = ex[0]
178 line = ex[1][0]
179 line = ex[1][0]
179 self.out.write("%s\n\n*** ERROR: %s%s%s\n" %
180 self.out.write("%s\n\n*** ERROR: %s%s%s\n" %
180 (colors[token.ERRORTOKEN],
181 (colors[token.ERRORTOKEN],
181 msg, self.raw[self.lines[line]:],
182 msg, self.raw[self.lines[line]:],
182 colors.normal)
183 colors.normal)
183 )
184 )
184 error = True
185 error = True
185 self.out.write(colors.normal+'\n')
186 self.out.write(colors.normal+'\n')
186 if string_output:
187 if string_output:
187 output = self.out.getvalue()
188 output = self.out.getvalue()
188 self.out = out_old
189 self.out = out_old
189 return (output, error)
190 return (output, error)
190 return (None, error)
191 return (None, error)
191
192
192 def __call__(self, toktype, toktext, (srow,scol), (erow,ecol), line):
193 def __call__(self, toktype, toktext, (srow,scol), (erow,ecol), line):
193 """ Token handler, with syntax highlighting."""
194 """ Token handler, with syntax highlighting."""
194
195
195 # local shorthands
196 # local shorthands
196 colors = self.colors
197 colors = self.colors
197 owrite = self.out.write
198 owrite = self.out.write
198
199
199 # line separator, so this works across platforms
200 # line separator, so this works across platforms
200 linesep = os.linesep
201 linesep = os.linesep
201
202
202 # calculate new positions
203 # calculate new positions
203 oldpos = self.pos
204 oldpos = self.pos
204 newpos = self.lines[srow] + scol
205 newpos = self.lines[srow] + scol
205 self.pos = newpos + len(toktext)
206 self.pos = newpos + len(toktext)
206
207
207 # handle newlines
208 # handle newlines
208 if toktype in [token.NEWLINE, tokenize.NL]:
209 if toktype in [token.NEWLINE, tokenize.NL]:
209 owrite(linesep)
210 owrite(linesep)
210 return
211 return
211
212
212 # send the original whitespace, if needed
213 # send the original whitespace, if needed
213 if newpos > oldpos:
214 if newpos > oldpos:
214 owrite(self.raw[oldpos:newpos])
215 owrite(self.raw[oldpos:newpos])
215
216
216 # skip indenting tokens
217 # skip indenting tokens
217 if toktype in [token.INDENT, token.DEDENT]:
218 if toktype in [token.INDENT, token.DEDENT]:
218 self.pos = newpos
219 self.pos = newpos
219 return
220 return
220
221
221 # map token type to a color group
222 # map token type to a color group
222 if token.LPAR <= toktype and toktype <= token.OP:
223 if token.LPAR <= toktype and toktype <= token.OP:
223 toktype = token.OP
224 toktype = token.OP
224 elif toktype == token.NAME and keyword.iskeyword(toktext):
225 elif toktype == token.NAME and keyword.iskeyword(toktext):
225 toktype = _KEYWORD
226 toktype = _KEYWORD
226 color = colors.get(toktype, colors[_TEXT])
227 color = colors.get(toktype, colors[_TEXT])
227
228
228 #print '<%s>' % toktext, # dbg
229 #print '<%s>' % toktext, # dbg
229
230
230 # Triple quoted strings must be handled carefully so that backtracking
231 # Triple quoted strings must be handled carefully so that backtracking
231 # in pagers works correctly. We need color terminators on _each_ line.
232 # in pagers works correctly. We need color terminators on _each_ line.
232 if linesep in toktext:
233 if linesep in toktext:
233 toktext = toktext.replace(linesep, '%s%s%s' %
234 toktext = toktext.replace(linesep, '%s%s%s' %
234 (colors.normal,linesep,color))
235 (colors.normal,linesep,color))
235
236
236 # send text
237 # send text
237 owrite('%s%s%s' % (color,toktext,colors.normal))
238 owrite('%s%s%s' % (color,toktext,colors.normal))
238
239
239 def main():
240 def main():
240 """Colorize a python file using ANSI color escapes and print to stdout.
241 """Colorize a python file using ANSI color escapes and print to stdout.
241
242
242 Usage:
243 Usage:
243 %s [-s scheme] filename
244 %s [-s scheme] filename
244
245
245 Options:
246 Options:
246
247
247 -s scheme: give the color scheme to use. Currently only 'Linux'
248 -s scheme: give the color scheme to use. Currently only 'Linux'
248 (default) and 'LightBG' and 'NoColor' are implemented (give without
249 (default) and 'LightBG' and 'NoColor' are implemented (give without
249 quotes). """
250 quotes). """
250
251
251 def usage():
252 def usage():
252 print >> sys.stderr, main.__doc__ % sys.argv[0]
253 print >> sys.stderr, main.__doc__ % sys.argv[0]
253 sys.exit(1)
254 sys.exit(1)
254
255
255 # FIXME: rewrite this to at least use getopt
256 # FIXME: rewrite this to at least use getopt
256 try:
257 try:
257 if sys.argv[1] == '-s':
258 if sys.argv[1] == '-s':
258 scheme_name = sys.argv[2]
259 scheme_name = sys.argv[2]
259 del sys.argv[1:3]
260 del sys.argv[1:3]
260 else:
261 else:
261 scheme_name = _scheme_default
262 scheme_name = _scheme_default
262
263
263 except:
264 except:
264 usage()
265 usage()
265
266
266 try:
267 try:
267 fname = sys.argv[1]
268 fname = sys.argv[1]
268 except:
269 except:
269 usage()
270 usage()
270
271
271 # write colorized version to stdout
272 # write colorized version to stdout
272 parser = Parser()
273 parser = Parser()
273 try:
274 try:
274 parser.format(file(fname).read(),scheme = scheme_name)
275 parser.format(file(fname).read(),scheme = scheme_name)
275 except IOError,msg:
276 except IOError,msg:
276 # if user reads through a pager and quits, don't print traceback
277 # if user reads through a pager and quits, don't print traceback
277 if msg.args != (32,'Broken pipe'):
278 if msg.args != (32,'Broken pipe'):
278 raise
279 raise
279
280
280 if __name__ == "__main__":
281 if __name__ == "__main__":
281 main()
282 main()
@@ -1,2599 +1,2611 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 2221 2007-04-06 02:58:37Z fperez $
9 $Id: iplib.py 2225 2007-04-08 02:48:16Z jdh2358 $
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 Debugger,OInspect,PyColorize,ultraTB
64 from IPython import Debugger,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 # Get system encoding at startup time. Certain terminals (like Emacs
359 # under Win32 have it set to None, and we need to have a known valid
360 # encoding to use in the raw_input() method
361 self.stdin_encoding = sys.stdin.encoding or 'ascii'
362
358 # dict of things NOT to alias (keywords, builtins and some magics)
363 # dict of things NOT to alias (keywords, builtins and some magics)
359 no_alias = {}
364 no_alias = {}
360 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
365 no_alias_magics = ['cd','popd','pushd','dhist','alias','unalias']
361 for key in keyword.kwlist + no_alias_magics:
366 for key in keyword.kwlist + no_alias_magics:
362 no_alias[key] = 1
367 no_alias[key] = 1
363 no_alias.update(__builtin__.__dict__)
368 no_alias.update(__builtin__.__dict__)
364 self.no_alias = no_alias
369 self.no_alias = no_alias
365
370
366 # make global variables for user access to these
371 # make global variables for user access to these
367 self.user_ns['_ih'] = self.input_hist
372 self.user_ns['_ih'] = self.input_hist
368 self.user_ns['_oh'] = self.output_hist
373 self.user_ns['_oh'] = self.output_hist
369 self.user_ns['_dh'] = self.dir_hist
374 self.user_ns['_dh'] = self.dir_hist
370
375
371 # user aliases to input and output histories
376 # user aliases to input and output histories
372 self.user_ns['In'] = self.input_hist
377 self.user_ns['In'] = self.input_hist
373 self.user_ns['Out'] = self.output_hist
378 self.user_ns['Out'] = self.output_hist
374
379
375 # Object variable to store code object waiting execution. This is
380 # Object variable to store code object waiting execution. This is
376 # used mainly by the multithreaded shells, but it can come in handy in
381 # 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
382 # other situations. No need to use a Queue here, since it's a single
378 # item which gets cleared once run.
383 # item which gets cleared once run.
379 self.code_to_run = None
384 self.code_to_run = None
380
385
381 # escapes for automatic behavior on the command line
386 # escapes for automatic behavior on the command line
382 self.ESC_SHELL = '!'
387 self.ESC_SHELL = '!'
383 self.ESC_HELP = '?'
388 self.ESC_HELP = '?'
384 self.ESC_MAGIC = '%'
389 self.ESC_MAGIC = '%'
385 self.ESC_QUOTE = ','
390 self.ESC_QUOTE = ','
386 self.ESC_QUOTE2 = ';'
391 self.ESC_QUOTE2 = ';'
387 self.ESC_PAREN = '/'
392 self.ESC_PAREN = '/'
388
393
389 # And their associated handlers
394 # And their associated handlers
390 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
395 self.esc_handlers = {self.ESC_PAREN : self.handle_auto,
391 self.ESC_QUOTE : self.handle_auto,
396 self.ESC_QUOTE : self.handle_auto,
392 self.ESC_QUOTE2 : self.handle_auto,
397 self.ESC_QUOTE2 : self.handle_auto,
393 self.ESC_MAGIC : self.handle_magic,
398 self.ESC_MAGIC : self.handle_magic,
394 self.ESC_HELP : self.handle_help,
399 self.ESC_HELP : self.handle_help,
395 self.ESC_SHELL : self.handle_shell_escape,
400 self.ESC_SHELL : self.handle_shell_escape,
396 }
401 }
397
402
398 # class initializations
403 # class initializations
399 Magic.__init__(self,self)
404 Magic.__init__(self,self)
400
405
401 # Python source parser/formatter for syntax highlighting
406 # Python source parser/formatter for syntax highlighting
402 pyformat = PyColorize.Parser().format
407 pyformat = PyColorize.Parser().format
403 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
408 self.pycolorize = lambda src: pyformat(src,'str',self.rc['colors'])
404
409
405 # hooks holds pointers used for user-side customizations
410 # hooks holds pointers used for user-side customizations
406 self.hooks = Struct()
411 self.hooks = Struct()
407
412
408 self.strdispatchers = {}
413 self.strdispatchers = {}
409
414
410 # Set all default hooks, defined in the IPython.hooks module.
415 # Set all default hooks, defined in the IPython.hooks module.
411 hooks = IPython.hooks
416 hooks = IPython.hooks
412 for hook_name in hooks.__all__:
417 for hook_name in hooks.__all__:
413 # default hooks have priority 100, i.e. low; user hooks should have 0-100 priority
418 # default hooks have priority 100, i.e. low; user hooks should have
419 # 0-100 priority
414 self.set_hook(hook_name,getattr(hooks,hook_name), 100)
420 self.set_hook(hook_name,getattr(hooks,hook_name), 100)
415 #print "bound hook",hook_name
421 #print "bound hook",hook_name
416
422
417 # Flag to mark unconditional exit
423 # Flag to mark unconditional exit
418 self.exit_now = False
424 self.exit_now = False
419
425
420 self.usage_min = """\
426 self.usage_min = """\
421 An enhanced console for Python.
427 An enhanced console for Python.
422 Some of its features are:
428 Some of its features are:
423 - Readline support if the readline library is present.
429 - Readline support if the readline library is present.
424 - Tab completion in the local namespace.
430 - Tab completion in the local namespace.
425 - Logging of input, see command-line options.
431 - Logging of input, see command-line options.
426 - System shell escape via ! , eg !ls.
432 - System shell escape via ! , eg !ls.
427 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
433 - Magic commands, starting with a % (like %ls, %pwd, %cd, etc.)
428 - Keeps track of locally defined variables via %who, %whos.
434 - Keeps track of locally defined variables via %who, %whos.
429 - Show object information with a ? eg ?x or x? (use ?? for more info).
435 - Show object information with a ? eg ?x or x? (use ?? for more info).
430 """
436 """
431 if usage: self.usage = usage
437 if usage: self.usage = usage
432 else: self.usage = self.usage_min
438 else: self.usage = self.usage_min
433
439
434 # Storage
440 # Storage
435 self.rc = rc # This will hold all configuration information
441 self.rc = rc # This will hold all configuration information
436 self.pager = 'less'
442 self.pager = 'less'
437 # temporary files used for various purposes. Deleted at exit.
443 # temporary files used for various purposes. Deleted at exit.
438 self.tempfiles = []
444 self.tempfiles = []
439
445
440 # Keep track of readline usage (later set by init_readline)
446 # Keep track of readline usage (later set by init_readline)
441 self.has_readline = False
447 self.has_readline = False
442
448
443 # template for logfile headers. It gets resolved at runtime by the
449 # template for logfile headers. It gets resolved at runtime by the
444 # logstart method.
450 # logstart method.
445 self.loghead_tpl = \
451 self.loghead_tpl = \
446 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
452 """#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
447 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
453 #log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
448 #log# opts = %s
454 #log# opts = %s
449 #log# args = %s
455 #log# args = %s
450 #log# It is safe to make manual edits below here.
456 #log# It is safe to make manual edits below here.
451 #log#-----------------------------------------------------------------------
457 #log#-----------------------------------------------------------------------
452 """
458 """
453 # for pushd/popd management
459 # for pushd/popd management
454 try:
460 try:
455 self.home_dir = get_home_dir()
461 self.home_dir = get_home_dir()
456 except HomeDirError,msg:
462 except HomeDirError,msg:
457 fatal(msg)
463 fatal(msg)
458
464
459 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
465 self.dir_stack = [os.getcwd().replace(self.home_dir,'~')]
460
466
461 # Functions to call the underlying shell.
467 # Functions to call the underlying shell.
462
468
463 # The first is similar to os.system, but it doesn't return a value,
469 # 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.
470 # and it allows interpolation of variables in the user's namespace.
465 self.system = lambda cmd: \
471 self.system = lambda cmd: \
466 shell(self.var_expand(cmd,depth=2),
472 shell(self.var_expand(cmd,depth=2),
467 header=self.rc.system_header,
473 header=self.rc.system_header,
468 verbose=self.rc.system_verbose)
474 verbose=self.rc.system_verbose)
469
475
470 # These are for getoutput and getoutputerror:
476 # These are for getoutput and getoutputerror:
471 self.getoutput = lambda cmd: \
477 self.getoutput = lambda cmd: \
472 getoutput(self.var_expand(cmd,depth=2),
478 getoutput(self.var_expand(cmd,depth=2),
473 header=self.rc.system_header,
479 header=self.rc.system_header,
474 verbose=self.rc.system_verbose)
480 verbose=self.rc.system_verbose)
475
481
476 self.getoutputerror = lambda cmd: \
482 self.getoutputerror = lambda cmd: \
477 getoutputerror(self.var_expand(cmd,depth=2),
483 getoutputerror(self.var_expand(cmd,depth=2),
478 header=self.rc.system_header,
484 header=self.rc.system_header,
479 verbose=self.rc.system_verbose)
485 verbose=self.rc.system_verbose)
480
486
481 # RegExp for splitting line contents into pre-char//first
487 # RegExp for splitting line contents into pre-char//first
482 # word-method//rest. For clarity, each group in on one line.
488 # word-method//rest. For clarity, each group in on one line.
483
489
484 # WARNING: update the regexp if the above escapes are changed, as they
490 # WARNING: update the regexp if the above escapes are changed, as they
485 # are hardwired in.
491 # are hardwired in.
486
492
487 # Don't get carried away with trying to make the autocalling catch too
493 # 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
494 # much: it's better to be conservative rather than to trigger hidden
489 # evals() somewhere and end up causing side effects.
495 # evals() somewhere and end up causing side effects.
490 self.line_split = re.compile(r'^(\s*[,;/]?\s*)'
496 self.line_split = re.compile(r'^(\s*[,;/]?\s*)'
491 r'([\?\w\.]+\w*\s*)'
497 r'([\?\w\.]+\w*\s*)'
492 r'(\(?.*$)')
498 r'(\(?.*$)')
493
499
494 self.shell_line_split = re.compile(r'^(\s*)'
500 self.shell_line_split = re.compile(r'^(\s*)'
495 r'(\S*\s*)'
501 r'(\S*\s*)'
496 r'(\(?.*$)')
502 r'(\(?.*$)')
497
503
498
499 # A simpler regexp used as a fallback if the above doesn't work. This
504 # 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
505 # 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
506 # 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
507 # I'm afraid of breaking something; do it once the unit tests are in
503 # place.
508 # place.
504 self.line_split_fallback = re.compile(r'^(\s*)'
509 self.line_split_fallback = re.compile(r'^(\s*)'
505 r'([%\!\?\w\.]*)'
510 r'([%\!\?\w\.]*)'
506 r'(.*)')
511 r'(.*)')
507
512
508 # Original re, keep around for a while in case changes break something
513 # Original re, keep around for a while in case changes break something
509 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
514 #self.line_split = re.compile(r'(^[\s*!\?%,/]?)'
510 # r'(\s*[\?\w\.]+\w*\s*)'
515 # r'(\s*[\?\w\.]+\w*\s*)'
511 # r'(\(?.*$)')
516 # r'(\(?.*$)')
512
517
513 # RegExp to identify potential function names
518 # RegExp to identify potential function names
514 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
519 self.re_fun_name = re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$')
515
520
516 # RegExp to exclude strings with this start from autocalling. In
521 # RegExp to exclude strings with this start from autocalling. In
517 # particular, all binary operators should be excluded, so that if foo
522 # 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
523 # 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
524 # invalid. The characters '!=()' don't need to be checked for, as the
520 # _prefilter routine explicitely does so, to catch direct calls and
525 # _prefilter routine explicitely does so, to catch direct calls and
521 # rebindings of existing names.
526 # rebindings of existing names.
522
527
523 # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise
528 # Warning: the '-' HAS TO BE AT THE END of the first group, otherwise
524 # it affects the rest of the group in square brackets.
529 # it affects the rest of the group in square brackets.
525 self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]'
530 self.re_exclude_auto = re.compile(r'^[<>,&^\|\*/\+-]'
526 '|^is |^not |^in |^and |^or ')
531 '|^is |^not |^in |^and |^or ')
527
532
528 # try to catch also methods for stuff in lists/tuples/dicts: off
533 # try to catch also methods for stuff in lists/tuples/dicts: off
529 # (experimental). For this to work, the line_split regexp would need
534 # (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
535 # 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_.
536 # 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_.\[\]]*) ?$')
537 #self.re_fun_name = re.compile (r'[a-zA-Z_]([a-zA-Z0-9_.\[\]]*) ?$')
533
538
534 # keep track of where we started running (mainly for crash post-mortem)
539 # keep track of where we started running (mainly for crash post-mortem)
535 self.starting_dir = os.getcwd()
540 self.starting_dir = os.getcwd()
536
541
537 # Various switches which can be set
542 # Various switches which can be set
538 self.CACHELENGTH = 5000 # this is cheap, it's just text
543 self.CACHELENGTH = 5000 # this is cheap, it's just text
539 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
544 self.BANNER = "Python %(version)s on %(platform)s\n" % sys.__dict__
540 self.banner2 = banner2
545 self.banner2 = banner2
541
546
542 # TraceBack handlers:
547 # TraceBack handlers:
543
548
544 # Syntax error handler.
549 # Syntax error handler.
545 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
550 self.SyntaxTB = SyntaxTB(color_scheme='NoColor')
546
551
547 # The interactive one is initialized with an offset, meaning we always
552 # 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
553 # want to remove the topmost item in the traceback, which is our own
549 # internal code. Valid modes: ['Plain','Context','Verbose']
554 # internal code. Valid modes: ['Plain','Context','Verbose']
550 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
555 self.InteractiveTB = ultraTB.AutoFormattedTB(mode = 'Plain',
551 color_scheme='NoColor',
556 color_scheme='NoColor',
552 tb_offset = 1)
557 tb_offset = 1)
553
558
554 # IPython itself shouldn't crash. This will produce a detailed
559 # IPython itself shouldn't crash. This will produce a detailed
555 # post-mortem if it does. But we only install the crash handler for
560 # 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
561 # non-threaded shells, the threaded ones use a normal verbose reporter
557 # and lose the crash handler. This is because exceptions in the main
562 # and lose the crash handler. This is because exceptions in the main
558 # thread (such as in GUI code) propagate directly to sys.excepthook,
563 # 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.
564 # and there's no point in printing crash dumps for every user exception.
560 if self.isthreaded:
565 if self.isthreaded:
561 ipCrashHandler = ultraTB.FormattedTB()
566 ipCrashHandler = ultraTB.FormattedTB()
562 else:
567 else:
563 from IPython import CrashHandler
568 from IPython import CrashHandler
564 ipCrashHandler = CrashHandler.IPythonCrashHandler(self)
569 ipCrashHandler = CrashHandler.IPythonCrashHandler(self)
565 self.set_crash_handler(ipCrashHandler)
570 self.set_crash_handler(ipCrashHandler)
566
571
567 # and add any custom exception handlers the user may have specified
572 # and add any custom exception handlers the user may have specified
568 self.set_custom_exc(*custom_exceptions)
573 self.set_custom_exc(*custom_exceptions)
569
574
570 # indentation management
575 # indentation management
571 self.autoindent = False
576 self.autoindent = False
572 self.indent_current_nsp = 0
577 self.indent_current_nsp = 0
573
578
574 # Make some aliases automatically
579 # Make some aliases automatically
575 # Prepare list of shell aliases to auto-define
580 # Prepare list of shell aliases to auto-define
576 if os.name == 'posix':
581 if os.name == 'posix':
577 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
582 auto_alias = ('mkdir mkdir', 'rmdir rmdir',
578 'mv mv -i','rm rm -i','cp cp -i',
583 'mv mv -i','rm rm -i','cp cp -i',
579 'cat cat','less less','clear clear',
584 'cat cat','less less','clear clear',
580 # a better ls
585 # a better ls
581 'ls ls -F',
586 'ls ls -F',
582 # long ls
587 # long ls
583 'll ls -lF')
588 'll ls -lF')
584 # Extra ls aliases with color, which need special treatment on BSD
589 # Extra ls aliases with color, which need special treatment on BSD
585 # variants
590 # variants
586 ls_extra = ( # color ls
591 ls_extra = ( # color ls
587 'lc ls -F -o --color',
592 'lc ls -F -o --color',
588 # ls normal files only
593 # ls normal files only
589 'lf ls -F -o --color %l | grep ^-',
594 'lf ls -F -o --color %l | grep ^-',
590 # ls symbolic links
595 # ls symbolic links
591 'lk ls -F -o --color %l | grep ^l',
596 'lk ls -F -o --color %l | grep ^l',
592 # directories or links to directories,
597 # directories or links to directories,
593 'ldir ls -F -o --color %l | grep /$',
598 'ldir ls -F -o --color %l | grep /$',
594 # things which are executable
599 # things which are executable
595 'lx ls -F -o --color %l | grep ^-..x',
600 'lx ls -F -o --color %l | grep ^-..x',
596 )
601 )
597 # The BSDs don't ship GNU ls, so they don't understand the
602 # The BSDs don't ship GNU ls, so they don't understand the
598 # --color switch out of the box
603 # --color switch out of the box
599 if 'bsd' in sys.platform:
604 if 'bsd' in sys.platform:
600 ls_extra = ( # ls normal files only
605 ls_extra = ( # ls normal files only
601 'lf ls -lF | grep ^-',
606 'lf ls -lF | grep ^-',
602 # ls symbolic links
607 # ls symbolic links
603 'lk ls -lF | grep ^l',
608 'lk ls -lF | grep ^l',
604 # directories or links to directories,
609 # directories or links to directories,
605 'ldir ls -lF | grep /$',
610 'ldir ls -lF | grep /$',
606 # things which are executable
611 # things which are executable
607 'lx ls -lF | grep ^-..x',
612 'lx ls -lF | grep ^-..x',
608 )
613 )
609 auto_alias = auto_alias + ls_extra
614 auto_alias = auto_alias + ls_extra
610 elif os.name in ['nt','dos']:
615 elif os.name in ['nt','dos']:
611 auto_alias = ('dir dir /on', 'ls dir /on',
616 auto_alias = ('dir dir /on', 'ls dir /on',
612 'ddir dir /ad /on', 'ldir dir /ad /on',
617 'ddir dir /ad /on', 'ldir dir /ad /on',
613 'mkdir mkdir','rmdir rmdir','echo echo',
618 'mkdir mkdir','rmdir rmdir','echo echo',
614 'ren ren','cls cls','copy copy')
619 'ren ren','cls cls','copy copy')
615 else:
620 else:
616 auto_alias = ()
621 auto_alias = ()
617 self.auto_alias = [s.split(None,1) for s in auto_alias]
622 self.auto_alias = [s.split(None,1) for s in auto_alias]
618 # Call the actual (public) initializer
623 # Call the actual (public) initializer
619 self.init_auto_alias()
624 self.init_auto_alias()
620
625
621 # Produce a public API instance
626 # Produce a public API instance
622 self.api = IPython.ipapi.IPApi(self)
627 self.api = IPython.ipapi.IPApi(self)
623
628
624 # track which builtins we add, so we can clean up later
629 # track which builtins we add, so we can clean up later
625 self.builtins_added = {}
630 self.builtins_added = {}
626 # This method will add the necessary builtins for operation, but
631 # This method will add the necessary builtins for operation, but
627 # tracking what it did via the builtins_added dict.
632 # tracking what it did via the builtins_added dict.
628 self.add_builtins()
633 self.add_builtins()
629
634
630 # end __init__
635 # end __init__
631
636
632 def var_expand(self,cmd,depth=0):
637 def var_expand(self,cmd,depth=0):
633 """Expand python variables in a string.
638 """Expand python variables in a string.
634
639
635 The depth argument indicates how many frames above the caller should
640 The depth argument indicates how many frames above the caller should
636 be walked to look for the local namespace where to expand variables.
641 be walked to look for the local namespace where to expand variables.
637
642
638 The global namespace for expansion is always the user's interactive
643 The global namespace for expansion is always the user's interactive
639 namespace.
644 namespace.
640 """
645 """
641
646
642 return str(ItplNS(cmd.replace('#','\#'),
647 return str(ItplNS(cmd.replace('#','\#'),
643 self.user_ns, # globals
648 self.user_ns, # globals
644 # Skip our own frame in searching for locals:
649 # Skip our own frame in searching for locals:
645 sys._getframe(depth+1).f_locals # locals
650 sys._getframe(depth+1).f_locals # locals
646 ))
651 ))
647
652
648 def pre_config_initialization(self):
653 def pre_config_initialization(self):
649 """Pre-configuration init method
654 """Pre-configuration init method
650
655
651 This is called before the configuration files are processed to
656 This is called before the configuration files are processed to
652 prepare the services the config files might need.
657 prepare the services the config files might need.
653
658
654 self.rc already has reasonable default values at this point.
659 self.rc already has reasonable default values at this point.
655 """
660 """
656 rc = self.rc
661 rc = self.rc
657
662
658 self.db = pickleshare.PickleShareDB(rc.ipythondir + "/db")
663 self.db = pickleshare.PickleShareDB(rc.ipythondir + "/db")
659
664
660 def post_config_initialization(self):
665 def post_config_initialization(self):
661 """Post configuration init method
666 """Post configuration init method
662
667
663 This is called after the configuration files have been processed to
668 This is called after the configuration files have been processed to
664 'finalize' the initialization."""
669 'finalize' the initialization."""
665
670
666 rc = self.rc
671 rc = self.rc
667
672
668 # Object inspector
673 # Object inspector
669 self.inspector = OInspect.Inspector(OInspect.InspectColors,
674 self.inspector = OInspect.Inspector(OInspect.InspectColors,
670 PyColorize.ANSICodeColors,
675 PyColorize.ANSICodeColors,
671 'NoColor',
676 'NoColor',
672 rc.object_info_string_level)
677 rc.object_info_string_level)
673
678
674 # Load readline proper
679 # Load readline proper
675 if rc.readline:
680 if rc.readline:
676 self.init_readline()
681 self.init_readline()
677
682
678 # local shortcut, this is used a LOT
683 # local shortcut, this is used a LOT
679 self.log = self.logger.log
684 self.log = self.logger.log
680
685
681 # Initialize cache, set in/out prompts and printing system
686 # Initialize cache, set in/out prompts and printing system
682 self.outputcache = CachedOutput(self,
687 self.outputcache = CachedOutput(self,
683 rc.cache_size,
688 rc.cache_size,
684 rc.pprint,
689 rc.pprint,
685 input_sep = rc.separate_in,
690 input_sep = rc.separate_in,
686 output_sep = rc.separate_out,
691 output_sep = rc.separate_out,
687 output_sep2 = rc.separate_out2,
692 output_sep2 = rc.separate_out2,
688 ps1 = rc.prompt_in1,
693 ps1 = rc.prompt_in1,
689 ps2 = rc.prompt_in2,
694 ps2 = rc.prompt_in2,
690 ps_out = rc.prompt_out,
695 ps_out = rc.prompt_out,
691 pad_left = rc.prompts_pad_left)
696 pad_left = rc.prompts_pad_left)
692
697
693 # user may have over-ridden the default print hook:
698 # user may have over-ridden the default print hook:
694 try:
699 try:
695 self.outputcache.__class__.display = self.hooks.display
700 self.outputcache.__class__.display = self.hooks.display
696 except AttributeError:
701 except AttributeError:
697 pass
702 pass
698
703
699 # I don't like assigning globally to sys, because it means when
704 # I don't like assigning globally to sys, because it means when
700 # embedding instances, each embedded instance overrides the previous
705 # embedding instances, each embedded instance overrides the previous
701 # choice. But sys.displayhook seems to be called internally by exec,
706 # 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
707 # so I don't see a way around it. We first save the original and then
703 # overwrite it.
708 # overwrite it.
704 self.sys_displayhook = sys.displayhook
709 self.sys_displayhook = sys.displayhook
705 sys.displayhook = self.outputcache
710 sys.displayhook = self.outputcache
706
711
707 # Set user colors (don't do it in the constructor above so that it
712 # Set user colors (don't do it in the constructor above so that it
708 # doesn't crash if colors option is invalid)
713 # doesn't crash if colors option is invalid)
709 self.magic_colors(rc.colors)
714 self.magic_colors(rc.colors)
710
715
711 # Set calling of pdb on exceptions
716 # Set calling of pdb on exceptions
712 self.call_pdb = rc.pdb
717 self.call_pdb = rc.pdb
713
718
714 # Load user aliases
719 # Load user aliases
715 for alias in rc.alias:
720 for alias in rc.alias:
716 self.magic_alias(alias)
721 self.magic_alias(alias)
717 self.hooks.late_startup_hook()
722 self.hooks.late_startup_hook()
718
723
719 batchrun = False
724 batchrun = False
720 for batchfile in [path(arg) for arg in self.rc.args
725 for batchfile in [path(arg) for arg in self.rc.args
721 if arg.lower().endswith('.ipy')]:
726 if arg.lower().endswith('.ipy')]:
722 if not batchfile.isfile():
727 if not batchfile.isfile():
723 print "No such batch file:", batchfile
728 print "No such batch file:", batchfile
724 continue
729 continue
725 self.api.runlines(batchfile.text())
730 self.api.runlines(batchfile.text())
726 batchrun = True
731 batchrun = True
727 if batchrun:
732 if batchrun:
728 self.exit_now = True
733 self.exit_now = True
729
734
730 def add_builtins(self):
735 def add_builtins(self):
731 """Store ipython references into the builtin namespace.
736 """Store ipython references into the builtin namespace.
732
737
733 Some parts of ipython operate via builtins injected here, which hold a
738 Some parts of ipython operate via builtins injected here, which hold a
734 reference to IPython itself."""
739 reference to IPython itself."""
735
740
736 # TODO: deprecate all except _ip; 'jobs' should be installed
741 # TODO: deprecate all except _ip; 'jobs' should be installed
737 # by an extension and the rest are under _ip, ipalias is redundant
742 # by an extension and the rest are under _ip, ipalias is redundant
738 builtins_new = dict(__IPYTHON__ = self,
743 builtins_new = dict(__IPYTHON__ = self,
739 ip_set_hook = self.set_hook,
744 ip_set_hook = self.set_hook,
740 jobs = self.jobs,
745 jobs = self.jobs,
741 ipmagic = wrap_deprecated(self.ipmagic,'_ip.magic()'),
746 ipmagic = wrap_deprecated(self.ipmagic,'_ip.magic()'),
742 ipalias = wrap_deprecated(self.ipalias),
747 ipalias = wrap_deprecated(self.ipalias),
743 ipsystem = wrap_deprecated(self.ipsystem,'_ip.system()'),
748 ipsystem = wrap_deprecated(self.ipsystem,'_ip.system()'),
744 _ip = self.api
749 _ip = self.api
745 )
750 )
746 for biname,bival in builtins_new.items():
751 for biname,bival in builtins_new.items():
747 try:
752 try:
748 # store the orignal value so we can restore it
753 # store the orignal value so we can restore it
749 self.builtins_added[biname] = __builtin__.__dict__[biname]
754 self.builtins_added[biname] = __builtin__.__dict__[biname]
750 except KeyError:
755 except KeyError:
751 # or mark that it wasn't defined, and we'll just delete it at
756 # or mark that it wasn't defined, and we'll just delete it at
752 # cleanup
757 # cleanup
753 self.builtins_added[biname] = Undefined
758 self.builtins_added[biname] = Undefined
754 __builtin__.__dict__[biname] = bival
759 __builtin__.__dict__[biname] = bival
755
760
756 # Keep in the builtins a flag for when IPython is active. We set it
761 # 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
762 # with setdefault so that multiple nested IPythons don't clobber one
758 # another. Each will increase its value by one upon being activated,
763 # another. Each will increase its value by one upon being activated,
759 # which also gives us a way to determine the nesting level.
764 # which also gives us a way to determine the nesting level.
760 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
765 __builtin__.__dict__.setdefault('__IPYTHON__active',0)
761
766
762 def clean_builtins(self):
767 def clean_builtins(self):
763 """Remove any builtins which might have been added by add_builtins, or
768 """Remove any builtins which might have been added by add_builtins, or
764 restore overwritten ones to their previous values."""
769 restore overwritten ones to their previous values."""
765 for biname,bival in self.builtins_added.items():
770 for biname,bival in self.builtins_added.items():
766 if bival is Undefined:
771 if bival is Undefined:
767 del __builtin__.__dict__[biname]
772 del __builtin__.__dict__[biname]
768 else:
773 else:
769 __builtin__.__dict__[biname] = bival
774 __builtin__.__dict__[biname] = bival
770 self.builtins_added.clear()
775 self.builtins_added.clear()
771
776
772 def set_hook(self,name,hook, priority = 50, str_key = None, re_key = None):
777 def set_hook(self,name,hook, priority = 50, str_key = None, re_key = None):
773 """set_hook(name,hook) -> sets an internal IPython hook.
778 """set_hook(name,hook) -> sets an internal IPython hook.
774
779
775 IPython exposes some of its internal API as user-modifiable hooks. By
780 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
781 adding your function to one of these hooks, you can modify IPython's
777 behavior to call at runtime your own routines."""
782 behavior to call at runtime your own routines."""
778
783
779 # At some point in the future, this should validate the hook before it
784 # 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
785 # accepts it. Probably at least check that the hook takes the number
781 # of args it's supposed to.
786 # of args it's supposed to.
782
787
783 f = new.instancemethod(hook,self,self.__class__)
788 f = new.instancemethod(hook,self,self.__class__)
784
789
785 # check if the hook is for strdispatcher first
790 # check if the hook is for strdispatcher first
786 if str_key is not None:
791 if str_key is not None:
787 sdp = self.strdispatchers.get(name, StrDispatch())
792 sdp = self.strdispatchers.get(name, StrDispatch())
788 sdp.add_s(str_key, f, priority )
793 sdp.add_s(str_key, f, priority )
789 self.strdispatchers[name] = sdp
794 self.strdispatchers[name] = sdp
790 return
795 return
791 if re_key is not None:
796 if re_key is not None:
792 sdp = self.strdispatchers.get(name, StrDispatch())
797 sdp = self.strdispatchers.get(name, StrDispatch())
793 sdp.add_re(re.compile(re_key), f, priority )
798 sdp.add_re(re.compile(re_key), f, priority )
794 self.strdispatchers[name] = sdp
799 self.strdispatchers[name] = sdp
795 return
800 return
796
801
797 dp = getattr(self.hooks, name, None)
802 dp = getattr(self.hooks, name, None)
798 if name not in IPython.hooks.__all__:
803 if name not in IPython.hooks.__all__:
799 print "Warning! Hook '%s' is not one of %s" % (name, IPython.hooks.__all__ )
804 print "Warning! Hook '%s' is not one of %s" % (name, IPython.hooks.__all__ )
800 if not dp:
805 if not dp:
801 dp = IPython.hooks.CommandChainDispatcher()
806 dp = IPython.hooks.CommandChainDispatcher()
802
807
803 try:
808 try:
804 dp.add(f,priority)
809 dp.add(f,priority)
805 except AttributeError:
810 except AttributeError:
806 # it was not commandchain, plain old func - replace
811 # it was not commandchain, plain old func - replace
807 dp = f
812 dp = f
808
813
809 setattr(self.hooks,name, dp)
814 setattr(self.hooks,name, dp)
810
815
811
816
812 #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
817 #setattr(self.hooks,name,new.instancemethod(hook,self,self.__class__))
813
818
814 def set_crash_handler(self,crashHandler):
819 def set_crash_handler(self,crashHandler):
815 """Set the IPython crash handler.
820 """Set the IPython crash handler.
816
821
817 This must be a callable with a signature suitable for use as
822 This must be a callable with a signature suitable for use as
818 sys.excepthook."""
823 sys.excepthook."""
819
824
820 # Install the given crash handler as the Python exception hook
825 # Install the given crash handler as the Python exception hook
821 sys.excepthook = crashHandler
826 sys.excepthook = crashHandler
822
827
823 # The instance will store a pointer to this, so that runtime code
828 # The instance will store a pointer to this, so that runtime code
824 # (such as magics) can access it. This is because during the
829 # (such as magics) can access it. This is because during the
825 # read-eval loop, it gets temporarily overwritten (to deal with GUI
830 # read-eval loop, it gets temporarily overwritten (to deal with GUI
826 # frameworks).
831 # frameworks).
827 self.sys_excepthook = sys.excepthook
832 self.sys_excepthook = sys.excepthook
828
833
829
834
830 def set_custom_exc(self,exc_tuple,handler):
835 def set_custom_exc(self,exc_tuple,handler):
831 """set_custom_exc(exc_tuple,handler)
836 """set_custom_exc(exc_tuple,handler)
832
837
833 Set a custom exception handler, which will be called if any of the
838 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
839 exceptions in exc_tuple occur in the mainloop (specifically, in the
835 runcode() method.
840 runcode() method.
836
841
837 Inputs:
842 Inputs:
838
843
839 - exc_tuple: a *tuple* of valid exceptions to call the defined
844 - 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
845 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
846 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:
847 you only want to trap a single exception, use a singleton tuple:
843
848
844 exc_tuple == (MyCustomException,)
849 exc_tuple == (MyCustomException,)
845
850
846 - handler: this must be defined as a function with the following
851 - handler: this must be defined as a function with the following
847 basic interface: def my_handler(self,etype,value,tb).
852 basic interface: def my_handler(self,etype,value,tb).
848
853
849 This will be made into an instance method (via new.instancemethod)
854 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
855 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
856 listed in the exc_tuple are caught. If the handler is None, an
852 internal basic one is used, which just prints basic info.
857 internal basic one is used, which just prints basic info.
853
858
854 WARNING: by putting in your own exception handler into IPython's main
859 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
860 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."""
861 facility should only be used if you really know what you are doing."""
857
862
858 assert type(exc_tuple)==type(()) , \
863 assert type(exc_tuple)==type(()) , \
859 "The custom exceptions must be given AS A TUPLE."
864 "The custom exceptions must be given AS A TUPLE."
860
865
861 def dummy_handler(self,etype,value,tb):
866 def dummy_handler(self,etype,value,tb):
862 print '*** Simple custom exception handler ***'
867 print '*** Simple custom exception handler ***'
863 print 'Exception type :',etype
868 print 'Exception type :',etype
864 print 'Exception value:',value
869 print 'Exception value:',value
865 print 'Traceback :',tb
870 print 'Traceback :',tb
866 print 'Source code :','\n'.join(self.buffer)
871 print 'Source code :','\n'.join(self.buffer)
867
872
868 if handler is None: handler = dummy_handler
873 if handler is None: handler = dummy_handler
869
874
870 self.CustomTB = new.instancemethod(handler,self,self.__class__)
875 self.CustomTB = new.instancemethod(handler,self,self.__class__)
871 self.custom_exceptions = exc_tuple
876 self.custom_exceptions = exc_tuple
872
877
873 def set_custom_completer(self,completer,pos=0):
878 def set_custom_completer(self,completer,pos=0):
874 """set_custom_completer(completer,pos=0)
879 """set_custom_completer(completer,pos=0)
875
880
876 Adds a new custom completer function.
881 Adds a new custom completer function.
877
882
878 The position argument (defaults to 0) is the index in the completers
883 The position argument (defaults to 0) is the index in the completers
879 list where you want the completer to be inserted."""
884 list where you want the completer to be inserted."""
880
885
881 newcomp = new.instancemethod(completer,self.Completer,
886 newcomp = new.instancemethod(completer,self.Completer,
882 self.Completer.__class__)
887 self.Completer.__class__)
883 self.Completer.matchers.insert(pos,newcomp)
888 self.Completer.matchers.insert(pos,newcomp)
884
889
885 def set_completer(self):
890 def set_completer(self):
886 """reset readline's completer to be our own."""
891 """reset readline's completer to be our own."""
887 self.readline.set_completer(self.Completer.complete)
892 self.readline.set_completer(self.Completer.complete)
888
893
889 def _get_call_pdb(self):
894 def _get_call_pdb(self):
890 return self._call_pdb
895 return self._call_pdb
891
896
892 def _set_call_pdb(self,val):
897 def _set_call_pdb(self,val):
893
898
894 if val not in (0,1,False,True):
899 if val not in (0,1,False,True):
895 raise ValueError,'new call_pdb value must be boolean'
900 raise ValueError,'new call_pdb value must be boolean'
896
901
897 # store value in instance
902 # store value in instance
898 self._call_pdb = val
903 self._call_pdb = val
899
904
900 # notify the actual exception handlers
905 # notify the actual exception handlers
901 self.InteractiveTB.call_pdb = val
906 self.InteractiveTB.call_pdb = val
902 if self.isthreaded:
907 if self.isthreaded:
903 try:
908 try:
904 self.sys_excepthook.call_pdb = val
909 self.sys_excepthook.call_pdb = val
905 except:
910 except:
906 warn('Failed to activate pdb for threaded exception handler')
911 warn('Failed to activate pdb for threaded exception handler')
907
912
908 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
913 call_pdb = property(_get_call_pdb,_set_call_pdb,None,
909 'Control auto-activation of pdb at exceptions')
914 'Control auto-activation of pdb at exceptions')
910
915
911
916
912 # These special functions get installed in the builtin namespace, to
917 # These special functions get installed in the builtin namespace, to
913 # provide programmatic (pure python) access to magics, aliases and system
918 # provide programmatic (pure python) access to magics, aliases and system
914 # calls. This is important for logging, user scripting, and more.
919 # calls. This is important for logging, user scripting, and more.
915
920
916 # We are basically exposing, via normal python functions, the three
921 # We are basically exposing, via normal python functions, the three
917 # mechanisms in which ipython offers special call modes (magics for
922 # mechanisms in which ipython offers special call modes (magics for
918 # internal control, aliases for direct system access via pre-selected
923 # internal control, aliases for direct system access via pre-selected
919 # names, and !cmd for calling arbitrary system commands).
924 # names, and !cmd for calling arbitrary system commands).
920
925
921 def ipmagic(self,arg_s):
926 def ipmagic(self,arg_s):
922 """Call a magic function by name.
927 """Call a magic function by name.
923
928
924 Input: a string containing the name of the magic function to call and any
929 Input: a string containing the name of the magic function to call and any
925 additional arguments to be passed to the magic.
930 additional arguments to be passed to the magic.
926
931
927 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
932 ipmagic('name -opt foo bar') is equivalent to typing at the ipython
928 prompt:
933 prompt:
929
934
930 In[1]: %name -opt foo bar
935 In[1]: %name -opt foo bar
931
936
932 To call a magic without arguments, simply use ipmagic('name').
937 To call a magic without arguments, simply use ipmagic('name').
933
938
934 This provides a proper Python function to call IPython's magics in any
939 This provides a proper Python function to call IPython's magics in any
935 valid Python code you can type at the interpreter, including loops and
940 valid Python code you can type at the interpreter, including loops and
936 compound statements. It is added by IPython to the Python builtin
941 compound statements. It is added by IPython to the Python builtin
937 namespace upon initialization."""
942 namespace upon initialization."""
938
943
939 args = arg_s.split(' ',1)
944 args = arg_s.split(' ',1)
940 magic_name = args[0]
945 magic_name = args[0]
941 magic_name = magic_name.lstrip(self.ESC_MAGIC)
946 magic_name = magic_name.lstrip(self.ESC_MAGIC)
942
947
943 try:
948 try:
944 magic_args = args[1]
949 magic_args = args[1]
945 except IndexError:
950 except IndexError:
946 magic_args = ''
951 magic_args = ''
947 fn = getattr(self,'magic_'+magic_name,None)
952 fn = getattr(self,'magic_'+magic_name,None)
948 if fn is None:
953 if fn is None:
949 error("Magic function `%s` not found." % magic_name)
954 error("Magic function `%s` not found." % magic_name)
950 else:
955 else:
951 magic_args = self.var_expand(magic_args,1)
956 magic_args = self.var_expand(magic_args,1)
952 return fn(magic_args)
957 return fn(magic_args)
953
958
954 def ipalias(self,arg_s):
959 def ipalias(self,arg_s):
955 """Call an alias by name.
960 """Call an alias by name.
956
961
957 Input: a string containing the name of the alias to call and any
962 Input: a string containing the name of the alias to call and any
958 additional arguments to be passed to the magic.
963 additional arguments to be passed to the magic.
959
964
960 ipalias('name -opt foo bar') is equivalent to typing at the ipython
965 ipalias('name -opt foo bar') is equivalent to typing at the ipython
961 prompt:
966 prompt:
962
967
963 In[1]: name -opt foo bar
968 In[1]: name -opt foo bar
964
969
965 To call an alias without arguments, simply use ipalias('name').
970 To call an alias without arguments, simply use ipalias('name').
966
971
967 This provides a proper Python function to call IPython's aliases in any
972 This provides a proper Python function to call IPython's aliases in any
968 valid Python code you can type at the interpreter, including loops and
973 valid Python code you can type at the interpreter, including loops and
969 compound statements. It is added by IPython to the Python builtin
974 compound statements. It is added by IPython to the Python builtin
970 namespace upon initialization."""
975 namespace upon initialization."""
971
976
972 args = arg_s.split(' ',1)
977 args = arg_s.split(' ',1)
973 alias_name = args[0]
978 alias_name = args[0]
974 try:
979 try:
975 alias_args = args[1]
980 alias_args = args[1]
976 except IndexError:
981 except IndexError:
977 alias_args = ''
982 alias_args = ''
978 if alias_name in self.alias_table:
983 if alias_name in self.alias_table:
979 self.call_alias(alias_name,alias_args)
984 self.call_alias(alias_name,alias_args)
980 else:
985 else:
981 error("Alias `%s` not found." % alias_name)
986 error("Alias `%s` not found." % alias_name)
982
987
983 def ipsystem(self,arg_s):
988 def ipsystem(self,arg_s):
984 """Make a system call, using IPython."""
989 """Make a system call, using IPython."""
985
990
986 self.system(arg_s)
991 self.system(arg_s)
987
992
988 def complete(self,text):
993 def complete(self,text):
989 """Return a sorted list of all possible completions on text.
994 """Return a sorted list of all possible completions on text.
990
995
991 Inputs:
996 Inputs:
992
997
993 - text: a string of text to be completed on.
998 - text: a string of text to be completed on.
994
999
995 This is a wrapper around the completion mechanism, similar to what
1000 This is a wrapper around the completion mechanism, similar to what
996 readline does at the command line when the TAB key is hit. By
1001 readline does at the command line when the TAB key is hit. By
997 exposing it as a method, it can be used by other non-readline
1002 exposing it as a method, it can be used by other non-readline
998 environments (such as GUIs) for text completion.
1003 environments (such as GUIs) for text completion.
999
1004
1000 Simple usage example:
1005 Simple usage example:
1001
1006
1002 In [1]: x = 'hello'
1007 In [1]: x = 'hello'
1003
1008
1004 In [2]: __IP.complete('x.l')
1009 In [2]: __IP.complete('x.l')
1005 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
1010 Out[2]: ['x.ljust', 'x.lower', 'x.lstrip']"""
1006
1011
1007 complete = self.Completer.complete
1012 complete = self.Completer.complete
1008 state = 0
1013 state = 0
1009 # use a dict so we get unique keys, since ipyhton's multiple
1014 # use a dict so we get unique keys, since ipyhton's multiple
1010 # completers can return duplicates. When we make 2.4 a requirement,
1015 # completers can return duplicates. When we make 2.4 a requirement,
1011 # start using sets instead, which are faster.
1016 # start using sets instead, which are faster.
1012 comps = {}
1017 comps = {}
1013 while True:
1018 while True:
1014 newcomp = complete(text,state,line_buffer=text)
1019 newcomp = complete(text,state,line_buffer=text)
1015 if newcomp is None:
1020 if newcomp is None:
1016 break
1021 break
1017 comps[newcomp] = 1
1022 comps[newcomp] = 1
1018 state += 1
1023 state += 1
1019 outcomps = comps.keys()
1024 outcomps = comps.keys()
1020 outcomps.sort()
1025 outcomps.sort()
1021 return outcomps
1026 return outcomps
1022
1027
1023 def set_completer_frame(self, frame=None):
1028 def set_completer_frame(self, frame=None):
1024 if frame:
1029 if frame:
1025 self.Completer.namespace = frame.f_locals
1030 self.Completer.namespace = frame.f_locals
1026 self.Completer.global_namespace = frame.f_globals
1031 self.Completer.global_namespace = frame.f_globals
1027 else:
1032 else:
1028 self.Completer.namespace = self.user_ns
1033 self.Completer.namespace = self.user_ns
1029 self.Completer.global_namespace = self.user_global_ns
1034 self.Completer.global_namespace = self.user_global_ns
1030
1035
1031 def init_auto_alias(self):
1036 def init_auto_alias(self):
1032 """Define some aliases automatically.
1037 """Define some aliases automatically.
1033
1038
1034 These are ALL parameter-less aliases"""
1039 These are ALL parameter-less aliases"""
1035
1040
1036 for alias,cmd in self.auto_alias:
1041 for alias,cmd in self.auto_alias:
1037 self.alias_table[alias] = (0,cmd)
1042 self.alias_table[alias] = (0,cmd)
1038
1043
1039 def alias_table_validate(self,verbose=0):
1044 def alias_table_validate(self,verbose=0):
1040 """Update information about the alias table.
1045 """Update information about the alias table.
1041
1046
1042 In particular, make sure no Python keywords/builtins are in it."""
1047 In particular, make sure no Python keywords/builtins are in it."""
1043
1048
1044 no_alias = self.no_alias
1049 no_alias = self.no_alias
1045 for k in self.alias_table.keys():
1050 for k in self.alias_table.keys():
1046 if k in no_alias:
1051 if k in no_alias:
1047 del self.alias_table[k]
1052 del self.alias_table[k]
1048 if verbose:
1053 if verbose:
1049 print ("Deleting alias <%s>, it's a Python "
1054 print ("Deleting alias <%s>, it's a Python "
1050 "keyword or builtin." % k)
1055 "keyword or builtin." % k)
1051
1056
1052 def set_autoindent(self,value=None):
1057 def set_autoindent(self,value=None):
1053 """Set the autoindent flag, checking for readline support.
1058 """Set the autoindent flag, checking for readline support.
1054
1059
1055 If called with no arguments, it acts as a toggle."""
1060 If called with no arguments, it acts as a toggle."""
1056
1061
1057 if not self.has_readline:
1062 if not self.has_readline:
1058 if os.name == 'posix':
1063 if os.name == 'posix':
1059 warn("The auto-indent feature requires the readline library")
1064 warn("The auto-indent feature requires the readline library")
1060 self.autoindent = 0
1065 self.autoindent = 0
1061 return
1066 return
1062 if value is None:
1067 if value is None:
1063 self.autoindent = not self.autoindent
1068 self.autoindent = not self.autoindent
1064 else:
1069 else:
1065 self.autoindent = value
1070 self.autoindent = value
1066
1071
1067 def rc_set_toggle(self,rc_field,value=None):
1072 def rc_set_toggle(self,rc_field,value=None):
1068 """Set or toggle a field in IPython's rc config. structure.
1073 """Set or toggle a field in IPython's rc config. structure.
1069
1074
1070 If called with no arguments, it acts as a toggle.
1075 If called with no arguments, it acts as a toggle.
1071
1076
1072 If called with a non-existent field, the resulting AttributeError
1077 If called with a non-existent field, the resulting AttributeError
1073 exception will propagate out."""
1078 exception will propagate out."""
1074
1079
1075 rc_val = getattr(self.rc,rc_field)
1080 rc_val = getattr(self.rc,rc_field)
1076 if value is None:
1081 if value is None:
1077 value = not rc_val
1082 value = not rc_val
1078 setattr(self.rc,rc_field,value)
1083 setattr(self.rc,rc_field,value)
1079
1084
1080 def user_setup(self,ipythondir,rc_suffix,mode='install'):
1085 def user_setup(self,ipythondir,rc_suffix,mode='install'):
1081 """Install the user configuration directory.
1086 """Install the user configuration directory.
1082
1087
1083 Can be called when running for the first time or to upgrade the user's
1088 Can be called when running for the first time or to upgrade the user's
1084 .ipython/ directory with the mode parameter. Valid modes are 'install'
1089 .ipython/ directory with the mode parameter. Valid modes are 'install'
1085 and 'upgrade'."""
1090 and 'upgrade'."""
1086
1091
1087 def wait():
1092 def wait():
1088 try:
1093 try:
1089 raw_input("Please press <RETURN> to start IPython.")
1094 raw_input("Please press <RETURN> to start IPython.")
1090 except EOFError:
1095 except EOFError:
1091 print >> Term.cout
1096 print >> Term.cout
1092 print '*'*70
1097 print '*'*70
1093
1098
1094 cwd = os.getcwd() # remember where we started
1099 cwd = os.getcwd() # remember where we started
1095 glb = glob.glob
1100 glb = glob.glob
1096 print '*'*70
1101 print '*'*70
1097 if mode == 'install':
1102 if mode == 'install':
1098 print \
1103 print \
1099 """Welcome to IPython. I will try to create a personal configuration directory
1104 """Welcome to IPython. I will try to create a personal configuration directory
1100 where you can customize many aspects of IPython's functionality in:\n"""
1105 where you can customize many aspects of IPython's functionality in:\n"""
1101 else:
1106 else:
1102 print 'I am going to upgrade your configuration in:'
1107 print 'I am going to upgrade your configuration in:'
1103
1108
1104 print ipythondir
1109 print ipythondir
1105
1110
1106 rcdirend = os.path.join('IPython','UserConfig')
1111 rcdirend = os.path.join('IPython','UserConfig')
1107 cfg = lambda d: os.path.join(d,rcdirend)
1112 cfg = lambda d: os.path.join(d,rcdirend)
1108 try:
1113 try:
1109 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1114 rcdir = filter(os.path.isdir,map(cfg,sys.path))[0]
1110 except IOError:
1115 except IOError:
1111 warning = """
1116 warning = """
1112 Installation error. IPython's directory was not found.
1117 Installation error. IPython's directory was not found.
1113
1118
1114 Check the following:
1119 Check the following:
1115
1120
1116 The ipython/IPython directory should be in a directory belonging to your
1121 The ipython/IPython directory should be in a directory belonging to your
1117 PYTHONPATH environment variable (that is, it should be in a directory
1122 PYTHONPATH environment variable (that is, it should be in a directory
1118 belonging to sys.path). You can copy it explicitly there or just link to it.
1123 belonging to sys.path). You can copy it explicitly there or just link to it.
1119
1124
1120 IPython will proceed with builtin defaults.
1125 IPython will proceed with builtin defaults.
1121 """
1126 """
1122 warn(warning)
1127 warn(warning)
1123 wait()
1128 wait()
1124 return
1129 return
1125
1130
1126 if mode == 'install':
1131 if mode == 'install':
1127 try:
1132 try:
1128 shutil.copytree(rcdir,ipythondir)
1133 shutil.copytree(rcdir,ipythondir)
1129 os.chdir(ipythondir)
1134 os.chdir(ipythondir)
1130 rc_files = glb("ipythonrc*")
1135 rc_files = glb("ipythonrc*")
1131 for rc_file in rc_files:
1136 for rc_file in rc_files:
1132 os.rename(rc_file,rc_file+rc_suffix)
1137 os.rename(rc_file,rc_file+rc_suffix)
1133 except:
1138 except:
1134 warning = """
1139 warning = """
1135
1140
1136 There was a problem with the installation:
1141 There was a problem with the installation:
1137 %s
1142 %s
1138 Try to correct it or contact the developers if you think it's a bug.
1143 Try to correct it or contact the developers if you think it's a bug.
1139 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1144 IPython will proceed with builtin defaults.""" % sys.exc_info()[1]
1140 warn(warning)
1145 warn(warning)
1141 wait()
1146 wait()
1142 return
1147 return
1143
1148
1144 elif mode == 'upgrade':
1149 elif mode == 'upgrade':
1145 try:
1150 try:
1146 os.chdir(ipythondir)
1151 os.chdir(ipythondir)
1147 except:
1152 except:
1148 print """
1153 print """
1149 Can not upgrade: changing to directory %s failed. Details:
1154 Can not upgrade: changing to directory %s failed. Details:
1150 %s
1155 %s
1151 """ % (ipythondir,sys.exc_info()[1])
1156 """ % (ipythondir,sys.exc_info()[1])
1152 wait()
1157 wait()
1153 return
1158 return
1154 else:
1159 else:
1155 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1160 sources = glb(os.path.join(rcdir,'[A-Za-z]*'))
1156 for new_full_path in sources:
1161 for new_full_path in sources:
1157 new_filename = os.path.basename(new_full_path)
1162 new_filename = os.path.basename(new_full_path)
1158 if new_filename.startswith('ipythonrc'):
1163 if new_filename.startswith('ipythonrc'):
1159 new_filename = new_filename + rc_suffix
1164 new_filename = new_filename + rc_suffix
1160 # The config directory should only contain files, skip any
1165 # The config directory should only contain files, skip any
1161 # directories which may be there (like CVS)
1166 # directories which may be there (like CVS)
1162 if os.path.isdir(new_full_path):
1167 if os.path.isdir(new_full_path):
1163 continue
1168 continue
1164 if os.path.exists(new_filename):
1169 if os.path.exists(new_filename):
1165 old_file = new_filename+'.old'
1170 old_file = new_filename+'.old'
1166 if os.path.exists(old_file):
1171 if os.path.exists(old_file):
1167 os.remove(old_file)
1172 os.remove(old_file)
1168 os.rename(new_filename,old_file)
1173 os.rename(new_filename,old_file)
1169 shutil.copy(new_full_path,new_filename)
1174 shutil.copy(new_full_path,new_filename)
1170 else:
1175 else:
1171 raise ValueError,'unrecognized mode for install:',`mode`
1176 raise ValueError,'unrecognized mode for install:',`mode`
1172
1177
1173 # Fix line-endings to those native to each platform in the config
1178 # Fix line-endings to those native to each platform in the config
1174 # directory.
1179 # directory.
1175 try:
1180 try:
1176 os.chdir(ipythondir)
1181 os.chdir(ipythondir)
1177 except:
1182 except:
1178 print """
1183 print """
1179 Problem: changing to directory %s failed.
1184 Problem: changing to directory %s failed.
1180 Details:
1185 Details:
1181 %s
1186 %s
1182
1187
1183 Some configuration files may have incorrect line endings. This should not
1188 Some configuration files may have incorrect line endings. This should not
1184 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1189 cause any problems during execution. """ % (ipythondir,sys.exc_info()[1])
1185 wait()
1190 wait()
1186 else:
1191 else:
1187 for fname in glb('ipythonrc*'):
1192 for fname in glb('ipythonrc*'):
1188 try:
1193 try:
1189 native_line_ends(fname,backup=0)
1194 native_line_ends(fname,backup=0)
1190 except IOError:
1195 except IOError:
1191 pass
1196 pass
1192
1197
1193 if mode == 'install':
1198 if mode == 'install':
1194 print """
1199 print """
1195 Successful installation!
1200 Successful installation!
1196
1201
1197 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1202 Please read the sections 'Initial Configuration' and 'Quick Tips' in the
1198 IPython manual (there are both HTML and PDF versions supplied with the
1203 IPython manual (there are both HTML and PDF versions supplied with the
1199 distribution) to make sure that your system environment is properly configured
1204 distribution) to make sure that your system environment is properly configured
1200 to take advantage of IPython's features.
1205 to take advantage of IPython's features.
1201
1206
1202 Important note: the configuration system has changed! The old system is
1207 Important note: the configuration system has changed! The old system is
1203 still in place, but its setting may be partly overridden by the settings in
1208 still in place, but its setting may be partly overridden by the settings in
1204 "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file
1209 "~/.ipython/ipy_user_conf.py" config file. Please take a look at the file
1205 if some of the new settings bother you.
1210 if some of the new settings bother you.
1206
1211
1207 """
1212 """
1208 else:
1213 else:
1209 print """
1214 print """
1210 Successful upgrade!
1215 Successful upgrade!
1211
1216
1212 All files in your directory:
1217 All files in your directory:
1213 %(ipythondir)s
1218 %(ipythondir)s
1214 which would have been overwritten by the upgrade were backed up with a .old
1219 which would have been overwritten by the upgrade were backed up with a .old
1215 extension. If you had made particular customizations in those files you may
1220 extension. If you had made particular customizations in those files you may
1216 want to merge them back into the new files.""" % locals()
1221 want to merge them back into the new files.""" % locals()
1217 wait()
1222 wait()
1218 os.chdir(cwd)
1223 os.chdir(cwd)
1219 # end user_setup()
1224 # end user_setup()
1220
1225
1221 def atexit_operations(self):
1226 def atexit_operations(self):
1222 """This will be executed at the time of exit.
1227 """This will be executed at the time of exit.
1223
1228
1224 Saving of persistent data should be performed here. """
1229 Saving of persistent data should be performed here. """
1225
1230
1226 #print '*** IPython exit cleanup ***' # dbg
1231 #print '*** IPython exit cleanup ***' # dbg
1227 # input history
1232 # input history
1228 self.savehist()
1233 self.savehist()
1229
1234
1230 # Cleanup all tempfiles left around
1235 # Cleanup all tempfiles left around
1231 for tfile in self.tempfiles:
1236 for tfile in self.tempfiles:
1232 try:
1237 try:
1233 os.unlink(tfile)
1238 os.unlink(tfile)
1234 except OSError:
1239 except OSError:
1235 pass
1240 pass
1236
1241
1237 # save the "persistent data" catch-all dictionary
1242 # save the "persistent data" catch-all dictionary
1238 self.hooks.shutdown_hook()
1243 self.hooks.shutdown_hook()
1239
1244
1240 def savehist(self):
1245 def savehist(self):
1241 """Save input history to a file (via readline library)."""
1246 """Save input history to a file (via readline library)."""
1242 try:
1247 try:
1243 self.readline.write_history_file(self.histfile)
1248 self.readline.write_history_file(self.histfile)
1244 except:
1249 except:
1245 print 'Unable to save IPython command history to file: ' + \
1250 print 'Unable to save IPython command history to file: ' + \
1246 `self.histfile`
1251 `self.histfile`
1247
1252
1253 def reloadhist(self):
1254 """Reload the input history from disk file."""
1255
1256 if self.has_readline:
1257 self.readline.clear_history()
1258 self.readline.read_history_file(self.shell.histfile)
1259
1248 def history_saving_wrapper(self, func):
1260 def history_saving_wrapper(self, func):
1249 """ Wrap func for readline history saving
1261 """ Wrap func for readline history saving
1250
1262
1251 Convert func into callable that saves & restores
1263 Convert func into callable that saves & restores
1252 history around the call """
1264 history around the call """
1253
1265
1254 if not self.has_readline:
1266 if not self.has_readline:
1255 return func
1267 return func
1256
1268
1257 def wrapper():
1269 def wrapper():
1258 self.savehist()
1270 self.savehist()
1259 try:
1271 try:
1260 func()
1272 func()
1261 finally:
1273 finally:
1262 readline.read_history_file(self.histfile)
1274 readline.read_history_file(self.histfile)
1263 return wrapper
1275 return wrapper
1264
1276
1265
1277
1266 def pre_readline(self):
1278 def pre_readline(self):
1267 """readline hook to be used at the start of each line.
1279 """readline hook to be used at the start of each line.
1268
1280
1269 Currently it handles auto-indent only."""
1281 Currently it handles auto-indent only."""
1270
1282
1271 #debugx('self.indent_current_nsp','pre_readline:')
1283 #debugx('self.indent_current_nsp','pre_readline:')
1272 self.readline.insert_text(self.indent_current_str())
1284 self.readline.insert_text(self.indent_current_str())
1273
1285
1274 def init_readline(self):
1286 def init_readline(self):
1275 """Command history completion/saving/reloading."""
1287 """Command history completion/saving/reloading."""
1276
1288
1277 import IPython.rlineimpl as readline
1289 import IPython.rlineimpl as readline
1278 if not readline.have_readline:
1290 if not readline.have_readline:
1279 self.has_readline = 0
1291 self.has_readline = 0
1280 self.readline = None
1292 self.readline = None
1281 # no point in bugging windows users with this every time:
1293 # no point in bugging windows users with this every time:
1282 warn('Readline services not available on this platform.')
1294 warn('Readline services not available on this platform.')
1283 else:
1295 else:
1284 sys.modules['readline'] = readline
1296 sys.modules['readline'] = readline
1285 import atexit
1297 import atexit
1286 from IPython.completer import IPCompleter
1298 from IPython.completer import IPCompleter
1287 self.Completer = IPCompleter(self,
1299 self.Completer = IPCompleter(self,
1288 self.user_ns,
1300 self.user_ns,
1289 self.user_global_ns,
1301 self.user_global_ns,
1290 self.rc.readline_omit__names,
1302 self.rc.readline_omit__names,
1291 self.alias_table)
1303 self.alias_table)
1292 sdisp = self.strdispatchers.get('complete_command', StrDispatch())
1304 sdisp = self.strdispatchers.get('complete_command', StrDispatch())
1293 self.strdispatchers['complete_command'] = sdisp
1305 self.strdispatchers['complete_command'] = sdisp
1294 self.Completer.custom_completers = sdisp
1306 self.Completer.custom_completers = sdisp
1295 # Platform-specific configuration
1307 # Platform-specific configuration
1296 if os.name == 'nt':
1308 if os.name == 'nt':
1297 self.readline_startup_hook = readline.set_pre_input_hook
1309 self.readline_startup_hook = readline.set_pre_input_hook
1298 else:
1310 else:
1299 self.readline_startup_hook = readline.set_startup_hook
1311 self.readline_startup_hook = readline.set_startup_hook
1300
1312
1301 # Load user's initrc file (readline config)
1313 # Load user's initrc file (readline config)
1302 inputrc_name = os.environ.get('INPUTRC')
1314 inputrc_name = os.environ.get('INPUTRC')
1303 if inputrc_name is None:
1315 if inputrc_name is None:
1304 home_dir = get_home_dir()
1316 home_dir = get_home_dir()
1305 if home_dir is not None:
1317 if home_dir is not None:
1306 inputrc_name = os.path.join(home_dir,'.inputrc')
1318 inputrc_name = os.path.join(home_dir,'.inputrc')
1307 if os.path.isfile(inputrc_name):
1319 if os.path.isfile(inputrc_name):
1308 try:
1320 try:
1309 readline.read_init_file(inputrc_name)
1321 readline.read_init_file(inputrc_name)
1310 except:
1322 except:
1311 warn('Problems reading readline initialization file <%s>'
1323 warn('Problems reading readline initialization file <%s>'
1312 % inputrc_name)
1324 % inputrc_name)
1313
1325
1314 self.has_readline = 1
1326 self.has_readline = 1
1315 self.readline = readline
1327 self.readline = readline
1316 # save this in sys so embedded copies can restore it properly
1328 # save this in sys so embedded copies can restore it properly
1317 sys.ipcompleter = self.Completer.complete
1329 sys.ipcompleter = self.Completer.complete
1318 self.set_completer()
1330 self.set_completer()
1319
1331
1320 # Configure readline according to user's prefs
1332 # Configure readline according to user's prefs
1321 for rlcommand in self.rc.readline_parse_and_bind:
1333 for rlcommand in self.rc.readline_parse_and_bind:
1322 readline.parse_and_bind(rlcommand)
1334 readline.parse_and_bind(rlcommand)
1323
1335
1324 # remove some chars from the delimiters list
1336 # remove some chars from the delimiters list
1325 delims = readline.get_completer_delims()
1337 delims = readline.get_completer_delims()
1326 delims = delims.translate(string._idmap,
1338 delims = delims.translate(string._idmap,
1327 self.rc.readline_remove_delims)
1339 self.rc.readline_remove_delims)
1328 readline.set_completer_delims(delims)
1340 readline.set_completer_delims(delims)
1329 # otherwise we end up with a monster history after a while:
1341 # otherwise we end up with a monster history after a while:
1330 readline.set_history_length(1000)
1342 readline.set_history_length(1000)
1331 try:
1343 try:
1332 #print '*** Reading readline history' # dbg
1344 #print '*** Reading readline history' # dbg
1333 readline.read_history_file(self.histfile)
1345 readline.read_history_file(self.histfile)
1334 except IOError:
1346 except IOError:
1335 pass # It doesn't exist yet.
1347 pass # It doesn't exist yet.
1336
1348
1337 atexit.register(self.atexit_operations)
1349 atexit.register(self.atexit_operations)
1338 del atexit
1350 del atexit
1339
1351
1340 # Configure auto-indent for all platforms
1352 # Configure auto-indent for all platforms
1341 self.set_autoindent(self.rc.autoindent)
1353 self.set_autoindent(self.rc.autoindent)
1342
1354
1343 def ask_yes_no(self,prompt,default=True):
1355 def ask_yes_no(self,prompt,default=True):
1344 if self.rc.quiet:
1356 if self.rc.quiet:
1345 return True
1357 return True
1346 return ask_yes_no(prompt,default)
1358 return ask_yes_no(prompt,default)
1347
1359
1348 def _should_recompile(self,e):
1360 def _should_recompile(self,e):
1349 """Utility routine for edit_syntax_error"""
1361 """Utility routine for edit_syntax_error"""
1350
1362
1351 if e.filename in ('<ipython console>','<input>','<string>',
1363 if e.filename in ('<ipython console>','<input>','<string>',
1352 '<console>','<BackgroundJob compilation>',
1364 '<console>','<BackgroundJob compilation>',
1353 None):
1365 None):
1354
1366
1355 return False
1367 return False
1356 try:
1368 try:
1357 if (self.rc.autoedit_syntax and
1369 if (self.rc.autoedit_syntax and
1358 not self.ask_yes_no('Return to editor to correct syntax error? '
1370 not self.ask_yes_no('Return to editor to correct syntax error? '
1359 '[Y/n] ','y')):
1371 '[Y/n] ','y')):
1360 return False
1372 return False
1361 except EOFError:
1373 except EOFError:
1362 return False
1374 return False
1363
1375
1364 def int0(x):
1376 def int0(x):
1365 try:
1377 try:
1366 return int(x)
1378 return int(x)
1367 except TypeError:
1379 except TypeError:
1368 return 0
1380 return 0
1369 # always pass integer line and offset values to editor hook
1381 # always pass integer line and offset values to editor hook
1370 self.hooks.fix_error_editor(e.filename,
1382 self.hooks.fix_error_editor(e.filename,
1371 int0(e.lineno),int0(e.offset),e.msg)
1383 int0(e.lineno),int0(e.offset),e.msg)
1372 return True
1384 return True
1373
1385
1374 def edit_syntax_error(self):
1386 def edit_syntax_error(self):
1375 """The bottom half of the syntax error handler called in the main loop.
1387 """The bottom half of the syntax error handler called in the main loop.
1376
1388
1377 Loop until syntax error is fixed or user cancels.
1389 Loop until syntax error is fixed or user cancels.
1378 """
1390 """
1379
1391
1380 while self.SyntaxTB.last_syntax_error:
1392 while self.SyntaxTB.last_syntax_error:
1381 # copy and clear last_syntax_error
1393 # copy and clear last_syntax_error
1382 err = self.SyntaxTB.clear_err_state()
1394 err = self.SyntaxTB.clear_err_state()
1383 if not self._should_recompile(err):
1395 if not self._should_recompile(err):
1384 return
1396 return
1385 try:
1397 try:
1386 # may set last_syntax_error again if a SyntaxError is raised
1398 # may set last_syntax_error again if a SyntaxError is raised
1387 self.safe_execfile(err.filename,self.user_ns)
1399 self.safe_execfile(err.filename,self.user_ns)
1388 except:
1400 except:
1389 self.showtraceback()
1401 self.showtraceback()
1390 else:
1402 else:
1391 try:
1403 try:
1392 f = file(err.filename)
1404 f = file(err.filename)
1393 try:
1405 try:
1394 sys.displayhook(f.read())
1406 sys.displayhook(f.read())
1395 finally:
1407 finally:
1396 f.close()
1408 f.close()
1397 except:
1409 except:
1398 self.showtraceback()
1410 self.showtraceback()
1399
1411
1400 def showsyntaxerror(self, filename=None):
1412 def showsyntaxerror(self, filename=None):
1401 """Display the syntax error that just occurred.
1413 """Display the syntax error that just occurred.
1402
1414
1403 This doesn't display a stack trace because there isn't one.
1415 This doesn't display a stack trace because there isn't one.
1404
1416
1405 If a filename is given, it is stuffed in the exception instead
1417 If a filename is given, it is stuffed in the exception instead
1406 of what was there before (because Python's parser always uses
1418 of what was there before (because Python's parser always uses
1407 "<string>" when reading from a string).
1419 "<string>" when reading from a string).
1408 """
1420 """
1409 etype, value, last_traceback = sys.exc_info()
1421 etype, value, last_traceback = sys.exc_info()
1410
1422
1411 # See note about these variables in showtraceback() below
1423 # See note about these variables in showtraceback() below
1412 sys.last_type = etype
1424 sys.last_type = etype
1413 sys.last_value = value
1425 sys.last_value = value
1414 sys.last_traceback = last_traceback
1426 sys.last_traceback = last_traceback
1415
1427
1416 if filename and etype is SyntaxError:
1428 if filename and etype is SyntaxError:
1417 # Work hard to stuff the correct filename in the exception
1429 # Work hard to stuff the correct filename in the exception
1418 try:
1430 try:
1419 msg, (dummy_filename, lineno, offset, line) = value
1431 msg, (dummy_filename, lineno, offset, line) = value
1420 except:
1432 except:
1421 # Not the format we expect; leave it alone
1433 # Not the format we expect; leave it alone
1422 pass
1434 pass
1423 else:
1435 else:
1424 # Stuff in the right filename
1436 # Stuff in the right filename
1425 try:
1437 try:
1426 # Assume SyntaxError is a class exception
1438 # Assume SyntaxError is a class exception
1427 value = SyntaxError(msg, (filename, lineno, offset, line))
1439 value = SyntaxError(msg, (filename, lineno, offset, line))
1428 except:
1440 except:
1429 # If that failed, assume SyntaxError is a string
1441 # If that failed, assume SyntaxError is a string
1430 value = msg, (filename, lineno, offset, line)
1442 value = msg, (filename, lineno, offset, line)
1431 self.SyntaxTB(etype,value,[])
1443 self.SyntaxTB(etype,value,[])
1432
1444
1433 def debugger(self,force=False):
1445 def debugger(self,force=False):
1434 """Call the pydb/pdb debugger.
1446 """Call the pydb/pdb debugger.
1435
1447
1436 Keywords:
1448 Keywords:
1437
1449
1438 - force(False): by default, this routine checks the instance call_pdb
1450 - force(False): by default, this routine checks the instance call_pdb
1439 flag and does not actually invoke the debugger if the flag is false.
1451 flag and does not actually invoke the debugger if the flag is false.
1440 The 'force' option forces the debugger to activate even if the flag
1452 The 'force' option forces the debugger to activate even if the flag
1441 is false.
1453 is false.
1442 """
1454 """
1443
1455
1444 if not (force or self.call_pdb):
1456 if not (force or self.call_pdb):
1445 return
1457 return
1446
1458
1447 if not hasattr(sys,'last_traceback'):
1459 if not hasattr(sys,'last_traceback'):
1448 error('No traceback has been produced, nothing to debug.')
1460 error('No traceback has been produced, nothing to debug.')
1449 return
1461 return
1450
1462
1451 # use pydb if available
1463 # use pydb if available
1452 if Debugger.has_pydb:
1464 if Debugger.has_pydb:
1453 from pydb import pm
1465 from pydb import pm
1454 else:
1466 else:
1455 # fallback to our internal debugger
1467 # fallback to our internal debugger
1456 pm = lambda : self.InteractiveTB.debugger(force=True)
1468 pm = lambda : self.InteractiveTB.debugger(force=True)
1457 self.history_saving_wrapper(pm)()
1469 self.history_saving_wrapper(pm)()
1458
1470
1459 def showtraceback(self,exc_tuple = None,filename=None,tb_offset=None):
1471 def showtraceback(self,exc_tuple = None,filename=None,tb_offset=None):
1460 """Display the exception that just occurred.
1472 """Display the exception that just occurred.
1461
1473
1462 If nothing is known about the exception, this is the method which
1474 If nothing is known about the exception, this is the method which
1463 should be used throughout the code for presenting user tracebacks,
1475 should be used throughout the code for presenting user tracebacks,
1464 rather than directly invoking the InteractiveTB object.
1476 rather than directly invoking the InteractiveTB object.
1465
1477
1466 A specific showsyntaxerror() also exists, but this method can take
1478 A specific showsyntaxerror() also exists, but this method can take
1467 care of calling it if needed, so unless you are explicitly catching a
1479 care of calling it if needed, so unless you are explicitly catching a
1468 SyntaxError exception, don't try to analyze the stack manually and
1480 SyntaxError exception, don't try to analyze the stack manually and
1469 simply call this method."""
1481 simply call this method."""
1470
1482
1471 # Though this won't be called by syntax errors in the input line,
1483 # Though this won't be called by syntax errors in the input line,
1472 # there may be SyntaxError cases whith imported code.
1484 # there may be SyntaxError cases whith imported code.
1473 if exc_tuple is None:
1485 if exc_tuple is None:
1474 etype, value, tb = sys.exc_info()
1486 etype, value, tb = sys.exc_info()
1475 else:
1487 else:
1476 etype, value, tb = exc_tuple
1488 etype, value, tb = exc_tuple
1477
1489
1478 if etype is SyntaxError:
1490 if etype is SyntaxError:
1479 self.showsyntaxerror(filename)
1491 self.showsyntaxerror(filename)
1480 else:
1492 else:
1481 # WARNING: these variables are somewhat deprecated and not
1493 # WARNING: these variables are somewhat deprecated and not
1482 # necessarily safe to use in a threaded environment, but tools
1494 # necessarily safe to use in a threaded environment, but tools
1483 # like pdb depend on their existence, so let's set them. If we
1495 # like pdb depend on their existence, so let's set them. If we
1484 # find problems in the field, we'll need to revisit their use.
1496 # find problems in the field, we'll need to revisit their use.
1485 sys.last_type = etype
1497 sys.last_type = etype
1486 sys.last_value = value
1498 sys.last_value = value
1487 sys.last_traceback = tb
1499 sys.last_traceback = tb
1488
1500
1489 if etype in self.custom_exceptions:
1501 if etype in self.custom_exceptions:
1490 self.CustomTB(etype,value,tb)
1502 self.CustomTB(etype,value,tb)
1491 else:
1503 else:
1492 self.InteractiveTB(etype,value,tb,tb_offset=tb_offset)
1504 self.InteractiveTB(etype,value,tb,tb_offset=tb_offset)
1493 if self.InteractiveTB.call_pdb and self.has_readline:
1505 if self.InteractiveTB.call_pdb and self.has_readline:
1494 # pdb mucks up readline, fix it back
1506 # pdb mucks up readline, fix it back
1495 self.set_completer()
1507 self.set_completer()
1496
1508
1497 def mainloop(self,banner=None):
1509 def mainloop(self,banner=None):
1498 """Creates the local namespace and starts the mainloop.
1510 """Creates the local namespace and starts the mainloop.
1499
1511
1500 If an optional banner argument is given, it will override the
1512 If an optional banner argument is given, it will override the
1501 internally created default banner."""
1513 internally created default banner."""
1502
1514
1503 if self.rc.c: # Emulate Python's -c option
1515 if self.rc.c: # Emulate Python's -c option
1504 self.exec_init_cmd()
1516 self.exec_init_cmd()
1505 if banner is None:
1517 if banner is None:
1506 if not self.rc.banner:
1518 if not self.rc.banner:
1507 banner = ''
1519 banner = ''
1508 # banner is string? Use it directly!
1520 # banner is string? Use it directly!
1509 elif isinstance(self.rc.banner,basestring):
1521 elif isinstance(self.rc.banner,basestring):
1510 banner = self.rc.banner
1522 banner = self.rc.banner
1511 else:
1523 else:
1512 banner = self.BANNER+self.banner2
1524 banner = self.BANNER+self.banner2
1513
1525
1514 self.interact(banner)
1526 self.interact(banner)
1515
1527
1516 def exec_init_cmd(self):
1528 def exec_init_cmd(self):
1517 """Execute a command given at the command line.
1529 """Execute a command given at the command line.
1518
1530
1519 This emulates Python's -c option."""
1531 This emulates Python's -c option."""
1520
1532
1521 #sys.argv = ['-c']
1533 #sys.argv = ['-c']
1522 self.push(self.rc.c)
1534 self.push(self.rc.c)
1523
1535
1524 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1536 def embed_mainloop(self,header='',local_ns=None,global_ns=None,stack_depth=0):
1525 """Embeds IPython into a running python program.
1537 """Embeds IPython into a running python program.
1526
1538
1527 Input:
1539 Input:
1528
1540
1529 - header: An optional header message can be specified.
1541 - header: An optional header message can be specified.
1530
1542
1531 - local_ns, global_ns: working namespaces. If given as None, the
1543 - local_ns, global_ns: working namespaces. If given as None, the
1532 IPython-initialized one is updated with __main__.__dict__, so that
1544 IPython-initialized one is updated with __main__.__dict__, so that
1533 program variables become visible but user-specific configuration
1545 program variables become visible but user-specific configuration
1534 remains possible.
1546 remains possible.
1535
1547
1536 - stack_depth: specifies how many levels in the stack to go to
1548 - stack_depth: specifies how many levels in the stack to go to
1537 looking for namespaces (when local_ns and global_ns are None). This
1549 looking for namespaces (when local_ns and global_ns are None). This
1538 allows an intermediate caller to make sure that this function gets
1550 allows an intermediate caller to make sure that this function gets
1539 the namespace from the intended level in the stack. By default (0)
1551 the namespace from the intended level in the stack. By default (0)
1540 it will get its locals and globals from the immediate caller.
1552 it will get its locals and globals from the immediate caller.
1541
1553
1542 Warning: it's possible to use this in a program which is being run by
1554 Warning: it's possible to use this in a program which is being run by
1543 IPython itself (via %run), but some funny things will happen (a few
1555 IPython itself (via %run), but some funny things will happen (a few
1544 globals get overwritten). In the future this will be cleaned up, as
1556 globals get overwritten). In the future this will be cleaned up, as
1545 there is no fundamental reason why it can't work perfectly."""
1557 there is no fundamental reason why it can't work perfectly."""
1546
1558
1547 # Get locals and globals from caller
1559 # Get locals and globals from caller
1548 if local_ns is None or global_ns is None:
1560 if local_ns is None or global_ns is None:
1549 call_frame = sys._getframe(stack_depth).f_back
1561 call_frame = sys._getframe(stack_depth).f_back
1550
1562
1551 if local_ns is None:
1563 if local_ns is None:
1552 local_ns = call_frame.f_locals
1564 local_ns = call_frame.f_locals
1553 if global_ns is None:
1565 if global_ns is None:
1554 global_ns = call_frame.f_globals
1566 global_ns = call_frame.f_globals
1555
1567
1556 # Update namespaces and fire up interpreter
1568 # Update namespaces and fire up interpreter
1557
1569
1558 # The global one is easy, we can just throw it in
1570 # The global one is easy, we can just throw it in
1559 self.user_global_ns = global_ns
1571 self.user_global_ns = global_ns
1560
1572
1561 # but the user/local one is tricky: ipython needs it to store internal
1573 # but the user/local one is tricky: ipython needs it to store internal
1562 # data, but we also need the locals. We'll copy locals in the user
1574 # data, but we also need the locals. We'll copy locals in the user
1563 # one, but will track what got copied so we can delete them at exit.
1575 # one, but will track what got copied so we can delete them at exit.
1564 # This is so that a later embedded call doesn't see locals from a
1576 # This is so that a later embedded call doesn't see locals from a
1565 # previous call (which most likely existed in a separate scope).
1577 # previous call (which most likely existed in a separate scope).
1566 local_varnames = local_ns.keys()
1578 local_varnames = local_ns.keys()
1567 self.user_ns.update(local_ns)
1579 self.user_ns.update(local_ns)
1568
1580
1569 # Patch for global embedding to make sure that things don't overwrite
1581 # Patch for global embedding to make sure that things don't overwrite
1570 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1582 # user globals accidentally. Thanks to Richard <rxe@renre-europe.com>
1571 # FIXME. Test this a bit more carefully (the if.. is new)
1583 # FIXME. Test this a bit more carefully (the if.. is new)
1572 if local_ns is None and global_ns is None:
1584 if local_ns is None and global_ns is None:
1573 self.user_global_ns.update(__main__.__dict__)
1585 self.user_global_ns.update(__main__.__dict__)
1574
1586
1575 # make sure the tab-completer has the correct frame information, so it
1587 # make sure the tab-completer has the correct frame information, so it
1576 # actually completes using the frame's locals/globals
1588 # actually completes using the frame's locals/globals
1577 self.set_completer_frame()
1589 self.set_completer_frame()
1578
1590
1579 # before activating the interactive mode, we need to make sure that
1591 # before activating the interactive mode, we need to make sure that
1580 # all names in the builtin namespace needed by ipython point to
1592 # all names in the builtin namespace needed by ipython point to
1581 # ourselves, and not to other instances.
1593 # ourselves, and not to other instances.
1582 self.add_builtins()
1594 self.add_builtins()
1583
1595
1584 self.interact(header)
1596 self.interact(header)
1585
1597
1586 # now, purge out the user namespace from anything we might have added
1598 # now, purge out the user namespace from anything we might have added
1587 # from the caller's local namespace
1599 # from the caller's local namespace
1588 delvar = self.user_ns.pop
1600 delvar = self.user_ns.pop
1589 for var in local_varnames:
1601 for var in local_varnames:
1590 delvar(var,None)
1602 delvar(var,None)
1591 # and clean builtins we may have overridden
1603 # and clean builtins we may have overridden
1592 self.clean_builtins()
1604 self.clean_builtins()
1593
1605
1594 def interact(self, banner=None):
1606 def interact(self, banner=None):
1595 """Closely emulate the interactive Python console.
1607 """Closely emulate the interactive Python console.
1596
1608
1597 The optional banner argument specify the banner to print
1609 The optional banner argument specify the banner to print
1598 before the first interaction; by default it prints a banner
1610 before the first interaction; by default it prints a banner
1599 similar to the one printed by the real Python interpreter,
1611 similar to the one printed by the real Python interpreter,
1600 followed by the current class name in parentheses (so as not
1612 followed by the current class name in parentheses (so as not
1601 to confuse this with the real interpreter -- since it's so
1613 to confuse this with the real interpreter -- since it's so
1602 close!).
1614 close!).
1603
1615
1604 """
1616 """
1605
1617
1606 if self.exit_now:
1618 if self.exit_now:
1607 # batch run -> do not interact
1619 # batch run -> do not interact
1608 return
1620 return
1609 cprt = 'Type "copyright", "credits" or "license" for more information.'
1621 cprt = 'Type "copyright", "credits" or "license" for more information.'
1610 if banner is None:
1622 if banner is None:
1611 self.write("Python %s on %s\n%s\n(%s)\n" %
1623 self.write("Python %s on %s\n%s\n(%s)\n" %
1612 (sys.version, sys.platform, cprt,
1624 (sys.version, sys.platform, cprt,
1613 self.__class__.__name__))
1625 self.__class__.__name__))
1614 else:
1626 else:
1615 self.write(banner)
1627 self.write(banner)
1616
1628
1617 more = 0
1629 more = 0
1618
1630
1619 # Mark activity in the builtins
1631 # Mark activity in the builtins
1620 __builtin__.__dict__['__IPYTHON__active'] += 1
1632 __builtin__.__dict__['__IPYTHON__active'] += 1
1621
1633
1622 # exit_now is set by a call to %Exit or %Quit
1634 # exit_now is set by a call to %Exit or %Quit
1623 while not self.exit_now:
1635 while not self.exit_now:
1624 if more:
1636 if more:
1625 prompt = self.hooks.generate_prompt(True)
1637 prompt = self.hooks.generate_prompt(True)
1626 if self.autoindent:
1638 if self.autoindent:
1627 self.readline_startup_hook(self.pre_readline)
1639 self.readline_startup_hook(self.pre_readline)
1628 else:
1640 else:
1629 prompt = self.hooks.generate_prompt(False)
1641 prompt = self.hooks.generate_prompt(False)
1630 try:
1642 try:
1631 line = self.raw_input(prompt,more)
1643 line = self.raw_input(prompt,more)
1632 if self.exit_now:
1644 if self.exit_now:
1633 # quick exit on sys.std[in|out] close
1645 # quick exit on sys.std[in|out] close
1634 break
1646 break
1635 if self.autoindent:
1647 if self.autoindent:
1636 self.readline_startup_hook(None)
1648 self.readline_startup_hook(None)
1637 except KeyboardInterrupt:
1649 except KeyboardInterrupt:
1638 self.write('\nKeyboardInterrupt\n')
1650 self.write('\nKeyboardInterrupt\n')
1639 self.resetbuffer()
1651 self.resetbuffer()
1640 # keep cache in sync with the prompt counter:
1652 # keep cache in sync with the prompt counter:
1641 self.outputcache.prompt_count -= 1
1653 self.outputcache.prompt_count -= 1
1642
1654
1643 if self.autoindent:
1655 if self.autoindent:
1644 self.indent_current_nsp = 0
1656 self.indent_current_nsp = 0
1645 more = 0
1657 more = 0
1646 except EOFError:
1658 except EOFError:
1647 if self.autoindent:
1659 if self.autoindent:
1648 self.readline_startup_hook(None)
1660 self.readline_startup_hook(None)
1649 self.write('\n')
1661 self.write('\n')
1650 self.exit()
1662 self.exit()
1651 except bdb.BdbQuit:
1663 except bdb.BdbQuit:
1652 warn('The Python debugger has exited with a BdbQuit exception.\n'
1664 warn('The Python debugger has exited with a BdbQuit exception.\n'
1653 'Because of how pdb handles the stack, it is impossible\n'
1665 'Because of how pdb handles the stack, it is impossible\n'
1654 'for IPython to properly format this particular exception.\n'
1666 'for IPython to properly format this particular exception.\n'
1655 'IPython will resume normal operation.')
1667 'IPython will resume normal operation.')
1656 except:
1668 except:
1657 # exceptions here are VERY RARE, but they can be triggered
1669 # exceptions here are VERY RARE, but they can be triggered
1658 # asynchronously by signal handlers, for example.
1670 # asynchronously by signal handlers, for example.
1659 self.showtraceback()
1671 self.showtraceback()
1660 else:
1672 else:
1661 more = self.push(line)
1673 more = self.push(line)
1662 if (self.SyntaxTB.last_syntax_error and
1674 if (self.SyntaxTB.last_syntax_error and
1663 self.rc.autoedit_syntax):
1675 self.rc.autoedit_syntax):
1664 self.edit_syntax_error()
1676 self.edit_syntax_error()
1665
1677
1666 # We are off again...
1678 # We are off again...
1667 __builtin__.__dict__['__IPYTHON__active'] -= 1
1679 __builtin__.__dict__['__IPYTHON__active'] -= 1
1668
1680
1669 def excepthook(self, etype, value, tb):
1681 def excepthook(self, etype, value, tb):
1670 """One more defense for GUI apps that call sys.excepthook.
1682 """One more defense for GUI apps that call sys.excepthook.
1671
1683
1672 GUI frameworks like wxPython trap exceptions and call
1684 GUI frameworks like wxPython trap exceptions and call
1673 sys.excepthook themselves. I guess this is a feature that
1685 sys.excepthook themselves. I guess this is a feature that
1674 enables them to keep running after exceptions that would
1686 enables them to keep running after exceptions that would
1675 otherwise kill their mainloop. This is a bother for IPython
1687 otherwise kill their mainloop. This is a bother for IPython
1676 which excepts to catch all of the program exceptions with a try:
1688 which excepts to catch all of the program exceptions with a try:
1677 except: statement.
1689 except: statement.
1678
1690
1679 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1691 Normally, IPython sets sys.excepthook to a CrashHandler instance, so if
1680 any app directly invokes sys.excepthook, it will look to the user like
1692 any app directly invokes sys.excepthook, it will look to the user like
1681 IPython crashed. In order to work around this, we can disable the
1693 IPython crashed. In order to work around this, we can disable the
1682 CrashHandler and replace it with this excepthook instead, which prints a
1694 CrashHandler and replace it with this excepthook instead, which prints a
1683 regular traceback using our InteractiveTB. In this fashion, apps which
1695 regular traceback using our InteractiveTB. In this fashion, apps which
1684 call sys.excepthook will generate a regular-looking exception from
1696 call sys.excepthook will generate a regular-looking exception from
1685 IPython, and the CrashHandler will only be triggered by real IPython
1697 IPython, and the CrashHandler will only be triggered by real IPython
1686 crashes.
1698 crashes.
1687
1699
1688 This hook should be used sparingly, only in places which are not likely
1700 This hook should be used sparingly, only in places which are not likely
1689 to be true IPython errors.
1701 to be true IPython errors.
1690 """
1702 """
1691 self.showtraceback((etype,value,tb),tb_offset=0)
1703 self.showtraceback((etype,value,tb),tb_offset=0)
1692
1704
1693 def expand_aliases(self,fn,rest):
1705 def expand_aliases(self,fn,rest):
1694 """ Expand multiple levels of aliases:
1706 """ Expand multiple levels of aliases:
1695
1707
1696 if:
1708 if:
1697
1709
1698 alias foo bar /tmp
1710 alias foo bar /tmp
1699 alias baz foo
1711 alias baz foo
1700
1712
1701 then:
1713 then:
1702
1714
1703 baz huhhahhei -> bar /tmp huhhahhei
1715 baz huhhahhei -> bar /tmp huhhahhei
1704
1716
1705 """
1717 """
1706 line = fn + " " + rest
1718 line = fn + " " + rest
1707
1719
1708 done = Set()
1720 done = Set()
1709 while 1:
1721 while 1:
1710 pre,fn,rest = self.split_user_input(line, pattern = self.shell_line_split)
1722 pre,fn,rest = self.split_user_input(line, pattern = self.shell_line_split)
1711 # print "!",fn,"!",rest # dbg
1723 # print "!",fn,"!",rest # dbg
1712 if fn in self.alias_table:
1724 if fn in self.alias_table:
1713 if fn in done:
1725 if fn in done:
1714 warn("Cyclic alias definition, repeated '%s'" % fn)
1726 warn("Cyclic alias definition, repeated '%s'" % fn)
1715 return ""
1727 return ""
1716 done.add(fn)
1728 done.add(fn)
1717
1729
1718 l2 = self.transform_alias(fn,rest)
1730 l2 = self.transform_alias(fn,rest)
1719 # dir -> dir
1731 # dir -> dir
1720 # print "alias",line, "->",l2 #dbg
1732 # print "alias",line, "->",l2 #dbg
1721 if l2 == line:
1733 if l2 == line:
1722 break
1734 break
1723 # ls -> ls -F should not recurse forever
1735 # ls -> ls -F should not recurse forever
1724 if l2.split(None,1)[0] == line.split(None,1)[0]:
1736 if l2.split(None,1)[0] == line.split(None,1)[0]:
1725 line = l2
1737 line = l2
1726 break
1738 break
1727
1739
1728 line=l2
1740 line=l2
1729
1741
1730
1742
1731 # print "al expand to",line #dbg
1743 # print "al expand to",line #dbg
1732 else:
1744 else:
1733 break
1745 break
1734
1746
1735 return line
1747 return line
1736
1748
1737 def transform_alias(self, alias,rest=''):
1749 def transform_alias(self, alias,rest=''):
1738 """ Transform alias to system command string.
1750 """ Transform alias to system command string.
1739 """
1751 """
1740 nargs,cmd = self.alias_table[alias]
1752 nargs,cmd = self.alias_table[alias]
1741 if ' ' in cmd and os.path.isfile(cmd):
1753 if ' ' in cmd and os.path.isfile(cmd):
1742 cmd = '"%s"' % cmd
1754 cmd = '"%s"' % cmd
1743
1755
1744 # Expand the %l special to be the user's input line
1756 # Expand the %l special to be the user's input line
1745 if cmd.find('%l') >= 0:
1757 if cmd.find('%l') >= 0:
1746 cmd = cmd.replace('%l',rest)
1758 cmd = cmd.replace('%l',rest)
1747 rest = ''
1759 rest = ''
1748 if nargs==0:
1760 if nargs==0:
1749 # Simple, argument-less aliases
1761 # Simple, argument-less aliases
1750 cmd = '%s %s' % (cmd,rest)
1762 cmd = '%s %s' % (cmd,rest)
1751 else:
1763 else:
1752 # Handle aliases with positional arguments
1764 # Handle aliases with positional arguments
1753 args = rest.split(None,nargs)
1765 args = rest.split(None,nargs)
1754 if len(args)< nargs:
1766 if len(args)< nargs:
1755 error('Alias <%s> requires %s arguments, %s given.' %
1767 error('Alias <%s> requires %s arguments, %s given.' %
1756 (alias,nargs,len(args)))
1768 (alias,nargs,len(args)))
1757 return None
1769 return None
1758 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1770 cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:]))
1759 # Now call the macro, evaluating in the user's namespace
1771 # Now call the macro, evaluating in the user's namespace
1760 #print 'new command: <%r>' % cmd # dbg
1772 #print 'new command: <%r>' % cmd # dbg
1761 return cmd
1773 return cmd
1762
1774
1763 def call_alias(self,alias,rest=''):
1775 def call_alias(self,alias,rest=''):
1764 """Call an alias given its name and the rest of the line.
1776 """Call an alias given its name and the rest of the line.
1765
1777
1766 This is only used to provide backwards compatibility for users of
1778 This is only used to provide backwards compatibility for users of
1767 ipalias(), use of which is not recommended for anymore."""
1779 ipalias(), use of which is not recommended for anymore."""
1768
1780
1769 # Now call the macro, evaluating in the user's namespace
1781 # Now call the macro, evaluating in the user's namespace
1770 cmd = self.transform_alias(alias, rest)
1782 cmd = self.transform_alias(alias, rest)
1771 try:
1783 try:
1772 self.system(cmd)
1784 self.system(cmd)
1773 except:
1785 except:
1774 self.showtraceback()
1786 self.showtraceback()
1775
1787
1776 def indent_current_str(self):
1788 def indent_current_str(self):
1777 """return the current level of indentation as a string"""
1789 """return the current level of indentation as a string"""
1778 return self.indent_current_nsp * ' '
1790 return self.indent_current_nsp * ' '
1779
1791
1780 def autoindent_update(self,line):
1792 def autoindent_update(self,line):
1781 """Keep track of the indent level."""
1793 """Keep track of the indent level."""
1782
1794
1783 #debugx('line')
1795 #debugx('line')
1784 #debugx('self.indent_current_nsp')
1796 #debugx('self.indent_current_nsp')
1785 if self.autoindent:
1797 if self.autoindent:
1786 if line:
1798 if line:
1787 inisp = num_ini_spaces(line)
1799 inisp = num_ini_spaces(line)
1788 if inisp < self.indent_current_nsp:
1800 if inisp < self.indent_current_nsp:
1789 self.indent_current_nsp = inisp
1801 self.indent_current_nsp = inisp
1790
1802
1791 if line[-1] == ':':
1803 if line[-1] == ':':
1792 self.indent_current_nsp += 4
1804 self.indent_current_nsp += 4
1793 elif dedent_re.match(line):
1805 elif dedent_re.match(line):
1794 self.indent_current_nsp -= 4
1806 self.indent_current_nsp -= 4
1795 else:
1807 else:
1796 self.indent_current_nsp = 0
1808 self.indent_current_nsp = 0
1797
1809
1798 def runlines(self,lines):
1810 def runlines(self,lines):
1799 """Run a string of one or more lines of source.
1811 """Run a string of one or more lines of source.
1800
1812
1801 This method is capable of running a string containing multiple source
1813 This method is capable of running a string containing multiple source
1802 lines, as if they had been entered at the IPython prompt. Since it
1814 lines, as if they had been entered at the IPython prompt. Since it
1803 exposes IPython's processing machinery, the given strings can contain
1815 exposes IPython's processing machinery, the given strings can contain
1804 magic calls (%magic), special shell access (!cmd), etc."""
1816 magic calls (%magic), special shell access (!cmd), etc."""
1805
1817
1806 # We must start with a clean buffer, in case this is run from an
1818 # We must start with a clean buffer, in case this is run from an
1807 # interactive IPython session (via a magic, for example).
1819 # interactive IPython session (via a magic, for example).
1808 self.resetbuffer()
1820 self.resetbuffer()
1809 lines = lines.split('\n')
1821 lines = lines.split('\n')
1810 more = 0
1822 more = 0
1811 for line in lines:
1823 for line in lines:
1812 # skip blank lines so we don't mess up the prompt counter, but do
1824 # skip blank lines so we don't mess up the prompt counter, but do
1813 # NOT skip even a blank line if we are in a code block (more is
1825 # NOT skip even a blank line if we are in a code block (more is
1814 # true)
1826 # true)
1815 if line or more:
1827 if line or more:
1816 more = self.push(self.prefilter(line,more))
1828 more = self.push(self.prefilter(line,more))
1817 # IPython's runsource returns None if there was an error
1829 # IPython's runsource returns None if there was an error
1818 # compiling the code. This allows us to stop processing right
1830 # compiling the code. This allows us to stop processing right
1819 # away, so the user gets the error message at the right place.
1831 # away, so the user gets the error message at the right place.
1820 if more is None:
1832 if more is None:
1821 break
1833 break
1822 # final newline in case the input didn't have it, so that the code
1834 # final newline in case the input didn't have it, so that the code
1823 # actually does get executed
1835 # actually does get executed
1824 if more:
1836 if more:
1825 self.push('\n')
1837 self.push('\n')
1826
1838
1827 def runsource(self, source, filename='<input>', symbol='single'):
1839 def runsource(self, source, filename='<input>', symbol='single'):
1828 """Compile and run some source in the interpreter.
1840 """Compile and run some source in the interpreter.
1829
1841
1830 Arguments are as for compile_command().
1842 Arguments are as for compile_command().
1831
1843
1832 One several things can happen:
1844 One several things can happen:
1833
1845
1834 1) The input is incorrect; compile_command() raised an
1846 1) The input is incorrect; compile_command() raised an
1835 exception (SyntaxError or OverflowError). A syntax traceback
1847 exception (SyntaxError or OverflowError). A syntax traceback
1836 will be printed by calling the showsyntaxerror() method.
1848 will be printed by calling the showsyntaxerror() method.
1837
1849
1838 2) The input is incomplete, and more input is required;
1850 2) The input is incomplete, and more input is required;
1839 compile_command() returned None. Nothing happens.
1851 compile_command() returned None. Nothing happens.
1840
1852
1841 3) The input is complete; compile_command() returned a code
1853 3) The input is complete; compile_command() returned a code
1842 object. The code is executed by calling self.runcode() (which
1854 object. The code is executed by calling self.runcode() (which
1843 also handles run-time exceptions, except for SystemExit).
1855 also handles run-time exceptions, except for SystemExit).
1844
1856
1845 The return value is:
1857 The return value is:
1846
1858
1847 - True in case 2
1859 - True in case 2
1848
1860
1849 - False in the other cases, unless an exception is raised, where
1861 - False in the other cases, unless an exception is raised, where
1850 None is returned instead. This can be used by external callers to
1862 None is returned instead. This can be used by external callers to
1851 know whether to continue feeding input or not.
1863 know whether to continue feeding input or not.
1852
1864
1853 The return value can be used to decide whether to use sys.ps1 or
1865 The return value can be used to decide whether to use sys.ps1 or
1854 sys.ps2 to prompt the next line."""
1866 sys.ps2 to prompt the next line."""
1855
1867
1856 # if the source code has leading blanks, add 'if 1:\n' to it
1868 # if the source code has leading blanks, add 'if 1:\n' to it
1857 # this allows execution of indented pasted code. It is tempting
1869 # this allows execution of indented pasted code. It is tempting
1858 # to add '\n' at the end of source to run commands like ' a=1'
1870 # to add '\n' at the end of source to run commands like ' a=1'
1859 # directly, but this fails for more complicated scenarios
1871 # directly, but this fails for more complicated scenarios
1860 if source[:1] in [' ', '\t']:
1872 if source[:1] in [' ', '\t']:
1861 source = 'if 1:\n%s' % source
1873 source = 'if 1:\n%s' % source
1862
1874
1863 try:
1875 try:
1864 code = self.compile(source,filename,symbol)
1876 code = self.compile(source,filename,symbol)
1865 except (OverflowError, SyntaxError, ValueError):
1877 except (OverflowError, SyntaxError, ValueError):
1866 # Case 1
1878 # Case 1
1867 self.showsyntaxerror(filename)
1879 self.showsyntaxerror(filename)
1868 return None
1880 return None
1869
1881
1870 if code is None:
1882 if code is None:
1871 # Case 2
1883 # Case 2
1872 return True
1884 return True
1873
1885
1874 # Case 3
1886 # Case 3
1875 # We store the code object so that threaded shells and
1887 # We store the code object so that threaded shells and
1876 # custom exception handlers can access all this info if needed.
1888 # custom exception handlers can access all this info if needed.
1877 # The source corresponding to this can be obtained from the
1889 # The source corresponding to this can be obtained from the
1878 # buffer attribute as '\n'.join(self.buffer).
1890 # buffer attribute as '\n'.join(self.buffer).
1879 self.code_to_run = code
1891 self.code_to_run = code
1880 # now actually execute the code object
1892 # now actually execute the code object
1881 if self.runcode(code) == 0:
1893 if self.runcode(code) == 0:
1882 return False
1894 return False
1883 else:
1895 else:
1884 return None
1896 return None
1885
1897
1886 def runcode(self,code_obj):
1898 def runcode(self,code_obj):
1887 """Execute a code object.
1899 """Execute a code object.
1888
1900
1889 When an exception occurs, self.showtraceback() is called to display a
1901 When an exception occurs, self.showtraceback() is called to display a
1890 traceback.
1902 traceback.
1891
1903
1892 Return value: a flag indicating whether the code to be run completed
1904 Return value: a flag indicating whether the code to be run completed
1893 successfully:
1905 successfully:
1894
1906
1895 - 0: successful execution.
1907 - 0: successful execution.
1896 - 1: an error occurred.
1908 - 1: an error occurred.
1897 """
1909 """
1898
1910
1899 # Set our own excepthook in case the user code tries to call it
1911 # Set our own excepthook in case the user code tries to call it
1900 # directly, so that the IPython crash handler doesn't get triggered
1912 # directly, so that the IPython crash handler doesn't get triggered
1901 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1913 old_excepthook,sys.excepthook = sys.excepthook, self.excepthook
1902
1914
1903 # we save the original sys.excepthook in the instance, in case config
1915 # we save the original sys.excepthook in the instance, in case config
1904 # code (such as magics) needs access to it.
1916 # code (such as magics) needs access to it.
1905 self.sys_excepthook = old_excepthook
1917 self.sys_excepthook = old_excepthook
1906 outflag = 1 # happens in more places, so it's easier as default
1918 outflag = 1 # happens in more places, so it's easier as default
1907 try:
1919 try:
1908 try:
1920 try:
1909 # Embedded instances require separate global/local namespaces
1921 # Embedded instances require separate global/local namespaces
1910 # so they can see both the surrounding (local) namespace and
1922 # so they can see both the surrounding (local) namespace and
1911 # the module-level globals when called inside another function.
1923 # the module-level globals when called inside another function.
1912 if self.embedded:
1924 if self.embedded:
1913 exec code_obj in self.user_global_ns, self.user_ns
1925 exec code_obj in self.user_global_ns, self.user_ns
1914 # Normal (non-embedded) instances should only have a single
1926 # Normal (non-embedded) instances should only have a single
1915 # namespace for user code execution, otherwise functions won't
1927 # namespace for user code execution, otherwise functions won't
1916 # see interactive top-level globals.
1928 # see interactive top-level globals.
1917 else:
1929 else:
1918 exec code_obj in self.user_ns
1930 exec code_obj in self.user_ns
1919 finally:
1931 finally:
1920 # Reset our crash handler in place
1932 # Reset our crash handler in place
1921 sys.excepthook = old_excepthook
1933 sys.excepthook = old_excepthook
1922 except SystemExit:
1934 except SystemExit:
1923 self.resetbuffer()
1935 self.resetbuffer()
1924 self.showtraceback()
1936 self.showtraceback()
1925 warn("Type %exit or %quit to exit IPython "
1937 warn("Type %exit or %quit to exit IPython "
1926 "(%Exit or %Quit do so unconditionally).",level=1)
1938 "(%Exit or %Quit do so unconditionally).",level=1)
1927 except self.custom_exceptions:
1939 except self.custom_exceptions:
1928 etype,value,tb = sys.exc_info()
1940 etype,value,tb = sys.exc_info()
1929 self.CustomTB(etype,value,tb)
1941 self.CustomTB(etype,value,tb)
1930 except:
1942 except:
1931 self.showtraceback()
1943 self.showtraceback()
1932 else:
1944 else:
1933 outflag = 0
1945 outflag = 0
1934 if softspace(sys.stdout, 0):
1946 if softspace(sys.stdout, 0):
1935 print
1947 print
1936 # Flush out code object which has been run (and source)
1948 # Flush out code object which has been run (and source)
1937 self.code_to_run = None
1949 self.code_to_run = None
1938 return outflag
1950 return outflag
1939
1951
1940 def push(self, line):
1952 def push(self, line):
1941 """Push a line to the interpreter.
1953 """Push a line to the interpreter.
1942
1954
1943 The line should not have a trailing newline; it may have
1955 The line should not have a trailing newline; it may have
1944 internal newlines. The line is appended to a buffer and the
1956 internal newlines. The line is appended to a buffer and the
1945 interpreter's runsource() method is called with the
1957 interpreter's runsource() method is called with the
1946 concatenated contents of the buffer as source. If this
1958 concatenated contents of the buffer as source. If this
1947 indicates that the command was executed or invalid, the buffer
1959 indicates that the command was executed or invalid, the buffer
1948 is reset; otherwise, the command is incomplete, and the buffer
1960 is reset; otherwise, the command is incomplete, and the buffer
1949 is left as it was after the line was appended. The return
1961 is left as it was after the line was appended. The return
1950 value is 1 if more input is required, 0 if the line was dealt
1962 value is 1 if more input is required, 0 if the line was dealt
1951 with in some way (this is the same as runsource()).
1963 with in some way (this is the same as runsource()).
1952 """
1964 """
1953
1965
1954 # autoindent management should be done here, and not in the
1966 # autoindent management should be done here, and not in the
1955 # interactive loop, since that one is only seen by keyboard input. We
1967 # interactive loop, since that one is only seen by keyboard input. We
1956 # need this done correctly even for code run via runlines (which uses
1968 # need this done correctly even for code run via runlines (which uses
1957 # push).
1969 # push).
1958
1970
1959 #print 'push line: <%s>' % line # dbg
1971 #print 'push line: <%s>' % line # dbg
1960 for subline in line.splitlines():
1972 for subline in line.splitlines():
1961 self.autoindent_update(subline)
1973 self.autoindent_update(subline)
1962 self.buffer.append(line)
1974 self.buffer.append(line)
1963 more = self.runsource('\n'.join(self.buffer), self.filename)
1975 more = self.runsource('\n'.join(self.buffer), self.filename)
1964 if not more:
1976 if not more:
1965 self.resetbuffer()
1977 self.resetbuffer()
1966 return more
1978 return more
1967
1979
1968 def resetbuffer(self):
1980 def resetbuffer(self):
1969 """Reset the input buffer."""
1981 """Reset the input buffer."""
1970 self.buffer[:] = []
1982 self.buffer[:] = []
1971
1983
1972 def raw_input(self,prompt='',continue_prompt=False):
1984 def raw_input(self,prompt='',continue_prompt=False):
1973 """Write a prompt and read a line.
1985 """Write a prompt and read a line.
1974
1986
1975 The returned line does not include the trailing newline.
1987 The returned line does not include the trailing newline.
1976 When the user enters the EOF key sequence, EOFError is raised.
1988 When the user enters the EOF key sequence, EOFError is raised.
1977
1989
1978 Optional inputs:
1990 Optional inputs:
1979
1991
1980 - prompt(''): a string to be printed to prompt the user.
1992 - prompt(''): a string to be printed to prompt the user.
1981
1993
1982 - continue_prompt(False): whether this line is the first one or a
1994 - continue_prompt(False): whether this line is the first one or a
1983 continuation in a sequence of inputs.
1995 continuation in a sequence of inputs.
1984 """
1996 """
1985
1997
1986 # Code run by the user may have modified the readline completer state.
1998 # Code run by the user may have modified the readline completer state.
1987 # We must ensure that our completer is back in place.
1999 # We must ensure that our completer is back in place.
1988 self.set_completer()
2000 self.set_completer()
1989
2001
1990 try:
2002 try:
1991 line = raw_input_original(prompt).decode(sys.stdin.encoding)
2003 line = raw_input_original(prompt).decode(self.stdin_encoding)
1992 except ValueError:
2004 except ValueError:
1993 warn("\n********\nYou or a %run:ed script called sys.stdin.close()"
2005 warn("\n********\nYou or a %run:ed script called sys.stdin.close()"
1994 " or sys.stdout.close()!\nExiting IPython!")
2006 " or sys.stdout.close()!\nExiting IPython!")
1995 self.exit_now = True
2007 self.exit_now = True
1996 return ""
2008 return ""
1997
2009
1998 # Try to be reasonably smart about not re-indenting pasted input more
2010 # Try to be reasonably smart about not re-indenting pasted input more
1999 # than necessary. We do this by trimming out the auto-indent initial
2011 # than necessary. We do this by trimming out the auto-indent initial
2000 # spaces, if the user's actual input started itself with whitespace.
2012 # spaces, if the user's actual input started itself with whitespace.
2001 #debugx('self.buffer[-1]')
2013 #debugx('self.buffer[-1]')
2002
2014
2003 if self.autoindent:
2015 if self.autoindent:
2004 if num_ini_spaces(line) > self.indent_current_nsp:
2016 if num_ini_spaces(line) > self.indent_current_nsp:
2005 line = line[self.indent_current_nsp:]
2017 line = line[self.indent_current_nsp:]
2006 self.indent_current_nsp = 0
2018 self.indent_current_nsp = 0
2007
2019
2008 # store the unfiltered input before the user has any chance to modify
2020 # store the unfiltered input before the user has any chance to modify
2009 # it.
2021 # it.
2010 if line.strip():
2022 if line.strip():
2011 if continue_prompt:
2023 if continue_prompt:
2012 self.input_hist_raw[-1] += '%s\n' % line
2024 self.input_hist_raw[-1] += '%s\n' % line
2013 if self.has_readline: # and some config option is set?
2025 if self.has_readline: # and some config option is set?
2014 try:
2026 try:
2015 histlen = self.readline.get_current_history_length()
2027 histlen = self.readline.get_current_history_length()
2016 newhist = self.input_hist_raw[-1].rstrip()
2028 newhist = self.input_hist_raw[-1].rstrip()
2017 self.readline.remove_history_item(histlen-1)
2029 self.readline.remove_history_item(histlen-1)
2018 self.readline.replace_history_item(histlen-2,newhist)
2030 self.readline.replace_history_item(histlen-2,newhist)
2019 except AttributeError:
2031 except AttributeError:
2020 pass # re{move,place}_history_item are new in 2.4.
2032 pass # re{move,place}_history_item are new in 2.4.
2021 else:
2033 else:
2022 self.input_hist_raw.append('%s\n' % line)
2034 self.input_hist_raw.append('%s\n' % line)
2023
2035
2024 try:
2036 try:
2025 lineout = self.prefilter(line,continue_prompt)
2037 lineout = self.prefilter(line,continue_prompt)
2026 except:
2038 except:
2027 # blanket except, in case a user-defined prefilter crashes, so it
2039 # blanket except, in case a user-defined prefilter crashes, so it
2028 # can't take all of ipython with it.
2040 # can't take all of ipython with it.
2029 self.showtraceback()
2041 self.showtraceback()
2030 return ''
2042 return ''
2031 else:
2043 else:
2032 return lineout
2044 return lineout
2033
2045
2034 def split_user_input(self,line, pattern = None):
2046 def split_user_input(self,line, pattern = None):
2035 """Split user input into pre-char, function part and rest."""
2047 """Split user input into pre-char, function part and rest."""
2036
2048
2037 if pattern is None:
2049 if pattern is None:
2038 pattern = self.line_split
2050 pattern = self.line_split
2039
2051
2040 lsplit = pattern.match(line)
2052 lsplit = pattern.match(line)
2041 if lsplit is None: # no regexp match returns None
2053 if lsplit is None: # no regexp match returns None
2042 #print "match failed for line '%s'" % line # dbg
2054 #print "match failed for line '%s'" % line # dbg
2043 try:
2055 try:
2044 iFun,theRest = line.split(None,1)
2056 iFun,theRest = line.split(None,1)
2045 except ValueError:
2057 except ValueError:
2046 #print "split failed for line '%s'" % line # dbg
2058 #print "split failed for line '%s'" % line # dbg
2047 iFun,theRest = line,''
2059 iFun,theRest = line,''
2048 pre = re.match('^(\s*)(.*)',line).groups()[0]
2060 pre = re.match('^(\s*)(.*)',line).groups()[0]
2049 else:
2061 else:
2050 pre,iFun,theRest = lsplit.groups()
2062 pre,iFun,theRest = lsplit.groups()
2051
2063
2052 # iFun has to be a valid python identifier, so it better be only pure
2064 # iFun has to be a valid python identifier, so it better be only pure
2053 #ascii, no unicode:
2065 #ascii, no unicode:
2054 try:
2066 try:
2055 iFun = iFun.encode('ascii')
2067 iFun = iFun.encode('ascii')
2056 except UnicodeEncodeError:
2068 except UnicodeEncodeError:
2057 theRest = iFun+u' '+theRest
2069 theRest = iFun+u' '+theRest
2058 iFun = u''
2070 iFun = u''
2059
2071
2060 #print 'line:<%s>' % line # dbg
2072 #print 'line:<%s>' % line # dbg
2061 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
2073 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
2062 return pre,iFun.strip(),theRest
2074 return pre,iFun.strip(),theRest
2063
2075
2064 # THIS VERSION IS BROKEN!!! It was intended to prevent spurious attribute
2076 # THIS VERSION IS BROKEN!!! It was intended to prevent spurious attribute
2065 # accesses with a more stringent check of inputs, but it introduced other
2077 # accesses with a more stringent check of inputs, but it introduced other
2066 # bugs. Disable it for now until I can properly fix it.
2078 # bugs. Disable it for now until I can properly fix it.
2067 def split_user_inputBROKEN(self,line):
2079 def split_user_inputBROKEN(self,line):
2068 """Split user input into pre-char, function part and rest."""
2080 """Split user input into pre-char, function part and rest."""
2069
2081
2070 lsplit = self.line_split.match(line)
2082 lsplit = self.line_split.match(line)
2071 if lsplit is None: # no regexp match returns None
2083 if lsplit is None: # no regexp match returns None
2072 lsplit = self.line_split_fallback.match(line)
2084 lsplit = self.line_split_fallback.match(line)
2073
2085
2074 #pre,iFun,theRest = lsplit.groups() # dbg
2086 #pre,iFun,theRest = lsplit.groups() # dbg
2075 #print 'line:<%s>' % line # dbg
2087 #print 'line:<%s>' % line # dbg
2076 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
2088 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun.strip(),theRest) # dbg
2077 #return pre,iFun.strip(),theRest # dbg
2089 #return pre,iFun.strip(),theRest # dbg
2078
2090
2079 return lsplit.groups()
2091 return lsplit.groups()
2080
2092
2081 def _prefilter(self, line, continue_prompt):
2093 def _prefilter(self, line, continue_prompt):
2082 """Calls different preprocessors, depending on the form of line."""
2094 """Calls different preprocessors, depending on the form of line."""
2083
2095
2084 # All handlers *must* return a value, even if it's blank ('').
2096 # All handlers *must* return a value, even if it's blank ('').
2085
2097
2086 # Lines are NOT logged here. Handlers should process the line as
2098 # Lines are NOT logged here. Handlers should process the line as
2087 # needed, update the cache AND log it (so that the input cache array
2099 # needed, update the cache AND log it (so that the input cache array
2088 # stays synced).
2100 # stays synced).
2089
2101
2090 # This function is _very_ delicate, and since it's also the one which
2102 # This function is _very_ delicate, and since it's also the one which
2091 # determines IPython's response to user input, it must be as efficient
2103 # determines IPython's response to user input, it must be as efficient
2092 # as possible. For this reason it has _many_ returns in it, trying
2104 # as possible. For this reason it has _many_ returns in it, trying
2093 # always to exit as quickly as it can figure out what it needs to do.
2105 # always to exit as quickly as it can figure out what it needs to do.
2094
2106
2095 # This function is the main responsible for maintaining IPython's
2107 # This function is the main responsible for maintaining IPython's
2096 # behavior respectful of Python's semantics. So be _very_ careful if
2108 # behavior respectful of Python's semantics. So be _very_ careful if
2097 # making changes to anything here.
2109 # making changes to anything here.
2098
2110
2099 #.....................................................................
2111 #.....................................................................
2100 # Code begins
2112 # Code begins
2101
2113
2102 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
2114 #if line.startswith('%crash'): raise RuntimeError,'Crash now!' # dbg
2103
2115
2104 # save the line away in case we crash, so the post-mortem handler can
2116 # save the line away in case we crash, so the post-mortem handler can
2105 # record it
2117 # record it
2106 self._last_input_line = line
2118 self._last_input_line = line
2107
2119
2108 #print '***line: <%s>' % line # dbg
2120 #print '***line: <%s>' % line # dbg
2109
2121
2110 # the input history needs to track even empty lines
2122 # the input history needs to track even empty lines
2111 stripped = line.strip()
2123 stripped = line.strip()
2112
2124
2113 if not stripped:
2125 if not stripped:
2114 if not continue_prompt:
2126 if not continue_prompt:
2115 self.outputcache.prompt_count -= 1
2127 self.outputcache.prompt_count -= 1
2116 return self.handle_normal(line,continue_prompt)
2128 return self.handle_normal(line,continue_prompt)
2117 #return self.handle_normal('',continue_prompt)
2129 #return self.handle_normal('',continue_prompt)
2118
2130
2119 # print '***cont',continue_prompt # dbg
2131 # print '***cont',continue_prompt # dbg
2120 # special handlers are only allowed for single line statements
2132 # special handlers are only allowed for single line statements
2121 if continue_prompt and not self.rc.multi_line_specials:
2133 if continue_prompt and not self.rc.multi_line_specials:
2122 return self.handle_normal(line,continue_prompt)
2134 return self.handle_normal(line,continue_prompt)
2123
2135
2124
2136
2125 # For the rest, we need the structure of the input
2137 # For the rest, we need the structure of the input
2126 pre,iFun,theRest = self.split_user_input(line)
2138 pre,iFun,theRest = self.split_user_input(line)
2127
2139
2128 # See whether any pre-existing handler can take care of it
2140 # See whether any pre-existing handler can take care of it
2129
2141
2130 rewritten = self.hooks.input_prefilter(stripped)
2142 rewritten = self.hooks.input_prefilter(stripped)
2131 if rewritten != stripped: # ok, some prefilter did something
2143 if rewritten != stripped: # ok, some prefilter did something
2132 rewritten = pre + rewritten # add indentation
2144 rewritten = pre + rewritten # add indentation
2133 return self.handle_normal(rewritten)
2145 return self.handle_normal(rewritten)
2134
2146
2135 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2147 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2136
2148
2137 # Next, check if we can automatically execute this thing
2149 # Next, check if we can automatically execute this thing
2138
2150
2139 # Allow ! in multi-line statements if multi_line_specials is on:
2151 # Allow ! in multi-line statements if multi_line_specials is on:
2140 if continue_prompt and self.rc.multi_line_specials and \
2152 if continue_prompt and self.rc.multi_line_specials and \
2141 iFun.startswith(self.ESC_SHELL):
2153 iFun.startswith(self.ESC_SHELL):
2142 return self.handle_shell_escape(line,continue_prompt,
2154 return self.handle_shell_escape(line,continue_prompt,
2143 pre=pre,iFun=iFun,
2155 pre=pre,iFun=iFun,
2144 theRest=theRest)
2156 theRest=theRest)
2145
2157
2146 # First check for explicit escapes in the last/first character
2158 # First check for explicit escapes in the last/first character
2147 handler = None
2159 handler = None
2148 if line[-1] == self.ESC_HELP and line[0] != self.ESC_SHELL:
2160 if line[-1] == self.ESC_HELP and line[0] != self.ESC_SHELL:
2149 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
2161 handler = self.esc_handlers.get(line[-1]) # the ? can be at the end
2150 if handler is None:
2162 if handler is None:
2151 # look at the first character of iFun, NOT of line, so we skip
2163 # look at the first character of iFun, NOT of line, so we skip
2152 # leading whitespace in multiline input
2164 # leading whitespace in multiline input
2153 handler = self.esc_handlers.get(iFun[0:1])
2165 handler = self.esc_handlers.get(iFun[0:1])
2154 if handler is not None:
2166 if handler is not None:
2155 return handler(line,continue_prompt,pre,iFun,theRest)
2167 return handler(line,continue_prompt,pre,iFun,theRest)
2156 # Emacs ipython-mode tags certain input lines
2168 # Emacs ipython-mode tags certain input lines
2157 if line.endswith('# PYTHON-MODE'):
2169 if line.endswith('# PYTHON-MODE'):
2158 return self.handle_emacs(line,continue_prompt)
2170 return self.handle_emacs(line,continue_prompt)
2159
2171
2160 # Let's try to find if the input line is a magic fn
2172 # Let's try to find if the input line is a magic fn
2161 oinfo = None
2173 oinfo = None
2162 if hasattr(self,'magic_'+iFun):
2174 if hasattr(self,'magic_'+iFun):
2163 # WARNING: _ofind uses getattr(), so it can consume generators and
2175 # WARNING: _ofind uses getattr(), so it can consume generators and
2164 # cause other side effects.
2176 # cause other side effects.
2165 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2177 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2166 if oinfo['ismagic']:
2178 if oinfo['ismagic']:
2167 # Be careful not to call magics when a variable assignment is
2179 # Be careful not to call magics when a variable assignment is
2168 # being made (ls='hi', for example)
2180 # being made (ls='hi', for example)
2169 if self.rc.automagic and \
2181 if self.rc.automagic and \
2170 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
2182 (len(theRest)==0 or theRest[0] not in '!=()<>,') and \
2171 (self.rc.multi_line_specials or not continue_prompt):
2183 (self.rc.multi_line_specials or not continue_prompt):
2172 return self.handle_magic(line,continue_prompt,
2184 return self.handle_magic(line,continue_prompt,
2173 pre,iFun,theRest)
2185 pre,iFun,theRest)
2174 else:
2186 else:
2175 return self.handle_normal(line,continue_prompt)
2187 return self.handle_normal(line,continue_prompt)
2176
2188
2177 # If the rest of the line begins with an (in)equality, assginment or
2189 # If the rest of the line begins with an (in)equality, assginment or
2178 # function call, we should not call _ofind but simply execute it.
2190 # function call, we should not call _ofind but simply execute it.
2179 # This avoids spurious geattr() accesses on objects upon assignment.
2191 # This avoids spurious geattr() accesses on objects upon assignment.
2180 #
2192 #
2181 # It also allows users to assign to either alias or magic names true
2193 # It also allows users to assign to either alias or magic names true
2182 # python variables (the magic/alias systems always take second seat to
2194 # python variables (the magic/alias systems always take second seat to
2183 # true python code).
2195 # true python code).
2184 if theRest and theRest[0] in '!=()':
2196 if theRest and theRest[0] in '!=()':
2185 return self.handle_normal(line,continue_prompt)
2197 return self.handle_normal(line,continue_prompt)
2186
2198
2187 if oinfo is None:
2199 if oinfo is None:
2188 # let's try to ensure that _oinfo is ONLY called when autocall is
2200 # let's try to ensure that _oinfo is ONLY called when autocall is
2189 # on. Since it has inevitable potential side effects, at least
2201 # on. Since it has inevitable potential side effects, at least
2190 # having autocall off should be a guarantee to the user that no
2202 # having autocall off should be a guarantee to the user that no
2191 # weird things will happen.
2203 # weird things will happen.
2192
2204
2193 if self.rc.autocall:
2205 if self.rc.autocall:
2194 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2206 oinfo = self._ofind(iFun) # FIXME - _ofind is part of Magic
2195 else:
2207 else:
2196 # in this case, all that's left is either an alias or
2208 # in this case, all that's left is either an alias or
2197 # processing the line normally.
2209 # processing the line normally.
2198 if iFun in self.alias_table:
2210 if iFun in self.alias_table:
2199 # if autocall is off, by not running _ofind we won't know
2211 # if autocall is off, by not running _ofind we won't know
2200 # whether the given name may also exist in one of the
2212 # whether the given name may also exist in one of the
2201 # user's namespace. At this point, it's best to do a
2213 # user's namespace. At this point, it's best to do a
2202 # quick check just to be sure that we don't let aliases
2214 # quick check just to be sure that we don't let aliases
2203 # shadow variables.
2215 # shadow variables.
2204 head = iFun.split('.',1)[0]
2216 head = iFun.split('.',1)[0]
2205 if head in self.user_ns or head in self.internal_ns \
2217 if head in self.user_ns or head in self.internal_ns \
2206 or head in __builtin__.__dict__:
2218 or head in __builtin__.__dict__:
2207 return self.handle_normal(line,continue_prompt)
2219 return self.handle_normal(line,continue_prompt)
2208 else:
2220 else:
2209 return self.handle_alias(line,continue_prompt,
2221 return self.handle_alias(line,continue_prompt,
2210 pre,iFun,theRest)
2222 pre,iFun,theRest)
2211
2223
2212 else:
2224 else:
2213 return self.handle_normal(line,continue_prompt)
2225 return self.handle_normal(line,continue_prompt)
2214
2226
2215 if not oinfo['found']:
2227 if not oinfo['found']:
2216 return self.handle_normal(line,continue_prompt)
2228 return self.handle_normal(line,continue_prompt)
2217 else:
2229 else:
2218 #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2230 #print 'pre<%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2219 if oinfo['isalias']:
2231 if oinfo['isalias']:
2220 return self.handle_alias(line,continue_prompt,
2232 return self.handle_alias(line,continue_prompt,
2221 pre,iFun,theRest)
2233 pre,iFun,theRest)
2222
2234
2223 if (self.rc.autocall
2235 if (self.rc.autocall
2224 and
2236 and
2225 (
2237 (
2226 #only consider exclusion re if not "," or ";" autoquoting
2238 #only consider exclusion re if not "," or ";" autoquoting
2227 (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2
2239 (pre == self.ESC_QUOTE or pre == self.ESC_QUOTE2
2228 or pre == self.ESC_PAREN) or
2240 or pre == self.ESC_PAREN) or
2229 (not self.re_exclude_auto.match(theRest)))
2241 (not self.re_exclude_auto.match(theRest)))
2230 and
2242 and
2231 self.re_fun_name.match(iFun) and
2243 self.re_fun_name.match(iFun) and
2232 callable(oinfo['obj'])) :
2244 callable(oinfo['obj'])) :
2233 #print 'going auto' # dbg
2245 #print 'going auto' # dbg
2234 return self.handle_auto(line,continue_prompt,
2246 return self.handle_auto(line,continue_prompt,
2235 pre,iFun,theRest,oinfo['obj'])
2247 pre,iFun,theRest,oinfo['obj'])
2236 else:
2248 else:
2237 #print 'was callable?', callable(oinfo['obj']) # dbg
2249 #print 'was callable?', callable(oinfo['obj']) # dbg
2238 return self.handle_normal(line,continue_prompt)
2250 return self.handle_normal(line,continue_prompt)
2239
2251
2240 # If we get here, we have a normal Python line. Log and return.
2252 # If we get here, we have a normal Python line. Log and return.
2241 return self.handle_normal(line,continue_prompt)
2253 return self.handle_normal(line,continue_prompt)
2242
2254
2243 def _prefilter_dumb(self, line, continue_prompt):
2255 def _prefilter_dumb(self, line, continue_prompt):
2244 """simple prefilter function, for debugging"""
2256 """simple prefilter function, for debugging"""
2245 return self.handle_normal(line,continue_prompt)
2257 return self.handle_normal(line,continue_prompt)
2246
2258
2247
2259
2248 def multiline_prefilter(self, line, continue_prompt):
2260 def multiline_prefilter(self, line, continue_prompt):
2249 """ Run _prefilter for each line of input
2261 """ Run _prefilter for each line of input
2250
2262
2251 Covers cases where there are multiple lines in the user entry,
2263 Covers cases where there are multiple lines in the user entry,
2252 which is the case when the user goes back to a multiline history
2264 which is the case when the user goes back to a multiline history
2253 entry and presses enter.
2265 entry and presses enter.
2254
2266
2255 """
2267 """
2256 out = []
2268 out = []
2257 for l in line.rstrip('\n').split('\n'):
2269 for l in line.rstrip('\n').split('\n'):
2258 out.append(self._prefilter(l, continue_prompt))
2270 out.append(self._prefilter(l, continue_prompt))
2259 return '\n'.join(out)
2271 return '\n'.join(out)
2260
2272
2261 # Set the default prefilter() function (this can be user-overridden)
2273 # Set the default prefilter() function (this can be user-overridden)
2262 prefilter = multiline_prefilter
2274 prefilter = multiline_prefilter
2263
2275
2264 def handle_normal(self,line,continue_prompt=None,
2276 def handle_normal(self,line,continue_prompt=None,
2265 pre=None,iFun=None,theRest=None):
2277 pre=None,iFun=None,theRest=None):
2266 """Handle normal input lines. Use as a template for handlers."""
2278 """Handle normal input lines. Use as a template for handlers."""
2267
2279
2268 # With autoindent on, we need some way to exit the input loop, and I
2280 # With autoindent on, we need some way to exit the input loop, and I
2269 # don't want to force the user to have to backspace all the way to
2281 # don't want to force the user to have to backspace all the way to
2270 # clear the line. The rule will be in this case, that either two
2282 # clear the line. The rule will be in this case, that either two
2271 # lines of pure whitespace in a row, or a line of pure whitespace but
2283 # lines of pure whitespace in a row, or a line of pure whitespace but
2272 # of a size different to the indent level, will exit the input loop.
2284 # of a size different to the indent level, will exit the input loop.
2273
2285
2274 if (continue_prompt and self.autoindent and line.isspace() and
2286 if (continue_prompt and self.autoindent and line.isspace() and
2275 (0 < abs(len(line) - self.indent_current_nsp) <= 2 or
2287 (0 < abs(len(line) - self.indent_current_nsp) <= 2 or
2276 (self.buffer[-1]).isspace() )):
2288 (self.buffer[-1]).isspace() )):
2277 line = ''
2289 line = ''
2278
2290
2279 self.log(line,line,continue_prompt)
2291 self.log(line,line,continue_prompt)
2280 return line
2292 return line
2281
2293
2282 def handle_alias(self,line,continue_prompt=None,
2294 def handle_alias(self,line,continue_prompt=None,
2283 pre=None,iFun=None,theRest=None):
2295 pre=None,iFun=None,theRest=None):
2284 """Handle alias input lines. """
2296 """Handle alias input lines. """
2285
2297
2286 # pre is needed, because it carries the leading whitespace. Otherwise
2298 # pre is needed, because it carries the leading whitespace. Otherwise
2287 # aliases won't work in indented sections.
2299 # aliases won't work in indented sections.
2288 transformed = self.expand_aliases(iFun, theRest)
2300 transformed = self.expand_aliases(iFun, theRest)
2289 line_out = '%s_ip.system(%s)' % (pre, make_quoted_expr( transformed ))
2301 line_out = '%s_ip.system(%s)' % (pre, make_quoted_expr( transformed ))
2290 self.log(line,line_out,continue_prompt)
2302 self.log(line,line_out,continue_prompt)
2291 #print 'line out:',line_out # dbg
2303 #print 'line out:',line_out # dbg
2292 return line_out
2304 return line_out
2293
2305
2294 def handle_shell_escape(self, line, continue_prompt=None,
2306 def handle_shell_escape(self, line, continue_prompt=None,
2295 pre=None,iFun=None,theRest=None):
2307 pre=None,iFun=None,theRest=None):
2296 """Execute the line in a shell, empty return value"""
2308 """Execute the line in a shell, empty return value"""
2297
2309
2298 #print 'line in :', `line` # dbg
2310 #print 'line in :', `line` # dbg
2299 # Example of a special handler. Others follow a similar pattern.
2311 # Example of a special handler. Others follow a similar pattern.
2300 if line.lstrip().startswith('!!'):
2312 if line.lstrip().startswith('!!'):
2301 # rewrite iFun/theRest to properly hold the call to %sx and
2313 # rewrite iFun/theRest to properly hold the call to %sx and
2302 # the actual command to be executed, so handle_magic can work
2314 # the actual command to be executed, so handle_magic can work
2303 # correctly
2315 # correctly
2304 theRest = '%s %s' % (iFun[2:],theRest)
2316 theRest = '%s %s' % (iFun[2:],theRest)
2305 iFun = 'sx'
2317 iFun = 'sx'
2306 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,
2318 return self.handle_magic('%ssx %s' % (self.ESC_MAGIC,
2307 line.lstrip()[2:]),
2319 line.lstrip()[2:]),
2308 continue_prompt,pre,iFun,theRest)
2320 continue_prompt,pre,iFun,theRest)
2309 else:
2321 else:
2310 cmd=line.lstrip().lstrip('!')
2322 cmd=line.lstrip().lstrip('!')
2311 line_out = '%s_ip.system(%s)' % (pre,make_quoted_expr(cmd))
2323 line_out = '%s_ip.system(%s)' % (pre,make_quoted_expr(cmd))
2312 # update cache/log and return
2324 # update cache/log and return
2313 self.log(line,line_out,continue_prompt)
2325 self.log(line,line_out,continue_prompt)
2314 return line_out
2326 return line_out
2315
2327
2316 def handle_magic(self, line, continue_prompt=None,
2328 def handle_magic(self, line, continue_prompt=None,
2317 pre=None,iFun=None,theRest=None):
2329 pre=None,iFun=None,theRest=None):
2318 """Execute magic functions."""
2330 """Execute magic functions."""
2319
2331
2320
2332
2321 cmd = '%s_ip.magic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
2333 cmd = '%s_ip.magic(%s)' % (pre,make_quoted_expr(iFun + " " + theRest))
2322 self.log(line,cmd,continue_prompt)
2334 self.log(line,cmd,continue_prompt)
2323 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
2335 #print 'in handle_magic, cmd=<%s>' % cmd # dbg
2324 return cmd
2336 return cmd
2325
2337
2326 def handle_auto(self, line, continue_prompt=None,
2338 def handle_auto(self, line, continue_prompt=None,
2327 pre=None,iFun=None,theRest=None,obj=None):
2339 pre=None,iFun=None,theRest=None,obj=None):
2328 """Hande lines which can be auto-executed, quoting if requested."""
2340 """Hande lines which can be auto-executed, quoting if requested."""
2329
2341
2330 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2342 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
2331
2343
2332 # This should only be active for single-line input!
2344 # This should only be active for single-line input!
2333 if continue_prompt:
2345 if continue_prompt:
2334 self.log(line,line,continue_prompt)
2346 self.log(line,line,continue_prompt)
2335 return line
2347 return line
2336
2348
2337 auto_rewrite = True
2349 auto_rewrite = True
2338
2350
2339 if pre == self.ESC_QUOTE:
2351 if pre == self.ESC_QUOTE:
2340 # Auto-quote splitting on whitespace
2352 # Auto-quote splitting on whitespace
2341 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
2353 newcmd = '%s("%s")' % (iFun,'", "'.join(theRest.split()) )
2342 elif pre == self.ESC_QUOTE2:
2354 elif pre == self.ESC_QUOTE2:
2343 # Auto-quote whole string
2355 # Auto-quote whole string
2344 newcmd = '%s("%s")' % (iFun,theRest)
2356 newcmd = '%s("%s")' % (iFun,theRest)
2345 elif pre == self.ESC_PAREN:
2357 elif pre == self.ESC_PAREN:
2346 newcmd = '%s(%s)' % (iFun,",".join(theRest.split()))
2358 newcmd = '%s(%s)' % (iFun,",".join(theRest.split()))
2347 else:
2359 else:
2348 # Auto-paren.
2360 # Auto-paren.
2349 # We only apply it to argument-less calls if the autocall
2361 # We only apply it to argument-less calls if the autocall
2350 # parameter is set to 2. We only need to check that autocall is <
2362 # parameter is set to 2. We only need to check that autocall is <
2351 # 2, since this function isn't called unless it's at least 1.
2363 # 2, since this function isn't called unless it's at least 1.
2352 if not theRest and (self.rc.autocall < 2):
2364 if not theRest and (self.rc.autocall < 2):
2353 newcmd = '%s %s' % (iFun,theRest)
2365 newcmd = '%s %s' % (iFun,theRest)
2354 auto_rewrite = False
2366 auto_rewrite = False
2355 else:
2367 else:
2356 if theRest.startswith('['):
2368 if theRest.startswith('['):
2357 if hasattr(obj,'__getitem__'):
2369 if hasattr(obj,'__getitem__'):
2358 # Don't autocall in this case: item access for an object
2370 # Don't autocall in this case: item access for an object
2359 # which is BOTH callable and implements __getitem__.
2371 # which is BOTH callable and implements __getitem__.
2360 newcmd = '%s %s' % (iFun,theRest)
2372 newcmd = '%s %s' % (iFun,theRest)
2361 auto_rewrite = False
2373 auto_rewrite = False
2362 else:
2374 else:
2363 # if the object doesn't support [] access, go ahead and
2375 # if the object doesn't support [] access, go ahead and
2364 # autocall
2376 # autocall
2365 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2377 newcmd = '%s(%s)' % (iFun.rstrip(),theRest)
2366 elif theRest.endswith(';'):
2378 elif theRest.endswith(';'):
2367 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
2379 newcmd = '%s(%s);' % (iFun.rstrip(),theRest[:-1])
2368 else:
2380 else:
2369 newcmd = '%s(%s)' % (iFun.rstrip(), theRest)
2381 newcmd = '%s(%s)' % (iFun.rstrip(), theRest)
2370
2382
2371 if auto_rewrite:
2383 if auto_rewrite:
2372 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
2384 print >>Term.cout, self.outputcache.prompt1.auto_rewrite() + newcmd
2373 # log what is now valid Python, not the actual user input (without the
2385 # log what is now valid Python, not the actual user input (without the
2374 # final newline)
2386 # final newline)
2375 self.log(line,newcmd,continue_prompt)
2387 self.log(line,newcmd,continue_prompt)
2376 return newcmd
2388 return newcmd
2377
2389
2378 def handle_help(self, line, continue_prompt=None,
2390 def handle_help(self, line, continue_prompt=None,
2379 pre=None,iFun=None,theRest=None):
2391 pre=None,iFun=None,theRest=None):
2380 """Try to get some help for the object.
2392 """Try to get some help for the object.
2381
2393
2382 obj? or ?obj -> basic information.
2394 obj? or ?obj -> basic information.
2383 obj?? or ??obj -> more details.
2395 obj?? or ??obj -> more details.
2384 """
2396 """
2385
2397
2386 # We need to make sure that we don't process lines which would be
2398 # We need to make sure that we don't process lines which would be
2387 # otherwise valid python, such as "x=1 # what?"
2399 # otherwise valid python, such as "x=1 # what?"
2388 try:
2400 try:
2389 codeop.compile_command(line)
2401 codeop.compile_command(line)
2390 except SyntaxError:
2402 except SyntaxError:
2391 # We should only handle as help stuff which is NOT valid syntax
2403 # We should only handle as help stuff which is NOT valid syntax
2392 if line[0]==self.ESC_HELP:
2404 if line[0]==self.ESC_HELP:
2393 line = line[1:]
2405 line = line[1:]
2394 elif line[-1]==self.ESC_HELP:
2406 elif line[-1]==self.ESC_HELP:
2395 line = line[:-1]
2407 line = line[:-1]
2396 self.log(line,'#?'+line,continue_prompt)
2408 self.log(line,'#?'+line,continue_prompt)
2397 if line:
2409 if line:
2398 #print 'line:<%r>' % line # dbg
2410 #print 'line:<%r>' % line # dbg
2399 self.magic_pinfo(line)
2411 self.magic_pinfo(line)
2400 else:
2412 else:
2401 page(self.usage,screen_lines=self.rc.screen_length)
2413 page(self.usage,screen_lines=self.rc.screen_length)
2402 return '' # Empty string is needed here!
2414 return '' # Empty string is needed here!
2403 except:
2415 except:
2404 # Pass any other exceptions through to the normal handler
2416 # Pass any other exceptions through to the normal handler
2405 return self.handle_normal(line,continue_prompt)
2417 return self.handle_normal(line,continue_prompt)
2406 else:
2418 else:
2407 # If the code compiles ok, we should handle it normally
2419 # If the code compiles ok, we should handle it normally
2408 return self.handle_normal(line,continue_prompt)
2420 return self.handle_normal(line,continue_prompt)
2409
2421
2410 def getapi(self):
2422 def getapi(self):
2411 """ Get an IPApi object for this shell instance
2423 """ Get an IPApi object for this shell instance
2412
2424
2413 Getting an IPApi object is always preferable to accessing the shell
2425 Getting an IPApi object is always preferable to accessing the shell
2414 directly, but this holds true especially for extensions.
2426 directly, but this holds true especially for extensions.
2415
2427
2416 It should always be possible to implement an extension with IPApi
2428 It should always be possible to implement an extension with IPApi
2417 alone. If not, contact maintainer to request an addition.
2429 alone. If not, contact maintainer to request an addition.
2418
2430
2419 """
2431 """
2420 return self.api
2432 return self.api
2421
2433
2422 def handle_emacs(self,line,continue_prompt=None,
2434 def handle_emacs(self,line,continue_prompt=None,
2423 pre=None,iFun=None,theRest=None):
2435 pre=None,iFun=None,theRest=None):
2424 """Handle input lines marked by python-mode."""
2436 """Handle input lines marked by python-mode."""
2425
2437
2426 # Currently, nothing is done. Later more functionality can be added
2438 # Currently, nothing is done. Later more functionality can be added
2427 # here if needed.
2439 # here if needed.
2428
2440
2429 # The input cache shouldn't be updated
2441 # The input cache shouldn't be updated
2430
2442
2431 return line
2443 return line
2432
2444
2433 def mktempfile(self,data=None):
2445 def mktempfile(self,data=None):
2434 """Make a new tempfile and return its filename.
2446 """Make a new tempfile and return its filename.
2435
2447
2436 This makes a call to tempfile.mktemp, but it registers the created
2448 This makes a call to tempfile.mktemp, but it registers the created
2437 filename internally so ipython cleans it up at exit time.
2449 filename internally so ipython cleans it up at exit time.
2438
2450
2439 Optional inputs:
2451 Optional inputs:
2440
2452
2441 - data(None): if data is given, it gets written out to the temp file
2453 - data(None): if data is given, it gets written out to the temp file
2442 immediately, and the file is closed again."""
2454 immediately, and the file is closed again."""
2443
2455
2444 filename = tempfile.mktemp('.py','ipython_edit_')
2456 filename = tempfile.mktemp('.py','ipython_edit_')
2445 self.tempfiles.append(filename)
2457 self.tempfiles.append(filename)
2446
2458
2447 if data:
2459 if data:
2448 tmp_file = open(filename,'w')
2460 tmp_file = open(filename,'w')
2449 tmp_file.write(data)
2461 tmp_file.write(data)
2450 tmp_file.close()
2462 tmp_file.close()
2451 return filename
2463 return filename
2452
2464
2453 def write(self,data):
2465 def write(self,data):
2454 """Write a string to the default output"""
2466 """Write a string to the default output"""
2455 Term.cout.write(data)
2467 Term.cout.write(data)
2456
2468
2457 def write_err(self,data):
2469 def write_err(self,data):
2458 """Write a string to the default error output"""
2470 """Write a string to the default error output"""
2459 Term.cerr.write(data)
2471 Term.cerr.write(data)
2460
2472
2461 def exit(self):
2473 def exit(self):
2462 """Handle interactive exit.
2474 """Handle interactive exit.
2463
2475
2464 This method sets the exit_now attribute."""
2476 This method sets the exit_now attribute."""
2465
2477
2466 if self.rc.confirm_exit:
2478 if self.rc.confirm_exit:
2467 if self.ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2479 if self.ask_yes_no('Do you really want to exit ([y]/n)?','y'):
2468 self.exit_now = True
2480 self.exit_now = True
2469 else:
2481 else:
2470 self.exit_now = True
2482 self.exit_now = True
2471
2483
2472 def safe_execfile(self,fname,*where,**kw):
2484 def safe_execfile(self,fname,*where,**kw):
2473 """A safe version of the builtin execfile().
2485 """A safe version of the builtin execfile().
2474
2486
2475 This version will never throw an exception, and knows how to handle
2487 This version will never throw an exception, and knows how to handle
2476 ipython logs as well."""
2488 ipython logs as well."""
2477
2489
2478 def syspath_cleanup():
2490 def syspath_cleanup():
2479 """Internal cleanup routine for sys.path."""
2491 """Internal cleanup routine for sys.path."""
2480 if add_dname:
2492 if add_dname:
2481 try:
2493 try:
2482 sys.path.remove(dname)
2494 sys.path.remove(dname)
2483 except ValueError:
2495 except ValueError:
2484 # For some reason the user has already removed it, ignore.
2496 # For some reason the user has already removed it, ignore.
2485 pass
2497 pass
2486
2498
2487 fname = os.path.expanduser(fname)
2499 fname = os.path.expanduser(fname)
2488
2500
2489 # Find things also in current directory. This is needed to mimic the
2501 # Find things also in current directory. This is needed to mimic the
2490 # behavior of running a script from the system command line, where
2502 # behavior of running a script from the system command line, where
2491 # Python inserts the script's directory into sys.path
2503 # Python inserts the script's directory into sys.path
2492 dname = os.path.dirname(os.path.abspath(fname))
2504 dname = os.path.dirname(os.path.abspath(fname))
2493 add_dname = False
2505 add_dname = False
2494 if dname not in sys.path:
2506 if dname not in sys.path:
2495 sys.path.insert(0,dname)
2507 sys.path.insert(0,dname)
2496 add_dname = True
2508 add_dname = True
2497
2509
2498 try:
2510 try:
2499 xfile = open(fname)
2511 xfile = open(fname)
2500 except:
2512 except:
2501 print >> Term.cerr, \
2513 print >> Term.cerr, \
2502 'Could not open file <%s> for safe execution.' % fname
2514 'Could not open file <%s> for safe execution.' % fname
2503 syspath_cleanup()
2515 syspath_cleanup()
2504 return None
2516 return None
2505
2517
2506 kw.setdefault('islog',0)
2518 kw.setdefault('islog',0)
2507 kw.setdefault('quiet',1)
2519 kw.setdefault('quiet',1)
2508 kw.setdefault('exit_ignore',0)
2520 kw.setdefault('exit_ignore',0)
2509 first = xfile.readline()
2521 first = xfile.readline()
2510 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2522 loghead = str(self.loghead_tpl).split('\n',1)[0].strip()
2511 xfile.close()
2523 xfile.close()
2512 # line by line execution
2524 # line by line execution
2513 if first.startswith(loghead) or kw['islog']:
2525 if first.startswith(loghead) or kw['islog']:
2514 print 'Loading log file <%s> one line at a time...' % fname
2526 print 'Loading log file <%s> one line at a time...' % fname
2515 if kw['quiet']:
2527 if kw['quiet']:
2516 stdout_save = sys.stdout
2528 stdout_save = sys.stdout
2517 sys.stdout = StringIO.StringIO()
2529 sys.stdout = StringIO.StringIO()
2518 try:
2530 try:
2519 globs,locs = where[0:2]
2531 globs,locs = where[0:2]
2520 except:
2532 except:
2521 try:
2533 try:
2522 globs = locs = where[0]
2534 globs = locs = where[0]
2523 except:
2535 except:
2524 globs = locs = globals()
2536 globs = locs = globals()
2525 badblocks = []
2537 badblocks = []
2526
2538
2527 # we also need to identify indented blocks of code when replaying
2539 # we also need to identify indented blocks of code when replaying
2528 # logs and put them together before passing them to an exec
2540 # logs and put them together before passing them to an exec
2529 # statement. This takes a bit of regexp and look-ahead work in the
2541 # statement. This takes a bit of regexp and look-ahead work in the
2530 # file. It's easiest if we swallow the whole thing in memory
2542 # file. It's easiest if we swallow the whole thing in memory
2531 # first, and manually walk through the lines list moving the
2543 # first, and manually walk through the lines list moving the
2532 # counter ourselves.
2544 # counter ourselves.
2533 indent_re = re.compile('\s+\S')
2545 indent_re = re.compile('\s+\S')
2534 xfile = open(fname)
2546 xfile = open(fname)
2535 filelines = xfile.readlines()
2547 filelines = xfile.readlines()
2536 xfile.close()
2548 xfile.close()
2537 nlines = len(filelines)
2549 nlines = len(filelines)
2538 lnum = 0
2550 lnum = 0
2539 while lnum < nlines:
2551 while lnum < nlines:
2540 line = filelines[lnum]
2552 line = filelines[lnum]
2541 lnum += 1
2553 lnum += 1
2542 # don't re-insert logger status info into cache
2554 # don't re-insert logger status info into cache
2543 if line.startswith('#log#'):
2555 if line.startswith('#log#'):
2544 continue
2556 continue
2545 else:
2557 else:
2546 # build a block of code (maybe a single line) for execution
2558 # build a block of code (maybe a single line) for execution
2547 block = line
2559 block = line
2548 try:
2560 try:
2549 next = filelines[lnum] # lnum has already incremented
2561 next = filelines[lnum] # lnum has already incremented
2550 except:
2562 except:
2551 next = None
2563 next = None
2552 while next and indent_re.match(next):
2564 while next and indent_re.match(next):
2553 block += next
2565 block += next
2554 lnum += 1
2566 lnum += 1
2555 try:
2567 try:
2556 next = filelines[lnum]
2568 next = filelines[lnum]
2557 except:
2569 except:
2558 next = None
2570 next = None
2559 # now execute the block of one or more lines
2571 # now execute the block of one or more lines
2560 try:
2572 try:
2561 exec block in globs,locs
2573 exec block in globs,locs
2562 except SystemExit:
2574 except SystemExit:
2563 pass
2575 pass
2564 except:
2576 except:
2565 badblocks.append(block.rstrip())
2577 badblocks.append(block.rstrip())
2566 if kw['quiet']: # restore stdout
2578 if kw['quiet']: # restore stdout
2567 sys.stdout.close()
2579 sys.stdout.close()
2568 sys.stdout = stdout_save
2580 sys.stdout = stdout_save
2569 print 'Finished replaying log file <%s>' % fname
2581 print 'Finished replaying log file <%s>' % fname
2570 if badblocks:
2582 if badblocks:
2571 print >> sys.stderr, ('\nThe following lines/blocks in file '
2583 print >> sys.stderr, ('\nThe following lines/blocks in file '
2572 '<%s> reported errors:' % fname)
2584 '<%s> reported errors:' % fname)
2573
2585
2574 for badline in badblocks:
2586 for badline in badblocks:
2575 print >> sys.stderr, badline
2587 print >> sys.stderr, badline
2576 else: # regular file execution
2588 else: # regular file execution
2577 try:
2589 try:
2578 if sys.platform == 'win32':
2590 if sys.platform == 'win32':
2579 # Work around a bug in Python for Windows. The bug was
2591 # Work around a bug in Python for Windows. The bug was
2580 # fixed in in Python 2.5 r54159 and 54158, but that's still
2592 # fixed in in Python 2.5 r54159 and 54158, but that's still
2581 # SVN Python as of March/07. For details, see:
2593 # SVN Python as of March/07. For details, see:
2582 # http://projects.scipy.org/ipython/ipython/ticket/123
2594 # http://projects.scipy.org/ipython/ipython/ticket/123
2583 exec file(fname) in where[0],where[1]
2595 exec file(fname) in where[0],where[1]
2584 else:
2596 else:
2585 execfile(fname,*where)
2597 execfile(fname,*where)
2586 except SyntaxError:
2598 except SyntaxError:
2587 self.showsyntaxerror()
2599 self.showsyntaxerror()
2588 warn('Failure executing file: <%s>' % fname)
2600 warn('Failure executing file: <%s>' % fname)
2589 except SystemExit,status:
2601 except SystemExit,status:
2590 if not kw['exit_ignore']:
2602 if not kw['exit_ignore']:
2591 self.showtraceback()
2603 self.showtraceback()
2592 warn('Failure executing file: <%s>' % fname)
2604 warn('Failure executing file: <%s>' % fname)
2593 except:
2605 except:
2594 self.showtraceback()
2606 self.showtraceback()
2595 warn('Failure executing file: <%s>' % fname)
2607 warn('Failure executing file: <%s>' % fname)
2596
2608
2597 syspath_cleanup()
2609 syspath_cleanup()
2598
2610
2599 #************************* end of file <iplib.py> *****************************
2611 #************************* end of file <iplib.py> *****************************
@@ -1,6513 +1,6525 b''
1 2007-04-07 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * Tag 0.8.0 for release.
4
5 * IPython/iplib.py (reloadhist): add API function to cleanly
6 reload the readline history, which was growing inappropriately on
7 every %run call.
8
9 * win32_manual_post_install.py (run): apply last part of Nicolas
10 Pernetty's patch (I'd accidentally applied it in a different
11 directory and this particular file didn't get patched).
12
1 2007-04-05 Fernando Perez <Fernando.Perez@colorado.edu>
13 2007-04-05 Fernando Perez <Fernando.Perez@colorado.edu>
2
14
3 * IPython/Shell.py (MAIN_THREAD_ID): get rid of my stupid hack to
15 * IPython/Shell.py (MAIN_THREAD_ID): get rid of my stupid hack to
4 find the main thread id and use the proper API call. Thanks to
16 find the main thread id and use the proper API call. Thanks to
5 Stefan for the fix.
17 Stefan for the fix.
6
18
7 * test/test_prefilter.py (esc_handler_tests): udpate one of Dan's
19 * test/test_prefilter.py (esc_handler_tests): udpate one of Dan's
8 unit tests to reflect fixed ticket #52, and add more tests sent by
20 unit tests to reflect fixed ticket #52, and add more tests sent by
9 him.
21 him.
10
22
11 * IPython/iplib.py (raw_input): restore the readline completer
23 * IPython/iplib.py (raw_input): restore the readline completer
12 state on every input, in case third-party code messed it up.
24 state on every input, in case third-party code messed it up.
13 (_prefilter): revert recent addition of early-escape checks which
25 (_prefilter): revert recent addition of early-escape checks which
14 prevent many valid alias calls from working.
26 prevent many valid alias calls from working.
15
27
16 * IPython/Shell.py (MTInteractiveShell.runcode): add a tracking
28 * IPython/Shell.py (MTInteractiveShell.runcode): add a tracking
17 flag for sigint handler so we don't run a full signal() call on
29 flag for sigint handler so we don't run a full signal() call on
18 each runcode access.
30 each runcode access.
19
31
20 * IPython/Magic.py (magic_whos): small improvement to diagnostic
32 * IPython/Magic.py (magic_whos): small improvement to diagnostic
21 message.
33 message.
22
34
23 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
35 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
24
36
25 * IPython/Shell.py (sigint_handler): I *THINK* I finally got
37 * IPython/Shell.py (sigint_handler): I *THINK* I finally got
26 asynchronous exceptions working, i.e., Ctrl-C can actually
38 asynchronous exceptions working, i.e., Ctrl-C can actually
27 interrupt long-running code in the multithreaded shells.
39 interrupt long-running code in the multithreaded shells.
28
40
29 This is using Tomer Filiba's great ctypes-based trick:
41 This is using Tomer Filiba's great ctypes-based trick:
30 http://sebulba.wikispaces.com/recipe+thread2. I'd already tried
42 http://sebulba.wikispaces.com/recipe+thread2. I'd already tried
31 this in the past, but hadn't been able to make it work before. So
43 this in the past, but hadn't been able to make it work before. So
32 far it looks like it's actually running, but this needs more
44 far it looks like it's actually running, but this needs more
33 testing. If it really works, I'll be *very* happy, and we'll owe
45 testing. If it really works, I'll be *very* happy, and we'll owe
34 a huge thank you to Tomer. My current implementation is ugly,
46 a huge thank you to Tomer. My current implementation is ugly,
35 hackish and uses nasty globals, but I don't want to try and clean
47 hackish and uses nasty globals, but I don't want to try and clean
36 anything up until we know if it actually works.
48 anything up until we know if it actually works.
37
49
38 NOTE: this feature needs ctypes to work. ctypes is included in
50 NOTE: this feature needs ctypes to work. ctypes is included in
39 Python2.5, but 2.4 users will need to manually install it. This
51 Python2.5, but 2.4 users will need to manually install it. This
40 feature makes multi-threaded shells so much more usable that it's
52 feature makes multi-threaded shells so much more usable that it's
41 a minor price to pay (ctypes is very easy to install, already a
53 a minor price to pay (ctypes is very easy to install, already a
42 requirement for win32 and available in major linux distros).
54 requirement for win32 and available in major linux distros).
43
55
44 2007-04-04 Ville Vainio <vivainio@gmail.com>
56 2007-04-04 Ville Vainio <vivainio@gmail.com>
45
57
46 * Extensions/ipy_completers.py, ipy_stock_completers.py:
58 * Extensions/ipy_completers.py, ipy_stock_completers.py:
47 Moved implementations of 'bundled' completers to ipy_completers.py,
59 Moved implementations of 'bundled' completers to ipy_completers.py,
48 they are only enabled in ipy_stock_completers.py.
60 they are only enabled in ipy_stock_completers.py.
49
61
50 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
62 2007-04-04 Fernando Perez <Fernando.Perez@colorado.edu>
51
63
52 * IPython/PyColorize.py (Parser.format2): Fix identation of
64 * IPython/PyColorize.py (Parser.format2): Fix identation of
53 colorzied output and return early if color scheme is NoColor, to
65 colorzied output and return early if color scheme is NoColor, to
54 avoid unnecessary and expensive tokenization. Closes #131.
66 avoid unnecessary and expensive tokenization. Closes #131.
55
67
56 2007-04-03 Fernando Perez <Fernando.Perez@colorado.edu>
68 2007-04-03 Fernando Perez <Fernando.Perez@colorado.edu>
57
69
58 * IPython/Debugger.py: disable the use of pydb version 1.17. It
70 * IPython/Debugger.py: disable the use of pydb version 1.17. It
59 has a critical bug (a missing import that makes post-mortem not
71 has a critical bug (a missing import that makes post-mortem not
60 work at all). Unfortunately as of this time, this is the version
72 work at all). Unfortunately as of this time, this is the version
61 shipped with Ubuntu Edgy, so quite a few people have this one. I
73 shipped with Ubuntu Edgy, so quite a few people have this one. I
62 hope Edgy will update to a more recent package.
74 hope Edgy will update to a more recent package.
63
75
64 2007-04-02 Fernando Perez <Fernando.Perez@colorado.edu>
76 2007-04-02 Fernando Perez <Fernando.Perez@colorado.edu>
65
77
66 * IPython/iplib.py (_prefilter): close #52, second part of a patch
78 * IPython/iplib.py (_prefilter): close #52, second part of a patch
67 set by Stefan (only the first part had been applied before).
79 set by Stefan (only the first part had been applied before).
68
80
69 * IPython/Extensions/ipy_stock_completers.py (module_completer):
81 * IPython/Extensions/ipy_stock_completers.py (module_completer):
70 remove usage of the dangerous pkgutil.walk_packages(). See
82 remove usage of the dangerous pkgutil.walk_packages(). See
71 details in comments left in the code.
83 details in comments left in the code.
72
84
73 * IPython/Magic.py (magic_whos): add support for numpy arrays
85 * IPython/Magic.py (magic_whos): add support for numpy arrays
74 similar to what we had for Numeric.
86 similar to what we had for Numeric.
75
87
76 * IPython/completer.py (IPCompleter.complete): extend the
88 * IPython/completer.py (IPCompleter.complete): extend the
77 complete() call API to support completions by other mechanisms
89 complete() call API to support completions by other mechanisms
78 than readline. Closes #109.
90 than readline. Closes #109.
79
91
80 * IPython/iplib.py (safe_execfile): add a safeguard under Win32 to
92 * IPython/iplib.py (safe_execfile): add a safeguard under Win32 to
81 protect against a bug in Python's execfile(). Closes #123.
93 protect against a bug in Python's execfile(). Closes #123.
82
94
83 2007-04-01 Fernando Perez <Fernando.Perez@colorado.edu>
95 2007-04-01 Fernando Perez <Fernando.Perez@colorado.edu>
84
96
85 * IPython/iplib.py (split_user_input): ensure that when splitting
97 * IPython/iplib.py (split_user_input): ensure that when splitting
86 user input, the part that can be treated as a python name is pure
98 user input, the part that can be treated as a python name is pure
87 ascii (Python identifiers MUST be pure ascii). Part of the
99 ascii (Python identifiers MUST be pure ascii). Part of the
88 ongoing Unicode support work.
100 ongoing Unicode support work.
89
101
90 * IPython/Prompts.py (prompt_specials_color): Add \N for the
102 * IPython/Prompts.py (prompt_specials_color): Add \N for the
91 actual prompt number, without any coloring. This allows users to
103 actual prompt number, without any coloring. This allows users to
92 produce numbered prompts with their own colors. Added after a
104 produce numbered prompts with their own colors. Added after a
93 report/request by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
105 report/request by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
94
106
95 2007-03-31 Walter Doerwald <walter@livinglogic.de>
107 2007-03-31 Walter Doerwald <walter@livinglogic.de>
96
108
97 * IPython/Extensions/igrid.py: Map the return key
109 * IPython/Extensions/igrid.py: Map the return key
98 to enter() and shift-return to enterattr().
110 to enter() and shift-return to enterattr().
99
111
100 2007-03-30 Fernando Perez <Fernando.Perez@colorado.edu>
112 2007-03-30 Fernando Perez <Fernando.Perez@colorado.edu>
101
113
102 * IPython/Magic.py (magic_psearch): add unicode support by
114 * IPython/Magic.py (magic_psearch): add unicode support by
103 encoding to ascii the input, since this routine also only deals
115 encoding to ascii the input, since this routine also only deals
104 with valid Python names. Fixes a bug reported by Stefan.
116 with valid Python names. Fixes a bug reported by Stefan.
105
117
106 2007-03-29 Fernando Perez <Fernando.Perez@colorado.edu>
118 2007-03-29 Fernando Perez <Fernando.Perez@colorado.edu>
107
119
108 * IPython/Magic.py (_inspect): convert unicode input into ascii
120 * IPython/Magic.py (_inspect): convert unicode input into ascii
109 before trying to evaluate it as a Python identifier. This fixes a
121 before trying to evaluate it as a Python identifier. This fixes a
110 problem that the new unicode support had introduced when analyzing
122 problem that the new unicode support had introduced when analyzing
111 long definition lines for functions.
123 long definition lines for functions.
112
124
113 2007-03-24 Walter Doerwald <walter@livinglogic.de>
125 2007-03-24 Walter Doerwald <walter@livinglogic.de>
114
126
115 * IPython/Extensions/igrid.py: Fix picking. Using
127 * IPython/Extensions/igrid.py: Fix picking. Using
116 igrid with wxPython 2.6 and -wthread should work now.
128 igrid with wxPython 2.6 and -wthread should work now.
117 igrid.display() simply tries to create a frame without
129 igrid.display() simply tries to create a frame without
118 an application. Only if this fails an application is created.
130 an application. Only if this fails an application is created.
119
131
120 2007-03-23 Walter Doerwald <walter@livinglogic.de>
132 2007-03-23 Walter Doerwald <walter@livinglogic.de>
121
133
122 * IPython/Extensions/path.py: Updated to version 2.2.
134 * IPython/Extensions/path.py: Updated to version 2.2.
123
135
124 2007-03-23 Ville Vainio <vivainio@gmail.com>
136 2007-03-23 Ville Vainio <vivainio@gmail.com>
125
137
126 * iplib.py: recursive alias expansion now works better, so that
138 * iplib.py: recursive alias expansion now works better, so that
127 cases like 'top' -> 'd:/cygwin/top' -> 'ls :/cygwin/top'
139 cases like 'top' -> 'd:/cygwin/top' -> 'ls :/cygwin/top'
128 doesn't trip up the process, if 'd' has been aliased to 'ls'.
140 doesn't trip up the process, if 'd' has been aliased to 'ls'.
129
141
130 * Extensions/ipy_gnuglobal.py added, provides %global magic
142 * Extensions/ipy_gnuglobal.py added, provides %global magic
131 for users of http://www.gnu.org/software/global
143 for users of http://www.gnu.org/software/global
132
144
133 * iplib.py: '!command /?' now doesn't invoke IPython's help system.
145 * iplib.py: '!command /?' now doesn't invoke IPython's help system.
134 Closes #52. Patch by Stefan van der Walt.
146 Closes #52. Patch by Stefan van der Walt.
135
147
136 2007-03-23 Fernando Perez <Fernando.Perez@colorado.edu>
148 2007-03-23 Fernando Perez <Fernando.Perez@colorado.edu>
137
149
138 * IPython/FakeModule.py (FakeModule.__init__): Small fix to
150 * IPython/FakeModule.py (FakeModule.__init__): Small fix to
139 respect the __file__ attribute when using %run. Thanks to a bug
151 respect the __file__ attribute when using %run. Thanks to a bug
140 report by Sebastian Rooks <sebastian.rooks-AT-free.fr>.
152 report by Sebastian Rooks <sebastian.rooks-AT-free.fr>.
141
153
142 2007-03-22 Fernando Perez <Fernando.Perez@colorado.edu>
154 2007-03-22 Fernando Perez <Fernando.Perez@colorado.edu>
143
155
144 * IPython/iplib.py (raw_input): Fix mishandling of unicode at
156 * IPython/iplib.py (raw_input): Fix mishandling of unicode at
145 input. Patch sent by Stefan.
157 input. Patch sent by Stefan.
146
158
147 2007-03-20 J�rgen Stenarson <jorgen.stenarson@bostream.nu>
159 2007-03-20 J�rgen Stenarson <jorgen.stenarson@bostream.nu>
148 * IPython/Extensions/ipy_stock_completer.py
160 * IPython/Extensions/ipy_stock_completer.py
149 shlex_split, fix bug in shlex_split. len function
161 shlex_split, fix bug in shlex_split. len function
150 call was missing an if statement. Caused shlex_split to
162 call was missing an if statement. Caused shlex_split to
151 sometimes return "" as last element.
163 sometimes return "" as last element.
152
164
153 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu>
165 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu>
154
166
155 * IPython/completer.py
167 * IPython/completer.py
156 (IPCompleter.file_matches.single_dir_expand): fix a problem
168 (IPCompleter.file_matches.single_dir_expand): fix a problem
157 reported by Stefan, where directories containign a single subdir
169 reported by Stefan, where directories containign a single subdir
158 would be completed too early.
170 would be completed too early.
159
171
160 * IPython/Shell.py (_load_pylab): Make the execution of 'from
172 * IPython/Shell.py (_load_pylab): Make the execution of 'from
161 pylab import *' when -pylab is given be optional. A new flag,
173 pylab import *' when -pylab is given be optional. A new flag,
162 pylab_import_all controls this behavior, the default is True for
174 pylab_import_all controls this behavior, the default is True for
163 backwards compatibility.
175 backwards compatibility.
164
176
165 * IPython/ultraTB.py (_formatTracebackLines): Added (slightly
177 * IPython/ultraTB.py (_formatTracebackLines): Added (slightly
166 modified) R. Bernstein's patch for fully syntax highlighted
178 modified) R. Bernstein's patch for fully syntax highlighted
167 tracebacks. The functionality is also available under ultraTB for
179 tracebacks. The functionality is also available under ultraTB for
168 non-ipython users (someone using ultraTB but outside an ipython
180 non-ipython users (someone using ultraTB but outside an ipython
169 session). They can select the color scheme by setting the
181 session). They can select the color scheme by setting the
170 module-level global DEFAULT_SCHEME. The highlight functionality
182 module-level global DEFAULT_SCHEME. The highlight functionality
171 also works when debugging.
183 also works when debugging.
172
184
173 * IPython/genutils.py (IOStream.close): small patch by
185 * IPython/genutils.py (IOStream.close): small patch by
174 R. Bernstein for improved pydb support.
186 R. Bernstein for improved pydb support.
175
187
176 * IPython/Debugger.py (Pdb.format_stack_entry): Added patch by
188 * IPython/Debugger.py (Pdb.format_stack_entry): Added patch by
177 DaveS <davls@telus.net> to improve support of debugging under
189 DaveS <davls@telus.net> to improve support of debugging under
178 NTEmacs, including improved pydb behavior.
190 NTEmacs, including improved pydb behavior.
179
191
180 * IPython/Magic.py (magic_prun): Fix saving of profile info for
192 * IPython/Magic.py (magic_prun): Fix saving of profile info for
181 Python 2.5, where the stats object API changed a little. Thanks
193 Python 2.5, where the stats object API changed a little. Thanks
182 to a bug report by Paul Smith <paul.smith-AT-catugmt.com>.
194 to a bug report by Paul Smith <paul.smith-AT-catugmt.com>.
183
195
184 * IPython/ColorANSI.py (InputTermColors.Normal): applied Nicolas
196 * IPython/ColorANSI.py (InputTermColors.Normal): applied Nicolas
185 Pernetty's patch to improve support for (X)Emacs under Win32.
197 Pernetty's patch to improve support for (X)Emacs under Win32.
186
198
187 2007-03-17 Fernando Perez <Fernando.Perez@colorado.edu>
199 2007-03-17 Fernando Perez <Fernando.Perez@colorado.edu>
188
200
189 * IPython/Shell.py (hijack_wx): ipmort WX with current semantics
201 * IPython/Shell.py (hijack_wx): ipmort WX with current semantics
190 to quiet a deprecation warning that fires with Wx 2.8. Thanks to
202 to quiet a deprecation warning that fires with Wx 2.8. Thanks to
191 a report by Nik Tautenhahn.
203 a report by Nik Tautenhahn.
192
204
193 2007-03-16 Walter Doerwald <walter@livinglogic.de>
205 2007-03-16 Walter Doerwald <walter@livinglogic.de>
194
206
195 * setup.py: Add the igrid help files to the list of data files
207 * setup.py: Add the igrid help files to the list of data files
196 to be installed alongside igrid.
208 to be installed alongside igrid.
197 * IPython/Extensions/igrid.py: (Patch by Nik Tautenhahn)
209 * IPython/Extensions/igrid.py: (Patch by Nik Tautenhahn)
198 Show the input object of the igrid browser as the window tile.
210 Show the input object of the igrid browser as the window tile.
199 Show the object the cursor is on in the statusbar.
211 Show the object the cursor is on in the statusbar.
200
212
201 2007-03-15 Ville Vainio <vivainio@gmail.com>
213 2007-03-15 Ville Vainio <vivainio@gmail.com>
202
214
203 * Extensions/ipy_stock_completers.py: Fixed exception
215 * Extensions/ipy_stock_completers.py: Fixed exception
204 on mismatching quotes in %run completer. Patch by
216 on mismatching quotes in %run completer. Patch by
205 J�rgen Stenarson. Closes #127.
217 J�rgen Stenarson. Closes #127.
206
218
207 2007-03-14 Ville Vainio <vivainio@gmail.com>
219 2007-03-14 Ville Vainio <vivainio@gmail.com>
208
220
209 * Extensions/ext_rehashdir.py: Do not do auto_alias
221 * Extensions/ext_rehashdir.py: Do not do auto_alias
210 in %rehashdir, it clobbers %store'd aliases.
222 in %rehashdir, it clobbers %store'd aliases.
211
223
212 * UserConfig/ipy_profile_sh.py: envpersist.py extension
224 * UserConfig/ipy_profile_sh.py: envpersist.py extension
213 (beefed up %env) imported for sh profile.
225 (beefed up %env) imported for sh profile.
214
226
215 2007-03-10 Walter Doerwald <walter@livinglogic.de>
227 2007-03-10 Walter Doerwald <walter@livinglogic.de>
216
228
217 * IPython/Extensions/ipipe.py: Prefer ibrowse over igrid
229 * IPython/Extensions/ipipe.py: Prefer ibrowse over igrid
218 as the default browser.
230 as the default browser.
219 * IPython/Extensions/igrid.py: Make a few igrid attributes private.
231 * IPython/Extensions/igrid.py: Make a few igrid attributes private.
220 As igrid displays all attributes it ever encounters, fetch() (which has
232 As igrid displays all attributes it ever encounters, fetch() (which has
221 been renamed to _fetch()) doesn't have to recalculate the display attributes
233 been renamed to _fetch()) doesn't have to recalculate the display attributes
222 every time a new item is fetched. This should speed up scrolling.
234 every time a new item is fetched. This should speed up scrolling.
223
235
224 2007-03-10 Fernando Perez <Fernando.Perez@colorado.edu>
236 2007-03-10 Fernando Perez <Fernando.Perez@colorado.edu>
225
237
226 * IPython/iplib.py (InteractiveShell.__init__): fix for Alex
238 * IPython/iplib.py (InteractiveShell.__init__): fix for Alex
227 Schmolck's recently reported tab-completion bug (my previous one
239 Schmolck's recently reported tab-completion bug (my previous one
228 had a problem). Patch by Dan Milstein <danmil-AT-comcast.net>.
240 had a problem). Patch by Dan Milstein <danmil-AT-comcast.net>.
229
241
230 2007-03-09 Walter Doerwald <walter@livinglogic.de>
242 2007-03-09 Walter Doerwald <walter@livinglogic.de>
231
243
232 * IPython/Extensions/igrid.py: Patch by Nik Tautenhahn:
244 * IPython/Extensions/igrid.py: Patch by Nik Tautenhahn:
233 Close help window if exiting igrid.
245 Close help window if exiting igrid.
234
246
235 2007-03-02 J�rgen Stenarson <jorgen.stenarson@bostream.nu>
247 2007-03-02 J�rgen Stenarson <jorgen.stenarson@bostream.nu>
236
248
237 * IPython/Extensions/ipy_defaults.py: Check if readline is available
249 * IPython/Extensions/ipy_defaults.py: Check if readline is available
238 before calling functions from readline.
250 before calling functions from readline.
239
251
240 2007-03-02 Walter Doerwald <walter@livinglogic.de>
252 2007-03-02 Walter Doerwald <walter@livinglogic.de>
241
253
242 * IPython/Extensions/igrid.py: Add Nik Tautenhahns igrid extension.
254 * IPython/Extensions/igrid.py: Add Nik Tautenhahns igrid extension.
243 igrid is a wxPython-based display object for ipipe. If your system has
255 igrid is a wxPython-based display object for ipipe. If your system has
244 wx installed igrid will be the default display. Without wx ipipe falls
256 wx installed igrid will be the default display. Without wx ipipe falls
245 back to ibrowse (which needs curses). If no curses is installed ipipe
257 back to ibrowse (which needs curses). If no curses is installed ipipe
246 falls back to idump.
258 falls back to idump.
247
259
248 2007-03-01 Fernando Perez <Fernando.Perez@colorado.edu>
260 2007-03-01 Fernando Perez <Fernando.Perez@colorado.edu>
249
261
250 * IPython/iplib.py (split_user_inputBROKEN): temporarily disable
262 * IPython/iplib.py (split_user_inputBROKEN): temporarily disable
251 my changes from yesterday, they introduced bugs. Will reactivate
263 my changes from yesterday, they introduced bugs. Will reactivate
252 once I get a correct solution, which will be much easier thanks to
264 once I get a correct solution, which will be much easier thanks to
253 Dan Milstein's new prefilter test suite.
265 Dan Milstein's new prefilter test suite.
254
266
255 2007-02-28 Fernando Perez <Fernando.Perez@colorado.edu>
267 2007-02-28 Fernando Perez <Fernando.Perez@colorado.edu>
256
268
257 * IPython/iplib.py (split_user_input): fix input splitting so we
269 * IPython/iplib.py (split_user_input): fix input splitting so we
258 don't attempt attribute accesses on things that can't possibly be
270 don't attempt attribute accesses on things that can't possibly be
259 valid Python attributes. After a bug report by Alex Schmolck.
271 valid Python attributes. After a bug report by Alex Schmolck.
260 (InteractiveShell.__init__): brown-paper bag fix; regexp broke
272 (InteractiveShell.__init__): brown-paper bag fix; regexp broke
261 %magic with explicit % prefix.
273 %magic with explicit % prefix.
262
274
263 2007-02-27 Fernando Perez <Fernando.Perez@colorado.edu>
275 2007-02-27 Fernando Perez <Fernando.Perez@colorado.edu>
264
276
265 * IPython/Shell.py (IPShellGTK.mainloop): update threads calls to
277 * IPython/Shell.py (IPShellGTK.mainloop): update threads calls to
266 avoid a DeprecationWarning from GTK.
278 avoid a DeprecationWarning from GTK.
267
279
268 2007-02-22 Fernando Perez <Fernando.Perez@colorado.edu>
280 2007-02-22 Fernando Perez <Fernando.Perez@colorado.edu>
269
281
270 * IPython/genutils.py (clock): I modified clock() to return total
282 * IPython/genutils.py (clock): I modified clock() to return total
271 time, user+system. This is a more commonly needed metric. I also
283 time, user+system. This is a more commonly needed metric. I also
272 introduced the new clocku/clocks to get only user/system time if
284 introduced the new clocku/clocks to get only user/system time if
273 one wants those instead.
285 one wants those instead.
274
286
275 ***WARNING: API CHANGE*** clock() used to return only user time,
287 ***WARNING: API CHANGE*** clock() used to return only user time,
276 so if you want exactly the same results as before, use clocku
288 so if you want exactly the same results as before, use clocku
277 instead.
289 instead.
278
290
279 2007-02-22 Ville Vainio <vivainio@gmail.com>
291 2007-02-22 Ville Vainio <vivainio@gmail.com>
280
292
281 * IPython/Extensions/ipy_p4.py: Extension for improved
293 * IPython/Extensions/ipy_p4.py: Extension for improved
282 p4 (perforce version control system) experience.
294 p4 (perforce version control system) experience.
283 Adds %p4 magic with p4 command completion and
295 Adds %p4 magic with p4 command completion and
284 automatic -G argument (marshall output as python dict)
296 automatic -G argument (marshall output as python dict)
285
297
286 2007-02-19 Fernando Perez <Fernando.Perez@colorado.edu>
298 2007-02-19 Fernando Perez <Fernando.Perez@colorado.edu>
287
299
288 * IPython/demo.py (Demo.re_stop): make dashes optional in demo
300 * IPython/demo.py (Demo.re_stop): make dashes optional in demo
289 stop marks.
301 stop marks.
290 (ClearingMixin): a simple mixin to easily make a Demo class clear
302 (ClearingMixin): a simple mixin to easily make a Demo class clear
291 the screen in between blocks and have empty marquees. The
303 the screen in between blocks and have empty marquees. The
292 ClearDemo and ClearIPDemo classes that use it are included.
304 ClearDemo and ClearIPDemo classes that use it are included.
293
305
294 2007-02-18 Fernando Perez <Fernando.Perez@colorado.edu>
306 2007-02-18 Fernando Perez <Fernando.Perez@colorado.edu>
295
307
296 * IPython/irunner.py (pexpect_monkeypatch): patch pexpect to
308 * IPython/irunner.py (pexpect_monkeypatch): patch pexpect to
297 protect against exceptions at Python shutdown time. Patch
309 protect against exceptions at Python shutdown time. Patch
298 sumbmitted to upstream.
310 sumbmitted to upstream.
299
311
300 2007-02-14 Walter Doerwald <walter@livinglogic.de>
312 2007-02-14 Walter Doerwald <walter@livinglogic.de>
301
313
302 * IPython/Extensions/ibrowse.py: If entering the first object level
314 * IPython/Extensions/ibrowse.py: If entering the first object level
303 (i.e. the object for which the browser has been started) fails,
315 (i.e. the object for which the browser has been started) fails,
304 now the error is raised directly (aborting the browser) instead of
316 now the error is raised directly (aborting the browser) instead of
305 running into an empty levels list later.
317 running into an empty levels list later.
306
318
307 2007-02-03 Walter Doerwald <walter@livinglogic.de>
319 2007-02-03 Walter Doerwald <walter@livinglogic.de>
308
320
309 * IPython/Extensions/ipipe.py: Add an xrepr implementation
321 * IPython/Extensions/ipipe.py: Add an xrepr implementation
310 for the noitem object.
322 for the noitem object.
311
323
312 2007-01-31 Fernando Perez <Fernando.Perez@colorado.edu>
324 2007-01-31 Fernando Perez <Fernando.Perez@colorado.edu>
313
325
314 * IPython/completer.py (Completer.attr_matches): Fix small
326 * IPython/completer.py (Completer.attr_matches): Fix small
315 tab-completion bug with Enthought Traits objects with units.
327 tab-completion bug with Enthought Traits objects with units.
316 Thanks to a bug report by Tom Denniston
328 Thanks to a bug report by Tom Denniston
317 <tom.denniston-AT-alum.dartmouth.org>.
329 <tom.denniston-AT-alum.dartmouth.org>.
318
330
319 2007-01-27 Fernando Perez <Fernando.Perez@colorado.edu>
331 2007-01-27 Fernando Perez <Fernando.Perez@colorado.edu>
320
332
321 * IPython/Extensions/ipy_stock_completers.py (runlistpy): fix a
333 * IPython/Extensions/ipy_stock_completers.py (runlistpy): fix a
322 bug where only .ipy or .py would be completed. Once the first
334 bug where only .ipy or .py would be completed. Once the first
323 argument to %run has been given, all completions are valid because
335 argument to %run has been given, all completions are valid because
324 they are the arguments to the script, which may well be non-python
336 they are the arguments to the script, which may well be non-python
325 filenames.
337 filenames.
326
338
327 * IPython/irunner.py (InteractiveRunner.run_source): major updates
339 * IPython/irunner.py (InteractiveRunner.run_source): major updates
328 to irunner to allow it to correctly support real doctesting of
340 to irunner to allow it to correctly support real doctesting of
329 out-of-process ipython code.
341 out-of-process ipython code.
330
342
331 * IPython/Magic.py (magic_cd): Make the setting of the terminal
343 * IPython/Magic.py (magic_cd): Make the setting of the terminal
332 title an option (-noterm_title) because it completely breaks
344 title an option (-noterm_title) because it completely breaks
333 doctesting.
345 doctesting.
334
346
335 * IPython/demo.py: fix IPythonDemo class that was not actually working.
347 * IPython/demo.py: fix IPythonDemo class that was not actually working.
336
348
337 2007-01-24 Fernando Perez <Fernando.Perez@colorado.edu>
349 2007-01-24 Fernando Perez <Fernando.Perez@colorado.edu>
338
350
339 * IPython/irunner.py (main): fix small bug where extensions were
351 * IPython/irunner.py (main): fix small bug where extensions were
340 not being correctly recognized.
352 not being correctly recognized.
341
353
342 2007-01-23 Walter Doerwald <walter@livinglogic.de>
354 2007-01-23 Walter Doerwald <walter@livinglogic.de>
343
355
344 * IPython/Extensions/ipipe.py (xiter): Make sure that iterating
356 * IPython/Extensions/ipipe.py (xiter): Make sure that iterating
345 a string containing a single line yields the string itself as the
357 a string containing a single line yields the string itself as the
346 only item.
358 only item.
347
359
348 * IPython/Extensions/ibrowse.py (ibrowse): Avoid entering an
360 * IPython/Extensions/ibrowse.py (ibrowse): Avoid entering an
349 object if it's the same as the one on the last level (This avoids
361 object if it's the same as the one on the last level (This avoids
350 infinite recursion for one line strings).
362 infinite recursion for one line strings).
351
363
352 2007-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
364 2007-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
353
365
354 * IPython/ultraTB.py (AutoFormattedTB.__call__): properly flush
366 * IPython/ultraTB.py (AutoFormattedTB.__call__): properly flush
355 all output streams before printing tracebacks. This ensures that
367 all output streams before printing tracebacks. This ensures that
356 user output doesn't end up interleaved with traceback output.
368 user output doesn't end up interleaved with traceback output.
357
369
358 2007-01-10 Ville Vainio <vivainio@gmail.com>
370 2007-01-10 Ville Vainio <vivainio@gmail.com>
359
371
360 * Extensions/envpersist.py: Turbocharged %env that remembers
372 * Extensions/envpersist.py: Turbocharged %env that remembers
361 env vars across sessions; e.g. "%env PATH+=;/opt/scripts" or
373 env vars across sessions; e.g. "%env PATH+=;/opt/scripts" or
362 "%env VISUAL=jed".
374 "%env VISUAL=jed".
363
375
364 2007-01-05 Fernando Perez <Fernando.Perez@colorado.edu>
376 2007-01-05 Fernando Perez <Fernando.Perez@colorado.edu>
365
377
366 * IPython/iplib.py (showtraceback): ensure that we correctly call
378 * IPython/iplib.py (showtraceback): ensure that we correctly call
367 custom handlers in all cases (some with pdb were slipping through,
379 custom handlers in all cases (some with pdb were slipping through,
368 but I'm not exactly sure why).
380 but I'm not exactly sure why).
369
381
370 * IPython/Debugger.py (Tracer.__init__): added new class to
382 * IPython/Debugger.py (Tracer.__init__): added new class to
371 support set_trace-like usage of IPython's enhanced debugger.
383 support set_trace-like usage of IPython's enhanced debugger.
372
384
373 2006-12-24 Ville Vainio <vivainio@gmail.com>
385 2006-12-24 Ville Vainio <vivainio@gmail.com>
374
386
375 * ipmaker.py: more informative message when ipy_user_conf
387 * ipmaker.py: more informative message when ipy_user_conf
376 import fails (suggest running %upgrade).
388 import fails (suggest running %upgrade).
377
389
378 * tools/run_ipy_in_profiler.py: Utility to see where
390 * tools/run_ipy_in_profiler.py: Utility to see where
379 the time during IPython startup is spent.
391 the time during IPython startup is spent.
380
392
381 2006-12-20 Ville Vainio <vivainio@gmail.com>
393 2006-12-20 Ville Vainio <vivainio@gmail.com>
382
394
383 * 0.7.3 is out - merge all from 0.7.3 branch to trunk
395 * 0.7.3 is out - merge all from 0.7.3 branch to trunk
384
396
385 * ipapi.py: Add new ipapi method, expand_alias.
397 * ipapi.py: Add new ipapi method, expand_alias.
386
398
387 * Release.py: Bump up version to 0.7.4.svn
399 * Release.py: Bump up version to 0.7.4.svn
388
400
389 2006-12-17 Ville Vainio <vivainio@gmail.com>
401 2006-12-17 Ville Vainio <vivainio@gmail.com>
390
402
391 * Extensions/jobctrl.py: Fixed &cmd arg arg...
403 * Extensions/jobctrl.py: Fixed &cmd arg arg...
392 to work properly on posix too
404 to work properly on posix too
393
405
394 * Release.py: Update revnum (version is still just 0.7.3).
406 * Release.py: Update revnum (version is still just 0.7.3).
395
407
396 2006-12-15 Ville Vainio <vivainio@gmail.com>
408 2006-12-15 Ville Vainio <vivainio@gmail.com>
397
409
398 * scripts/ipython_win_post_install: create ipython.py in
410 * scripts/ipython_win_post_install: create ipython.py in
399 prefix + "/scripts".
411 prefix + "/scripts".
400
412
401 * Release.py: Update version to 0.7.3.
413 * Release.py: Update version to 0.7.3.
402
414
403 2006-12-14 Ville Vainio <vivainio@gmail.com>
415 2006-12-14 Ville Vainio <vivainio@gmail.com>
404
416
405 * scripts/ipython_win_post_install: Overwrite old shortcuts
417 * scripts/ipython_win_post_install: Overwrite old shortcuts
406 if they already exist
418 if they already exist
407
419
408 * Release.py: release 0.7.3rc2
420 * Release.py: release 0.7.3rc2
409
421
410 2006-12-13 Ville Vainio <vivainio@gmail.com>
422 2006-12-13 Ville Vainio <vivainio@gmail.com>
411
423
412 * Branch and update Release.py for 0.7.3rc1
424 * Branch and update Release.py for 0.7.3rc1
413
425
414 2006-12-13 Fernando Perez <Fernando.Perez@colorado.edu>
426 2006-12-13 Fernando Perez <Fernando.Perez@colorado.edu>
415
427
416 * IPython/Shell.py (IPShellWX): update for current WX naming
428 * IPython/Shell.py (IPShellWX): update for current WX naming
417 conventions, to avoid a deprecation warning with current WX
429 conventions, to avoid a deprecation warning with current WX
418 versions. Thanks to a report by Danny Shevitz.
430 versions. Thanks to a report by Danny Shevitz.
419
431
420 2006-12-12 Ville Vainio <vivainio@gmail.com>
432 2006-12-12 Ville Vainio <vivainio@gmail.com>
421
433
422 * ipmaker.py: apply david cournapeau's patch to make
434 * ipmaker.py: apply david cournapeau's patch to make
423 import_some work properly even when ipythonrc does
435 import_some work properly even when ipythonrc does
424 import_some on empty list (it was an old bug!).
436 import_some on empty list (it was an old bug!).
425
437
426 * UserConfig/ipy_user_conf.py, UserConfig/ipythonrc:
438 * UserConfig/ipy_user_conf.py, UserConfig/ipythonrc:
427 Add deprecation note to ipythonrc and a url to wiki
439 Add deprecation note to ipythonrc and a url to wiki
428 in ipy_user_conf.py
440 in ipy_user_conf.py
429
441
430
442
431 * Magic.py (%run): %run myscript.ipy now runs myscript.ipy
443 * Magic.py (%run): %run myscript.ipy now runs myscript.ipy
432 as if it was typed on IPython command prompt, i.e.
444 as if it was typed on IPython command prompt, i.e.
433 as IPython script.
445 as IPython script.
434
446
435 * example-magic.py, magic_grepl.py: remove outdated examples
447 * example-magic.py, magic_grepl.py: remove outdated examples
436
448
437 2006-12-11 Fernando Perez <Fernando.Perez@colorado.edu>
449 2006-12-11 Fernando Perez <Fernando.Perez@colorado.edu>
438
450
439 * IPython/iplib.py (debugger): prevent a nasty traceback if %debug
451 * IPython/iplib.py (debugger): prevent a nasty traceback if %debug
440 is called before any exception has occurred.
452 is called before any exception has occurred.
441
453
442 2006-12-08 Ville Vainio <vivainio@gmail.com>
454 2006-12-08 Ville Vainio <vivainio@gmail.com>
443
455
444 * Extensions/ipy_stock_completers.py: fix cd completer
456 * Extensions/ipy_stock_completers.py: fix cd completer
445 to translate /'s to \'s again.
457 to translate /'s to \'s again.
446
458
447 * completer.py: prevent traceback on file completions w/
459 * completer.py: prevent traceback on file completions w/
448 backslash.
460 backslash.
449
461
450 * Release.py: Update release number to 0.7.3b3 for release
462 * Release.py: Update release number to 0.7.3b3 for release
451
463
452 2006-12-07 Ville Vainio <vivainio@gmail.com>
464 2006-12-07 Ville Vainio <vivainio@gmail.com>
453
465
454 * Extensions/ipy_signals.py: Ignore ctrl+C in IPython process
466 * Extensions/ipy_signals.py: Ignore ctrl+C in IPython process
455 while executing external code. Provides more shell-like behaviour
467 while executing external code. Provides more shell-like behaviour
456 and overall better response to ctrl + C / ctrl + break.
468 and overall better response to ctrl + C / ctrl + break.
457
469
458 * tools/make_tarball.py: new script to create tarball straight from svn
470 * tools/make_tarball.py: new script to create tarball straight from svn
459 (setup.py sdist doesn't work on win32).
471 (setup.py sdist doesn't work on win32).
460
472
461 * Extensions/ipy_stock_completers.py: fix cd completer to give up
473 * Extensions/ipy_stock_completers.py: fix cd completer to give up
462 on dirnames with spaces and use the default completer instead.
474 on dirnames with spaces and use the default completer instead.
463
475
464 * Revision.py: Change version to 0.7.3b2 for release.
476 * Revision.py: Change version to 0.7.3b2 for release.
465
477
466 2006-12-05 Ville Vainio <vivainio@gmail.com>
478 2006-12-05 Ville Vainio <vivainio@gmail.com>
467
479
468 * Magic.py, iplib.py, completer.py: Apply R. Bernstein's
480 * Magic.py, iplib.py, completer.py: Apply R. Bernstein's
469 pydb patch 4 (rm debug printing, py 2.5 checking)
481 pydb patch 4 (rm debug printing, py 2.5 checking)
470
482
471 2006-11-30 Walter Doerwald <walter@livinglogic.de>
483 2006-11-30 Walter Doerwald <walter@livinglogic.de>
472 * IPython/Extensions/ibrowse.py: Add two new commands to ibrowse:
484 * IPython/Extensions/ibrowse.py: Add two new commands to ibrowse:
473 "refresh" (mapped to "r") refreshes the screen by restarting the iterator.
485 "refresh" (mapped to "r") refreshes the screen by restarting the iterator.
474 "refreshfind" (mapped to "R") does the same but tries to go back to the same
486 "refreshfind" (mapped to "R") does the same but tries to go back to the same
475 object the cursor was on before the refresh. The command "markrange" is
487 object the cursor was on before the refresh. The command "markrange" is
476 mapped to "%" now.
488 mapped to "%" now.
477 * IPython/Extensions/ibrowse.py: Make igrpentry and ipwdentry comparable.
489 * IPython/Extensions/ibrowse.py: Make igrpentry and ipwdentry comparable.
478
490
479 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu>
491 2006-11-29 Fernando Perez <Fernando.Perez@colorado.edu>
480
492
481 * IPython/Magic.py (magic_debug): new %debug magic to activate the
493 * IPython/Magic.py (magic_debug): new %debug magic to activate the
482 interactive debugger on the last traceback, without having to call
494 interactive debugger on the last traceback, without having to call
483 %pdb and rerun your code. Made minor changes in various modules,
495 %pdb and rerun your code. Made minor changes in various modules,
484 should automatically recognize pydb if available.
496 should automatically recognize pydb if available.
485
497
486 2006-11-28 Ville Vainio <vivainio@gmail.com>
498 2006-11-28 Ville Vainio <vivainio@gmail.com>
487
499
488 * completer.py: If the text start with !, show file completions
500 * completer.py: If the text start with !, show file completions
489 properly. This helps when trying to complete command name
501 properly. This helps when trying to complete command name
490 for shell escapes.
502 for shell escapes.
491
503
492 2006-11-27 Ville Vainio <vivainio@gmail.com>
504 2006-11-27 Ville Vainio <vivainio@gmail.com>
493
505
494 * ipy_stock_completers.py: bzr completer submitted by Stefan van
506 * ipy_stock_completers.py: bzr completer submitted by Stefan van
495 der Walt. Clean up svn and hg completers by using a common
507 der Walt. Clean up svn and hg completers by using a common
496 vcs_completer.
508 vcs_completer.
497
509
498 2006-11-26 Ville Vainio <vivainio@gmail.com>
510 2006-11-26 Ville Vainio <vivainio@gmail.com>
499
511
500 * Remove ipconfig and %config; you should use _ip.options structure
512 * Remove ipconfig and %config; you should use _ip.options structure
501 directly instead!
513 directly instead!
502
514
503 * genutils.py: add wrap_deprecated function for deprecating callables
515 * genutils.py: add wrap_deprecated function for deprecating callables
504
516
505 * iplib.py: deprecate ipmagic, ipsystem, ipalias. Use _ip.magic and
517 * iplib.py: deprecate ipmagic, ipsystem, ipalias. Use _ip.magic and
506 _ip.system instead. ipalias is redundant.
518 _ip.system instead. ipalias is redundant.
507
519
508 * Magic.py: %rehashdir no longer aliases 'cmdname' to 'cmdname.exe' on
520 * Magic.py: %rehashdir no longer aliases 'cmdname' to 'cmdname.exe' on
509 win32, but just 'cmdname'. Other extensions (non-'exe') are still made
521 win32, but just 'cmdname'. Other extensions (non-'exe') are still made
510 explicit.
522 explicit.
511
523
512 * ipy_stock_completers.py: 'hg' (mercurial VCS) now has a custom
524 * ipy_stock_completers.py: 'hg' (mercurial VCS) now has a custom
513 completer. Try it by entering 'hg ' and pressing tab.
525 completer. Try it by entering 'hg ' and pressing tab.
514
526
515 * macro.py: Give Macro a useful __repr__ method
527 * macro.py: Give Macro a useful __repr__ method
516
528
517 * Magic.py: %whos abbreviates the typename of Macro for brevity.
529 * Magic.py: %whos abbreviates the typename of Macro for brevity.
518
530
519 2006-11-24 Walter Doerwald <walter@livinglogic.de>
531 2006-11-24 Walter Doerwald <walter@livinglogic.de>
520 * IPython/Extensions/astyle.py: Do a relative import of ipipe, so that
532 * IPython/Extensions/astyle.py: Do a relative import of ipipe, so that
521 we don't get a duplicate ipipe module, where registration of the xrepr
533 we don't get a duplicate ipipe module, where registration of the xrepr
522 implementation for Text is useless.
534 implementation for Text is useless.
523
535
524 * IPython/Extensions/ipipe.py: Fix __xrepr__() implementation for ils.
536 * IPython/Extensions/ipipe.py: Fix __xrepr__() implementation for ils.
525
537
526 * IPython/Extensions/ibrowse.py: Fix keymapping for the enter command.
538 * IPython/Extensions/ibrowse.py: Fix keymapping for the enter command.
527
539
528 2006-11-24 Ville Vainio <vivainio@gmail.com>
540 2006-11-24 Ville Vainio <vivainio@gmail.com>
529
541
530 * Magic.py, manual_base.lyx: Kirill Smelkov patch:
542 * Magic.py, manual_base.lyx: Kirill Smelkov patch:
531 try to use "cProfile" instead of the slower pure python
543 try to use "cProfile" instead of the slower pure python
532 "profile"
544 "profile"
533
545
534 2006-11-23 Ville Vainio <vivainio@gmail.com>
546 2006-11-23 Ville Vainio <vivainio@gmail.com>
535
547
536 * manual_base.lyx: Kirill Smelkov patch: Fix wrong
548 * manual_base.lyx: Kirill Smelkov patch: Fix wrong
537 Qt+IPython+Designer link in documentation.
549 Qt+IPython+Designer link in documentation.
538
550
539 * Extensions/ipy_pydb.py: R. Bernstein's patch for passing
551 * Extensions/ipy_pydb.py: R. Bernstein's patch for passing
540 correct Pdb object to %pydb.
552 correct Pdb object to %pydb.
541
553
542
554
543 2006-11-22 Walter Doerwald <walter@livinglogic.de>
555 2006-11-22 Walter Doerwald <walter@livinglogic.de>
544 * IPython/Extensions/astyle.py: Text needs it's own implemenation of the
556 * IPython/Extensions/astyle.py: Text needs it's own implemenation of the
545 generic xrepr(), otherwise the list implementation would kick in.
557 generic xrepr(), otherwise the list implementation would kick in.
546
558
547 2006-11-21 Ville Vainio <vivainio@gmail.com>
559 2006-11-21 Ville Vainio <vivainio@gmail.com>
548
560
549 * upgrade_dir.py: Now actually overwrites a nonmodified user file
561 * upgrade_dir.py: Now actually overwrites a nonmodified user file
550 with one from UserConfig.
562 with one from UserConfig.
551
563
552 * ipy_profile_sh.py: Add dummy "depth" to var_expand lambda,
564 * ipy_profile_sh.py: Add dummy "depth" to var_expand lambda,
553 it was missing which broke the sh profile.
565 it was missing which broke the sh profile.
554
566
555 * completer.py: file completer now uses explicit '/' instead
567 * completer.py: file completer now uses explicit '/' instead
556 of os.path.join, expansion of 'foo' was broken on win32
568 of os.path.join, expansion of 'foo' was broken on win32
557 if there was one directory with name 'foobar'.
569 if there was one directory with name 'foobar'.
558
570
559 * A bunch of patches from Kirill Smelkov:
571 * A bunch of patches from Kirill Smelkov:
560
572
561 * [patch 9/9] doc: point bug-tracker URL to IPythons trac-tickets.
573 * [patch 9/9] doc: point bug-tracker URL to IPythons trac-tickets.
562
574
563 * [patch 7/9] Implement %page -r (page in raw mode) -
575 * [patch 7/9] Implement %page -r (page in raw mode) -
564
576
565 * [patch 5/9] ScientificPython webpage has moved
577 * [patch 5/9] ScientificPython webpage has moved
566
578
567 * [patch 4/9] The manual mentions %ds, should be %dhist
579 * [patch 4/9] The manual mentions %ds, should be %dhist
568
580
569 * [patch 3/9] Kill old bits from %prun doc.
581 * [patch 3/9] Kill old bits from %prun doc.
570
582
571 * [patch 1/9] Fix typos here and there.
583 * [patch 1/9] Fix typos here and there.
572
584
573 2006-11-08 Ville Vainio <vivainio@gmail.com>
585 2006-11-08 Ville Vainio <vivainio@gmail.com>
574
586
575 * completer.py (attr_matches): catch all exceptions raised
587 * completer.py (attr_matches): catch all exceptions raised
576 by eval of expr with dots.
588 by eval of expr with dots.
577
589
578 2006-11-07 Fernando Perez <Fernando.Perez@colorado.edu>
590 2006-11-07 Fernando Perez <Fernando.Perez@colorado.edu>
579
591
580 * IPython/iplib.py (runsource): Prepend an 'if 1:' to the user
592 * IPython/iplib.py (runsource): Prepend an 'if 1:' to the user
581 input if it starts with whitespace. This allows you to paste
593 input if it starts with whitespace. This allows you to paste
582 indented input from any editor without manually having to type in
594 indented input from any editor without manually having to type in
583 the 'if 1:', which is convenient when working interactively.
595 the 'if 1:', which is convenient when working interactively.
584 Slightly modifed version of a patch by Bo Peng
596 Slightly modifed version of a patch by Bo Peng
585 <bpeng-AT-rice.edu>.
597 <bpeng-AT-rice.edu>.
586
598
587 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
599 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
588
600
589 * IPython/irunner.py (main): modified irunner so it automatically
601 * IPython/irunner.py (main): modified irunner so it automatically
590 recognizes the right runner to use based on the extension (.py for
602 recognizes the right runner to use based on the extension (.py for
591 python, .ipy for ipython and .sage for sage).
603 python, .ipy for ipython and .sage for sage).
592
604
593 * IPython/iplib.py (InteractiveShell.ipconfig): new builtin, also
605 * IPython/iplib.py (InteractiveShell.ipconfig): new builtin, also
594 visible in ipapi as ip.config(), to programatically control the
606 visible in ipapi as ip.config(), to programatically control the
595 internal rc object. There's an accompanying %config magic for
607 internal rc object. There's an accompanying %config magic for
596 interactive use, which has been enhanced to match the
608 interactive use, which has been enhanced to match the
597 funtionality in ipconfig.
609 funtionality in ipconfig.
598
610
599 * IPython/Magic.py (magic_system_verbose): Change %system_verbose
611 * IPython/Magic.py (magic_system_verbose): Change %system_verbose
600 so it's not just a toggle, it now takes an argument. Add support
612 so it's not just a toggle, it now takes an argument. Add support
601 for a customizable header when making system calls, as the new
613 for a customizable header when making system calls, as the new
602 system_header variable in the ipythonrc file.
614 system_header variable in the ipythonrc file.
603
615
604 2006-11-03 Walter Doerwald <walter@livinglogic.de>
616 2006-11-03 Walter Doerwald <walter@livinglogic.de>
605
617
606 * IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now
618 * IPython/Extensions/ipipe.py: xrepr(), xiter() and xattrs() are now
607 generic functions (using Philip J. Eby's simplegeneric package).
619 generic functions (using Philip J. Eby's simplegeneric package).
608 This makes it possible to customize the display of third-party classes
620 This makes it possible to customize the display of third-party classes
609 without having to monkeypatch them. xiter() no longer supports a mode
621 without having to monkeypatch them. xiter() no longer supports a mode
610 argument and the XMode class has been removed. The same functionality can
622 argument and the XMode class has been removed. The same functionality can
611 be implemented via IterAttributeDescriptor and IterMethodDescriptor.
623 be implemented via IterAttributeDescriptor and IterMethodDescriptor.
612 One consequence of the switch to generic functions is that xrepr() and
624 One consequence of the switch to generic functions is that xrepr() and
613 xattrs() implementation must define the default value for the mode
625 xattrs() implementation must define the default value for the mode
614 argument themselves and xattrs() implementations must return real
626 argument themselves and xattrs() implementations must return real
615 descriptors.
627 descriptors.
616
628
617 * IPython/external: This new subpackage will contain all third-party
629 * IPython/external: This new subpackage will contain all third-party
618 packages that are bundled with IPython. (The first one is simplegeneric).
630 packages that are bundled with IPython. (The first one is simplegeneric).
619
631
620 * IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent
632 * IPython/Extensions/ipipe.py (ifile/ils): Readd output of the parent
621 directory which as been dropped in r1703.
633 directory which as been dropped in r1703.
622
634
623 * IPython/Extensions/ipipe.py (iless): Fixed.
635 * IPython/Extensions/ipipe.py (iless): Fixed.
624
636
625 * IPython/Extensions/ibrowse: Fixed sorting under Python 2.3.
637 * IPython/Extensions/ibrowse: Fixed sorting under Python 2.3.
626
638
627 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
639 2006-11-03 Fernando Perez <Fernando.Perez@colorado.edu>
628
640
629 * IPython/iplib.py (InteractiveShell.var_expand): fix stack
641 * IPython/iplib.py (InteractiveShell.var_expand): fix stack
630 handling in variable expansion so that shells and magics recognize
642 handling in variable expansion so that shells and magics recognize
631 function local scopes correctly. Bug reported by Brian.
643 function local scopes correctly. Bug reported by Brian.
632
644
633 * scripts/ipython: remove the very first entry in sys.path which
645 * scripts/ipython: remove the very first entry in sys.path which
634 Python auto-inserts for scripts, so that sys.path under IPython is
646 Python auto-inserts for scripts, so that sys.path under IPython is
635 as similar as possible to that under plain Python.
647 as similar as possible to that under plain Python.
636
648
637 * IPython/completer.py (IPCompleter.file_matches): Fix
649 * IPython/completer.py (IPCompleter.file_matches): Fix
638 tab-completion so that quotes are not closed unless the completion
650 tab-completion so that quotes are not closed unless the completion
639 is unambiguous. After a request by Stefan. Minor cleanups in
651 is unambiguous. After a request by Stefan. Minor cleanups in
640 ipy_stock_completers.
652 ipy_stock_completers.
641
653
642 2006-11-02 Ville Vainio <vivainio@gmail.com>
654 2006-11-02 Ville Vainio <vivainio@gmail.com>
643
655
644 * ipy_stock_completers.py: Add %run and %cd completers.
656 * ipy_stock_completers.py: Add %run and %cd completers.
645
657
646 * completer.py: Try running custom completer for both
658 * completer.py: Try running custom completer for both
647 "foo" and "%foo" if the command is just "foo". Ignore case
659 "foo" and "%foo" if the command is just "foo". Ignore case
648 when filtering possible completions.
660 when filtering possible completions.
649
661
650 * UserConfig/ipy_user_conf.py: install stock completers as default
662 * UserConfig/ipy_user_conf.py: install stock completers as default
651
663
652 * iplib.py (history_saving_wrapper), debugger(), ipy_pydb.py:
664 * iplib.py (history_saving_wrapper), debugger(), ipy_pydb.py:
653 simplified readline history save / restore through a wrapper
665 simplified readline history save / restore through a wrapper
654 function
666 function
655
667
656
668
657 2006-10-31 Ville Vainio <vivainio@gmail.com>
669 2006-10-31 Ville Vainio <vivainio@gmail.com>
658
670
659 * strdispatch.py, completer.py, ipy_stock_completers.py:
671 * strdispatch.py, completer.py, ipy_stock_completers.py:
660 Allow str_key ("command") in completer hooks. Implement
672 Allow str_key ("command") in completer hooks. Implement
661 trivial completer for 'import' (stdlib modules only). Rename
673 trivial completer for 'import' (stdlib modules only). Rename
662 ipy_linux_package_managers.py to ipy_stock_completers.py.
674 ipy_linux_package_managers.py to ipy_stock_completers.py.
663 SVN completer.
675 SVN completer.
664
676
665 * Extensions/ledit.py: %magic line editor for easily and
677 * Extensions/ledit.py: %magic line editor for easily and
666 incrementally manipulating lists of strings. The magic command
678 incrementally manipulating lists of strings. The magic command
667 name is %led.
679 name is %led.
668
680
669 2006-10-30 Ville Vainio <vivainio@gmail.com>
681 2006-10-30 Ville Vainio <vivainio@gmail.com>
670
682
671 * Debugger.py, iplib.py (debugger()): Add last set of Rocky
683 * Debugger.py, iplib.py (debugger()): Add last set of Rocky
672 Bernsteins's patches for pydb integration.
684 Bernsteins's patches for pydb integration.
673 http://bashdb.sourceforge.net/pydb/
685 http://bashdb.sourceforge.net/pydb/
674
686
675 * strdispatch.py, iplib.py, completer.py, IPython/__init__.py,
687 * strdispatch.py, iplib.py, completer.py, IPython/__init__.py,
676 Extensions/ipy_linux_package_managers.py, hooks.py: Implement
688 Extensions/ipy_linux_package_managers.py, hooks.py: Implement
677 custom completer hook to allow the users to implement their own
689 custom completer hook to allow the users to implement their own
678 completers. See ipy_linux_package_managers.py for example. The
690 completers. See ipy_linux_package_managers.py for example. The
679 hook name is 'complete_command'.
691 hook name is 'complete_command'.
680
692
681 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
693 2006-10-28 Fernando Perez <Fernando.Perez@colorado.edu>
682
694
683 * IPython/UserConfig/ipythonrc-scipy: minor cleanups to remove old
695 * IPython/UserConfig/ipythonrc-scipy: minor cleanups to remove old
684 Numeric leftovers.
696 Numeric leftovers.
685
697
686 * ipython.el (py-execute-region): apply Stefan's patch to fix
698 * ipython.el (py-execute-region): apply Stefan's patch to fix
687 garbled results if the python shell hasn't been previously started.
699 garbled results if the python shell hasn't been previously started.
688
700
689 * IPython/genutils.py (arg_split): moved to genutils, since it's a
701 * IPython/genutils.py (arg_split): moved to genutils, since it's a
690 pretty generic function and useful for other things.
702 pretty generic function and useful for other things.
691
703
692 * IPython/OInspect.py (getsource): Add customizable source
704 * IPython/OInspect.py (getsource): Add customizable source
693 extractor. After a request/patch form W. Stein (SAGE).
705 extractor. After a request/patch form W. Stein (SAGE).
694
706
695 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
707 * IPython/irunner.py (InteractiveRunner.run_source): reset tty
696 window size to a more reasonable value from what pexpect does,
708 window size to a more reasonable value from what pexpect does,
697 since their choice causes wrapping bugs with long input lines.
709 since their choice causes wrapping bugs with long input lines.
698
710
699 2006-10-28 Ville Vainio <vivainio@gmail.com>
711 2006-10-28 Ville Vainio <vivainio@gmail.com>
700
712
701 * Magic.py (%run): Save and restore the readline history from
713 * Magic.py (%run): Save and restore the readline history from
702 file around %run commands to prevent side effects from
714 file around %run commands to prevent side effects from
703 %runned programs that might use readline (e.g. pydb).
715 %runned programs that might use readline (e.g. pydb).
704
716
705 * extensions/ipy_pydb.py: Adds %pydb magic when imported, for
717 * extensions/ipy_pydb.py: Adds %pydb magic when imported, for
706 invoking the pydb enhanced debugger.
718 invoking the pydb enhanced debugger.
707
719
708 2006-10-23 Walter Doerwald <walter@livinglogic.de>
720 2006-10-23 Walter Doerwald <walter@livinglogic.de>
709
721
710 * IPython/Extensions/ipipe.py (ifile): Remove all methods that
722 * IPython/Extensions/ipipe.py (ifile): Remove all methods that
711 call the base class method and propagate the return value to
723 call the base class method and propagate the return value to
712 ifile. This is now done by path itself.
724 ifile. This is now done by path itself.
713
725
714 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
726 2006-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
715
727
716 * IPython/ipapi.py (IPApi.__init__): Added new entry to public
728 * IPython/ipapi.py (IPApi.__init__): Added new entry to public
717 api: set_crash_handler(), to expose the ability to change the
729 api: set_crash_handler(), to expose the ability to change the
718 internal crash handler.
730 internal crash handler.
719
731
720 * IPython/CrashHandler.py (CrashHandler.__init__): abstract out
732 * IPython/CrashHandler.py (CrashHandler.__init__): abstract out
721 the various parameters of the crash handler so that apps using
733 the various parameters of the crash handler so that apps using
722 IPython as their engine can customize crash handling. Ipmlemented
734 IPython as their engine can customize crash handling. Ipmlemented
723 at the request of SAGE.
735 at the request of SAGE.
724
736
725 2006-10-14 Ville Vainio <vivainio@gmail.com>
737 2006-10-14 Ville Vainio <vivainio@gmail.com>
726
738
727 * Magic.py, ipython.el: applied first "safe" part of Rocky
739 * Magic.py, ipython.el: applied first "safe" part of Rocky
728 Bernstein's patch set for pydb integration.
740 Bernstein's patch set for pydb integration.
729
741
730 * Magic.py (%unalias, %alias): %store'd aliases can now be
742 * Magic.py (%unalias, %alias): %store'd aliases can now be
731 removed with '%unalias'. %alias w/o args now shows most
743 removed with '%unalias'. %alias w/o args now shows most
732 interesting (stored / manually defined) aliases last
744 interesting (stored / manually defined) aliases last
733 where they catch the eye w/o scrolling.
745 where they catch the eye w/o scrolling.
734
746
735 * Magic.py (%rehashx), ext_rehashdir.py: files with
747 * Magic.py (%rehashx), ext_rehashdir.py: files with
736 'py' extension are always considered executable, even
748 'py' extension are always considered executable, even
737 when not in PATHEXT environment variable.
749 when not in PATHEXT environment variable.
738
750
739 2006-10-12 Ville Vainio <vivainio@gmail.com>
751 2006-10-12 Ville Vainio <vivainio@gmail.com>
740
752
741 * jobctrl.py: Add new "jobctrl" extension for spawning background
753 * jobctrl.py: Add new "jobctrl" extension for spawning background
742 processes with "&find /". 'import jobctrl' to try it out. Requires
754 processes with "&find /". 'import jobctrl' to try it out. Requires
743 'subprocess' module, standard in python 2.4+.
755 'subprocess' module, standard in python 2.4+.
744
756
745 * iplib.py (expand_aliases, handle_alias): Aliases expand transitively,
757 * iplib.py (expand_aliases, handle_alias): Aliases expand transitively,
746 so if foo -> bar and bar -> baz, then foo -> baz.
758 so if foo -> bar and bar -> baz, then foo -> baz.
747
759
748 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
760 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu>
749
761
750 * IPython/Magic.py (Magic.parse_options): add a new posix option
762 * IPython/Magic.py (Magic.parse_options): add a new posix option
751 to allow parsing of input args in magics that doesn't strip quotes
763 to allow parsing of input args in magics that doesn't strip quotes
752 (if posix=False). This also closes %timeit bug reported by
764 (if posix=False). This also closes %timeit bug reported by
753 Stefan.
765 Stefan.
754
766
755 2006-10-03 Ville Vainio <vivainio@gmail.com>
767 2006-10-03 Ville Vainio <vivainio@gmail.com>
756
768
757 * iplib.py (raw_input, interact): Return ValueError catching for
769 * iplib.py (raw_input, interact): Return ValueError catching for
758 raw_input. Fixes infinite loop for sys.stdin.close() or
770 raw_input. Fixes infinite loop for sys.stdin.close() or
759 sys.stdout.close().
771 sys.stdout.close().
760
772
761 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
773 2006-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
762
774
763 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
775 * IPython/irunner.py (InteractiveRunner.run_source): small fixes
764 to help in handling doctests. irunner is now pretty useful for
776 to help in handling doctests. irunner is now pretty useful for
765 running standalone scripts and simulate a full interactive session
777 running standalone scripts and simulate a full interactive session
766 in a format that can be then pasted as a doctest.
778 in a format that can be then pasted as a doctest.
767
779
768 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
780 * IPython/iplib.py (InteractiveShell.__init__): Install exit/quit
769 on top of the default (useless) ones. This also fixes the nasty
781 on top of the default (useless) ones. This also fixes the nasty
770 way in which 2.5's Quitter() exits (reverted [1785]).
782 way in which 2.5's Quitter() exits (reverted [1785]).
771
783
772 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
784 * IPython/Debugger.py (Pdb.__init__): Fix ipdb to work with python
773 2.5.
785 2.5.
774
786
775 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
787 * IPython/ultraTB.py (TBTools.set_colors): Make sure that ipdb
776 color scheme is updated as well when color scheme is changed
788 color scheme is updated as well when color scheme is changed
777 interactively.
789 interactively.
778
790
779 2006-09-27 Ville Vainio <vivainio@gmail.com>
791 2006-09-27 Ville Vainio <vivainio@gmail.com>
780
792
781 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
793 * iplib.py (raw_input): python 2.5 closes stdin on quit -> avoid
782 infinite loop and just exit. It's a hack, but will do for a while.
794 infinite loop and just exit. It's a hack, but will do for a while.
783
795
784 2006-08-25 Walter Doerwald <walter@livinglogic.de>
796 2006-08-25 Walter Doerwald <walter@livinglogic.de>
785
797
786 * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to
798 * IPython/Extensions/ipipe.py (ils): Add arguments dirs and files to
787 the constructor, this makes it possible to get a list of only directories
799 the constructor, this makes it possible to get a list of only directories
788 or only files.
800 or only files.
789
801
790 2006-08-12 Ville Vainio <vivainio@gmail.com>
802 2006-08-12 Ville Vainio <vivainio@gmail.com>
791
803
792 * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,
804 * Fakemodule.py, OInspect.py: Reverted 2006-08-11 mods,
793 they broke unittest
805 they broke unittest
794
806
795 2006-08-11 Ville Vainio <vivainio@gmail.com>
807 2006-08-11 Ville Vainio <vivainio@gmail.com>
796
808
797 * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch
809 * Fakemodule.py, OInspect.py: remove 2006-08-09 monkepatch
798 by resolving issue properly, i.e. by inheriting FakeModule
810 by resolving issue properly, i.e. by inheriting FakeModule
799 from types.ModuleType. Pickling ipython interactive data
811 from types.ModuleType. Pickling ipython interactive data
800 should still work as usual (testing appreciated).
812 should still work as usual (testing appreciated).
801
813
802 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
814 2006-08-09 Fernando Perez <Fernando.Perez@colorado.edu>
803
815
804 * IPython/OInspect.py: monkeypatch inspect from the stdlib if
816 * IPython/OInspect.py: monkeypatch inspect from the stdlib if
805 running under python 2.3 with code from 2.4 to fix a bug with
817 running under python 2.3 with code from 2.4 to fix a bug with
806 help(). Reported by the Debian maintainers, Norbert Tretkowski
818 help(). Reported by the Debian maintainers, Norbert Tretkowski
807 <norbert-AT-tretkowski.de> and Alexandre Fayolle
819 <norbert-AT-tretkowski.de> and Alexandre Fayolle
808 <afayolle-AT-debian.org>.
820 <afayolle-AT-debian.org>.
809
821
810 2006-08-04 Walter Doerwald <walter@livinglogic.de>
822 2006-08-04 Walter Doerwald <walter@livinglogic.de>
811
823
812 * IPython/Extensions/ibrowse.py: Fixed the help message in the footer
824 * IPython/Extensions/ibrowse.py: Fixed the help message in the footer
813 (which was displaying "quit" twice).
825 (which was displaying "quit" twice).
814
826
815 2006-07-28 Walter Doerwald <walter@livinglogic.de>
827 2006-07-28 Walter Doerwald <walter@livinglogic.de>
816
828
817 * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using
829 * IPython/Extensions/ipipe.py: Fix isort.__iter__() (was still using
818 the mode argument).
830 the mode argument).
819
831
820 2006-07-27 Walter Doerwald <walter@livinglogic.de>
832 2006-07-27 Walter Doerwald <walter@livinglogic.de>
821
833
822 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
834 * IPython/Extensions/ipipe.py: Fix getglobals() if we're
823 not running under IPython.
835 not running under IPython.
824
836
825 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
837 * IPython/Extensions/ipipe.py: Rename XAttr to AttributeDetail
826 and make it iterable (iterating over the attribute itself). Add two new
838 and make it iterable (iterating over the attribute itself). Add two new
827 magic strings for __xattrs__(): If the string starts with "-", the attribute
839 magic strings for __xattrs__(): If the string starts with "-", the attribute
828 will not be displayed in ibrowse's detail view (but it can still be
840 will not be displayed in ibrowse's detail view (but it can still be
829 iterated over). This makes it possible to add attributes that are large
841 iterated over). This makes it possible to add attributes that are large
830 lists or generator methods to the detail view. Replace magic attribute names
842 lists or generator methods to the detail view. Replace magic attribute names
831 and _attrname() and _getattr() with "descriptors": For each type of magic
843 and _attrname() and _getattr() with "descriptors": For each type of magic
832 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
844 attribute name there's a subclass of Descriptor: None -> SelfDescriptor();
833 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
845 "foo" -> AttributeDescriptor("foo"); "foo()" -> MethodDescriptor("foo");
834 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
846 "-foo" -> IterAttributeDescriptor("foo"); "-foo()" -> IterMethodDescriptor("foo");
835 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
847 foo() -> FunctionDescriptor(foo). Magic strings returned from __xattrs__()
836 are still supported.
848 are still supported.
837
849
838 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
850 * IPython/Extensions/ibrowse.py: If fetching the next row from the input
839 fails in ibrowse.fetch(), the exception object is added as the last item
851 fails in ibrowse.fetch(), the exception object is added as the last item
840 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
852 and item fetching is canceled. This prevents ibrowse from aborting if e.g.
841 a generator throws an exception midway through execution.
853 a generator throws an exception midway through execution.
842
854
843 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
855 * IPython/Extensions/ipipe.py: Turn ifile's properties mimetype and
844 encoding into methods.
856 encoding into methods.
845
857
846 2006-07-26 Ville Vainio <vivainio@gmail.com>
858 2006-07-26 Ville Vainio <vivainio@gmail.com>
847
859
848 * iplib.py: history now stores multiline input as single
860 * iplib.py: history now stores multiline input as single
849 history entries. Patch by Jorgen Cederlof.
861 history entries. Patch by Jorgen Cederlof.
850
862
851 2006-07-18 Walter Doerwald <walter@livinglogic.de>
863 2006-07-18 Walter Doerwald <walter@livinglogic.de>
852
864
853 * IPython/Extensions/ibrowse.py: Make cursor visible over
865 * IPython/Extensions/ibrowse.py: Make cursor visible over
854 non existing attributes.
866 non existing attributes.
855
867
856 2006-07-14 Walter Doerwald <walter@livinglogic.de>
868 2006-07-14 Walter Doerwald <walter@livinglogic.de>
857
869
858 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
870 * IPython/Extensions/ipipe.py (ix): Use os.popen4() so that the
859 error output of the running command doesn't mess up the screen.
871 error output of the running command doesn't mess up the screen.
860
872
861 2006-07-13 Walter Doerwald <walter@livinglogic.de>
873 2006-07-13 Walter Doerwald <walter@livinglogic.de>
862
874
863 * IPython/Extensions/ipipe.py (isort): Make isort usable without
875 * IPython/Extensions/ipipe.py (isort): Make isort usable without
864 argument. This sorts the items themselves.
876 argument. This sorts the items themselves.
865
877
866 2006-07-12 Walter Doerwald <walter@livinglogic.de>
878 2006-07-12 Walter Doerwald <walter@livinglogic.de>
867
879
868 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
880 * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval):
869 Compile expression strings into code objects. This should speed
881 Compile expression strings into code objects. This should speed
870 up ifilter and friends somewhat.
882 up ifilter and friends somewhat.
871
883
872 2006-07-08 Ville Vainio <vivainio@gmail.com>
884 2006-07-08 Ville Vainio <vivainio@gmail.com>
873
885
874 * Magic.py: %cpaste now strips > from the beginning of lines
886 * Magic.py: %cpaste now strips > from the beginning of lines
875 to ease pasting quoted code from emails. Contributed by
887 to ease pasting quoted code from emails. Contributed by
876 Stefan van der Walt.
888 Stefan van der Walt.
877
889
878 2006-06-29 Ville Vainio <vivainio@gmail.com>
890 2006-06-29 Ville Vainio <vivainio@gmail.com>
879
891
880 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
892 * ipmaker.py, Shell.py: qt4agg matplotlib backend support for pylab
881 mode, patch contributed by Darren Dale. NEEDS TESTING!
893 mode, patch contributed by Darren Dale. NEEDS TESTING!
882
894
883 2006-06-28 Walter Doerwald <walter@livinglogic.de>
895 2006-06-28 Walter Doerwald <walter@livinglogic.de>
884
896
885 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
897 * IPython/Extensions/ibrowse.py: Give the ibrowse cursor row
886 a blue background. Fix fetching new display rows when the browser
898 a blue background. Fix fetching new display rows when the browser
887 scrolls more than a screenful (e.g. by using the goto command).
899 scrolls more than a screenful (e.g. by using the goto command).
888
900
889 2006-06-27 Ville Vainio <vivainio@gmail.com>
901 2006-06-27 Ville Vainio <vivainio@gmail.com>
890
902
891 * Magic.py (_inspect, _ofind) Apply David Huard's
903 * Magic.py (_inspect, _ofind) Apply David Huard's
892 patch for displaying the correct docstring for 'property'
904 patch for displaying the correct docstring for 'property'
893 attributes.
905 attributes.
894
906
895 2006-06-23 Walter Doerwald <walter@livinglogic.de>
907 2006-06-23 Walter Doerwald <walter@livinglogic.de>
896
908
897 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
909 * IPython/Extensions/ibrowse.py: Put the documentation of the keyboard
898 commands into the methods implementing them.
910 commands into the methods implementing them.
899
911
900 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
912 2006-06-22 Fernando Perez <Fernando.Perez@colorado.edu>
901
913
902 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
914 * ipython.el (ipython-indentation-hook): cleanup patch, submitted
903 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
915 by Kov Chai <tchaikov-AT-gmail.com>. He notes that the original
904 autoindent support was authored by Jin Liu.
916 autoindent support was authored by Jin Liu.
905
917
906 2006-06-22 Walter Doerwald <walter@livinglogic.de>
918 2006-06-22 Walter Doerwald <walter@livinglogic.de>
907
919
908 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
920 * IPython/Extensions/ibrowse.py: Replace the plain dictionaries used
909 for keymaps with a custom class that simplifies handling.
921 for keymaps with a custom class that simplifies handling.
910
922
911 2006-06-19 Walter Doerwald <walter@livinglogic.de>
923 2006-06-19 Walter Doerwald <walter@livinglogic.de>
912
924
913 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
925 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
914 resizing. This requires Python 2.5 to work.
926 resizing. This requires Python 2.5 to work.
915
927
916 2006-06-16 Walter Doerwald <walter@livinglogic.de>
928 2006-06-16 Walter Doerwald <walter@livinglogic.de>
917
929
918 * IPython/Extensions/ibrowse.py: Add two new commands to
930 * IPython/Extensions/ibrowse.py: Add two new commands to
919 ibrowse: "hideattr" (mapped to "h") hides the attribute under
931 ibrowse: "hideattr" (mapped to "h") hides the attribute under
920 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
932 the cursor. "unhiderattrs" (mapped to "H") reveals all hidden
921 attributes again. Remapped the help command to "?". Display
933 attributes again. Remapped the help command to "?". Display
922 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
934 keycodes in the range 0x01-0x1F as CTRL-xx. Add CTRL-a and CTRL-e
923 as keys for the "home" and "end" commands. Add three new commands
935 as keys for the "home" and "end" commands. Add three new commands
924 to the input mode for "find" and friends: "delend" (CTRL-K)
936 to the input mode for "find" and friends: "delend" (CTRL-K)
925 deletes to the end of line. "incsearchup" searches upwards in the
937 deletes to the end of line. "incsearchup" searches upwards in the
926 command history for an input that starts with the text before the cursor.
938 command history for an input that starts with the text before the cursor.
927 "incsearchdown" does the same downwards. Removed a bogus mapping of
939 "incsearchdown" does the same downwards. Removed a bogus mapping of
928 the x key to "delete".
940 the x key to "delete".
929
941
930 2006-06-15 Ville Vainio <vivainio@gmail.com>
942 2006-06-15 Ville Vainio <vivainio@gmail.com>
931
943
932 * iplib.py, hooks.py: Added new generate_prompt hook that can be
944 * iplib.py, hooks.py: Added new generate_prompt hook that can be
933 used to create prompts dynamically, instead of the "old" way of
945 used to create prompts dynamically, instead of the "old" way of
934 assigning "magic" strings to prompt_in1 and prompt_in2. The old
946 assigning "magic" strings to prompt_in1 and prompt_in2. The old
935 way still works (it's invoked by the default hook), of course.
947 way still works (it's invoked by the default hook), of course.
936
948
937 * Prompts.py: added generate_output_prompt hook for altering output
949 * Prompts.py: added generate_output_prompt hook for altering output
938 prompt
950 prompt
939
951
940 * Release.py: Changed version string to 0.7.3.svn.
952 * Release.py: Changed version string to 0.7.3.svn.
941
953
942 2006-06-15 Walter Doerwald <walter@livinglogic.de>
954 2006-06-15 Walter Doerwald <walter@livinglogic.de>
943
955
944 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
956 * IPython/Extensions/ibrowse.py: Change _BrowserLevel.moveto() so that
945 the call to fetch() always tries to fetch enough data for at least one
957 the call to fetch() always tries to fetch enough data for at least one
946 full screen. This makes it possible to simply call moveto(0,0,True) in
958 full screen. This makes it possible to simply call moveto(0,0,True) in
947 the constructor. Fix typos and removed the obsolete goto attribute.
959 the constructor. Fix typos and removed the obsolete goto attribute.
948
960
949 2006-06-12 Ville Vainio <vivainio@gmail.com>
961 2006-06-12 Ville Vainio <vivainio@gmail.com>
950
962
951 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
963 * ipy_profile_sh.py: applied Krisha Mohan Gundu's patch for
952 allowing $variable interpolation within multiline statements,
964 allowing $variable interpolation within multiline statements,
953 though so far only with "sh" profile for a testing period.
965 though so far only with "sh" profile for a testing period.
954 The patch also enables splitting long commands with \ but it
966 The patch also enables splitting long commands with \ but it
955 doesn't work properly yet.
967 doesn't work properly yet.
956
968
957 2006-06-12 Walter Doerwald <walter@livinglogic.de>
969 2006-06-12 Walter Doerwald <walter@livinglogic.de>
958
970
959 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
971 * IPython/Extensions/ibrowse.py (_dodisplay): Display the length of the
960 input history and the position of the cursor in the input history for
972 input history and the position of the cursor in the input history for
961 the find, findbackwards and goto command.
973 the find, findbackwards and goto command.
962
974
963 2006-06-10 Walter Doerwald <walter@livinglogic.de>
975 2006-06-10 Walter Doerwald <walter@livinglogic.de>
964
976
965 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
977 * IPython/Extensions/ibrowse.py: Add a class _CommandInput that
966 implements the basic functionality of browser commands that require
978 implements the basic functionality of browser commands that require
967 input. Reimplement the goto, find and findbackwards commands as
979 input. Reimplement the goto, find and findbackwards commands as
968 subclasses of _CommandInput. Add an input history and keymaps to those
980 subclasses of _CommandInput. Add an input history and keymaps to those
969 commands. Add "\r" as a keyboard shortcut for the enterdefault and
981 commands. Add "\r" as a keyboard shortcut for the enterdefault and
970 execute commands.
982 execute commands.
971
983
972 2006-06-07 Ville Vainio <vivainio@gmail.com>
984 2006-06-07 Ville Vainio <vivainio@gmail.com>
973
985
974 * iplib.py: ipython mybatch.ipy exits ipython immediately after
986 * iplib.py: ipython mybatch.ipy exits ipython immediately after
975 running the batch files instead of leaving the session open.
987 running the batch files instead of leaving the session open.
976
988
977 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
989 2006-06-07 Fernando Perez <Fernando.Perez@colorado.edu>
978
990
979 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
991 * IPython/iplib.py (InteractiveShell.__init__): update BSD fix, as
980 the original fix was incomplete. Patch submitted by W. Maier.
992 the original fix was incomplete. Patch submitted by W. Maier.
981
993
982 2006-06-07 Ville Vainio <vivainio@gmail.com>
994 2006-06-07 Ville Vainio <vivainio@gmail.com>
983
995
984 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
996 * iplib.py,Magic.py, ipmaker.py (magic_rehashx):
985 Confirmation prompts can be supressed by 'quiet' option.
997 Confirmation prompts can be supressed by 'quiet' option.
986 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
998 _ip.options.quiet = 1 means "assume yes for all yes/no queries".
987
999
988 2006-06-06 *** Released version 0.7.2
1000 2006-06-06 *** Released version 0.7.2
989
1001
990 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
1002 2006-06-06 Fernando Perez <Fernando.Perez@colorado.edu>
991
1003
992 * IPython/Release.py (version): Made 0.7.2 final for release.
1004 * IPython/Release.py (version): Made 0.7.2 final for release.
993 Repo tagged and release cut.
1005 Repo tagged and release cut.
994
1006
995 2006-06-05 Ville Vainio <vivainio@gmail.com>
1007 2006-06-05 Ville Vainio <vivainio@gmail.com>
996
1008
997 * Magic.py (magic_rehashx): Honor no_alias list earlier in
1009 * Magic.py (magic_rehashx): Honor no_alias list earlier in
998 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
1010 %rehashx, to avoid clobbering builtins in ipy_profile_sh.py
999
1011
1000 * upgrade_dir.py: try import 'path' module a bit harder
1012 * upgrade_dir.py: try import 'path' module a bit harder
1001 (for %upgrade)
1013 (for %upgrade)
1002
1014
1003 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
1015 2006-06-03 Fernando Perez <Fernando.Perez@colorado.edu>
1004
1016
1005 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
1017 * IPython/genutils.py (ask_yes_no): treat EOF as a default answer
1006 instead of looping 20 times.
1018 instead of looping 20 times.
1007
1019
1008 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
1020 * IPython/ipmaker.py (make_IPython): honor -ipythondir flag
1009 correctly at initialization time. Bug reported by Krishna Mohan
1021 correctly at initialization time. Bug reported by Krishna Mohan
1010 Gundu <gkmohan-AT-gmail.com> on the user list.
1022 Gundu <gkmohan-AT-gmail.com> on the user list.
1011
1023
1012 * IPython/Release.py (version): Mark 0.7.2 version to start
1024 * IPython/Release.py (version): Mark 0.7.2 version to start
1013 testing for release on 06/06.
1025 testing for release on 06/06.
1014
1026
1015 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
1027 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu>
1016
1028
1017 * scripts/irunner: thin script interface so users don't have to
1029 * scripts/irunner: thin script interface so users don't have to
1018 find the module and call it as an executable, since modules rarely
1030 find the module and call it as an executable, since modules rarely
1019 live in people's PATH.
1031 live in people's PATH.
1020
1032
1021 * IPython/irunner.py (InteractiveRunner.__init__): added
1033 * IPython/irunner.py (InteractiveRunner.__init__): added
1022 delaybeforesend attribute to control delays with newer versions of
1034 delaybeforesend attribute to control delays with newer versions of
1023 pexpect. Thanks to detailed help from pexpect's author, Noah
1035 pexpect. Thanks to detailed help from pexpect's author, Noah
1024 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
1036 Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner
1025 correctly (it works in NoColor mode).
1037 correctly (it works in NoColor mode).
1026
1038
1027 * IPython/iplib.py (handle_normal): fix nasty crash reported on
1039 * IPython/iplib.py (handle_normal): fix nasty crash reported on
1028 SAGE list, from improper log() calls.
1040 SAGE list, from improper log() calls.
1029
1041
1030 2006-05-31 Ville Vainio <vivainio@gmail.com>
1042 2006-05-31 Ville Vainio <vivainio@gmail.com>
1031
1043
1032 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
1044 * upgrade_dir.py, Magic.py (magic_upgrade): call upgrade_dir
1033 with args in parens to work correctly with dirs that have spaces.
1045 with args in parens to work correctly with dirs that have spaces.
1034
1046
1035 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
1047 2006-05-30 Fernando Perez <Fernando.Perez@colorado.edu>
1036
1048
1037 * IPython/Logger.py (Logger.logstart): add option to log raw input
1049 * IPython/Logger.py (Logger.logstart): add option to log raw input
1038 instead of the processed one. A -r flag was added to the
1050 instead of the processed one. A -r flag was added to the
1039 %logstart magic used for controlling logging.
1051 %logstart magic used for controlling logging.
1040
1052
1041 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
1053 2006-05-29 Fernando Perez <Fernando.Perez@colorado.edu>
1042
1054
1043 * IPython/iplib.py (InteractiveShell.__init__): add check for the
1055 * IPython/iplib.py (InteractiveShell.__init__): add check for the
1044 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
1056 *BSDs to omit --color from all 'ls' aliases, since *BSD ls doesn't
1045 recognize the option. After a bug report by Will Maier. This
1057 recognize the option. After a bug report by Will Maier. This
1046 closes #64 (will do it after confirmation from W. Maier).
1058 closes #64 (will do it after confirmation from W. Maier).
1047
1059
1048 * IPython/irunner.py: New module to run scripts as if manually
1060 * IPython/irunner.py: New module to run scripts as if manually
1049 typed into an interactive environment, based on pexpect. After a
1061 typed into an interactive environment, based on pexpect. After a
1050 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
1062 submission by Ken Schutte <kschutte-AT-csail.mit.edu> on the
1051 ipython-user list. Simple unittests in the tests/ directory.
1063 ipython-user list. Simple unittests in the tests/ directory.
1052
1064
1053 * tools/release: add Will Maier, OpenBSD port maintainer, to
1065 * tools/release: add Will Maier, OpenBSD port maintainer, to
1054 recepients list. We are now officially part of the OpenBSD ports:
1066 recepients list. We are now officially part of the OpenBSD ports:
1055 http://www.openbsd.org/ports.html ! Many thanks to Will for the
1067 http://www.openbsd.org/ports.html ! Many thanks to Will for the
1056 work.
1068 work.
1057
1069
1058 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
1070 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
1059
1071
1060 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
1072 * IPython/ipmaker.py (make_IPython): modify sys.argv fix (below)
1061 so that it doesn't break tkinter apps.
1073 so that it doesn't break tkinter apps.
1062
1074
1063 * IPython/iplib.py (_prefilter): fix bug where aliases would
1075 * IPython/iplib.py (_prefilter): fix bug where aliases would
1064 shadow variables when autocall was fully off. Reported by SAGE
1076 shadow variables when autocall was fully off. Reported by SAGE
1065 author William Stein.
1077 author William Stein.
1066
1078
1067 * IPython/OInspect.py (Inspector.__init__): add a flag to control
1079 * IPython/OInspect.py (Inspector.__init__): add a flag to control
1068 at what detail level strings are computed when foo? is requested.
1080 at what detail level strings are computed when foo? is requested.
1069 This allows users to ask for example that the string form of an
1081 This allows users to ask for example that the string form of an
1070 object is only computed when foo?? is called, or even never, by
1082 object is only computed when foo?? is called, or even never, by
1071 setting the object_info_string_level >= 2 in the configuration
1083 setting the object_info_string_level >= 2 in the configuration
1072 file. This new option has been added and documented. After a
1084 file. This new option has been added and documented. After a
1073 request by SAGE to be able to control the printing of very large
1085 request by SAGE to be able to control the printing of very large
1074 objects more easily.
1086 objects more easily.
1075
1087
1076 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
1088 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
1077
1089
1078 * IPython/ipmaker.py (make_IPython): remove the ipython call path
1090 * IPython/ipmaker.py (make_IPython): remove the ipython call path
1079 from sys.argv, to be 100% consistent with how Python itself works
1091 from sys.argv, to be 100% consistent with how Python itself works
1080 (as seen for example with python -i file.py). After a bug report
1092 (as seen for example with python -i file.py). After a bug report
1081 by Jeffrey Collins.
1093 by Jeffrey Collins.
1082
1094
1083 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
1095 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix
1084 nasty bug which was preventing custom namespaces with -pylab,
1096 nasty bug which was preventing custom namespaces with -pylab,
1085 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
1097 reported by M. Foord. Minor cleanup, remove old matplotlib.matlab
1086 compatibility (long gone from mpl).
1098 compatibility (long gone from mpl).
1087
1099
1088 * IPython/ipapi.py (make_session): name change: create->make. We
1100 * IPython/ipapi.py (make_session): name change: create->make. We
1089 use make in other places (ipmaker,...), it's shorter and easier to
1101 use make in other places (ipmaker,...), it's shorter and easier to
1090 type and say, etc. I'm trying to clean things before 0.7.2 so
1102 type and say, etc. I'm trying to clean things before 0.7.2 so
1091 that I can keep things stable wrt to ipapi in the chainsaw branch.
1103 that I can keep things stable wrt to ipapi in the chainsaw branch.
1092
1104
1093 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
1105 * ipython.el: fix the py-pdbtrack-input-prompt variable so that
1094 python-mode recognizes our debugger mode. Add support for
1106 python-mode recognizes our debugger mode. Add support for
1095 autoindent inside (X)emacs. After a patch sent in by Jin Liu
1107 autoindent inside (X)emacs. After a patch sent in by Jin Liu
1096 <m.liu.jin-AT-gmail.com> originally written by
1108 <m.liu.jin-AT-gmail.com> originally written by
1097 doxgen-AT-newsmth.net (with minor modifications for xemacs
1109 doxgen-AT-newsmth.net (with minor modifications for xemacs
1098 compatibility)
1110 compatibility)
1099
1111
1100 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
1112 * IPython/Debugger.py (Pdb.format_stack_entry): fix formatting of
1101 tracebacks when walking the stack so that the stack tracking system
1113 tracebacks when walking the stack so that the stack tracking system
1102 in emacs' python-mode can identify the frames correctly.
1114 in emacs' python-mode can identify the frames correctly.
1103
1115
1104 * IPython/ipmaker.py (make_IPython): make the internal (and
1116 * IPython/ipmaker.py (make_IPython): make the internal (and
1105 default config) autoedit_syntax value false by default. Too many
1117 default config) autoedit_syntax value false by default. Too many
1106 users have complained to me (both on and off-list) about problems
1118 users have complained to me (both on and off-list) about problems
1107 with this option being on by default, so I'm making it default to
1119 with this option being on by default, so I'm making it default to
1108 off. It can still be enabled by anyone via the usual mechanisms.
1120 off. It can still be enabled by anyone via the usual mechanisms.
1109
1121
1110 * IPython/completer.py (Completer.attr_matches): add support for
1122 * IPython/completer.py (Completer.attr_matches): add support for
1111 PyCrust-style _getAttributeNames magic method. Patch contributed
1123 PyCrust-style _getAttributeNames magic method. Patch contributed
1112 by <mscott-AT-goldenspud.com>. Closes #50.
1124 by <mscott-AT-goldenspud.com>. Closes #50.
1113
1125
1114 * IPython/iplib.py (InteractiveShell.__init__): remove the
1126 * IPython/iplib.py (InteractiveShell.__init__): remove the
1115 deletion of exit/quit from __builtin__, which can break
1127 deletion of exit/quit from __builtin__, which can break
1116 third-party tools like the Zope debugging console. The
1128 third-party tools like the Zope debugging console. The
1117 %exit/%quit magics remain. In general, it's probably a good idea
1129 %exit/%quit magics remain. In general, it's probably a good idea
1118 not to delete anything from __builtin__, since we never know what
1130 not to delete anything from __builtin__, since we never know what
1119 that will break. In any case, python now (for 2.5) will support
1131 that will break. In any case, python now (for 2.5) will support
1120 'real' exit/quit, so this issue is moot. Closes #55.
1132 'real' exit/quit, so this issue is moot. Closes #55.
1121
1133
1122 * IPython/genutils.py (with_obj): rename the 'with' function to
1134 * IPython/genutils.py (with_obj): rename the 'with' function to
1123 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
1135 'withobj' to avoid incompatibilities with Python 2.5, where 'with'
1124 becomes a language keyword. Closes #53.
1136 becomes a language keyword. Closes #53.
1125
1137
1126 * IPython/FakeModule.py (FakeModule.__init__): add a proper
1138 * IPython/FakeModule.py (FakeModule.__init__): add a proper
1127 __file__ attribute to this so it fools more things into thinking
1139 __file__ attribute to this so it fools more things into thinking
1128 it is a real module. Closes #59.
1140 it is a real module. Closes #59.
1129
1141
1130 * IPython/Magic.py (magic_edit): add -n option to open the editor
1142 * IPython/Magic.py (magic_edit): add -n option to open the editor
1131 at a specific line number. After a patch by Stefan van der Walt.
1143 at a specific line number. After a patch by Stefan van der Walt.
1132
1144
1133 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
1145 2006-05-23 Fernando Perez <Fernando.Perez@colorado.edu>
1134
1146
1135 * IPython/iplib.py (edit_syntax_error): fix crash when for some
1147 * IPython/iplib.py (edit_syntax_error): fix crash when for some
1136 reason the file could not be opened. After automatic crash
1148 reason the file could not be opened. After automatic crash
1137 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
1149 reports sent by James Graham <jgraham-AT-ast.cam.ac.uk> and
1138 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
1150 Charles Dolan <charlespatrickdolan-AT-yahoo.com>.
1139 (_should_recompile): Don't fire editor if using %bg, since there
1151 (_should_recompile): Don't fire editor if using %bg, since there
1140 is no file in the first place. From the same report as above.
1152 is no file in the first place. From the same report as above.
1141 (raw_input): protect against faulty third-party prefilters. After
1153 (raw_input): protect against faulty third-party prefilters. After
1142 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
1154 an automatic crash report sent by Dirk Laurie <dirk-AT-sun.ac.za>
1143 while running under SAGE.
1155 while running under SAGE.
1144
1156
1145 2006-05-23 Ville Vainio <vivainio@gmail.com>
1157 2006-05-23 Ville Vainio <vivainio@gmail.com>
1146
1158
1147 * ipapi.py: Stripped down ip.to_user_ns() to work only as
1159 * ipapi.py: Stripped down ip.to_user_ns() to work only as
1148 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
1160 ip.to_user_ns("x1 y1"), which exposes vars x1 and y1. ipapi.get()
1149 now returns None (again), unless dummy is specifically allowed by
1161 now returns None (again), unless dummy is specifically allowed by
1150 ipapi.get(allow_dummy=True).
1162 ipapi.get(allow_dummy=True).
1151
1163
1152 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
1164 2006-05-18 Fernando Perez <Fernando.Perez@colorado.edu>
1153
1165
1154 * IPython: remove all 2.2-compatibility objects and hacks from
1166 * IPython: remove all 2.2-compatibility objects and hacks from
1155 everywhere, since we only support 2.3 at this point. Docs
1167 everywhere, since we only support 2.3 at this point. Docs
1156 updated.
1168 updated.
1157
1169
1158 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
1170 * IPython/ipapi.py (IPApi.__init__): Cleanup of all getters.
1159 Anything requiring extra validation can be turned into a Python
1171 Anything requiring extra validation can be turned into a Python
1160 property in the future. I used a property for the db one b/c
1172 property in the future. I used a property for the db one b/c
1161 there was a nasty circularity problem with the initialization
1173 there was a nasty circularity problem with the initialization
1162 order, which right now I don't have time to clean up.
1174 order, which right now I don't have time to clean up.
1163
1175
1164 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
1176 * IPython/Shell.py (MTInteractiveShell.runcode): Fix, I think,
1165 another locking bug reported by Jorgen. I'm not 100% sure though,
1177 another locking bug reported by Jorgen. I'm not 100% sure though,
1166 so more testing is needed...
1178 so more testing is needed...
1167
1179
1168 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
1180 2006-05-17 Fernando Perez <Fernando.Perez@colorado.edu>
1169
1181
1170 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
1182 * IPython/ipapi.py (IPApi.to_user_ns): New function to inject
1171 local variables from any routine in user code (typically executed
1183 local variables from any routine in user code (typically executed
1172 with %run) directly into the interactive namespace. Very useful
1184 with %run) directly into the interactive namespace. Very useful
1173 when doing complex debugging.
1185 when doing complex debugging.
1174 (IPythonNotRunning): Changed the default None object to a dummy
1186 (IPythonNotRunning): Changed the default None object to a dummy
1175 whose attributes can be queried as well as called without
1187 whose attributes can be queried as well as called without
1176 exploding, to ease writing code which works transparently both in
1188 exploding, to ease writing code which works transparently both in
1177 and out of ipython and uses some of this API.
1189 and out of ipython and uses some of this API.
1178
1190
1179 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
1191 2006-05-16 Fernando Perez <Fernando.Perez@colorado.edu>
1180
1192
1181 * IPython/hooks.py (result_display): Fix the fact that our display
1193 * IPython/hooks.py (result_display): Fix the fact that our display
1182 hook was using str() instead of repr(), as the default python
1194 hook was using str() instead of repr(), as the default python
1183 console does. This had gone unnoticed b/c it only happened if
1195 console does. This had gone unnoticed b/c it only happened if
1184 %Pprint was off, but the inconsistency was there.
1196 %Pprint was off, but the inconsistency was there.
1185
1197
1186 2006-05-15 Ville Vainio <vivainio@gmail.com>
1198 2006-05-15 Ville Vainio <vivainio@gmail.com>
1187
1199
1188 * Oinspect.py: Only show docstring for nonexisting/binary files
1200 * Oinspect.py: Only show docstring for nonexisting/binary files
1189 when doing object??, closing ticket #62
1201 when doing object??, closing ticket #62
1190
1202
1191 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
1203 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu>
1192
1204
1193 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
1205 * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading
1194 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
1206 bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock
1195 was being released in a routine which hadn't checked if it had
1207 was being released in a routine which hadn't checked if it had
1196 been the one to acquire it.
1208 been the one to acquire it.
1197
1209
1198 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
1210 2006-05-07 Fernando Perez <Fernando.Perez@colorado.edu>
1199
1211
1200 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
1212 * IPython/Release.py (version): put out 0.7.2.rc1 for testing.
1201
1213
1202 2006-04-11 Ville Vainio <vivainio@gmail.com>
1214 2006-04-11 Ville Vainio <vivainio@gmail.com>
1203
1215
1204 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
1216 * iplib.py, ipmaker.py: .ipy extension now means "ipython batch file"
1205 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
1217 in command line. E.g. "ipython test.ipy" runs test.ipy with ipython
1206 prefilters, allowing stuff like magics and aliases in the file.
1218 prefilters, allowing stuff like magics and aliases in the file.
1207
1219
1208 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
1220 * Prompts.py, Extensions/clearcmd.py, ipy_system_conf.py: %clear magic
1209 added. Supported now are "%clear in" and "%clear out" (clear input and
1221 added. Supported now are "%clear in" and "%clear out" (clear input and
1210 output history, respectively). Also fixed CachedOutput.flush to
1222 output history, respectively). Also fixed CachedOutput.flush to
1211 properly flush the output cache.
1223 properly flush the output cache.
1212
1224
1213 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
1225 * Extensions/pspersistence.py: Fix %store to avoid "%store obj.attr"
1214 half-success (and fail explicitly).
1226 half-success (and fail explicitly).
1215
1227
1216 2006-03-28 Ville Vainio <vivainio@gmail.com>
1228 2006-03-28 Ville Vainio <vivainio@gmail.com>
1217
1229
1218 * iplib.py: Fix quoting of aliases so that only argless ones
1230 * iplib.py: Fix quoting of aliases so that only argless ones
1219 are quoted
1231 are quoted
1220
1232
1221 2006-03-28 Ville Vainio <vivainio@gmail.com>
1233 2006-03-28 Ville Vainio <vivainio@gmail.com>
1222
1234
1223 * iplib.py: Quote aliases with spaces in the name.
1235 * iplib.py: Quote aliases with spaces in the name.
1224 "c:\program files\blah\bin" is now legal alias target.
1236 "c:\program files\blah\bin" is now legal alias target.
1225
1237
1226 * ext_rehashdir.py: Space no longer allowed as arg
1238 * ext_rehashdir.py: Space no longer allowed as arg
1227 separator, since space is legal in path names.
1239 separator, since space is legal in path names.
1228
1240
1229 2006-03-16 Ville Vainio <vivainio@gmail.com>
1241 2006-03-16 Ville Vainio <vivainio@gmail.com>
1230
1242
1231 * upgrade_dir.py: Take path.py from Extensions, correcting
1243 * upgrade_dir.py: Take path.py from Extensions, correcting
1232 %upgrade magic
1244 %upgrade magic
1233
1245
1234 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
1246 * ipmaker.py: Suggest using %upgrade if ipy_user_conf.py isn't found.
1235
1247
1236 * hooks.py: Only enclose editor binary in quotes if legal and
1248 * hooks.py: Only enclose editor binary in quotes if legal and
1237 necessary (space in the name, and is an existing file). Fixes a bug
1249 necessary (space in the name, and is an existing file). Fixes a bug
1238 reported by Zachary Pincus.
1250 reported by Zachary Pincus.
1239
1251
1240 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
1252 2006-03-13 Fernando Perez <Fernando.Perez@colorado.edu>
1241
1253
1242 * Manual: thanks to a tip on proper color handling for Emacs, by
1254 * Manual: thanks to a tip on proper color handling for Emacs, by
1243 Eric J Haywiser <ejh1-AT-MIT.EDU>.
1255 Eric J Haywiser <ejh1-AT-MIT.EDU>.
1244
1256
1245 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
1257 * ipython.el: close http://www.scipy.net/roundup/ipython/issue57
1246 by applying the provided patch. Thanks to Liu Jin
1258 by applying the provided patch. Thanks to Liu Jin
1247 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
1259 <m.liu.jin-AT-gmail.com> for the contribution. No problems under
1248 XEmacs/Linux, I'm trusting the submitter that it actually helps
1260 XEmacs/Linux, I'm trusting the submitter that it actually helps
1249 under win32/GNU Emacs. Will revisit if any problems are reported.
1261 under win32/GNU Emacs. Will revisit if any problems are reported.
1250
1262
1251 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1263 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1252
1264
1253 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
1265 * IPython/Gnuplot2.py (_FileClass): update for current Gnuplot.py
1254 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
1266 from SVN, thanks to a patch by Ryan Woodard <rywo@bas.ac.uk>.
1255
1267
1256 2006-03-12 Ville Vainio <vivainio@gmail.com>
1268 2006-03-12 Ville Vainio <vivainio@gmail.com>
1257
1269
1258 * Magic.py (magic_timeit): Added %timeit magic, contributed by
1270 * Magic.py (magic_timeit): Added %timeit magic, contributed by
1259 Torsten Marek.
1271 Torsten Marek.
1260
1272
1261 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1273 2006-03-12 Fernando Perez <Fernando.Perez@colorado.edu>
1262
1274
1263 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
1275 * IPython/Magic.py (magic_macro): fix so that the n1-n2 syntax for
1264 line ranges works again.
1276 line ranges works again.
1265
1277
1266 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
1278 2006-03-11 Fernando Perez <Fernando.Perez@colorado.edu>
1267
1279
1268 * IPython/iplib.py (showtraceback): add back sys.last_traceback
1280 * IPython/iplib.py (showtraceback): add back sys.last_traceback
1269 and friends, after a discussion with Zach Pincus on ipython-user.
1281 and friends, after a discussion with Zach Pincus on ipython-user.
1270 I'm not 100% sure, but after thinking about it quite a bit, it may
1282 I'm not 100% sure, but after thinking about it quite a bit, it may
1271 be OK. Testing with the multithreaded shells didn't reveal any
1283 be OK. Testing with the multithreaded shells didn't reveal any
1272 problems, but let's keep an eye out.
1284 problems, but let's keep an eye out.
1273
1285
1274 In the process, I fixed a few things which were calling
1286 In the process, I fixed a few things which were calling
1275 self.InteractiveTB() directly (like safe_execfile), which is a
1287 self.InteractiveTB() directly (like safe_execfile), which is a
1276 mistake: ALL exception reporting should be done by calling
1288 mistake: ALL exception reporting should be done by calling
1277 self.showtraceback(), which handles state and tab-completion and
1289 self.showtraceback(), which handles state and tab-completion and
1278 more.
1290 more.
1279
1291
1280 2006-03-01 Ville Vainio <vivainio@gmail.com>
1292 2006-03-01 Ville Vainio <vivainio@gmail.com>
1281
1293
1282 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
1294 * Extensions/ipipe.py: Added Walter Doerwald's "ipipe" module.
1283 To use, do "from ipipe import *".
1295 To use, do "from ipipe import *".
1284
1296
1285 2006-02-24 Ville Vainio <vivainio@gmail.com>
1297 2006-02-24 Ville Vainio <vivainio@gmail.com>
1286
1298
1287 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
1299 * Magic.py, upgrade_dir.py: %upgrade magic added. Does things more
1288 "cleanly" and safely than the older upgrade mechanism.
1300 "cleanly" and safely than the older upgrade mechanism.
1289
1301
1290 2006-02-21 Ville Vainio <vivainio@gmail.com>
1302 2006-02-21 Ville Vainio <vivainio@gmail.com>
1291
1303
1292 * Magic.py: %save works again.
1304 * Magic.py: %save works again.
1293
1305
1294 2006-02-15 Ville Vainio <vivainio@gmail.com>
1306 2006-02-15 Ville Vainio <vivainio@gmail.com>
1295
1307
1296 * Magic.py: %Pprint works again
1308 * Magic.py: %Pprint works again
1297
1309
1298 * Extensions/ipy_sane_defaults.py: Provide everything provided
1310 * Extensions/ipy_sane_defaults.py: Provide everything provided
1299 in default ipythonrc, to make it possible to have a completely empty
1311 in default ipythonrc, to make it possible to have a completely empty
1300 ipythonrc (and thus completely rc-file free configuration)
1312 ipythonrc (and thus completely rc-file free configuration)
1301
1313
1302 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
1314 2006-02-11 Fernando Perez <Fernando.Perez@colorado.edu>
1303
1315
1304 * IPython/hooks.py (editor): quote the call to the editor command,
1316 * IPython/hooks.py (editor): quote the call to the editor command,
1305 to allow commands with spaces in them. Problem noted by watching
1317 to allow commands with spaces in them. Problem noted by watching
1306 Ian Oswald's video about textpad under win32 at
1318 Ian Oswald's video about textpad under win32 at
1307 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
1319 http://showmedo.com/videoListPage?listKey=PythonIPythonSeries
1308
1320
1309 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
1321 * IPython/UserConfig/ipythonrc: Replace @ signs with % when
1310 describing magics (we haven't used @ for a loong time).
1322 describing magics (we haven't used @ for a loong time).
1311
1323
1312 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
1324 * IPython/ultraTB.py (VerboseTB.text.text_repr): Added patch
1313 contributed by marienz to close
1325 contributed by marienz to close
1314 http://www.scipy.net/roundup/ipython/issue53.
1326 http://www.scipy.net/roundup/ipython/issue53.
1315
1327
1316 2006-02-10 Ville Vainio <vivainio@gmail.com>
1328 2006-02-10 Ville Vainio <vivainio@gmail.com>
1317
1329
1318 * genutils.py: getoutput now works in win32 too
1330 * genutils.py: getoutput now works in win32 too
1319
1331
1320 * completer.py: alias and magic completion only invoked
1332 * completer.py: alias and magic completion only invoked
1321 at the first "item" in the line, to avoid "cd %store"
1333 at the first "item" in the line, to avoid "cd %store"
1322 nonsense.
1334 nonsense.
1323
1335
1324 2006-02-09 Ville Vainio <vivainio@gmail.com>
1336 2006-02-09 Ville Vainio <vivainio@gmail.com>
1325
1337
1326 * test/*: Added a unit testing framework (finally).
1338 * test/*: Added a unit testing framework (finally).
1327 '%run runtests.py' to run test_*.
1339 '%run runtests.py' to run test_*.
1328
1340
1329 * ipapi.py: Exposed runlines and set_custom_exc
1341 * ipapi.py: Exposed runlines and set_custom_exc
1330
1342
1331 2006-02-07 Ville Vainio <vivainio@gmail.com>
1343 2006-02-07 Ville Vainio <vivainio@gmail.com>
1332
1344
1333 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
1345 * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall,
1334 instead use "f(1 2)" as before.
1346 instead use "f(1 2)" as before.
1335
1347
1336 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
1348 2006-02-05 Fernando Perez <Fernando.Perez@colorado.edu>
1337
1349
1338 * IPython/demo.py (IPythonDemo): Add new classes to the demo
1350 * IPython/demo.py (IPythonDemo): Add new classes to the demo
1339 facilities, for demos processed by the IPython input filter
1351 facilities, for demos processed by the IPython input filter
1340 (IPythonDemo), and for running a script one-line-at-a-time as a
1352 (IPythonDemo), and for running a script one-line-at-a-time as a
1341 demo, both for pure Python (LineDemo) and for IPython-processed
1353 demo, both for pure Python (LineDemo) and for IPython-processed
1342 input (IPythonLineDemo). After a request by Dave Kohel, from the
1354 input (IPythonLineDemo). After a request by Dave Kohel, from the
1343 SAGE team.
1355 SAGE team.
1344 (Demo.edit): added an edit() method to the demo objects, to edit
1356 (Demo.edit): added an edit() method to the demo objects, to edit
1345 the in-memory copy of the last executed block.
1357 the in-memory copy of the last executed block.
1346
1358
1347 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
1359 * IPython/Magic.py (magic_edit): add '-r' option for 'raw'
1348 processing to %edit, %macro and %save. These commands can now be
1360 processing to %edit, %macro and %save. These commands can now be
1349 invoked on the unprocessed input as it was typed by the user
1361 invoked on the unprocessed input as it was typed by the user
1350 (without any prefilters applied). After requests by the SAGE team
1362 (without any prefilters applied). After requests by the SAGE team
1351 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
1363 at SAGE days 2006: http://modular.ucsd.edu/sage/days1/schedule.html.
1352
1364
1353 2006-02-01 Ville Vainio <vivainio@gmail.com>
1365 2006-02-01 Ville Vainio <vivainio@gmail.com>
1354
1366
1355 * setup.py, eggsetup.py: easy_install ipython==dev works
1367 * setup.py, eggsetup.py: easy_install ipython==dev works
1356 correctly now (on Linux)
1368 correctly now (on Linux)
1357
1369
1358 * ipy_user_conf,ipmaker: user config changes, removed spurious
1370 * ipy_user_conf,ipmaker: user config changes, removed spurious
1359 warnings
1371 warnings
1360
1372
1361 * iplib: if rc.banner is string, use it as is.
1373 * iplib: if rc.banner is string, use it as is.
1362
1374
1363 * Magic: %pycat accepts a string argument and pages it's contents.
1375 * Magic: %pycat accepts a string argument and pages it's contents.
1364
1376
1365
1377
1366 2006-01-30 Ville Vainio <vivainio@gmail.com>
1378 2006-01-30 Ville Vainio <vivainio@gmail.com>
1367
1379
1368 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
1380 * pickleshare,pspersistence,ipapi,Magic: persistence overhaul.
1369 Now %store and bookmarks work through PickleShare, meaning that
1381 Now %store and bookmarks work through PickleShare, meaning that
1370 concurrent access is possible and all ipython sessions see the
1382 concurrent access is possible and all ipython sessions see the
1371 same database situation all the time, instead of snapshot of
1383 same database situation all the time, instead of snapshot of
1372 the situation when the session was started. Hence, %bookmark
1384 the situation when the session was started. Hence, %bookmark
1373 results are immediately accessible from othes sessions. The database
1385 results are immediately accessible from othes sessions. The database
1374 is also available for use by user extensions. See:
1386 is also available for use by user extensions. See:
1375 http://www.python.org/pypi/pickleshare
1387 http://www.python.org/pypi/pickleshare
1376
1388
1377 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
1389 * hooks.py: Two new hooks, 'shutdown_hook' and 'late_startup_hook'.
1378
1390
1379 * aliases can now be %store'd
1391 * aliases can now be %store'd
1380
1392
1381 * path.py moved to Extensions so that pickleshare does not need
1393 * path.py moved to Extensions so that pickleshare does not need
1382 IPython-specific import. Extensions added to pythonpath right
1394 IPython-specific import. Extensions added to pythonpath right
1383 at __init__.
1395 at __init__.
1384
1396
1385 * iplib.py: ipalias deprecated/redundant; aliases are converted and
1397 * iplib.py: ipalias deprecated/redundant; aliases are converted and
1386 called with _ip.system and the pre-transformed command string.
1398 called with _ip.system and the pre-transformed command string.
1387
1399
1388 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
1400 2006-01-29 Fernando Perez <Fernando.Perez@colorado.edu>
1389
1401
1390 * IPython/iplib.py (interact): Fix that we were not catching
1402 * IPython/iplib.py (interact): Fix that we were not catching
1391 KeyboardInterrupt exceptions properly. I'm not quite sure why the
1403 KeyboardInterrupt exceptions properly. I'm not quite sure why the
1392 logic here had to change, but it's fixed now.
1404 logic here had to change, but it's fixed now.
1393
1405
1394 2006-01-29 Ville Vainio <vivainio@gmail.com>
1406 2006-01-29 Ville Vainio <vivainio@gmail.com>
1395
1407
1396 * iplib.py: Try to import pyreadline on Windows.
1408 * iplib.py: Try to import pyreadline on Windows.
1397
1409
1398 2006-01-27 Ville Vainio <vivainio@gmail.com>
1410 2006-01-27 Ville Vainio <vivainio@gmail.com>
1399
1411
1400 * iplib.py: Expose ipapi as _ip in builtin namespace.
1412 * iplib.py: Expose ipapi as _ip in builtin namespace.
1401 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
1413 Makes ipmagic (-> _ip.magic), ipsystem (-> _ip.system)
1402 and ip_set_hook (-> _ip.set_hook) redundant. % and !
1414 and ip_set_hook (-> _ip.set_hook) redundant. % and !
1403 syntax now produce _ip.* variant of the commands.
1415 syntax now produce _ip.* variant of the commands.
1404
1416
1405 * "_ip.options().autoedit_syntax = 2" automatically throws
1417 * "_ip.options().autoedit_syntax = 2" automatically throws
1406 user to editor for syntax error correction without prompting.
1418 user to editor for syntax error correction without prompting.
1407
1419
1408 2006-01-27 Ville Vainio <vivainio@gmail.com>
1420 2006-01-27 Ville Vainio <vivainio@gmail.com>
1409
1421
1410 * ipmaker.py: Give "realistic" sys.argv for scripts (without
1422 * ipmaker.py: Give "realistic" sys.argv for scripts (without
1411 'ipython' at argv[0]) executed through command line.
1423 'ipython' at argv[0]) executed through command line.
1412 NOTE: this DEPRECATES calling ipython with multiple scripts
1424 NOTE: this DEPRECATES calling ipython with multiple scripts
1413 ("ipython a.py b.py c.py")
1425 ("ipython a.py b.py c.py")
1414
1426
1415 * iplib.py, hooks.py: Added configurable input prefilter,
1427 * iplib.py, hooks.py: Added configurable input prefilter,
1416 named 'input_prefilter'. See ext_rescapture.py for example
1428 named 'input_prefilter'. See ext_rescapture.py for example
1417 usage.
1429 usage.
1418
1430
1419 * ext_rescapture.py, Magic.py: Better system command output capture
1431 * ext_rescapture.py, Magic.py: Better system command output capture
1420 through 'var = !ls' (deprecates user-visible %sc). Same notation
1432 through 'var = !ls' (deprecates user-visible %sc). Same notation
1421 applies for magics, 'var = %alias' assigns alias list to var.
1433 applies for magics, 'var = %alias' assigns alias list to var.
1422
1434
1423 * ipapi.py: added meta() for accessing extension-usable data store.
1435 * ipapi.py: added meta() for accessing extension-usable data store.
1424
1436
1425 * iplib.py: added InteractiveShell.getapi(). New magics should be
1437 * iplib.py: added InteractiveShell.getapi(). New magics should be
1426 written doing self.getapi() instead of using the shell directly.
1438 written doing self.getapi() instead of using the shell directly.
1427
1439
1428 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
1440 * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and
1429 %store foo >> ~/myfoo.txt to store variables to files (in clean
1441 %store foo >> ~/myfoo.txt to store variables to files (in clean
1430 textual form, not a restorable pickle).
1442 textual form, not a restorable pickle).
1431
1443
1432 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
1444 * ipmaker.py: now import ipy_profile_PROFILENAME automatically
1433
1445
1434 * usage.py, Magic.py: added %quickref
1446 * usage.py, Magic.py: added %quickref
1435
1447
1436 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
1448 * iplib.py: ESC_PAREN fixes: /f 1 2 -> f(1,2), not f(1 2).
1437
1449
1438 * GetoptErrors when invoking magics etc. with wrong args
1450 * GetoptErrors when invoking magics etc. with wrong args
1439 are now more helpful:
1451 are now more helpful:
1440 GetoptError: option -l not recognized (allowed: "qb" )
1452 GetoptError: option -l not recognized (allowed: "qb" )
1441
1453
1442 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
1454 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
1443
1455
1444 * IPython/demo.py (Demo.show): Flush stdout after each block, so
1456 * IPython/demo.py (Demo.show): Flush stdout after each block, so
1445 computationally intensive blocks don't appear to stall the demo.
1457 computationally intensive blocks don't appear to stall the demo.
1446
1458
1447 2006-01-24 Ville Vainio <vivainio@gmail.com>
1459 2006-01-24 Ville Vainio <vivainio@gmail.com>
1448
1460
1449 * iplib.py, hooks.py: 'result_display' hook can return a non-None
1461 * iplib.py, hooks.py: 'result_display' hook can return a non-None
1450 value to manipulate resulting history entry.
1462 value to manipulate resulting history entry.
1451
1463
1452 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
1464 * ipapi.py: Moved TryNext here from hooks.py. Moved functions
1453 to instance methods of IPApi class, to make extending an embedded
1465 to instance methods of IPApi class, to make extending an embedded
1454 IPython feasible. See ext_rehashdir.py for example usage.
1466 IPython feasible. See ext_rehashdir.py for example usage.
1455
1467
1456 * Merged 1071-1076 from branches/0.7.1
1468 * Merged 1071-1076 from branches/0.7.1
1457
1469
1458
1470
1459 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
1471 2006-01-23 Fernando Perez <Fernando.Perez@colorado.edu>
1460
1472
1461 * tools/release (daystamp): Fix build tools to use the new
1473 * tools/release (daystamp): Fix build tools to use the new
1462 eggsetup.py script to build lightweight eggs.
1474 eggsetup.py script to build lightweight eggs.
1463
1475
1464 * Applied changesets 1062 and 1064 before 0.7.1 release.
1476 * Applied changesets 1062 and 1064 before 0.7.1 release.
1465
1477
1466 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
1478 * IPython/Magic.py (magic_history): Add '-r' option to %hist, to
1467 see the raw input history (without conversions like %ls ->
1479 see the raw input history (without conversions like %ls ->
1468 ipmagic("ls")). After a request from W. Stein, SAGE
1480 ipmagic("ls")). After a request from W. Stein, SAGE
1469 (http://modular.ucsd.edu/sage) developer. This information is
1481 (http://modular.ucsd.edu/sage) developer. This information is
1470 stored in the input_hist_raw attribute of the IPython instance, so
1482 stored in the input_hist_raw attribute of the IPython instance, so
1471 developers can access it if needed (it's an InputList instance).
1483 developers can access it if needed (it's an InputList instance).
1472
1484
1473 * Versionstring = 0.7.2.svn
1485 * Versionstring = 0.7.2.svn
1474
1486
1475 * eggsetup.py: A separate script for constructing eggs, creates
1487 * eggsetup.py: A separate script for constructing eggs, creates
1476 proper launch scripts even on Windows (an .exe file in
1488 proper launch scripts even on Windows (an .exe file in
1477 \python24\scripts).
1489 \python24\scripts).
1478
1490
1479 * ipapi.py: launch_new_instance, launch entry point needed for the
1491 * ipapi.py: launch_new_instance, launch entry point needed for the
1480 egg.
1492 egg.
1481
1493
1482 2006-01-23 Ville Vainio <vivainio@gmail.com>
1494 2006-01-23 Ville Vainio <vivainio@gmail.com>
1483
1495
1484 * Added %cpaste magic for pasting python code
1496 * Added %cpaste magic for pasting python code
1485
1497
1486 2006-01-22 Ville Vainio <vivainio@gmail.com>
1498 2006-01-22 Ville Vainio <vivainio@gmail.com>
1487
1499
1488 * Merge from branches/0.7.1 into trunk, revs 1052-1057
1500 * Merge from branches/0.7.1 into trunk, revs 1052-1057
1489
1501
1490 * Versionstring = 0.7.2.svn
1502 * Versionstring = 0.7.2.svn
1491
1503
1492 * eggsetup.py: A separate script for constructing eggs, creates
1504 * eggsetup.py: A separate script for constructing eggs, creates
1493 proper launch scripts even on Windows (an .exe file in
1505 proper launch scripts even on Windows (an .exe file in
1494 \python24\scripts).
1506 \python24\scripts).
1495
1507
1496 * ipapi.py: launch_new_instance, launch entry point needed for the
1508 * ipapi.py: launch_new_instance, launch entry point needed for the
1497 egg.
1509 egg.
1498
1510
1499 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
1511 2006-01-22 Fernando Perez <Fernando.Perez@colorado.edu>
1500
1512
1501 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
1513 * IPython/OInspect.py (Inspector.pinfo): fix bug where foo?? or
1502 %pfile foo would print the file for foo even if it was a binary.
1514 %pfile foo would print the file for foo even if it was a binary.
1503 Now, extensions '.so' and '.dll' are skipped.
1515 Now, extensions '.so' and '.dll' are skipped.
1504
1516
1505 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
1517 * IPython/Shell.py (MTInteractiveShell.__init__): Fix threading
1506 bug, where macros would fail in all threaded modes. I'm not 100%
1518 bug, where macros would fail in all threaded modes. I'm not 100%
1507 sure, so I'm going to put out an rc instead of making a release
1519 sure, so I'm going to put out an rc instead of making a release
1508 today, and wait for feedback for at least a few days.
1520 today, and wait for feedback for at least a few days.
1509
1521
1510 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
1522 * IPython/iplib.py (handle_normal): fix (finally? somehow I doubt
1511 it...) the handling of pasting external code with autoindent on.
1523 it...) the handling of pasting external code with autoindent on.
1512 To get out of a multiline input, the rule will appear for most
1524 To get out of a multiline input, the rule will appear for most
1513 users unchanged: two blank lines or change the indent level
1525 users unchanged: two blank lines or change the indent level
1514 proposed by IPython. But there is a twist now: you can
1526 proposed by IPython. But there is a twist now: you can
1515 add/subtract only *one or two spaces*. If you add/subtract three
1527 add/subtract only *one or two spaces*. If you add/subtract three
1516 or more (unless you completely delete the line), IPython will
1528 or more (unless you completely delete the line), IPython will
1517 accept that line, and you'll need to enter a second one of pure
1529 accept that line, and you'll need to enter a second one of pure
1518 whitespace. I know it sounds complicated, but I can't find a
1530 whitespace. I know it sounds complicated, but I can't find a
1519 different solution that covers all the cases, with the right
1531 different solution that covers all the cases, with the right
1520 heuristics. Hopefully in actual use, nobody will really notice
1532 heuristics. Hopefully in actual use, nobody will really notice
1521 all these strange rules and things will 'just work'.
1533 all these strange rules and things will 'just work'.
1522
1534
1523 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
1535 2006-01-21 Fernando Perez <Fernando.Perez@colorado.edu>
1524
1536
1525 * IPython/iplib.py (interact): catch exceptions which can be
1537 * IPython/iplib.py (interact): catch exceptions which can be
1526 triggered asynchronously by signal handlers. Thanks to an
1538 triggered asynchronously by signal handlers. Thanks to an
1527 automatic crash report, submitted by Colin Kingsley
1539 automatic crash report, submitted by Colin Kingsley
1528 <tercel-AT-gentoo.org>.
1540 <tercel-AT-gentoo.org>.
1529
1541
1530 2006-01-20 Ville Vainio <vivainio@gmail.com>
1542 2006-01-20 Ville Vainio <vivainio@gmail.com>
1531
1543
1532 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
1544 * Ipython/Extensions/ext_rehashdir.py: Created a usable example
1533 (%rehashdir, very useful, try it out) of how to extend ipython
1545 (%rehashdir, very useful, try it out) of how to extend ipython
1534 with new magics. Also added Extensions dir to pythonpath to make
1546 with new magics. Also added Extensions dir to pythonpath to make
1535 importing extensions easy.
1547 importing extensions easy.
1536
1548
1537 * %store now complains when trying to store interactively declared
1549 * %store now complains when trying to store interactively declared
1538 classes / instances of those classes.
1550 classes / instances of those classes.
1539
1551
1540 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
1552 * Extensions/ipy_system_conf.py, UserConfig/ipy_user_conf.py,
1541 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
1553 ipmaker.py: Config rehaul. Now ipy_..._conf.py are always imported
1542 if they exist, and ipy_user_conf.py with some defaults is created for
1554 if they exist, and ipy_user_conf.py with some defaults is created for
1543 the user.
1555 the user.
1544
1556
1545 * Startup rehashing done by the config file, not InterpreterExec.
1557 * Startup rehashing done by the config file, not InterpreterExec.
1546 This means system commands are available even without selecting the
1558 This means system commands are available even without selecting the
1547 pysh profile. It's the sensible default after all.
1559 pysh profile. It's the sensible default after all.
1548
1560
1549 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
1561 2006-01-20 Fernando Perez <Fernando.Perez@colorado.edu>
1550
1562
1551 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
1563 * IPython/iplib.py (raw_input): I _think_ I got the pasting of
1552 multiline code with autoindent on working. But I am really not
1564 multiline code with autoindent on working. But I am really not
1553 sure, so this needs more testing. Will commit a debug-enabled
1565 sure, so this needs more testing. Will commit a debug-enabled
1554 version for now, while I test it some more, so that Ville and
1566 version for now, while I test it some more, so that Ville and
1555 others may also catch any problems. Also made
1567 others may also catch any problems. Also made
1556 self.indent_current_str() a method, to ensure that there's no
1568 self.indent_current_str() a method, to ensure that there's no
1557 chance of the indent space count and the corresponding string
1569 chance of the indent space count and the corresponding string
1558 falling out of sync. All code needing the string should just call
1570 falling out of sync. All code needing the string should just call
1559 the method.
1571 the method.
1560
1572
1561 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
1573 2006-01-18 Fernando Perez <Fernando.Perez@colorado.edu>
1562
1574
1563 * IPython/Magic.py (magic_edit): fix check for when users don't
1575 * IPython/Magic.py (magic_edit): fix check for when users don't
1564 save their output files, the try/except was in the wrong section.
1576 save their output files, the try/except was in the wrong section.
1565
1577
1566 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
1578 2006-01-17 Fernando Perez <Fernando.Perez@colorado.edu>
1567
1579
1568 * IPython/Magic.py (magic_run): fix __file__ global missing from
1580 * IPython/Magic.py (magic_run): fix __file__ global missing from
1569 script's namespace when executed via %run. After a report by
1581 script's namespace when executed via %run. After a report by
1570 Vivian.
1582 Vivian.
1571
1583
1572 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
1584 * IPython/Debugger.py (Pdb.__init__): Fix breakage with '%run -d'
1573 when using python 2.4. The parent constructor changed in 2.4, and
1585 when using python 2.4. The parent constructor changed in 2.4, and
1574 we need to track it directly (we can't call it, as it messes up
1586 we need to track it directly (we can't call it, as it messes up
1575 readline and tab-completion inside our pdb would stop working).
1587 readline and tab-completion inside our pdb would stop working).
1576 After a bug report by R. Bernstein <rocky-AT-panix.com>.
1588 After a bug report by R. Bernstein <rocky-AT-panix.com>.
1577
1589
1578 2006-01-16 Ville Vainio <vivainio@gmail.com>
1590 2006-01-16 Ville Vainio <vivainio@gmail.com>
1579
1591
1580 * Ipython/magic.py: Reverted back to old %edit functionality
1592 * Ipython/magic.py: Reverted back to old %edit functionality
1581 that returns file contents on exit.
1593 that returns file contents on exit.
1582
1594
1583 * IPython/path.py: Added Jason Orendorff's "path" module to
1595 * IPython/path.py: Added Jason Orendorff's "path" module to
1584 IPython tree, http://www.jorendorff.com/articles/python/path/.
1596 IPython tree, http://www.jorendorff.com/articles/python/path/.
1585 You can get path objects conveniently through %sc, and !!, e.g.:
1597 You can get path objects conveniently through %sc, and !!, e.g.:
1586 sc files=ls
1598 sc files=ls
1587 for p in files.paths: # or files.p
1599 for p in files.paths: # or files.p
1588 print p,p.mtime
1600 print p,p.mtime
1589
1601
1590 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
1602 * Ipython/iplib.py:"," and ";" autoquoting-upon-autocall
1591 now work again without considering the exclusion regexp -
1603 now work again without considering the exclusion regexp -
1592 hence, things like ',foo my/path' turn to 'foo("my/path")'
1604 hence, things like ',foo my/path' turn to 'foo("my/path")'
1593 instead of syntax error.
1605 instead of syntax error.
1594
1606
1595
1607
1596 2006-01-14 Ville Vainio <vivainio@gmail.com>
1608 2006-01-14 Ville Vainio <vivainio@gmail.com>
1597
1609
1598 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
1610 * IPython/ipapi.py (ashook, asmagic, options): Added convenience
1599 ipapi decorators for python 2.4 users, options() provides access to rc
1611 ipapi decorators for python 2.4 users, options() provides access to rc
1600 data.
1612 data.
1601
1613
1602 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
1614 * IPython/Magic.py (magic_cd): %cd now accepts backslashes
1603 as path separators (even on Linux ;-). Space character after
1615 as path separators (even on Linux ;-). Space character after
1604 backslash (as yielded by tab completer) is still space;
1616 backslash (as yielded by tab completer) is still space;
1605 "%cd long\ name" works as expected.
1617 "%cd long\ name" works as expected.
1606
1618
1607 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
1619 * IPython/ipapi.py,hooks.py,iplib.py: Hooks now implemented
1608 as "chain of command", with priority. API stays the same,
1620 as "chain of command", with priority. API stays the same,
1609 TryNext exception raised by a hook function signals that
1621 TryNext exception raised by a hook function signals that
1610 current hook failed and next hook should try handling it, as
1622 current hook failed and next hook should try handling it, as
1611 suggested by Walter Dörwald <walter@livinglogic.de>. Walter also
1623 suggested by Walter Dörwald <walter@livinglogic.de>. Walter also
1612 requested configurable display hook, which is now implemented.
1624 requested configurable display hook, which is now implemented.
1613
1625
1614 2006-01-13 Ville Vainio <vivainio@gmail.com>
1626 2006-01-13 Ville Vainio <vivainio@gmail.com>
1615
1627
1616 * IPython/platutils*.py: platform specific utility functions,
1628 * IPython/platutils*.py: platform specific utility functions,
1617 so far only set_term_title is implemented (change terminal
1629 so far only set_term_title is implemented (change terminal
1618 label in windowing systems). %cd now changes the title to
1630 label in windowing systems). %cd now changes the title to
1619 current dir.
1631 current dir.
1620
1632
1621 * IPython/Release.py: Added myself to "authors" list,
1633 * IPython/Release.py: Added myself to "authors" list,
1622 had to create new files.
1634 had to create new files.
1623
1635
1624 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
1636 * IPython/iplib.py (handle_shell_escape): fixed logical flaw in
1625 shell escape; not a known bug but had potential to be one in the
1637 shell escape; not a known bug but had potential to be one in the
1626 future.
1638 future.
1627
1639
1628 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
1640 * IPython/ipapi.py (added),OInspect.py,iplib.py: "Public"
1629 extension API for IPython! See the module for usage example. Fix
1641 extension API for IPython! See the module for usage example. Fix
1630 OInspect for docstring-less magic functions.
1642 OInspect for docstring-less magic functions.
1631
1643
1632
1644
1633 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
1645 2006-01-13 Fernando Perez <Fernando.Perez@colorado.edu>
1634
1646
1635 * IPython/iplib.py (raw_input): temporarily deactivate all
1647 * IPython/iplib.py (raw_input): temporarily deactivate all
1636 attempts at allowing pasting of code with autoindent on. It
1648 attempts at allowing pasting of code with autoindent on. It
1637 introduced bugs (reported by Prabhu) and I can't seem to find a
1649 introduced bugs (reported by Prabhu) and I can't seem to find a
1638 robust combination which works in all cases. Will have to revisit
1650 robust combination which works in all cases. Will have to revisit
1639 later.
1651 later.
1640
1652
1641 * IPython/genutils.py: remove isspace() function. We've dropped
1653 * IPython/genutils.py: remove isspace() function. We've dropped
1642 2.2 compatibility, so it's OK to use the string method.
1654 2.2 compatibility, so it's OK to use the string method.
1643
1655
1644 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1656 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1645
1657
1646 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
1658 * IPython/iplib.py (InteractiveShell.__init__): fix regexp
1647 matching what NOT to autocall on, to include all python binary
1659 matching what NOT to autocall on, to include all python binary
1648 operators (including things like 'and', 'or', 'is' and 'in').
1660 operators (including things like 'and', 'or', 'is' and 'in').
1649 Prompted by a bug report on 'foo & bar', but I realized we had
1661 Prompted by a bug report on 'foo & bar', but I realized we had
1650 many more potential bug cases with other operators. The regexp is
1662 many more potential bug cases with other operators. The regexp is
1651 self.re_exclude_auto, it's fairly commented.
1663 self.re_exclude_auto, it's fairly commented.
1652
1664
1653 2006-01-12 Ville Vainio <vivainio@gmail.com>
1665 2006-01-12 Ville Vainio <vivainio@gmail.com>
1654
1666
1655 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
1667 * IPython/iplib.py (make_quoted_expr,handle_shell_escape):
1656 Prettified and hardened string/backslash quoting with ipsystem(),
1668 Prettified and hardened string/backslash quoting with ipsystem(),
1657 ipalias() and ipmagic(). Now even \ characters are passed to
1669 ipalias() and ipmagic(). Now even \ characters are passed to
1658 %magics, !shell escapes and aliases exactly as they are in the
1670 %magics, !shell escapes and aliases exactly as they are in the
1659 ipython command line. Should improve backslash experience,
1671 ipython command line. Should improve backslash experience,
1660 particularly in Windows (path delimiter for some commands that
1672 particularly in Windows (path delimiter for some commands that
1661 won't understand '/'), but Unix benefits as well (regexps). %cd
1673 won't understand '/'), but Unix benefits as well (regexps). %cd
1662 magic still doesn't support backslash path delimiters, though. Also
1674 magic still doesn't support backslash path delimiters, though. Also
1663 deleted all pretense of supporting multiline command strings in
1675 deleted all pretense of supporting multiline command strings in
1664 !system or %magic commands. Thanks to Jerry McRae for suggestions.
1676 !system or %magic commands. Thanks to Jerry McRae for suggestions.
1665
1677
1666 * doc/build_doc_instructions.txt added. Documentation on how to
1678 * doc/build_doc_instructions.txt added. Documentation on how to
1667 use doc/update_manual.py, added yesterday. Both files contributed
1679 use doc/update_manual.py, added yesterday. Both files contributed
1668 by Jörgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
1680 by Jörgen Stenarson <jorgen.stenarson-AT-bostream.nu>. This slates
1669 doc/*.sh for deprecation at a later date.
1681 doc/*.sh for deprecation at a later date.
1670
1682
1671 * /ipython.py Added ipython.py to root directory for
1683 * /ipython.py Added ipython.py to root directory for
1672 zero-installation (tar xzvf ipython.tgz; cd ipython; python
1684 zero-installation (tar xzvf ipython.tgz; cd ipython; python
1673 ipython.py) and development convenience (no need to keep doing
1685 ipython.py) and development convenience (no need to keep doing
1674 "setup.py install" between changes).
1686 "setup.py install" between changes).
1675
1687
1676 * Made ! and !! shell escapes work (again) in multiline expressions:
1688 * Made ! and !! shell escapes work (again) in multiline expressions:
1677 if 1:
1689 if 1:
1678 !ls
1690 !ls
1679 !!ls
1691 !!ls
1680
1692
1681 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1693 2006-01-12 Fernando Perez <Fernando.Perez@colorado.edu>
1682
1694
1683 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
1695 * IPython/ipstruct.py (Struct): Rename IPython.Struct to
1684 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
1696 IPython.ipstruct, to avoid local shadowing of the stdlib 'struct'
1685 module in case-insensitive installation. Was causing crashes
1697 module in case-insensitive installation. Was causing crashes
1686 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
1698 under win32. Closes http://www.scipy.net/roundup/ipython/issue49.
1687
1699
1688 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
1700 * IPython/Magic.py (magic_pycat): Fix pycat, patch by Marien Zwart
1689 <marienz-AT-gentoo.org>, closes
1701 <marienz-AT-gentoo.org>, closes
1690 http://www.scipy.net/roundup/ipython/issue51.
1702 http://www.scipy.net/roundup/ipython/issue51.
1691
1703
1692 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
1704 2006-01-11 Fernando Perez <Fernando.Perez@colorado.edu>
1693
1705
1694 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
1706 * IPython/Shell.py (IPShellGTK.on_timer): Finally fix the
1695 problem of excessive CPU usage under *nix and keyboard lag under
1707 problem of excessive CPU usage under *nix and keyboard lag under
1696 win32.
1708 win32.
1697
1709
1698 2006-01-10 *** Released version 0.7.0
1710 2006-01-10 *** Released version 0.7.0
1699
1711
1700 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
1712 2006-01-10 Fernando Perez <Fernando.Perez@colorado.edu>
1701
1713
1702 * IPython/Release.py (revision): tag version number to 0.7.0,
1714 * IPython/Release.py (revision): tag version number to 0.7.0,
1703 ready for release.
1715 ready for release.
1704
1716
1705 * IPython/Magic.py (magic_edit): Add print statement to %edit so
1717 * IPython/Magic.py (magic_edit): Add print statement to %edit so
1706 it informs the user of the name of the temp. file used. This can
1718 it informs the user of the name of the temp. file used. This can
1707 help if you decide later to reuse that same file, so you know
1719 help if you decide later to reuse that same file, so you know
1708 where to copy the info from.
1720 where to copy the info from.
1709
1721
1710 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
1722 2006-01-09 Fernando Perez <Fernando.Perez@colorado.edu>
1711
1723
1712 * setup_bdist_egg.py: little script to build an egg. Added
1724 * setup_bdist_egg.py: little script to build an egg. Added
1713 support in the release tools as well.
1725 support in the release tools as well.
1714
1726
1715 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
1727 2006-01-08 Fernando Perez <Fernando.Perez@colorado.edu>
1716
1728
1717 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
1729 * IPython/Shell.py (IPShellWX.__init__): add support for WXPython
1718 version selection (new -wxversion command line and ipythonrc
1730 version selection (new -wxversion command line and ipythonrc
1719 parameter). Patch contributed by Arnd Baecker
1731 parameter). Patch contributed by Arnd Baecker
1720 <arnd.baecker-AT-web.de>.
1732 <arnd.baecker-AT-web.de>.
1721
1733
1722 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1734 * IPython/iplib.py (embed_mainloop): fix tab-completion in
1723 embedded instances, for variables defined at the interactive
1735 embedded instances, for variables defined at the interactive
1724 prompt of the embedded ipython. Reported by Arnd.
1736 prompt of the embedded ipython. Reported by Arnd.
1725
1737
1726 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
1738 * IPython/Magic.py (magic_autocall): Fix %autocall magic. Now
1727 it can be used as a (stateful) toggle, or with a direct parameter.
1739 it can be used as a (stateful) toggle, or with a direct parameter.
1728
1740
1729 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
1741 * IPython/ultraTB.py (_fixed_getinnerframes): remove debug assert which
1730 could be triggered in certain cases and cause the traceback
1742 could be triggered in certain cases and cause the traceback
1731 printer not to work.
1743 printer not to work.
1732
1744
1733 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
1745 2006-01-07 Fernando Perez <Fernando.Perez@colorado.edu>
1734
1746
1735 * IPython/iplib.py (_should_recompile): Small fix, closes
1747 * IPython/iplib.py (_should_recompile): Small fix, closes
1736 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
1748 http://www.scipy.net/roundup/ipython/issue48. Patch by Scott.
1737
1749
1738 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
1750 2006-01-04 Fernando Perez <Fernando.Perez@colorado.edu>
1739
1751
1740 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
1752 * IPython/Shell.py (IPShellGTK.mainloop): fix bug in the GTK
1741 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
1753 backend for matplotlib (100% cpu utiliziation). Thanks to Charlie
1742 Moad for help with tracking it down.
1754 Moad for help with tracking it down.
1743
1755
1744 * IPython/iplib.py (handle_auto): fix autocall handling for
1756 * IPython/iplib.py (handle_auto): fix autocall handling for
1745 objects which support BOTH __getitem__ and __call__ (so that f [x]
1757 objects which support BOTH __getitem__ and __call__ (so that f [x]
1746 is left alone, instead of becoming f([x]) automatically).
1758 is left alone, instead of becoming f([x]) automatically).
1747
1759
1748 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
1760 * IPython/Magic.py (magic_cd): fix crash when cd -b was used.
1749 Ville's patch.
1761 Ville's patch.
1750
1762
1751 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
1763 2006-01-03 Fernando Perez <Fernando.Perez@colorado.edu>
1752
1764
1753 * IPython/iplib.py (handle_auto): changed autocall semantics to
1765 * IPython/iplib.py (handle_auto): changed autocall semantics to
1754 include 'smart' mode, where the autocall transformation is NOT
1766 include 'smart' mode, where the autocall transformation is NOT
1755 applied if there are no arguments on the line. This allows you to
1767 applied if there are no arguments on the line. This allows you to
1756 just type 'foo' if foo is a callable to see its internal form,
1768 just type 'foo' if foo is a callable to see its internal form,
1757 instead of having it called with no arguments (typically a
1769 instead of having it called with no arguments (typically a
1758 mistake). The old 'full' autocall still exists: for that, you
1770 mistake). The old 'full' autocall still exists: for that, you
1759 need to set the 'autocall' parameter to 2 in your ipythonrc file.
1771 need to set the 'autocall' parameter to 2 in your ipythonrc file.
1760
1772
1761 * IPython/completer.py (Completer.attr_matches): add
1773 * IPython/completer.py (Completer.attr_matches): add
1762 tab-completion support for Enthoughts' traits. After a report by
1774 tab-completion support for Enthoughts' traits. After a report by
1763 Arnd and a patch by Prabhu.
1775 Arnd and a patch by Prabhu.
1764
1776
1765 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
1777 2006-01-02 Fernando Perez <Fernando.Perez@colorado.edu>
1766
1778
1767 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
1779 * IPython/ultraTB.py (_fixed_getinnerframes): added Alex
1768 Schmolck's patch to fix inspect.getinnerframes().
1780 Schmolck's patch to fix inspect.getinnerframes().
1769
1781
1770 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
1782 * IPython/iplib.py (InteractiveShell.__init__): significant fixes
1771 for embedded instances, regarding handling of namespaces and items
1783 for embedded instances, regarding handling of namespaces and items
1772 added to the __builtin__ one. Multiple embedded instances and
1784 added to the __builtin__ one. Multiple embedded instances and
1773 recursive embeddings should work better now (though I'm not sure
1785 recursive embeddings should work better now (though I'm not sure
1774 I've got all the corner cases fixed, that code is a bit of a brain
1786 I've got all the corner cases fixed, that code is a bit of a brain
1775 twister).
1787 twister).
1776
1788
1777 * IPython/Magic.py (magic_edit): added support to edit in-memory
1789 * IPython/Magic.py (magic_edit): added support to edit in-memory
1778 macros (automatically creates the necessary temp files). %edit
1790 macros (automatically creates the necessary temp files). %edit
1779 also doesn't return the file contents anymore, it's just noise.
1791 also doesn't return the file contents anymore, it's just noise.
1780
1792
1781 * IPython/completer.py (Completer.attr_matches): revert change to
1793 * IPython/completer.py (Completer.attr_matches): revert change to
1782 complete only on attributes listed in __all__. I realized it
1794 complete only on attributes listed in __all__. I realized it
1783 cripples the tab-completion system as a tool for exploring the
1795 cripples the tab-completion system as a tool for exploring the
1784 internals of unknown libraries (it renders any non-__all__
1796 internals of unknown libraries (it renders any non-__all__
1785 attribute off-limits). I got bit by this when trying to see
1797 attribute off-limits). I got bit by this when trying to see
1786 something inside the dis module.
1798 something inside the dis module.
1787
1799
1788 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
1800 2005-12-31 Fernando Perez <Fernando.Perez@colorado.edu>
1789
1801
1790 * IPython/iplib.py (InteractiveShell.__init__): add .meta
1802 * IPython/iplib.py (InteractiveShell.__init__): add .meta
1791 namespace for users and extension writers to hold data in. This
1803 namespace for users and extension writers to hold data in. This
1792 follows the discussion in
1804 follows the discussion in
1793 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
1805 http://projects.scipy.org/ipython/ipython/wiki/RefactoringIPython.
1794
1806
1795 * IPython/completer.py (IPCompleter.complete): small patch to help
1807 * IPython/completer.py (IPCompleter.complete): small patch to help
1796 tab-completion under Emacs, after a suggestion by John Barnard
1808 tab-completion under Emacs, after a suggestion by John Barnard
1797 <barnarj-AT-ccf.org>.
1809 <barnarj-AT-ccf.org>.
1798
1810
1799 * IPython/Magic.py (Magic.extract_input_slices): added support for
1811 * IPython/Magic.py (Magic.extract_input_slices): added support for
1800 the slice notation in magics to use N-M to represent numbers N...M
1812 the slice notation in magics to use N-M to represent numbers N...M
1801 (closed endpoints). This is used by %macro and %save.
1813 (closed endpoints). This is used by %macro and %save.
1802
1814
1803 * IPython/completer.py (Completer.attr_matches): for modules which
1815 * IPython/completer.py (Completer.attr_matches): for modules which
1804 define __all__, complete only on those. After a patch by Jeffrey
1816 define __all__, complete only on those. After a patch by Jeffrey
1805 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
1817 Collins <jcollins_boulder-AT-earthlink.net>. Also, clean up and
1806 speed up this routine.
1818 speed up this routine.
1807
1819
1808 * IPython/Logger.py (Logger.log): fix a history handling bug. I
1820 * IPython/Logger.py (Logger.log): fix a history handling bug. I
1809 don't know if this is the end of it, but the behavior now is
1821 don't know if this is the end of it, but the behavior now is
1810 certainly much more correct. Note that coupled with macros,
1822 certainly much more correct. Note that coupled with macros,
1811 slightly surprising (at first) behavior may occur: a macro will in
1823 slightly surprising (at first) behavior may occur: a macro will in
1812 general expand to multiple lines of input, so upon exiting, the
1824 general expand to multiple lines of input, so upon exiting, the
1813 in/out counters will both be bumped by the corresponding amount
1825 in/out counters will both be bumped by the corresponding amount
1814 (as if the macro's contents had been typed interactively). Typing
1826 (as if the macro's contents had been typed interactively). Typing
1815 %hist will reveal the intermediate (silently processed) lines.
1827 %hist will reveal the intermediate (silently processed) lines.
1816
1828
1817 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
1829 * IPython/Magic.py (magic_run): fix a subtle bug which could cause
1818 pickle to fail (%run was overwriting __main__ and not restoring
1830 pickle to fail (%run was overwriting __main__ and not restoring
1819 it, but pickle relies on __main__ to operate).
1831 it, but pickle relies on __main__ to operate).
1820
1832
1821 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
1833 * IPython/iplib.py (InteractiveShell): fix pdb calling: I'm now
1822 using properties, but forgot to make the main InteractiveShell
1834 using properties, but forgot to make the main InteractiveShell
1823 class a new-style class. Properties fail silently, and
1835 class a new-style class. Properties fail silently, and
1824 mysteriously, with old-style class (getters work, but
1836 mysteriously, with old-style class (getters work, but
1825 setters don't do anything).
1837 setters don't do anything).
1826
1838
1827 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
1839 2005-12-30 Fernando Perez <Fernando.Perez@colorado.edu>
1828
1840
1829 * IPython/Magic.py (magic_history): fix history reporting bug (I
1841 * IPython/Magic.py (magic_history): fix history reporting bug (I
1830 know some nasties are still there, I just can't seem to find a
1842 know some nasties are still there, I just can't seem to find a
1831 reproducible test case to track them down; the input history is
1843 reproducible test case to track them down; the input history is
1832 falling out of sync...)
1844 falling out of sync...)
1833
1845
1834 * IPython/iplib.py (handle_shell_escape): fix bug where both
1846 * IPython/iplib.py (handle_shell_escape): fix bug where both
1835 aliases and system accesses where broken for indented code (such
1847 aliases and system accesses where broken for indented code (such
1836 as loops).
1848 as loops).
1837
1849
1838 * IPython/genutils.py (shell): fix small but critical bug for
1850 * IPython/genutils.py (shell): fix small but critical bug for
1839 win32 system access.
1851 win32 system access.
1840
1852
1841 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
1853 2005-12-29 Fernando Perez <Fernando.Perez@colorado.edu>
1842
1854
1843 * IPython/iplib.py (showtraceback): remove use of the
1855 * IPython/iplib.py (showtraceback): remove use of the
1844 sys.last_{type/value/traceback} structures, which are non
1856 sys.last_{type/value/traceback} structures, which are non
1845 thread-safe.
1857 thread-safe.
1846 (_prefilter): change control flow to ensure that we NEVER
1858 (_prefilter): change control flow to ensure that we NEVER
1847 introspect objects when autocall is off. This will guarantee that
1859 introspect objects when autocall is off. This will guarantee that
1848 having an input line of the form 'x.y', where access to attribute
1860 having an input line of the form 'x.y', where access to attribute
1849 'y' has side effects, doesn't trigger the side effect TWICE. It
1861 'y' has side effects, doesn't trigger the side effect TWICE. It
1850 is important to note that, with autocall on, these side effects
1862 is important to note that, with autocall on, these side effects
1851 can still happen.
1863 can still happen.
1852 (ipsystem): new builtin, to complete the ip{magic/alias/system}
1864 (ipsystem): new builtin, to complete the ip{magic/alias/system}
1853 trio. IPython offers these three kinds of special calls which are
1865 trio. IPython offers these three kinds of special calls which are
1854 not python code, and it's a good thing to have their call method
1866 not python code, and it's a good thing to have their call method
1855 be accessible as pure python functions (not just special syntax at
1867 be accessible as pure python functions (not just special syntax at
1856 the command line). It gives us a better internal implementation
1868 the command line). It gives us a better internal implementation
1857 structure, as well as exposing these for user scripting more
1869 structure, as well as exposing these for user scripting more
1858 cleanly.
1870 cleanly.
1859
1871
1860 * IPython/macro.py (Macro.__init__): moved macros to a standalone
1872 * IPython/macro.py (Macro.__init__): moved macros to a standalone
1861 file. Now that they'll be more likely to be used with the
1873 file. Now that they'll be more likely to be used with the
1862 persistance system (%store), I want to make sure their module path
1874 persistance system (%store), I want to make sure their module path
1863 doesn't change in the future, so that we don't break things for
1875 doesn't change in the future, so that we don't break things for
1864 users' persisted data.
1876 users' persisted data.
1865
1877
1866 * IPython/iplib.py (autoindent_update): move indentation
1878 * IPython/iplib.py (autoindent_update): move indentation
1867 management into the _text_ processing loop, not the keyboard
1879 management into the _text_ processing loop, not the keyboard
1868 interactive one. This is necessary to correctly process non-typed
1880 interactive one. This is necessary to correctly process non-typed
1869 multiline input (such as macros).
1881 multiline input (such as macros).
1870
1882
1871 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
1883 * IPython/Magic.py (Magic.format_latex): patch by Stefan van der
1872 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
1884 Walt <stefan-AT-sun.ac.za> to fix latex formatting of docstrings,
1873 which was producing problems in the resulting manual.
1885 which was producing problems in the resulting manual.
1874 (magic_whos): improve reporting of instances (show their class,
1886 (magic_whos): improve reporting of instances (show their class,
1875 instead of simply printing 'instance' which isn't terribly
1887 instead of simply printing 'instance' which isn't terribly
1876 informative).
1888 informative).
1877
1889
1878 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
1890 * IPython/genutils.py (shell): commit Jorgen Stenarson's patch
1879 (minor mods) to support network shares under win32.
1891 (minor mods) to support network shares under win32.
1880
1892
1881 * IPython/winconsole.py (get_console_size): add new winconsole
1893 * IPython/winconsole.py (get_console_size): add new winconsole
1882 module and fixes to page_dumb() to improve its behavior under
1894 module and fixes to page_dumb() to improve its behavior under
1883 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
1895 win32. Contributed by Alexander Belchenko <bialix-AT-ukr.net>.
1884
1896
1885 * IPython/Magic.py (Macro): simplified Macro class to just
1897 * IPython/Magic.py (Macro): simplified Macro class to just
1886 subclass list. We've had only 2.2 compatibility for a very long
1898 subclass list. We've had only 2.2 compatibility for a very long
1887 time, yet I was still avoiding subclassing the builtin types. No
1899 time, yet I was still avoiding subclassing the builtin types. No
1888 more (I'm also starting to use properties, though I won't shift to
1900 more (I'm also starting to use properties, though I won't shift to
1889 2.3-specific features quite yet).
1901 2.3-specific features quite yet).
1890 (magic_store): added Ville's patch for lightweight variable
1902 (magic_store): added Ville's patch for lightweight variable
1891 persistence, after a request on the user list by Matt Wilkie
1903 persistence, after a request on the user list by Matt Wilkie
1892 <maphew-AT-gmail.com>. The new %store magic's docstring has full
1904 <maphew-AT-gmail.com>. The new %store magic's docstring has full
1893 details.
1905 details.
1894
1906
1895 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1907 * IPython/iplib.py (InteractiveShell.post_config_initialization):
1896 changed the default logfile name from 'ipython.log' to
1908 changed the default logfile name from 'ipython.log' to
1897 'ipython_log.py'. These logs are real python files, and now that
1909 'ipython_log.py'. These logs are real python files, and now that
1898 we have much better multiline support, people are more likely to
1910 we have much better multiline support, people are more likely to
1899 want to use them as such. Might as well name them correctly.
1911 want to use them as such. Might as well name them correctly.
1900
1912
1901 * IPython/Magic.py: substantial cleanup. While we can't stop
1913 * IPython/Magic.py: substantial cleanup. While we can't stop
1902 using magics as mixins, due to the existing customizations 'out
1914 using magics as mixins, due to the existing customizations 'out
1903 there' which rely on the mixin naming conventions, at least I
1915 there' which rely on the mixin naming conventions, at least I
1904 cleaned out all cross-class name usage. So once we are OK with
1916 cleaned out all cross-class name usage. So once we are OK with
1905 breaking compatibility, the two systems can be separated.
1917 breaking compatibility, the two systems can be separated.
1906
1918
1907 * IPython/Logger.py: major cleanup. This one is NOT a mixin
1919 * IPython/Logger.py: major cleanup. This one is NOT a mixin
1908 anymore, and the class is a fair bit less hideous as well. New
1920 anymore, and the class is a fair bit less hideous as well. New
1909 features were also introduced: timestamping of input, and logging
1921 features were also introduced: timestamping of input, and logging
1910 of output results. These are user-visible with the -t and -o
1922 of output results. These are user-visible with the -t and -o
1911 options to %logstart. Closes
1923 options to %logstart. Closes
1912 http://www.scipy.net/roundup/ipython/issue11 and a request by
1924 http://www.scipy.net/roundup/ipython/issue11 and a request by
1913 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
1925 William Stein (SAGE developer - http://modular.ucsd.edu/sage).
1914
1926
1915 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
1927 2005-12-28 Fernando Perez <Fernando.Perez@colorado.edu>
1916
1928
1917 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
1929 * IPython/iplib.py (handle_shell_escape): add Ville's patch to
1918 better handle backslashes in paths. See the thread 'More Windows
1930 better handle backslashes in paths. See the thread 'More Windows
1919 questions part 2 - \/ characters revisited' on the iypthon user
1931 questions part 2 - \/ characters revisited' on the iypthon user
1920 list:
1932 list:
1921 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
1933 http://scipy.net/pipermail/ipython-user/2005-June/000907.html
1922
1934
1923 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
1935 (InteractiveShell.__init__): fix tab-completion bug in threaded shells.
1924
1936
1925 (InteractiveShell.__init__): change threaded shells to not use the
1937 (InteractiveShell.__init__): change threaded shells to not use the
1926 ipython crash handler. This was causing more problems than not,
1938 ipython crash handler. This was causing more problems than not,
1927 as exceptions in the main thread (GUI code, typically) would
1939 as exceptions in the main thread (GUI code, typically) would
1928 always show up as a 'crash', when they really weren't.
1940 always show up as a 'crash', when they really weren't.
1929
1941
1930 The colors and exception mode commands (%colors/%xmode) have been
1942 The colors and exception mode commands (%colors/%xmode) have been
1931 synchronized to also take this into account, so users can get
1943 synchronized to also take this into account, so users can get
1932 verbose exceptions for their threaded code as well. I also added
1944 verbose exceptions for their threaded code as well. I also added
1933 support for activating pdb inside this exception handler as well,
1945 support for activating pdb inside this exception handler as well,
1934 so now GUI authors can use IPython's enhanced pdb at runtime.
1946 so now GUI authors can use IPython's enhanced pdb at runtime.
1935
1947
1936 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
1948 * IPython/ipmaker.py (make_IPython): make the autoedit_syntax flag
1937 true by default, and add it to the shipped ipythonrc file. Since
1949 true by default, and add it to the shipped ipythonrc file. Since
1938 this asks the user before proceeding, I think it's OK to make it
1950 this asks the user before proceeding, I think it's OK to make it
1939 true by default.
1951 true by default.
1940
1952
1941 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
1953 * IPython/Magic.py (magic_exit): make new exit/quit magics instead
1942 of the previous special-casing of input in the eval loop. I think
1954 of the previous special-casing of input in the eval loop. I think
1943 this is cleaner, as they really are commands and shouldn't have
1955 this is cleaner, as they really are commands and shouldn't have
1944 a special role in the middle of the core code.
1956 a special role in the middle of the core code.
1945
1957
1946 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
1958 2005-12-27 Fernando Perez <Fernando.Perez@colorado.edu>
1947
1959
1948 * IPython/iplib.py (edit_syntax_error): added support for
1960 * IPython/iplib.py (edit_syntax_error): added support for
1949 automatically reopening the editor if the file had a syntax error
1961 automatically reopening the editor if the file had a syntax error
1950 in it. Thanks to scottt who provided the patch at:
1962 in it. Thanks to scottt who provided the patch at:
1951 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
1963 http://www.scipy.net/roundup/ipython/issue36 (slightly modified
1952 version committed).
1964 version committed).
1953
1965
1954 * IPython/iplib.py (handle_normal): add suport for multi-line
1966 * IPython/iplib.py (handle_normal): add suport for multi-line
1955 input with emtpy lines. This fixes
1967 input with emtpy lines. This fixes
1956 http://www.scipy.net/roundup/ipython/issue43 and a similar
1968 http://www.scipy.net/roundup/ipython/issue43 and a similar
1957 discussion on the user list.
1969 discussion on the user list.
1958
1970
1959 WARNING: a behavior change is necessarily introduced to support
1971 WARNING: a behavior change is necessarily introduced to support
1960 blank lines: now a single blank line with whitespace does NOT
1972 blank lines: now a single blank line with whitespace does NOT
1961 break the input loop, which means that when autoindent is on, by
1973 break the input loop, which means that when autoindent is on, by
1962 default hitting return on the next (indented) line does NOT exit.
1974 default hitting return on the next (indented) line does NOT exit.
1963
1975
1964 Instead, to exit a multiline input you can either have:
1976 Instead, to exit a multiline input you can either have:
1965
1977
1966 - TWO whitespace lines (just hit return again), or
1978 - TWO whitespace lines (just hit return again), or
1967 - a single whitespace line of a different length than provided
1979 - a single whitespace line of a different length than provided
1968 by the autoindent (add or remove a space).
1980 by the autoindent (add or remove a space).
1969
1981
1970 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
1982 * IPython/completer.py (MagicCompleter.__init__): new 'completer'
1971 module to better organize all readline-related functionality.
1983 module to better organize all readline-related functionality.
1972 I've deleted FlexCompleter and put all completion clases here.
1984 I've deleted FlexCompleter and put all completion clases here.
1973
1985
1974 * IPython/iplib.py (raw_input): improve indentation management.
1986 * IPython/iplib.py (raw_input): improve indentation management.
1975 It is now possible to paste indented code with autoindent on, and
1987 It is now possible to paste indented code with autoindent on, and
1976 the code is interpreted correctly (though it still looks bad on
1988 the code is interpreted correctly (though it still looks bad on
1977 screen, due to the line-oriented nature of ipython).
1989 screen, due to the line-oriented nature of ipython).
1978 (MagicCompleter.complete): change behavior so that a TAB key on an
1990 (MagicCompleter.complete): change behavior so that a TAB key on an
1979 otherwise empty line actually inserts a tab, instead of completing
1991 otherwise empty line actually inserts a tab, instead of completing
1980 on the entire global namespace. This makes it easier to use the
1992 on the entire global namespace. This makes it easier to use the
1981 TAB key for indentation. After a request by Hans Meine
1993 TAB key for indentation. After a request by Hans Meine
1982 <hans_meine-AT-gmx.net>
1994 <hans_meine-AT-gmx.net>
1983 (_prefilter): add support so that typing plain 'exit' or 'quit'
1995 (_prefilter): add support so that typing plain 'exit' or 'quit'
1984 does a sensible thing. Originally I tried to deviate as little as
1996 does a sensible thing. Originally I tried to deviate as little as
1985 possible from the default python behavior, but even that one may
1997 possible from the default python behavior, but even that one may
1986 change in this direction (thread on python-dev to that effect).
1998 change in this direction (thread on python-dev to that effect).
1987 Regardless, ipython should do the right thing even if CPython's
1999 Regardless, ipython should do the right thing even if CPython's
1988 '>>>' prompt doesn't.
2000 '>>>' prompt doesn't.
1989 (InteractiveShell): removed subclassing code.InteractiveConsole
2001 (InteractiveShell): removed subclassing code.InteractiveConsole
1990 class. By now we'd overridden just about all of its methods: I've
2002 class. By now we'd overridden just about all of its methods: I've
1991 copied the remaining two over, and now ipython is a standalone
2003 copied the remaining two over, and now ipython is a standalone
1992 class. This will provide a clearer picture for the chainsaw
2004 class. This will provide a clearer picture for the chainsaw
1993 branch refactoring.
2005 branch refactoring.
1994
2006
1995 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
2007 2005-12-26 Fernando Perez <Fernando.Perez@colorado.edu>
1996
2008
1997 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
2009 * IPython/ultraTB.py (VerboseTB.text): harden reporting against
1998 failures for objects which break when dir() is called on them.
2010 failures for objects which break when dir() is called on them.
1999
2011
2000 * IPython/FlexCompleter.py (Completer.__init__): Added support for
2012 * IPython/FlexCompleter.py (Completer.__init__): Added support for
2001 distinct local and global namespaces in the completer API. This
2013 distinct local and global namespaces in the completer API. This
2002 change allows us to properly handle completion with distinct
2014 change allows us to properly handle completion with distinct
2003 scopes, including in embedded instances (this had never really
2015 scopes, including in embedded instances (this had never really
2004 worked correctly).
2016 worked correctly).
2005
2017
2006 Note: this introduces a change in the constructor for
2018 Note: this introduces a change in the constructor for
2007 MagicCompleter, as a new global_namespace parameter is now the
2019 MagicCompleter, as a new global_namespace parameter is now the
2008 second argument (the others were bumped one position).
2020 second argument (the others were bumped one position).
2009
2021
2010 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
2022 2005-12-25 Fernando Perez <Fernando.Perez@colorado.edu>
2011
2023
2012 * IPython/iplib.py (embed_mainloop): fix tab-completion in
2024 * IPython/iplib.py (embed_mainloop): fix tab-completion in
2013 embedded instances (which can be done now thanks to Vivian's
2025 embedded instances (which can be done now thanks to Vivian's
2014 frame-handling fixes for pdb).
2026 frame-handling fixes for pdb).
2015 (InteractiveShell.__init__): Fix namespace handling problem in
2027 (InteractiveShell.__init__): Fix namespace handling problem in
2016 embedded instances. We were overwriting __main__ unconditionally,
2028 embedded instances. We were overwriting __main__ unconditionally,
2017 and this should only be done for 'full' (non-embedded) IPython;
2029 and this should only be done for 'full' (non-embedded) IPython;
2018 embedded instances must respect the caller's __main__. Thanks to
2030 embedded instances must respect the caller's __main__. Thanks to
2019 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
2031 a bug report by Yaroslav Bulatov <yaroslavvb-AT-gmail.com>
2020
2032
2021 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
2033 2005-12-24 Fernando Perez <Fernando.Perez@colorado.edu>
2022
2034
2023 * setup.py: added download_url to setup(). This registers the
2035 * setup.py: added download_url to setup(). This registers the
2024 download address at PyPI, which is not only useful to humans
2036 download address at PyPI, which is not only useful to humans
2025 browsing the site, but is also picked up by setuptools (the Eggs
2037 browsing the site, but is also picked up by setuptools (the Eggs
2026 machinery). Thanks to Ville and R. Kern for the info/discussion
2038 machinery). Thanks to Ville and R. Kern for the info/discussion
2027 on this.
2039 on this.
2028
2040
2029 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
2041 2005-12-23 Fernando Perez <Fernando.Perez@colorado.edu>
2030
2042
2031 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
2043 * IPython/Debugger.py (Pdb.__init__): Major pdb mode enhancements.
2032 This brings a lot of nice functionality to the pdb mode, which now
2044 This brings a lot of nice functionality to the pdb mode, which now
2033 has tab-completion, syntax highlighting, and better stack handling
2045 has tab-completion, syntax highlighting, and better stack handling
2034 than before. Many thanks to Vivian De Smedt
2046 than before. Many thanks to Vivian De Smedt
2035 <vivian-AT-vdesmedt.com> for the original patches.
2047 <vivian-AT-vdesmedt.com> for the original patches.
2036
2048
2037 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
2049 2005-12-08 Fernando Perez <Fernando.Perez@colorado.edu>
2038
2050
2039 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
2051 * IPython/Shell.py (IPShellGTK.mainloop): fix mainloop() calling
2040 sequence to consistently accept the banner argument. The
2052 sequence to consistently accept the banner argument. The
2041 inconsistency was tripping SAGE, thanks to Gary Zablackis
2053 inconsistency was tripping SAGE, thanks to Gary Zablackis
2042 <gzabl-AT-yahoo.com> for the report.
2054 <gzabl-AT-yahoo.com> for the report.
2043
2055
2044 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2056 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2045
2057
2046 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2058 * IPython/iplib.py (InteractiveShell.post_config_initialization):
2047 Fix bug where a naked 'alias' call in the ipythonrc file would
2059 Fix bug where a naked 'alias' call in the ipythonrc file would
2048 cause a crash. Bug reported by Jorgen Stenarson.
2060 cause a crash. Bug reported by Jorgen Stenarson.
2049
2061
2050 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2062 2005-11-15 Fernando Perez <Fernando.Perez@colorado.edu>
2051
2063
2052 * IPython/ipmaker.py (make_IPython): cleanups which should improve
2064 * IPython/ipmaker.py (make_IPython): cleanups which should improve
2053 startup time.
2065 startup time.
2054
2066
2055 * IPython/iplib.py (runcode): my globals 'fix' for embedded
2067 * IPython/iplib.py (runcode): my globals 'fix' for embedded
2056 instances had introduced a bug with globals in normal code. Now
2068 instances had introduced a bug with globals in normal code. Now
2057 it's working in all cases.
2069 it's working in all cases.
2058
2070
2059 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
2071 * IPython/Magic.py (magic_psearch): Finish wildcard cleanup and
2060 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
2072 API changes. A new ipytonrc option, 'wildcards_case_sensitive'
2061 has been introduced to set the default case sensitivity of the
2073 has been introduced to set the default case sensitivity of the
2062 searches. Users can still select either mode at runtime on a
2074 searches. Users can still select either mode at runtime on a
2063 per-search basis.
2075 per-search basis.
2064
2076
2065 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
2077 2005-11-13 Fernando Perez <Fernando.Perez@colorado.edu>
2066
2078
2067 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
2079 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
2068 attributes in wildcard searches for subclasses. Modified version
2080 attributes in wildcard searches for subclasses. Modified version
2069 of a patch by Jorgen.
2081 of a patch by Jorgen.
2070
2082
2071 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
2083 2005-11-12 Fernando Perez <Fernando.Perez@colorado.edu>
2072
2084
2073 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
2085 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
2074 embedded instances. I added a user_global_ns attribute to the
2086 embedded instances. I added a user_global_ns attribute to the
2075 InteractiveShell class to handle this.
2087 InteractiveShell class to handle this.
2076
2088
2077 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
2089 2005-10-31 Fernando Perez <Fernando.Perez@colorado.edu>
2078
2090
2079 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
2091 * IPython/Shell.py (IPShellGTK.mainloop): Change timeout_add to
2080 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
2092 idle_add, which fixes horrible keyboard lag problems under gtk 2.6
2081 (reported under win32, but may happen also in other platforms).
2093 (reported under win32, but may happen also in other platforms).
2082 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
2094 Bug report and fix courtesy of Sean Moore <smm-AT-logic.bm>
2083
2095
2084 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
2096 2005-10-15 Fernando Perez <Fernando.Perez@colorado.edu>
2085
2097
2086 * IPython/Magic.py (magic_psearch): new support for wildcard
2098 * IPython/Magic.py (magic_psearch): new support for wildcard
2087 patterns. Now, typing ?a*b will list all names which begin with a
2099 patterns. Now, typing ?a*b will list all names which begin with a
2088 and end in b, for example. The %psearch magic has full
2100 and end in b, for example. The %psearch magic has full
2089 docstrings. Many thanks to Jörgen Stenarson
2101 docstrings. Many thanks to Jörgen Stenarson
2090 <jorgen.stenarson-AT-bostream.nu>, author of the patches
2102 <jorgen.stenarson-AT-bostream.nu>, author of the patches
2091 implementing this functionality.
2103 implementing this functionality.
2092
2104
2093 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2105 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2094
2106
2095 * Manual: fixed long-standing annoyance of double-dashes (as in
2107 * Manual: fixed long-standing annoyance of double-dashes (as in
2096 --prefix=~, for example) being stripped in the HTML version. This
2108 --prefix=~, for example) being stripped in the HTML version. This
2097 is a latex2html bug, but a workaround was provided. Many thanks
2109 is a latex2html bug, but a workaround was provided. Many thanks
2098 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
2110 to George K. Thiruvathukal <gthiruv-AT-luc.edu> for the detailed
2099 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
2111 help, and Michael Tobis <mtobis-AT-gmail.com> for getting the ball
2100 rolling. This seemingly small issue had tripped a number of users
2112 rolling. This seemingly small issue had tripped a number of users
2101 when first installing, so I'm glad to see it gone.
2113 when first installing, so I'm glad to see it gone.
2102
2114
2103 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2115 2005-09-27 Fernando Perez <Fernando.Perez@colorado.edu>
2104
2116
2105 * IPython/Extensions/numeric_formats.py: fix missing import,
2117 * IPython/Extensions/numeric_formats.py: fix missing import,
2106 reported by Stephen Walton.
2118 reported by Stephen Walton.
2107
2119
2108 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
2120 2005-09-24 Fernando Perez <Fernando.Perez@colorado.edu>
2109
2121
2110 * IPython/demo.py: finish demo module, fully documented now.
2122 * IPython/demo.py: finish demo module, fully documented now.
2111
2123
2112 * IPython/genutils.py (file_read): simple little utility to read a
2124 * IPython/genutils.py (file_read): simple little utility to read a
2113 file and ensure it's closed afterwards.
2125 file and ensure it's closed afterwards.
2114
2126
2115 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
2127 2005-09-23 Fernando Perez <Fernando.Perez@colorado.edu>
2116
2128
2117 * IPython/demo.py (Demo.__init__): added support for individually
2129 * IPython/demo.py (Demo.__init__): added support for individually
2118 tagging blocks for automatic execution.
2130 tagging blocks for automatic execution.
2119
2131
2120 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
2132 * IPython/Magic.py (magic_pycat): new %pycat magic for showing
2121 syntax-highlighted python sources, requested by John.
2133 syntax-highlighted python sources, requested by John.
2122
2134
2123 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
2135 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
2124
2136
2125 * IPython/demo.py (Demo.again): fix bug where again() blocks after
2137 * IPython/demo.py (Demo.again): fix bug where again() blocks after
2126 finishing.
2138 finishing.
2127
2139
2128 * IPython/genutils.py (shlex_split): moved from Magic to here,
2140 * IPython/genutils.py (shlex_split): moved from Magic to here,
2129 where all 2.2 compatibility stuff lives. I needed it for demo.py.
2141 where all 2.2 compatibility stuff lives. I needed it for demo.py.
2130
2142
2131 * IPython/demo.py (Demo.__init__): added support for silent
2143 * IPython/demo.py (Demo.__init__): added support for silent
2132 blocks, improved marks as regexps, docstrings written.
2144 blocks, improved marks as regexps, docstrings written.
2133 (Demo.__init__): better docstring, added support for sys.argv.
2145 (Demo.__init__): better docstring, added support for sys.argv.
2134
2146
2135 * IPython/genutils.py (marquee): little utility used by the demo
2147 * IPython/genutils.py (marquee): little utility used by the demo
2136 code, handy in general.
2148 code, handy in general.
2137
2149
2138 * IPython/demo.py (Demo.__init__): new class for interactive
2150 * IPython/demo.py (Demo.__init__): new class for interactive
2139 demos. Not documented yet, I just wrote it in a hurry for
2151 demos. Not documented yet, I just wrote it in a hurry for
2140 scipy'05. Will docstring later.
2152 scipy'05. Will docstring later.
2141
2153
2142 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
2154 2005-09-20 Fernando Perez <Fernando.Perez@colorado.edu>
2143
2155
2144 * IPython/Shell.py (sigint_handler): Drastic simplification which
2156 * IPython/Shell.py (sigint_handler): Drastic simplification which
2145 also seems to make Ctrl-C work correctly across threads! This is
2157 also seems to make Ctrl-C work correctly across threads! This is
2146 so simple, that I can't beleive I'd missed it before. Needs more
2158 so simple, that I can't beleive I'd missed it before. Needs more
2147 testing, though.
2159 testing, though.
2148 (KBINT): Never mind, revert changes. I'm sure I'd tried something
2160 (KBINT): Never mind, revert changes. I'm sure I'd tried something
2149 like this before...
2161 like this before...
2150
2162
2151 * IPython/genutils.py (get_home_dir): add protection against
2163 * IPython/genutils.py (get_home_dir): add protection against
2152 non-dirs in win32 registry.
2164 non-dirs in win32 registry.
2153
2165
2154 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
2166 * IPython/iplib.py (InteractiveShell.alias_table_validate): fix
2155 bug where dict was mutated while iterating (pysh crash).
2167 bug where dict was mutated while iterating (pysh crash).
2156
2168
2157 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
2169 2005-09-06 Fernando Perez <Fernando.Perez@colorado.edu>
2158
2170
2159 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
2171 * IPython/iplib.py (handle_auto): Fix inconsistency arising from
2160 spurious newlines added by this routine. After a report by
2172 spurious newlines added by this routine. After a report by
2161 F. Mantegazza.
2173 F. Mantegazza.
2162
2174
2163 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
2175 2005-09-05 Fernando Perez <Fernando.Perez@colorado.edu>
2164
2176
2165 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
2177 * IPython/Shell.py (hijack_gtk): remove pygtk.require("2.0")
2166 calls. These were a leftover from the GTK 1.x days, and can cause
2178 calls. These were a leftover from the GTK 1.x days, and can cause
2167 problems in certain cases (after a report by John Hunter).
2179 problems in certain cases (after a report by John Hunter).
2168
2180
2169 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
2181 * IPython/iplib.py (InteractiveShell.__init__): Trap exception if
2170 os.getcwd() fails at init time. Thanks to patch from David Remahl
2182 os.getcwd() fails at init time. Thanks to patch from David Remahl
2171 <chmod007-AT-mac.com>.
2183 <chmod007-AT-mac.com>.
2172 (InteractiveShell.__init__): prevent certain special magics from
2184 (InteractiveShell.__init__): prevent certain special magics from
2173 being shadowed by aliases. Closes
2185 being shadowed by aliases. Closes
2174 http://www.scipy.net/roundup/ipython/issue41.
2186 http://www.scipy.net/roundup/ipython/issue41.
2175
2187
2176 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
2188 2005-08-31 Fernando Perez <Fernando.Perez@colorado.edu>
2177
2189
2178 * IPython/iplib.py (InteractiveShell.complete): Added new
2190 * IPython/iplib.py (InteractiveShell.complete): Added new
2179 top-level completion method to expose the completion mechanism
2191 top-level completion method to expose the completion mechanism
2180 beyond readline-based environments.
2192 beyond readline-based environments.
2181
2193
2182 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
2194 2005-08-19 Fernando Perez <Fernando.Perez@colorado.edu>
2183
2195
2184 * tools/ipsvnc (svnversion): fix svnversion capture.
2196 * tools/ipsvnc (svnversion): fix svnversion capture.
2185
2197
2186 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
2198 * IPython/iplib.py (InteractiveShell.__init__): Add has_readline
2187 attribute to self, which was missing. Before, it was set by a
2199 attribute to self, which was missing. Before, it was set by a
2188 routine which in certain cases wasn't being called, so the
2200 routine which in certain cases wasn't being called, so the
2189 instance could end up missing the attribute. This caused a crash.
2201 instance could end up missing the attribute. This caused a crash.
2190 Closes http://www.scipy.net/roundup/ipython/issue40.
2202 Closes http://www.scipy.net/roundup/ipython/issue40.
2191
2203
2192 2005-08-16 Fernando Perez <fperez@colorado.edu>
2204 2005-08-16 Fernando Perez <fperez@colorado.edu>
2193
2205
2194 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
2206 * IPython/ultraTB.py (VerboseTB.text): don't crash if object
2195 contains non-string attribute. Closes
2207 contains non-string attribute. Closes
2196 http://www.scipy.net/roundup/ipython/issue38.
2208 http://www.scipy.net/roundup/ipython/issue38.
2197
2209
2198 2005-08-14 Fernando Perez <fperez@colorado.edu>
2210 2005-08-14 Fernando Perez <fperez@colorado.edu>
2199
2211
2200 * tools/ipsvnc: Minor improvements, to add changeset info.
2212 * tools/ipsvnc: Minor improvements, to add changeset info.
2201
2213
2202 2005-08-12 Fernando Perez <fperez@colorado.edu>
2214 2005-08-12 Fernando Perez <fperez@colorado.edu>
2203
2215
2204 * IPython/iplib.py (runsource): remove self.code_to_run_src
2216 * IPython/iplib.py (runsource): remove self.code_to_run_src
2205 attribute. I realized this is nothing more than
2217 attribute. I realized this is nothing more than
2206 '\n'.join(self.buffer), and having the same data in two different
2218 '\n'.join(self.buffer), and having the same data in two different
2207 places is just asking for synchronization bugs. This may impact
2219 places is just asking for synchronization bugs. This may impact
2208 people who have custom exception handlers, so I need to warn
2220 people who have custom exception handlers, so I need to warn
2209 ipython-dev about it (F. Mantegazza may use them).
2221 ipython-dev about it (F. Mantegazza may use them).
2210
2222
2211 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
2223 2005-07-29 Fernando Perez <Fernando.Perez@colorado.edu>
2212
2224
2213 * IPython/genutils.py: fix 2.2 compatibility (generators)
2225 * IPython/genutils.py: fix 2.2 compatibility (generators)
2214
2226
2215 2005-07-18 Fernando Perez <fperez@colorado.edu>
2227 2005-07-18 Fernando Perez <fperez@colorado.edu>
2216
2228
2217 * IPython/genutils.py (get_home_dir): fix to help users with
2229 * IPython/genutils.py (get_home_dir): fix to help users with
2218 invalid $HOME under win32.
2230 invalid $HOME under win32.
2219
2231
2220 2005-07-17 Fernando Perez <fperez@colorado.edu>
2232 2005-07-17 Fernando Perez <fperez@colorado.edu>
2221
2233
2222 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
2234 * IPython/Prompts.py (str_safe): Make unicode-safe. Also remove
2223 some old hacks and clean up a bit other routines; code should be
2235 some old hacks and clean up a bit other routines; code should be
2224 simpler and a bit faster.
2236 simpler and a bit faster.
2225
2237
2226 * IPython/iplib.py (interact): removed some last-resort attempts
2238 * IPython/iplib.py (interact): removed some last-resort attempts
2227 to survive broken stdout/stderr. That code was only making it
2239 to survive broken stdout/stderr. That code was only making it
2228 harder to abstract out the i/o (necessary for gui integration),
2240 harder to abstract out the i/o (necessary for gui integration),
2229 and the crashes it could prevent were extremely rare in practice
2241 and the crashes it could prevent were extremely rare in practice
2230 (besides being fully user-induced in a pretty violent manner).
2242 (besides being fully user-induced in a pretty violent manner).
2231
2243
2232 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
2244 * IPython/genutils.py (IOStream.__init__): Simplify the i/o stuff.
2233 Nothing major yet, but the code is simpler to read; this should
2245 Nothing major yet, but the code is simpler to read; this should
2234 make it easier to do more serious modifications in the future.
2246 make it easier to do more serious modifications in the future.
2235
2247
2236 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
2248 * IPython/Extensions/InterpreterExec.py: Fix auto-quoting in pysh,
2237 which broke in .15 (thanks to a report by Ville).
2249 which broke in .15 (thanks to a report by Ville).
2238
2250
2239 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
2251 * IPython/Itpl.py (Itpl.__init__): add unicode support (it may not
2240 be quite correct, I know next to nothing about unicode). This
2252 be quite correct, I know next to nothing about unicode). This
2241 will allow unicode strings to be used in prompts, amongst other
2253 will allow unicode strings to be used in prompts, amongst other
2242 cases. It also will prevent ipython from crashing when unicode
2254 cases. It also will prevent ipython from crashing when unicode
2243 shows up unexpectedly in many places. If ascii encoding fails, we
2255 shows up unexpectedly in many places. If ascii encoding fails, we
2244 assume utf_8. Currently the encoding is not a user-visible
2256 assume utf_8. Currently the encoding is not a user-visible
2245 setting, though it could be made so if there is demand for it.
2257 setting, though it could be made so if there is demand for it.
2246
2258
2247 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
2259 * IPython/ipmaker.py (make_IPython): remove old 2.1-specific hack.
2248
2260
2249 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
2261 * IPython/Struct.py (Struct.merge): switch keys() to iterator.
2250
2262
2251 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
2263 * IPython/background_jobs.py: moved 2.2 compatibility to genutils.
2252
2264
2253 * IPython/genutils.py: Add 2.2 compatibility here, so all other
2265 * IPython/genutils.py: Add 2.2 compatibility here, so all other
2254 code can work transparently for 2.2/2.3.
2266 code can work transparently for 2.2/2.3.
2255
2267
2256 2005-07-16 Fernando Perez <fperez@colorado.edu>
2268 2005-07-16 Fernando Perez <fperez@colorado.edu>
2257
2269
2258 * IPython/ultraTB.py (ExceptionColors): Make a global variable
2270 * IPython/ultraTB.py (ExceptionColors): Make a global variable
2259 out of the color scheme table used for coloring exception
2271 out of the color scheme table used for coloring exception
2260 tracebacks. This allows user code to add new schemes at runtime.
2272 tracebacks. This allows user code to add new schemes at runtime.
2261 This is a minimally modified version of the patch at
2273 This is a minimally modified version of the patch at
2262 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
2274 http://www.scipy.net/roundup/ipython/issue35, many thanks to pabw
2263 for the contribution.
2275 for the contribution.
2264
2276
2265 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
2277 * IPython/FlexCompleter.py (Completer.attr_matches): Add a
2266 slightly modified version of the patch in
2278 slightly modified version of the patch in
2267 http://www.scipy.net/roundup/ipython/issue34, which also allows me
2279 http://www.scipy.net/roundup/ipython/issue34, which also allows me
2268 to remove the previous try/except solution (which was costlier).
2280 to remove the previous try/except solution (which was costlier).
2269 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
2281 Thanks to Gaetan Lehmann <gaetan.lehmann-AT-jouy.inra.fr> for the fix.
2270
2282
2271 2005-06-08 Fernando Perez <fperez@colorado.edu>
2283 2005-06-08 Fernando Perez <fperez@colorado.edu>
2272
2284
2273 * IPython/iplib.py (write/write_err): Add methods to abstract all
2285 * IPython/iplib.py (write/write_err): Add methods to abstract all
2274 I/O a bit more.
2286 I/O a bit more.
2275
2287
2276 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
2288 * IPython/Shell.py (IPShellGTK.mainloop): Fix GTK deprecation
2277 warning, reported by Aric Hagberg, fix by JD Hunter.
2289 warning, reported by Aric Hagberg, fix by JD Hunter.
2278
2290
2279 2005-06-02 *** Released version 0.6.15
2291 2005-06-02 *** Released version 0.6.15
2280
2292
2281 2005-06-01 Fernando Perez <fperez@colorado.edu>
2293 2005-06-01 Fernando Perez <fperez@colorado.edu>
2282
2294
2283 * IPython/iplib.py (MagicCompleter.file_matches): Fix
2295 * IPython/iplib.py (MagicCompleter.file_matches): Fix
2284 tab-completion of filenames within open-quoted strings. Note that
2296 tab-completion of filenames within open-quoted strings. Note that
2285 this requires that in ~/.ipython/ipythonrc, users change the
2297 this requires that in ~/.ipython/ipythonrc, users change the
2286 readline delimiters configuration to read:
2298 readline delimiters configuration to read:
2287
2299
2288 readline_remove_delims -/~
2300 readline_remove_delims -/~
2289
2301
2290
2302
2291 2005-05-31 *** Released version 0.6.14
2303 2005-05-31 *** Released version 0.6.14
2292
2304
2293 2005-05-29 Fernando Perez <fperez@colorado.edu>
2305 2005-05-29 Fernando Perez <fperez@colorado.edu>
2294
2306
2295 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
2307 * IPython/ultraTB.py (VerboseTB.text): Fix crash for tracebacks
2296 with files not on the filesystem. Reported by Eliyahu Sandler
2308 with files not on the filesystem. Reported by Eliyahu Sandler
2297 <eli@gondolin.net>
2309 <eli@gondolin.net>
2298
2310
2299 2005-05-22 Fernando Perez <fperez@colorado.edu>
2311 2005-05-22 Fernando Perez <fperez@colorado.edu>
2300
2312
2301 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
2313 * IPython/iplib.py: Fix a few crashes in the --upgrade option.
2302 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
2314 After an initial report by LUK ShunTim <shuntim.luk@polyu.edu.hk>.
2303
2315
2304 2005-05-19 Fernando Perez <fperez@colorado.edu>
2316 2005-05-19 Fernando Perez <fperez@colorado.edu>
2305
2317
2306 * IPython/iplib.py (safe_execfile): close a file which could be
2318 * IPython/iplib.py (safe_execfile): close a file which could be
2307 left open (causing problems in win32, which locks open files).
2319 left open (causing problems in win32, which locks open files).
2308 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
2320 Thanks to a bug report by D Brown <dbrown2@yahoo.com>.
2309
2321
2310 2005-05-18 Fernando Perez <fperez@colorado.edu>
2322 2005-05-18 Fernando Perez <fperez@colorado.edu>
2311
2323
2312 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
2324 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): pass all
2313 keyword arguments correctly to safe_execfile().
2325 keyword arguments correctly to safe_execfile().
2314
2326
2315 2005-05-13 Fernando Perez <fperez@colorado.edu>
2327 2005-05-13 Fernando Perez <fperez@colorado.edu>
2316
2328
2317 * ipython.1: Added info about Qt to manpage, and threads warning
2329 * ipython.1: Added info about Qt to manpage, and threads warning
2318 to usage page (invoked with --help).
2330 to usage page (invoked with --help).
2319
2331
2320 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
2332 * IPython/iplib.py (MagicCompleter.python_func_kw_matches): Added
2321 new matcher (it goes at the end of the priority list) to do
2333 new matcher (it goes at the end of the priority list) to do
2322 tab-completion on named function arguments. Submitted by George
2334 tab-completion on named function arguments. Submitted by George
2323 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
2335 Sakkis <gsakkis-AT-eden.rutgers.edu>. See the thread at
2324 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
2336 http://www.scipy.net/pipermail/ipython-dev/2005-April/000436.html
2325 for more details.
2337 for more details.
2326
2338
2327 * IPython/Magic.py (magic_run): Added new -e flag to ignore
2339 * IPython/Magic.py (magic_run): Added new -e flag to ignore
2328 SystemExit exceptions in the script being run. Thanks to a report
2340 SystemExit exceptions in the script being run. Thanks to a report
2329 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
2341 by danny shevitz <danny_shevitz-AT-yahoo.com>, about this
2330 producing very annoying behavior when running unit tests.
2342 producing very annoying behavior when running unit tests.
2331
2343
2332 2005-05-12 Fernando Perez <fperez@colorado.edu>
2344 2005-05-12 Fernando Perez <fperez@colorado.edu>
2333
2345
2334 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
2346 * IPython/iplib.py (handle_auto): fixed auto-quoting and parens,
2335 which I'd broken (again) due to a changed regexp. In the process,
2347 which I'd broken (again) due to a changed regexp. In the process,
2336 added ';' as an escape to auto-quote the whole line without
2348 added ';' as an escape to auto-quote the whole line without
2337 splitting its arguments. Thanks to a report by Jerry McRae
2349 splitting its arguments. Thanks to a report by Jerry McRae
2338 <qrs0xyc02-AT-sneakemail.com>.
2350 <qrs0xyc02-AT-sneakemail.com>.
2339
2351
2340 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
2352 * IPython/ultraTB.py (VerboseTB.text): protect against rare but
2341 possible crashes caused by a TokenError. Reported by Ed Schofield
2353 possible crashes caused by a TokenError. Reported by Ed Schofield
2342 <schofield-AT-ftw.at>.
2354 <schofield-AT-ftw.at>.
2343
2355
2344 2005-05-06 Fernando Perez <fperez@colorado.edu>
2356 2005-05-06 Fernando Perez <fperez@colorado.edu>
2345
2357
2346 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
2358 * IPython/Shell.py (hijack_wx): Fix to work with WX v.2.6.
2347
2359
2348 2005-04-29 Fernando Perez <fperez@colorado.edu>
2360 2005-04-29 Fernando Perez <fperez@colorado.edu>
2349
2361
2350 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
2362 * IPython/Shell.py (IPShellQt): Thanks to Denis Rivière
2351 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
2363 <nudz-AT-free.fr>, Yann Cointepas <yann-AT-sapetnioc.org> and Benjamin
2352 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
2364 Thyreau <Benji2-AT-decideur.info>, we now have a -qthread option
2353 which provides support for Qt interactive usage (similar to the
2365 which provides support for Qt interactive usage (similar to the
2354 existing one for WX and GTK). This had been often requested.
2366 existing one for WX and GTK). This had been often requested.
2355
2367
2356 2005-04-14 *** Released version 0.6.13
2368 2005-04-14 *** Released version 0.6.13
2357
2369
2358 2005-04-08 Fernando Perez <fperez@colorado.edu>
2370 2005-04-08 Fernando Perez <fperez@colorado.edu>
2359
2371
2360 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
2372 * IPython/Magic.py (Magic._ofind): remove docstring evaluation
2361 from _ofind, which gets called on almost every input line. Now,
2373 from _ofind, which gets called on almost every input line. Now,
2362 we only try to get docstrings if they are actually going to be
2374 we only try to get docstrings if they are actually going to be
2363 used (the overhead of fetching unnecessary docstrings can be
2375 used (the overhead of fetching unnecessary docstrings can be
2364 noticeable for certain objects, such as Pyro proxies).
2376 noticeable for certain objects, such as Pyro proxies).
2365
2377
2366 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
2378 * IPython/iplib.py (MagicCompleter.python_matches): Change the API
2367 for completers. For some reason I had been passing them the state
2379 for completers. For some reason I had been passing them the state
2368 variable, which completers never actually need, and was in
2380 variable, which completers never actually need, and was in
2369 conflict with the rlcompleter API. Custom completers ONLY need to
2381 conflict with the rlcompleter API. Custom completers ONLY need to
2370 take the text parameter.
2382 take the text parameter.
2371
2383
2372 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
2384 * IPython/Extensions/InterpreterExec.py: Fix regexp so that magics
2373 work correctly in pysh. I've also moved all the logic which used
2385 work correctly in pysh. I've also moved all the logic which used
2374 to be in pysh.py here, which will prevent problems with future
2386 to be in pysh.py here, which will prevent problems with future
2375 upgrades. However, this time I must warn users to update their
2387 upgrades. However, this time I must warn users to update their
2376 pysh profile to include the line
2388 pysh profile to include the line
2377
2389
2378 import_all IPython.Extensions.InterpreterExec
2390 import_all IPython.Extensions.InterpreterExec
2379
2391
2380 because otherwise things won't work for them. They MUST also
2392 because otherwise things won't work for them. They MUST also
2381 delete pysh.py and the line
2393 delete pysh.py and the line
2382
2394
2383 execfile pysh.py
2395 execfile pysh.py
2384
2396
2385 from their ipythonrc-pysh.
2397 from their ipythonrc-pysh.
2386
2398
2387 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
2399 * IPython/FlexCompleter.py (Completer.attr_matches): Make more
2388 robust in the face of objects whose dir() returns non-strings
2400 robust in the face of objects whose dir() returns non-strings
2389 (which it shouldn't, but some broken libs like ITK do). Thanks to
2401 (which it shouldn't, but some broken libs like ITK do). Thanks to
2390 a patch by John Hunter (implemented differently, though). Also
2402 a patch by John Hunter (implemented differently, though). Also
2391 minor improvements by using .extend instead of + on lists.
2403 minor improvements by using .extend instead of + on lists.
2392
2404
2393 * pysh.py:
2405 * pysh.py:
2394
2406
2395 2005-04-06 Fernando Perez <fperez@colorado.edu>
2407 2005-04-06 Fernando Perez <fperez@colorado.edu>
2396
2408
2397 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
2409 * IPython/ipmaker.py (make_IPython): Make multi_line_specials on
2398 by default, so that all users benefit from it. Those who don't
2410 by default, so that all users benefit from it. Those who don't
2399 want it can still turn it off.
2411 want it can still turn it off.
2400
2412
2401 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
2413 * IPython/UserConfig/ipythonrc: Add multi_line_specials to the
2402 config file, I'd forgotten about this, so users were getting it
2414 config file, I'd forgotten about this, so users were getting it
2403 off by default.
2415 off by default.
2404
2416
2405 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
2417 * IPython/iplib.py (ipmagic): big overhaul of the magic system for
2406 consistency. Now magics can be called in multiline statements,
2418 consistency. Now magics can be called in multiline statements,
2407 and python variables can be expanded in magic calls via $var.
2419 and python variables can be expanded in magic calls via $var.
2408 This makes the magic system behave just like aliases or !system
2420 This makes the magic system behave just like aliases or !system
2409 calls.
2421 calls.
2410
2422
2411 2005-03-28 Fernando Perez <fperez@colorado.edu>
2423 2005-03-28 Fernando Perez <fperez@colorado.edu>
2412
2424
2413 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
2425 * IPython/iplib.py (handle_auto): cleanup to use %s instead of
2414 expensive string additions for building command. Add support for
2426 expensive string additions for building command. Add support for
2415 trailing ';' when autocall is used.
2427 trailing ';' when autocall is used.
2416
2428
2417 2005-03-26 Fernando Perez <fperez@colorado.edu>
2429 2005-03-26 Fernando Perez <fperez@colorado.edu>
2418
2430
2419 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
2431 * ipython.el: Fix http://www.scipy.net/roundup/ipython/issue31.
2420 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
2432 Bugfix by A. Schmolck, the ipython.el maintainer. Also make
2421 ipython.el robust against prompts with any number of spaces
2433 ipython.el robust against prompts with any number of spaces
2422 (including 0) after the ':' character.
2434 (including 0) after the ':' character.
2423
2435
2424 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
2436 * IPython/Prompts.py (Prompt2.set_p_str): Fix spurious space in
2425 continuation prompt, which misled users to think the line was
2437 continuation prompt, which misled users to think the line was
2426 already indented. Closes debian Bug#300847, reported to me by
2438 already indented. Closes debian Bug#300847, reported to me by
2427 Norbert Tretkowski <tretkowski-AT-inittab.de>.
2439 Norbert Tretkowski <tretkowski-AT-inittab.de>.
2428
2440
2429 2005-03-23 Fernando Perez <fperez@colorado.edu>
2441 2005-03-23 Fernando Perez <fperez@colorado.edu>
2430
2442
2431 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
2443 * IPython/Prompts.py (Prompt1.__str__): Make sure that prompts are
2432 properly aligned if they have embedded newlines.
2444 properly aligned if they have embedded newlines.
2433
2445
2434 * IPython/iplib.py (runlines): Add a public method to expose
2446 * IPython/iplib.py (runlines): Add a public method to expose
2435 IPython's code execution machinery, so that users can run strings
2447 IPython's code execution machinery, so that users can run strings
2436 as if they had been typed at the prompt interactively.
2448 as if they had been typed at the prompt interactively.
2437 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
2449 (InteractiveShell.__init__): Added getoutput() to the __IPYTHON__
2438 methods which can call the system shell, but with python variable
2450 methods which can call the system shell, but with python variable
2439 expansion. The three such methods are: __IPYTHON__.system,
2451 expansion. The three such methods are: __IPYTHON__.system,
2440 .getoutput and .getoutputerror. These need to be documented in a
2452 .getoutput and .getoutputerror. These need to be documented in a
2441 'public API' section (to be written) of the manual.
2453 'public API' section (to be written) of the manual.
2442
2454
2443 2005-03-20 Fernando Perez <fperez@colorado.edu>
2455 2005-03-20 Fernando Perez <fperez@colorado.edu>
2444
2456
2445 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
2457 * IPython/iplib.py (InteractiveShell.set_custom_exc): new system
2446 for custom exception handling. This is quite powerful, and it
2458 for custom exception handling. This is quite powerful, and it
2447 allows for user-installable exception handlers which can trap
2459 allows for user-installable exception handlers which can trap
2448 custom exceptions at runtime and treat them separately from
2460 custom exceptions at runtime and treat them separately from
2449 IPython's default mechanisms. At the request of Frédéric
2461 IPython's default mechanisms. At the request of Frédéric
2450 Mantegazza <mantegazza-AT-ill.fr>.
2462 Mantegazza <mantegazza-AT-ill.fr>.
2451 (InteractiveShell.set_custom_completer): public API function to
2463 (InteractiveShell.set_custom_completer): public API function to
2452 add new completers at runtime.
2464 add new completers at runtime.
2453
2465
2454 2005-03-19 Fernando Perez <fperez@colorado.edu>
2466 2005-03-19 Fernando Perez <fperez@colorado.edu>
2455
2467
2456 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
2468 * IPython/OInspect.py (getdoc): Add a call to obj.getdoc(), to
2457 allow objects which provide their docstrings via non-standard
2469 allow objects which provide their docstrings via non-standard
2458 mechanisms (like Pyro proxies) to still be inspected by ipython's
2470 mechanisms (like Pyro proxies) to still be inspected by ipython's
2459 ? system.
2471 ? system.
2460
2472
2461 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
2473 * IPython/iplib.py (InteractiveShell.__init__): back off the _o/_e
2462 automatic capture system. I tried quite hard to make it work
2474 automatic capture system. I tried quite hard to make it work
2463 reliably, and simply failed. I tried many combinations with the
2475 reliably, and simply failed. I tried many combinations with the
2464 subprocess module, but eventually nothing worked in all needed
2476 subprocess module, but eventually nothing worked in all needed
2465 cases (not blocking stdin for the child, duplicating stdout
2477 cases (not blocking stdin for the child, duplicating stdout
2466 without blocking, etc). The new %sc/%sx still do capture to these
2478 without blocking, etc). The new %sc/%sx still do capture to these
2467 magical list/string objects which make shell use much more
2479 magical list/string objects which make shell use much more
2468 conveninent, so not all is lost.
2480 conveninent, so not all is lost.
2469
2481
2470 XXX - FIX MANUAL for the change above!
2482 XXX - FIX MANUAL for the change above!
2471
2483
2472 (runsource): I copied code.py's runsource() into ipython to modify
2484 (runsource): I copied code.py's runsource() into ipython to modify
2473 it a bit. Now the code object and source to be executed are
2485 it a bit. Now the code object and source to be executed are
2474 stored in ipython. This makes this info accessible to third-party
2486 stored in ipython. This makes this info accessible to third-party
2475 tools, like custom exception handlers. After a request by Frédéric
2487 tools, like custom exception handlers. After a request by Frédéric
2476 Mantegazza <mantegazza-AT-ill.fr>.
2488 Mantegazza <mantegazza-AT-ill.fr>.
2477
2489
2478 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
2490 * IPython/UserConfig/ipythonrc: Add up/down arrow keys to
2479 history-search via readline (like C-p/C-n). I'd wanted this for a
2491 history-search via readline (like C-p/C-n). I'd wanted this for a
2480 long time, but only recently found out how to do it. For users
2492 long time, but only recently found out how to do it. For users
2481 who already have their ipythonrc files made and want this, just
2493 who already have their ipythonrc files made and want this, just
2482 add:
2494 add:
2483
2495
2484 readline_parse_and_bind "\e[A": history-search-backward
2496 readline_parse_and_bind "\e[A": history-search-backward
2485 readline_parse_and_bind "\e[B": history-search-forward
2497 readline_parse_and_bind "\e[B": history-search-forward
2486
2498
2487 2005-03-18 Fernando Perez <fperez@colorado.edu>
2499 2005-03-18 Fernando Perez <fperez@colorado.edu>
2488
2500
2489 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
2501 * IPython/Magic.py (magic_sc): %sc and %sx now use the fancy
2490 LSString and SList classes which allow transparent conversions
2502 LSString and SList classes which allow transparent conversions
2491 between list mode and whitespace-separated string.
2503 between list mode and whitespace-separated string.
2492 (magic_r): Fix recursion problem in %r.
2504 (magic_r): Fix recursion problem in %r.
2493
2505
2494 * IPython/genutils.py (LSString): New class to be used for
2506 * IPython/genutils.py (LSString): New class to be used for
2495 automatic storage of the results of all alias/system calls in _o
2507 automatic storage of the results of all alias/system calls in _o
2496 and _e (stdout/err). These provide a .l/.list attribute which
2508 and _e (stdout/err). These provide a .l/.list attribute which
2497 does automatic splitting on newlines. This means that for most
2509 does automatic splitting on newlines. This means that for most
2498 uses, you'll never need to do capturing of output with %sc/%sx
2510 uses, you'll never need to do capturing of output with %sc/%sx
2499 anymore, since ipython keeps this always done for you. Note that
2511 anymore, since ipython keeps this always done for you. Note that
2500 only the LAST results are stored, the _o/e variables are
2512 only the LAST results are stored, the _o/e variables are
2501 overwritten on each call. If you need to save their contents
2513 overwritten on each call. If you need to save their contents
2502 further, simply bind them to any other name.
2514 further, simply bind them to any other name.
2503
2515
2504 2005-03-17 Fernando Perez <fperez@colorado.edu>
2516 2005-03-17 Fernando Perez <fperez@colorado.edu>
2505
2517
2506 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
2518 * IPython/Prompts.py (BasePrompt.cwd_filt): a few more fixes for
2507 prompt namespace handling.
2519 prompt namespace handling.
2508
2520
2509 2005-03-16 Fernando Perez <fperez@colorado.edu>
2521 2005-03-16 Fernando Perez <fperez@colorado.edu>
2510
2522
2511 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
2523 * IPython/Prompts.py (CachedOutput.__init__): Fix default and
2512 classic prompts to be '>>> ' (final space was missing, and it
2524 classic prompts to be '>>> ' (final space was missing, and it
2513 trips the emacs python mode).
2525 trips the emacs python mode).
2514 (BasePrompt.__str__): Added safe support for dynamic prompt
2526 (BasePrompt.__str__): Added safe support for dynamic prompt
2515 strings. Now you can set your prompt string to be '$x', and the
2527 strings. Now you can set your prompt string to be '$x', and the
2516 value of x will be printed from your interactive namespace. The
2528 value of x will be printed from your interactive namespace. The
2517 interpolation syntax includes the full Itpl support, so
2529 interpolation syntax includes the full Itpl support, so
2518 ${foo()+x+bar()} is a valid prompt string now, and the function
2530 ${foo()+x+bar()} is a valid prompt string now, and the function
2519 calls will be made at runtime.
2531 calls will be made at runtime.
2520
2532
2521 2005-03-15 Fernando Perez <fperez@colorado.edu>
2533 2005-03-15 Fernando Perez <fperez@colorado.edu>
2522
2534
2523 * IPython/Magic.py (magic_history): renamed %hist to %history, to
2535 * IPython/Magic.py (magic_history): renamed %hist to %history, to
2524 avoid name clashes in pylab. %hist still works, it just forwards
2536 avoid name clashes in pylab. %hist still works, it just forwards
2525 the call to %history.
2537 the call to %history.
2526
2538
2527 2005-03-02 *** Released version 0.6.12
2539 2005-03-02 *** Released version 0.6.12
2528
2540
2529 2005-03-02 Fernando Perez <fperez@colorado.edu>
2541 2005-03-02 Fernando Perez <fperez@colorado.edu>
2530
2542
2531 * IPython/iplib.py (handle_magic): log magic calls properly as
2543 * IPython/iplib.py (handle_magic): log magic calls properly as
2532 ipmagic() function calls.
2544 ipmagic() function calls.
2533
2545
2534 * IPython/Magic.py (magic_time): Improved %time to support
2546 * IPython/Magic.py (magic_time): Improved %time to support
2535 statements and provide wall-clock as well as CPU time.
2547 statements and provide wall-clock as well as CPU time.
2536
2548
2537 2005-02-27 Fernando Perez <fperez@colorado.edu>
2549 2005-02-27 Fernando Perez <fperez@colorado.edu>
2538
2550
2539 * IPython/hooks.py: New hooks module, to expose user-modifiable
2551 * IPython/hooks.py: New hooks module, to expose user-modifiable
2540 IPython functionality in a clean manner. For now only the editor
2552 IPython functionality in a clean manner. For now only the editor
2541 hook is actually written, and other thigns which I intend to turn
2553 hook is actually written, and other thigns which I intend to turn
2542 into proper hooks aren't yet there. The display and prefilter
2554 into proper hooks aren't yet there. The display and prefilter
2543 stuff, for example, should be hooks. But at least now the
2555 stuff, for example, should be hooks. But at least now the
2544 framework is in place, and the rest can be moved here with more
2556 framework is in place, and the rest can be moved here with more
2545 time later. IPython had had a .hooks variable for a long time for
2557 time later. IPython had had a .hooks variable for a long time for
2546 this purpose, but I'd never actually used it for anything.
2558 this purpose, but I'd never actually used it for anything.
2547
2559
2548 2005-02-26 Fernando Perez <fperez@colorado.edu>
2560 2005-02-26 Fernando Perez <fperez@colorado.edu>
2549
2561
2550 * IPython/ipmaker.py (make_IPython): make the default ipython
2562 * IPython/ipmaker.py (make_IPython): make the default ipython
2551 directory be called _ipython under win32, to follow more the
2563 directory be called _ipython under win32, to follow more the
2552 naming peculiarities of that platform (where buggy software like
2564 naming peculiarities of that platform (where buggy software like
2553 Visual Sourcesafe breaks with .named directories). Reported by
2565 Visual Sourcesafe breaks with .named directories). Reported by
2554 Ville Vainio.
2566 Ville Vainio.
2555
2567
2556 2005-02-23 Fernando Perez <fperez@colorado.edu>
2568 2005-02-23 Fernando Perez <fperez@colorado.edu>
2557
2569
2558 * IPython/iplib.py (InteractiveShell.__init__): removed a few
2570 * IPython/iplib.py (InteractiveShell.__init__): removed a few
2559 auto_aliases for win32 which were causing problems. Users can
2571 auto_aliases for win32 which were causing problems. Users can
2560 define the ones they personally like.
2572 define the ones they personally like.
2561
2573
2562 2005-02-21 Fernando Perez <fperez@colorado.edu>
2574 2005-02-21 Fernando Perez <fperez@colorado.edu>
2563
2575
2564 * IPython/Magic.py (magic_time): new magic to time execution of
2576 * IPython/Magic.py (magic_time): new magic to time execution of
2565 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
2577 expressions. After a request by Charles Moad <cmoad-AT-indiana.edu>.
2566
2578
2567 2005-02-19 Fernando Perez <fperez@colorado.edu>
2579 2005-02-19 Fernando Perez <fperez@colorado.edu>
2568
2580
2569 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
2581 * IPython/ConfigLoader.py (ConfigLoader.load): Allow empty strings
2570 into keys (for prompts, for example).
2582 into keys (for prompts, for example).
2571
2583
2572 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
2584 * IPython/Prompts.py (BasePrompt.set_p_str): Fix to allow empty
2573 prompts in case users want them. This introduces a small behavior
2585 prompts in case users want them. This introduces a small behavior
2574 change: ipython does not automatically add a space to all prompts
2586 change: ipython does not automatically add a space to all prompts
2575 anymore. To get the old prompts with a space, users should add it
2587 anymore. To get the old prompts with a space, users should add it
2576 manually to their ipythonrc file, so for example prompt_in1 should
2588 manually to their ipythonrc file, so for example prompt_in1 should
2577 now read 'In [\#]: ' instead of 'In [\#]:'.
2589 now read 'In [\#]: ' instead of 'In [\#]:'.
2578 (BasePrompt.__init__): New option prompts_pad_left (only in rc
2590 (BasePrompt.__init__): New option prompts_pad_left (only in rc
2579 file) to control left-padding of secondary prompts.
2591 file) to control left-padding of secondary prompts.
2580
2592
2581 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
2593 * IPython/Magic.py (Magic.profile_missing_notice): Don't crash if
2582 the profiler can't be imported. Fix for Debian, which removed
2594 the profiler can't be imported. Fix for Debian, which removed
2583 profile.py because of License issues. I applied a slightly
2595 profile.py because of License issues. I applied a slightly
2584 modified version of the original Debian patch at
2596 modified version of the original Debian patch at
2585 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
2597 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=294500.
2586
2598
2587 2005-02-17 Fernando Perez <fperez@colorado.edu>
2599 2005-02-17 Fernando Perez <fperez@colorado.edu>
2588
2600
2589 * IPython/genutils.py (native_line_ends): Fix bug which would
2601 * IPython/genutils.py (native_line_ends): Fix bug which would
2590 cause improper line-ends under win32 b/c I was not opening files
2602 cause improper line-ends under win32 b/c I was not opening files
2591 in binary mode. Bug report and fix thanks to Ville.
2603 in binary mode. Bug report and fix thanks to Ville.
2592
2604
2593 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
2605 * IPython/iplib.py (handle_auto): Fix bug which I introduced when
2594 trying to catch spurious foo[1] autocalls. My fix actually broke
2606 trying to catch spurious foo[1] autocalls. My fix actually broke
2595 ',/' autoquote/call with explicit escape (bad regexp).
2607 ',/' autoquote/call with explicit escape (bad regexp).
2596
2608
2597 2005-02-15 *** Released version 0.6.11
2609 2005-02-15 *** Released version 0.6.11
2598
2610
2599 2005-02-14 Fernando Perez <fperez@colorado.edu>
2611 2005-02-14 Fernando Perez <fperez@colorado.edu>
2600
2612
2601 * IPython/background_jobs.py: New background job management
2613 * IPython/background_jobs.py: New background job management
2602 subsystem. This is implemented via a new set of classes, and
2614 subsystem. This is implemented via a new set of classes, and
2603 IPython now provides a builtin 'jobs' object for background job
2615 IPython now provides a builtin 'jobs' object for background job
2604 execution. A convenience %bg magic serves as a lightweight
2616 execution. A convenience %bg magic serves as a lightweight
2605 frontend for starting the more common type of calls. This was
2617 frontend for starting the more common type of calls. This was
2606 inspired by discussions with B. Granger and the BackgroundCommand
2618 inspired by discussions with B. Granger and the BackgroundCommand
2607 class described in the book Python Scripting for Computational
2619 class described in the book Python Scripting for Computational
2608 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
2620 Science, by H. P. Langtangen: http://folk.uio.no/hpl/scripting
2609 (although ultimately no code from this text was used, as IPython's
2621 (although ultimately no code from this text was used, as IPython's
2610 system is a separate implementation).
2622 system is a separate implementation).
2611
2623
2612 * IPython/iplib.py (MagicCompleter.python_matches): add new option
2624 * IPython/iplib.py (MagicCompleter.python_matches): add new option
2613 to control the completion of single/double underscore names
2625 to control the completion of single/double underscore names
2614 separately. As documented in the example ipytonrc file, the
2626 separately. As documented in the example ipytonrc file, the
2615 readline_omit__names variable can now be set to 2, to omit even
2627 readline_omit__names variable can now be set to 2, to omit even
2616 single underscore names. Thanks to a patch by Brian Wong
2628 single underscore names. Thanks to a patch by Brian Wong
2617 <BrianWong-AT-AirgoNetworks.Com>.
2629 <BrianWong-AT-AirgoNetworks.Com>.
2618 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
2630 (InteractiveShell.__init__): Fix bug which would cause foo[1] to
2619 be autocalled as foo([1]) if foo were callable. A problem for
2631 be autocalled as foo([1]) if foo were callable. A problem for
2620 things which are both callable and implement __getitem__.
2632 things which are both callable and implement __getitem__.
2621 (init_readline): Fix autoindentation for win32. Thanks to a patch
2633 (init_readline): Fix autoindentation for win32. Thanks to a patch
2622 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
2634 by Vivian De Smedt <vivian-AT-vdesmedt.com>.
2623
2635
2624 2005-02-12 Fernando Perez <fperez@colorado.edu>
2636 2005-02-12 Fernando Perez <fperez@colorado.edu>
2625
2637
2626 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
2638 * IPython/ipmaker.py (make_IPython): Disabled the stout traps
2627 which I had written long ago to sort out user error messages which
2639 which I had written long ago to sort out user error messages which
2628 may occur during startup. This seemed like a good idea initially,
2640 may occur during startup. This seemed like a good idea initially,
2629 but it has proven a disaster in retrospect. I don't want to
2641 but it has proven a disaster in retrospect. I don't want to
2630 change much code for now, so my fix is to set the internal 'debug'
2642 change much code for now, so my fix is to set the internal 'debug'
2631 flag to true everywhere, whose only job was precisely to control
2643 flag to true everywhere, whose only job was precisely to control
2632 this subsystem. This closes issue 28 (as well as avoiding all
2644 this subsystem. This closes issue 28 (as well as avoiding all
2633 sorts of strange hangups which occur from time to time).
2645 sorts of strange hangups which occur from time to time).
2634
2646
2635 2005-02-07 Fernando Perez <fperez@colorado.edu>
2647 2005-02-07 Fernando Perez <fperez@colorado.edu>
2636
2648
2637 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
2649 * IPython/Magic.py (magic_edit): Fix 'ed -p' not working when the
2638 previous call produced a syntax error.
2650 previous call produced a syntax error.
2639
2651
2640 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2652 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2641 classes without constructor.
2653 classes without constructor.
2642
2654
2643 2005-02-06 Fernando Perez <fperez@colorado.edu>
2655 2005-02-06 Fernando Perez <fperez@colorado.edu>
2644
2656
2645 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
2657 * IPython/iplib.py (MagicCompleter.complete): Extend the list of
2646 completions with the results of each matcher, so we return results
2658 completions with the results of each matcher, so we return results
2647 to the user from all namespaces. This breaks with ipython
2659 to the user from all namespaces. This breaks with ipython
2648 tradition, but I think it's a nicer behavior. Now you get all
2660 tradition, but I think it's a nicer behavior. Now you get all
2649 possible completions listed, from all possible namespaces (python,
2661 possible completions listed, from all possible namespaces (python,
2650 filesystem, magics...) After a request by John Hunter
2662 filesystem, magics...) After a request by John Hunter
2651 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2663 <jdhunter-AT-nitace.bsd.uchicago.edu>.
2652
2664
2653 2005-02-05 Fernando Perez <fperez@colorado.edu>
2665 2005-02-05 Fernando Perez <fperez@colorado.edu>
2654
2666
2655 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
2667 * IPython/Magic.py (magic_prun): Fix bug where prun would fail if
2656 the call had quote characters in it (the quotes were stripped).
2668 the call had quote characters in it (the quotes were stripped).
2657
2669
2658 2005-01-31 Fernando Perez <fperez@colorado.edu>
2670 2005-01-31 Fernando Perez <fperez@colorado.edu>
2659
2671
2660 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
2672 * IPython/iplib.py (InteractiveShell.__init__): reduce reliance on
2661 Itpl.itpl() to make the code more robust against psyco
2673 Itpl.itpl() to make the code more robust against psyco
2662 optimizations.
2674 optimizations.
2663
2675
2664 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
2676 * IPython/Itpl.py (Itpl.__str__): Use a _getframe() call instead
2665 of causing an exception. Quicker, cleaner.
2677 of causing an exception. Quicker, cleaner.
2666
2678
2667 2005-01-28 Fernando Perez <fperez@colorado.edu>
2679 2005-01-28 Fernando Perez <fperez@colorado.edu>
2668
2680
2669 * scripts/ipython_win_post_install.py (install): hardcode
2681 * scripts/ipython_win_post_install.py (install): hardcode
2670 sys.prefix+'python.exe' as the executable path. It turns out that
2682 sys.prefix+'python.exe' as the executable path. It turns out that
2671 during the post-installation run, sys.executable resolves to the
2683 during the post-installation run, sys.executable resolves to the
2672 name of the binary installer! I should report this as a distutils
2684 name of the binary installer! I should report this as a distutils
2673 bug, I think. I updated the .10 release with this tiny fix, to
2685 bug, I think. I updated the .10 release with this tiny fix, to
2674 avoid annoying the lists further.
2686 avoid annoying the lists further.
2675
2687
2676 2005-01-27 *** Released version 0.6.10
2688 2005-01-27 *** Released version 0.6.10
2677
2689
2678 2005-01-27 Fernando Perez <fperez@colorado.edu>
2690 2005-01-27 Fernando Perez <fperez@colorado.edu>
2679
2691
2680 * IPython/numutils.py (norm): Added 'inf' as optional name for
2692 * IPython/numutils.py (norm): Added 'inf' as optional name for
2681 L-infinity norm, included references to mathworld.com for vector
2693 L-infinity norm, included references to mathworld.com for vector
2682 norm definitions.
2694 norm definitions.
2683 (amin/amax): added amin/amax for array min/max. Similar to what
2695 (amin/amax): added amin/amax for array min/max. Similar to what
2684 pylab ships with after the recent reorganization of names.
2696 pylab ships with after the recent reorganization of names.
2685 (spike/spike_odd): removed deprecated spike/spike_odd functions.
2697 (spike/spike_odd): removed deprecated spike/spike_odd functions.
2686
2698
2687 * ipython.el: committed Alex's recent fixes and improvements.
2699 * ipython.el: committed Alex's recent fixes and improvements.
2688 Tested with python-mode from CVS, and it looks excellent. Since
2700 Tested with python-mode from CVS, and it looks excellent. Since
2689 python-mode hasn't released anything in a while, I'm temporarily
2701 python-mode hasn't released anything in a while, I'm temporarily
2690 putting a copy of today's CVS (v 4.70) of python-mode in:
2702 putting a copy of today's CVS (v 4.70) of python-mode in:
2691 http://ipython.scipy.org/tmp/python-mode.el
2703 http://ipython.scipy.org/tmp/python-mode.el
2692
2704
2693 * scripts/ipython_win_post_install.py (install): Win32 fix to use
2705 * scripts/ipython_win_post_install.py (install): Win32 fix to use
2694 sys.executable for the executable name, instead of assuming it's
2706 sys.executable for the executable name, instead of assuming it's
2695 called 'python.exe' (the post-installer would have produced broken
2707 called 'python.exe' (the post-installer would have produced broken
2696 setups on systems with a differently named python binary).
2708 setups on systems with a differently named python binary).
2697
2709
2698 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
2710 * IPython/PyColorize.py (Parser.__call__): change explicit '\n'
2699 references to os.linesep, to make the code more
2711 references to os.linesep, to make the code more
2700 platform-independent. This is also part of the win32 coloring
2712 platform-independent. This is also part of the win32 coloring
2701 fixes.
2713 fixes.
2702
2714
2703 * IPython/genutils.py (page_dumb): Remove attempts to chop long
2715 * IPython/genutils.py (page_dumb): Remove attempts to chop long
2704 lines, which actually cause coloring bugs because the length of
2716 lines, which actually cause coloring bugs because the length of
2705 the line is very difficult to correctly compute with embedded
2717 the line is very difficult to correctly compute with embedded
2706 escapes. This was the source of all the coloring problems under
2718 escapes. This was the source of all the coloring problems under
2707 Win32. I think that _finally_, Win32 users have a properly
2719 Win32. I think that _finally_, Win32 users have a properly
2708 working ipython in all respects. This would never have happened
2720 working ipython in all respects. This would never have happened
2709 if not for Gary Bishop and Viktor Ransmayr's great help and work.
2721 if not for Gary Bishop and Viktor Ransmayr's great help and work.
2710
2722
2711 2005-01-26 *** Released version 0.6.9
2723 2005-01-26 *** Released version 0.6.9
2712
2724
2713 2005-01-25 Fernando Perez <fperez@colorado.edu>
2725 2005-01-25 Fernando Perez <fperez@colorado.edu>
2714
2726
2715 * setup.py: finally, we have a true Windows installer, thanks to
2727 * setup.py: finally, we have a true Windows installer, thanks to
2716 the excellent work of Viktor Ransmayr
2728 the excellent work of Viktor Ransmayr
2717 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
2729 <viktor.ransmayr-AT-t-online.de>. The docs have been updated for
2718 Windows users. The setup routine is quite a bit cleaner thanks to
2730 Windows users. The setup routine is quite a bit cleaner thanks to
2719 this, and the post-install script uses the proper functions to
2731 this, and the post-install script uses the proper functions to
2720 allow a clean de-installation using the standard Windows Control
2732 allow a clean de-installation using the standard Windows Control
2721 Panel.
2733 Panel.
2722
2734
2723 * IPython/genutils.py (get_home_dir): changed to use the $HOME
2735 * IPython/genutils.py (get_home_dir): changed to use the $HOME
2724 environment variable under all OSes (including win32) if
2736 environment variable under all OSes (including win32) if
2725 available. This will give consistency to win32 users who have set
2737 available. This will give consistency to win32 users who have set
2726 this variable for any reason. If os.environ['HOME'] fails, the
2738 this variable for any reason. If os.environ['HOME'] fails, the
2727 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
2739 previous policy of using HOMEDRIVE\HOMEPATH kicks in.
2728
2740
2729 2005-01-24 Fernando Perez <fperez@colorado.edu>
2741 2005-01-24 Fernando Perez <fperez@colorado.edu>
2730
2742
2731 * IPython/numutils.py (empty_like): add empty_like(), similar to
2743 * IPython/numutils.py (empty_like): add empty_like(), similar to
2732 zeros_like() but taking advantage of the new empty() Numeric routine.
2744 zeros_like() but taking advantage of the new empty() Numeric routine.
2733
2745
2734 2005-01-23 *** Released version 0.6.8
2746 2005-01-23 *** Released version 0.6.8
2735
2747
2736 2005-01-22 Fernando Perez <fperez@colorado.edu>
2748 2005-01-22 Fernando Perez <fperez@colorado.edu>
2737
2749
2738 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
2750 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): I removed the
2739 automatic show() calls. After discussing things with JDH, it
2751 automatic show() calls. After discussing things with JDH, it
2740 turns out there are too many corner cases where this can go wrong.
2752 turns out there are too many corner cases where this can go wrong.
2741 It's best not to try to be 'too smart', and simply have ipython
2753 It's best not to try to be 'too smart', and simply have ipython
2742 reproduce as much as possible the default behavior of a normal
2754 reproduce as much as possible the default behavior of a normal
2743 python shell.
2755 python shell.
2744
2756
2745 * IPython/iplib.py (InteractiveShell.__init__): Modified the
2757 * IPython/iplib.py (InteractiveShell.__init__): Modified the
2746 line-splitting regexp and _prefilter() to avoid calling getattr()
2758 line-splitting regexp and _prefilter() to avoid calling getattr()
2747 on assignments. This closes
2759 on assignments. This closes
2748 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
2760 http://www.scipy.net/roundup/ipython/issue24. Note that Python's
2749 readline uses getattr(), so a simple <TAB> keypress is still
2761 readline uses getattr(), so a simple <TAB> keypress is still
2750 enough to trigger getattr() calls on an object.
2762 enough to trigger getattr() calls on an object.
2751
2763
2752 2005-01-21 Fernando Perez <fperez@colorado.edu>
2764 2005-01-21 Fernando Perez <fperez@colorado.edu>
2753
2765
2754 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
2766 * IPython/Shell.py (MatplotlibShellBase.magic_run): Fix the %run
2755 docstring under pylab so it doesn't mask the original.
2767 docstring under pylab so it doesn't mask the original.
2756
2768
2757 2005-01-21 *** Released version 0.6.7
2769 2005-01-21 *** Released version 0.6.7
2758
2770
2759 2005-01-21 Fernando Perez <fperez@colorado.edu>
2771 2005-01-21 Fernando Perez <fperez@colorado.edu>
2760
2772
2761 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
2773 * IPython/Shell.py (MTInteractiveShell.runcode): Trap a crash with
2762 signal handling for win32 users in multithreaded mode.
2774 signal handling for win32 users in multithreaded mode.
2763
2775
2764 2005-01-17 Fernando Perez <fperez@colorado.edu>
2776 2005-01-17 Fernando Perez <fperez@colorado.edu>
2765
2777
2766 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2778 * IPython/OInspect.py (Inspector.pinfo): Fix crash when inspecting
2767 instances with no __init__. After a crash report by Norbert Nemec
2779 instances with no __init__. After a crash report by Norbert Nemec
2768 <Norbert-AT-nemec-online.de>.
2780 <Norbert-AT-nemec-online.de>.
2769
2781
2770 2005-01-14 Fernando Perez <fperez@colorado.edu>
2782 2005-01-14 Fernando Perez <fperez@colorado.edu>
2771
2783
2772 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
2784 * IPython/ultraTB.py (VerboseTB.text): Fix bug in reporting of
2773 names for verbose exceptions, when multiple dotted names and the
2785 names for verbose exceptions, when multiple dotted names and the
2774 'parent' object were present on the same line.
2786 'parent' object were present on the same line.
2775
2787
2776 2005-01-11 Fernando Perez <fperez@colorado.edu>
2788 2005-01-11 Fernando Perez <fperez@colorado.edu>
2777
2789
2778 * IPython/genutils.py (flag_calls): new utility to trap and flag
2790 * IPython/genutils.py (flag_calls): new utility to trap and flag
2779 calls in functions. I need it to clean up matplotlib support.
2791 calls in functions. I need it to clean up matplotlib support.
2780 Also removed some deprecated code in genutils.
2792 Also removed some deprecated code in genutils.
2781
2793
2782 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
2794 * IPython/Shell.py (MatplotlibShellBase.mplot_exec): small fix so
2783 that matplotlib scripts called with %run, which don't call show()
2795 that matplotlib scripts called with %run, which don't call show()
2784 themselves, still have their plotting windows open.
2796 themselves, still have their plotting windows open.
2785
2797
2786 2005-01-05 Fernando Perez <fperez@colorado.edu>
2798 2005-01-05 Fernando Perez <fperez@colorado.edu>
2787
2799
2788 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
2800 * IPython/Shell.py (IPShellGTK.__init__): Patch by Andrew Straw
2789 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
2801 <astraw-AT-caltech.edu>, to fix gtk deprecation warnings.
2790
2802
2791 2004-12-19 Fernando Perez <fperez@colorado.edu>
2803 2004-12-19 Fernando Perez <fperez@colorado.edu>
2792
2804
2793 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
2805 * IPython/Shell.py (MTInteractiveShell.runcode): Get rid of
2794 parent_runcode, which was an eyesore. The same result can be
2806 parent_runcode, which was an eyesore. The same result can be
2795 obtained with Python's regular superclass mechanisms.
2807 obtained with Python's regular superclass mechanisms.
2796
2808
2797 2004-12-17 Fernando Perez <fperez@colorado.edu>
2809 2004-12-17 Fernando Perez <fperez@colorado.edu>
2798
2810
2799 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
2811 * IPython/Magic.py (Magic.magic_sc): Fix quote stripping problem
2800 reported by Prabhu.
2812 reported by Prabhu.
2801 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
2813 (Magic.magic_sx): direct all errors to Term.cerr (defaults to
2802 sys.stderr) instead of explicitly calling sys.stderr. This helps
2814 sys.stderr) instead of explicitly calling sys.stderr. This helps
2803 maintain our I/O abstractions clean, for future GUI embeddings.
2815 maintain our I/O abstractions clean, for future GUI embeddings.
2804
2816
2805 * IPython/genutils.py (info): added new utility for sys.stderr
2817 * IPython/genutils.py (info): added new utility for sys.stderr
2806 unified info message handling (thin wrapper around warn()).
2818 unified info message handling (thin wrapper around warn()).
2807
2819
2808 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
2820 * IPython/ultraTB.py (VerboseTB.text): Fix misreported global
2809 composite (dotted) names on verbose exceptions.
2821 composite (dotted) names on verbose exceptions.
2810 (VerboseTB.nullrepr): harden against another kind of errors which
2822 (VerboseTB.nullrepr): harden against another kind of errors which
2811 Python's inspect module can trigger, and which were crashing
2823 Python's inspect module can trigger, and which were crashing
2812 IPython. Thanks to a report by Marco Lombardi
2824 IPython. Thanks to a report by Marco Lombardi
2813 <mlombard-AT-ma010192.hq.eso.org>.
2825 <mlombard-AT-ma010192.hq.eso.org>.
2814
2826
2815 2004-12-13 *** Released version 0.6.6
2827 2004-12-13 *** Released version 0.6.6
2816
2828
2817 2004-12-12 Fernando Perez <fperez@colorado.edu>
2829 2004-12-12 Fernando Perez <fperez@colorado.edu>
2818
2830
2819 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
2831 * IPython/Shell.py (IPShellGTK.mainloop): catch RuntimeErrors
2820 generated by pygtk upon initialization if it was built without
2832 generated by pygtk upon initialization if it was built without
2821 threads (for matplotlib users). After a crash reported by
2833 threads (for matplotlib users). After a crash reported by
2822 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
2834 Leguijt, Jaap J SIEP-EPT-RES <Jaap.Leguijt-AT-shell.com>.
2823
2835
2824 * IPython/ipmaker.py (make_IPython): fix small bug in the
2836 * IPython/ipmaker.py (make_IPython): fix small bug in the
2825 import_some parameter for multiple imports.
2837 import_some parameter for multiple imports.
2826
2838
2827 * IPython/iplib.py (ipmagic): simplified the interface of
2839 * IPython/iplib.py (ipmagic): simplified the interface of
2828 ipmagic() to take a single string argument, just as it would be
2840 ipmagic() to take a single string argument, just as it would be
2829 typed at the IPython cmd line.
2841 typed at the IPython cmd line.
2830 (ipalias): Added new ipalias() with an interface identical to
2842 (ipalias): Added new ipalias() with an interface identical to
2831 ipmagic(). This completes exposing a pure python interface to the
2843 ipmagic(). This completes exposing a pure python interface to the
2832 alias and magic system, which can be used in loops or more complex
2844 alias and magic system, which can be used in loops or more complex
2833 code where IPython's automatic line mangling is not active.
2845 code where IPython's automatic line mangling is not active.
2834
2846
2835 * IPython/genutils.py (timing): changed interface of timing to
2847 * IPython/genutils.py (timing): changed interface of timing to
2836 simply run code once, which is the most common case. timings()
2848 simply run code once, which is the most common case. timings()
2837 remains unchanged, for the cases where you want multiple runs.
2849 remains unchanged, for the cases where you want multiple runs.
2838
2850
2839 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
2851 * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): Fix a
2840 bug where Python2.2 crashes with exec'ing code which does not end
2852 bug where Python2.2 crashes with exec'ing code which does not end
2841 in a single newline. Python 2.3 is OK, so I hadn't noticed this
2853 in a single newline. Python 2.3 is OK, so I hadn't noticed this
2842 before.
2854 before.
2843
2855
2844 2004-12-10 Fernando Perez <fperez@colorado.edu>
2856 2004-12-10 Fernando Perez <fperez@colorado.edu>
2845
2857
2846 * IPython/Magic.py (Magic.magic_prun): changed name of option from
2858 * IPython/Magic.py (Magic.magic_prun): changed name of option from
2847 -t to -T, to accomodate the new -t flag in %run (the %run and
2859 -t to -T, to accomodate the new -t flag in %run (the %run and
2848 %prun options are kind of intermixed, and it's not easy to change
2860 %prun options are kind of intermixed, and it's not easy to change
2849 this with the limitations of python's getopt).
2861 this with the limitations of python's getopt).
2850
2862
2851 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
2863 * IPython/Magic.py (Magic.magic_run): Added new -t option to time
2852 the execution of scripts. It's not as fine-tuned as timeit.py,
2864 the execution of scripts. It's not as fine-tuned as timeit.py,
2853 but it works from inside ipython (and under 2.2, which lacks
2865 but it works from inside ipython (and under 2.2, which lacks
2854 timeit.py). Optionally a number of runs > 1 can be given for
2866 timeit.py). Optionally a number of runs > 1 can be given for
2855 timing very short-running code.
2867 timing very short-running code.
2856
2868
2857 * IPython/genutils.py (uniq_stable): new routine which returns a
2869 * IPython/genutils.py (uniq_stable): new routine which returns a
2858 list of unique elements in any iterable, but in stable order of
2870 list of unique elements in any iterable, but in stable order of
2859 appearance. I needed this for the ultraTB fixes, and it's a handy
2871 appearance. I needed this for the ultraTB fixes, and it's a handy
2860 utility.
2872 utility.
2861
2873
2862 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
2874 * IPython/ultraTB.py (VerboseTB.text): Fix proper reporting of
2863 dotted names in Verbose exceptions. This had been broken since
2875 dotted names in Verbose exceptions. This had been broken since
2864 the very start, now x.y will properly be printed in a Verbose
2876 the very start, now x.y will properly be printed in a Verbose
2865 traceback, instead of x being shown and y appearing always as an
2877 traceback, instead of x being shown and y appearing always as an
2866 'undefined global'. Getting this to work was a bit tricky,
2878 'undefined global'. Getting this to work was a bit tricky,
2867 because by default python tokenizers are stateless. Saved by
2879 because by default python tokenizers are stateless. Saved by
2868 python's ability to easily add a bit of state to an arbitrary
2880 python's ability to easily add a bit of state to an arbitrary
2869 function (without needing to build a full-blown callable object).
2881 function (without needing to build a full-blown callable object).
2870
2882
2871 Also big cleanup of this code, which had horrendous runtime
2883 Also big cleanup of this code, which had horrendous runtime
2872 lookups of zillions of attributes for colorization. Moved all
2884 lookups of zillions of attributes for colorization. Moved all
2873 this code into a few templates, which make it cleaner and quicker.
2885 this code into a few templates, which make it cleaner and quicker.
2874
2886
2875 Printout quality was also improved for Verbose exceptions: one
2887 Printout quality was also improved for Verbose exceptions: one
2876 variable per line, and memory addresses are printed (this can be
2888 variable per line, and memory addresses are printed (this can be
2877 quite handy in nasty debugging situations, which is what Verbose
2889 quite handy in nasty debugging situations, which is what Verbose
2878 is for).
2890 is for).
2879
2891
2880 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
2892 * IPython/ipmaker.py (make_IPython): Do NOT execute files named in
2881 the command line as scripts to be loaded by embedded instances.
2893 the command line as scripts to be loaded by embedded instances.
2882 Doing so has the potential for an infinite recursion if there are
2894 Doing so has the potential for an infinite recursion if there are
2883 exceptions thrown in the process. This fixes a strange crash
2895 exceptions thrown in the process. This fixes a strange crash
2884 reported by Philippe MULLER <muller-AT-irit.fr>.
2896 reported by Philippe MULLER <muller-AT-irit.fr>.
2885
2897
2886 2004-12-09 Fernando Perez <fperez@colorado.edu>
2898 2004-12-09 Fernando Perez <fperez@colorado.edu>
2887
2899
2888 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
2900 * IPython/Shell.py (MatplotlibShellBase.use): Change pylab support
2889 to reflect new names in matplotlib, which now expose the
2901 to reflect new names in matplotlib, which now expose the
2890 matlab-compatible interface via a pylab module instead of the
2902 matlab-compatible interface via a pylab module instead of the
2891 'matlab' name. The new code is backwards compatible, so users of
2903 'matlab' name. The new code is backwards compatible, so users of
2892 all matplotlib versions are OK. Patch by J. Hunter.
2904 all matplotlib versions are OK. Patch by J. Hunter.
2893
2905
2894 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
2906 * IPython/OInspect.py (Inspector.pinfo): Add to object? printing
2895 of __init__ docstrings for instances (class docstrings are already
2907 of __init__ docstrings for instances (class docstrings are already
2896 automatically printed). Instances with customized docstrings
2908 automatically printed). Instances with customized docstrings
2897 (indep. of the class) are also recognized and all 3 separate
2909 (indep. of the class) are also recognized and all 3 separate
2898 docstrings are printed (instance, class, constructor). After some
2910 docstrings are printed (instance, class, constructor). After some
2899 comments/suggestions by J. Hunter.
2911 comments/suggestions by J. Hunter.
2900
2912
2901 2004-12-05 Fernando Perez <fperez@colorado.edu>
2913 2004-12-05 Fernando Perez <fperez@colorado.edu>
2902
2914
2903 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
2915 * IPython/iplib.py (MagicCompleter.complete): Remove annoying
2904 warnings when tab-completion fails and triggers an exception.
2916 warnings when tab-completion fails and triggers an exception.
2905
2917
2906 2004-12-03 Fernando Perez <fperez@colorado.edu>
2918 2004-12-03 Fernando Perez <fperez@colorado.edu>
2907
2919
2908 * IPython/Magic.py (magic_prun): Fix bug where an exception would
2920 * IPython/Magic.py (magic_prun): Fix bug where an exception would
2909 be triggered when using 'run -p'. An incorrect option flag was
2921 be triggered when using 'run -p'. An incorrect option flag was
2910 being set ('d' instead of 'D').
2922 being set ('d' instead of 'D').
2911 (manpage): fix missing escaped \- sign.
2923 (manpage): fix missing escaped \- sign.
2912
2924
2913 2004-11-30 *** Released version 0.6.5
2925 2004-11-30 *** Released version 0.6.5
2914
2926
2915 2004-11-30 Fernando Perez <fperez@colorado.edu>
2927 2004-11-30 Fernando Perez <fperez@colorado.edu>
2916
2928
2917 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
2929 * IPython/Magic.py (Magic.magic_run): Fix bug in breakpoint
2918 setting with -d option.
2930 setting with -d option.
2919
2931
2920 * setup.py (docfiles): Fix problem where the doc glob I was using
2932 * setup.py (docfiles): Fix problem where the doc glob I was using
2921 was COMPLETELY BROKEN. It was giving the right files by pure
2933 was COMPLETELY BROKEN. It was giving the right files by pure
2922 accident, but failed once I tried to include ipython.el. Note:
2934 accident, but failed once I tried to include ipython.el. Note:
2923 glob() does NOT allow you to do exclusion on multiple endings!
2935 glob() does NOT allow you to do exclusion on multiple endings!
2924
2936
2925 2004-11-29 Fernando Perez <fperez@colorado.edu>
2937 2004-11-29 Fernando Perez <fperez@colorado.edu>
2926
2938
2927 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
2939 * IPython/usage.py (__doc__): cleaned up usage docstring, by using
2928 the manpage as the source. Better formatting & consistency.
2940 the manpage as the source. Better formatting & consistency.
2929
2941
2930 * IPython/Magic.py (magic_run): Added new -d option, to run
2942 * IPython/Magic.py (magic_run): Added new -d option, to run
2931 scripts under the control of the python pdb debugger. Note that
2943 scripts under the control of the python pdb debugger. Note that
2932 this required changing the %prun option -d to -D, to avoid a clash
2944 this required changing the %prun option -d to -D, to avoid a clash
2933 (since %run must pass options to %prun, and getopt is too dumb to
2945 (since %run must pass options to %prun, and getopt is too dumb to
2934 handle options with string values with embedded spaces). Thanks
2946 handle options with string values with embedded spaces). Thanks
2935 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
2947 to a suggestion by Matthew Arnison <maffew-AT-cat.org.au>.
2936 (magic_who_ls): added type matching to %who and %whos, so that one
2948 (magic_who_ls): added type matching to %who and %whos, so that one
2937 can filter their output to only include variables of certain
2949 can filter their output to only include variables of certain
2938 types. Another suggestion by Matthew.
2950 types. Another suggestion by Matthew.
2939 (magic_whos): Added memory summaries in kb and Mb for arrays.
2951 (magic_whos): Added memory summaries in kb and Mb for arrays.
2940 (magic_who): Improve formatting (break lines every 9 vars).
2952 (magic_who): Improve formatting (break lines every 9 vars).
2941
2953
2942 2004-11-28 Fernando Perez <fperez@colorado.edu>
2954 2004-11-28 Fernando Perez <fperez@colorado.edu>
2943
2955
2944 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
2956 * IPython/Logger.py (Logger.log): Fix bug in syncing the input
2945 cache when empty lines were present.
2957 cache when empty lines were present.
2946
2958
2947 2004-11-24 Fernando Perez <fperez@colorado.edu>
2959 2004-11-24 Fernando Perez <fperez@colorado.edu>
2948
2960
2949 * IPython/usage.py (__doc__): document the re-activated threading
2961 * IPython/usage.py (__doc__): document the re-activated threading
2950 options for WX and GTK.
2962 options for WX and GTK.
2951
2963
2952 2004-11-23 Fernando Perez <fperez@colorado.edu>
2964 2004-11-23 Fernando Perez <fperez@colorado.edu>
2953
2965
2954 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
2966 * IPython/Shell.py (start): Added Prabhu's big patch to reactivate
2955 the -wthread and -gthread options, along with a new -tk one to try
2967 the -wthread and -gthread options, along with a new -tk one to try
2956 and coordinate Tk threading with wx/gtk. The tk support is very
2968 and coordinate Tk threading with wx/gtk. The tk support is very
2957 platform dependent, since it seems to require Tcl and Tk to be
2969 platform dependent, since it seems to require Tcl and Tk to be
2958 built with threads (Fedora1/2 appears NOT to have it, but in
2970 built with threads (Fedora1/2 appears NOT to have it, but in
2959 Prabhu's Debian boxes it works OK). But even with some Tk
2971 Prabhu's Debian boxes it works OK). But even with some Tk
2960 limitations, this is a great improvement.
2972 limitations, this is a great improvement.
2961
2973
2962 * IPython/Prompts.py (prompt_specials_color): Added \t for time
2974 * IPython/Prompts.py (prompt_specials_color): Added \t for time
2963 info in user prompts. Patch by Prabhu.
2975 info in user prompts. Patch by Prabhu.
2964
2976
2965 2004-11-18 Fernando Perez <fperez@colorado.edu>
2977 2004-11-18 Fernando Perez <fperez@colorado.edu>
2966
2978
2967 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
2979 * IPython/genutils.py (ask_yes_no): Add check for a max of 20
2968 EOFErrors and bail, to avoid infinite loops if a non-terminating
2980 EOFErrors and bail, to avoid infinite loops if a non-terminating
2969 file is fed into ipython. Patch submitted in issue 19 by user,
2981 file is fed into ipython. Patch submitted in issue 19 by user,
2970 many thanks.
2982 many thanks.
2971
2983
2972 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
2984 * IPython/iplib.py (InteractiveShell.handle_auto): do NOT trigger
2973 autoquote/parens in continuation prompts, which can cause lots of
2985 autoquote/parens in continuation prompts, which can cause lots of
2974 problems. Closes roundup issue 20.
2986 problems. Closes roundup issue 20.
2975
2987
2976 2004-11-17 Fernando Perez <fperez@colorado.edu>
2988 2004-11-17 Fernando Perez <fperez@colorado.edu>
2977
2989
2978 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
2990 * debian/control (Build-Depends-Indep): Fix dpatch dependency,
2979 reported as debian bug #280505. I'm not sure my local changelog
2991 reported as debian bug #280505. I'm not sure my local changelog
2980 entry has the proper debian format (Jack?).
2992 entry has the proper debian format (Jack?).
2981
2993
2982 2004-11-08 *** Released version 0.6.4
2994 2004-11-08 *** Released version 0.6.4
2983
2995
2984 2004-11-08 Fernando Perez <fperez@colorado.edu>
2996 2004-11-08 Fernando Perez <fperez@colorado.edu>
2985
2997
2986 * IPython/iplib.py (init_readline): Fix exit message for Windows
2998 * IPython/iplib.py (init_readline): Fix exit message for Windows
2987 when readline is active. Thanks to a report by Eric Jones
2999 when readline is active. Thanks to a report by Eric Jones
2988 <eric-AT-enthought.com>.
3000 <eric-AT-enthought.com>.
2989
3001
2990 2004-11-07 Fernando Perez <fperez@colorado.edu>
3002 2004-11-07 Fernando Perez <fperez@colorado.edu>
2991
3003
2992 * IPython/genutils.py (page): Add a trap for OSError exceptions,
3004 * IPython/genutils.py (page): Add a trap for OSError exceptions,
2993 sometimes seen by win2k/cygwin users.
3005 sometimes seen by win2k/cygwin users.
2994
3006
2995 2004-11-06 Fernando Perez <fperez@colorado.edu>
3007 2004-11-06 Fernando Perez <fperez@colorado.edu>
2996
3008
2997 * IPython/iplib.py (interact): Change the handling of %Exit from
3009 * IPython/iplib.py (interact): Change the handling of %Exit from
2998 trying to propagate a SystemExit to an internal ipython flag.
3010 trying to propagate a SystemExit to an internal ipython flag.
2999 This is less elegant than using Python's exception mechanism, but
3011 This is less elegant than using Python's exception mechanism, but
3000 I can't get that to work reliably with threads, so under -pylab
3012 I can't get that to work reliably with threads, so under -pylab
3001 %Exit was hanging IPython. Cross-thread exception handling is
3013 %Exit was hanging IPython. Cross-thread exception handling is
3002 really a bitch. Thaks to a bug report by Stephen Walton
3014 really a bitch. Thaks to a bug report by Stephen Walton
3003 <stephen.walton-AT-csun.edu>.
3015 <stephen.walton-AT-csun.edu>.
3004
3016
3005 2004-11-04 Fernando Perez <fperez@colorado.edu>
3017 2004-11-04 Fernando Perez <fperez@colorado.edu>
3006
3018
3007 * IPython/iplib.py (raw_input_original): store a pointer to the
3019 * IPython/iplib.py (raw_input_original): store a pointer to the
3008 true raw_input to harden against code which can modify it
3020 true raw_input to harden against code which can modify it
3009 (wx.py.PyShell does this and would otherwise crash ipython).
3021 (wx.py.PyShell does this and would otherwise crash ipython).
3010 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
3022 Thanks to a bug report by Jim Flowers <james.flowers-AT-lgx.com>.
3011
3023
3012 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
3024 * IPython/Shell.py (MTInteractiveShell.runsource): Cleaner fix for
3013 Ctrl-C problem, which does not mess up the input line.
3025 Ctrl-C problem, which does not mess up the input line.
3014
3026
3015 2004-11-03 Fernando Perez <fperez@colorado.edu>
3027 2004-11-03 Fernando Perez <fperez@colorado.edu>
3016
3028
3017 * IPython/Release.py: Changed licensing to BSD, in all files.
3029 * IPython/Release.py: Changed licensing to BSD, in all files.
3018 (name): lowercase name for tarball/RPM release.
3030 (name): lowercase name for tarball/RPM release.
3019
3031
3020 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
3032 * IPython/OInspect.py (getdoc): wrap inspect.getdoc() safely for
3021 use throughout ipython.
3033 use throughout ipython.
3022
3034
3023 * IPython/Magic.py (Magic._ofind): Switch to using the new
3035 * IPython/Magic.py (Magic._ofind): Switch to using the new
3024 OInspect.getdoc() function.
3036 OInspect.getdoc() function.
3025
3037
3026 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
3038 * IPython/Shell.py (sigint_handler): Hack to ignore the execution
3027 of the line currently being canceled via Ctrl-C. It's extremely
3039 of the line currently being canceled via Ctrl-C. It's extremely
3028 ugly, but I don't know how to do it better (the problem is one of
3040 ugly, but I don't know how to do it better (the problem is one of
3029 handling cross-thread exceptions).
3041 handling cross-thread exceptions).
3030
3042
3031 2004-10-28 Fernando Perez <fperez@colorado.edu>
3043 2004-10-28 Fernando Perez <fperez@colorado.edu>
3032
3044
3033 * IPython/Shell.py (signal_handler): add signal handlers to trap
3045 * IPython/Shell.py (signal_handler): add signal handlers to trap
3034 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
3046 SIGINT and SIGSEGV in threaded code properly. Thanks to a bug
3035 report by Francesc Alted.
3047 report by Francesc Alted.
3036
3048
3037 2004-10-21 Fernando Perez <fperez@colorado.edu>
3049 2004-10-21 Fernando Perez <fperez@colorado.edu>
3038
3050
3039 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
3051 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Fix @
3040 to % for pysh syntax extensions.
3052 to % for pysh syntax extensions.
3041
3053
3042 2004-10-09 Fernando Perez <fperez@colorado.edu>
3054 2004-10-09 Fernando Perez <fperez@colorado.edu>
3043
3055
3044 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
3056 * IPython/Magic.py (Magic.magic_whos): modify output of Numeric
3045 arrays to print a more useful summary, without calling str(arr).
3057 arrays to print a more useful summary, without calling str(arr).
3046 This avoids the problem of extremely lengthy computations which
3058 This avoids the problem of extremely lengthy computations which
3047 occur if arr is large, and appear to the user as a system lockup
3059 occur if arr is large, and appear to the user as a system lockup
3048 with 100% cpu activity. After a suggestion by Kristian Sandberg
3060 with 100% cpu activity. After a suggestion by Kristian Sandberg
3049 <Kristian.Sandberg@colorado.edu>.
3061 <Kristian.Sandberg@colorado.edu>.
3050 (Magic.__init__): fix bug in global magic escapes not being
3062 (Magic.__init__): fix bug in global magic escapes not being
3051 correctly set.
3063 correctly set.
3052
3064
3053 2004-10-08 Fernando Perez <fperez@colorado.edu>
3065 2004-10-08 Fernando Perez <fperez@colorado.edu>
3054
3066
3055 * IPython/Magic.py (__license__): change to absolute imports of
3067 * IPython/Magic.py (__license__): change to absolute imports of
3056 ipython's own internal packages, to start adapting to the absolute
3068 ipython's own internal packages, to start adapting to the absolute
3057 import requirement of PEP-328.
3069 import requirement of PEP-328.
3058
3070
3059 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
3071 * IPython/genutils.py (__author__): Fix coding to utf-8 on all
3060 files, and standardize author/license marks through the Release
3072 files, and standardize author/license marks through the Release
3061 module instead of having per/file stuff (except for files with
3073 module instead of having per/file stuff (except for files with
3062 particular licenses, like the MIT/PSF-licensed codes).
3074 particular licenses, like the MIT/PSF-licensed codes).
3063
3075
3064 * IPython/Debugger.py: remove dead code for python 2.1
3076 * IPython/Debugger.py: remove dead code for python 2.1
3065
3077
3066 2004-10-04 Fernando Perez <fperez@colorado.edu>
3078 2004-10-04 Fernando Perez <fperez@colorado.edu>
3067
3079
3068 * IPython/iplib.py (ipmagic): New function for accessing magics
3080 * IPython/iplib.py (ipmagic): New function for accessing magics
3069 via a normal python function call.
3081 via a normal python function call.
3070
3082
3071 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
3083 * IPython/Magic.py (Magic.magic_magic): Change the magic escape
3072 from '@' to '%', to accomodate the new @decorator syntax of python
3084 from '@' to '%', to accomodate the new @decorator syntax of python
3073 2.4.
3085 2.4.
3074
3086
3075 2004-09-29 Fernando Perez <fperez@colorado.edu>
3087 2004-09-29 Fernando Perez <fperez@colorado.edu>
3076
3088
3077 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
3089 * IPython/Shell.py (MatplotlibShellBase.use): Added a wrapper to
3078 matplotlib.use to prevent running scripts which try to switch
3090 matplotlib.use to prevent running scripts which try to switch
3079 interactive backends from within ipython. This will just crash
3091 interactive backends from within ipython. This will just crash
3080 the python interpreter, so we can't allow it (but a detailed error
3092 the python interpreter, so we can't allow it (but a detailed error
3081 is given to the user).
3093 is given to the user).
3082
3094
3083 2004-09-28 Fernando Perez <fperez@colorado.edu>
3095 2004-09-28 Fernando Perez <fperez@colorado.edu>
3084
3096
3085 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
3097 * IPython/Shell.py (MatplotlibShellBase.mplot_exec):
3086 matplotlib-related fixes so that using @run with non-matplotlib
3098 matplotlib-related fixes so that using @run with non-matplotlib
3087 scripts doesn't pop up spurious plot windows. This requires
3099 scripts doesn't pop up spurious plot windows. This requires
3088 matplotlib >= 0.63, where I had to make some changes as well.
3100 matplotlib >= 0.63, where I had to make some changes as well.
3089
3101
3090 * IPython/ipmaker.py (make_IPython): update version requirement to
3102 * IPython/ipmaker.py (make_IPython): update version requirement to
3091 python 2.2.
3103 python 2.2.
3092
3104
3093 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
3105 * IPython/iplib.py (InteractiveShell.mainloop): Add an optional
3094 banner arg for embedded customization.
3106 banner arg for embedded customization.
3095
3107
3096 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
3108 * IPython/Magic.py (Magic.__init__): big cleanup to remove all
3097 explicit uses of __IP as the IPython's instance name. Now things
3109 explicit uses of __IP as the IPython's instance name. Now things
3098 are properly handled via the shell.name value. The actual code
3110 are properly handled via the shell.name value. The actual code
3099 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
3111 is a bit ugly b/c I'm doing it via a global in Magic.py, but this
3100 is much better than before. I'll clean things completely when the
3112 is much better than before. I'll clean things completely when the
3101 magic stuff gets a real overhaul.
3113 magic stuff gets a real overhaul.
3102
3114
3103 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
3115 * ipython.1: small fixes, sent in by Jack Moffit. He also sent in
3104 minor changes to debian dir.
3116 minor changes to debian dir.
3105
3117
3106 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
3118 * IPython/iplib.py (InteractiveShell.__init__): Fix adding a
3107 pointer to the shell itself in the interactive namespace even when
3119 pointer to the shell itself in the interactive namespace even when
3108 a user-supplied dict is provided. This is needed for embedding
3120 a user-supplied dict is provided. This is needed for embedding
3109 purposes (found by tests with Michel Sanner).
3121 purposes (found by tests with Michel Sanner).
3110
3122
3111 2004-09-27 Fernando Perez <fperez@colorado.edu>
3123 2004-09-27 Fernando Perez <fperez@colorado.edu>
3112
3124
3113 * IPython/UserConfig/ipythonrc: remove []{} from
3125 * IPython/UserConfig/ipythonrc: remove []{} from
3114 readline_remove_delims, so that things like [modname.<TAB> do
3126 readline_remove_delims, so that things like [modname.<TAB> do
3115 proper completion. This disables [].TAB, but that's a less common
3127 proper completion. This disables [].TAB, but that's a less common
3116 case than module names in list comprehensions, for example.
3128 case than module names in list comprehensions, for example.
3117 Thanks to a report by Andrea Riciputi.
3129 Thanks to a report by Andrea Riciputi.
3118
3130
3119 2004-09-09 Fernando Perez <fperez@colorado.edu>
3131 2004-09-09 Fernando Perez <fperez@colorado.edu>
3120
3132
3121 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
3133 * IPython/Shell.py (IPShellGTK.mainloop): reorder to avoid
3122 blocking problems in win32 and osx. Fix by John.
3134 blocking problems in win32 and osx. Fix by John.
3123
3135
3124 2004-09-08 Fernando Perez <fperez@colorado.edu>
3136 2004-09-08 Fernando Perez <fperez@colorado.edu>
3125
3137
3126 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
3138 * IPython/Shell.py (IPShellWX.OnInit): Fix output redirection bug
3127 for Win32 and OSX. Fix by John Hunter.
3139 for Win32 and OSX. Fix by John Hunter.
3128
3140
3129 2004-08-30 *** Released version 0.6.3
3141 2004-08-30 *** Released version 0.6.3
3130
3142
3131 2004-08-30 Fernando Perez <fperez@colorado.edu>
3143 2004-08-30 Fernando Perez <fperez@colorado.edu>
3132
3144
3133 * setup.py (isfile): Add manpages to list of dependent files to be
3145 * setup.py (isfile): Add manpages to list of dependent files to be
3134 updated.
3146 updated.
3135
3147
3136 2004-08-27 Fernando Perez <fperez@colorado.edu>
3148 2004-08-27 Fernando Perez <fperez@colorado.edu>
3137
3149
3138 * IPython/Shell.py (start): I've disabled -wthread and -gthread
3150 * IPython/Shell.py (start): I've disabled -wthread and -gthread
3139 for now. They don't really work with standalone WX/GTK code
3151 for now. They don't really work with standalone WX/GTK code
3140 (though matplotlib IS working fine with both of those backends).
3152 (though matplotlib IS working fine with both of those backends).
3141 This will neeed much more testing. I disabled most things with
3153 This will neeed much more testing. I disabled most things with
3142 comments, so turning it back on later should be pretty easy.
3154 comments, so turning it back on later should be pretty easy.
3143
3155
3144 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
3156 * IPython/iplib.py (InteractiveShell.__init__): Fix accidental
3145 autocalling of expressions like r'foo', by modifying the line
3157 autocalling of expressions like r'foo', by modifying the line
3146 split regexp. Closes
3158 split regexp. Closes
3147 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
3159 http://www.scipy.net/roundup/ipython/issue18, reported by Nicholas
3148 Riley <ipythonbugs-AT-sabi.net>.
3160 Riley <ipythonbugs-AT-sabi.net>.
3149 (InteractiveShell.mainloop): honor --nobanner with banner
3161 (InteractiveShell.mainloop): honor --nobanner with banner
3150 extensions.
3162 extensions.
3151
3163
3152 * IPython/Shell.py: Significant refactoring of all classes, so
3164 * IPython/Shell.py: Significant refactoring of all classes, so
3153 that we can really support ALL matplotlib backends and threading
3165 that we can really support ALL matplotlib backends and threading
3154 models (John spotted a bug with Tk which required this). Now we
3166 models (John spotted a bug with Tk which required this). Now we
3155 should support single-threaded, WX-threads and GTK-threads, both
3167 should support single-threaded, WX-threads and GTK-threads, both
3156 for generic code and for matplotlib.
3168 for generic code and for matplotlib.
3157
3169
3158 * IPython/ipmaker.py (__call__): Changed -mpthread option to
3170 * IPython/ipmaker.py (__call__): Changed -mpthread option to
3159 -pylab, to simplify things for users. Will also remove the pylab
3171 -pylab, to simplify things for users. Will also remove the pylab
3160 profile, since now all of matplotlib configuration is directly
3172 profile, since now all of matplotlib configuration is directly
3161 handled here. This also reduces startup time.
3173 handled here. This also reduces startup time.
3162
3174
3163 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
3175 * IPython/Shell.py (IPShellGTK.run): Fixed bug where mainloop() of
3164 shell wasn't being correctly called. Also in IPShellWX.
3176 shell wasn't being correctly called. Also in IPShellWX.
3165
3177
3166 * IPython/iplib.py (InteractiveShell.__init__): Added option to
3178 * IPython/iplib.py (InteractiveShell.__init__): Added option to
3167 fine-tune banner.
3179 fine-tune banner.
3168
3180
3169 * IPython/numutils.py (spike): Deprecate these spike functions,
3181 * IPython/numutils.py (spike): Deprecate these spike functions,
3170 delete (long deprecated) gnuplot_exec handler.
3182 delete (long deprecated) gnuplot_exec handler.
3171
3183
3172 2004-08-26 Fernando Perez <fperez@colorado.edu>
3184 2004-08-26 Fernando Perez <fperez@colorado.edu>
3173
3185
3174 * ipython.1: Update for threading options, plus some others which
3186 * ipython.1: Update for threading options, plus some others which
3175 were missing.
3187 were missing.
3176
3188
3177 * IPython/ipmaker.py (__call__): Added -wthread option for
3189 * IPython/ipmaker.py (__call__): Added -wthread option for
3178 wxpython thread handling. Make sure threading options are only
3190 wxpython thread handling. Make sure threading options are only
3179 valid at the command line.
3191 valid at the command line.
3180
3192
3181 * scripts/ipython: moved shell selection into a factory function
3193 * scripts/ipython: moved shell selection into a factory function
3182 in Shell.py, to keep the starter script to a minimum.
3194 in Shell.py, to keep the starter script to a minimum.
3183
3195
3184 2004-08-25 Fernando Perez <fperez@colorado.edu>
3196 2004-08-25 Fernando Perez <fperez@colorado.edu>
3185
3197
3186 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
3198 * IPython/Shell.py (IPShellWX.wxexit): fixes to WX threading, by
3187 John. Along with some recent changes he made to matplotlib, the
3199 John. Along with some recent changes he made to matplotlib, the
3188 next versions of both systems should work very well together.
3200 next versions of both systems should work very well together.
3189
3201
3190 2004-08-24 Fernando Perez <fperez@colorado.edu>
3202 2004-08-24 Fernando Perez <fperez@colorado.edu>
3191
3203
3192 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
3204 * IPython/Magic.py (Magic.magic_prun): cleanup some dead code. I
3193 tried to switch the profiling to using hotshot, but I'm getting
3205 tried to switch the profiling to using hotshot, but I'm getting
3194 strange errors from prof.runctx() there. I may be misreading the
3206 strange errors from prof.runctx() there. I may be misreading the
3195 docs, but it looks weird. For now the profiling code will
3207 docs, but it looks weird. For now the profiling code will
3196 continue to use the standard profiler.
3208 continue to use the standard profiler.
3197
3209
3198 2004-08-23 Fernando Perez <fperez@colorado.edu>
3210 2004-08-23 Fernando Perez <fperez@colorado.edu>
3199
3211
3200 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
3212 * IPython/Shell.py (IPShellWX.__init__): Improvements to the WX
3201 threaded shell, by John Hunter. It's not quite ready yet, but
3213 threaded shell, by John Hunter. It's not quite ready yet, but
3202 close.
3214 close.
3203
3215
3204 2004-08-22 Fernando Perez <fperez@colorado.edu>
3216 2004-08-22 Fernando Perez <fperez@colorado.edu>
3205
3217
3206 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
3218 * IPython/iplib.py (InteractiveShell.interact): tab cleanups, also
3207 in Magic and ultraTB.
3219 in Magic and ultraTB.
3208
3220
3209 * ipython.1: document threading options in manpage.
3221 * ipython.1: document threading options in manpage.
3210
3222
3211 * scripts/ipython: Changed name of -thread option to -gthread,
3223 * scripts/ipython: Changed name of -thread option to -gthread,
3212 since this is GTK specific. I want to leave the door open for a
3224 since this is GTK specific. I want to leave the door open for a
3213 -wthread option for WX, which will most likely be necessary. This
3225 -wthread option for WX, which will most likely be necessary. This
3214 change affects usage and ipmaker as well.
3226 change affects usage and ipmaker as well.
3215
3227
3216 * IPython/Shell.py (matplotlib_shell): Add a factory function to
3228 * IPython/Shell.py (matplotlib_shell): Add a factory function to
3217 handle the matplotlib shell issues. Code by John Hunter
3229 handle the matplotlib shell issues. Code by John Hunter
3218 <jdhunter-AT-nitace.bsd.uchicago.edu>.
3230 <jdhunter-AT-nitace.bsd.uchicago.edu>.
3219 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
3231 (IPShellMatplotlibWX.__init__): Rudimentary WX support. It's
3220 broken (and disabled for end users) for now, but it puts the
3232 broken (and disabled for end users) for now, but it puts the
3221 infrastructure in place.
3233 infrastructure in place.
3222
3234
3223 2004-08-21 Fernando Perez <fperez@colorado.edu>
3235 2004-08-21 Fernando Perez <fperez@colorado.edu>
3224
3236
3225 * ipythonrc-pylab: Add matplotlib support.
3237 * ipythonrc-pylab: Add matplotlib support.
3226
3238
3227 * matplotlib_config.py: new files for matplotlib support, part of
3239 * matplotlib_config.py: new files for matplotlib support, part of
3228 the pylab profile.
3240 the pylab profile.
3229
3241
3230 * IPython/usage.py (__doc__): documented the threading options.
3242 * IPython/usage.py (__doc__): documented the threading options.
3231
3243
3232 2004-08-20 Fernando Perez <fperez@colorado.edu>
3244 2004-08-20 Fernando Perez <fperez@colorado.edu>
3233
3245
3234 * ipython: Modified the main calling routine to handle the -thread
3246 * ipython: Modified the main calling routine to handle the -thread
3235 and -mpthread options. This needs to be done as a top-level hack,
3247 and -mpthread options. This needs to be done as a top-level hack,
3236 because it determines which class to instantiate for IPython
3248 because it determines which class to instantiate for IPython
3237 itself.
3249 itself.
3238
3250
3239 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
3251 * IPython/Shell.py (MTInteractiveShell.__init__): New set of
3240 classes to support multithreaded GTK operation without blocking,
3252 classes to support multithreaded GTK operation without blocking,
3241 and matplotlib with all backends. This is a lot of still very
3253 and matplotlib with all backends. This is a lot of still very
3242 experimental code, and threads are tricky. So it may still have a
3254 experimental code, and threads are tricky. So it may still have a
3243 few rough edges... This code owes a lot to
3255 few rough edges... This code owes a lot to
3244 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
3256 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65109, by
3245 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
3257 Brian # McErlean and John Finlay, to Antoon Pardon for fixes, and
3246 to John Hunter for all the matplotlib work.
3258 to John Hunter for all the matplotlib work.
3247
3259
3248 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
3260 * IPython/ipmaker.py (__call__): Added -thread and -mpthread
3249 options for gtk thread and matplotlib support.
3261 options for gtk thread and matplotlib support.
3250
3262
3251 2004-08-16 Fernando Perez <fperez@colorado.edu>
3263 2004-08-16 Fernando Perez <fperez@colorado.edu>
3252
3264
3253 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
3265 * IPython/iplib.py (InteractiveShell.__init__): don't trigger
3254 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
3266 autocall for things like p*q,p/q,p+q,p-q, when p is callable. Bug
3255 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
3267 reported by Stephen Walton <stephen.walton-AT-csun.edu>.
3256
3268
3257 2004-08-11 Fernando Perez <fperez@colorado.edu>
3269 2004-08-11 Fernando Perez <fperez@colorado.edu>
3258
3270
3259 * setup.py (isfile): Fix build so documentation gets updated for
3271 * setup.py (isfile): Fix build so documentation gets updated for
3260 rpms (it was only done for .tgz builds).
3272 rpms (it was only done for .tgz builds).
3261
3273
3262 2004-08-10 Fernando Perez <fperez@colorado.edu>
3274 2004-08-10 Fernando Perez <fperez@colorado.edu>
3263
3275
3264 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
3276 * genutils.py (Term): Fix misspell of stdin stream (sin->cin).
3265
3277
3266 * iplib.py : Silence syntax error exceptions in tab-completion.
3278 * iplib.py : Silence syntax error exceptions in tab-completion.
3267
3279
3268 2004-08-05 Fernando Perez <fperez@colorado.edu>
3280 2004-08-05 Fernando Perez <fperez@colorado.edu>
3269
3281
3270 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
3282 * IPython/Prompts.py (Prompt2.set_colors): Fix incorrectly set
3271 'color off' mark for continuation prompts. This was causing long
3283 'color off' mark for continuation prompts. This was causing long
3272 continuation lines to mis-wrap.
3284 continuation lines to mis-wrap.
3273
3285
3274 2004-08-01 Fernando Perez <fperez@colorado.edu>
3286 2004-08-01 Fernando Perez <fperez@colorado.edu>
3275
3287
3276 * IPython/ipmaker.py (make_IPython): Allow the shell class used
3288 * IPython/ipmaker.py (make_IPython): Allow the shell class used
3277 for building ipython to be a parameter. All this is necessary
3289 for building ipython to be a parameter. All this is necessary
3278 right now to have a multithreaded version, but this insane
3290 right now to have a multithreaded version, but this insane
3279 non-design will be cleaned up soon. For now, it's a hack that
3291 non-design will be cleaned up soon. For now, it's a hack that
3280 works.
3292 works.
3281
3293
3282 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
3294 * IPython/Shell.py (IPShell.__init__): Stop using mutable default
3283 args in various places. No bugs so far, but it's a dangerous
3295 args in various places. No bugs so far, but it's a dangerous
3284 practice.
3296 practice.
3285
3297
3286 2004-07-31 Fernando Perez <fperez@colorado.edu>
3298 2004-07-31 Fernando Perez <fperez@colorado.edu>
3287
3299
3288 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
3300 * IPython/iplib.py (complete): ignore SyntaxError exceptions to
3289 fix completion of files with dots in their names under most
3301 fix completion of files with dots in their names under most
3290 profiles (pysh was OK because the completion order is different).
3302 profiles (pysh was OK because the completion order is different).
3291
3303
3292 2004-07-27 Fernando Perez <fperez@colorado.edu>
3304 2004-07-27 Fernando Perez <fperez@colorado.edu>
3293
3305
3294 * IPython/iplib.py (InteractiveShell.__init__): build dict of
3306 * IPython/iplib.py (InteractiveShell.__init__): build dict of
3295 keywords manually, b/c the one in keyword.py was removed in python
3307 keywords manually, b/c the one in keyword.py was removed in python
3296 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
3308 2.4. Patch by Anakim Border <aborder-AT-users.sourceforge.net>.
3297 This is NOT a bug under python 2.3 and earlier.
3309 This is NOT a bug under python 2.3 and earlier.
3298
3310
3299 2004-07-26 Fernando Perez <fperez@colorado.edu>
3311 2004-07-26 Fernando Perez <fperez@colorado.edu>
3300
3312
3301 * IPython/ultraTB.py (VerboseTB.text): Add another
3313 * IPython/ultraTB.py (VerboseTB.text): Add another
3302 linecache.checkcache() call to try to prevent inspect.py from
3314 linecache.checkcache() call to try to prevent inspect.py from
3303 crashing under python 2.3. I think this fixes
3315 crashing under python 2.3. I think this fixes
3304 http://www.scipy.net/roundup/ipython/issue17.
3316 http://www.scipy.net/roundup/ipython/issue17.
3305
3317
3306 2004-07-26 *** Released version 0.6.2
3318 2004-07-26 *** Released version 0.6.2
3307
3319
3308 2004-07-26 Fernando Perez <fperez@colorado.edu>
3320 2004-07-26 Fernando Perez <fperez@colorado.edu>
3309
3321
3310 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
3322 * IPython/Magic.py (Magic.magic_cd): Fix bug where 'cd -N' would
3311 fail for any number.
3323 fail for any number.
3312 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
3324 (Magic.magic_bookmark): Fix bug where 'bookmark -l' would fail for
3313 empty bookmarks.
3325 empty bookmarks.
3314
3326
3315 2004-07-26 *** Released version 0.6.1
3327 2004-07-26 *** Released version 0.6.1
3316
3328
3317 2004-07-26 Fernando Perez <fperez@colorado.edu>
3329 2004-07-26 Fernando Perez <fperez@colorado.edu>
3318
3330
3319 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
3331 * ipython_win_post_install.py (run): Added pysh shortcut for Windows.
3320
3332
3321 * IPython/iplib.py (protect_filename): Applied Ville's patch for
3333 * IPython/iplib.py (protect_filename): Applied Ville's patch for
3322 escaping '()[]{}' in filenames.
3334 escaping '()[]{}' in filenames.
3323
3335
3324 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
3336 * IPython/Magic.py (shlex_split): Fix handling of '*' and '?' for
3325 Python 2.2 users who lack a proper shlex.split.
3337 Python 2.2 users who lack a proper shlex.split.
3326
3338
3327 2004-07-19 Fernando Perez <fperez@colorado.edu>
3339 2004-07-19 Fernando Perez <fperez@colorado.edu>
3328
3340
3329 * IPython/iplib.py (InteractiveShell.init_readline): Add support
3341 * IPython/iplib.py (InteractiveShell.init_readline): Add support
3330 for reading readline's init file. I follow the normal chain:
3342 for reading readline's init file. I follow the normal chain:
3331 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
3343 $INPUTRC is honored, otherwise ~/.inputrc is used. Thanks to a
3332 report by Mike Heeter. This closes
3344 report by Mike Heeter. This closes
3333 http://www.scipy.net/roundup/ipython/issue16.
3345 http://www.scipy.net/roundup/ipython/issue16.
3334
3346
3335 2004-07-18 Fernando Perez <fperez@colorado.edu>
3347 2004-07-18 Fernando Perez <fperez@colorado.edu>
3336
3348
3337 * IPython/iplib.py (__init__): Add better handling of '\' under
3349 * IPython/iplib.py (__init__): Add better handling of '\' under
3338 Win32 for filenames. After a patch by Ville.
3350 Win32 for filenames. After a patch by Ville.
3339
3351
3340 2004-07-17 Fernando Perez <fperez@colorado.edu>
3352 2004-07-17 Fernando Perez <fperez@colorado.edu>
3341
3353
3342 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3354 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
3343 autocalling would be triggered for 'foo is bar' if foo is
3355 autocalling would be triggered for 'foo is bar' if foo is
3344 callable. I also cleaned up the autocall detection code to use a
3356 callable. I also cleaned up the autocall detection code to use a
3345 regexp, which is faster. Bug reported by Alexander Schmolck.
3357 regexp, which is faster. Bug reported by Alexander Schmolck.
3346
3358
3347 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
3359 * IPython/Magic.py (Magic.magic_pinfo): Fix bug where strings with
3348 '?' in them would confuse the help system. Reported by Alex
3360 '?' in them would confuse the help system. Reported by Alex
3349 Schmolck.
3361 Schmolck.
3350
3362
3351 2004-07-16 Fernando Perez <fperez@colorado.edu>
3363 2004-07-16 Fernando Perez <fperez@colorado.edu>
3352
3364
3353 * IPython/GnuplotInteractive.py (__all__): added plot2.
3365 * IPython/GnuplotInteractive.py (__all__): added plot2.
3354
3366
3355 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
3367 * IPython/Gnuplot2.py (Gnuplot.plot2): added new function for
3356 plotting dictionaries, lists or tuples of 1d arrays.
3368 plotting dictionaries, lists or tuples of 1d arrays.
3357
3369
3358 * IPython/Magic.py (Magic.magic_hist): small clenaups and
3370 * IPython/Magic.py (Magic.magic_hist): small clenaups and
3359 optimizations.
3371 optimizations.
3360
3372
3361 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
3373 * IPython/iplib.py:Remove old Changelog info for cleanup. This is
3362 the information which was there from Janko's original IPP code:
3374 the information which was there from Janko's original IPP code:
3363
3375
3364 03.05.99 20:53 porto.ifm.uni-kiel.de
3376 03.05.99 20:53 porto.ifm.uni-kiel.de
3365 --Started changelog.
3377 --Started changelog.
3366 --make clear do what it say it does
3378 --make clear do what it say it does
3367 --added pretty output of lines from inputcache
3379 --added pretty output of lines from inputcache
3368 --Made Logger a mixin class, simplifies handling of switches
3380 --Made Logger a mixin class, simplifies handling of switches
3369 --Added own completer class. .string<TAB> expands to last history
3381 --Added own completer class. .string<TAB> expands to last history
3370 line which starts with string. The new expansion is also present
3382 line which starts with string. The new expansion is also present
3371 with Ctrl-r from the readline library. But this shows, who this
3383 with Ctrl-r from the readline library. But this shows, who this
3372 can be done for other cases.
3384 can be done for other cases.
3373 --Added convention that all shell functions should accept a
3385 --Added convention that all shell functions should accept a
3374 parameter_string This opens the door for different behaviour for
3386 parameter_string This opens the door for different behaviour for
3375 each function. @cd is a good example of this.
3387 each function. @cd is a good example of this.
3376
3388
3377 04.05.99 12:12 porto.ifm.uni-kiel.de
3389 04.05.99 12:12 porto.ifm.uni-kiel.de
3378 --added logfile rotation
3390 --added logfile rotation
3379 --added new mainloop method which freezes first the namespace
3391 --added new mainloop method which freezes first the namespace
3380
3392
3381 07.05.99 21:24 porto.ifm.uni-kiel.de
3393 07.05.99 21:24 porto.ifm.uni-kiel.de
3382 --added the docreader classes. Now there is a help system.
3394 --added the docreader classes. Now there is a help system.
3383 -This is only a first try. Currently it's not easy to put new
3395 -This is only a first try. Currently it's not easy to put new
3384 stuff in the indices. But this is the way to go. Info would be
3396 stuff in the indices. But this is the way to go. Info would be
3385 better, but HTML is every where and not everybody has an info
3397 better, but HTML is every where and not everybody has an info
3386 system installed and it's not so easy to change html-docs to info.
3398 system installed and it's not so easy to change html-docs to info.
3387 --added global logfile option
3399 --added global logfile option
3388 --there is now a hook for object inspection method pinfo needs to
3400 --there is now a hook for object inspection method pinfo needs to
3389 be provided for this. Can be reached by two '??'.
3401 be provided for this. Can be reached by two '??'.
3390
3402
3391 08.05.99 20:51 porto.ifm.uni-kiel.de
3403 08.05.99 20:51 porto.ifm.uni-kiel.de
3392 --added a README
3404 --added a README
3393 --bug in rc file. Something has changed so functions in the rc
3405 --bug in rc file. Something has changed so functions in the rc
3394 file need to reference the shell and not self. Not clear if it's a
3406 file need to reference the shell and not self. Not clear if it's a
3395 bug or feature.
3407 bug or feature.
3396 --changed rc file for new behavior
3408 --changed rc file for new behavior
3397
3409
3398 2004-07-15 Fernando Perez <fperez@colorado.edu>
3410 2004-07-15 Fernando Perez <fperez@colorado.edu>
3399
3411
3400 * IPython/Logger.py (Logger.log): fixed recent bug where the input
3412 * IPython/Logger.py (Logger.log): fixed recent bug where the input
3401 cache was falling out of sync in bizarre manners when multi-line
3413 cache was falling out of sync in bizarre manners when multi-line
3402 input was present. Minor optimizations and cleanup.
3414 input was present. Minor optimizations and cleanup.
3403
3415
3404 (Logger): Remove old Changelog info for cleanup. This is the
3416 (Logger): Remove old Changelog info for cleanup. This is the
3405 information which was there from Janko's original code:
3417 information which was there from Janko's original code:
3406
3418
3407 Changes to Logger: - made the default log filename a parameter
3419 Changes to Logger: - made the default log filename a parameter
3408
3420
3409 - put a check for lines beginning with !@? in log(). Needed
3421 - put a check for lines beginning with !@? in log(). Needed
3410 (even if the handlers properly log their lines) for mid-session
3422 (even if the handlers properly log their lines) for mid-session
3411 logging activation to work properly. Without this, lines logged
3423 logging activation to work properly. Without this, lines logged
3412 in mid session, which get read from the cache, would end up
3424 in mid session, which get read from the cache, would end up
3413 'bare' (with !@? in the open) in the log. Now they are caught
3425 'bare' (with !@? in the open) in the log. Now they are caught
3414 and prepended with a #.
3426 and prepended with a #.
3415
3427
3416 * IPython/iplib.py (InteractiveShell.init_readline): added check
3428 * IPython/iplib.py (InteractiveShell.init_readline): added check
3417 in case MagicCompleter fails to be defined, so we don't crash.
3429 in case MagicCompleter fails to be defined, so we don't crash.
3418
3430
3419 2004-07-13 Fernando Perez <fperez@colorado.edu>
3431 2004-07-13 Fernando Perez <fperez@colorado.edu>
3420
3432
3421 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
3433 * IPython/Gnuplot2.py (Gnuplot.hardcopy): add automatic generation
3422 of EPS if the requested filename ends in '.eps'.
3434 of EPS if the requested filename ends in '.eps'.
3423
3435
3424 2004-07-04 Fernando Perez <fperez@colorado.edu>
3436 2004-07-04 Fernando Perez <fperez@colorado.edu>
3425
3437
3426 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
3438 * IPython/iplib.py (InteractiveShell.handle_shell_escape): Fix
3427 escaping of quotes when calling the shell.
3439 escaping of quotes when calling the shell.
3428
3440
3429 2004-07-02 Fernando Perez <fperez@colorado.edu>
3441 2004-07-02 Fernando Perez <fperez@colorado.edu>
3430
3442
3431 * IPython/Prompts.py (CachedOutput.update): Fix problem with
3443 * IPython/Prompts.py (CachedOutput.update): Fix problem with
3432 gettext not working because we were clobbering '_'. Fixes
3444 gettext not working because we were clobbering '_'. Fixes
3433 http://www.scipy.net/roundup/ipython/issue6.
3445 http://www.scipy.net/roundup/ipython/issue6.
3434
3446
3435 2004-07-01 Fernando Perez <fperez@colorado.edu>
3447 2004-07-01 Fernando Perez <fperez@colorado.edu>
3436
3448
3437 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
3449 * IPython/Magic.py (Magic.magic_cd): integrated bookmark handling
3438 into @cd. Patch by Ville.
3450 into @cd. Patch by Ville.
3439
3451
3440 * IPython/iplib.py (InteractiveShell.post_config_initialization):
3452 * IPython/iplib.py (InteractiveShell.post_config_initialization):
3441 new function to store things after ipmaker runs. Patch by Ville.
3453 new function to store things after ipmaker runs. Patch by Ville.
3442 Eventually this will go away once ipmaker is removed and the class
3454 Eventually this will go away once ipmaker is removed and the class
3443 gets cleaned up, but for now it's ok. Key functionality here is
3455 gets cleaned up, but for now it's ok. Key functionality here is
3444 the addition of the persistent storage mechanism, a dict for
3456 the addition of the persistent storage mechanism, a dict for
3445 keeping data across sessions (for now just bookmarks, but more can
3457 keeping data across sessions (for now just bookmarks, but more can
3446 be implemented later).
3458 be implemented later).
3447
3459
3448 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
3460 * IPython/Magic.py (Magic.magic_bookmark): New bookmark system,
3449 persistent across sections. Patch by Ville, I modified it
3461 persistent across sections. Patch by Ville, I modified it
3450 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
3462 soemwhat to allow bookmarking arbitrary dirs other than CWD. Also
3451 added a '-l' option to list all bookmarks.
3463 added a '-l' option to list all bookmarks.
3452
3464
3453 * IPython/iplib.py (InteractiveShell.atexit_operations): new
3465 * IPython/iplib.py (InteractiveShell.atexit_operations): new
3454 center for cleanup. Registered with atexit.register(). I moved
3466 center for cleanup. Registered with atexit.register(). I moved
3455 here the old exit_cleanup(). After a patch by Ville.
3467 here the old exit_cleanup(). After a patch by Ville.
3456
3468
3457 * IPython/Magic.py (get_py_filename): added '~' to the accepted
3469 * IPython/Magic.py (get_py_filename): added '~' to the accepted
3458 characters in the hacked shlex_split for python 2.2.
3470 characters in the hacked shlex_split for python 2.2.
3459
3471
3460 * IPython/iplib.py (file_matches): more fixes to filenames with
3472 * IPython/iplib.py (file_matches): more fixes to filenames with
3461 whitespace in them. It's not perfect, but limitations in python's
3473 whitespace in them. It's not perfect, but limitations in python's
3462 readline make it impossible to go further.
3474 readline make it impossible to go further.
3463
3475
3464 2004-06-29 Fernando Perez <fperez@colorado.edu>
3476 2004-06-29 Fernando Perez <fperez@colorado.edu>
3465
3477
3466 * IPython/iplib.py (file_matches): escape whitespace correctly in
3478 * IPython/iplib.py (file_matches): escape whitespace correctly in
3467 filename completions. Bug reported by Ville.
3479 filename completions. Bug reported by Ville.
3468
3480
3469 2004-06-28 Fernando Perez <fperez@colorado.edu>
3481 2004-06-28 Fernando Perez <fperez@colorado.edu>
3470
3482
3471 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
3483 * IPython/ipmaker.py (__call__): Added per-profile histories. Now
3472 the history file will be called 'history-PROFNAME' (or just
3484 the history file will be called 'history-PROFNAME' (or just
3473 'history' if no profile is loaded). I was getting annoyed at
3485 'history' if no profile is loaded). I was getting annoyed at
3474 getting my Numerical work history clobbered by pysh sessions.
3486 getting my Numerical work history clobbered by pysh sessions.
3475
3487
3476 * IPython/iplib.py (InteractiveShell.__init__): Internal
3488 * IPython/iplib.py (InteractiveShell.__init__): Internal
3477 getoutputerror() function so that we can honor the system_verbose
3489 getoutputerror() function so that we can honor the system_verbose
3478 flag for _all_ system calls. I also added escaping of #
3490 flag for _all_ system calls. I also added escaping of #
3479 characters here to avoid confusing Itpl.
3491 characters here to avoid confusing Itpl.
3480
3492
3481 * IPython/Magic.py (shlex_split): removed call to shell in
3493 * IPython/Magic.py (shlex_split): removed call to shell in
3482 parse_options and replaced it with shlex.split(). The annoying
3494 parse_options and replaced it with shlex.split(). The annoying
3483 part was that in Python 2.2, shlex.split() doesn't exist, so I had
3495 part was that in Python 2.2, shlex.split() doesn't exist, so I had
3484 to backport it from 2.3, with several frail hacks (the shlex
3496 to backport it from 2.3, with several frail hacks (the shlex
3485 module is rather limited in 2.2). Thanks to a suggestion by Ville
3497 module is rather limited in 2.2). Thanks to a suggestion by Ville
3486 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
3498 Vainio <vivainio@kolumbus.fi>. For Python 2.3 there should be no
3487 problem.
3499 problem.
3488
3500
3489 (Magic.magic_system_verbose): new toggle to print the actual
3501 (Magic.magic_system_verbose): new toggle to print the actual
3490 system calls made by ipython. Mainly for debugging purposes.
3502 system calls made by ipython. Mainly for debugging purposes.
3491
3503
3492 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
3504 * IPython/GnuplotRuntime.py (gnu_out): fix bug for cygwin, which
3493 doesn't support persistence. Reported (and fix suggested) by
3505 doesn't support persistence. Reported (and fix suggested) by
3494 Travis Caldwell <travis_caldwell2000@yahoo.com>.
3506 Travis Caldwell <travis_caldwell2000@yahoo.com>.
3495
3507
3496 2004-06-26 Fernando Perez <fperez@colorado.edu>
3508 2004-06-26 Fernando Perez <fperez@colorado.edu>
3497
3509
3498 * IPython/Logger.py (Logger.log): fix to handle correctly empty
3510 * IPython/Logger.py (Logger.log): fix to handle correctly empty
3499 continue prompts.
3511 continue prompts.
3500
3512
3501 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
3513 * IPython/Extensions/InterpreterExec.py (pysh): moved the pysh()
3502 function (basically a big docstring) and a few more things here to
3514 function (basically a big docstring) and a few more things here to
3503 speedup startup. pysh.py is now very lightweight. We want because
3515 speedup startup. pysh.py is now very lightweight. We want because
3504 it gets execfile'd, while InterpreterExec gets imported, so
3516 it gets execfile'd, while InterpreterExec gets imported, so
3505 byte-compilation saves time.
3517 byte-compilation saves time.
3506
3518
3507 2004-06-25 Fernando Perez <fperez@colorado.edu>
3519 2004-06-25 Fernando Perez <fperez@colorado.edu>
3508
3520
3509 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
3521 * IPython/Magic.py (Magic.magic_cd): Fixed to restore usage of 'cd
3510 -NUM', which was recently broken.
3522 -NUM', which was recently broken.
3511
3523
3512 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
3524 * IPython/iplib.py (InteractiveShell.handle_shell_escape): allow !
3513 in multi-line input (but not !!, which doesn't make sense there).
3525 in multi-line input (but not !!, which doesn't make sense there).
3514
3526
3515 * IPython/UserConfig/ipythonrc: made autoindent on by default.
3527 * IPython/UserConfig/ipythonrc: made autoindent on by default.
3516 It's just too useful, and people can turn it off in the less
3528 It's just too useful, and people can turn it off in the less
3517 common cases where it's a problem.
3529 common cases where it's a problem.
3518
3530
3519 2004-06-24 Fernando Perez <fperez@colorado.edu>
3531 2004-06-24 Fernando Perez <fperez@colorado.edu>
3520
3532
3521 * IPython/iplib.py (InteractiveShell._prefilter): big change -
3533 * IPython/iplib.py (InteractiveShell._prefilter): big change -
3522 special syntaxes (like alias calling) is now allied in multi-line
3534 special syntaxes (like alias calling) is now allied in multi-line
3523 input. This is still _very_ experimental, but it's necessary for
3535 input. This is still _very_ experimental, but it's necessary for
3524 efficient shell usage combining python looping syntax with system
3536 efficient shell usage combining python looping syntax with system
3525 calls. For now it's restricted to aliases, I don't think it
3537 calls. For now it's restricted to aliases, I don't think it
3526 really even makes sense to have this for magics.
3538 really even makes sense to have this for magics.
3527
3539
3528 2004-06-23 Fernando Perez <fperez@colorado.edu>
3540 2004-06-23 Fernando Perez <fperez@colorado.edu>
3529
3541
3530 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
3542 * IPython/Extensions/InterpreterExec.py (prefilter_shell): Added
3531 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
3543 $var=cmd <=> @sc var=cmd and $$var=cmd <=> @sc -l var=cmd.
3532
3544
3533 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
3545 * IPython/Magic.py (Magic.magic_rehashx): modified to handle
3534 extensions under Windows (after code sent by Gary Bishop). The
3546 extensions under Windows (after code sent by Gary Bishop). The
3535 extensions considered 'executable' are stored in IPython's rc
3547 extensions considered 'executable' are stored in IPython's rc
3536 structure as win_exec_ext.
3548 structure as win_exec_ext.
3537
3549
3538 * IPython/genutils.py (shell): new function, like system() but
3550 * IPython/genutils.py (shell): new function, like system() but
3539 without return value. Very useful for interactive shell work.
3551 without return value. Very useful for interactive shell work.
3540
3552
3541 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
3553 * IPython/Magic.py (Magic.magic_unalias): New @unalias function to
3542 delete aliases.
3554 delete aliases.
3543
3555
3544 * IPython/iplib.py (InteractiveShell.alias_table_update): make
3556 * IPython/iplib.py (InteractiveShell.alias_table_update): make
3545 sure that the alias table doesn't contain python keywords.
3557 sure that the alias table doesn't contain python keywords.
3546
3558
3547 2004-06-21 Fernando Perez <fperez@colorado.edu>
3559 2004-06-21 Fernando Perez <fperez@colorado.edu>
3548
3560
3549 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
3561 * IPython/Magic.py (Magic.magic_rehash): Fix crash when
3550 non-existent items are found in $PATH. Reported by Thorsten.
3562 non-existent items are found in $PATH. Reported by Thorsten.
3551
3563
3552 2004-06-20 Fernando Perez <fperez@colorado.edu>
3564 2004-06-20 Fernando Perez <fperez@colorado.edu>
3553
3565
3554 * IPython/iplib.py (complete): modified the completer so that the
3566 * IPython/iplib.py (complete): modified the completer so that the
3555 order of priorities can be easily changed at runtime.
3567 order of priorities can be easily changed at runtime.
3556
3568
3557 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
3569 * IPython/Extensions/InterpreterExec.py (prefilter_shell):
3558 Modified to auto-execute all lines beginning with '~', '/' or '.'.
3570 Modified to auto-execute all lines beginning with '~', '/' or '.'.
3559
3571
3560 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
3572 * IPython/Magic.py (Magic.magic_sx): modified @sc and @sx to
3561 expand Python variables prepended with $ in all system calls. The
3573 expand Python variables prepended with $ in all system calls. The
3562 same was done to InteractiveShell.handle_shell_escape. Now all
3574 same was done to InteractiveShell.handle_shell_escape. Now all
3563 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
3575 system access mechanisms (!, !!, @sc, @sx and aliases) allow the
3564 expansion of python variables and expressions according to the
3576 expansion of python variables and expressions according to the
3565 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
3577 syntax of PEP-215 - http://www.python.org/peps/pep-0215.html.
3566
3578
3567 Though PEP-215 has been rejected, a similar (but simpler) one
3579 Though PEP-215 has been rejected, a similar (but simpler) one
3568 seems like it will go into Python 2.4, PEP-292 -
3580 seems like it will go into Python 2.4, PEP-292 -
3569 http://www.python.org/peps/pep-0292.html.
3581 http://www.python.org/peps/pep-0292.html.
3570
3582
3571 I'll keep the full syntax of PEP-215, since IPython has since the
3583 I'll keep the full syntax of PEP-215, since IPython has since the
3572 start used Ka-Ping Yee's reference implementation discussed there
3584 start used Ka-Ping Yee's reference implementation discussed there
3573 (Itpl), and I actually like the powerful semantics it offers.
3585 (Itpl), and I actually like the powerful semantics it offers.
3574
3586
3575 In order to access normal shell variables, the $ has to be escaped
3587 In order to access normal shell variables, the $ has to be escaped
3576 via an extra $. For example:
3588 via an extra $. For example:
3577
3589
3578 In [7]: PATH='a python variable'
3590 In [7]: PATH='a python variable'
3579
3591
3580 In [8]: !echo $PATH
3592 In [8]: !echo $PATH
3581 a python variable
3593 a python variable
3582
3594
3583 In [9]: !echo $$PATH
3595 In [9]: !echo $$PATH
3584 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
3596 /usr/local/lf9560/bin:/usr/local/intel/compiler70/ia32/bin:...
3585
3597
3586 (Magic.parse_options): escape $ so the shell doesn't evaluate
3598 (Magic.parse_options): escape $ so the shell doesn't evaluate
3587 things prematurely.
3599 things prematurely.
3588
3600
3589 * IPython/iplib.py (InteractiveShell.call_alias): added the
3601 * IPython/iplib.py (InteractiveShell.call_alias): added the
3590 ability for aliases to expand python variables via $.
3602 ability for aliases to expand python variables via $.
3591
3603
3592 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
3604 * IPython/Magic.py (Magic.magic_rehash): based on the new alias
3593 system, now there's a @rehash/@rehashx pair of magics. These work
3605 system, now there's a @rehash/@rehashx pair of magics. These work
3594 like the csh rehash command, and can be invoked at any time. They
3606 like the csh rehash command, and can be invoked at any time. They
3595 build a table of aliases to everything in the user's $PATH
3607 build a table of aliases to everything in the user's $PATH
3596 (@rehash uses everything, @rehashx is slower but only adds
3608 (@rehash uses everything, @rehashx is slower but only adds
3597 executable files). With this, the pysh.py-based shell profile can
3609 executable files). With this, the pysh.py-based shell profile can
3598 now simply call rehash upon startup, and full access to all
3610 now simply call rehash upon startup, and full access to all
3599 programs in the user's path is obtained.
3611 programs in the user's path is obtained.
3600
3612
3601 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
3613 * IPython/iplib.py (InteractiveShell.call_alias): The new alias
3602 functionality is now fully in place. I removed the old dynamic
3614 functionality is now fully in place. I removed the old dynamic
3603 code generation based approach, in favor of a much lighter one
3615 code generation based approach, in favor of a much lighter one
3604 based on a simple dict. The advantage is that this allows me to
3616 based on a simple dict. The advantage is that this allows me to
3605 now have thousands of aliases with negligible cost (unthinkable
3617 now have thousands of aliases with negligible cost (unthinkable
3606 with the old system).
3618 with the old system).
3607
3619
3608 2004-06-19 Fernando Perez <fperez@colorado.edu>
3620 2004-06-19 Fernando Perez <fperez@colorado.edu>
3609
3621
3610 * IPython/iplib.py (__init__): extended MagicCompleter class to
3622 * IPython/iplib.py (__init__): extended MagicCompleter class to
3611 also complete (last in priority) on user aliases.
3623 also complete (last in priority) on user aliases.
3612
3624
3613 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
3625 * IPython/Itpl.py (Itpl.__str__): fixed order of globals/locals in
3614 call to eval.
3626 call to eval.
3615 (ItplNS.__init__): Added a new class which functions like Itpl,
3627 (ItplNS.__init__): Added a new class which functions like Itpl,
3616 but allows configuring the namespace for the evaluation to occur
3628 but allows configuring the namespace for the evaluation to occur
3617 in.
3629 in.
3618
3630
3619 2004-06-18 Fernando Perez <fperez@colorado.edu>
3631 2004-06-18 Fernando Perez <fperez@colorado.edu>
3620
3632
3621 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
3633 * IPython/iplib.py (InteractiveShell.runcode): modify to print a
3622 better message when 'exit' or 'quit' are typed (a common newbie
3634 better message when 'exit' or 'quit' are typed (a common newbie
3623 confusion).
3635 confusion).
3624
3636
3625 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
3637 * IPython/Magic.py (Magic.magic_colors): Added the runtime color
3626 check for Windows users.
3638 check for Windows users.
3627
3639
3628 * IPython/iplib.py (InteractiveShell.user_setup): removed
3640 * IPython/iplib.py (InteractiveShell.user_setup): removed
3629 disabling of colors for Windows. I'll test at runtime and issue a
3641 disabling of colors for Windows. I'll test at runtime and issue a
3630 warning if Gary's readline isn't found, as to nudge users to
3642 warning if Gary's readline isn't found, as to nudge users to
3631 download it.
3643 download it.
3632
3644
3633 2004-06-16 Fernando Perez <fperez@colorado.edu>
3645 2004-06-16 Fernando Perez <fperez@colorado.edu>
3634
3646
3635 * IPython/genutils.py (Stream.__init__): changed to print errors
3647 * IPython/genutils.py (Stream.__init__): changed to print errors
3636 to sys.stderr. I had a circular dependency here. Now it's
3648 to sys.stderr. I had a circular dependency here. Now it's
3637 possible to run ipython as IDLE's shell (consider this pre-alpha,
3649 possible to run ipython as IDLE's shell (consider this pre-alpha,
3638 since true stdout things end up in the starting terminal instead
3650 since true stdout things end up in the starting terminal instead
3639 of IDLE's out).
3651 of IDLE's out).
3640
3652
3641 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
3653 * IPython/Prompts.py (Prompt2.set_colors): prevent crashes for
3642 users who haven't # updated their prompt_in2 definitions. Remove
3654 users who haven't # updated their prompt_in2 definitions. Remove
3643 eventually.
3655 eventually.
3644 (multiple_replace): added credit to original ASPN recipe.
3656 (multiple_replace): added credit to original ASPN recipe.
3645
3657
3646 2004-06-15 Fernando Perez <fperez@colorado.edu>
3658 2004-06-15 Fernando Perez <fperez@colorado.edu>
3647
3659
3648 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
3660 * IPython/iplib.py (InteractiveShell.__init__): add 'cp' to the
3649 list of auto-defined aliases.
3661 list of auto-defined aliases.
3650
3662
3651 2004-06-13 Fernando Perez <fperez@colorado.edu>
3663 2004-06-13 Fernando Perez <fperez@colorado.edu>
3652
3664
3653 * setup.py (scriptfiles): Don't trigger win_post_install unless an
3665 * setup.py (scriptfiles): Don't trigger win_post_install unless an
3654 install was really requested (so setup.py can be used for other
3666 install was really requested (so setup.py can be used for other
3655 things under Windows).
3667 things under Windows).
3656
3668
3657 2004-06-10 Fernando Perez <fperez@colorado.edu>
3669 2004-06-10 Fernando Perez <fperez@colorado.edu>
3658
3670
3659 * IPython/Logger.py (Logger.create_log): Manually remove any old
3671 * IPython/Logger.py (Logger.create_log): Manually remove any old
3660 backup, since os.remove may fail under Windows. Fixes bug
3672 backup, since os.remove may fail under Windows. Fixes bug
3661 reported by Thorsten.
3673 reported by Thorsten.
3662
3674
3663 2004-06-09 Fernando Perez <fperez@colorado.edu>
3675 2004-06-09 Fernando Perez <fperez@colorado.edu>
3664
3676
3665 * examples/example-embed.py: fixed all references to %n (replaced
3677 * examples/example-embed.py: fixed all references to %n (replaced
3666 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
3678 with \\# for ps1/out prompts and with \\D for ps2 prompts). Done
3667 for all examples and the manual as well.
3679 for all examples and the manual as well.
3668
3680
3669 2004-06-08 Fernando Perez <fperez@colorado.edu>
3681 2004-06-08 Fernando Perez <fperez@colorado.edu>
3670
3682
3671 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
3683 * IPython/Prompts.py (Prompt2.set_p_str): fixed all prompt
3672 alignment and color management. All 3 prompt subsystems now
3684 alignment and color management. All 3 prompt subsystems now
3673 inherit from BasePrompt.
3685 inherit from BasePrompt.
3674
3686
3675 * tools/release: updates for windows installer build and tag rpms
3687 * tools/release: updates for windows installer build and tag rpms
3676 with python version (since paths are fixed).
3688 with python version (since paths are fixed).
3677
3689
3678 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
3690 * IPython/UserConfig/ipythonrc: modified to use \# instead of %n,
3679 which will become eventually obsolete. Also fixed the default
3691 which will become eventually obsolete. Also fixed the default
3680 prompt_in2 to use \D, so at least new users start with the correct
3692 prompt_in2 to use \D, so at least new users start with the correct
3681 defaults.
3693 defaults.
3682 WARNING: Users with existing ipythonrc files will need to apply
3694 WARNING: Users with existing ipythonrc files will need to apply
3683 this fix manually!
3695 this fix manually!
3684
3696
3685 * setup.py: make windows installer (.exe). This is finally the
3697 * setup.py: make windows installer (.exe). This is finally the
3686 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
3698 integration of an old patch by Cory Dodt <dodt-AT-fcoe.k12.ca.us>,
3687 which I hadn't included because it required Python 2.3 (or recent
3699 which I hadn't included because it required Python 2.3 (or recent
3688 distutils).
3700 distutils).
3689
3701
3690 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
3702 * IPython/usage.py (__doc__): update docs (and manpage) to reflect
3691 usage of new '\D' escape.
3703 usage of new '\D' escape.
3692
3704
3693 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
3705 * IPython/Prompts.py (ROOT_SYMBOL): Small fix for Windows (which
3694 lacks os.getuid())
3706 lacks os.getuid())
3695 (CachedOutput.set_colors): Added the ability to turn coloring
3707 (CachedOutput.set_colors): Added the ability to turn coloring
3696 on/off with @colors even for manually defined prompt colors. It
3708 on/off with @colors even for manually defined prompt colors. It
3697 uses a nasty global, but it works safely and via the generic color
3709 uses a nasty global, but it works safely and via the generic color
3698 handling mechanism.
3710 handling mechanism.
3699 (Prompt2.__init__): Introduced new escape '\D' for continuation
3711 (Prompt2.__init__): Introduced new escape '\D' for continuation
3700 prompts. It represents the counter ('\#') as dots.
3712 prompts. It represents the counter ('\#') as dots.
3701 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
3713 *** NOTE *** THIS IS A BACKWARDS-INCOMPATIBLE CHANGE. Users will
3702 need to update their ipythonrc files and replace '%n' with '\D' in
3714 need to update their ipythonrc files and replace '%n' with '\D' in
3703 their prompt_in2 settings everywhere. Sorry, but there's
3715 their prompt_in2 settings everywhere. Sorry, but there's
3704 otherwise no clean way to get all prompts to properly align. The
3716 otherwise no clean way to get all prompts to properly align. The
3705 ipythonrc shipped with IPython has been updated.
3717 ipythonrc shipped with IPython has been updated.
3706
3718
3707 2004-06-07 Fernando Perez <fperez@colorado.edu>
3719 2004-06-07 Fernando Perez <fperez@colorado.edu>
3708
3720
3709 * setup.py (isfile): Pass local_icons option to latex2html, so the
3721 * setup.py (isfile): Pass local_icons option to latex2html, so the
3710 resulting HTML file is self-contained. Thanks to
3722 resulting HTML file is self-contained. Thanks to
3711 dryice-AT-liu.com.cn for the tip.
3723 dryice-AT-liu.com.cn for the tip.
3712
3724
3713 * pysh.py: I created a new profile 'shell', which implements a
3725 * pysh.py: I created a new profile 'shell', which implements a
3714 _rudimentary_ IPython-based shell. This is in NO WAY a realy
3726 _rudimentary_ IPython-based shell. This is in NO WAY a realy
3715 system shell, nor will it become one anytime soon. It's mainly
3727 system shell, nor will it become one anytime soon. It's mainly
3716 meant to illustrate the use of the new flexible bash-like prompts.
3728 meant to illustrate the use of the new flexible bash-like prompts.
3717 I guess it could be used by hardy souls for true shell management,
3729 I guess it could be used by hardy souls for true shell management,
3718 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
3730 but it's no tcsh/bash... pysh.py is loaded by the 'shell'
3719 profile. This uses the InterpreterExec extension provided by
3731 profile. This uses the InterpreterExec extension provided by
3720 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
3732 W.J. van der Laan <gnufnork-AT-hetdigitalegat.nl>
3721
3733
3722 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
3734 * IPython/Prompts.py (PromptOut.__str__): now it will correctly
3723 auto-align itself with the length of the previous input prompt
3735 auto-align itself with the length of the previous input prompt
3724 (taking into account the invisible color escapes).
3736 (taking into account the invisible color escapes).
3725 (CachedOutput.__init__): Large restructuring of this class. Now
3737 (CachedOutput.__init__): Large restructuring of this class. Now
3726 all three prompts (primary1, primary2, output) are proper objects,
3738 all three prompts (primary1, primary2, output) are proper objects,
3727 managed by the 'parent' CachedOutput class. The code is still a
3739 managed by the 'parent' CachedOutput class. The code is still a
3728 bit hackish (all prompts share state via a pointer to the cache),
3740 bit hackish (all prompts share state via a pointer to the cache),
3729 but it's overall far cleaner than before.
3741 but it's overall far cleaner than before.
3730
3742
3731 * IPython/genutils.py (getoutputerror): modified to add verbose,
3743 * IPython/genutils.py (getoutputerror): modified to add verbose,
3732 debug and header options. This makes the interface of all getout*
3744 debug and header options. This makes the interface of all getout*
3733 functions uniform.
3745 functions uniform.
3734 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
3746 (SystemExec.getoutputerror): added getoutputerror to SystemExec.
3735
3747
3736 * IPython/Magic.py (Magic.default_option): added a function to
3748 * IPython/Magic.py (Magic.default_option): added a function to
3737 allow registering default options for any magic command. This
3749 allow registering default options for any magic command. This
3738 makes it easy to have profiles which customize the magics globally
3750 makes it easy to have profiles which customize the magics globally
3739 for a certain use. The values set through this function are
3751 for a certain use. The values set through this function are
3740 picked up by the parse_options() method, which all magics should
3752 picked up by the parse_options() method, which all magics should
3741 use to parse their options.
3753 use to parse their options.
3742
3754
3743 * IPython/genutils.py (warn): modified the warnings framework to
3755 * IPython/genutils.py (warn): modified the warnings framework to
3744 use the Term I/O class. I'm trying to slowly unify all of
3756 use the Term I/O class. I'm trying to slowly unify all of
3745 IPython's I/O operations to pass through Term.
3757 IPython's I/O operations to pass through Term.
3746
3758
3747 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
3759 * IPython/Prompts.py (Prompt2._str_other): Added functionality in
3748 the secondary prompt to correctly match the length of the primary
3760 the secondary prompt to correctly match the length of the primary
3749 one for any prompt. Now multi-line code will properly line up
3761 one for any prompt. Now multi-line code will properly line up
3750 even for path dependent prompts, such as the new ones available
3762 even for path dependent prompts, such as the new ones available
3751 via the prompt_specials.
3763 via the prompt_specials.
3752
3764
3753 2004-06-06 Fernando Perez <fperez@colorado.edu>
3765 2004-06-06 Fernando Perez <fperez@colorado.edu>
3754
3766
3755 * IPython/Prompts.py (prompt_specials): Added the ability to have
3767 * IPython/Prompts.py (prompt_specials): Added the ability to have
3756 bash-like special sequences in the prompts, which get
3768 bash-like special sequences in the prompts, which get
3757 automatically expanded. Things like hostname, current working
3769 automatically expanded. Things like hostname, current working
3758 directory and username are implemented already, but it's easy to
3770 directory and username are implemented already, but it's easy to
3759 add more in the future. Thanks to a patch by W.J. van der Laan
3771 add more in the future. Thanks to a patch by W.J. van der Laan
3760 <gnufnork-AT-hetdigitalegat.nl>
3772 <gnufnork-AT-hetdigitalegat.nl>
3761 (prompt_specials): Added color support for prompt strings, so
3773 (prompt_specials): Added color support for prompt strings, so
3762 users can define arbitrary color setups for their prompts.
3774 users can define arbitrary color setups for their prompts.
3763
3775
3764 2004-06-05 Fernando Perez <fperez@colorado.edu>
3776 2004-06-05 Fernando Perez <fperez@colorado.edu>
3765
3777
3766 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
3778 * IPython/genutils.py (Term.reopen_all): Added Windows-specific
3767 code to load Gary Bishop's readline and configure it
3779 code to load Gary Bishop's readline and configure it
3768 automatically. Thanks to Gary for help on this.
3780 automatically. Thanks to Gary for help on this.
3769
3781
3770 2004-06-01 Fernando Perez <fperez@colorado.edu>
3782 2004-06-01 Fernando Perez <fperez@colorado.edu>
3771
3783
3772 * IPython/Logger.py (Logger.create_log): fix bug for logging
3784 * IPython/Logger.py (Logger.create_log): fix bug for logging
3773 with no filename (previous fix was incomplete).
3785 with no filename (previous fix was incomplete).
3774
3786
3775 2004-05-25 Fernando Perez <fperez@colorado.edu>
3787 2004-05-25 Fernando Perez <fperez@colorado.edu>
3776
3788
3777 * IPython/Magic.py (Magic.parse_options): fix bug where naked
3789 * IPython/Magic.py (Magic.parse_options): fix bug where naked
3778 parens would get passed to the shell.
3790 parens would get passed to the shell.
3779
3791
3780 2004-05-20 Fernando Perez <fperez@colorado.edu>
3792 2004-05-20 Fernando Perez <fperez@colorado.edu>
3781
3793
3782 * IPython/Magic.py (Magic.magic_prun): changed default profile
3794 * IPython/Magic.py (Magic.magic_prun): changed default profile
3783 sort order to 'time' (the more common profiling need).
3795 sort order to 'time' (the more common profiling need).
3784
3796
3785 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
3797 * IPython/OInspect.py (Inspector.pinfo): flush the inspect cache
3786 so that source code shown is guaranteed in sync with the file on
3798 so that source code shown is guaranteed in sync with the file on
3787 disk (also changed in psource). Similar fix to the one for
3799 disk (also changed in psource). Similar fix to the one for
3788 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
3800 ultraTB on 2004-05-06. Thanks to a bug report by Yann Le Du
3789 <yann.ledu-AT-noos.fr>.
3801 <yann.ledu-AT-noos.fr>.
3790
3802
3791 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
3803 * IPython/Magic.py (Magic.parse_options): Fixed bug where commands
3792 with a single option would not be correctly parsed. Closes
3804 with a single option would not be correctly parsed. Closes
3793 http://www.scipy.net/roundup/ipython/issue14. This bug had been
3805 http://www.scipy.net/roundup/ipython/issue14. This bug had been
3794 introduced in 0.6.0 (on 2004-05-06).
3806 introduced in 0.6.0 (on 2004-05-06).
3795
3807
3796 2004-05-13 *** Released version 0.6.0
3808 2004-05-13 *** Released version 0.6.0
3797
3809
3798 2004-05-13 Fernando Perez <fperez@colorado.edu>
3810 2004-05-13 Fernando Perez <fperez@colorado.edu>
3799
3811
3800 * debian/: Added debian/ directory to CVS, so that debian support
3812 * debian/: Added debian/ directory to CVS, so that debian support
3801 is publicly accessible. The debian package is maintained by Jack
3813 is publicly accessible. The debian package is maintained by Jack
3802 Moffit <jack-AT-xiph.org>.
3814 Moffit <jack-AT-xiph.org>.
3803
3815
3804 * Documentation: included the notes about an ipython-based system
3816 * Documentation: included the notes about an ipython-based system
3805 shell (the hypothetical 'pysh') into the new_design.pdf document,
3817 shell (the hypothetical 'pysh') into the new_design.pdf document,
3806 so that these ideas get distributed to users along with the
3818 so that these ideas get distributed to users along with the
3807 official documentation.
3819 official documentation.
3808
3820
3809 2004-05-10 Fernando Perez <fperez@colorado.edu>
3821 2004-05-10 Fernando Perez <fperez@colorado.edu>
3810
3822
3811 * IPython/Logger.py (Logger.create_log): fix recently introduced
3823 * IPython/Logger.py (Logger.create_log): fix recently introduced
3812 bug (misindented line) where logstart would fail when not given an
3824 bug (misindented line) where logstart would fail when not given an
3813 explicit filename.
3825 explicit filename.
3814
3826
3815 2004-05-09 Fernando Perez <fperez@colorado.edu>
3827 2004-05-09 Fernando Perez <fperez@colorado.edu>
3816
3828
3817 * IPython/Magic.py (Magic.parse_options): skip system call when
3829 * IPython/Magic.py (Magic.parse_options): skip system call when
3818 there are no options to look for. Faster, cleaner for the common
3830 there are no options to look for. Faster, cleaner for the common
3819 case.
3831 case.
3820
3832
3821 * Documentation: many updates to the manual: describing Windows
3833 * Documentation: many updates to the manual: describing Windows
3822 support better, Gnuplot updates, credits, misc small stuff. Also
3834 support better, Gnuplot updates, credits, misc small stuff. Also
3823 updated the new_design doc a bit.
3835 updated the new_design doc a bit.
3824
3836
3825 2004-05-06 *** Released version 0.6.0.rc1
3837 2004-05-06 *** Released version 0.6.0.rc1
3826
3838
3827 2004-05-06 Fernando Perez <fperez@colorado.edu>
3839 2004-05-06 Fernando Perez <fperez@colorado.edu>
3828
3840
3829 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
3841 * IPython/ultraTB.py (ListTB.text): modified a ton of string +=
3830 operations to use the vastly more efficient list/''.join() method.
3842 operations to use the vastly more efficient list/''.join() method.
3831 (FormattedTB.text): Fix
3843 (FormattedTB.text): Fix
3832 http://www.scipy.net/roundup/ipython/issue12 - exception source
3844 http://www.scipy.net/roundup/ipython/issue12 - exception source
3833 extract not updated after reload. Thanks to Mike Salib
3845 extract not updated after reload. Thanks to Mike Salib
3834 <msalib-AT-mit.edu> for pinning the source of the problem.
3846 <msalib-AT-mit.edu> for pinning the source of the problem.
3835 Fortunately, the solution works inside ipython and doesn't require
3847 Fortunately, the solution works inside ipython and doesn't require
3836 any changes to python proper.
3848 any changes to python proper.
3837
3849
3838 * IPython/Magic.py (Magic.parse_options): Improved to process the
3850 * IPython/Magic.py (Magic.parse_options): Improved to process the
3839 argument list as a true shell would (by actually using the
3851 argument list as a true shell would (by actually using the
3840 underlying system shell). This way, all @magics automatically get
3852 underlying system shell). This way, all @magics automatically get
3841 shell expansion for variables. Thanks to a comment by Alex
3853 shell expansion for variables. Thanks to a comment by Alex
3842 Schmolck.
3854 Schmolck.
3843
3855
3844 2004-04-04 Fernando Perez <fperez@colorado.edu>
3856 2004-04-04 Fernando Perez <fperez@colorado.edu>
3845
3857
3846 * IPython/iplib.py (InteractiveShell.interact): Added a special
3858 * IPython/iplib.py (InteractiveShell.interact): Added a special
3847 trap for a debugger quit exception, which is basically impossible
3859 trap for a debugger quit exception, which is basically impossible
3848 to handle by normal mechanisms, given what pdb does to the stack.
3860 to handle by normal mechanisms, given what pdb does to the stack.
3849 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
3861 This fixes a crash reported by <fgibbons-AT-llama.med.harvard.edu>.
3850
3862
3851 2004-04-03 Fernando Perez <fperez@colorado.edu>
3863 2004-04-03 Fernando Perez <fperez@colorado.edu>
3852
3864
3853 * IPython/genutils.py (Term): Standardized the names of the Term
3865 * IPython/genutils.py (Term): Standardized the names of the Term
3854 class streams to cin/cout/cerr, following C++ naming conventions
3866 class streams to cin/cout/cerr, following C++ naming conventions
3855 (I can't use in/out/err because 'in' is not a valid attribute
3867 (I can't use in/out/err because 'in' is not a valid attribute
3856 name).
3868 name).
3857
3869
3858 * IPython/iplib.py (InteractiveShell.interact): don't increment
3870 * IPython/iplib.py (InteractiveShell.interact): don't increment
3859 the prompt if there's no user input. By Daniel 'Dang' Griffith
3871 the prompt if there's no user input. By Daniel 'Dang' Griffith
3860 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
3872 <pythondev-dang-AT-lazytwinacres.net>, after a suggestion from
3861 Francois Pinard.
3873 Francois Pinard.
3862
3874
3863 2004-04-02 Fernando Perez <fperez@colorado.edu>
3875 2004-04-02 Fernando Perez <fperez@colorado.edu>
3864
3876
3865 * IPython/genutils.py (Stream.__init__): Modified to survive at
3877 * IPython/genutils.py (Stream.__init__): Modified to survive at
3866 least importing in contexts where stdin/out/err aren't true file
3878 least importing in contexts where stdin/out/err aren't true file
3867 objects, such as PyCrust (they lack fileno() and mode). However,
3879 objects, such as PyCrust (they lack fileno() and mode). However,
3868 the recovery facilities which rely on these things existing will
3880 the recovery facilities which rely on these things existing will
3869 not work.
3881 not work.
3870
3882
3871 2004-04-01 Fernando Perez <fperez@colorado.edu>
3883 2004-04-01 Fernando Perez <fperez@colorado.edu>
3872
3884
3873 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
3885 * IPython/Magic.py (Magic.magic_sx): modified (as well as @sc) to
3874 use the new getoutputerror() function, so it properly
3886 use the new getoutputerror() function, so it properly
3875 distinguishes stdout/err.
3887 distinguishes stdout/err.
3876
3888
3877 * IPython/genutils.py (getoutputerror): added a function to
3889 * IPython/genutils.py (getoutputerror): added a function to
3878 capture separately the standard output and error of a command.
3890 capture separately the standard output and error of a command.
3879 After a comment from dang on the mailing lists. This code is
3891 After a comment from dang on the mailing lists. This code is
3880 basically a modified version of commands.getstatusoutput(), from
3892 basically a modified version of commands.getstatusoutput(), from
3881 the standard library.
3893 the standard library.
3882
3894
3883 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
3895 * IPython/iplib.py (InteractiveShell.handle_shell_escape): added
3884 '!!' as a special syntax (shorthand) to access @sx.
3896 '!!' as a special syntax (shorthand) to access @sx.
3885
3897
3886 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
3898 * IPython/Magic.py (Magic.magic_sx): new magic, to execute a shell
3887 command and return its output as a list split on '\n'.
3899 command and return its output as a list split on '\n'.
3888
3900
3889 2004-03-31 Fernando Perez <fperez@colorado.edu>
3901 2004-03-31 Fernando Perez <fperez@colorado.edu>
3890
3902
3891 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
3903 * IPython/FakeModule.py (FakeModule.__init__): added __nonzero__
3892 method to dictionaries used as FakeModule instances if they lack
3904 method to dictionaries used as FakeModule instances if they lack
3893 it. At least pydoc in python2.3 breaks for runtime-defined
3905 it. At least pydoc in python2.3 breaks for runtime-defined
3894 functions without this hack. At some point I need to _really_
3906 functions without this hack. At some point I need to _really_
3895 understand what FakeModule is doing, because it's a gross hack.
3907 understand what FakeModule is doing, because it's a gross hack.
3896 But it solves Arnd's problem for now...
3908 But it solves Arnd's problem for now...
3897
3909
3898 2004-02-27 Fernando Perez <fperez@colorado.edu>
3910 2004-02-27 Fernando Perez <fperez@colorado.edu>
3899
3911
3900 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
3912 * IPython/Logger.py (Logger.create_log): Fix bug where 'rotate'
3901 mode would behave erratically. Also increased the number of
3913 mode would behave erratically. Also increased the number of
3902 possible logs in rotate mod to 999. Thanks to Rod Holland
3914 possible logs in rotate mod to 999. Thanks to Rod Holland
3903 <rhh@StructureLABS.com> for the report and fixes.
3915 <rhh@StructureLABS.com> for the report and fixes.
3904
3916
3905 2004-02-26 Fernando Perez <fperez@colorado.edu>
3917 2004-02-26 Fernando Perez <fperez@colorado.edu>
3906
3918
3907 * IPython/genutils.py (page): Check that the curses module really
3919 * IPython/genutils.py (page): Check that the curses module really
3908 has the initscr attribute before trying to use it. For some
3920 has the initscr attribute before trying to use it. For some
3909 reason, the Solaris curses module is missing this. I think this
3921 reason, the Solaris curses module is missing this. I think this
3910 should be considered a Solaris python bug, but I'm not sure.
3922 should be considered a Solaris python bug, but I'm not sure.
3911
3923
3912 2004-01-17 Fernando Perez <fperez@colorado.edu>
3924 2004-01-17 Fernando Perez <fperez@colorado.edu>
3913
3925
3914 * IPython/genutils.py (Stream.__init__): Changes to try to make
3926 * IPython/genutils.py (Stream.__init__): Changes to try to make
3915 ipython robust against stdin/out/err being closed by the user.
3927 ipython robust against stdin/out/err being closed by the user.
3916 This is 'user error' (and blocks a normal python session, at least
3928 This is 'user error' (and blocks a normal python session, at least
3917 the stdout case). However, Ipython should be able to survive such
3929 the stdout case). However, Ipython should be able to survive such
3918 instances of abuse as gracefully as possible. To simplify the
3930 instances of abuse as gracefully as possible. To simplify the
3919 coding and maintain compatibility with Gary Bishop's Term
3931 coding and maintain compatibility with Gary Bishop's Term
3920 contributions, I've made use of classmethods for this. I think
3932 contributions, I've made use of classmethods for this. I think
3921 this introduces a dependency on python 2.2.
3933 this introduces a dependency on python 2.2.
3922
3934
3923 2004-01-13 Fernando Perez <fperez@colorado.edu>
3935 2004-01-13 Fernando Perez <fperez@colorado.edu>
3924
3936
3925 * IPython/numutils.py (exp_safe): simplified the code a bit and
3937 * IPython/numutils.py (exp_safe): simplified the code a bit and
3926 removed the need for importing the kinds module altogether.
3938 removed the need for importing the kinds module altogether.
3927
3939
3928 2004-01-06 Fernando Perez <fperez@colorado.edu>
3940 2004-01-06 Fernando Perez <fperez@colorado.edu>
3929
3941
3930 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
3942 * IPython/Magic.py (Magic.magic_sc): Made the shell capture system
3931 a magic function instead, after some community feedback. No
3943 a magic function instead, after some community feedback. No
3932 special syntax will exist for it, but its name is deliberately
3944 special syntax will exist for it, but its name is deliberately
3933 very short.
3945 very short.
3934
3946
3935 2003-12-20 Fernando Perez <fperez@colorado.edu>
3947 2003-12-20 Fernando Perez <fperez@colorado.edu>
3936
3948
3937 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
3949 * IPython/iplib.py (InteractiveShell.handle_shell_assign): Added
3938 new functionality, to automagically assign the result of a shell
3950 new functionality, to automagically assign the result of a shell
3939 command to a variable. I'll solicit some community feedback on
3951 command to a variable. I'll solicit some community feedback on
3940 this before making it permanent.
3952 this before making it permanent.
3941
3953
3942 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
3954 * IPython/OInspect.py (Inspector.pinfo): Fix crash when info was
3943 requested about callables for which inspect couldn't obtain a
3955 requested about callables for which inspect couldn't obtain a
3944 proper argspec. Thanks to a crash report sent by Etienne
3956 proper argspec. Thanks to a crash report sent by Etienne
3945 Posthumus <etienne-AT-apple01.cs.vu.nl>.
3957 Posthumus <etienne-AT-apple01.cs.vu.nl>.
3946
3958
3947 2003-12-09 Fernando Perez <fperez@colorado.edu>
3959 2003-12-09 Fernando Perez <fperez@colorado.edu>
3948
3960
3949 * IPython/genutils.py (page): patch for the pager to work across
3961 * IPython/genutils.py (page): patch for the pager to work across
3950 various versions of Windows. By Gary Bishop.
3962 various versions of Windows. By Gary Bishop.
3951
3963
3952 2003-12-04 Fernando Perez <fperez@colorado.edu>
3964 2003-12-04 Fernando Perez <fperez@colorado.edu>
3953
3965
3954 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
3966 * IPython/Gnuplot2.py (PlotItems): Fixes for working with
3955 Gnuplot.py version 1.7, whose internal names changed quite a bit.
3967 Gnuplot.py version 1.7, whose internal names changed quite a bit.
3956 While I tested this and it looks ok, there may still be corner
3968 While I tested this and it looks ok, there may still be corner
3957 cases I've missed.
3969 cases I've missed.
3958
3970
3959 2003-12-01 Fernando Perez <fperez@colorado.edu>
3971 2003-12-01 Fernando Perez <fperez@colorado.edu>
3960
3972
3961 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
3973 * IPython/iplib.py (InteractiveShell._prefilter): Fixed a bug
3962 where a line like 'p,q=1,2' would fail because the automagic
3974 where a line like 'p,q=1,2' would fail because the automagic
3963 system would be triggered for @p.
3975 system would be triggered for @p.
3964
3976
3965 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
3977 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): Tab-related
3966 cleanups, code unmodified.
3978 cleanups, code unmodified.
3967
3979
3968 * IPython/genutils.py (Term): added a class for IPython to handle
3980 * IPython/genutils.py (Term): added a class for IPython to handle
3969 output. In most cases it will just be a proxy for stdout/err, but
3981 output. In most cases it will just be a proxy for stdout/err, but
3970 having this allows modifications to be made for some platforms,
3982 having this allows modifications to be made for some platforms,
3971 such as handling color escapes under Windows. All of this code
3983 such as handling color escapes under Windows. All of this code
3972 was contributed by Gary Bishop, with minor modifications by me.
3984 was contributed by Gary Bishop, with minor modifications by me.
3973 The actual changes affect many files.
3985 The actual changes affect many files.
3974
3986
3975 2003-11-30 Fernando Perez <fperez@colorado.edu>
3987 2003-11-30 Fernando Perez <fperez@colorado.edu>
3976
3988
3977 * IPython/iplib.py (file_matches): new completion code, courtesy
3989 * IPython/iplib.py (file_matches): new completion code, courtesy
3978 of Jeff Collins. This enables filename completion again under
3990 of Jeff Collins. This enables filename completion again under
3979 python 2.3, which disabled it at the C level.
3991 python 2.3, which disabled it at the C level.
3980
3992
3981 2003-11-11 Fernando Perez <fperez@colorado.edu>
3993 2003-11-11 Fernando Perez <fperez@colorado.edu>
3982
3994
3983 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
3995 * IPython/numutils.py (amap): Added amap() fn. Simple shorthand
3984 for Numeric.array(map(...)), but often convenient.
3996 for Numeric.array(map(...)), but often convenient.
3985
3997
3986 2003-11-05 Fernando Perez <fperez@colorado.edu>
3998 2003-11-05 Fernando Perez <fperez@colorado.edu>
3987
3999
3988 * IPython/numutils.py (frange): Changed a call from int() to
4000 * IPython/numutils.py (frange): Changed a call from int() to
3989 int(round()) to prevent a problem reported with arange() in the
4001 int(round()) to prevent a problem reported with arange() in the
3990 numpy list.
4002 numpy list.
3991
4003
3992 2003-10-06 Fernando Perez <fperez@colorado.edu>
4004 2003-10-06 Fernando Perez <fperez@colorado.edu>
3993
4005
3994 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
4006 * IPython/DPyGetOpt.py (DPyGetOpt.processArguments): changed to
3995 prevent crashes if sys lacks an argv attribute (it happens with
4007 prevent crashes if sys lacks an argv attribute (it happens with
3996 embedded interpreters which build a bare-bones sys module).
4008 embedded interpreters which build a bare-bones sys module).
3997 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
4009 Thanks to a report/bugfix by Adam Hupp <hupp-AT-cs.wisc.edu>.
3998
4010
3999 2003-09-24 Fernando Perez <fperez@colorado.edu>
4011 2003-09-24 Fernando Perez <fperez@colorado.edu>
4000
4012
4001 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
4013 * IPython/Magic.py (Magic._ofind): blanket except around getattr()
4002 to protect against poorly written user objects where __getattr__
4014 to protect against poorly written user objects where __getattr__
4003 raises exceptions other than AttributeError. Thanks to a bug
4015 raises exceptions other than AttributeError. Thanks to a bug
4004 report by Oliver Sander <osander-AT-gmx.de>.
4016 report by Oliver Sander <osander-AT-gmx.de>.
4005
4017
4006 * IPython/FakeModule.py (FakeModule.__repr__): this method was
4018 * IPython/FakeModule.py (FakeModule.__repr__): this method was
4007 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
4019 missing. Thanks to bug report by Ralf Schmitt <ralf-AT-brainbot.com>.
4008
4020
4009 2003-09-09 Fernando Perez <fperez@colorado.edu>
4021 2003-09-09 Fernando Perez <fperez@colorado.edu>
4010
4022
4011 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
4023 * IPython/iplib.py (InteractiveShell._prefilter): fix bug where
4012 unpacking a list whith a callable as first element would
4024 unpacking a list whith a callable as first element would
4013 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
4025 mistakenly trigger autocalling. Thanks to a bug report by Jeffery
4014 Collins.
4026 Collins.
4015
4027
4016 2003-08-25 *** Released version 0.5.0
4028 2003-08-25 *** Released version 0.5.0
4017
4029
4018 2003-08-22 Fernando Perez <fperez@colorado.edu>
4030 2003-08-22 Fernando Perez <fperez@colorado.edu>
4019
4031
4020 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
4032 * IPython/ultraTB.py (VerboseTB.linereader): Improved handling of
4021 improperly defined user exceptions. Thanks to feedback from Mark
4033 improperly defined user exceptions. Thanks to feedback from Mark
4022 Russell <mrussell-AT-verio.net>.
4034 Russell <mrussell-AT-verio.net>.
4023
4035
4024 2003-08-20 Fernando Perez <fperez@colorado.edu>
4036 2003-08-20 Fernando Perez <fperez@colorado.edu>
4025
4037
4026 * IPython/OInspect.py (Inspector.pinfo): changed String Form
4038 * IPython/OInspect.py (Inspector.pinfo): changed String Form
4027 printing so that it would print multi-line string forms starting
4039 printing so that it would print multi-line string forms starting
4028 with a new line. This way the formatting is better respected for
4040 with a new line. This way the formatting is better respected for
4029 objects which work hard to make nice string forms.
4041 objects which work hard to make nice string forms.
4030
4042
4031 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
4043 * IPython/iplib.py (InteractiveShell.handle_auto): Fix bug where
4032 autocall would overtake data access for objects with both
4044 autocall would overtake data access for objects with both
4033 __getitem__ and __call__.
4045 __getitem__ and __call__.
4034
4046
4035 2003-08-19 *** Released version 0.5.0-rc1
4047 2003-08-19 *** Released version 0.5.0-rc1
4036
4048
4037 2003-08-19 Fernando Perez <fperez@colorado.edu>
4049 2003-08-19 Fernando Perez <fperez@colorado.edu>
4038
4050
4039 * IPython/deep_reload.py (load_tail): single tiny change here
4051 * IPython/deep_reload.py (load_tail): single tiny change here
4040 seems to fix the long-standing bug of dreload() failing to work
4052 seems to fix the long-standing bug of dreload() failing to work
4041 for dotted names. But this module is pretty tricky, so I may have
4053 for dotted names. But this module is pretty tricky, so I may have
4042 missed some subtlety. Needs more testing!.
4054 missed some subtlety. Needs more testing!.
4043
4055
4044 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
4056 * IPython/ultraTB.py (VerboseTB.linereader): harden against user
4045 exceptions which have badly implemented __str__ methods.
4057 exceptions which have badly implemented __str__ methods.
4046 (VerboseTB.text): harden against inspect.getinnerframes crashing,
4058 (VerboseTB.text): harden against inspect.getinnerframes crashing,
4047 which I've been getting reports about from Python 2.3 users. I
4059 which I've been getting reports about from Python 2.3 users. I
4048 wish I had a simple test case to reproduce the problem, so I could
4060 wish I had a simple test case to reproduce the problem, so I could
4049 either write a cleaner workaround or file a bug report if
4061 either write a cleaner workaround or file a bug report if
4050 necessary.
4062 necessary.
4051
4063
4052 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
4064 * IPython/Magic.py (Magic.magic_edit): fixed bug where after
4053 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
4065 making a class 'foo', file 'foo.py' couldn't be edited. Thanks to
4054 a bug report by Tjabo Kloppenburg.
4066 a bug report by Tjabo Kloppenburg.
4055
4067
4056 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
4068 * IPython/ultraTB.py (VerboseTB.debugger): hardened against pdb
4057 crashes. Wrapped the pdb call in a blanket try/except, since pdb
4069 crashes. Wrapped the pdb call in a blanket try/except, since pdb
4058 seems rather unstable. Thanks to a bug report by Tjabo
4070 seems rather unstable. Thanks to a bug report by Tjabo
4059 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
4071 Kloppenburg <tjabo.kloppenburg-AT-unix-ag.uni-siegen.de>.
4060
4072
4061 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
4073 * IPython/Release.py (version): release 0.5.0-rc1. I want to put
4062 this out soon because of the critical fixes in the inner loop for
4074 this out soon because of the critical fixes in the inner loop for
4063 generators.
4075 generators.
4064
4076
4065 * IPython/Magic.py (Magic.getargspec): removed. This (and
4077 * IPython/Magic.py (Magic.getargspec): removed. This (and
4066 _get_def) have been obsoleted by OInspect for a long time, I
4078 _get_def) have been obsoleted by OInspect for a long time, I
4067 hadn't noticed that they were dead code.
4079 hadn't noticed that they were dead code.
4068 (Magic._ofind): restored _ofind functionality for a few literals
4080 (Magic._ofind): restored _ofind functionality for a few literals
4069 (those in ["''",'""','[]','{}','()']). But it won't work anymore
4081 (those in ["''",'""','[]','{}','()']). But it won't work anymore
4070 for things like "hello".capitalize?, since that would require a
4082 for things like "hello".capitalize?, since that would require a
4071 potentially dangerous eval() again.
4083 potentially dangerous eval() again.
4072
4084
4073 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
4085 * IPython/iplib.py (InteractiveShell._prefilter): reorganized the
4074 logic a bit more to clean up the escapes handling and minimize the
4086 logic a bit more to clean up the escapes handling and minimize the
4075 use of _ofind to only necessary cases. The interactive 'feel' of
4087 use of _ofind to only necessary cases. The interactive 'feel' of
4076 IPython should have improved quite a bit with the changes in
4088 IPython should have improved quite a bit with the changes in
4077 _prefilter and _ofind (besides being far safer than before).
4089 _prefilter and _ofind (besides being far safer than before).
4078
4090
4079 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
4091 * IPython/Magic.py (Magic.magic_edit): Fixed old bug (but rather
4080 obscure, never reported). Edit would fail to find the object to
4092 obscure, never reported). Edit would fail to find the object to
4081 edit under some circumstances.
4093 edit under some circumstances.
4082 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
4094 (Magic._ofind): CRITICAL FIX. Finally removed the eval() calls
4083 which were causing double-calling of generators. Those eval calls
4095 which were causing double-calling of generators. Those eval calls
4084 were _very_ dangerous, since code with side effects could be
4096 were _very_ dangerous, since code with side effects could be
4085 triggered. As they say, 'eval is evil'... These were the
4097 triggered. As they say, 'eval is evil'... These were the
4086 nastiest evals in IPython. Besides, _ofind is now far simpler,
4098 nastiest evals in IPython. Besides, _ofind is now far simpler,
4087 and it should also be quite a bit faster. Its use of inspect is
4099 and it should also be quite a bit faster. Its use of inspect is
4088 also safer, so perhaps some of the inspect-related crashes I've
4100 also safer, so perhaps some of the inspect-related crashes I've
4089 seen lately with Python 2.3 might be taken care of. That will
4101 seen lately with Python 2.3 might be taken care of. That will
4090 need more testing.
4102 need more testing.
4091
4103
4092 2003-08-17 Fernando Perez <fperez@colorado.edu>
4104 2003-08-17 Fernando Perez <fperez@colorado.edu>
4093
4105
4094 * IPython/iplib.py (InteractiveShell._prefilter): significant
4106 * IPython/iplib.py (InteractiveShell._prefilter): significant
4095 simplifications to the logic for handling user escapes. Faster
4107 simplifications to the logic for handling user escapes. Faster
4096 and simpler code.
4108 and simpler code.
4097
4109
4098 2003-08-14 Fernando Perez <fperez@colorado.edu>
4110 2003-08-14 Fernando Perez <fperez@colorado.edu>
4099
4111
4100 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
4112 * IPython/numutils.py (sum_flat): rewrote to be non-recursive.
4101 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
4113 Now it requires O(N) storage (N=size(a)) for non-contiguous input,
4102 but it should be quite a bit faster. And the recursive version
4114 but it should be quite a bit faster. And the recursive version
4103 generated O(log N) intermediate storage for all rank>1 arrays,
4115 generated O(log N) intermediate storage for all rank>1 arrays,
4104 even if they were contiguous.
4116 even if they were contiguous.
4105 (l1norm): Added this function.
4117 (l1norm): Added this function.
4106 (norm): Added this function for arbitrary norms (including
4118 (norm): Added this function for arbitrary norms (including
4107 l-infinity). l1 and l2 are still special cases for convenience
4119 l-infinity). l1 and l2 are still special cases for convenience
4108 and speed.
4120 and speed.
4109
4121
4110 2003-08-03 Fernando Perez <fperez@colorado.edu>
4122 2003-08-03 Fernando Perez <fperez@colorado.edu>
4111
4123
4112 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
4124 * IPython/Magic.py (Magic.magic_edit): Removed all remaining string
4113 exceptions, which now raise PendingDeprecationWarnings in Python
4125 exceptions, which now raise PendingDeprecationWarnings in Python
4114 2.3. There were some in Magic and some in Gnuplot2.
4126 2.3. There were some in Magic and some in Gnuplot2.
4115
4127
4116 2003-06-30 Fernando Perez <fperez@colorado.edu>
4128 2003-06-30 Fernando Perez <fperez@colorado.edu>
4117
4129
4118 * IPython/genutils.py (page): modified to call curses only for
4130 * IPython/genutils.py (page): modified to call curses only for
4119 terminals where TERM=='xterm'. After problems under many other
4131 terminals where TERM=='xterm'. After problems under many other
4120 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
4132 terminals were reported by Keith Beattie <KSBeattie-AT-lbl.gov>.
4121
4133
4122 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
4134 * IPython/iplib.py (complete): removed spurious 'print "IE"' which
4123 would be triggered when readline was absent. This was just an old
4135 would be triggered when readline was absent. This was just an old
4124 debugging statement I'd forgotten to take out.
4136 debugging statement I'd forgotten to take out.
4125
4137
4126 2003-06-20 Fernando Perez <fperez@colorado.edu>
4138 2003-06-20 Fernando Perez <fperez@colorado.edu>
4127
4139
4128 * IPython/genutils.py (clock): modified to return only user time
4140 * IPython/genutils.py (clock): modified to return only user time
4129 (not counting system time), after a discussion on scipy. While
4141 (not counting system time), after a discussion on scipy. While
4130 system time may be a useful quantity occasionally, it may much
4142 system time may be a useful quantity occasionally, it may much
4131 more easily be skewed by occasional swapping or other similar
4143 more easily be skewed by occasional swapping or other similar
4132 activity.
4144 activity.
4133
4145
4134 2003-06-05 Fernando Perez <fperez@colorado.edu>
4146 2003-06-05 Fernando Perez <fperez@colorado.edu>
4135
4147
4136 * IPython/numutils.py (identity): new function, for building
4148 * IPython/numutils.py (identity): new function, for building
4137 arbitrary rank Kronecker deltas (mostly backwards compatible with
4149 arbitrary rank Kronecker deltas (mostly backwards compatible with
4138 Numeric.identity)
4150 Numeric.identity)
4139
4151
4140 2003-06-03 Fernando Perez <fperez@colorado.edu>
4152 2003-06-03 Fernando Perez <fperez@colorado.edu>
4141
4153
4142 * IPython/iplib.py (InteractiveShell.handle_magic): protect
4154 * IPython/iplib.py (InteractiveShell.handle_magic): protect
4143 arguments passed to magics with spaces, to allow trailing '\' to
4155 arguments passed to magics with spaces, to allow trailing '\' to
4144 work normally (mainly for Windows users).
4156 work normally (mainly for Windows users).
4145
4157
4146 2003-05-29 Fernando Perez <fperez@colorado.edu>
4158 2003-05-29 Fernando Perez <fperez@colorado.edu>
4147
4159
4148 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
4160 * IPython/ipmaker.py (make_IPython): Load site._Helper() as help
4149 instead of pydoc.help. This fixes a bizarre behavior where
4161 instead of pydoc.help. This fixes a bizarre behavior where
4150 printing '%s' % locals() would trigger the help system. Now
4162 printing '%s' % locals() would trigger the help system. Now
4151 ipython behaves like normal python does.
4163 ipython behaves like normal python does.
4152
4164
4153 Note that if one does 'from pydoc import help', the bizarre
4165 Note that if one does 'from pydoc import help', the bizarre
4154 behavior returns, but this will also happen in normal python, so
4166 behavior returns, but this will also happen in normal python, so
4155 it's not an ipython bug anymore (it has to do with how pydoc.help
4167 it's not an ipython bug anymore (it has to do with how pydoc.help
4156 is implemented).
4168 is implemented).
4157
4169
4158 2003-05-22 Fernando Perez <fperez@colorado.edu>
4170 2003-05-22 Fernando Perez <fperez@colorado.edu>
4159
4171
4160 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
4172 * IPython/FlexCompleter.py (Completer.attr_matches): fixed to
4161 return [] instead of None when nothing matches, also match to end
4173 return [] instead of None when nothing matches, also match to end
4162 of line. Patch by Gary Bishop.
4174 of line. Patch by Gary Bishop.
4163
4175
4164 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
4176 * IPython/ipmaker.py (make_IPython): Added same sys.excepthook
4165 protection as before, for files passed on the command line. This
4177 protection as before, for files passed on the command line. This
4166 prevents the CrashHandler from kicking in if user files call into
4178 prevents the CrashHandler from kicking in if user files call into
4167 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
4179 sys.excepthook (such as PyQt and WxWindows have a nasty habit of
4168 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
4180 doing). After a report by Kasper Souren <Kasper.Souren-AT-ircam.fr>
4169
4181
4170 2003-05-20 *** Released version 0.4.0
4182 2003-05-20 *** Released version 0.4.0
4171
4183
4172 2003-05-20 Fernando Perez <fperez@colorado.edu>
4184 2003-05-20 Fernando Perez <fperez@colorado.edu>
4173
4185
4174 * setup.py: added support for manpages. It's a bit hackish b/c of
4186 * setup.py: added support for manpages. It's a bit hackish b/c of
4175 a bug in the way the bdist_rpm distutils target handles gzipped
4187 a bug in the way the bdist_rpm distutils target handles gzipped
4176 manpages, but it works. After a patch by Jack.
4188 manpages, but it works. After a patch by Jack.
4177
4189
4178 2003-05-19 Fernando Perez <fperez@colorado.edu>
4190 2003-05-19 Fernando Perez <fperez@colorado.edu>
4179
4191
4180 * IPython/numutils.py: added a mockup of the kinds module, since
4192 * IPython/numutils.py: added a mockup of the kinds module, since
4181 it was recently removed from Numeric. This way, numutils will
4193 it was recently removed from Numeric. This way, numutils will
4182 work for all users even if they are missing kinds.
4194 work for all users even if they are missing kinds.
4183
4195
4184 * IPython/Magic.py (Magic._ofind): Harden against an inspect
4196 * IPython/Magic.py (Magic._ofind): Harden against an inspect
4185 failure, which can occur with SWIG-wrapped extensions. After a
4197 failure, which can occur with SWIG-wrapped extensions. After a
4186 crash report from Prabhu.
4198 crash report from Prabhu.
4187
4199
4188 2003-05-16 Fernando Perez <fperez@colorado.edu>
4200 2003-05-16 Fernando Perez <fperez@colorado.edu>
4189
4201
4190 * IPython/iplib.py (InteractiveShell.excepthook): New method to
4202 * IPython/iplib.py (InteractiveShell.excepthook): New method to
4191 protect ipython from user code which may call directly
4203 protect ipython from user code which may call directly
4192 sys.excepthook (this looks like an ipython crash to the user, even
4204 sys.excepthook (this looks like an ipython crash to the user, even
4193 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4205 when it isn't). After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4194 This is especially important to help users of WxWindows, but may
4206 This is especially important to help users of WxWindows, but may
4195 also be useful in other cases.
4207 also be useful in other cases.
4196
4208
4197 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
4209 * IPython/ultraTB.py (AutoFormattedTB.__call__): Changed to allow
4198 an optional tb_offset to be specified, and to preserve exception
4210 an optional tb_offset to be specified, and to preserve exception
4199 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4211 info if given. After a patch by Gary Bishop <gb-AT-cs.unc.edu>.
4200
4212
4201 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
4213 * ipython.1 (Default): Thanks to Jack's work, we now have manpages!
4202
4214
4203 2003-05-15 Fernando Perez <fperez@colorado.edu>
4215 2003-05-15 Fernando Perez <fperez@colorado.edu>
4204
4216
4205 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
4217 * IPython/iplib.py (InteractiveShell.user_setup): Fix crash when
4206 installing for a new user under Windows.
4218 installing for a new user under Windows.
4207
4219
4208 2003-05-12 Fernando Perez <fperez@colorado.edu>
4220 2003-05-12 Fernando Perez <fperez@colorado.edu>
4209
4221
4210 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
4222 * IPython/iplib.py (InteractiveShell.handle_emacs): New line
4211 handler for Emacs comint-based lines. Currently it doesn't do
4223 handler for Emacs comint-based lines. Currently it doesn't do
4212 much (but importantly, it doesn't update the history cache). In
4224 much (but importantly, it doesn't update the history cache). In
4213 the future it may be expanded if Alex needs more functionality
4225 the future it may be expanded if Alex needs more functionality
4214 there.
4226 there.
4215
4227
4216 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
4228 * IPython/CrashHandler.py (CrashHandler.__call__): Added platform
4217 info to crash reports.
4229 info to crash reports.
4218
4230
4219 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
4231 * IPython/iplib.py (InteractiveShell.mainloop): Added -c option,
4220 just like Python's -c. Also fixed crash with invalid -color
4232 just like Python's -c. Also fixed crash with invalid -color
4221 option value at startup. Thanks to Will French
4233 option value at startup. Thanks to Will French
4222 <wfrench-AT-bestweb.net> for the bug report.
4234 <wfrench-AT-bestweb.net> for the bug report.
4223
4235
4224 2003-05-09 Fernando Perez <fperez@colorado.edu>
4236 2003-05-09 Fernando Perez <fperez@colorado.edu>
4225
4237
4226 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
4238 * IPython/genutils.py (EvalDict.__getitem__): Renamed EvalString
4227 to EvalDict (it's a mapping, after all) and simplified its code
4239 to EvalDict (it's a mapping, after all) and simplified its code
4228 quite a bit, after a nice discussion on c.l.py where Gustavo
4240 quite a bit, after a nice discussion on c.l.py where Gustavo
4229 Córdova <gcordova-AT-sismex.com> suggested the new version.
4241 Córdova <gcordova-AT-sismex.com> suggested the new version.
4230
4242
4231 2003-04-30 Fernando Perez <fperez@colorado.edu>
4243 2003-04-30 Fernando Perez <fperez@colorado.edu>
4232
4244
4233 * IPython/genutils.py (timings_out): modified it to reduce its
4245 * IPython/genutils.py (timings_out): modified it to reduce its
4234 overhead in the common reps==1 case.
4246 overhead in the common reps==1 case.
4235
4247
4236 2003-04-29 Fernando Perez <fperez@colorado.edu>
4248 2003-04-29 Fernando Perez <fperez@colorado.edu>
4237
4249
4238 * IPython/genutils.py (timings_out): Modified to use the resource
4250 * IPython/genutils.py (timings_out): Modified to use the resource
4239 module, which avoids the wraparound problems of time.clock().
4251 module, which avoids the wraparound problems of time.clock().
4240
4252
4241 2003-04-17 *** Released version 0.2.15pre4
4253 2003-04-17 *** Released version 0.2.15pre4
4242
4254
4243 2003-04-17 Fernando Perez <fperez@colorado.edu>
4255 2003-04-17 Fernando Perez <fperez@colorado.edu>
4244
4256
4245 * setup.py (scriptfiles): Split windows-specific stuff over to a
4257 * setup.py (scriptfiles): Split windows-specific stuff over to a
4246 separate file, in an attempt to have a Windows GUI installer.
4258 separate file, in an attempt to have a Windows GUI installer.
4247 That didn't work, but part of the groundwork is done.
4259 That didn't work, but part of the groundwork is done.
4248
4260
4249 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
4261 * IPython/UserConfig/ipythonrc: Added M-i, M-o and M-I for
4250 indent/unindent with 4 spaces. Particularly useful in combination
4262 indent/unindent with 4 spaces. Particularly useful in combination
4251 with the new auto-indent option.
4263 with the new auto-indent option.
4252
4264
4253 2003-04-16 Fernando Perez <fperez@colorado.edu>
4265 2003-04-16 Fernando Perez <fperez@colorado.edu>
4254
4266
4255 * IPython/Magic.py: various replacements of self.rc for
4267 * IPython/Magic.py: various replacements of self.rc for
4256 self.shell.rc. A lot more remains to be done to fully disentangle
4268 self.shell.rc. A lot more remains to be done to fully disentangle
4257 this class from the main Shell class.
4269 this class from the main Shell class.
4258
4270
4259 * IPython/GnuplotRuntime.py: added checks for mouse support so
4271 * IPython/GnuplotRuntime.py: added checks for mouse support so
4260 that we don't try to enable it if the current gnuplot doesn't
4272 that we don't try to enable it if the current gnuplot doesn't
4261 really support it. Also added checks so that we don't try to
4273 really support it. Also added checks so that we don't try to
4262 enable persist under Windows (where Gnuplot doesn't recognize the
4274 enable persist under Windows (where Gnuplot doesn't recognize the
4263 option).
4275 option).
4264
4276
4265 * IPython/iplib.py (InteractiveShell.interact): Added optional
4277 * IPython/iplib.py (InteractiveShell.interact): Added optional
4266 auto-indenting code, after a patch by King C. Shu
4278 auto-indenting code, after a patch by King C. Shu
4267 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
4279 <kingshu-AT-myrealbox.com>. It's off by default because it doesn't
4268 get along well with pasting indented code. If I ever figure out
4280 get along well with pasting indented code. If I ever figure out
4269 how to make that part go well, it will become on by default.
4281 how to make that part go well, it will become on by default.
4270
4282
4271 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
4283 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixed bug which would
4272 crash ipython if there was an unmatched '%' in the user's prompt
4284 crash ipython if there was an unmatched '%' in the user's prompt
4273 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4285 string. Reported by Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4274
4286
4275 * IPython/iplib.py (InteractiveShell.interact): removed the
4287 * IPython/iplib.py (InteractiveShell.interact): removed the
4276 ability to ask the user whether he wants to crash or not at the
4288 ability to ask the user whether he wants to crash or not at the
4277 'last line' exception handler. Calling functions at that point
4289 'last line' exception handler. Calling functions at that point
4278 changes the stack, and the error reports would have incorrect
4290 changes the stack, and the error reports would have incorrect
4279 tracebacks.
4291 tracebacks.
4280
4292
4281 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
4293 * IPython/Magic.py (Magic.magic_page): Added new @page magic, to
4282 pass through a peger a pretty-printed form of any object. After a
4294 pass through a peger a pretty-printed form of any object. After a
4283 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
4295 contribution by Olivier Aubert <oaubert-AT-bat710.univ-lyon1.fr>
4284
4296
4285 2003-04-14 Fernando Perez <fperez@colorado.edu>
4297 2003-04-14 Fernando Perez <fperez@colorado.edu>
4286
4298
4287 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
4299 * IPython/iplib.py (InteractiveShell.user_setup): Fixed bug where
4288 all files in ~ would be modified at first install (instead of
4300 all files in ~ would be modified at first install (instead of
4289 ~/.ipython). This could be potentially disastrous, as the
4301 ~/.ipython). This could be potentially disastrous, as the
4290 modification (make line-endings native) could damage binary files.
4302 modification (make line-endings native) could damage binary files.
4291
4303
4292 2003-04-10 Fernando Perez <fperez@colorado.edu>
4304 2003-04-10 Fernando Perez <fperez@colorado.edu>
4293
4305
4294 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
4306 * IPython/iplib.py (InteractiveShell.handle_help): Modified to
4295 handle only lines which are invalid python. This now means that
4307 handle only lines which are invalid python. This now means that
4296 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
4308 lines like 'x=1 #?' execute properly. Thanks to Jeffery Collins
4297 for the bug report.
4309 for the bug report.
4298
4310
4299 2003-04-01 Fernando Perez <fperez@colorado.edu>
4311 2003-04-01 Fernando Perez <fperez@colorado.edu>
4300
4312
4301 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
4313 * IPython/iplib.py (InteractiveShell.showtraceback): Fixed bug
4302 where failing to set sys.last_traceback would crash pdb.pm().
4314 where failing to set sys.last_traceback would crash pdb.pm().
4303 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
4315 Thanks to Jeffery D. Collins <Jeff.Collins-AT-vexcel.com> for the bug
4304 report.
4316 report.
4305
4317
4306 2003-03-25 Fernando Perez <fperez@colorado.edu>
4318 2003-03-25 Fernando Perez <fperez@colorado.edu>
4307
4319
4308 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
4320 * IPython/Magic.py (Magic.magic_prun): rstrip() output of profiler
4309 before printing it (it had a lot of spurious blank lines at the
4321 before printing it (it had a lot of spurious blank lines at the
4310 end).
4322 end).
4311
4323
4312 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
4324 * IPython/Gnuplot2.py (Gnuplot.hardcopy): fixed bug where lpr
4313 output would be sent 21 times! Obviously people don't use this
4325 output would be sent 21 times! Obviously people don't use this
4314 too often, or I would have heard about it.
4326 too often, or I would have heard about it.
4315
4327
4316 2003-03-24 Fernando Perez <fperez@colorado.edu>
4328 2003-03-24 Fernando Perez <fperez@colorado.edu>
4317
4329
4318 * setup.py (scriptfiles): renamed the data_files parameter from
4330 * setup.py (scriptfiles): renamed the data_files parameter from
4319 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
4331 'base' to 'data' to fix rpm build issues. Thanks to Ralf Ahlbrink
4320 for the patch.
4332 for the patch.
4321
4333
4322 2003-03-20 Fernando Perez <fperez@colorado.edu>
4334 2003-03-20 Fernando Perez <fperez@colorado.edu>
4323
4335
4324 * IPython/genutils.py (error): added error() and fatal()
4336 * IPython/genutils.py (error): added error() and fatal()
4325 functions.
4337 functions.
4326
4338
4327 2003-03-18 *** Released version 0.2.15pre3
4339 2003-03-18 *** Released version 0.2.15pre3
4328
4340
4329 2003-03-18 Fernando Perez <fperez@colorado.edu>
4341 2003-03-18 Fernando Perez <fperez@colorado.edu>
4330
4342
4331 * setupext/install_data_ext.py
4343 * setupext/install_data_ext.py
4332 (install_data_ext.initialize_options): Class contributed by Jack
4344 (install_data_ext.initialize_options): Class contributed by Jack
4333 Moffit for fixing the old distutils hack. He is sending this to
4345 Moffit for fixing the old distutils hack. He is sending this to
4334 the distutils folks so in the future we may not need it as a
4346 the distutils folks so in the future we may not need it as a
4335 private fix.
4347 private fix.
4336
4348
4337 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
4349 * MANIFEST.in: Extensive reorganization, based on Jack Moffit's
4338 changes for Debian packaging. See his patch for full details.
4350 changes for Debian packaging. See his patch for full details.
4339 The old distutils hack of making the ipythonrc* files carry a
4351 The old distutils hack of making the ipythonrc* files carry a
4340 bogus .py extension is gone, at last. Examples were moved to a
4352 bogus .py extension is gone, at last. Examples were moved to a
4341 separate subdir under doc/, and the separate executable scripts
4353 separate subdir under doc/, and the separate executable scripts
4342 now live in their own directory. Overall a great cleanup. The
4354 now live in their own directory. Overall a great cleanup. The
4343 manual was updated to use the new files, and setup.py has been
4355 manual was updated to use the new files, and setup.py has been
4344 fixed for this setup.
4356 fixed for this setup.
4345
4357
4346 * IPython/PyColorize.py (Parser.usage): made non-executable and
4358 * IPython/PyColorize.py (Parser.usage): made non-executable and
4347 created a pycolor wrapper around it to be included as a script.
4359 created a pycolor wrapper around it to be included as a script.
4348
4360
4349 2003-03-12 *** Released version 0.2.15pre2
4361 2003-03-12 *** Released version 0.2.15pre2
4350
4362
4351 2003-03-12 Fernando Perez <fperez@colorado.edu>
4363 2003-03-12 Fernando Perez <fperez@colorado.edu>
4352
4364
4353 * IPython/ColorANSI.py (make_color_table): Finally fixed the
4365 * IPython/ColorANSI.py (make_color_table): Finally fixed the
4354 long-standing problem with garbage characters in some terminals.
4366 long-standing problem with garbage characters in some terminals.
4355 The issue was really that the \001 and \002 escapes must _only_ be
4367 The issue was really that the \001 and \002 escapes must _only_ be
4356 passed to input prompts (which call readline), but _never_ to
4368 passed to input prompts (which call readline), but _never_ to
4357 normal text to be printed on screen. I changed ColorANSI to have
4369 normal text to be printed on screen. I changed ColorANSI to have
4358 two classes: TermColors and InputTermColors, each with the
4370 two classes: TermColors and InputTermColors, each with the
4359 appropriate escapes for input prompts or normal text. The code in
4371 appropriate escapes for input prompts or normal text. The code in
4360 Prompts.py got slightly more complicated, but this very old and
4372 Prompts.py got slightly more complicated, but this very old and
4361 annoying bug is finally fixed.
4373 annoying bug is finally fixed.
4362
4374
4363 All the credit for nailing down the real origin of this problem
4375 All the credit for nailing down the real origin of this problem
4364 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
4376 and the correct solution goes to Jack Moffit <jack-AT-xiph.org>.
4365 *Many* thanks to him for spending quite a bit of effort on this.
4377 *Many* thanks to him for spending quite a bit of effort on this.
4366
4378
4367 2003-03-05 *** Released version 0.2.15pre1
4379 2003-03-05 *** Released version 0.2.15pre1
4368
4380
4369 2003-03-03 Fernando Perez <fperez@colorado.edu>
4381 2003-03-03 Fernando Perez <fperez@colorado.edu>
4370
4382
4371 * IPython/FakeModule.py: Moved the former _FakeModule to a
4383 * IPython/FakeModule.py: Moved the former _FakeModule to a
4372 separate file, because it's also needed by Magic (to fix a similar
4384 separate file, because it's also needed by Magic (to fix a similar
4373 pickle-related issue in @run).
4385 pickle-related issue in @run).
4374
4386
4375 2003-03-02 Fernando Perez <fperez@colorado.edu>
4387 2003-03-02 Fernando Perez <fperez@colorado.edu>
4376
4388
4377 * IPython/Magic.py (Magic.magic_autocall): new magic to control
4389 * IPython/Magic.py (Magic.magic_autocall): new magic to control
4378 the autocall option at runtime.
4390 the autocall option at runtime.
4379 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
4391 (Magic.magic_dhist): changed self.user_ns to self.shell.user_ns
4380 across Magic.py to start separating Magic from InteractiveShell.
4392 across Magic.py to start separating Magic from InteractiveShell.
4381 (Magic._ofind): Fixed to return proper namespace for dotted
4393 (Magic._ofind): Fixed to return proper namespace for dotted
4382 names. Before, a dotted name would always return 'not currently
4394 names. Before, a dotted name would always return 'not currently
4383 defined', because it would find the 'parent'. s.x would be found,
4395 defined', because it would find the 'parent'. s.x would be found,
4384 but since 'x' isn't defined by itself, it would get confused.
4396 but since 'x' isn't defined by itself, it would get confused.
4385 (Magic.magic_run): Fixed pickling problems reported by Ralf
4397 (Magic.magic_run): Fixed pickling problems reported by Ralf
4386 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
4398 Ahlbrink <RAhlbrink-AT-RosenInspection.net>. The fix was similar to
4387 that I'd used when Mike Heeter reported similar issues at the
4399 that I'd used when Mike Heeter reported similar issues at the
4388 top-level, but now for @run. It boils down to injecting the
4400 top-level, but now for @run. It boils down to injecting the
4389 namespace where code is being executed with something that looks
4401 namespace where code is being executed with something that looks
4390 enough like a module to fool pickle.dump(). Since a pickle stores
4402 enough like a module to fool pickle.dump(). Since a pickle stores
4391 a named reference to the importing module, we need this for
4403 a named reference to the importing module, we need this for
4392 pickles to save something sensible.
4404 pickles to save something sensible.
4393
4405
4394 * IPython/ipmaker.py (make_IPython): added an autocall option.
4406 * IPython/ipmaker.py (make_IPython): added an autocall option.
4395
4407
4396 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
4408 * IPython/iplib.py (InteractiveShell._prefilter): reordered all of
4397 the auto-eval code. Now autocalling is an option, and the code is
4409 the auto-eval code. Now autocalling is an option, and the code is
4398 also vastly safer. There is no more eval() involved at all.
4410 also vastly safer. There is no more eval() involved at all.
4399
4411
4400 2003-03-01 Fernando Perez <fperez@colorado.edu>
4412 2003-03-01 Fernando Perez <fperez@colorado.edu>
4401
4413
4402 * IPython/Magic.py (Magic._ofind): Changed interface to return a
4414 * IPython/Magic.py (Magic._ofind): Changed interface to return a
4403 dict with named keys instead of a tuple.
4415 dict with named keys instead of a tuple.
4404
4416
4405 * IPython: Started using CVS for IPython as of 0.2.15pre1.
4417 * IPython: Started using CVS for IPython as of 0.2.15pre1.
4406
4418
4407 * setup.py (make_shortcut): Fixed message about directories
4419 * setup.py (make_shortcut): Fixed message about directories
4408 created during Windows installation (the directories were ok, just
4420 created during Windows installation (the directories were ok, just
4409 the printed message was misleading). Thanks to Chris Liechti
4421 the printed message was misleading). Thanks to Chris Liechti
4410 <cliechti-AT-gmx.net> for the heads up.
4422 <cliechti-AT-gmx.net> for the heads up.
4411
4423
4412 2003-02-21 Fernando Perez <fperez@colorado.edu>
4424 2003-02-21 Fernando Perez <fperez@colorado.edu>
4413
4425
4414 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
4426 * IPython/iplib.py (InteractiveShell._prefilter): Fixed catching
4415 of ValueError exception when checking for auto-execution. This
4427 of ValueError exception when checking for auto-execution. This
4416 one is raised by things like Numeric arrays arr.flat when the
4428 one is raised by things like Numeric arrays arr.flat when the
4417 array is non-contiguous.
4429 array is non-contiguous.
4418
4430
4419 2003-01-31 Fernando Perez <fperez@colorado.edu>
4431 2003-01-31 Fernando Perez <fperez@colorado.edu>
4420
4432
4421 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
4433 * IPython/genutils.py (SystemExec.bq): Fixed bug where bq would
4422 not return any value at all (even though the command would get
4434 not return any value at all (even though the command would get
4423 executed).
4435 executed).
4424 (xsys): Flush stdout right after printing the command to ensure
4436 (xsys): Flush stdout right after printing the command to ensure
4425 proper ordering of commands and command output in the total
4437 proper ordering of commands and command output in the total
4426 output.
4438 output.
4427 (SystemExec/xsys/bq): Switched the names of xsys/bq and
4439 (SystemExec/xsys/bq): Switched the names of xsys/bq and
4428 system/getoutput as defaults. The old ones are kept for
4440 system/getoutput as defaults. The old ones are kept for
4429 compatibility reasons, so no code which uses this library needs
4441 compatibility reasons, so no code which uses this library needs
4430 changing.
4442 changing.
4431
4443
4432 2003-01-27 *** Released version 0.2.14
4444 2003-01-27 *** Released version 0.2.14
4433
4445
4434 2003-01-25 Fernando Perez <fperez@colorado.edu>
4446 2003-01-25 Fernando Perez <fperez@colorado.edu>
4435
4447
4436 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
4448 * IPython/Magic.py (Magic.magic_edit): Fixed problem where
4437 functions defined in previous edit sessions could not be re-edited
4449 functions defined in previous edit sessions could not be re-edited
4438 (because the temp files were immediately removed). Now temp files
4450 (because the temp files were immediately removed). Now temp files
4439 are removed only at IPython's exit.
4451 are removed only at IPython's exit.
4440 (Magic.magic_run): Improved @run to perform shell-like expansions
4452 (Magic.magic_run): Improved @run to perform shell-like expansions
4441 on its arguments (~users and $VARS). With this, @run becomes more
4453 on its arguments (~users and $VARS). With this, @run becomes more
4442 like a normal command-line.
4454 like a normal command-line.
4443
4455
4444 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
4456 * IPython/Shell.py (IPShellEmbed.__call__): Fixed a bunch of small
4445 bugs related to embedding and cleaned up that code. A fairly
4457 bugs related to embedding and cleaned up that code. A fairly
4446 important one was the impossibility to access the global namespace
4458 important one was the impossibility to access the global namespace
4447 through the embedded IPython (only local variables were visible).
4459 through the embedded IPython (only local variables were visible).
4448
4460
4449 2003-01-14 Fernando Perez <fperez@colorado.edu>
4461 2003-01-14 Fernando Perez <fperez@colorado.edu>
4450
4462
4451 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
4463 * IPython/iplib.py (InteractiveShell._prefilter): Fixed
4452 auto-calling to be a bit more conservative. Now it doesn't get
4464 auto-calling to be a bit more conservative. Now it doesn't get
4453 triggered if any of '!=()<>' are in the rest of the input line, to
4465 triggered if any of '!=()<>' are in the rest of the input line, to
4454 allow comparing callables. Thanks to Alex for the heads up.
4466 allow comparing callables. Thanks to Alex for the heads up.
4455
4467
4456 2003-01-07 Fernando Perez <fperez@colorado.edu>
4468 2003-01-07 Fernando Perez <fperez@colorado.edu>
4457
4469
4458 * IPython/genutils.py (page): fixed estimation of the number of
4470 * IPython/genutils.py (page): fixed estimation of the number of
4459 lines in a string to be paged to simply count newlines. This
4471 lines in a string to be paged to simply count newlines. This
4460 prevents over-guessing due to embedded escape sequences. A better
4472 prevents over-guessing due to embedded escape sequences. A better
4461 long-term solution would involve stripping out the control chars
4473 long-term solution would involve stripping out the control chars
4462 for the count, but it's potentially so expensive I just don't
4474 for the count, but it's potentially so expensive I just don't
4463 think it's worth doing.
4475 think it's worth doing.
4464
4476
4465 2002-12-19 *** Released version 0.2.14pre50
4477 2002-12-19 *** Released version 0.2.14pre50
4466
4478
4467 2002-12-19 Fernando Perez <fperez@colorado.edu>
4479 2002-12-19 Fernando Perez <fperez@colorado.edu>
4468
4480
4469 * tools/release (version): Changed release scripts to inform
4481 * tools/release (version): Changed release scripts to inform
4470 Andrea and build a NEWS file with a list of recent changes.
4482 Andrea and build a NEWS file with a list of recent changes.
4471
4483
4472 * IPython/ColorANSI.py (__all__): changed terminal detection
4484 * IPython/ColorANSI.py (__all__): changed terminal detection
4473 code. Seems to work better for xterms without breaking
4485 code. Seems to work better for xterms without breaking
4474 konsole. Will need more testing to determine if WinXP and Mac OSX
4486 konsole. Will need more testing to determine if WinXP and Mac OSX
4475 also work ok.
4487 also work ok.
4476
4488
4477 2002-12-18 *** Released version 0.2.14pre49
4489 2002-12-18 *** Released version 0.2.14pre49
4478
4490
4479 2002-12-18 Fernando Perez <fperez@colorado.edu>
4491 2002-12-18 Fernando Perez <fperez@colorado.edu>
4480
4492
4481 * Docs: added new info about Mac OSX, from Andrea.
4493 * Docs: added new info about Mac OSX, from Andrea.
4482
4494
4483 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
4495 * IPython/Gnuplot2.py (String): Added a String PlotItem class to
4484 allow direct plotting of python strings whose format is the same
4496 allow direct plotting of python strings whose format is the same
4485 of gnuplot data files.
4497 of gnuplot data files.
4486
4498
4487 2002-12-16 Fernando Perez <fperez@colorado.edu>
4499 2002-12-16 Fernando Perez <fperez@colorado.edu>
4488
4500
4489 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
4501 * IPython/iplib.py (InteractiveShell.interact): fixed default (y)
4490 value of exit question to be acknowledged.
4502 value of exit question to be acknowledged.
4491
4503
4492 2002-12-03 Fernando Perez <fperez@colorado.edu>
4504 2002-12-03 Fernando Perez <fperez@colorado.edu>
4493
4505
4494 * IPython/ipmaker.py: removed generators, which had been added
4506 * IPython/ipmaker.py: removed generators, which had been added
4495 by mistake in an earlier debugging run. This was causing trouble
4507 by mistake in an earlier debugging run. This was causing trouble
4496 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
4508 to users of python 2.1.x. Thanks to Abel Daniel <abli-AT-freemail.hu>
4497 for pointing this out.
4509 for pointing this out.
4498
4510
4499 2002-11-17 Fernando Perez <fperez@colorado.edu>
4511 2002-11-17 Fernando Perez <fperez@colorado.edu>
4500
4512
4501 * Manual: updated the Gnuplot section.
4513 * Manual: updated the Gnuplot section.
4502
4514
4503 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
4515 * IPython/GnuplotRuntime.py: refactored a lot all this code, with
4504 a much better split of what goes in Runtime and what goes in
4516 a much better split of what goes in Runtime and what goes in
4505 Interactive.
4517 Interactive.
4506
4518
4507 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
4519 * IPython/ipmaker.py: fixed bug where import_fail_info wasn't
4508 being imported from iplib.
4520 being imported from iplib.
4509
4521
4510 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
4522 * IPython/GnuplotInteractive.py (magic_gpc): renamed @gp to @gpc
4511 for command-passing. Now the global Gnuplot instance is called
4523 for command-passing. Now the global Gnuplot instance is called
4512 'gp' instead of 'g', which was really a far too fragile and
4524 'gp' instead of 'g', which was really a far too fragile and
4513 common name.
4525 common name.
4514
4526
4515 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
4527 * IPython/Gnuplot2.py (eps_fix_bbox): added this to fix broken
4516 bounding boxes generated by Gnuplot for square plots.
4528 bounding boxes generated by Gnuplot for square plots.
4517
4529
4518 * IPython/genutils.py (popkey): new function added. I should
4530 * IPython/genutils.py (popkey): new function added. I should
4519 suggest this on c.l.py as a dict method, it seems useful.
4531 suggest this on c.l.py as a dict method, it seems useful.
4520
4532
4521 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
4533 * IPython/Gnuplot2.py (Gnuplot.plot): Overhauled plot and replot
4522 to transparently handle PostScript generation. MUCH better than
4534 to transparently handle PostScript generation. MUCH better than
4523 the previous plot_eps/replot_eps (which I removed now). The code
4535 the previous plot_eps/replot_eps (which I removed now). The code
4524 is also fairly clean and well documented now (including
4536 is also fairly clean and well documented now (including
4525 docstrings).
4537 docstrings).
4526
4538
4527 2002-11-13 Fernando Perez <fperez@colorado.edu>
4539 2002-11-13 Fernando Perez <fperez@colorado.edu>
4528
4540
4529 * IPython/Magic.py (Magic.magic_edit): fixed docstring
4541 * IPython/Magic.py (Magic.magic_edit): fixed docstring
4530 (inconsistent with options).
4542 (inconsistent with options).
4531
4543
4532 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
4544 * IPython/Gnuplot2.py (Gnuplot.hardcopy): hardcopy had been
4533 manually disabled, I don't know why. Fixed it.
4545 manually disabled, I don't know why. Fixed it.
4534 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
4546 (Gnuplot._plot_eps): added new plot_eps/replot_eps to get directly
4535 eps output.
4547 eps output.
4536
4548
4537 2002-11-12 Fernando Perez <fperez@colorado.edu>
4549 2002-11-12 Fernando Perez <fperez@colorado.edu>
4538
4550
4539 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
4551 * IPython/genutils.py (ask_yes_no): trap EOF and ^C so that they
4540 don't propagate up to caller. Fixes crash reported by François
4552 don't propagate up to caller. Fixes crash reported by François
4541 Pinard.
4553 Pinard.
4542
4554
4543 2002-11-09 Fernando Perez <fperez@colorado.edu>
4555 2002-11-09 Fernando Perez <fperez@colorado.edu>
4544
4556
4545 * IPython/ipmaker.py (make_IPython): fixed problem with writing
4557 * IPython/ipmaker.py (make_IPython): fixed problem with writing
4546 history file for new users.
4558 history file for new users.
4547 (make_IPython): fixed bug where initial install would leave the
4559 (make_IPython): fixed bug where initial install would leave the
4548 user running in the .ipython dir.
4560 user running in the .ipython dir.
4549 (make_IPython): fixed bug where config dir .ipython would be
4561 (make_IPython): fixed bug where config dir .ipython would be
4550 created regardless of the given -ipythondir option. Thanks to Cory
4562 created regardless of the given -ipythondir option. Thanks to Cory
4551 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
4563 Dodt <cdodt-AT-fcoe.k12.ca.us> for the bug report.
4552
4564
4553 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
4565 * IPython/genutils.py (ask_yes_no): new function for asking yes/no
4554 type confirmations. Will need to use it in all of IPython's code
4566 type confirmations. Will need to use it in all of IPython's code
4555 consistently.
4567 consistently.
4556
4568
4557 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
4569 * IPython/CrashHandler.py (CrashHandler.__call__): changed the
4558 context to print 31 lines instead of the default 5. This will make
4570 context to print 31 lines instead of the default 5. This will make
4559 the crash reports extremely detailed in case the problem is in
4571 the crash reports extremely detailed in case the problem is in
4560 libraries I don't have access to.
4572 libraries I don't have access to.
4561
4573
4562 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
4574 * IPython/iplib.py (InteractiveShell.interact): changed the 'last
4563 line of defense' code to still crash, but giving users fair
4575 line of defense' code to still crash, but giving users fair
4564 warning. I don't want internal errors to go unreported: if there's
4576 warning. I don't want internal errors to go unreported: if there's
4565 an internal problem, IPython should crash and generate a full
4577 an internal problem, IPython should crash and generate a full
4566 report.
4578 report.
4567
4579
4568 2002-11-08 Fernando Perez <fperez@colorado.edu>
4580 2002-11-08 Fernando Perez <fperez@colorado.edu>
4569
4581
4570 * IPython/iplib.py (InteractiveShell.interact): added code to trap
4582 * IPython/iplib.py (InteractiveShell.interact): added code to trap
4571 otherwise uncaught exceptions which can appear if people set
4583 otherwise uncaught exceptions which can appear if people set
4572 sys.stdout to something badly broken. Thanks to a crash report
4584 sys.stdout to something badly broken. Thanks to a crash report
4573 from henni-AT-mail.brainbot.com.
4585 from henni-AT-mail.brainbot.com.
4574
4586
4575 2002-11-04 Fernando Perez <fperez@colorado.edu>
4587 2002-11-04 Fernando Perez <fperez@colorado.edu>
4576
4588
4577 * IPython/iplib.py (InteractiveShell.interact): added
4589 * IPython/iplib.py (InteractiveShell.interact): added
4578 __IPYTHON__active to the builtins. It's a flag which goes on when
4590 __IPYTHON__active to the builtins. It's a flag which goes on when
4579 the interaction starts and goes off again when it stops. This
4591 the interaction starts and goes off again when it stops. This
4580 allows embedding code to detect being inside IPython. Before this
4592 allows embedding code to detect being inside IPython. Before this
4581 was done via __IPYTHON__, but that only shows that an IPython
4593 was done via __IPYTHON__, but that only shows that an IPython
4582 instance has been created.
4594 instance has been created.
4583
4595
4584 * IPython/Magic.py (Magic.magic_env): I realized that in a
4596 * IPython/Magic.py (Magic.magic_env): I realized that in a
4585 UserDict, instance.data holds the data as a normal dict. So I
4597 UserDict, instance.data holds the data as a normal dict. So I
4586 modified @env to return os.environ.data instead of rebuilding a
4598 modified @env to return os.environ.data instead of rebuilding a
4587 dict by hand.
4599 dict by hand.
4588
4600
4589 2002-11-02 Fernando Perez <fperez@colorado.edu>
4601 2002-11-02 Fernando Perez <fperez@colorado.edu>
4590
4602
4591 * IPython/genutils.py (warn): changed so that level 1 prints no
4603 * IPython/genutils.py (warn): changed so that level 1 prints no
4592 header. Level 2 is now the default (with 'WARNING' header, as
4604 header. Level 2 is now the default (with 'WARNING' header, as
4593 before). I think I tracked all places where changes were needed in
4605 before). I think I tracked all places where changes were needed in
4594 IPython, but outside code using the old level numbering may have
4606 IPython, but outside code using the old level numbering may have
4595 broken.
4607 broken.
4596
4608
4597 * IPython/iplib.py (InteractiveShell.runcode): added this to
4609 * IPython/iplib.py (InteractiveShell.runcode): added this to
4598 handle the tracebacks in SystemExit traps correctly. The previous
4610 handle the tracebacks in SystemExit traps correctly. The previous
4599 code (through interact) was printing more of the stack than
4611 code (through interact) was printing more of the stack than
4600 necessary, showing IPython internal code to the user.
4612 necessary, showing IPython internal code to the user.
4601
4613
4602 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
4614 * IPython/UserConfig/ipythonrc.py: Made confirm_exit 1 by
4603 default. Now that the default at the confirmation prompt is yes,
4615 default. Now that the default at the confirmation prompt is yes,
4604 it's not so intrusive. François' argument that ipython sessions
4616 it's not so intrusive. François' argument that ipython sessions
4605 tend to be complex enough not to lose them from an accidental C-d,
4617 tend to be complex enough not to lose them from an accidental C-d,
4606 is a valid one.
4618 is a valid one.
4607
4619
4608 * IPython/iplib.py (InteractiveShell.interact): added a
4620 * IPython/iplib.py (InteractiveShell.interact): added a
4609 showtraceback() call to the SystemExit trap, and modified the exit
4621 showtraceback() call to the SystemExit trap, and modified the exit
4610 confirmation to have yes as the default.
4622 confirmation to have yes as the default.
4611
4623
4612 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
4624 * IPython/UserConfig/ipythonrc.py: removed 'session' option from
4613 this file. It's been gone from the code for a long time, this was
4625 this file. It's been gone from the code for a long time, this was
4614 simply leftover junk.
4626 simply leftover junk.
4615
4627
4616 2002-11-01 Fernando Perez <fperez@colorado.edu>
4628 2002-11-01 Fernando Perez <fperez@colorado.edu>
4617
4629
4618 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
4630 * IPython/UserConfig/ipythonrc.py: new confirm_exit option
4619 added. If set, IPython now traps EOF and asks for
4631 added. If set, IPython now traps EOF and asks for
4620 confirmation. After a request by François Pinard.
4632 confirmation. After a request by François Pinard.
4621
4633
4622 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
4634 * IPython/Magic.py (Magic.magic_Exit): New @Exit and @Quit instead
4623 of @abort, and with a new (better) mechanism for handling the
4635 of @abort, and with a new (better) mechanism for handling the
4624 exceptions.
4636 exceptions.
4625
4637
4626 2002-10-27 Fernando Perez <fperez@colorado.edu>
4638 2002-10-27 Fernando Perez <fperez@colorado.edu>
4627
4639
4628 * IPython/usage.py (__doc__): updated the --help information and
4640 * IPython/usage.py (__doc__): updated the --help information and
4629 the ipythonrc file to indicate that -log generates
4641 the ipythonrc file to indicate that -log generates
4630 ./ipython.log. Also fixed the corresponding info in @logstart.
4642 ./ipython.log. Also fixed the corresponding info in @logstart.
4631 This and several other fixes in the manuals thanks to reports by
4643 This and several other fixes in the manuals thanks to reports by
4632 François Pinard <pinard-AT-iro.umontreal.ca>.
4644 François Pinard <pinard-AT-iro.umontreal.ca>.
4633
4645
4634 * IPython/Logger.py (Logger.switch_log): Fixed error message to
4646 * IPython/Logger.py (Logger.switch_log): Fixed error message to
4635 refer to @logstart (instead of @log, which doesn't exist).
4647 refer to @logstart (instead of @log, which doesn't exist).
4636
4648
4637 * IPython/iplib.py (InteractiveShell._prefilter): fixed
4649 * IPython/iplib.py (InteractiveShell._prefilter): fixed
4638 AttributeError crash. Thanks to Christopher Armstrong
4650 AttributeError crash. Thanks to Christopher Armstrong
4639 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
4651 <radix-AT-twistedmatrix.com> for the report/fix. This bug had been
4640 introduced recently (in 0.2.14pre37) with the fix to the eval
4652 introduced recently (in 0.2.14pre37) with the fix to the eval
4641 problem mentioned below.
4653 problem mentioned below.
4642
4654
4643 2002-10-17 Fernando Perez <fperez@colorado.edu>
4655 2002-10-17 Fernando Perez <fperez@colorado.edu>
4644
4656
4645 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
4657 * IPython/ConfigLoader.py (ConfigLoader.load): Fixes for Windows
4646 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
4658 installation. Thanks to Leonardo Santagada <retype-AT-terra.com.br>.
4647
4659
4648 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
4660 * IPython/iplib.py (InteractiveShell._prefilter): Many changes to
4649 this function to fix a problem reported by Alex Schmolck. He saw
4661 this function to fix a problem reported by Alex Schmolck. He saw
4650 it with list comprehensions and generators, which were getting
4662 it with list comprehensions and generators, which were getting
4651 called twice. The real problem was an 'eval' call in testing for
4663 called twice. The real problem was an 'eval' call in testing for
4652 automagic which was evaluating the input line silently.
4664 automagic which was evaluating the input line silently.
4653
4665
4654 This is a potentially very nasty bug, if the input has side
4666 This is a potentially very nasty bug, if the input has side
4655 effects which must not be repeated. The code is much cleaner now,
4667 effects which must not be repeated. The code is much cleaner now,
4656 without any blanket 'except' left and with a regexp test for
4668 without any blanket 'except' left and with a regexp test for
4657 actual function names.
4669 actual function names.
4658
4670
4659 But an eval remains, which I'm not fully comfortable with. I just
4671 But an eval remains, which I'm not fully comfortable with. I just
4660 don't know how to find out if an expression could be a callable in
4672 don't know how to find out if an expression could be a callable in
4661 the user's namespace without doing an eval on the string. However
4673 the user's namespace without doing an eval on the string. However
4662 that string is now much more strictly checked so that no code
4674 that string is now much more strictly checked so that no code
4663 slips by, so the eval should only happen for things that can
4675 slips by, so the eval should only happen for things that can
4664 really be only function/method names.
4676 really be only function/method names.
4665
4677
4666 2002-10-15 Fernando Perez <fperez@colorado.edu>
4678 2002-10-15 Fernando Perez <fperez@colorado.edu>
4667
4679
4668 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
4680 * Updated LyX to 1.2.1 so I can work on the docs again. Added Mac
4669 OSX information to main manual, removed README_Mac_OSX file from
4681 OSX information to main manual, removed README_Mac_OSX file from
4670 distribution. Also updated credits for recent additions.
4682 distribution. Also updated credits for recent additions.
4671
4683
4672 2002-10-10 Fernando Perez <fperez@colorado.edu>
4684 2002-10-10 Fernando Perez <fperez@colorado.edu>
4673
4685
4674 * README_Mac_OSX: Added a README for Mac OSX users for fixing
4686 * README_Mac_OSX: Added a README for Mac OSX users for fixing
4675 terminal-related issues. Many thanks to Andrea Riciputi
4687 terminal-related issues. Many thanks to Andrea Riciputi
4676 <andrea.riciputi-AT-libero.it> for writing it.
4688 <andrea.riciputi-AT-libero.it> for writing it.
4677
4689
4678 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
4690 * IPython/UserConfig/ipythonrc.py: Fixes to various small issues,
4679 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4691 thanks to Thorsten Kampe <thorsten-AT-thorstenkampe.de>.
4680
4692
4681 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
4693 * setup.py (make_shortcut): Fixes for Windows installation. Thanks
4682 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
4694 to Fredrik Kant <fredrik.kant-AT-front.com> and Syver Enstad
4683 <syver-en-AT-online.no> who both submitted patches for this problem.
4695 <syver-en-AT-online.no> who both submitted patches for this problem.
4684
4696
4685 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
4697 * IPython/iplib.py (InteractiveShell.embed_mainloop): Patch for
4686 global embedding to make sure that things don't overwrite user
4698 global embedding to make sure that things don't overwrite user
4687 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
4699 globals accidentally. Thanks to Richard <rxe-AT-renre-europe.com>
4688
4700
4689 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
4701 * IPython/Gnuplot2.py (gp): Patch for Gnuplot.py 1.6
4690 compatibility. Thanks to Hayden Callow
4702 compatibility. Thanks to Hayden Callow
4691 <h.callow-AT-elec.canterbury.ac.nz>
4703 <h.callow-AT-elec.canterbury.ac.nz>
4692
4704
4693 2002-10-04 Fernando Perez <fperez@colorado.edu>
4705 2002-10-04 Fernando Perez <fperez@colorado.edu>
4694
4706
4695 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
4707 * IPython/Gnuplot2.py (PlotItem): Added 'index' option for
4696 Gnuplot.File objects.
4708 Gnuplot.File objects.
4697
4709
4698 2002-07-23 Fernando Perez <fperez@colorado.edu>
4710 2002-07-23 Fernando Perez <fperez@colorado.edu>
4699
4711
4700 * IPython/genutils.py (timing): Added timings() and timing() for
4712 * IPython/genutils.py (timing): Added timings() and timing() for
4701 quick access to the most commonly needed data, the execution
4713 quick access to the most commonly needed data, the execution
4702 times. Old timing() renamed to timings_out().
4714 times. Old timing() renamed to timings_out().
4703
4715
4704 2002-07-18 Fernando Perez <fperez@colorado.edu>
4716 2002-07-18 Fernando Perez <fperez@colorado.edu>
4705
4717
4706 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
4718 * IPython/Shell.py (IPShellEmbed.restore_system_completer): fixed
4707 bug with nested instances disrupting the parent's tab completion.
4719 bug with nested instances disrupting the parent's tab completion.
4708
4720
4709 * IPython/iplib.py (all_completions): Added Alex Schmolck's
4721 * IPython/iplib.py (all_completions): Added Alex Schmolck's
4710 all_completions code to begin the emacs integration.
4722 all_completions code to begin the emacs integration.
4711
4723
4712 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
4724 * IPython/Gnuplot2.py (zip_items): Added optional 'titles'
4713 argument to allow titling individual arrays when plotting.
4725 argument to allow titling individual arrays when plotting.
4714
4726
4715 2002-07-15 Fernando Perez <fperez@colorado.edu>
4727 2002-07-15 Fernando Perez <fperez@colorado.edu>
4716
4728
4717 * setup.py (make_shortcut): changed to retrieve the value of
4729 * setup.py (make_shortcut): changed to retrieve the value of
4718 'Program Files' directory from the registry (this value changes in
4730 'Program Files' directory from the registry (this value changes in
4719 non-english versions of Windows). Thanks to Thomas Fanslau
4731 non-english versions of Windows). Thanks to Thomas Fanslau
4720 <tfanslau-AT-gmx.de> for the report.
4732 <tfanslau-AT-gmx.de> for the report.
4721
4733
4722 2002-07-10 Fernando Perez <fperez@colorado.edu>
4734 2002-07-10 Fernando Perez <fperez@colorado.edu>
4723
4735
4724 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
4736 * IPython/ultraTB.py (VerboseTB.debugger): enabled workaround for
4725 a bug in pdb, which crashes if a line with only whitespace is
4737 a bug in pdb, which crashes if a line with only whitespace is
4726 entered. Bug report submitted to sourceforge.
4738 entered. Bug report submitted to sourceforge.
4727
4739
4728 2002-07-09 Fernando Perez <fperez@colorado.edu>
4740 2002-07-09 Fernando Perez <fperez@colorado.edu>
4729
4741
4730 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
4742 * IPython/ultraTB.py (VerboseTB.nullrepr): fixed rare crash when
4731 reporting exceptions (it's a bug in inspect.py, I just set a
4743 reporting exceptions (it's a bug in inspect.py, I just set a
4732 workaround).
4744 workaround).
4733
4745
4734 2002-07-08 Fernando Perez <fperez@colorado.edu>
4746 2002-07-08 Fernando Perez <fperez@colorado.edu>
4735
4747
4736 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
4748 * IPython/iplib.py (InteractiveShell.__init__): fixed reference to
4737 __IPYTHON__ in __builtins__ to show up in user_ns.
4749 __IPYTHON__ in __builtins__ to show up in user_ns.
4738
4750
4739 2002-07-03 Fernando Perez <fperez@colorado.edu>
4751 2002-07-03 Fernando Perez <fperez@colorado.edu>
4740
4752
4741 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
4753 * IPython/GnuplotInteractive.py (magic_gp_set_default): changed
4742 name from @gp_set_instance to @gp_set_default.
4754 name from @gp_set_instance to @gp_set_default.
4743
4755
4744 * IPython/ipmaker.py (make_IPython): default editor value set to
4756 * IPython/ipmaker.py (make_IPython): default editor value set to
4745 '0' (a string), to match the rc file. Otherwise will crash when
4757 '0' (a string), to match the rc file. Otherwise will crash when
4746 .strip() is called on it.
4758 .strip() is called on it.
4747
4759
4748
4760
4749 2002-06-28 Fernando Perez <fperez@colorado.edu>
4761 2002-06-28 Fernando Perez <fperez@colorado.edu>
4750
4762
4751 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
4763 * IPython/iplib.py (InteractiveShell.safe_execfile): fix importing
4752 of files in current directory when a file is executed via
4764 of files in current directory when a file is executed via
4753 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
4765 @run. Patch also by RA <ralf_ahlbrink-AT-web.de>.
4754
4766
4755 * setup.py (manfiles): fix for rpm builds, submitted by RA
4767 * setup.py (manfiles): fix for rpm builds, submitted by RA
4756 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
4768 <ralf_ahlbrink-AT-web.de>. Now we have RPMs!
4757
4769
4758 * IPython/ipmaker.py (make_IPython): fixed lookup of default
4770 * IPython/ipmaker.py (make_IPython): fixed lookup of default
4759 editor when set to '0'. Problem was, '0' evaluates to True (it's a
4771 editor when set to '0'. Problem was, '0' evaluates to True (it's a
4760 string!). A. Schmolck caught this one.
4772 string!). A. Schmolck caught this one.
4761
4773
4762 2002-06-27 Fernando Perez <fperez@colorado.edu>
4774 2002-06-27 Fernando Perez <fperez@colorado.edu>
4763
4775
4764 * IPython/ipmaker.py (make_IPython): fixed bug when running user
4776 * IPython/ipmaker.py (make_IPython): fixed bug when running user
4765 defined files at the cmd line. __name__ wasn't being set to
4777 defined files at the cmd line. __name__ wasn't being set to
4766 __main__.
4778 __main__.
4767
4779
4768 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
4780 * IPython/Gnuplot2.py (zip_items): improved it so it can plot also
4769 regular lists and tuples besides Numeric arrays.
4781 regular lists and tuples besides Numeric arrays.
4770
4782
4771 * IPython/Prompts.py (CachedOutput.__call__): Added output
4783 * IPython/Prompts.py (CachedOutput.__call__): Added output
4772 supression for input ending with ';'. Similar to Mathematica and
4784 supression for input ending with ';'. Similar to Mathematica and
4773 Matlab. The _* vars and Out[] list are still updated, just like
4785 Matlab. The _* vars and Out[] list are still updated, just like
4774 Mathematica behaves.
4786 Mathematica behaves.
4775
4787
4776 2002-06-25 Fernando Perez <fperez@colorado.edu>
4788 2002-06-25 Fernando Perez <fperez@colorado.edu>
4777
4789
4778 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
4790 * IPython/ConfigLoader.py (ConfigLoader.load): fixed checking of
4779 .ini extensions for profiels under Windows.
4791 .ini extensions for profiels under Windows.
4780
4792
4781 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
4793 * IPython/OInspect.py (Inspector.pinfo): improved alignment of
4782 string form. Fix contributed by Alexander Schmolck
4794 string form. Fix contributed by Alexander Schmolck
4783 <a.schmolck-AT-gmx.net>
4795 <a.schmolck-AT-gmx.net>
4784
4796
4785 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
4797 * IPython/GnuplotRuntime.py (gp_new): new function. Returns a
4786 pre-configured Gnuplot instance.
4798 pre-configured Gnuplot instance.
4787
4799
4788 2002-06-21 Fernando Perez <fperez@colorado.edu>
4800 2002-06-21 Fernando Perez <fperez@colorado.edu>
4789
4801
4790 * IPython/numutils.py (exp_safe): new function, works around the
4802 * IPython/numutils.py (exp_safe): new function, works around the
4791 underflow problems in Numeric.
4803 underflow problems in Numeric.
4792 (log2): New fn. Safe log in base 2: returns exact integer answer
4804 (log2): New fn. Safe log in base 2: returns exact integer answer
4793 for exact integer powers of 2.
4805 for exact integer powers of 2.
4794
4806
4795 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
4807 * IPython/Magic.py (get_py_filename): fixed it not expanding '~'
4796 properly.
4808 properly.
4797
4809
4798 2002-06-20 Fernando Perez <fperez@colorado.edu>
4810 2002-06-20 Fernando Perez <fperez@colorado.edu>
4799
4811
4800 * IPython/genutils.py (timing): new function like
4812 * IPython/genutils.py (timing): new function like
4801 Mathematica's. Similar to time_test, but returns more info.
4813 Mathematica's. Similar to time_test, but returns more info.
4802
4814
4803 2002-06-18 Fernando Perez <fperez@colorado.edu>
4815 2002-06-18 Fernando Perez <fperez@colorado.edu>
4804
4816
4805 * IPython/Magic.py (Magic.magic_save): modified @save and @r
4817 * IPython/Magic.py (Magic.magic_save): modified @save and @r
4806 according to Mike Heeter's suggestions.
4818 according to Mike Heeter's suggestions.
4807
4819
4808 2002-06-16 Fernando Perez <fperez@colorado.edu>
4820 2002-06-16 Fernando Perez <fperez@colorado.edu>
4809
4821
4810 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
4822 * IPython/GnuplotRuntime.py: Massive overhaul to the Gnuplot
4811 system. GnuplotMagic is gone as a user-directory option. New files
4823 system. GnuplotMagic is gone as a user-directory option. New files
4812 make it easier to use all the gnuplot stuff both from external
4824 make it easier to use all the gnuplot stuff both from external
4813 programs as well as from IPython. Had to rewrite part of
4825 programs as well as from IPython. Had to rewrite part of
4814 hardcopy() b/c of a strange bug: often the ps files simply don't
4826 hardcopy() b/c of a strange bug: often the ps files simply don't
4815 get created, and require a repeat of the command (often several
4827 get created, and require a repeat of the command (often several
4816 times).
4828 times).
4817
4829
4818 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
4830 * IPython/ultraTB.py (AutoFormattedTB.__call__): changed to
4819 resolve output channel at call time, so that if sys.stderr has
4831 resolve output channel at call time, so that if sys.stderr has
4820 been redirected by user this gets honored.
4832 been redirected by user this gets honored.
4821
4833
4822 2002-06-13 Fernando Perez <fperez@colorado.edu>
4834 2002-06-13 Fernando Perez <fperez@colorado.edu>
4823
4835
4824 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
4836 * IPython/Shell.py (IPShell.__init__): Changed IPythonShell to
4825 IPShell. Kept a copy with the old names to avoid breaking people's
4837 IPShell. Kept a copy with the old names to avoid breaking people's
4826 embedded code.
4838 embedded code.
4827
4839
4828 * IPython/ipython: simplified it to the bare minimum after
4840 * IPython/ipython: simplified it to the bare minimum after
4829 Holger's suggestions. Added info about how to use it in
4841 Holger's suggestions. Added info about how to use it in
4830 PYTHONSTARTUP.
4842 PYTHONSTARTUP.
4831
4843
4832 * IPython/Shell.py (IPythonShell): changed the options passing
4844 * IPython/Shell.py (IPythonShell): changed the options passing
4833 from a string with funky %s replacements to a straight list. Maybe
4845 from a string with funky %s replacements to a straight list. Maybe
4834 a bit more typing, but it follows sys.argv conventions, so there's
4846 a bit more typing, but it follows sys.argv conventions, so there's
4835 less special-casing to remember.
4847 less special-casing to remember.
4836
4848
4837 2002-06-12 Fernando Perez <fperez@colorado.edu>
4849 2002-06-12 Fernando Perez <fperez@colorado.edu>
4838
4850
4839 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
4851 * IPython/Magic.py (Magic.magic_r): new magic auto-repeat
4840 command. Thanks to a suggestion by Mike Heeter.
4852 command. Thanks to a suggestion by Mike Heeter.
4841 (Magic.magic_pfile): added behavior to look at filenames if given
4853 (Magic.magic_pfile): added behavior to look at filenames if given
4842 arg is not a defined object.
4854 arg is not a defined object.
4843 (Magic.magic_save): New @save function to save code snippets. Also
4855 (Magic.magic_save): New @save function to save code snippets. Also
4844 a Mike Heeter idea.
4856 a Mike Heeter idea.
4845
4857
4846 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
4858 * IPython/UserConfig/GnuplotMagic.py (plot): Improvements to
4847 plot() and replot(). Much more convenient now, especially for
4859 plot() and replot(). Much more convenient now, especially for
4848 interactive use.
4860 interactive use.
4849
4861
4850 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
4862 * IPython/Magic.py (Magic.magic_run): Added .py automatically to
4851 filenames.
4863 filenames.
4852
4864
4853 2002-06-02 Fernando Perez <fperez@colorado.edu>
4865 2002-06-02 Fernando Perez <fperez@colorado.edu>
4854
4866
4855 * IPython/Struct.py (Struct.__init__): modified to admit
4867 * IPython/Struct.py (Struct.__init__): modified to admit
4856 initialization via another struct.
4868 initialization via another struct.
4857
4869
4858 * IPython/genutils.py (SystemExec.__init__): New stateful
4870 * IPython/genutils.py (SystemExec.__init__): New stateful
4859 interface to xsys and bq. Useful for writing system scripts.
4871 interface to xsys and bq. Useful for writing system scripts.
4860
4872
4861 2002-05-30 Fernando Perez <fperez@colorado.edu>
4873 2002-05-30 Fernando Perez <fperez@colorado.edu>
4862
4874
4863 * MANIFEST.in: Changed docfile selection to exclude all the lyx
4875 * MANIFEST.in: Changed docfile selection to exclude all the lyx
4864 documents. This will make the user download smaller (it's getting
4876 documents. This will make the user download smaller (it's getting
4865 too big).
4877 too big).
4866
4878
4867 2002-05-29 Fernando Perez <fperez@colorado.edu>
4879 2002-05-29 Fernando Perez <fperez@colorado.edu>
4868
4880
4869 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
4881 * IPython/iplib.py (_FakeModule.__init__): New class introduced to
4870 fix problems with shelve and pickle. Seems to work, but I don't
4882 fix problems with shelve and pickle. Seems to work, but I don't
4871 know if corner cases break it. Thanks to Mike Heeter
4883 know if corner cases break it. Thanks to Mike Heeter
4872 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
4884 <korora-AT-SDF.LONESTAR.ORG> for the bug reports and test cases.
4873
4885
4874 2002-05-24 Fernando Perez <fperez@colorado.edu>
4886 2002-05-24 Fernando Perez <fperez@colorado.edu>
4875
4887
4876 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
4888 * IPython/Magic.py (Macro.__init__): fixed magics embedded in
4877 macros having broken.
4889 macros having broken.
4878
4890
4879 2002-05-21 Fernando Perez <fperez@colorado.edu>
4891 2002-05-21 Fernando Perez <fperez@colorado.edu>
4880
4892
4881 * IPython/Magic.py (Magic.magic_logstart): fixed recently
4893 * IPython/Magic.py (Magic.magic_logstart): fixed recently
4882 introduced logging bug: all history before logging started was
4894 introduced logging bug: all history before logging started was
4883 being written one character per line! This came from the redesign
4895 being written one character per line! This came from the redesign
4884 of the input history as a special list which slices to strings,
4896 of the input history as a special list which slices to strings,
4885 not to lists.
4897 not to lists.
4886
4898
4887 2002-05-20 Fernando Perez <fperez@colorado.edu>
4899 2002-05-20 Fernando Perez <fperez@colorado.edu>
4888
4900
4889 * IPython/Prompts.py (CachedOutput.__init__): made the color table
4901 * IPython/Prompts.py (CachedOutput.__init__): made the color table
4890 be an attribute of all classes in this module. The design of these
4902 be an attribute of all classes in this module. The design of these
4891 classes needs some serious overhauling.
4903 classes needs some serious overhauling.
4892
4904
4893 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
4905 * IPython/DPyGetOpt.py (DPyGetOpt.setPosixCompliance): fixed bug
4894 which was ignoring '_' in option names.
4906 which was ignoring '_' in option names.
4895
4907
4896 * IPython/ultraTB.py (FormattedTB.__init__): Changed
4908 * IPython/ultraTB.py (FormattedTB.__init__): Changed
4897 'Verbose_novars' to 'Context' and made it the new default. It's a
4909 'Verbose_novars' to 'Context' and made it the new default. It's a
4898 bit more readable and also safer than verbose.
4910 bit more readable and also safer than verbose.
4899
4911
4900 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
4912 * IPython/PyColorize.py (Parser.__call__): Fixed coloring of
4901 triple-quoted strings.
4913 triple-quoted strings.
4902
4914
4903 * IPython/OInspect.py (__all__): new module exposing the object
4915 * IPython/OInspect.py (__all__): new module exposing the object
4904 introspection facilities. Now the corresponding magics are dummy
4916 introspection facilities. Now the corresponding magics are dummy
4905 wrappers around this. Having this module will make it much easier
4917 wrappers around this. Having this module will make it much easier
4906 to put these functions into our modified pdb.
4918 to put these functions into our modified pdb.
4907 This new object inspector system uses the new colorizing module,
4919 This new object inspector system uses the new colorizing module,
4908 so source code and other things are nicely syntax highlighted.
4920 so source code and other things are nicely syntax highlighted.
4909
4921
4910 2002-05-18 Fernando Perez <fperez@colorado.edu>
4922 2002-05-18 Fernando Perez <fperez@colorado.edu>
4911
4923
4912 * IPython/ColorANSI.py: Split the coloring tools into a separate
4924 * IPython/ColorANSI.py: Split the coloring tools into a separate
4913 module so I can use them in other code easier (they were part of
4925 module so I can use them in other code easier (they were part of
4914 ultraTB).
4926 ultraTB).
4915
4927
4916 2002-05-17 Fernando Perez <fperez@colorado.edu>
4928 2002-05-17 Fernando Perez <fperez@colorado.edu>
4917
4929
4918 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4930 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
4919 fixed it to set the global 'g' also to the called instance, as
4931 fixed it to set the global 'g' also to the called instance, as
4920 long as 'g' was still a gnuplot instance (so it doesn't overwrite
4932 long as 'g' was still a gnuplot instance (so it doesn't overwrite
4921 user's 'g' variables).
4933 user's 'g' variables).
4922
4934
4923 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
4935 * IPython/iplib.py (InteractiveShell.__init__): Added In/Out
4924 global variables (aliases to _ih,_oh) so that users which expect
4936 global variables (aliases to _ih,_oh) so that users which expect
4925 In[5] or Out[7] to work aren't unpleasantly surprised.
4937 In[5] or Out[7] to work aren't unpleasantly surprised.
4926 (InputList.__getslice__): new class to allow executing slices of
4938 (InputList.__getslice__): new class to allow executing slices of
4927 input history directly. Very simple class, complements the use of
4939 input history directly. Very simple class, complements the use of
4928 macros.
4940 macros.
4929
4941
4930 2002-05-16 Fernando Perez <fperez@colorado.edu>
4942 2002-05-16 Fernando Perez <fperez@colorado.edu>
4931
4943
4932 * setup.py (docdirbase): make doc directory be just doc/IPython
4944 * setup.py (docdirbase): make doc directory be just doc/IPython
4933 without version numbers, it will reduce clutter for users.
4945 without version numbers, it will reduce clutter for users.
4934
4946
4935 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
4947 * IPython/Magic.py (Magic.magic_run): Add explicit local dict to
4936 execfile call to prevent possible memory leak. See for details:
4948 execfile call to prevent possible memory leak. See for details:
4937 http://mail.python.org/pipermail/python-list/2002-February/088476.html
4949 http://mail.python.org/pipermail/python-list/2002-February/088476.html
4938
4950
4939 2002-05-15 Fernando Perez <fperez@colorado.edu>
4951 2002-05-15 Fernando Perez <fperez@colorado.edu>
4940
4952
4941 * IPython/Magic.py (Magic.magic_psource): made the object
4953 * IPython/Magic.py (Magic.magic_psource): made the object
4942 introspection names be more standard: pdoc, pdef, pfile and
4954 introspection names be more standard: pdoc, pdef, pfile and
4943 psource. They all print/page their output, and it makes
4955 psource. They all print/page their output, and it makes
4944 remembering them easier. Kept old names for compatibility as
4956 remembering them easier. Kept old names for compatibility as
4945 aliases.
4957 aliases.
4946
4958
4947 2002-05-14 Fernando Perez <fperez@colorado.edu>
4959 2002-05-14 Fernando Perez <fperez@colorado.edu>
4948
4960
4949 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
4961 * IPython/UserConfig/GnuplotMagic.py: I think I finally understood
4950 what the mouse problem was. The trick is to use gnuplot with temp
4962 what the mouse problem was. The trick is to use gnuplot with temp
4951 files and NOT with pipes (for data communication), because having
4963 files and NOT with pipes (for data communication), because having
4952 both pipes and the mouse on is bad news.
4964 both pipes and the mouse on is bad news.
4953
4965
4954 2002-05-13 Fernando Perez <fperez@colorado.edu>
4966 2002-05-13 Fernando Perez <fperez@colorado.edu>
4955
4967
4956 * IPython/Magic.py (Magic._ofind): fixed namespace order search
4968 * IPython/Magic.py (Magic._ofind): fixed namespace order search
4957 bug. Information would be reported about builtins even when
4969 bug. Information would be reported about builtins even when
4958 user-defined functions overrode them.
4970 user-defined functions overrode them.
4959
4971
4960 2002-05-11 Fernando Perez <fperez@colorado.edu>
4972 2002-05-11 Fernando Perez <fperez@colorado.edu>
4961
4973
4962 * IPython/__init__.py (__all__): removed FlexCompleter from
4974 * IPython/__init__.py (__all__): removed FlexCompleter from
4963 __all__ so that things don't fail in platforms without readline.
4975 __all__ so that things don't fail in platforms without readline.
4964
4976
4965 2002-05-10 Fernando Perez <fperez@colorado.edu>
4977 2002-05-10 Fernando Perez <fperez@colorado.edu>
4966
4978
4967 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
4979 * IPython/__init__.py (__all__): removed numutils from __all__ b/c
4968 it requires Numeric, effectively making Numeric a dependency for
4980 it requires Numeric, effectively making Numeric a dependency for
4969 IPython.
4981 IPython.
4970
4982
4971 * Released 0.2.13
4983 * Released 0.2.13
4972
4984
4973 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
4985 * IPython/Magic.py (Magic.magic_prun): big overhaul to the
4974 profiler interface. Now all the major options from the profiler
4986 profiler interface. Now all the major options from the profiler
4975 module are directly supported in IPython, both for single
4987 module are directly supported in IPython, both for single
4976 expressions (@prun) and for full programs (@run -p).
4988 expressions (@prun) and for full programs (@run -p).
4977
4989
4978 2002-05-09 Fernando Perez <fperez@colorado.edu>
4990 2002-05-09 Fernando Perez <fperez@colorado.edu>
4979
4991
4980 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
4992 * IPython/Magic.py (Magic.magic_doc): fixed to show docstrings of
4981 magic properly formatted for screen.
4993 magic properly formatted for screen.
4982
4994
4983 * setup.py (make_shortcut): Changed things to put pdf version in
4995 * setup.py (make_shortcut): Changed things to put pdf version in
4984 doc/ instead of doc/manual (had to change lyxport a bit).
4996 doc/ instead of doc/manual (had to change lyxport a bit).
4985
4997
4986 * IPython/Magic.py (Profile.string_stats): made profile runs go
4998 * IPython/Magic.py (Profile.string_stats): made profile runs go
4987 through pager (they are long and a pager allows searching, saving,
4999 through pager (they are long and a pager allows searching, saving,
4988 etc.)
5000 etc.)
4989
5001
4990 2002-05-08 Fernando Perez <fperez@colorado.edu>
5002 2002-05-08 Fernando Perez <fperez@colorado.edu>
4991
5003
4992 * Released 0.2.12
5004 * Released 0.2.12
4993
5005
4994 2002-05-06 Fernando Perez <fperez@colorado.edu>
5006 2002-05-06 Fernando Perez <fperez@colorado.edu>
4995
5007
4996 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
5008 * IPython/Magic.py (Magic.magic_hist): small bug fixed (recently
4997 introduced); 'hist n1 n2' was broken.
5009 introduced); 'hist n1 n2' was broken.
4998 (Magic.magic_pdb): added optional on/off arguments to @pdb
5010 (Magic.magic_pdb): added optional on/off arguments to @pdb
4999 (Magic.magic_run): added option -i to @run, which executes code in
5011 (Magic.magic_run): added option -i to @run, which executes code in
5000 the IPython namespace instead of a clean one. Also added @irun as
5012 the IPython namespace instead of a clean one. Also added @irun as
5001 an alias to @run -i.
5013 an alias to @run -i.
5002
5014
5003 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
5015 * IPython/UserConfig/GnuplotMagic.py (magic_gp_set_instance):
5004 fixed (it didn't really do anything, the namespaces were wrong).
5016 fixed (it didn't really do anything, the namespaces were wrong).
5005
5017
5006 * IPython/Debugger.py (__init__): Added workaround for python 2.1
5018 * IPython/Debugger.py (__init__): Added workaround for python 2.1
5007
5019
5008 * IPython/__init__.py (__all__): Fixed package namespace, now
5020 * IPython/__init__.py (__all__): Fixed package namespace, now
5009 'import IPython' does give access to IPython.<all> as
5021 'import IPython' does give access to IPython.<all> as
5010 expected. Also renamed __release__ to Release.
5022 expected. Also renamed __release__ to Release.
5011
5023
5012 * IPython/Debugger.py (__license__): created new Pdb class which
5024 * IPython/Debugger.py (__license__): created new Pdb class which
5013 functions like a drop-in for the normal pdb.Pdb but does NOT
5025 functions like a drop-in for the normal pdb.Pdb but does NOT
5014 import readline by default. This way it doesn't muck up IPython's
5026 import readline by default. This way it doesn't muck up IPython's
5015 readline handling, and now tab-completion finally works in the
5027 readline handling, and now tab-completion finally works in the
5016 debugger -- sort of. It completes things globally visible, but the
5028 debugger -- sort of. It completes things globally visible, but the
5017 completer doesn't track the stack as pdb walks it. That's a bit
5029 completer doesn't track the stack as pdb walks it. That's a bit
5018 tricky, and I'll have to implement it later.
5030 tricky, and I'll have to implement it later.
5019
5031
5020 2002-05-05 Fernando Perez <fperez@colorado.edu>
5032 2002-05-05 Fernando Perez <fperez@colorado.edu>
5021
5033
5022 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
5034 * IPython/Magic.py (Magic.magic_oinfo): fixed formatting bug for
5023 magic docstrings when printed via ? (explicit \'s were being
5035 magic docstrings when printed via ? (explicit \'s were being
5024 printed).
5036 printed).
5025
5037
5026 * IPython/ipmaker.py (make_IPython): fixed namespace
5038 * IPython/ipmaker.py (make_IPython): fixed namespace
5027 identification bug. Now variables loaded via logs or command-line
5039 identification bug. Now variables loaded via logs or command-line
5028 files are recognized in the interactive namespace by @who.
5040 files are recognized in the interactive namespace by @who.
5029
5041
5030 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
5042 * IPython/iplib.py (InteractiveShell.safe_execfile): Fixed bug in
5031 log replay system stemming from the string form of Structs.
5043 log replay system stemming from the string form of Structs.
5032
5044
5033 * IPython/Magic.py (Macro.__init__): improved macros to properly
5045 * IPython/Magic.py (Macro.__init__): improved macros to properly
5034 handle magic commands in them.
5046 handle magic commands in them.
5035 (Magic.magic_logstart): usernames are now expanded so 'logstart
5047 (Magic.magic_logstart): usernames are now expanded so 'logstart
5036 ~/mylog' now works.
5048 ~/mylog' now works.
5037
5049
5038 * IPython/iplib.py (complete): fixed bug where paths starting with
5050 * IPython/iplib.py (complete): fixed bug where paths starting with
5039 '/' would be completed as magic names.
5051 '/' would be completed as magic names.
5040
5052
5041 2002-05-04 Fernando Perez <fperez@colorado.edu>
5053 2002-05-04 Fernando Perez <fperez@colorado.edu>
5042
5054
5043 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
5055 * IPython/Magic.py (Magic.magic_run): added options -p and -f to
5044 allow running full programs under the profiler's control.
5056 allow running full programs under the profiler's control.
5045
5057
5046 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
5058 * IPython/ultraTB.py (FormattedTB.__init__): Added Verbose_novars
5047 mode to report exceptions verbosely but without formatting
5059 mode to report exceptions verbosely but without formatting
5048 variables. This addresses the issue of ipython 'freezing' (it's
5060 variables. This addresses the issue of ipython 'freezing' (it's
5049 not frozen, but caught in an expensive formatting loop) when huge
5061 not frozen, but caught in an expensive formatting loop) when huge
5050 variables are in the context of an exception.
5062 variables are in the context of an exception.
5051 (VerboseTB.text): Added '--->' markers at line where exception was
5063 (VerboseTB.text): Added '--->' markers at line where exception was
5052 triggered. Much clearer to read, especially in NoColor modes.
5064 triggered. Much clearer to read, especially in NoColor modes.
5053
5065
5054 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
5066 * IPython/Magic.py (Magic.magic_run): bugfix: -n option had been
5055 implemented in reverse when changing to the new parse_options().
5067 implemented in reverse when changing to the new parse_options().
5056
5068
5057 2002-05-03 Fernando Perez <fperez@colorado.edu>
5069 2002-05-03 Fernando Perez <fperez@colorado.edu>
5058
5070
5059 * IPython/Magic.py (Magic.parse_options): new function so that
5071 * IPython/Magic.py (Magic.parse_options): new function so that
5060 magics can parse options easier.
5072 magics can parse options easier.
5061 (Magic.magic_prun): new function similar to profile.run(),
5073 (Magic.magic_prun): new function similar to profile.run(),
5062 suggested by Chris Hart.
5074 suggested by Chris Hart.
5063 (Magic.magic_cd): fixed behavior so that it only changes if
5075 (Magic.magic_cd): fixed behavior so that it only changes if
5064 directory actually is in history.
5076 directory actually is in history.
5065
5077
5066 * IPython/usage.py (__doc__): added information about potential
5078 * IPython/usage.py (__doc__): added information about potential
5067 slowness of Verbose exception mode when there are huge data
5079 slowness of Verbose exception mode when there are huge data
5068 structures to be formatted (thanks to Archie Paulson).
5080 structures to be formatted (thanks to Archie Paulson).
5069
5081
5070 * IPython/ipmaker.py (make_IPython): Changed default logging
5082 * IPython/ipmaker.py (make_IPython): Changed default logging
5071 (when simply called with -log) to use curr_dir/ipython.log in
5083 (when simply called with -log) to use curr_dir/ipython.log in
5072 rotate mode. Fixed crash which was occuring with -log before
5084 rotate mode. Fixed crash which was occuring with -log before
5073 (thanks to Jim Boyle).
5085 (thanks to Jim Boyle).
5074
5086
5075 2002-05-01 Fernando Perez <fperez@colorado.edu>
5087 2002-05-01 Fernando Perez <fperez@colorado.edu>
5076
5088
5077 * Released 0.2.11 for these fixes (mainly the ultraTB one which
5089 * Released 0.2.11 for these fixes (mainly the ultraTB one which
5078 was nasty -- though somewhat of a corner case).
5090 was nasty -- though somewhat of a corner case).
5079
5091
5080 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
5092 * IPython/ultraTB.py (AutoFormattedTB.text): renamed __text to
5081 text (was a bug).
5093 text (was a bug).
5082
5094
5083 2002-04-30 Fernando Perez <fperez@colorado.edu>
5095 2002-04-30 Fernando Perez <fperez@colorado.edu>
5084
5096
5085 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
5097 * IPython/UserConfig/GnuplotMagic.py (magic_gp): Minor fix to add
5086 a print after ^D or ^C from the user so that the In[] prompt
5098 a print after ^D or ^C from the user so that the In[] prompt
5087 doesn't over-run the gnuplot one.
5099 doesn't over-run the gnuplot one.
5088
5100
5089 2002-04-29 Fernando Perez <fperez@colorado.edu>
5101 2002-04-29 Fernando Perez <fperez@colorado.edu>
5090
5102
5091 * Released 0.2.10
5103 * Released 0.2.10
5092
5104
5093 * IPython/__release__.py (version): get date dynamically.
5105 * IPython/__release__.py (version): get date dynamically.
5094
5106
5095 * Misc. documentation updates thanks to Arnd's comments. Also ran
5107 * Misc. documentation updates thanks to Arnd's comments. Also ran
5096 a full spellcheck on the manual (hadn't been done in a while).
5108 a full spellcheck on the manual (hadn't been done in a while).
5097
5109
5098 2002-04-27 Fernando Perez <fperez@colorado.edu>
5110 2002-04-27 Fernando Perez <fperez@colorado.edu>
5099
5111
5100 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
5112 * IPython/Magic.py (Magic.magic_logstart): Fixed bug where
5101 starting a log in mid-session would reset the input history list.
5113 starting a log in mid-session would reset the input history list.
5102
5114
5103 2002-04-26 Fernando Perez <fperez@colorado.edu>
5115 2002-04-26 Fernando Perez <fperez@colorado.edu>
5104
5116
5105 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
5117 * IPython/iplib.py (InteractiveShell.wait): Fixed bug where not
5106 all files were being included in an update. Now anything in
5118 all files were being included in an update. Now anything in
5107 UserConfig that matches [A-Za-z]*.py will go (this excludes
5119 UserConfig that matches [A-Za-z]*.py will go (this excludes
5108 __init__.py)
5120 __init__.py)
5109
5121
5110 2002-04-25 Fernando Perez <fperez@colorado.edu>
5122 2002-04-25 Fernando Perez <fperez@colorado.edu>
5111
5123
5112 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
5124 * IPython/iplib.py (InteractiveShell.__init__): Added __IPYTHON__
5113 to __builtins__ so that any form of embedded or imported code can
5125 to __builtins__ so that any form of embedded or imported code can
5114 test for being inside IPython.
5126 test for being inside IPython.
5115
5127
5116 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
5128 * IPython/UserConfig/GnuplotMagic.py: (magic_gp_set_instance):
5117 changed to GnuplotMagic because it's now an importable module,
5129 changed to GnuplotMagic because it's now an importable module,
5118 this makes the name follow that of the standard Gnuplot module.
5130 this makes the name follow that of the standard Gnuplot module.
5119 GnuplotMagic can now be loaded at any time in mid-session.
5131 GnuplotMagic can now be loaded at any time in mid-session.
5120
5132
5121 2002-04-24 Fernando Perez <fperez@colorado.edu>
5133 2002-04-24 Fernando Perez <fperez@colorado.edu>
5122
5134
5123 * IPython/numutils.py: removed SIUnits. It doesn't properly set
5135 * IPython/numutils.py: removed SIUnits. It doesn't properly set
5124 the globals (IPython has its own namespace) and the
5136 the globals (IPython has its own namespace) and the
5125 PhysicalQuantity stuff is much better anyway.
5137 PhysicalQuantity stuff is much better anyway.
5126
5138
5127 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
5139 * IPython/UserConfig/example-gnuplot.py (g2): Added gnuplot
5128 embedding example to standard user directory for
5140 embedding example to standard user directory for
5129 distribution. Also put it in the manual.
5141 distribution. Also put it in the manual.
5130
5142
5131 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
5143 * IPython/numutils.py (gnuplot_exec): Changed to take a gnuplot
5132 instance as first argument (so it doesn't rely on some obscure
5144 instance as first argument (so it doesn't rely on some obscure
5133 hidden global).
5145 hidden global).
5134
5146
5135 * IPython/UserConfig/ipythonrc.py: put () back in accepted
5147 * IPython/UserConfig/ipythonrc.py: put () back in accepted
5136 delimiters. While it prevents ().TAB from working, it allows
5148 delimiters. While it prevents ().TAB from working, it allows
5137 completions in open (... expressions. This is by far a more common
5149 completions in open (... expressions. This is by far a more common
5138 case.
5150 case.
5139
5151
5140 2002-04-23 Fernando Perez <fperez@colorado.edu>
5152 2002-04-23 Fernando Perez <fperez@colorado.edu>
5141
5153
5142 * IPython/Extensions/InterpreterPasteInput.py: new
5154 * IPython/Extensions/InterpreterPasteInput.py: new
5143 syntax-processing module for pasting lines with >>> or ... at the
5155 syntax-processing module for pasting lines with >>> or ... at the
5144 start.
5156 start.
5145
5157
5146 * IPython/Extensions/PhysicalQ_Interactive.py
5158 * IPython/Extensions/PhysicalQ_Interactive.py
5147 (PhysicalQuantityInteractive.__int__): fixed to work with either
5159 (PhysicalQuantityInteractive.__int__): fixed to work with either
5148 Numeric or math.
5160 Numeric or math.
5149
5161
5150 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
5162 * IPython/UserConfig/ipythonrc-numeric.py: reorganized the
5151 provided profiles. Now we have:
5163 provided profiles. Now we have:
5152 -math -> math module as * and cmath with its own namespace.
5164 -math -> math module as * and cmath with its own namespace.
5153 -numeric -> Numeric as *, plus gnuplot & grace
5165 -numeric -> Numeric as *, plus gnuplot & grace
5154 -physics -> same as before
5166 -physics -> same as before
5155
5167
5156 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
5168 * IPython/Magic.py (Magic.magic_magic): Fixed bug where
5157 user-defined magics wouldn't be found by @magic if they were
5169 user-defined magics wouldn't be found by @magic if they were
5158 defined as class methods. Also cleaned up the namespace search
5170 defined as class methods. Also cleaned up the namespace search
5159 logic and the string building (to use %s instead of many repeated
5171 logic and the string building (to use %s instead of many repeated
5160 string adds).
5172 string adds).
5161
5173
5162 * IPython/UserConfig/example-magic.py (magic_foo): updated example
5174 * IPython/UserConfig/example-magic.py (magic_foo): updated example
5163 of user-defined magics to operate with class methods (cleaner, in
5175 of user-defined magics to operate with class methods (cleaner, in
5164 line with the gnuplot code).
5176 line with the gnuplot code).
5165
5177
5166 2002-04-22 Fernando Perez <fperez@colorado.edu>
5178 2002-04-22 Fernando Perez <fperez@colorado.edu>
5167
5179
5168 * setup.py: updated dependency list so that manual is updated when
5180 * setup.py: updated dependency list so that manual is updated when
5169 all included files change.
5181 all included files change.
5170
5182
5171 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
5183 * IPython/ipmaker.py (make_IPython): Fixed bug which was ignoring
5172 the delimiter removal option (the fix is ugly right now).
5184 the delimiter removal option (the fix is ugly right now).
5173
5185
5174 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
5186 * IPython/UserConfig/ipythonrc-physics.py: simplified not to load
5175 all of the math profile (quicker loading, no conflict between
5187 all of the math profile (quicker loading, no conflict between
5176 g-9.8 and g-gnuplot).
5188 g-9.8 and g-gnuplot).
5177
5189
5178 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
5190 * IPython/CrashHandler.py (CrashHandler.__call__): changed default
5179 name of post-mortem files to IPython_crash_report.txt.
5191 name of post-mortem files to IPython_crash_report.txt.
5180
5192
5181 * Cleanup/update of the docs. Added all the new readline info and
5193 * Cleanup/update of the docs. Added all the new readline info and
5182 formatted all lists as 'real lists'.
5194 formatted all lists as 'real lists'.
5183
5195
5184 * IPython/ipmaker.py (make_IPython): removed now-obsolete
5196 * IPython/ipmaker.py (make_IPython): removed now-obsolete
5185 tab-completion options, since the full readline parse_and_bind is
5197 tab-completion options, since the full readline parse_and_bind is
5186 now accessible.
5198 now accessible.
5187
5199
5188 * IPython/iplib.py (InteractiveShell.init_readline): Changed
5200 * IPython/iplib.py (InteractiveShell.init_readline): Changed
5189 handling of readline options. Now users can specify any string to
5201 handling of readline options. Now users can specify any string to
5190 be passed to parse_and_bind(), as well as the delimiters to be
5202 be passed to parse_and_bind(), as well as the delimiters to be
5191 removed.
5203 removed.
5192 (InteractiveShell.__init__): Added __name__ to the global
5204 (InteractiveShell.__init__): Added __name__ to the global
5193 namespace so that things like Itpl which rely on its existence
5205 namespace so that things like Itpl which rely on its existence
5194 don't crash.
5206 don't crash.
5195 (InteractiveShell._prefilter): Defined the default with a _ so
5207 (InteractiveShell._prefilter): Defined the default with a _ so
5196 that prefilter() is easier to override, while the default one
5208 that prefilter() is easier to override, while the default one
5197 remains available.
5209 remains available.
5198
5210
5199 2002-04-18 Fernando Perez <fperez@colorado.edu>
5211 2002-04-18 Fernando Perez <fperez@colorado.edu>
5200
5212
5201 * Added information about pdb in the docs.
5213 * Added information about pdb in the docs.
5202
5214
5203 2002-04-17 Fernando Perez <fperez@colorado.edu>
5215 2002-04-17 Fernando Perez <fperez@colorado.edu>
5204
5216
5205 * IPython/ipmaker.py (make_IPython): added rc_override option to
5217 * IPython/ipmaker.py (make_IPython): added rc_override option to
5206 allow passing config options at creation time which may override
5218 allow passing config options at creation time which may override
5207 anything set in the config files or command line. This is
5219 anything set in the config files or command line. This is
5208 particularly useful for configuring embedded instances.
5220 particularly useful for configuring embedded instances.
5209
5221
5210 2002-04-15 Fernando Perez <fperez@colorado.edu>
5222 2002-04-15 Fernando Perez <fperez@colorado.edu>
5211
5223
5212 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
5224 * IPython/Logger.py (Logger.log): Fixed a nasty bug which could
5213 crash embedded instances because of the input cache falling out of
5225 crash embedded instances because of the input cache falling out of
5214 sync with the output counter.
5226 sync with the output counter.
5215
5227
5216 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
5228 * IPython/Shell.py (IPythonShellEmbed.__init__): added a debug
5217 mode which calls pdb after an uncaught exception in IPython itself.
5229 mode which calls pdb after an uncaught exception in IPython itself.
5218
5230
5219 2002-04-14 Fernando Perez <fperez@colorado.edu>
5231 2002-04-14 Fernando Perez <fperez@colorado.edu>
5220
5232
5221 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
5233 * IPython/iplib.py (InteractiveShell.showtraceback): pdb mucks up
5222 readline, fix it back after each call.
5234 readline, fix it back after each call.
5223
5235
5224 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
5236 * IPython/ultraTB.py (AutoFormattedTB.__text): made text a private
5225 method to force all access via __call__(), which guarantees that
5237 method to force all access via __call__(), which guarantees that
5226 traceback references are properly deleted.
5238 traceback references are properly deleted.
5227
5239
5228 * IPython/Prompts.py (CachedOutput._display): minor fixes to
5240 * IPython/Prompts.py (CachedOutput._display): minor fixes to
5229 improve printing when pprint is in use.
5241 improve printing when pprint is in use.
5230
5242
5231 2002-04-13 Fernando Perez <fperez@colorado.edu>
5243 2002-04-13 Fernando Perez <fperez@colorado.edu>
5232
5244
5233 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
5245 * IPython/Shell.py (IPythonShellEmbed.__call__): SystemExit
5234 exceptions aren't caught anymore. If the user triggers one, he
5246 exceptions aren't caught anymore. If the user triggers one, he
5235 should know why he's doing it and it should go all the way up,
5247 should know why he's doing it and it should go all the way up,
5236 just like any other exception. So now @abort will fully kill the
5248 just like any other exception. So now @abort will fully kill the
5237 embedded interpreter and the embedding code (unless that happens
5249 embedded interpreter and the embedding code (unless that happens
5238 to catch SystemExit).
5250 to catch SystemExit).
5239
5251
5240 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
5252 * IPython/ultraTB.py (VerboseTB.__init__): added a call_pdb flag
5241 and a debugger() method to invoke the interactive pdb debugger
5253 and a debugger() method to invoke the interactive pdb debugger
5242 after printing exception information. Also added the corresponding
5254 after printing exception information. Also added the corresponding
5243 -pdb option and @pdb magic to control this feature, and updated
5255 -pdb option and @pdb magic to control this feature, and updated
5244 the docs. After a suggestion from Christopher Hart
5256 the docs. After a suggestion from Christopher Hart
5245 (hart-AT-caltech.edu).
5257 (hart-AT-caltech.edu).
5246
5258
5247 2002-04-12 Fernando Perez <fperez@colorado.edu>
5259 2002-04-12 Fernando Perez <fperez@colorado.edu>
5248
5260
5249 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
5261 * IPython/Shell.py (IPythonShellEmbed.__init__): modified to use
5250 the exception handlers defined by the user (not the CrashHandler)
5262 the exception handlers defined by the user (not the CrashHandler)
5251 so that user exceptions don't trigger an ipython bug report.
5263 so that user exceptions don't trigger an ipython bug report.
5252
5264
5253 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
5265 * IPython/ultraTB.py (ColorTB.__init__): made the color scheme
5254 configurable (it should have always been so).
5266 configurable (it should have always been so).
5255
5267
5256 2002-03-26 Fernando Perez <fperez@colorado.edu>
5268 2002-03-26 Fernando Perez <fperez@colorado.edu>
5257
5269
5258 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
5270 * IPython/Shell.py (IPythonShellEmbed.__call__): many changes here
5259 and there to fix embedding namespace issues. This should all be
5271 and there to fix embedding namespace issues. This should all be
5260 done in a more elegant way.
5272 done in a more elegant way.
5261
5273
5262 2002-03-25 Fernando Perez <fperez@colorado.edu>
5274 2002-03-25 Fernando Perez <fperez@colorado.edu>
5263
5275
5264 * IPython/genutils.py (get_home_dir): Try to make it work under
5276 * IPython/genutils.py (get_home_dir): Try to make it work under
5265 win9x also.
5277 win9x also.
5266
5278
5267 2002-03-20 Fernando Perez <fperez@colorado.edu>
5279 2002-03-20 Fernando Perez <fperez@colorado.edu>
5268
5280
5269 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
5281 * IPython/Shell.py (IPythonShellEmbed.__init__): leave
5270 sys.displayhook untouched upon __init__.
5282 sys.displayhook untouched upon __init__.
5271
5283
5272 2002-03-19 Fernando Perez <fperez@colorado.edu>
5284 2002-03-19 Fernando Perez <fperez@colorado.edu>
5273
5285
5274 * Released 0.2.9 (for embedding bug, basically).
5286 * Released 0.2.9 (for embedding bug, basically).
5275
5287
5276 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
5288 * IPython/Shell.py (IPythonShellEmbed.__call__): Trap SystemExit
5277 exceptions so that enclosing shell's state can be restored.
5289 exceptions so that enclosing shell's state can be restored.
5278
5290
5279 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
5291 * Changed magic_gnuplot.py to magic-gnuplot.py to standardize
5280 naming conventions in the .ipython/ dir.
5292 naming conventions in the .ipython/ dir.
5281
5293
5282 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
5294 * IPython/iplib.py (InteractiveShell.init_readline): removed '-'
5283 from delimiters list so filenames with - in them get expanded.
5295 from delimiters list so filenames with - in them get expanded.
5284
5296
5285 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
5297 * IPython/Shell.py (IPythonShellEmbed.__call__): fixed bug with
5286 sys.displayhook not being properly restored after an embedded call.
5298 sys.displayhook not being properly restored after an embedded call.
5287
5299
5288 2002-03-18 Fernando Perez <fperez@colorado.edu>
5300 2002-03-18 Fernando Perez <fperez@colorado.edu>
5289
5301
5290 * Released 0.2.8
5302 * Released 0.2.8
5291
5303
5292 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
5304 * IPython/iplib.py (InteractiveShell.user_setup): fixed bug where
5293 some files weren't being included in a -upgrade.
5305 some files weren't being included in a -upgrade.
5294 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
5306 (InteractiveShell.init_readline): Added 'set show-all-if-ambiguous
5295 on' so that the first tab completes.
5307 on' so that the first tab completes.
5296 (InteractiveShell.handle_magic): fixed bug with spaces around
5308 (InteractiveShell.handle_magic): fixed bug with spaces around
5297 quotes breaking many magic commands.
5309 quotes breaking many magic commands.
5298
5310
5299 * setup.py: added note about ignoring the syntax error messages at
5311 * setup.py: added note about ignoring the syntax error messages at
5300 installation.
5312 installation.
5301
5313
5302 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
5314 * IPython/UserConfig/magic_gnuplot.py (magic_gp): finished
5303 streamlining the gnuplot interface, now there's only one magic @gp.
5315 streamlining the gnuplot interface, now there's only one magic @gp.
5304
5316
5305 2002-03-17 Fernando Perez <fperez@colorado.edu>
5317 2002-03-17 Fernando Perez <fperez@colorado.edu>
5306
5318
5307 * IPython/UserConfig/magic_gnuplot.py: new name for the
5319 * IPython/UserConfig/magic_gnuplot.py: new name for the
5308 example-magic_pm.py file. Much enhanced system, now with a shell
5320 example-magic_pm.py file. Much enhanced system, now with a shell
5309 for communicating directly with gnuplot, one command at a time.
5321 for communicating directly with gnuplot, one command at a time.
5310
5322
5311 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
5323 * IPython/Magic.py (Magic.magic_run): added option -n to prevent
5312 setting __name__=='__main__'.
5324 setting __name__=='__main__'.
5313
5325
5314 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
5326 * IPython/UserConfig/example-magic_pm.py (magic_pm): Added
5315 mini-shell for accessing gnuplot from inside ipython. Should
5327 mini-shell for accessing gnuplot from inside ipython. Should
5316 extend it later for grace access too. Inspired by Arnd's
5328 extend it later for grace access too. Inspired by Arnd's
5317 suggestion.
5329 suggestion.
5318
5330
5319 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
5331 * IPython/iplib.py (InteractiveShell.handle_magic): fixed bug when
5320 calling magic functions with () in their arguments. Thanks to Arnd
5332 calling magic functions with () in their arguments. Thanks to Arnd
5321 Baecker for pointing this to me.
5333 Baecker for pointing this to me.
5322
5334
5323 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
5335 * IPython/numutils.py (sum_flat): fixed bug. Would recurse
5324 infinitely for integer or complex arrays (only worked with floats).
5336 infinitely for integer or complex arrays (only worked with floats).
5325
5337
5326 2002-03-16 Fernando Perez <fperez@colorado.edu>
5338 2002-03-16 Fernando Perez <fperez@colorado.edu>
5327
5339
5328 * setup.py: Merged setup and setup_windows into a single script
5340 * setup.py: Merged setup and setup_windows into a single script
5329 which properly handles things for windows users.
5341 which properly handles things for windows users.
5330
5342
5331 2002-03-15 Fernando Perez <fperez@colorado.edu>
5343 2002-03-15 Fernando Perez <fperez@colorado.edu>
5332
5344
5333 * Big change to the manual: now the magics are all automatically
5345 * Big change to the manual: now the magics are all automatically
5334 documented. This information is generated from their docstrings
5346 documented. This information is generated from their docstrings
5335 and put in a latex file included by the manual lyx file. This way
5347 and put in a latex file included by the manual lyx file. This way
5336 we get always up to date information for the magics. The manual
5348 we get always up to date information for the magics. The manual
5337 now also has proper version information, also auto-synced.
5349 now also has proper version information, also auto-synced.
5338
5350
5339 For this to work, an undocumented --magic_docstrings option was added.
5351 For this to work, an undocumented --magic_docstrings option was added.
5340
5352
5341 2002-03-13 Fernando Perez <fperez@colorado.edu>
5353 2002-03-13 Fernando Perez <fperez@colorado.edu>
5342
5354
5343 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
5355 * IPython/ultraTB.py (TermColors): fixed problem with dark colors
5344 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
5356 under CDE terminals. An explicit ;2 color reset is needed in the escapes.
5345
5357
5346 2002-03-12 Fernando Perez <fperez@colorado.edu>
5358 2002-03-12 Fernando Perez <fperez@colorado.edu>
5347
5359
5348 * IPython/ultraTB.py (TermColors): changed color escapes again to
5360 * IPython/ultraTB.py (TermColors): changed color escapes again to
5349 fix the (old, reintroduced) line-wrapping bug. Basically, if
5361 fix the (old, reintroduced) line-wrapping bug. Basically, if
5350 \001..\002 aren't given in the color escapes, lines get wrapped
5362 \001..\002 aren't given in the color escapes, lines get wrapped
5351 weirdly. But giving those screws up old xterms and emacs terms. So
5363 weirdly. But giving those screws up old xterms and emacs terms. So
5352 I added some logic for emacs terms to be ok, but I can't identify old
5364 I added some logic for emacs terms to be ok, but I can't identify old
5353 xterms separately ($TERM=='xterm' for many terminals, like konsole).
5365 xterms separately ($TERM=='xterm' for many terminals, like konsole).
5354
5366
5355 2002-03-10 Fernando Perez <fperez@colorado.edu>
5367 2002-03-10 Fernando Perez <fperez@colorado.edu>
5356
5368
5357 * IPython/usage.py (__doc__): Various documentation cleanups and
5369 * IPython/usage.py (__doc__): Various documentation cleanups and
5358 updates, both in usage docstrings and in the manual.
5370 updates, both in usage docstrings and in the manual.
5359
5371
5360 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
5372 * IPython/Prompts.py (CachedOutput.set_colors): cleanups for
5361 handling of caching. Set minimum acceptabe value for having a
5373 handling of caching. Set minimum acceptabe value for having a
5362 cache at 20 values.
5374 cache at 20 values.
5363
5375
5364 * IPython/iplib.py (InteractiveShell.user_setup): moved the
5376 * IPython/iplib.py (InteractiveShell.user_setup): moved the
5365 install_first_time function to a method, renamed it and added an
5377 install_first_time function to a method, renamed it and added an
5366 'upgrade' mode. Now people can update their config directory with
5378 'upgrade' mode. Now people can update their config directory with
5367 a simple command line switch (-upgrade, also new).
5379 a simple command line switch (-upgrade, also new).
5368
5380
5369 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
5381 * IPython/Magic.py (Magic.magic_pfile): Made @pfile an alias to
5370 @file (convenient for automagic users under Python >= 2.2).
5382 @file (convenient for automagic users under Python >= 2.2).
5371 Removed @files (it seemed more like a plural than an abbrev. of
5383 Removed @files (it seemed more like a plural than an abbrev. of
5372 'file show').
5384 'file show').
5373
5385
5374 * IPython/iplib.py (install_first_time): Fixed crash if there were
5386 * IPython/iplib.py (install_first_time): Fixed crash if there were
5375 backup files ('~') in .ipython/ install directory.
5387 backup files ('~') in .ipython/ install directory.
5376
5388
5377 * IPython/ipmaker.py (make_IPython): fixes for new prompt
5389 * IPython/ipmaker.py (make_IPython): fixes for new prompt
5378 system. Things look fine, but these changes are fairly
5390 system. Things look fine, but these changes are fairly
5379 intrusive. Test them for a few days.
5391 intrusive. Test them for a few days.
5380
5392
5381 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
5393 * IPython/Prompts.py (CachedOutput.__init__): Massive rewrite of
5382 the prompts system. Now all in/out prompt strings are user
5394 the prompts system. Now all in/out prompt strings are user
5383 controllable. This is particularly useful for embedding, as one
5395 controllable. This is particularly useful for embedding, as one
5384 can tag embedded instances with particular prompts.
5396 can tag embedded instances with particular prompts.
5385
5397
5386 Also removed global use of sys.ps1/2, which now allows nested
5398 Also removed global use of sys.ps1/2, which now allows nested
5387 embeddings without any problems. Added command-line options for
5399 embeddings without any problems. Added command-line options for
5388 the prompt strings.
5400 the prompt strings.
5389
5401
5390 2002-03-08 Fernando Perez <fperez@colorado.edu>
5402 2002-03-08 Fernando Perez <fperez@colorado.edu>
5391
5403
5392 * IPython/UserConfig/example-embed-short.py (ipshell): added
5404 * IPython/UserConfig/example-embed-short.py (ipshell): added
5393 example file with the bare minimum code for embedding.
5405 example file with the bare minimum code for embedding.
5394
5406
5395 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
5407 * IPython/Shell.py (IPythonShellEmbed.set_dummy_mode): added
5396 functionality for the embeddable shell to be activated/deactivated
5408 functionality for the embeddable shell to be activated/deactivated
5397 either globally or at each call.
5409 either globally or at each call.
5398
5410
5399 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
5411 * IPython/Prompts.py (Prompt1.auto_rewrite): Fixes the problem of
5400 rewriting the prompt with '--->' for auto-inputs with proper
5412 rewriting the prompt with '--->' for auto-inputs with proper
5401 coloring. Now the previous UGLY hack in handle_auto() is gone, and
5413 coloring. Now the previous UGLY hack in handle_auto() is gone, and
5402 this is handled by the prompts class itself, as it should.
5414 this is handled by the prompts class itself, as it should.
5403
5415
5404 2002-03-05 Fernando Perez <fperez@colorado.edu>
5416 2002-03-05 Fernando Perez <fperez@colorado.edu>
5405
5417
5406 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
5418 * IPython/Magic.py (Magic.magic_logstart): Changed @log to
5407 @logstart to avoid name clashes with the math log function.
5419 @logstart to avoid name clashes with the math log function.
5408
5420
5409 * Big updates to X/Emacs section of the manual.
5421 * Big updates to X/Emacs section of the manual.
5410
5422
5411 * Removed ipython_emacs. Milan explained to me how to pass
5423 * Removed ipython_emacs. Milan explained to me how to pass
5412 arguments to ipython through Emacs. Some day I'm going to end up
5424 arguments to ipython through Emacs. Some day I'm going to end up
5413 learning some lisp...
5425 learning some lisp...
5414
5426
5415 2002-03-04 Fernando Perez <fperez@colorado.edu>
5427 2002-03-04 Fernando Perez <fperez@colorado.edu>
5416
5428
5417 * IPython/ipython_emacs: Created script to be used as the
5429 * IPython/ipython_emacs: Created script to be used as the
5418 py-python-command Emacs variable so we can pass IPython
5430 py-python-command Emacs variable so we can pass IPython
5419 parameters. I can't figure out how to tell Emacs directly to pass
5431 parameters. I can't figure out how to tell Emacs directly to pass
5420 parameters to IPython, so a dummy shell script will do it.
5432 parameters to IPython, so a dummy shell script will do it.
5421
5433
5422 Other enhancements made for things to work better under Emacs'
5434 Other enhancements made for things to work better under Emacs'
5423 various types of terminals. Many thanks to Milan Zamazal
5435 various types of terminals. Many thanks to Milan Zamazal
5424 <pdm-AT-zamazal.org> for all the suggestions and pointers.
5436 <pdm-AT-zamazal.org> for all the suggestions and pointers.
5425
5437
5426 2002-03-01 Fernando Perez <fperez@colorado.edu>
5438 2002-03-01 Fernando Perez <fperez@colorado.edu>
5427
5439
5428 * IPython/ipmaker.py (make_IPython): added a --readline! option so
5440 * IPython/ipmaker.py (make_IPython): added a --readline! option so
5429 that loading of readline is now optional. This gives better
5441 that loading of readline is now optional. This gives better
5430 control to emacs users.
5442 control to emacs users.
5431
5443
5432 * IPython/ultraTB.py (__date__): Modified color escape sequences
5444 * IPython/ultraTB.py (__date__): Modified color escape sequences
5433 and now things work fine under xterm and in Emacs' term buffers
5445 and now things work fine under xterm and in Emacs' term buffers
5434 (though not shell ones). Well, in emacs you get colors, but all
5446 (though not shell ones). Well, in emacs you get colors, but all
5435 seem to be 'light' colors (no difference between dark and light
5447 seem to be 'light' colors (no difference between dark and light
5436 ones). But the garbage chars are gone, and also in xterms. It
5448 ones). But the garbage chars are gone, and also in xterms. It
5437 seems that now I'm using 'cleaner' ansi sequences.
5449 seems that now I'm using 'cleaner' ansi sequences.
5438
5450
5439 2002-02-21 Fernando Perez <fperez@colorado.edu>
5451 2002-02-21 Fernando Perez <fperez@colorado.edu>
5440
5452
5441 * Released 0.2.7 (mainly to publish the scoping fix).
5453 * Released 0.2.7 (mainly to publish the scoping fix).
5442
5454
5443 * IPython/Logger.py (Logger.logstate): added. A corresponding
5455 * IPython/Logger.py (Logger.logstate): added. A corresponding
5444 @logstate magic was created.
5456 @logstate magic was created.
5445
5457
5446 * IPython/Magic.py: fixed nested scoping problem under Python
5458 * IPython/Magic.py: fixed nested scoping problem under Python
5447 2.1.x (automagic wasn't working).
5459 2.1.x (automagic wasn't working).
5448
5460
5449 2002-02-20 Fernando Perez <fperez@colorado.edu>
5461 2002-02-20 Fernando Perez <fperez@colorado.edu>
5450
5462
5451 * Released 0.2.6.
5463 * Released 0.2.6.
5452
5464
5453 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
5465 * IPython/OutputTrap.py (OutputTrap.__init__): added a 'quiet'
5454 option so that logs can come out without any headers at all.
5466 option so that logs can come out without any headers at all.
5455
5467
5456 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
5468 * IPython/UserConfig/ipythonrc-scipy.py: created a profile for
5457 SciPy.
5469 SciPy.
5458
5470
5459 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
5471 * IPython/iplib.py (InteractiveShell.embed_mainloop): Changed so
5460 that embedded IPython calls don't require vars() to be explicitly
5472 that embedded IPython calls don't require vars() to be explicitly
5461 passed. Now they are extracted from the caller's frame (code
5473 passed. Now they are extracted from the caller's frame (code
5462 snatched from Eric Jones' weave). Added better documentation to
5474 snatched from Eric Jones' weave). Added better documentation to
5463 the section on embedding and the example file.
5475 the section on embedding and the example file.
5464
5476
5465 * IPython/genutils.py (page): Changed so that under emacs, it just
5477 * IPython/genutils.py (page): Changed so that under emacs, it just
5466 prints the string. You can then page up and down in the emacs
5478 prints the string. You can then page up and down in the emacs
5467 buffer itself. This is how the builtin help() works.
5479 buffer itself. This is how the builtin help() works.
5468
5480
5469 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
5481 * IPython/Prompts.py (CachedOutput.__call__): Fixed issue with
5470 macro scoping: macros need to be executed in the user's namespace
5482 macro scoping: macros need to be executed in the user's namespace
5471 to work as if they had been typed by the user.
5483 to work as if they had been typed by the user.
5472
5484
5473 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
5485 * IPython/Magic.py (Magic.magic_macro): Changed macros so they
5474 execute automatically (no need to type 'exec...'). They then
5486 execute automatically (no need to type 'exec...'). They then
5475 behave like 'true macros'. The printing system was also modified
5487 behave like 'true macros'. The printing system was also modified
5476 for this to work.
5488 for this to work.
5477
5489
5478 2002-02-19 Fernando Perez <fperez@colorado.edu>
5490 2002-02-19 Fernando Perez <fperez@colorado.edu>
5479
5491
5480 * IPython/genutils.py (page_file): new function for paging files
5492 * IPython/genutils.py (page_file): new function for paging files
5481 in an OS-independent way. Also necessary for file viewing to work
5493 in an OS-independent way. Also necessary for file viewing to work
5482 well inside Emacs buffers.
5494 well inside Emacs buffers.
5483 (page): Added checks for being in an emacs buffer.
5495 (page): Added checks for being in an emacs buffer.
5484 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
5496 (page): fixed bug for Windows ($TERM isn't set in Windows). Fixed
5485 same bug in iplib.
5497 same bug in iplib.
5486
5498
5487 2002-02-18 Fernando Perez <fperez@colorado.edu>
5499 2002-02-18 Fernando Perez <fperez@colorado.edu>
5488
5500
5489 * IPython/iplib.py (InteractiveShell.init_readline): modified use
5501 * IPython/iplib.py (InteractiveShell.init_readline): modified use
5490 of readline so that IPython can work inside an Emacs buffer.
5502 of readline so that IPython can work inside an Emacs buffer.
5491
5503
5492 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
5504 * IPython/ultraTB.py (AutoFormattedTB.__call__): some fixes to
5493 method signatures (they weren't really bugs, but it looks cleaner
5505 method signatures (they weren't really bugs, but it looks cleaner
5494 and keeps PyChecker happy).
5506 and keeps PyChecker happy).
5495
5507
5496 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
5508 * IPython/ipmaker.py (make_IPython): added hooks Struct to __IP
5497 for implementing various user-defined hooks. Currently only
5509 for implementing various user-defined hooks. Currently only
5498 display is done.
5510 display is done.
5499
5511
5500 * IPython/Prompts.py (CachedOutput._display): changed display
5512 * IPython/Prompts.py (CachedOutput._display): changed display
5501 functions so that they can be dynamically changed by users easily.
5513 functions so that they can be dynamically changed by users easily.
5502
5514
5503 * IPython/Extensions/numeric_formats.py (num_display): added an
5515 * IPython/Extensions/numeric_formats.py (num_display): added an
5504 extension for printing NumPy arrays in flexible manners. It
5516 extension for printing NumPy arrays in flexible manners. It
5505 doesn't do anything yet, but all the structure is in
5517 doesn't do anything yet, but all the structure is in
5506 place. Ultimately the plan is to implement output format control
5518 place. Ultimately the plan is to implement output format control
5507 like in Octave.
5519 like in Octave.
5508
5520
5509 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
5521 * IPython/Magic.py (Magic.lsmagic): changed so that bound magic
5510 methods are found at run-time by all the automatic machinery.
5522 methods are found at run-time by all the automatic machinery.
5511
5523
5512 2002-02-17 Fernando Perez <fperez@colorado.edu>
5524 2002-02-17 Fernando Perez <fperez@colorado.edu>
5513
5525
5514 * setup_Windows.py (make_shortcut): documented. Cleaned up the
5526 * setup_Windows.py (make_shortcut): documented. Cleaned up the
5515 whole file a little.
5527 whole file a little.
5516
5528
5517 * ToDo: closed this document. Now there's a new_design.lyx
5529 * ToDo: closed this document. Now there's a new_design.lyx
5518 document for all new ideas. Added making a pdf of it for the
5530 document for all new ideas. Added making a pdf of it for the
5519 end-user distro.
5531 end-user distro.
5520
5532
5521 * IPython/Logger.py (Logger.switch_log): Created this to replace
5533 * IPython/Logger.py (Logger.switch_log): Created this to replace
5522 logon() and logoff(). It also fixes a nasty crash reported by
5534 logon() and logoff(). It also fixes a nasty crash reported by
5523 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
5535 Philip Hisley <compsys-AT-starpower.net>. Many thanks to him.
5524
5536
5525 * IPython/iplib.py (complete): got auto-completion to work with
5537 * IPython/iplib.py (complete): got auto-completion to work with
5526 automagic (I had wanted this for a long time).
5538 automagic (I had wanted this for a long time).
5527
5539
5528 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
5540 * IPython/Magic.py (Magic.magic_files): Added @files as an alias
5529 to @file, since file() is now a builtin and clashes with automagic
5541 to @file, since file() is now a builtin and clashes with automagic
5530 for @file.
5542 for @file.
5531
5543
5532 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
5544 * Made some new files: Prompts, CrashHandler, Magic, Logger. All
5533 of this was previously in iplib, which had grown to more than 2000
5545 of this was previously in iplib, which had grown to more than 2000
5534 lines, way too long. No new functionality, but it makes managing
5546 lines, way too long. No new functionality, but it makes managing
5535 the code a bit easier.
5547 the code a bit easier.
5536
5548
5537 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
5549 * IPython/iplib.py (IPythonCrashHandler.__call__): Added version
5538 information to crash reports.
5550 information to crash reports.
5539
5551
5540 2002-02-12 Fernando Perez <fperez@colorado.edu>
5552 2002-02-12 Fernando Perez <fperez@colorado.edu>
5541
5553
5542 * Released 0.2.5.
5554 * Released 0.2.5.
5543
5555
5544 2002-02-11 Fernando Perez <fperez@colorado.edu>
5556 2002-02-11 Fernando Perez <fperez@colorado.edu>
5545
5557
5546 * Wrote a relatively complete Windows installer. It puts
5558 * Wrote a relatively complete Windows installer. It puts
5547 everything in place, creates Start Menu entries and fixes the
5559 everything in place, creates Start Menu entries and fixes the
5548 color issues. Nothing fancy, but it works.
5560 color issues. Nothing fancy, but it works.
5549
5561
5550 2002-02-10 Fernando Perez <fperez@colorado.edu>
5562 2002-02-10 Fernando Perez <fperez@colorado.edu>
5551
5563
5552 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
5564 * IPython/iplib.py (InteractiveShell.safe_execfile): added an
5553 os.path.expanduser() call so that we can type @run ~/myfile.py and
5565 os.path.expanduser() call so that we can type @run ~/myfile.py and
5554 have thigs work as expected.
5566 have thigs work as expected.
5555
5567
5556 * IPython/genutils.py (page): fixed exception handling so things
5568 * IPython/genutils.py (page): fixed exception handling so things
5557 work both in Unix and Windows correctly. Quitting a pager triggers
5569 work both in Unix and Windows correctly. Quitting a pager triggers
5558 an IOError/broken pipe in Unix, and in windows not finding a pager
5570 an IOError/broken pipe in Unix, and in windows not finding a pager
5559 is also an IOError, so I had to actually look at the return value
5571 is also an IOError, so I had to actually look at the return value
5560 of the exception, not just the exception itself. Should be ok now.
5572 of the exception, not just the exception itself. Should be ok now.
5561
5573
5562 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
5574 * IPython/ultraTB.py (ColorSchemeTable.set_active_scheme):
5563 modified to allow case-insensitive color scheme changes.
5575 modified to allow case-insensitive color scheme changes.
5564
5576
5565 2002-02-09 Fernando Perez <fperez@colorado.edu>
5577 2002-02-09 Fernando Perez <fperez@colorado.edu>
5566
5578
5567 * IPython/genutils.py (native_line_ends): new function to leave
5579 * IPython/genutils.py (native_line_ends): new function to leave
5568 user config files with os-native line-endings.
5580 user config files with os-native line-endings.
5569
5581
5570 * README and manual updates.
5582 * README and manual updates.
5571
5583
5572 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
5584 * IPython/genutils.py: fixed unicode bug: use types.StringTypes
5573 instead of StringType to catch Unicode strings.
5585 instead of StringType to catch Unicode strings.
5574
5586
5575 * IPython/genutils.py (filefind): fixed bug for paths with
5587 * IPython/genutils.py (filefind): fixed bug for paths with
5576 embedded spaces (very common in Windows).
5588 embedded spaces (very common in Windows).
5577
5589
5578 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
5590 * IPython/ipmaker.py (make_IPython): added a '.ini' to the rc
5579 files under Windows, so that they get automatically associated
5591 files under Windows, so that they get automatically associated
5580 with a text editor. Windows makes it a pain to handle
5592 with a text editor. Windows makes it a pain to handle
5581 extension-less files.
5593 extension-less files.
5582
5594
5583 * IPython/iplib.py (InteractiveShell.init_readline): Made the
5595 * IPython/iplib.py (InteractiveShell.init_readline): Made the
5584 warning about readline only occur for Posix. In Windows there's no
5596 warning about readline only occur for Posix. In Windows there's no
5585 way to get readline, so why bother with the warning.
5597 way to get readline, so why bother with the warning.
5586
5598
5587 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
5599 * IPython/Struct.py (Struct.__str__): fixed to use self.__dict__
5588 for __str__ instead of dir(self), since dir() changed in 2.2.
5600 for __str__ instead of dir(self), since dir() changed in 2.2.
5589
5601
5590 * Ported to Windows! Tested on XP, I suspect it should work fine
5602 * Ported to Windows! Tested on XP, I suspect it should work fine
5591 on NT/2000, but I don't think it will work on 98 et al. That
5603 on NT/2000, but I don't think it will work on 98 et al. That
5592 series of Windows is such a piece of junk anyway that I won't try
5604 series of Windows is such a piece of junk anyway that I won't try
5593 porting it there. The XP port was straightforward, showed a few
5605 porting it there. The XP port was straightforward, showed a few
5594 bugs here and there (fixed all), in particular some string
5606 bugs here and there (fixed all), in particular some string
5595 handling stuff which required considering Unicode strings (which
5607 handling stuff which required considering Unicode strings (which
5596 Windows uses). This is good, but hasn't been too tested :) No
5608 Windows uses). This is good, but hasn't been too tested :) No
5597 fancy installer yet, I'll put a note in the manual so people at
5609 fancy installer yet, I'll put a note in the manual so people at
5598 least make manually a shortcut.
5610 least make manually a shortcut.
5599
5611
5600 * IPython/iplib.py (Magic.magic_colors): Unified the color options
5612 * IPython/iplib.py (Magic.magic_colors): Unified the color options
5601 into a single one, "colors". This now controls both prompt and
5613 into a single one, "colors". This now controls both prompt and
5602 exception color schemes, and can be changed both at startup
5614 exception color schemes, and can be changed both at startup
5603 (either via command-line switches or via ipythonrc files) and at
5615 (either via command-line switches or via ipythonrc files) and at
5604 runtime, with @colors.
5616 runtime, with @colors.
5605 (Magic.magic_run): renamed @prun to @run and removed the old
5617 (Magic.magic_run): renamed @prun to @run and removed the old
5606 @run. The two were too similar to warrant keeping both.
5618 @run. The two were too similar to warrant keeping both.
5607
5619
5608 2002-02-03 Fernando Perez <fperez@colorado.edu>
5620 2002-02-03 Fernando Perez <fperez@colorado.edu>
5609
5621
5610 * IPython/iplib.py (install_first_time): Added comment on how to
5622 * IPython/iplib.py (install_first_time): Added comment on how to
5611 configure the color options for first-time users. Put a <return>
5623 configure the color options for first-time users. Put a <return>
5612 request at the end so that small-terminal users get a chance to
5624 request at the end so that small-terminal users get a chance to
5613 read the startup info.
5625 read the startup info.
5614
5626
5615 2002-01-23 Fernando Perez <fperez@colorado.edu>
5627 2002-01-23 Fernando Perez <fperez@colorado.edu>
5616
5628
5617 * IPython/iplib.py (CachedOutput.update): Changed output memory
5629 * IPython/iplib.py (CachedOutput.update): Changed output memory
5618 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
5630 variable names from _o,_oo,_ooo,_o<n> to simply _,__,___,_<n>. For
5619 input history we still use _i. Did this b/c these variable are
5631 input history we still use _i. Did this b/c these variable are
5620 very commonly used in interactive work, so the less we need to
5632 very commonly used in interactive work, so the less we need to
5621 type the better off we are.
5633 type the better off we are.
5622 (Magic.magic_prun): updated @prun to better handle the namespaces
5634 (Magic.magic_prun): updated @prun to better handle the namespaces
5623 the file will run in, including a fix for __name__ not being set
5635 the file will run in, including a fix for __name__ not being set
5624 before.
5636 before.
5625
5637
5626 2002-01-20 Fernando Perez <fperez@colorado.edu>
5638 2002-01-20 Fernando Perez <fperez@colorado.edu>
5627
5639
5628 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
5640 * IPython/ultraTB.py (VerboseTB.linereader): Fixed printing of
5629 extra garbage for Python 2.2. Need to look more carefully into
5641 extra garbage for Python 2.2. Need to look more carefully into
5630 this later.
5642 this later.
5631
5643
5632 2002-01-19 Fernando Perez <fperez@colorado.edu>
5644 2002-01-19 Fernando Perez <fperez@colorado.edu>
5633
5645
5634 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
5646 * IPython/iplib.py (InteractiveShell.showtraceback): fixed to
5635 display SyntaxError exceptions properly formatted when they occur
5647 display SyntaxError exceptions properly formatted when they occur
5636 (they can be triggered by imported code).
5648 (they can be triggered by imported code).
5637
5649
5638 2002-01-18 Fernando Perez <fperez@colorado.edu>
5650 2002-01-18 Fernando Perez <fperez@colorado.edu>
5639
5651
5640 * IPython/iplib.py (InteractiveShell.safe_execfile): now
5652 * IPython/iplib.py (InteractiveShell.safe_execfile): now
5641 SyntaxError exceptions are reported nicely formatted, instead of
5653 SyntaxError exceptions are reported nicely formatted, instead of
5642 spitting out only offset information as before.
5654 spitting out only offset information as before.
5643 (Magic.magic_prun): Added the @prun function for executing
5655 (Magic.magic_prun): Added the @prun function for executing
5644 programs with command line args inside IPython.
5656 programs with command line args inside IPython.
5645
5657
5646 2002-01-16 Fernando Perez <fperez@colorado.edu>
5658 2002-01-16 Fernando Perez <fperez@colorado.edu>
5647
5659
5648 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
5660 * IPython/iplib.py (Magic.magic_hist): Changed @hist and @dhist
5649 to *not* include the last item given in a range. This brings their
5661 to *not* include the last item given in a range. This brings their
5650 behavior in line with Python's slicing:
5662 behavior in line with Python's slicing:
5651 a[n1:n2] -> a[n1]...a[n2-1]
5663 a[n1:n2] -> a[n1]...a[n2-1]
5652 It may be a bit less convenient, but I prefer to stick to Python's
5664 It may be a bit less convenient, but I prefer to stick to Python's
5653 conventions *everywhere*, so users never have to wonder.
5665 conventions *everywhere*, so users never have to wonder.
5654 (Magic.magic_macro): Added @macro function to ease the creation of
5666 (Magic.magic_macro): Added @macro function to ease the creation of
5655 macros.
5667 macros.
5656
5668
5657 2002-01-05 Fernando Perez <fperez@colorado.edu>
5669 2002-01-05 Fernando Perez <fperez@colorado.edu>
5658
5670
5659 * Released 0.2.4.
5671 * Released 0.2.4.
5660
5672
5661 * IPython/iplib.py (Magic.magic_pdef):
5673 * IPython/iplib.py (Magic.magic_pdef):
5662 (InteractiveShell.safe_execfile): report magic lines and error
5674 (InteractiveShell.safe_execfile): report magic lines and error
5663 lines without line numbers so one can easily copy/paste them for
5675 lines without line numbers so one can easily copy/paste them for
5664 re-execution.
5676 re-execution.
5665
5677
5666 * Updated manual with recent changes.
5678 * Updated manual with recent changes.
5667
5679
5668 * IPython/iplib.py (Magic.magic_oinfo): added constructor
5680 * IPython/iplib.py (Magic.magic_oinfo): added constructor
5669 docstring printing when class? is called. Very handy for knowing
5681 docstring printing when class? is called. Very handy for knowing
5670 how to create class instances (as long as __init__ is well
5682 how to create class instances (as long as __init__ is well
5671 documented, of course :)
5683 documented, of course :)
5672 (Magic.magic_doc): print both class and constructor docstrings.
5684 (Magic.magic_doc): print both class and constructor docstrings.
5673 (Magic.magic_pdef): give constructor info if passed a class and
5685 (Magic.magic_pdef): give constructor info if passed a class and
5674 __call__ info for callable object instances.
5686 __call__ info for callable object instances.
5675
5687
5676 2002-01-04 Fernando Perez <fperez@colorado.edu>
5688 2002-01-04 Fernando Perez <fperez@colorado.edu>
5677
5689
5678 * Made deep_reload() off by default. It doesn't always work
5690 * Made deep_reload() off by default. It doesn't always work
5679 exactly as intended, so it's probably safer to have it off. It's
5691 exactly as intended, so it's probably safer to have it off. It's
5680 still available as dreload() anyway, so nothing is lost.
5692 still available as dreload() anyway, so nothing is lost.
5681
5693
5682 2002-01-02 Fernando Perez <fperez@colorado.edu>
5694 2002-01-02 Fernando Perez <fperez@colorado.edu>
5683
5695
5684 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
5696 * Released 0.2.3 (contacted R.Singh at CU about biopython course,
5685 so I wanted an updated release).
5697 so I wanted an updated release).
5686
5698
5687 2001-12-27 Fernando Perez <fperez@colorado.edu>
5699 2001-12-27 Fernando Perez <fperez@colorado.edu>
5688
5700
5689 * IPython/iplib.py (InteractiveShell.interact): Added the original
5701 * IPython/iplib.py (InteractiveShell.interact): Added the original
5690 code from 'code.py' for this module in order to change the
5702 code from 'code.py' for this module in order to change the
5691 handling of a KeyboardInterrupt. This was necessary b/c otherwise
5703 handling of a KeyboardInterrupt. This was necessary b/c otherwise
5692 the history cache would break when the user hit Ctrl-C, and
5704 the history cache would break when the user hit Ctrl-C, and
5693 interact() offers no way to add any hooks to it.
5705 interact() offers no way to add any hooks to it.
5694
5706
5695 2001-12-23 Fernando Perez <fperez@colorado.edu>
5707 2001-12-23 Fernando Perez <fperez@colorado.edu>
5696
5708
5697 * setup.py: added check for 'MANIFEST' before trying to remove
5709 * setup.py: added check for 'MANIFEST' before trying to remove
5698 it. Thanks to Sean Reifschneider.
5710 it. Thanks to Sean Reifschneider.
5699
5711
5700 2001-12-22 Fernando Perez <fperez@colorado.edu>
5712 2001-12-22 Fernando Perez <fperez@colorado.edu>
5701
5713
5702 * Released 0.2.2.
5714 * Released 0.2.2.
5703
5715
5704 * Finished (reasonably) writing the manual. Later will add the
5716 * Finished (reasonably) writing the manual. Later will add the
5705 python-standard navigation stylesheets, but for the time being
5717 python-standard navigation stylesheets, but for the time being
5706 it's fairly complete. Distribution will include html and pdf
5718 it's fairly complete. Distribution will include html and pdf
5707 versions.
5719 versions.
5708
5720
5709 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
5721 * Bugfix: '.' wasn't being added to sys.path. Thanks to Prabhu
5710 (MayaVi author).
5722 (MayaVi author).
5711
5723
5712 2001-12-21 Fernando Perez <fperez@colorado.edu>
5724 2001-12-21 Fernando Perez <fperez@colorado.edu>
5713
5725
5714 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
5726 * Released 0.2.1. Barring any nasty bugs, this is it as far as a
5715 good public release, I think (with the manual and the distutils
5727 good public release, I think (with the manual and the distutils
5716 installer). The manual can use some work, but that can go
5728 installer). The manual can use some work, but that can go
5717 slowly. Otherwise I think it's quite nice for end users. Next
5729 slowly. Otherwise I think it's quite nice for end users. Next
5718 summer, rewrite the guts of it...
5730 summer, rewrite the guts of it...
5719
5731
5720 * Changed format of ipythonrc files to use whitespace as the
5732 * Changed format of ipythonrc files to use whitespace as the
5721 separator instead of an explicit '='. Cleaner.
5733 separator instead of an explicit '='. Cleaner.
5722
5734
5723 2001-12-20 Fernando Perez <fperez@colorado.edu>
5735 2001-12-20 Fernando Perez <fperez@colorado.edu>
5724
5736
5725 * Started a manual in LyX. For now it's just a quick merge of the
5737 * Started a manual in LyX. For now it's just a quick merge of the
5726 various internal docstrings and READMEs. Later it may grow into a
5738 various internal docstrings and READMEs. Later it may grow into a
5727 nice, full-blown manual.
5739 nice, full-blown manual.
5728
5740
5729 * Set up a distutils based installer. Installation should now be
5741 * Set up a distutils based installer. Installation should now be
5730 trivially simple for end-users.
5742 trivially simple for end-users.
5731
5743
5732 2001-12-11 Fernando Perez <fperez@colorado.edu>
5744 2001-12-11 Fernando Perez <fperez@colorado.edu>
5733
5745
5734 * Released 0.2.0. First public release, announced it at
5746 * Released 0.2.0. First public release, announced it at
5735 comp.lang.python. From now on, just bugfixes...
5747 comp.lang.python. From now on, just bugfixes...
5736
5748
5737 * Went through all the files, set copyright/license notices and
5749 * Went through all the files, set copyright/license notices and
5738 cleaned up things. Ready for release.
5750 cleaned up things. Ready for release.
5739
5751
5740 2001-12-10 Fernando Perez <fperez@colorado.edu>
5752 2001-12-10 Fernando Perez <fperez@colorado.edu>
5741
5753
5742 * Changed the first-time installer not to use tarfiles. It's more
5754 * Changed the first-time installer not to use tarfiles. It's more
5743 robust now and less unix-dependent. Also makes it easier for
5755 robust now and less unix-dependent. Also makes it easier for
5744 people to later upgrade versions.
5756 people to later upgrade versions.
5745
5757
5746 * Changed @exit to @abort to reflect the fact that it's pretty
5758 * Changed @exit to @abort to reflect the fact that it's pretty
5747 brutal (a sys.exit()). The difference between @abort and Ctrl-D
5759 brutal (a sys.exit()). The difference between @abort and Ctrl-D
5748 becomes significant only when IPyhton is embedded: in that case,
5760 becomes significant only when IPyhton is embedded: in that case,
5749 C-D closes IPython only, but @abort kills the enclosing program
5761 C-D closes IPython only, but @abort kills the enclosing program
5750 too (unless it had called IPython inside a try catching
5762 too (unless it had called IPython inside a try catching
5751 SystemExit).
5763 SystemExit).
5752
5764
5753 * Created Shell module which exposes the actuall IPython Shell
5765 * Created Shell module which exposes the actuall IPython Shell
5754 classes, currently the normal and the embeddable one. This at
5766 classes, currently the normal and the embeddable one. This at
5755 least offers a stable interface we won't need to change when
5767 least offers a stable interface we won't need to change when
5756 (later) the internals are rewritten. That rewrite will be confined
5768 (later) the internals are rewritten. That rewrite will be confined
5757 to iplib and ipmaker, but the Shell interface should remain as is.
5769 to iplib and ipmaker, but the Shell interface should remain as is.
5758
5770
5759 * Added embed module which offers an embeddable IPShell object,
5771 * Added embed module which offers an embeddable IPShell object,
5760 useful to fire up IPython *inside* a running program. Great for
5772 useful to fire up IPython *inside* a running program. Great for
5761 debugging or dynamical data analysis.
5773 debugging or dynamical data analysis.
5762
5774
5763 2001-12-08 Fernando Perez <fperez@colorado.edu>
5775 2001-12-08 Fernando Perez <fperez@colorado.edu>
5764
5776
5765 * Fixed small bug preventing seeing info from methods of defined
5777 * Fixed small bug preventing seeing info from methods of defined
5766 objects (incorrect namespace in _ofind()).
5778 objects (incorrect namespace in _ofind()).
5767
5779
5768 * Documentation cleanup. Moved the main usage docstrings to a
5780 * Documentation cleanup. Moved the main usage docstrings to a
5769 separate file, usage.py (cleaner to maintain, and hopefully in the
5781 separate file, usage.py (cleaner to maintain, and hopefully in the
5770 future some perlpod-like way of producing interactive, man and
5782 future some perlpod-like way of producing interactive, man and
5771 html docs out of it will be found).
5783 html docs out of it will be found).
5772
5784
5773 * Added @profile to see your profile at any time.
5785 * Added @profile to see your profile at any time.
5774
5786
5775 * Added @p as an alias for 'print'. It's especially convenient if
5787 * Added @p as an alias for 'print'. It's especially convenient if
5776 using automagic ('p x' prints x).
5788 using automagic ('p x' prints x).
5777
5789
5778 * Small cleanups and fixes after a pychecker run.
5790 * Small cleanups and fixes after a pychecker run.
5779
5791
5780 * Changed the @cd command to handle @cd - and @cd -<n> for
5792 * Changed the @cd command to handle @cd - and @cd -<n> for
5781 visiting any directory in _dh.
5793 visiting any directory in _dh.
5782
5794
5783 * Introduced _dh, a history of visited directories. @dhist prints
5795 * Introduced _dh, a history of visited directories. @dhist prints
5784 it out with numbers.
5796 it out with numbers.
5785
5797
5786 2001-12-07 Fernando Perez <fperez@colorado.edu>
5798 2001-12-07 Fernando Perez <fperez@colorado.edu>
5787
5799
5788 * Released 0.1.22
5800 * Released 0.1.22
5789
5801
5790 * Made initialization a bit more robust against invalid color
5802 * Made initialization a bit more robust against invalid color
5791 options in user input (exit, not traceback-crash).
5803 options in user input (exit, not traceback-crash).
5792
5804
5793 * Changed the bug crash reporter to write the report only in the
5805 * Changed the bug crash reporter to write the report only in the
5794 user's .ipython directory. That way IPython won't litter people's
5806 user's .ipython directory. That way IPython won't litter people's
5795 hard disks with crash files all over the place. Also print on
5807 hard disks with crash files all over the place. Also print on
5796 screen the necessary mail command.
5808 screen the necessary mail command.
5797
5809
5798 * With the new ultraTB, implemented LightBG color scheme for light
5810 * With the new ultraTB, implemented LightBG color scheme for light
5799 background terminals. A lot of people like white backgrounds, so I
5811 background terminals. A lot of people like white backgrounds, so I
5800 guess we should at least give them something readable.
5812 guess we should at least give them something readable.
5801
5813
5802 2001-12-06 Fernando Perez <fperez@colorado.edu>
5814 2001-12-06 Fernando Perez <fperez@colorado.edu>
5803
5815
5804 * Modified the structure of ultraTB. Now there's a proper class
5816 * Modified the structure of ultraTB. Now there's a proper class
5805 for tables of color schemes which allow adding schemes easily and
5817 for tables of color schemes which allow adding schemes easily and
5806 switching the active scheme without creating a new instance every
5818 switching the active scheme without creating a new instance every
5807 time (which was ridiculous). The syntax for creating new schemes
5819 time (which was ridiculous). The syntax for creating new schemes
5808 is also cleaner. I think ultraTB is finally done, with a clean
5820 is also cleaner. I think ultraTB is finally done, with a clean
5809 class structure. Names are also much cleaner (now there's proper
5821 class structure. Names are also much cleaner (now there's proper
5810 color tables, no need for every variable to also have 'color' in
5822 color tables, no need for every variable to also have 'color' in
5811 its name).
5823 its name).
5812
5824
5813 * Broke down genutils into separate files. Now genutils only
5825 * Broke down genutils into separate files. Now genutils only
5814 contains utility functions, and classes have been moved to their
5826 contains utility functions, and classes have been moved to their
5815 own files (they had enough independent functionality to warrant
5827 own files (they had enough independent functionality to warrant
5816 it): ConfigLoader, OutputTrap, Struct.
5828 it): ConfigLoader, OutputTrap, Struct.
5817
5829
5818 2001-12-05 Fernando Perez <fperez@colorado.edu>
5830 2001-12-05 Fernando Perez <fperez@colorado.edu>
5819
5831
5820 * IPython turns 21! Released version 0.1.21, as a candidate for
5832 * IPython turns 21! Released version 0.1.21, as a candidate for
5821 public consumption. If all goes well, release in a few days.
5833 public consumption. If all goes well, release in a few days.
5822
5834
5823 * Fixed path bug (files in Extensions/ directory wouldn't be found
5835 * Fixed path bug (files in Extensions/ directory wouldn't be found
5824 unless IPython/ was explicitly in sys.path).
5836 unless IPython/ was explicitly in sys.path).
5825
5837
5826 * Extended the FlexCompleter class as MagicCompleter to allow
5838 * Extended the FlexCompleter class as MagicCompleter to allow
5827 completion of @-starting lines.
5839 completion of @-starting lines.
5828
5840
5829 * Created __release__.py file as a central repository for release
5841 * Created __release__.py file as a central repository for release
5830 info that other files can read from.
5842 info that other files can read from.
5831
5843
5832 * Fixed small bug in logging: when logging was turned on in
5844 * Fixed small bug in logging: when logging was turned on in
5833 mid-session, old lines with special meanings (!@?) were being
5845 mid-session, old lines with special meanings (!@?) were being
5834 logged without the prepended comment, which is necessary since
5846 logged without the prepended comment, which is necessary since
5835 they are not truly valid python syntax. This should make session
5847 they are not truly valid python syntax. This should make session
5836 restores produce less errors.
5848 restores produce less errors.
5837
5849
5838 * The namespace cleanup forced me to make a FlexCompleter class
5850 * The namespace cleanup forced me to make a FlexCompleter class
5839 which is nothing but a ripoff of rlcompleter, but with selectable
5851 which is nothing but a ripoff of rlcompleter, but with selectable
5840 namespace (rlcompleter only works in __main__.__dict__). I'll try
5852 namespace (rlcompleter only works in __main__.__dict__). I'll try
5841 to submit a note to the authors to see if this change can be
5853 to submit a note to the authors to see if this change can be
5842 incorporated in future rlcompleter releases (Dec.6: done)
5854 incorporated in future rlcompleter releases (Dec.6: done)
5843
5855
5844 * More fixes to namespace handling. It was a mess! Now all
5856 * More fixes to namespace handling. It was a mess! Now all
5845 explicit references to __main__.__dict__ are gone (except when
5857 explicit references to __main__.__dict__ are gone (except when
5846 really needed) and everything is handled through the namespace
5858 really needed) and everything is handled through the namespace
5847 dicts in the IPython instance. We seem to be getting somewhere
5859 dicts in the IPython instance. We seem to be getting somewhere
5848 with this, finally...
5860 with this, finally...
5849
5861
5850 * Small documentation updates.
5862 * Small documentation updates.
5851
5863
5852 * Created the Extensions directory under IPython (with an
5864 * Created the Extensions directory under IPython (with an
5853 __init__.py). Put the PhysicalQ stuff there. This directory should
5865 __init__.py). Put the PhysicalQ stuff there. This directory should
5854 be used for all special-purpose extensions.
5866 be used for all special-purpose extensions.
5855
5867
5856 * File renaming:
5868 * File renaming:
5857 ipythonlib --> ipmaker
5869 ipythonlib --> ipmaker
5858 ipplib --> iplib
5870 ipplib --> iplib
5859 This makes a bit more sense in terms of what these files actually do.
5871 This makes a bit more sense in terms of what these files actually do.
5860
5872
5861 * Moved all the classes and functions in ipythonlib to ipplib, so
5873 * Moved all the classes and functions in ipythonlib to ipplib, so
5862 now ipythonlib only has make_IPython(). This will ease up its
5874 now ipythonlib only has make_IPython(). This will ease up its
5863 splitting in smaller functional chunks later.
5875 splitting in smaller functional chunks later.
5864
5876
5865 * Cleaned up (done, I think) output of @whos. Better column
5877 * Cleaned up (done, I think) output of @whos. Better column
5866 formatting, and now shows str(var) for as much as it can, which is
5878 formatting, and now shows str(var) for as much as it can, which is
5867 typically what one gets with a 'print var'.
5879 typically what one gets with a 'print var'.
5868
5880
5869 2001-12-04 Fernando Perez <fperez@colorado.edu>
5881 2001-12-04 Fernando Perez <fperez@colorado.edu>
5870
5882
5871 * Fixed namespace problems. Now builtin/IPyhton/user names get
5883 * Fixed namespace problems. Now builtin/IPyhton/user names get
5872 properly reported in their namespace. Internal namespace handling
5884 properly reported in their namespace. Internal namespace handling
5873 is finally getting decent (not perfect yet, but much better than
5885 is finally getting decent (not perfect yet, but much better than
5874 the ad-hoc mess we had).
5886 the ad-hoc mess we had).
5875
5887
5876 * Removed -exit option. If people just want to run a python
5888 * Removed -exit option. If people just want to run a python
5877 script, that's what the normal interpreter is for. Less
5889 script, that's what the normal interpreter is for. Less
5878 unnecessary options, less chances for bugs.
5890 unnecessary options, less chances for bugs.
5879
5891
5880 * Added a crash handler which generates a complete post-mortem if
5892 * Added a crash handler which generates a complete post-mortem if
5881 IPython crashes. This will help a lot in tracking bugs down the
5893 IPython crashes. This will help a lot in tracking bugs down the
5882 road.
5894 road.
5883
5895
5884 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
5896 * Fixed nasty bug in auto-evaluation part of prefilter(). Names
5885 which were boud to functions being reassigned would bypass the
5897 which were boud to functions being reassigned would bypass the
5886 logger, breaking the sync of _il with the prompt counter. This
5898 logger, breaking the sync of _il with the prompt counter. This
5887 would then crash IPython later when a new line was logged.
5899 would then crash IPython later when a new line was logged.
5888
5900
5889 2001-12-02 Fernando Perez <fperez@colorado.edu>
5901 2001-12-02 Fernando Perez <fperez@colorado.edu>
5890
5902
5891 * Made IPython a package. This means people don't have to clutter
5903 * Made IPython a package. This means people don't have to clutter
5892 their sys.path with yet another directory. Changed the INSTALL
5904 their sys.path with yet another directory. Changed the INSTALL
5893 file accordingly.
5905 file accordingly.
5894
5906
5895 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
5907 * Cleaned up the output of @who_ls, @who and @whos. @who_ls now
5896 sorts its output (so @who shows it sorted) and @whos formats the
5908 sorts its output (so @who shows it sorted) and @whos formats the
5897 table according to the width of the first column. Nicer, easier to
5909 table according to the width of the first column. Nicer, easier to
5898 read. Todo: write a generic table_format() which takes a list of
5910 read. Todo: write a generic table_format() which takes a list of
5899 lists and prints it nicely formatted, with optional row/column
5911 lists and prints it nicely formatted, with optional row/column
5900 separators and proper padding and justification.
5912 separators and proper padding and justification.
5901
5913
5902 * Released 0.1.20
5914 * Released 0.1.20
5903
5915
5904 * Fixed bug in @log which would reverse the inputcache list (a
5916 * Fixed bug in @log which would reverse the inputcache list (a
5905 copy operation was missing).
5917 copy operation was missing).
5906
5918
5907 * Code cleanup. @config was changed to use page(). Better, since
5919 * Code cleanup. @config was changed to use page(). Better, since
5908 its output is always quite long.
5920 its output is always quite long.
5909
5921
5910 * Itpl is back as a dependency. I was having too many problems
5922 * Itpl is back as a dependency. I was having too many problems
5911 getting the parametric aliases to work reliably, and it's just
5923 getting the parametric aliases to work reliably, and it's just
5912 easier to code weird string operations with it than playing %()s
5924 easier to code weird string operations with it than playing %()s
5913 games. It's only ~6k, so I don't think it's too big a deal.
5925 games. It's only ~6k, so I don't think it's too big a deal.
5914
5926
5915 * Found (and fixed) a very nasty bug with history. !lines weren't
5927 * Found (and fixed) a very nasty bug with history. !lines weren't
5916 getting cached, and the out of sync caches would crash
5928 getting cached, and the out of sync caches would crash
5917 IPython. Fixed it by reorganizing the prefilter/handlers/logger
5929 IPython. Fixed it by reorganizing the prefilter/handlers/logger
5918 division of labor a bit better. Bug fixed, cleaner structure.
5930 division of labor a bit better. Bug fixed, cleaner structure.
5919
5931
5920 2001-12-01 Fernando Perez <fperez@colorado.edu>
5932 2001-12-01 Fernando Perez <fperez@colorado.edu>
5921
5933
5922 * Released 0.1.19
5934 * Released 0.1.19
5923
5935
5924 * Added option -n to @hist to prevent line number printing. Much
5936 * Added option -n to @hist to prevent line number printing. Much
5925 easier to copy/paste code this way.
5937 easier to copy/paste code this way.
5926
5938
5927 * Created global _il to hold the input list. Allows easy
5939 * Created global _il to hold the input list. Allows easy
5928 re-execution of blocks of code by slicing it (inspired by Janko's
5940 re-execution of blocks of code by slicing it (inspired by Janko's
5929 comment on 'macros').
5941 comment on 'macros').
5930
5942
5931 * Small fixes and doc updates.
5943 * Small fixes and doc updates.
5932
5944
5933 * Rewrote @history function (was @h). Renamed it to @hist, @h is
5945 * Rewrote @history function (was @h). Renamed it to @hist, @h is
5934 much too fragile with automagic. Handles properly multi-line
5946 much too fragile with automagic. Handles properly multi-line
5935 statements and takes parameters.
5947 statements and takes parameters.
5936
5948
5937 2001-11-30 Fernando Perez <fperez@colorado.edu>
5949 2001-11-30 Fernando Perez <fperez@colorado.edu>
5938
5950
5939 * Version 0.1.18 released.
5951 * Version 0.1.18 released.
5940
5952
5941 * Fixed nasty namespace bug in initial module imports.
5953 * Fixed nasty namespace bug in initial module imports.
5942
5954
5943 * Added copyright/license notes to all code files (except
5955 * Added copyright/license notes to all code files (except
5944 DPyGetOpt). For the time being, LGPL. That could change.
5956 DPyGetOpt). For the time being, LGPL. That could change.
5945
5957
5946 * Rewrote a much nicer README, updated INSTALL, cleaned up
5958 * Rewrote a much nicer README, updated INSTALL, cleaned up
5947 ipythonrc-* samples.
5959 ipythonrc-* samples.
5948
5960
5949 * Overall code/documentation cleanup. Basically ready for
5961 * Overall code/documentation cleanup. Basically ready for
5950 release. Only remaining thing: licence decision (LGPL?).
5962 release. Only remaining thing: licence decision (LGPL?).
5951
5963
5952 * Converted load_config to a class, ConfigLoader. Now recursion
5964 * Converted load_config to a class, ConfigLoader. Now recursion
5953 control is better organized. Doesn't include the same file twice.
5965 control is better organized. Doesn't include the same file twice.
5954
5966
5955 2001-11-29 Fernando Perez <fperez@colorado.edu>
5967 2001-11-29 Fernando Perez <fperez@colorado.edu>
5956
5968
5957 * Got input history working. Changed output history variables from
5969 * Got input history working. Changed output history variables from
5958 _p to _o so that _i is for input and _o for output. Just cleaner
5970 _p to _o so that _i is for input and _o for output. Just cleaner
5959 convention.
5971 convention.
5960
5972
5961 * Implemented parametric aliases. This pretty much allows the
5973 * Implemented parametric aliases. This pretty much allows the
5962 alias system to offer full-blown shell convenience, I think.
5974 alias system to offer full-blown shell convenience, I think.
5963
5975
5964 * Version 0.1.17 released, 0.1.18 opened.
5976 * Version 0.1.17 released, 0.1.18 opened.
5965
5977
5966 * dot_ipython/ipythonrc (alias): added documentation.
5978 * dot_ipython/ipythonrc (alias): added documentation.
5967 (xcolor): Fixed small bug (xcolors -> xcolor)
5979 (xcolor): Fixed small bug (xcolors -> xcolor)
5968
5980
5969 * Changed the alias system. Now alias is a magic command to define
5981 * Changed the alias system. Now alias is a magic command to define
5970 aliases just like the shell. Rationale: the builtin magics should
5982 aliases just like the shell. Rationale: the builtin magics should
5971 be there for things deeply connected to IPython's
5983 be there for things deeply connected to IPython's
5972 architecture. And this is a much lighter system for what I think
5984 architecture. And this is a much lighter system for what I think
5973 is the really important feature: allowing users to define quickly
5985 is the really important feature: allowing users to define quickly
5974 magics that will do shell things for them, so they can customize
5986 magics that will do shell things for them, so they can customize
5975 IPython easily to match their work habits. If someone is really
5987 IPython easily to match their work habits. If someone is really
5976 desperate to have another name for a builtin alias, they can
5988 desperate to have another name for a builtin alias, they can
5977 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
5989 always use __IP.magic_newname = __IP.magic_oldname. Hackish but
5978 works.
5990 works.
5979
5991
5980 2001-11-28 Fernando Perez <fperez@colorado.edu>
5992 2001-11-28 Fernando Perez <fperez@colorado.edu>
5981
5993
5982 * Changed @file so that it opens the source file at the proper
5994 * Changed @file so that it opens the source file at the proper
5983 line. Since it uses less, if your EDITOR environment is
5995 line. Since it uses less, if your EDITOR environment is
5984 configured, typing v will immediately open your editor of choice
5996 configured, typing v will immediately open your editor of choice
5985 right at the line where the object is defined. Not as quick as
5997 right at the line where the object is defined. Not as quick as
5986 having a direct @edit command, but for all intents and purposes it
5998 having a direct @edit command, but for all intents and purposes it
5987 works. And I don't have to worry about writing @edit to deal with
5999 works. And I don't have to worry about writing @edit to deal with
5988 all the editors, less does that.
6000 all the editors, less does that.
5989
6001
5990 * Version 0.1.16 released, 0.1.17 opened.
6002 * Version 0.1.16 released, 0.1.17 opened.
5991
6003
5992 * Fixed some nasty bugs in the page/page_dumb combo that could
6004 * Fixed some nasty bugs in the page/page_dumb combo that could
5993 crash IPython.
6005 crash IPython.
5994
6006
5995 2001-11-27 Fernando Perez <fperez@colorado.edu>
6007 2001-11-27 Fernando Perez <fperez@colorado.edu>
5996
6008
5997 * Version 0.1.15 released, 0.1.16 opened.
6009 * Version 0.1.15 released, 0.1.16 opened.
5998
6010
5999 * Finally got ? and ?? to work for undefined things: now it's
6011 * Finally got ? and ?? to work for undefined things: now it's
6000 possible to type {}.get? and get information about the get method
6012 possible to type {}.get? and get information about the get method
6001 of dicts, or os.path? even if only os is defined (so technically
6013 of dicts, or os.path? even if only os is defined (so technically
6002 os.path isn't). Works at any level. For example, after import os,
6014 os.path isn't). Works at any level. For example, after import os,
6003 os?, os.path?, os.path.abspath? all work. This is great, took some
6015 os?, os.path?, os.path.abspath? all work. This is great, took some
6004 work in _ofind.
6016 work in _ofind.
6005
6017
6006 * Fixed more bugs with logging. The sanest way to do it was to add
6018 * Fixed more bugs with logging. The sanest way to do it was to add
6007 to @log a 'mode' parameter. Killed two in one shot (this mode
6019 to @log a 'mode' parameter. Killed two in one shot (this mode
6008 option was a request of Janko's). I think it's finally clean
6020 option was a request of Janko's). I think it's finally clean
6009 (famous last words).
6021 (famous last words).
6010
6022
6011 * Added a page_dumb() pager which does a decent job of paging on
6023 * Added a page_dumb() pager which does a decent job of paging on
6012 screen, if better things (like less) aren't available. One less
6024 screen, if better things (like less) aren't available. One less
6013 unix dependency (someday maybe somebody will port this to
6025 unix dependency (someday maybe somebody will port this to
6014 windows).
6026 windows).
6015
6027
6016 * Fixed problem in magic_log: would lock of logging out if log
6028 * Fixed problem in magic_log: would lock of logging out if log
6017 creation failed (because it would still think it had succeeded).
6029 creation failed (because it would still think it had succeeded).
6018
6030
6019 * Improved the page() function using curses to auto-detect screen
6031 * Improved the page() function using curses to auto-detect screen
6020 size. Now it can make a much better decision on whether to print
6032 size. Now it can make a much better decision on whether to print
6021 or page a string. Option screen_length was modified: a value 0
6033 or page a string. Option screen_length was modified: a value 0
6022 means auto-detect, and that's the default now.
6034 means auto-detect, and that's the default now.
6023
6035
6024 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
6036 * Version 0.1.14 released, 0.1.15 opened. I think this is ready to
6025 go out. I'll test it for a few days, then talk to Janko about
6037 go out. I'll test it for a few days, then talk to Janko about
6026 licences and announce it.
6038 licences and announce it.
6027
6039
6028 * Fixed the length of the auto-generated ---> prompt which appears
6040 * Fixed the length of the auto-generated ---> prompt which appears
6029 for auto-parens and auto-quotes. Getting this right isn't trivial,
6041 for auto-parens and auto-quotes. Getting this right isn't trivial,
6030 with all the color escapes, different prompt types and optional
6042 with all the color escapes, different prompt types and optional
6031 separators. But it seems to be working in all the combinations.
6043 separators. But it seems to be working in all the combinations.
6032
6044
6033 2001-11-26 Fernando Perez <fperez@colorado.edu>
6045 2001-11-26 Fernando Perez <fperez@colorado.edu>
6034
6046
6035 * Wrote a regexp filter to get option types from the option names
6047 * Wrote a regexp filter to get option types from the option names
6036 string. This eliminates the need to manually keep two duplicate
6048 string. This eliminates the need to manually keep two duplicate
6037 lists.
6049 lists.
6038
6050
6039 * Removed the unneeded check_option_names. Now options are handled
6051 * Removed the unneeded check_option_names. Now options are handled
6040 in a much saner manner and it's easy to visually check that things
6052 in a much saner manner and it's easy to visually check that things
6041 are ok.
6053 are ok.
6042
6054
6043 * Updated version numbers on all files I modified to carry a
6055 * Updated version numbers on all files I modified to carry a
6044 notice so Janko and Nathan have clear version markers.
6056 notice so Janko and Nathan have clear version markers.
6045
6057
6046 * Updated docstring for ultraTB with my changes. I should send
6058 * Updated docstring for ultraTB with my changes. I should send
6047 this to Nathan.
6059 this to Nathan.
6048
6060
6049 * Lots of small fixes. Ran everything through pychecker again.
6061 * Lots of small fixes. Ran everything through pychecker again.
6050
6062
6051 * Made loading of deep_reload an cmd line option. If it's not too
6063 * Made loading of deep_reload an cmd line option. If it's not too
6052 kosher, now people can just disable it. With -nodeep_reload it's
6064 kosher, now people can just disable it. With -nodeep_reload it's
6053 still available as dreload(), it just won't overwrite reload().
6065 still available as dreload(), it just won't overwrite reload().
6054
6066
6055 * Moved many options to the no| form (-opt and -noopt
6067 * Moved many options to the no| form (-opt and -noopt
6056 accepted). Cleaner.
6068 accepted). Cleaner.
6057
6069
6058 * Changed magic_log so that if called with no parameters, it uses
6070 * Changed magic_log so that if called with no parameters, it uses
6059 'rotate' mode. That way auto-generated logs aren't automatically
6071 'rotate' mode. That way auto-generated logs aren't automatically
6060 over-written. For normal logs, now a backup is made if it exists
6072 over-written. For normal logs, now a backup is made if it exists
6061 (only 1 level of backups). A new 'backup' mode was added to the
6073 (only 1 level of backups). A new 'backup' mode was added to the
6062 Logger class to support this. This was a request by Janko.
6074 Logger class to support this. This was a request by Janko.
6063
6075
6064 * Added @logoff/@logon to stop/restart an active log.
6076 * Added @logoff/@logon to stop/restart an active log.
6065
6077
6066 * Fixed a lot of bugs in log saving/replay. It was pretty
6078 * Fixed a lot of bugs in log saving/replay. It was pretty
6067 broken. Now special lines (!@,/) appear properly in the command
6079 broken. Now special lines (!@,/) appear properly in the command
6068 history after a log replay.
6080 history after a log replay.
6069
6081
6070 * Tried and failed to implement full session saving via pickle. My
6082 * Tried and failed to implement full session saving via pickle. My
6071 idea was to pickle __main__.__dict__, but modules can't be
6083 idea was to pickle __main__.__dict__, but modules can't be
6072 pickled. This would be a better alternative to replaying logs, but
6084 pickled. This would be a better alternative to replaying logs, but
6073 seems quite tricky to get to work. Changed -session to be called
6085 seems quite tricky to get to work. Changed -session to be called
6074 -logplay, which more accurately reflects what it does. And if we
6086 -logplay, which more accurately reflects what it does. And if we
6075 ever get real session saving working, -session is now available.
6087 ever get real session saving working, -session is now available.
6076
6088
6077 * Implemented color schemes for prompts also. As for tracebacks,
6089 * Implemented color schemes for prompts also. As for tracebacks,
6078 currently only NoColor and Linux are supported. But now the
6090 currently only NoColor and Linux are supported. But now the
6079 infrastructure is in place, based on a generic ColorScheme
6091 infrastructure is in place, based on a generic ColorScheme
6080 class. So writing and activating new schemes both for the prompts
6092 class. So writing and activating new schemes both for the prompts
6081 and the tracebacks should be straightforward.
6093 and the tracebacks should be straightforward.
6082
6094
6083 * Version 0.1.13 released, 0.1.14 opened.
6095 * Version 0.1.13 released, 0.1.14 opened.
6084
6096
6085 * Changed handling of options for output cache. Now counter is
6097 * Changed handling of options for output cache. Now counter is
6086 hardwired starting at 1 and one specifies the maximum number of
6098 hardwired starting at 1 and one specifies the maximum number of
6087 entries *in the outcache* (not the max prompt counter). This is
6099 entries *in the outcache* (not the max prompt counter). This is
6088 much better, since many statements won't increase the cache
6100 much better, since many statements won't increase the cache
6089 count. It also eliminated some confusing options, now there's only
6101 count. It also eliminated some confusing options, now there's only
6090 one: cache_size.
6102 one: cache_size.
6091
6103
6092 * Added 'alias' magic function and magic_alias option in the
6104 * Added 'alias' magic function and magic_alias option in the
6093 ipythonrc file. Now the user can easily define whatever names he
6105 ipythonrc file. Now the user can easily define whatever names he
6094 wants for the magic functions without having to play weird
6106 wants for the magic functions without having to play weird
6095 namespace games. This gives IPython a real shell-like feel.
6107 namespace games. This gives IPython a real shell-like feel.
6096
6108
6097 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
6109 * Fixed doc/?/?? for magics. Now all work, in all forms (explicit
6098 @ or not).
6110 @ or not).
6099
6111
6100 This was one of the last remaining 'visible' bugs (that I know
6112 This was one of the last remaining 'visible' bugs (that I know
6101 of). I think if I can clean up the session loading so it works
6113 of). I think if I can clean up the session loading so it works
6102 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
6114 100% I'll release a 0.2.0 version on c.p.l (talk to Janko first
6103 about licensing).
6115 about licensing).
6104
6116
6105 2001-11-25 Fernando Perez <fperez@colorado.edu>
6117 2001-11-25 Fernando Perez <fperez@colorado.edu>
6106
6118
6107 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
6119 * Rewrote somewhat oinfo (?/??). Nicer, now uses page() and
6108 there's a cleaner distinction between what ? and ?? show.
6120 there's a cleaner distinction between what ? and ?? show.
6109
6121
6110 * Added screen_length option. Now the user can define his own
6122 * Added screen_length option. Now the user can define his own
6111 screen size for page() operations.
6123 screen size for page() operations.
6112
6124
6113 * Implemented magic shell-like functions with automatic code
6125 * Implemented magic shell-like functions with automatic code
6114 generation. Now adding another function is just a matter of adding
6126 generation. Now adding another function is just a matter of adding
6115 an entry to a dict, and the function is dynamically generated at
6127 an entry to a dict, and the function is dynamically generated at
6116 run-time. Python has some really cool features!
6128 run-time. Python has some really cool features!
6117
6129
6118 * Renamed many options to cleanup conventions a little. Now all
6130 * Renamed many options to cleanup conventions a little. Now all
6119 are lowercase, and only underscores where needed. Also in the code
6131 are lowercase, and only underscores where needed. Also in the code
6120 option name tables are clearer.
6132 option name tables are clearer.
6121
6133
6122 * Changed prompts a little. Now input is 'In [n]:' instead of
6134 * Changed prompts a little. Now input is 'In [n]:' instead of
6123 'In[n]:='. This allows it the numbers to be aligned with the
6135 'In[n]:='. This allows it the numbers to be aligned with the
6124 Out[n] numbers, and removes usage of ':=' which doesn't exist in
6136 Out[n] numbers, and removes usage of ':=' which doesn't exist in
6125 Python (it was a Mathematica thing). The '...' continuation prompt
6137 Python (it was a Mathematica thing). The '...' continuation prompt
6126 was also changed a little to align better.
6138 was also changed a little to align better.
6127
6139
6128 * Fixed bug when flushing output cache. Not all _p<n> variables
6140 * Fixed bug when flushing output cache. Not all _p<n> variables
6129 exist, so their deletion needs to be wrapped in a try:
6141 exist, so their deletion needs to be wrapped in a try:
6130
6142
6131 * Figured out how to properly use inspect.formatargspec() (it
6143 * Figured out how to properly use inspect.formatargspec() (it
6132 requires the args preceded by *). So I removed all the code from
6144 requires the args preceded by *). So I removed all the code from
6133 _get_pdef in Magic, which was just replicating that.
6145 _get_pdef in Magic, which was just replicating that.
6134
6146
6135 * Added test to prefilter to allow redefining magic function names
6147 * Added test to prefilter to allow redefining magic function names
6136 as variables. This is ok, since the @ form is always available,
6148 as variables. This is ok, since the @ form is always available,
6137 but whe should allow the user to define a variable called 'ls' if
6149 but whe should allow the user to define a variable called 'ls' if
6138 he needs it.
6150 he needs it.
6139
6151
6140 * Moved the ToDo information from README into a separate ToDo.
6152 * Moved the ToDo information from README into a separate ToDo.
6141
6153
6142 * General code cleanup and small bugfixes. I think it's close to a
6154 * General code cleanup and small bugfixes. I think it's close to a
6143 state where it can be released, obviously with a big 'beta'
6155 state where it can be released, obviously with a big 'beta'
6144 warning on it.
6156 warning on it.
6145
6157
6146 * Got the magic function split to work. Now all magics are defined
6158 * Got the magic function split to work. Now all magics are defined
6147 in a separate class. It just organizes things a bit, and now
6159 in a separate class. It just organizes things a bit, and now
6148 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
6160 Xemacs behaves nicer (it was choking on InteractiveShell b/c it
6149 was too long).
6161 was too long).
6150
6162
6151 * Changed @clear to @reset to avoid potential confusions with
6163 * Changed @clear to @reset to avoid potential confusions with
6152 the shell command clear. Also renamed @cl to @clear, which does
6164 the shell command clear. Also renamed @cl to @clear, which does
6153 exactly what people expect it to from their shell experience.
6165 exactly what people expect it to from their shell experience.
6154
6166
6155 Added a check to the @reset command (since it's so
6167 Added a check to the @reset command (since it's so
6156 destructive, it's probably a good idea to ask for confirmation).
6168 destructive, it's probably a good idea to ask for confirmation).
6157 But now reset only works for full namespace resetting. Since the
6169 But now reset only works for full namespace resetting. Since the
6158 del keyword is already there for deleting a few specific
6170 del keyword is already there for deleting a few specific
6159 variables, I don't see the point of having a redundant magic
6171 variables, I don't see the point of having a redundant magic
6160 function for the same task.
6172 function for the same task.
6161
6173
6162 2001-11-24 Fernando Perez <fperez@colorado.edu>
6174 2001-11-24 Fernando Perez <fperez@colorado.edu>
6163
6175
6164 * Updated the builtin docs (esp. the ? ones).
6176 * Updated the builtin docs (esp. the ? ones).
6165
6177
6166 * Ran all the code through pychecker. Not terribly impressed with
6178 * Ran all the code through pychecker. Not terribly impressed with
6167 it: lots of spurious warnings and didn't really find anything of
6179 it: lots of spurious warnings and didn't really find anything of
6168 substance (just a few modules being imported and not used).
6180 substance (just a few modules being imported and not used).
6169
6181
6170 * Implemented the new ultraTB functionality into IPython. New
6182 * Implemented the new ultraTB functionality into IPython. New
6171 option: xcolors. This chooses color scheme. xmode now only selects
6183 option: xcolors. This chooses color scheme. xmode now only selects
6172 between Plain and Verbose. Better orthogonality.
6184 between Plain and Verbose. Better orthogonality.
6173
6185
6174 * Large rewrite of ultraTB. Much cleaner now, with a separation of
6186 * Large rewrite of ultraTB. Much cleaner now, with a separation of
6175 mode and color scheme for the exception handlers. Now it's
6187 mode and color scheme for the exception handlers. Now it's
6176 possible to have the verbose traceback with no coloring.
6188 possible to have the verbose traceback with no coloring.
6177
6189
6178 2001-11-23 Fernando Perez <fperez@colorado.edu>
6190 2001-11-23 Fernando Perez <fperez@colorado.edu>
6179
6191
6180 * Version 0.1.12 released, 0.1.13 opened.
6192 * Version 0.1.12 released, 0.1.13 opened.
6181
6193
6182 * Removed option to set auto-quote and auto-paren escapes by
6194 * Removed option to set auto-quote and auto-paren escapes by
6183 user. The chances of breaking valid syntax are just too high. If
6195 user. The chances of breaking valid syntax are just too high. If
6184 someone *really* wants, they can always dig into the code.
6196 someone *really* wants, they can always dig into the code.
6185
6197
6186 * Made prompt separators configurable.
6198 * Made prompt separators configurable.
6187
6199
6188 2001-11-22 Fernando Perez <fperez@colorado.edu>
6200 2001-11-22 Fernando Perez <fperez@colorado.edu>
6189
6201
6190 * Small bugfixes in many places.
6202 * Small bugfixes in many places.
6191
6203
6192 * Removed the MyCompleter class from ipplib. It seemed redundant
6204 * Removed the MyCompleter class from ipplib. It seemed redundant
6193 with the C-p,C-n history search functionality. Less code to
6205 with the C-p,C-n history search functionality. Less code to
6194 maintain.
6206 maintain.
6195
6207
6196 * Moved all the original ipython.py code into ipythonlib.py. Right
6208 * Moved all the original ipython.py code into ipythonlib.py. Right
6197 now it's just one big dump into a function called make_IPython, so
6209 now it's just one big dump into a function called make_IPython, so
6198 no real modularity has been gained. But at least it makes the
6210 no real modularity has been gained. But at least it makes the
6199 wrapper script tiny, and since ipythonlib is a module, it gets
6211 wrapper script tiny, and since ipythonlib is a module, it gets
6200 compiled and startup is much faster.
6212 compiled and startup is much faster.
6201
6213
6202 This is a reasobably 'deep' change, so we should test it for a
6214 This is a reasobably 'deep' change, so we should test it for a
6203 while without messing too much more with the code.
6215 while without messing too much more with the code.
6204
6216
6205 2001-11-21 Fernando Perez <fperez@colorado.edu>
6217 2001-11-21 Fernando Perez <fperez@colorado.edu>
6206
6218
6207 * Version 0.1.11 released, 0.1.12 opened for further work.
6219 * Version 0.1.11 released, 0.1.12 opened for further work.
6208
6220
6209 * Removed dependency on Itpl. It was only needed in one place. It
6221 * Removed dependency on Itpl. It was only needed in one place. It
6210 would be nice if this became part of python, though. It makes life
6222 would be nice if this became part of python, though. It makes life
6211 *a lot* easier in some cases.
6223 *a lot* easier in some cases.
6212
6224
6213 * Simplified the prefilter code a bit. Now all handlers are
6225 * Simplified the prefilter code a bit. Now all handlers are
6214 expected to explicitly return a value (at least a blank string).
6226 expected to explicitly return a value (at least a blank string).
6215
6227
6216 * Heavy edits in ipplib. Removed the help system altogether. Now
6228 * Heavy edits in ipplib. Removed the help system altogether. Now
6217 obj?/?? is used for inspecting objects, a magic @doc prints
6229 obj?/?? is used for inspecting objects, a magic @doc prints
6218 docstrings, and full-blown Python help is accessed via the 'help'
6230 docstrings, and full-blown Python help is accessed via the 'help'
6219 keyword. This cleans up a lot of code (less to maintain) and does
6231 keyword. This cleans up a lot of code (less to maintain) and does
6220 the job. Since 'help' is now a standard Python component, might as
6232 the job. Since 'help' is now a standard Python component, might as
6221 well use it and remove duplicate functionality.
6233 well use it and remove duplicate functionality.
6222
6234
6223 Also removed the option to use ipplib as a standalone program. By
6235 Also removed the option to use ipplib as a standalone program. By
6224 now it's too dependent on other parts of IPython to function alone.
6236 now it's too dependent on other parts of IPython to function alone.
6225
6237
6226 * Fixed bug in genutils.pager. It would crash if the pager was
6238 * Fixed bug in genutils.pager. It would crash if the pager was
6227 exited immediately after opening (broken pipe).
6239 exited immediately after opening (broken pipe).
6228
6240
6229 * Trimmed down the VerboseTB reporting a little. The header is
6241 * Trimmed down the VerboseTB reporting a little. The header is
6230 much shorter now and the repeated exception arguments at the end
6242 much shorter now and the repeated exception arguments at the end
6231 have been removed. For interactive use the old header seemed a bit
6243 have been removed. For interactive use the old header seemed a bit
6232 excessive.
6244 excessive.
6233
6245
6234 * Fixed small bug in output of @whos for variables with multi-word
6246 * Fixed small bug in output of @whos for variables with multi-word
6235 types (only first word was displayed).
6247 types (only first word was displayed).
6236
6248
6237 2001-11-17 Fernando Perez <fperez@colorado.edu>
6249 2001-11-17 Fernando Perez <fperez@colorado.edu>
6238
6250
6239 * Version 0.1.10 released, 0.1.11 opened for further work.
6251 * Version 0.1.10 released, 0.1.11 opened for further work.
6240
6252
6241 * Modified dirs and friends. dirs now *returns* the stack (not
6253 * Modified dirs and friends. dirs now *returns* the stack (not
6242 prints), so one can manipulate it as a variable. Convenient to
6254 prints), so one can manipulate it as a variable. Convenient to
6243 travel along many directories.
6255 travel along many directories.
6244
6256
6245 * Fixed bug in magic_pdef: would only work with functions with
6257 * Fixed bug in magic_pdef: would only work with functions with
6246 arguments with default values.
6258 arguments with default values.
6247
6259
6248 2001-11-14 Fernando Perez <fperez@colorado.edu>
6260 2001-11-14 Fernando Perez <fperez@colorado.edu>
6249
6261
6250 * Added the PhysicsInput stuff to dot_ipython so it ships as an
6262 * Added the PhysicsInput stuff to dot_ipython so it ships as an
6251 example with IPython. Various other minor fixes and cleanups.
6263 example with IPython. Various other minor fixes and cleanups.
6252
6264
6253 * Version 0.1.9 released, 0.1.10 opened for further work.
6265 * Version 0.1.9 released, 0.1.10 opened for further work.
6254
6266
6255 * Added sys.path to the list of directories searched in the
6267 * Added sys.path to the list of directories searched in the
6256 execfile= option. It used to be the current directory and the
6268 execfile= option. It used to be the current directory and the
6257 user's IPYTHONDIR only.
6269 user's IPYTHONDIR only.
6258
6270
6259 2001-11-13 Fernando Perez <fperez@colorado.edu>
6271 2001-11-13 Fernando Perez <fperez@colorado.edu>
6260
6272
6261 * Reinstated the raw_input/prefilter separation that Janko had
6273 * Reinstated the raw_input/prefilter separation that Janko had
6262 initially. This gives a more convenient setup for extending the
6274 initially. This gives a more convenient setup for extending the
6263 pre-processor from the outside: raw_input always gets a string,
6275 pre-processor from the outside: raw_input always gets a string,
6264 and prefilter has to process it. We can then redefine prefilter
6276 and prefilter has to process it. We can then redefine prefilter
6265 from the outside and implement extensions for special
6277 from the outside and implement extensions for special
6266 purposes.
6278 purposes.
6267
6279
6268 Today I got one for inputting PhysicalQuantity objects
6280 Today I got one for inputting PhysicalQuantity objects
6269 (from Scientific) without needing any function calls at
6281 (from Scientific) without needing any function calls at
6270 all. Extremely convenient, and it's all done as a user-level
6282 all. Extremely convenient, and it's all done as a user-level
6271 extension (no IPython code was touched). Now instead of:
6283 extension (no IPython code was touched). Now instead of:
6272 a = PhysicalQuantity(4.2,'m/s**2')
6284 a = PhysicalQuantity(4.2,'m/s**2')
6273 one can simply say
6285 one can simply say
6274 a = 4.2 m/s**2
6286 a = 4.2 m/s**2
6275 or even
6287 or even
6276 a = 4.2 m/s^2
6288 a = 4.2 m/s^2
6277
6289
6278 I use this, but it's also a proof of concept: IPython really is
6290 I use this, but it's also a proof of concept: IPython really is
6279 fully user-extensible, even at the level of the parsing of the
6291 fully user-extensible, even at the level of the parsing of the
6280 command line. It's not trivial, but it's perfectly doable.
6292 command line. It's not trivial, but it's perfectly doable.
6281
6293
6282 * Added 'add_flip' method to inclusion conflict resolver. Fixes
6294 * Added 'add_flip' method to inclusion conflict resolver. Fixes
6283 the problem of modules being loaded in the inverse order in which
6295 the problem of modules being loaded in the inverse order in which
6284 they were defined in
6296 they were defined in
6285
6297
6286 * Version 0.1.8 released, 0.1.9 opened for further work.
6298 * Version 0.1.8 released, 0.1.9 opened for further work.
6287
6299
6288 * Added magics pdef, source and file. They respectively show the
6300 * Added magics pdef, source and file. They respectively show the
6289 definition line ('prototype' in C), source code and full python
6301 definition line ('prototype' in C), source code and full python
6290 file for any callable object. The object inspector oinfo uses
6302 file for any callable object. The object inspector oinfo uses
6291 these to show the same information.
6303 these to show the same information.
6292
6304
6293 * Version 0.1.7 released, 0.1.8 opened for further work.
6305 * Version 0.1.7 released, 0.1.8 opened for further work.
6294
6306
6295 * Separated all the magic functions into a class called Magic. The
6307 * Separated all the magic functions into a class called Magic. The
6296 InteractiveShell class was becoming too big for Xemacs to handle
6308 InteractiveShell class was becoming too big for Xemacs to handle
6297 (de-indenting a line would lock it up for 10 seconds while it
6309 (de-indenting a line would lock it up for 10 seconds while it
6298 backtracked on the whole class!)
6310 backtracked on the whole class!)
6299
6311
6300 FIXME: didn't work. It can be done, but right now namespaces are
6312 FIXME: didn't work. It can be done, but right now namespaces are
6301 all messed up. Do it later (reverted it for now, so at least
6313 all messed up. Do it later (reverted it for now, so at least
6302 everything works as before).
6314 everything works as before).
6303
6315
6304 * Got the object introspection system (magic_oinfo) working! I
6316 * Got the object introspection system (magic_oinfo) working! I
6305 think this is pretty much ready for release to Janko, so he can
6317 think this is pretty much ready for release to Janko, so he can
6306 test it for a while and then announce it. Pretty much 100% of what
6318 test it for a while and then announce it. Pretty much 100% of what
6307 I wanted for the 'phase 1' release is ready. Happy, tired.
6319 I wanted for the 'phase 1' release is ready. Happy, tired.
6308
6320
6309 2001-11-12 Fernando Perez <fperez@colorado.edu>
6321 2001-11-12 Fernando Perez <fperez@colorado.edu>
6310
6322
6311 * Version 0.1.6 released, 0.1.7 opened for further work.
6323 * Version 0.1.6 released, 0.1.7 opened for further work.
6312
6324
6313 * Fixed bug in printing: it used to test for truth before
6325 * Fixed bug in printing: it used to test for truth before
6314 printing, so 0 wouldn't print. Now checks for None.
6326 printing, so 0 wouldn't print. Now checks for None.
6315
6327
6316 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
6328 * Fixed bug where auto-execs increase the prompt counter by 2 (b/c
6317 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
6329 they have to call len(str(sys.ps1)) ). But the fix is ugly, it
6318 reaches by hand into the outputcache. Think of a better way to do
6330 reaches by hand into the outputcache. Think of a better way to do
6319 this later.
6331 this later.
6320
6332
6321 * Various small fixes thanks to Nathan's comments.
6333 * Various small fixes thanks to Nathan's comments.
6322
6334
6323 * Changed magic_pprint to magic_Pprint. This way it doesn't
6335 * Changed magic_pprint to magic_Pprint. This way it doesn't
6324 collide with pprint() and the name is consistent with the command
6336 collide with pprint() and the name is consistent with the command
6325 line option.
6337 line option.
6326
6338
6327 * Changed prompt counter behavior to be fully like
6339 * Changed prompt counter behavior to be fully like
6328 Mathematica's. That is, even input that doesn't return a result
6340 Mathematica's. That is, even input that doesn't return a result
6329 raises the prompt counter. The old behavior was kind of confusing
6341 raises the prompt counter. The old behavior was kind of confusing
6330 (getting the same prompt number several times if the operation
6342 (getting the same prompt number several times if the operation
6331 didn't return a result).
6343 didn't return a result).
6332
6344
6333 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
6345 * Fixed Nathan's last name in a couple of places (Gray, not Graham).
6334
6346
6335 * Fixed -Classic mode (wasn't working anymore).
6347 * Fixed -Classic mode (wasn't working anymore).
6336
6348
6337 * Added colored prompts using Nathan's new code. Colors are
6349 * Added colored prompts using Nathan's new code. Colors are
6338 currently hardwired, they can be user-configurable. For
6350 currently hardwired, they can be user-configurable. For
6339 developers, they can be chosen in file ipythonlib.py, at the
6351 developers, they can be chosen in file ipythonlib.py, at the
6340 beginning of the CachedOutput class def.
6352 beginning of the CachedOutput class def.
6341
6353
6342 2001-11-11 Fernando Perez <fperez@colorado.edu>
6354 2001-11-11 Fernando Perez <fperez@colorado.edu>
6343
6355
6344 * Version 0.1.5 released, 0.1.6 opened for further work.
6356 * Version 0.1.5 released, 0.1.6 opened for further work.
6345
6357
6346 * Changed magic_env to *return* the environment as a dict (not to
6358 * Changed magic_env to *return* the environment as a dict (not to
6347 print it). This way it prints, but it can also be processed.
6359 print it). This way it prints, but it can also be processed.
6348
6360
6349 * Added Verbose exception reporting to interactive
6361 * Added Verbose exception reporting to interactive
6350 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
6362 exceptions. Very nice, now even 1/0 at the prompt gives a verbose
6351 traceback. Had to make some changes to the ultraTB file. This is
6363 traceback. Had to make some changes to the ultraTB file. This is
6352 probably the last 'big' thing in my mental todo list. This ties
6364 probably the last 'big' thing in my mental todo list. This ties
6353 in with the next entry:
6365 in with the next entry:
6354
6366
6355 * Changed -Xi and -Xf to a single -xmode option. Now all the user
6367 * Changed -Xi and -Xf to a single -xmode option. Now all the user
6356 has to specify is Plain, Color or Verbose for all exception
6368 has to specify is Plain, Color or Verbose for all exception
6357 handling.
6369 handling.
6358
6370
6359 * Removed ShellServices option. All this can really be done via
6371 * Removed ShellServices option. All this can really be done via
6360 the magic system. It's easier to extend, cleaner and has automatic
6372 the magic system. It's easier to extend, cleaner and has automatic
6361 namespace protection and documentation.
6373 namespace protection and documentation.
6362
6374
6363 2001-11-09 Fernando Perez <fperez@colorado.edu>
6375 2001-11-09 Fernando Perez <fperez@colorado.edu>
6364
6376
6365 * Fixed bug in output cache flushing (missing parameter to
6377 * Fixed bug in output cache flushing (missing parameter to
6366 __init__). Other small bugs fixed (found using pychecker).
6378 __init__). Other small bugs fixed (found using pychecker).
6367
6379
6368 * Version 0.1.4 opened for bugfixing.
6380 * Version 0.1.4 opened for bugfixing.
6369
6381
6370 2001-11-07 Fernando Perez <fperez@colorado.edu>
6382 2001-11-07 Fernando Perez <fperez@colorado.edu>
6371
6383
6372 * Version 0.1.3 released, mainly because of the raw_input bug.
6384 * Version 0.1.3 released, mainly because of the raw_input bug.
6373
6385
6374 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
6386 * Fixed NASTY bug in raw_input: input line wasn't properly parsed
6375 and when testing for whether things were callable, a call could
6387 and when testing for whether things were callable, a call could
6376 actually be made to certain functions. They would get called again
6388 actually be made to certain functions. They would get called again
6377 once 'really' executed, with a resulting double call. A disaster
6389 once 'really' executed, with a resulting double call. A disaster
6378 in many cases (list.reverse() would never work!).
6390 in many cases (list.reverse() would never work!).
6379
6391
6380 * Removed prefilter() function, moved its code to raw_input (which
6392 * Removed prefilter() function, moved its code to raw_input (which
6381 after all was just a near-empty caller for prefilter). This saves
6393 after all was just a near-empty caller for prefilter). This saves
6382 a function call on every prompt, and simplifies the class a tiny bit.
6394 a function call on every prompt, and simplifies the class a tiny bit.
6383
6395
6384 * Fix _ip to __ip name in magic example file.
6396 * Fix _ip to __ip name in magic example file.
6385
6397
6386 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
6398 * Changed 'tar -x -f' to 'tar xvf' in auto-installer. This should
6387 work with non-gnu versions of tar.
6399 work with non-gnu versions of tar.
6388
6400
6389 2001-11-06 Fernando Perez <fperez@colorado.edu>
6401 2001-11-06 Fernando Perez <fperez@colorado.edu>
6390
6402
6391 * Version 0.1.2. Just to keep track of the recent changes.
6403 * Version 0.1.2. Just to keep track of the recent changes.
6392
6404
6393 * Fixed nasty bug in output prompt routine. It used to check 'if
6405 * Fixed nasty bug in output prompt routine. It used to check 'if
6394 arg != None...'. Problem is, this fails if arg implements a
6406 arg != None...'. Problem is, this fails if arg implements a
6395 special comparison (__cmp__) which disallows comparing to
6407 special comparison (__cmp__) which disallows comparing to
6396 None. Found it when trying to use the PhysicalQuantity module from
6408 None. Found it when trying to use the PhysicalQuantity module from
6397 ScientificPython.
6409 ScientificPython.
6398
6410
6399 2001-11-05 Fernando Perez <fperez@colorado.edu>
6411 2001-11-05 Fernando Perez <fperez@colorado.edu>
6400
6412
6401 * Also added dirs. Now the pushd/popd/dirs family functions
6413 * Also added dirs. Now the pushd/popd/dirs family functions
6402 basically like the shell, with the added convenience of going home
6414 basically like the shell, with the added convenience of going home
6403 when called with no args.
6415 when called with no args.
6404
6416
6405 * pushd/popd slightly modified to mimic shell behavior more
6417 * pushd/popd slightly modified to mimic shell behavior more
6406 closely.
6418 closely.
6407
6419
6408 * Added env,pushd,popd from ShellServices as magic functions. I
6420 * Added env,pushd,popd from ShellServices as magic functions. I
6409 think the cleanest will be to port all desired functions from
6421 think the cleanest will be to port all desired functions from
6410 ShellServices as magics and remove ShellServices altogether. This
6422 ShellServices as magics and remove ShellServices altogether. This
6411 will provide a single, clean way of adding functionality
6423 will provide a single, clean way of adding functionality
6412 (shell-type or otherwise) to IP.
6424 (shell-type or otherwise) to IP.
6413
6425
6414 2001-11-04 Fernando Perez <fperez@colorado.edu>
6426 2001-11-04 Fernando Perez <fperez@colorado.edu>
6415
6427
6416 * Added .ipython/ directory to sys.path. This way users can keep
6428 * Added .ipython/ directory to sys.path. This way users can keep
6417 customizations there and access them via import.
6429 customizations there and access them via import.
6418
6430
6419 2001-11-03 Fernando Perez <fperez@colorado.edu>
6431 2001-11-03 Fernando Perez <fperez@colorado.edu>
6420
6432
6421 * Opened version 0.1.1 for new changes.
6433 * Opened version 0.1.1 for new changes.
6422
6434
6423 * Changed version number to 0.1.0: first 'public' release, sent to
6435 * Changed version number to 0.1.0: first 'public' release, sent to
6424 Nathan and Janko.
6436 Nathan and Janko.
6425
6437
6426 * Lots of small fixes and tweaks.
6438 * Lots of small fixes and tweaks.
6427
6439
6428 * Minor changes to whos format. Now strings are shown, snipped if
6440 * Minor changes to whos format. Now strings are shown, snipped if
6429 too long.
6441 too long.
6430
6442
6431 * Changed ShellServices to work on __main__ so they show up in @who
6443 * Changed ShellServices to work on __main__ so they show up in @who
6432
6444
6433 * Help also works with ? at the end of a line:
6445 * Help also works with ? at the end of a line:
6434 ?sin and sin?
6446 ?sin and sin?
6435 both produce the same effect. This is nice, as often I use the
6447 both produce the same effect. This is nice, as often I use the
6436 tab-complete to find the name of a method, but I used to then have
6448 tab-complete to find the name of a method, but I used to then have
6437 to go to the beginning of the line to put a ? if I wanted more
6449 to go to the beginning of the line to put a ? if I wanted more
6438 info. Now I can just add the ? and hit return. Convenient.
6450 info. Now I can just add the ? and hit return. Convenient.
6439
6451
6440 2001-11-02 Fernando Perez <fperez@colorado.edu>
6452 2001-11-02 Fernando Perez <fperez@colorado.edu>
6441
6453
6442 * Python version check (>=2.1) added.
6454 * Python version check (>=2.1) added.
6443
6455
6444 * Added LazyPython documentation. At this point the docs are quite
6456 * Added LazyPython documentation. At this point the docs are quite
6445 a mess. A cleanup is in order.
6457 a mess. A cleanup is in order.
6446
6458
6447 * Auto-installer created. For some bizarre reason, the zipfiles
6459 * Auto-installer created. For some bizarre reason, the zipfiles
6448 module isn't working on my system. So I made a tar version
6460 module isn't working on my system. So I made a tar version
6449 (hopefully the command line options in various systems won't kill
6461 (hopefully the command line options in various systems won't kill
6450 me).
6462 me).
6451
6463
6452 * Fixes to Struct in genutils. Now all dictionary-like methods are
6464 * Fixes to Struct in genutils. Now all dictionary-like methods are
6453 protected (reasonably).
6465 protected (reasonably).
6454
6466
6455 * Added pager function to genutils and changed ? to print usage
6467 * Added pager function to genutils and changed ? to print usage
6456 note through it (it was too long).
6468 note through it (it was too long).
6457
6469
6458 * Added the LazyPython functionality. Works great! I changed the
6470 * Added the LazyPython functionality. Works great! I changed the
6459 auto-quote escape to ';', it's on home row and next to '. But
6471 auto-quote escape to ';', it's on home row and next to '. But
6460 both auto-quote and auto-paren (still /) escapes are command-line
6472 both auto-quote and auto-paren (still /) escapes are command-line
6461 parameters.
6473 parameters.
6462
6474
6463
6475
6464 2001-11-01 Fernando Perez <fperez@colorado.edu>
6476 2001-11-01 Fernando Perez <fperez@colorado.edu>
6465
6477
6466 * Version changed to 0.0.7. Fairly large change: configuration now
6478 * Version changed to 0.0.7. Fairly large change: configuration now
6467 is all stored in a directory, by default .ipython. There, all
6479 is all stored in a directory, by default .ipython. There, all
6468 config files have normal looking names (not .names)
6480 config files have normal looking names (not .names)
6469
6481
6470 * Version 0.0.6 Released first to Lucas and Archie as a test
6482 * Version 0.0.6 Released first to Lucas and Archie as a test
6471 run. Since it's the first 'semi-public' release, change version to
6483 run. Since it's the first 'semi-public' release, change version to
6472 > 0.0.6 for any changes now.
6484 > 0.0.6 for any changes now.
6473
6485
6474 * Stuff I had put in the ipplib.py changelog:
6486 * Stuff I had put in the ipplib.py changelog:
6475
6487
6476 Changes to InteractiveShell:
6488 Changes to InteractiveShell:
6477
6489
6478 - Made the usage message a parameter.
6490 - Made the usage message a parameter.
6479
6491
6480 - Require the name of the shell variable to be given. It's a bit
6492 - Require the name of the shell variable to be given. It's a bit
6481 of a hack, but allows the name 'shell' not to be hardwired in the
6493 of a hack, but allows the name 'shell' not to be hardwired in the
6482 magic (@) handler, which is problematic b/c it requires
6494 magic (@) handler, which is problematic b/c it requires
6483 polluting the global namespace with 'shell'. This in turn is
6495 polluting the global namespace with 'shell'. This in turn is
6484 fragile: if a user redefines a variable called shell, things
6496 fragile: if a user redefines a variable called shell, things
6485 break.
6497 break.
6486
6498
6487 - magic @: all functions available through @ need to be defined
6499 - magic @: all functions available through @ need to be defined
6488 as magic_<name>, even though they can be called simply as
6500 as magic_<name>, even though they can be called simply as
6489 @<name>. This allows the special command @magic to gather
6501 @<name>. This allows the special command @magic to gather
6490 information automatically about all existing magic functions,
6502 information automatically about all existing magic functions,
6491 even if they are run-time user extensions, by parsing the shell
6503 even if they are run-time user extensions, by parsing the shell
6492 instance __dict__ looking for special magic_ names.
6504 instance __dict__ looking for special magic_ names.
6493
6505
6494 - mainloop: added *two* local namespace parameters. This allows
6506 - mainloop: added *two* local namespace parameters. This allows
6495 the class to differentiate between parameters which were there
6507 the class to differentiate between parameters which were there
6496 before and after command line initialization was processed. This
6508 before and after command line initialization was processed. This
6497 way, later @who can show things loaded at startup by the
6509 way, later @who can show things loaded at startup by the
6498 user. This trick was necessary to make session saving/reloading
6510 user. This trick was necessary to make session saving/reloading
6499 really work: ideally after saving/exiting/reloading a session,
6511 really work: ideally after saving/exiting/reloading a session,
6500 *everything* should look the same, including the output of @who. I
6512 *everything* should look the same, including the output of @who. I
6501 was only able to make this work with this double namespace
6513 was only able to make this work with this double namespace
6502 trick.
6514 trick.
6503
6515
6504 - added a header to the logfile which allows (almost) full
6516 - added a header to the logfile which allows (almost) full
6505 session restoring.
6517 session restoring.
6506
6518
6507 - prepend lines beginning with @ or !, with a and log
6519 - prepend lines beginning with @ or !, with a and log
6508 them. Why? !lines: may be useful to know what you did @lines:
6520 them. Why? !lines: may be useful to know what you did @lines:
6509 they may affect session state. So when restoring a session, at
6521 they may affect session state. So when restoring a session, at
6510 least inform the user of their presence. I couldn't quite get
6522 least inform the user of their presence. I couldn't quite get
6511 them to properly re-execute, but at least the user is warned.
6523 them to properly re-execute, but at least the user is warned.
6512
6524
6513 * Started ChangeLog.
6525 * Started ChangeLog.
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
General Comments 0
You need to be logged in to leave comments. Login now